Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- PositionManagerAux
- Optimization enabled
- true
- Compiler version
- v0.7.6+commit.7338295f
- Optimization runs
- 1
- EVM Version
- default
- Verified at
- 2023-12-18T14:42:32.644138Z
contracts/libraries/PositionManagerAux.sol
// SPDX-License-Identifier: MIT pragma solidity =0.7.6; pragma abicoder v2; import "contracts/interfaces/IEquilibreV2Pool.sol"; import "contracts/libraries/FixedPoint128.sol"; import "contracts/libraries/FullMath7.sol"; import "contracts/interfaces/INonfungiblePositionManager7.sol"; import "./PositionKey.sol"; /// @dev Splitting the contract because it's over the max code size library PositionManagerAux { /// @notice Emitted when liquidity is decreased for a position NFT /// @param tokenId The ID of the token for which liquidity was decreased /// @param liquidity The amount by which liquidity for the NFT position was decreased /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when tokens are collected for a position NFT /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior /// @param tokenId The ID of the token for which underlying tokens were collected /// @param recipient The address of the account that received the collected tokens /// @param amount0 The amount of token0 owed to the position that was collected /// @param amount1 The amount of token1 owed to the position that was collected event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); /// @notice Emitted when the attachment of an NFP is switched to a different veVara NFT. /// @param tokenId The identifier of the NFP for which the attachment is switched. /// @param oldVeVaraTokenId The identifier of the previous veVara NFT to which the NFP was attached. /// @param newVeVaraTokenId The identifier of the new veVara NFT to which the NFP was attached. event SwitchAttachment(uint256 indexed tokenId, uint256 oldVeVaraTokenId, uint256 newVeVaraTokenId); function decreaseLiquidity( INonfungiblePositionManager.Position storage position, IEquilibreV2Pool pool, INonfungiblePositionManager.DecreaseLiquidityParams calldata params ) external returns (uint256 amount0, uint256 amount1) { require(params.liquidity > 0, "L0"); uint128 positionLiquidity = position.liquidity; require(positionLiquidity >= params.liquidity, "pLl"); (amount0, amount1) = pool.burn(params.tokenId, position.tickLower, position.tickUpper, params.liquidity, position.veVaraTokenId); require(amount0 >= params.amount0Min && amount1 >= params.amount1Min, "PSC"); bytes32 positionKey = PositionKey.compute(address(this), params.tokenId, position.tickLower, position.tickUpper); // this is now updated to the current transaction (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , , ) = pool.positions(positionKey); position.tokensOwed0 += uint128(amount0) + uint128(FullMath7.mulDiv(feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128, positionLiquidity, FixedPoint128.Q128)); position.tokensOwed1 += uint128(amount1) + uint128(FullMath7.mulDiv(feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128, positionLiquidity, FixedPoint128.Q128)); position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128; position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128; // subtraction is safe because we checked positionLiquidity is gte params.liquidity position.liquidity = positionLiquidity - params.liquidity; emit DecreaseLiquidity(params.tokenId, params.liquidity, amount0, amount1); // veVara would've been detached if liquidity reaches 0 if (positionLiquidity - params.liquidity == 0) { emit SwitchAttachment(params.tokenId, position.veVaraTokenId, 0); position.veVaraTokenId = 0; } } function collect( INonfungiblePositionManager.Position storage position, IEquilibreV2Pool pool, INonfungiblePositionManager.CollectParams calldata params ) external returns (uint256 amount0, uint256 amount1) { require(params.amount0Max > 0 || params.amount1Max > 0, "C0"); // allow collecting to the nft position manager address with address 0 address recipient = params.recipient == address(0) ? address(this) : params.recipient; (uint128 tokensOwed0, uint128 tokensOwed1) = (position.tokensOwed0, position.tokensOwed1); // trigger an update of the position fees owed and fee growth snapshots if it has any liquidity if (position.liquidity > 0) { pool.burn(params.tokenId, position.tickLower, position.tickUpper, 0, position.veVaraTokenId); (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , , ) = pool.positions( PositionKey.compute(address(this), params.tokenId, position.tickLower, position.tickUpper) ); tokensOwed0 += uint128(FullMath7.mulDiv(feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128, position.liquidity, FixedPoint128.Q128)); tokensOwed1 += uint128(FullMath7.mulDiv(feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128, position.liquidity, FixedPoint128.Q128)); position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128; position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128; } // compute the arguments to give to the pool#collect method (uint128 amount0Collect, uint128 amount1Collect) = ( params.amount0Max > tokensOwed0 ? tokensOwed0 : params.amount0Max, params.amount1Max > tokensOwed1 ? tokensOwed1 : params.amount1Max ); // the actual amounts collected are returned (amount0, amount1) = pool.collect(recipient, params.tokenId, position.tickLower, position.tickUpper, amount0Collect, amount1Collect); // sometimes there will be a few less wei than expected due to rounding down in core, but we just subtract the full amount expected // instead of the actual amount so we can burn the token (position.tokensOwed0, position.tokensOwed1) = (tokensOwed0 - amount0Collect, tokensOwed1 - amount1Collect); emit Collect(params.tokenId, recipient, amount0Collect, amount1Collect); } }
openzeppelin3upgradeable/token/ERC721/IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
openzeppelin3/introspection/IERC165.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
openzeppelin3upgradeable/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0 <0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
openzeppelin3upgradeable/token/ERC721/IERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "./IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
contracts/interfaces/IERC721Permit.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; import "openzeppelin3/token/ERC721/IERC721.sol"; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721Permit is IERC721 { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable; }
contracts/interfaces/IERC721PermitUpgradeable.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import "openzeppelin3upgradeable/token/ERC721/IERC721Upgradeable.sol"; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721PermitUpgradeable is IERC721Upgradeable { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit(address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external payable; }
contracts/interfaces/IEquilibreV2Pool.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import "contracts/interfaces/pool/IEquilibreV2PoolImmutables.sol"; import "contracts/interfaces/pool/IEquilibreV2PoolState.sol"; import "contracts/interfaces/pool/IEquilibreV2PoolDerivedState.sol"; import "contracts/interfaces/pool/IEquilibreV2PoolActions.sol"; import "contracts/interfaces/pool/IEquilibreV2PoolOwnerActions.sol"; import "contracts/interfaces/pool/IEquilibreV2PoolEvents.sol"; /// @title The interface for a Equilibre V2 Pool /// @notice A Equilibre pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IEquilibreV2Pool is IEquilibreV2PoolImmutables, IEquilibreV2PoolState, IEquilibreV2PoolDerivedState, IEquilibreV2PoolActions, IEquilibreV2PoolOwnerActions, IEquilibreV2PoolEvents { /// @notice Initializes a pool with parameters provided function initialize(address _factory, address _nfpManager, address _veVara, address _voter, address _token0, address _token1, uint24 _fee, int24 _tickSpacing) external; function setFee(uint24 _fee) external; }
contracts/interfaces/INonfungiblePositionManager7.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity =0.7.6; pragma abicoder v2; import "openzeppelin3upgradeable/token/ERC721/IERC721MetadataUpgradeable.sol"; import "openzeppelin3upgradeable/token/ERC721/IERC721MetadataUpgradeable.sol"; import "openzeppelin3upgradeable/token/ERC721/IERC721EnumerableUpgradeable.sol"; import "./IPoolInitializer.sol"; import "./IERC721Permit.sol"; import "./IPeripheryPayments.sol"; import "./IPeripheryImmutableState.sol"; import "./IERC721PermitUpgradeable.sol"; import "contracts/libraries/PoolAddress.sol"; /// @title Non-fungible token for positions /// @notice Wraps Equilibre V2 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable, IERC721PermitUpgradeable { /// @notice Emitted when liquidity is increased for a position NFT /// @dev Also emitted when a token is minted /// @param tokenId The ID of the token for which liquidity was increased /// @param liquidity The amount by which liquidity for the NFT position was increased /// @param amount0 The amount of token0 that was paid for the increase in liquidity /// @param amount1 The amount of token1 that was paid for the increase in liquidity event IncreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when liquidity is decreased for a position NFT /// @param tokenId The ID of the token for which liquidity was decreased /// @param liquidity The amount by which liquidity for the NFT position was decreased /// @param amount0 The amount of token0 that was accounted for the decrease in liquidity /// @param amount1 The amount of token1 that was accounted for the decrease in liquidity event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); /// @notice Emitted when tokens are collected for a position NFT /// @dev The amounts reported may not be exactly equivalent to the amounts transferred, due to rounding behavior /// @param tokenId The ID of the token for which underlying tokens were collected /// @param recipient The address of the account that received the collected tokens /// @param amount0 The amount of token0 owed to the position that was collected /// @param amount1 The amount of token1 owed to the position that was collected event Collect(uint256 indexed tokenId, address recipient, uint256 amount0, uint256 amount1); /// @notice Emitted when the attachment of an NFP is switched to a different veVara NFT. /// @param tokenId The identifier of the NFP for which the attachment is switched. /// @param oldVeVaraTokenId The identifier of the previous veVara NFT to which the NFP was attached. /// @param newVeVaraTokenId The identifier of the new veVara NFT to which the NFP was attached. event SwitchAttachment(uint256 indexed tokenId, uint256 oldVeVaraTokenId, uint256 newVeVaraTokenId); /// @notice The address of the veVara NFTs function veVara() external view returns (address); /// @notice Returns the position information associated with a given token ID. /// @dev Throws if the token ID is not valid. /// @param tokenId The ID of the token that represents the position /// @return nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions( uint256 tokenId ) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @dev keeps as is for backward compatibility struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; // the veVara tokenId attached uint256 veVaraTokenId; } // details about the Equilibre position struct Position { // the nonce for permits uint96 nonce; // the address that is approved for spending this token address operator; // the ID of the pool with which this token is connected uint80 poolId; // the tick range of the position int24 tickLower; int24 tickUpper; // the liquidity of the position uint128 liquidity; // the fee growth of the aggregate position as of the last action on the individual position uint256 feeGrowthInside0LastX128; uint256 feeGrowthInside1LastX128; // how many uncollected tokens are owed to the position, as of the last computation uint128 tokensOwed0; uint128 tokensOwed1; // the veVara tokenId attached uint256 veVaraTokenId; } /// @notice Creates a new position wrapped in a NFT /// @dev Call this when the pool does exist and is initialized. Note that if the pool is created but not initialized /// a method does not exist, i.e. the pool is assumed to be initialized. /// @param params The params necessary to mint a position, encoded as `MintParams` in calldata /// @return tokenId The ID of the token that represents the minted position /// @return liquidity The amount of liquidity for this position /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function mint(MintParams calldata params) external payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1); struct IncreaseLiquidityParams { uint256 tokenId; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Increases the amount of liquidity in a position, with tokens paid by the `msg.sender` /// @param params tokenId The ID of the token for which liquidity is being increased, /// amount0Desired The desired amount of token0 to be spent, /// amount1Desired The desired amount of token1 to be spent, /// amount0Min The minimum amount of token0 to spend, which serves as a slippage check, /// amount1Min The minimum amount of token1 to spend, which serves as a slippage check, /// deadline The time by which the transaction must be included to effect the change /// @return liquidity The new liquidity amount as a result of the increase /// @return amount0 The amount of token0 to acheive resulting liquidity /// @return amount1 The amount of token1 to acheive resulting liquidity function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns (uint128 liquidity, uint256 amount0, uint256 amount1); struct DecreaseLiquidityParams { uint256 tokenId; uint128 liquidity; uint256 amount0Min; uint256 amount1Min; uint256 deadline; } /// @notice Decreases the amount of liquidity in a position and accounts it to the position /// @param params tokenId The ID of the token for which liquidity is being decreased, /// amount The amount by which liquidity will be decreased, /// amount0Min The minimum amount of token0 that should be accounted for the burned liquidity, /// amount1Min The minimum amount of token1 that should be accounted for the burned liquidity, /// deadline The time by which the transaction must be included to effect the change /// @return amount0 The amount of token0 accounted to the position's tokens owed /// @return amount1 The amount of token1 accounted to the position's tokens owed function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (uint256 amount0, uint256 amount1); struct CollectParams { uint256 tokenId; address recipient; uint128 amount0Max; uint128 amount1Max; } /// @notice Switches the attachment of a token to a different veVara NFT. /// @param tokenId The identifier of the NFP to switch attachment. /// @param veVaraTokenId The identifier of the veVara NFT to attach. function switchAttachment(uint256 tokenId, uint256 veVaraTokenId) external; /// @notice Collects up to a maximum amount of fees owed to a specific position to the recipient /// @param params tokenId The ID of the NFT for which tokens are being collected, /// recipient The account that should receive the tokens, /// amount0Max The maximum amount of token0 to collect, /// amount1Max The maximum amount of token1 to collect /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(CollectParams calldata params) external payable returns (uint256 amount0, uint256 amount1); /// @notice Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens /// must be collected first. /// @param tokenId The ID of the token that is being burned function burn(uint256 tokenId) external payable; }
contracts/interfaces/IPeripheryImmutableState.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0 <0.9.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); }
contracts/interfaces/IPeripheryPayments.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH. /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. /// @param amountMinimum The minimum amount of WETH9 to unwrap /// @param recipient The address receiving ETH function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() external payable; /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users /// @param token The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token function sweepToken(address token, uint256 amountMinimum, address recipient) external payable; }
contracts/interfaces/IPoolInitializer.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param fee The fee amount of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) external payable returns (address pool); }
contracts/interfaces/pool/IEquilibreV2PoolActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IEquilibreV2PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position at index 0 /// @dev The caller of this method receives a callback in the form of IEquilibreV2MintCallback#equilibreV2MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint(address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data) external returns (uint256 amount0, uint256 amount1); /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IEquilibreV2MintCallback#equilibreV2MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param index The index for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param veVaraTokenId The veVara tokenId to attach to the position /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, uint256 index, int24 tickLower, int24 tickUpper, uint128 amount, uint256 veVaraTokenId, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect(address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested) external returns (uint128 amount0, uint128 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param index The index of the position to be collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, uint256 index, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position at index 0 /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn(int24 tickLower, int24 tickUpper, uint128 amount) external returns (uint256 amount0, uint256 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param index The index for which the liquidity will be burned /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn(uint256 index, int24 tickLower, int24 tickUpper, uint128 amount) external returns (uint256 amount0, uint256 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param index The index for which the liquidity will be burned /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @param veVaraTokenId The veVara Token Id to attach /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn(uint256 index, int24 tickLower, int24 tickUpper, uint128 amount, uint256 veVaraTokenId) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IEquilibreV2SwapCallback#equilibreV2SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap(address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IEquilibreV2FlashCallback#equilibreV2FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash(address recipient, uint256 amount0, uint256 amount1, bytes calldata data) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
contracts/interfaces/pool/IEquilibreV2PoolDerivedState.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IEquilibreV2PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block timestamp function observe(uint32[] calldata secondsAgos) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside( int24 tickLower, int24 tickUpper ) external view returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside); /// @notice Returns the seconds per liquidity and seconds inside a tick range for a period /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range function periodCumulativesInside(uint32 period, int24 tickLower, int24 tickUpper) external view returns (uint160 secondsPerLiquidityInsideX128); }
openzeppelin3/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
contracts/interfaces/pool/IEquilibreV2PoolEvents.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IEquilibreV2PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint(address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect(address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn(address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash(address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext(uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
contracts/interfaces/pool/IEquilibreV2PoolImmutables.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IEquilibreV2PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IEquilibreV2Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The contract that manages EquilibreV2 NFPs, which must adhere to the INonfungiblePositionManager interface /// @return The contract address function nfpManager() external view returns (address); /// @notice The contract that manages veEquilibre NFTs, which must adhere to the IVotinEscrow interface /// @return The contract address function veVara() external view returns (address); /// @notice The contract that manages Equilibre votes, which must adhere to the IVoter interface /// @return The contract address function voter() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
contracts/interfaces/pool/IEquilibreV2PoolOwnerActions.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IEquilibreV2PoolOwnerActions { /// @notice Set the protocol's % share of the fees /// @dev Fees start at 50%, with 5% increments function setFeeProtocol() external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol(address recipient, uint128 amount0Requested, uint128 amount1Requested) external returns (uint128 amount0, uint128 amount1); }
contracts/interfaces/pool/IEquilibreV2PoolState.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IEquilibreV2PoolState { /// @notice reads arbitrary storage slots and returns the bytes /// @param slots The slots to read from /// @return returnData The data read from the slots function readStorage(bytes32[] calldata slots) external view returns (bytes32[] memory returnData); /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked); /// @notice Returns the last tick of a given period /// @param period The period in question /// @return previousPeriod The period before current period /// @dev this is because there might be periods without trades /// startTick The start tick of the period /// lastTick The last tick of the period, if the period is finished /// endSecondsPerLiquidityPeriodX128 Seconds per liquidity at period's end function periods(uint256 period) external view returns (uint32 previousPeriod, int24 startTick, int24 lastTick, uint160 endSecondsPerLiquidityCumulativeX128); /// @notice The last period where a trade or liquidity change happened function lastPeriod() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @return amount the amount of this position has for this period, /// veVaraAmount the amount of veVara attached to this position for this period, /// secondsDebtX96 used to account for changes in the deposit amount during the period function extensionInfos(uint256 period, bytes32 key) external view returns (uint128 amount, int128 veVaraAmount, int256 secondsDebtX96); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks( int24 tick ) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke /// Returns attachedVeVaraId the veVara tokenId attached to the position function positions( bytes32 key ) external view returns (uint128 _liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1, uint256 attachedVeVaraId); function extensionInfos(uint256 period) external view returns (int128 totalVeVaraAmount); /// @notice Get the period seconds debt of a specific position /// @param period the period number /// @param recipient recipient address /// @param index position index /// @param tickLower lower bound of range /// @param tickUpper upper bound of range /// @return secondsDebtX96 seconds the position was not in range for the period function positionPeriodDebt(uint256 period, address recipient, uint256 index, int24 tickLower, int24 tickUpper) external view returns (int256 secondsDebtX96); /// @notice get the period seconds in range of a specific position /// @param period the period number /// @param owner owner address /// @param index position index /// @param tickLower lower bound of range /// @param tickUpper upper bound of range /// @return periodSecondsInsideX96 seconds the position was not in range for the period function positionPeriodSecondsInRange(uint256 period, address owner, uint256 index, int24 tickLower, int24 tickUpper) external view returns (uint256 periodSecondsInsideX96); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns (uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized); }
contracts/libraries/FixedPoint128.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint128 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) library FixedPoint128 { uint256 internal constant Q128 = 0x100000000000000000000000000000000; }
contracts/libraries/FullMath7.sol
// SPDX-License-Identifier: MIT pragma solidity =0.7.6; /// @title Contains 512-bit math functions /// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision /// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits library FullMath7 { /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv function mulDiv(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { // 512-bit multiply [prod1 prod0] = a * b // Compute the product mod 2**256 and mod 2**256 - 1 // then use the Chinese Remainder Theorem to reconstruct // the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2**256 + prod0 uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division if (prod1 == 0) { require(denominator > 0); assembly { result := div(prod0, denominator) } return result; } // Make sure the result is less than 2**256. // Also prevents denominator == 0 require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0] // Compute remainder using mulmod uint256 remainder; assembly { remainder := mulmod(a, b, denominator) } // Subtract 256 bit number from 512 bit number assembly { prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator // Compute largest power of two divisor of denominator. // Always >= 1. uint256 twos = -denominator & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { result = mulDiv(a, b, denominator); if (mulmod(a, b, denominator) > 0) { require(result < type(uint256).max); result++; } } }
contracts/libraries/PairCodeHashLib.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.6; library PairCodeHashLib { function pairCodeHashAt(address addr) external view returns (bytes32) { bytes memory bytecode = at(addr); return keccak256(bytecode); } function at(address _addr) public view returns (bytes memory o_code) { assembly { let size := extcodesize(_addr) o_code := mload(0x40) mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f)))) mstore(o_code, size) extcodecopy(_addr, add(o_code, 0x20), 0, size) } } }
contracts/libraries/PoolAddress.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {PairCodeHashLib} from "./PairCodeHashLib.sol"; interface factoryImplementation { function POOL_INIT_CODE_HASH() external pure returns (bytes32); } /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { //bytes32 public constant POOL_INIT_CODE_HASH = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; uint24 fee; } /// @notice Returns PoolKey: the ordered tokens with the matched fee levels /// @param tokenA The first token of a pool, unsorted /// @param tokenB The second token of a pool, unsorted /// @param fee The fee level of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey(address tokenA, address tokenB, uint24 fee) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, fee: fee}); } /// @notice Deterministically computes the pool address given the factory and PoolKey /// @param factory The Equilibre V3 factory contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address factory, PoolKey memory key) internal view returns (address pool) { require(key.token0 < key.token1, "CA"); pool = address( uint160( uint256(keccak256(abi.encodePacked(hex"ff", factory, keccak256(abi.encode(key.token0, key.token1, key.fee)), factoryImplementation(factory).POOL_INIT_CODE_HASH()))) ) ); } }
contracts/libraries/PositionKey.sol
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0 <0.8.0; library PositionKey { /// @dev Returns the key of the position in the core library function compute(address owner, uint256 index, int24 tickLower, int24 tickUpper) internal pure returns (bytes32) { return keccak256(abi.encodePacked(owner, index, tickLower, tickUpper)); } }
openzeppelin3upgradeable/token/ERC721/IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT pragma solidity >=0.6.2 <0.8.0; import "../../introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; }
Compiler Settings
{"outputSelection":{"*":{"*":["*"],"":["*"]}},"optimizer":{"runs":1,"enabled":true},"metadata":{"bytecodeHash":"none"},"libraries":{}}
Contract ABI
[{"type":"event","name":"Collect","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"address","name":"recipient","internalType":"address","indexed":false},{"type":"uint256","name":"amount0","internalType":"uint256","indexed":false},{"type":"uint256","name":"amount1","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DecreaseLiquidity","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"uint128","name":"liquidity","internalType":"uint128","indexed":false},{"type":"uint256","name":"amount0","internalType":"uint256","indexed":false},{"type":"uint256","name":"amount1","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"SwitchAttachment","inputs":[{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"uint256","name":"oldVeVaraTokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"newVeVaraTokenId","internalType":"uint256","indexed":false}],"anonymous":false}]
Contract Creation Code
0x610cb0610026600b82828239805160001a60731461001957fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100405760003560e01c806354603ede14610045578063acc69a1d1461007c575b600080fd5b81801561005157600080fd5b506100656100603660046109cb565b61009c565b604051610073929190610c68565b60405180910390f35b81801561008857600080fd5b50610065610097366004610a13565b6104e8565b600080806100b06060850160408601610a4d565b6001600160801b031611806100dd575060006100d26080850160608601610a4d565b6001600160801b0316115b6101025760405162461bcd60e51b81526004016100f990610bdd565b60405180910390fd5b60008061011560408601602087016109af565b6001600160a01b0316146101385761013360408501602086016109af565b61013a565b305b600487015460018801549192506001600160801b0380821692600160801b928390048216929004161561033d5760018801546005890154604051631c7f367360e31b81526001600160a01b038a169263e3f9b398926101ba928b3592600160501b8104600290810b93600160681b909204900b9160009190600401610c37565b6040805180830381600087803b1580156101d357600080fd5b505af11580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b9190610b0b565b5050600188015460009081906001600160a01b038a169063514ea4bf9061024c9030908c3590600160501b8104600290810b91600160681b9004900b6108a7565b6040518263ffffffff1660e01b81526004016102689190610b9b565b60c06040518083038186803b15801561028057600080fd5b505afa158015610294573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b89190610aa2565b50505092509250506102f58a6002015483038b60010160109054906101000a90046001600160801b03166001600160801b0316600160801b6108ff565b8401935061032e8a6003015482038b60010160109054906101000a90046001600160801b03166001600160801b0316600160801b6108ff565b60028b019290925560038a0155015b6000806001600160801b03841661035a60608a0160408b01610a4d565b6001600160801b03161161037d576103786060890160408a01610a4d565b61037f565b835b6001600160801b03841661039960808b0160608c01610a4d565b6001600160801b0316116103bc576103b760808a0160608b01610a4d565b6103be565b835b60018c015460405163a02f106960e01b81529294509092506001600160a01b038b169163a02f1069916104139189918d3591600160501b8204600290810b92600160681b9004900b9089908990600401610b58565b6040805180830381600087803b15801561042c57600080fd5b505af1158015610440573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104649190610a69565b60048c0180546001600160801b03196001600160801b03918216600160801b878a03841602171686890382161790915560405192811699501696508835907f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f01906104d390889086908690610b2e565b60405180910390a25050505050935093915050565b600080806104fc6040850160208601610a4d565b6001600160801b0316116105225760405162461bcd60e51b81526004016100f990610bc1565b6001850154600160801b90046001600160801b03166105476040850160208601610a4d565b6001600160801b0316816001600160801b031610156105785760405162461bcd60e51b81526004016100f990610ba4565b60018601546001600160a01b0386169063e3f9b39890863590600160501b8104600290810b91600160681b9004900b6105b760408a0160208b01610a4d565b8b600501546040518663ffffffff1660e01b81526004016105dc959493929190610c37565b6040805180830381600087803b1580156105f557600080fd5b505af1158015610609573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062d9190610b0b565b90935091506040840135831080159061064a575083606001358210155b6106665760405162461bcd60e51b81526004016100f990610bf9565b6001860154600090610692903090873590600160501b8104600290810b91600160681b9004900b6108a7565b9050600080876001600160a01b031663514ea4bf846040518263ffffffff1660e01b81526004016106c39190610b9b565b60c06040518083038186803b1580156106db57600080fd5b505afa1580156106ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107139190610aa2565b505050925092505061073989600201548303856001600160801b0316600160801b6108ff565b60048a0180546001600160801b031981169289016001600160801b0391821601811692909217905560038a015461077a91908303908616600160801b6108ff565b60048a0180546001600160801b03808216938901600160801b92839004821601160291909117905560028901829055600389018190556107c06040880160208901610a4d565b60018a0180546001600160801b039287038316600160801b02921691909117905586357f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b461081460408a0160208b01610a4d565b888860405161082593929190610c16565b60405180910390a261083d6040880160208901610a4d565b84036001600160801b03166000141561089b5786600001357fa2b6a38750bb1e3737c2be167c075c253a8bacf8b30136ab89db8cef52fd7f1c8a60050154600060405161088b929190610c68565b60405180910390a2600060058a01555b50505050935093915050565b6040805160609590951b6001600160601b0319166020808701919091526034860194909452600292830b60e890811b60548701529190920b901b60578401528051808403603a018152605a9093019052815191012090565b6000808060001985870986860292508281109083900303905080610935576000841161092a57600080fd5b5082900490506109a8565b80841161094157600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b6000602082840312156109c0578081fd5b81356109a881610c76565b600080600083850360c08112156109e0578283fd5b8435935060208501356109f281610c76565b92506080603f1982011215610a05578182fd5b506040840190509250925092565b600080600083850360e0811215610a28578384fd5b843593506020850135610a3a81610c76565b925060a0603f1982011215610a05578182fd5b600060208284031215610a5e578081fd5b81356109a881610c8e565b60008060408385031215610a7b578182fd5b8251610a8681610c8e565b6020840151909250610a9781610c8e565b809150509250929050565b60008060008060008060c08789031215610aba578182fd5b8651610ac581610c8e565b8096505060208701519450604087015193506060870151610ae581610c8e565b6080880151909350610af681610c8e565b8092505060a087015190509295509295509295565b60008060408385031215610b1d578182fd5b505080516020909101519092909150565b6001600160a01b039390931683526001600160801b03918216602084015216604082015260600190565b6001600160a01b039690961686526020860194909452600292830b6040860152910b60608401526001600160801b0390811660808401521660a082015260c00190565b90815260200190565b6020808252600390820152621c131b60ea1b604082015260600190565b60208082526002908201526104c360f41b604082015260600190565b602080825260029082015261043360f41b604082015260600190565b60208082526003908201526250534360e81b604082015260600190565b6001600160801b039390931683526020830191909152604082015260600190565b948552600293840b60208601529190920b60408401526001600160801b039091166060830152608082015260a00190565b918252602082015260400190565b6001600160a01b0381168114610c8b57600080fd5b50565b6001600160801b0381168114610c8b57600080fdfea164736f6c6343000706000a
Deployed ByteCode
0x73cbf91d7af11e1e7fce0f597e3ee4713ab63574f330146080604052600436106100405760003560e01c806354603ede14610045578063acc69a1d1461007c575b600080fd5b81801561005157600080fd5b506100656100603660046109cb565b61009c565b604051610073929190610c68565b60405180910390f35b81801561008857600080fd5b50610065610097366004610a13565b6104e8565b600080806100b06060850160408601610a4d565b6001600160801b031611806100dd575060006100d26080850160608601610a4d565b6001600160801b0316115b6101025760405162461bcd60e51b81526004016100f990610bdd565b60405180910390fd5b60008061011560408601602087016109af565b6001600160a01b0316146101385761013360408501602086016109af565b61013a565b305b600487015460018801549192506001600160801b0380821692600160801b928390048216929004161561033d5760018801546005890154604051631c7f367360e31b81526001600160a01b038a169263e3f9b398926101ba928b3592600160501b8104600290810b93600160681b909204900b9160009190600401610c37565b6040805180830381600087803b1580156101d357600080fd5b505af11580156101e7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061020b9190610b0b565b5050600188015460009081906001600160a01b038a169063514ea4bf9061024c9030908c3590600160501b8104600290810b91600160681b9004900b6108a7565b6040518263ffffffff1660e01b81526004016102689190610b9b565b60c06040518083038186803b15801561028057600080fd5b505afa158015610294573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b89190610aa2565b50505092509250506102f58a6002015483038b60010160109054906101000a90046001600160801b03166001600160801b0316600160801b6108ff565b8401935061032e8a6003015482038b60010160109054906101000a90046001600160801b03166001600160801b0316600160801b6108ff565b60028b019290925560038a0155015b6000806001600160801b03841661035a60608a0160408b01610a4d565b6001600160801b03161161037d576103786060890160408a01610a4d565b61037f565b835b6001600160801b03841661039960808b0160608c01610a4d565b6001600160801b0316116103bc576103b760808a0160608b01610a4d565b6103be565b835b60018c015460405163a02f106960e01b81529294509092506001600160a01b038b169163a02f1069916104139189918d3591600160501b8204600290810b92600160681b9004900b9089908990600401610b58565b6040805180830381600087803b15801561042c57600080fd5b505af1158015610440573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104649190610a69565b60048c0180546001600160801b03196001600160801b03918216600160801b878a03841602171686890382161790915560405192811699501696508835907f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f01906104d390889086908690610b2e565b60405180910390a25050505050935093915050565b600080806104fc6040850160208601610a4d565b6001600160801b0316116105225760405162461bcd60e51b81526004016100f990610bc1565b6001850154600160801b90046001600160801b03166105476040850160208601610a4d565b6001600160801b0316816001600160801b031610156105785760405162461bcd60e51b81526004016100f990610ba4565b60018601546001600160a01b0386169063e3f9b39890863590600160501b8104600290810b91600160681b9004900b6105b760408a0160208b01610a4d565b8b600501546040518663ffffffff1660e01b81526004016105dc959493929190610c37565b6040805180830381600087803b1580156105f557600080fd5b505af1158015610609573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061062d9190610b0b565b90935091506040840135831080159061064a575083606001358210155b6106665760405162461bcd60e51b81526004016100f990610bf9565b6001860154600090610692903090873590600160501b8104600290810b91600160681b9004900b6108a7565b9050600080876001600160a01b031663514ea4bf846040518263ffffffff1660e01b81526004016106c39190610b9b565b60c06040518083038186803b1580156106db57600080fd5b505afa1580156106ef573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107139190610aa2565b505050925092505061073989600201548303856001600160801b0316600160801b6108ff565b60048a0180546001600160801b031981169289016001600160801b0391821601811692909217905560038a015461077a91908303908616600160801b6108ff565b60048a0180546001600160801b03808216938901600160801b92839004821601160291909117905560028901829055600389018190556107c06040880160208901610a4d565b60018a0180546001600160801b039287038316600160801b02921691909117905586357f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b461081460408a0160208b01610a4d565b888860405161082593929190610c16565b60405180910390a261083d6040880160208901610a4d565b84036001600160801b03166000141561089b5786600001357fa2b6a38750bb1e3737c2be167c075c253a8bacf8b30136ab89db8cef52fd7f1c8a60050154600060405161088b929190610c68565b60405180910390a2600060058a01555b50505050935093915050565b6040805160609590951b6001600160601b0319166020808701919091526034860194909452600292830b60e890811b60548701529190920b901b60578401528051808403603a018152605a9093019052815191012090565b6000808060001985870986860292508281109083900303905080610935576000841161092a57600080fd5b5082900490506109a8565b80841161094157600080fd5b6000848688096000868103871696879004966002600389028118808a02820302808a02820302808a02820302808a02820302808a02820302808a02909103029181900381900460010186841190950394909402919094039290920491909117919091029150505b9392505050565b6000602082840312156109c0578081fd5b81356109a881610c76565b600080600083850360c08112156109e0578283fd5b8435935060208501356109f281610c76565b92506080603f1982011215610a05578182fd5b506040840190509250925092565b600080600083850360e0811215610a28578384fd5b843593506020850135610a3a81610c76565b925060a0603f1982011215610a05578182fd5b600060208284031215610a5e578081fd5b81356109a881610c8e565b60008060408385031215610a7b578182fd5b8251610a8681610c8e565b6020840151909250610a9781610c8e565b809150509250929050565b60008060008060008060c08789031215610aba578182fd5b8651610ac581610c8e565b8096505060208701519450604087015193506060870151610ae581610c8e565b6080880151909350610af681610c8e565b8092505060a087015190509295509295509295565b60008060408385031215610b1d578182fd5b505080516020909101519092909150565b6001600160a01b039390931683526001600160801b03918216602084015216604082015260600190565b6001600160a01b039690961686526020860194909452600292830b6040860152910b60608401526001600160801b0390811660808401521660a082015260c00190565b90815260200190565b6020808252600390820152621c131b60ea1b604082015260600190565b60208082526002908201526104c360f41b604082015260600190565b602080825260029082015261043360f41b604082015260600190565b60208082526003908201526250534360e81b604082015260600190565b6001600160801b039390931683526020830191909152604082015260600190565b948552600293840b60208601529190920b60408401526001600160801b039091166060830152608082015260a00190565b918252602082015260400190565b6001600160a01b0381168114610c8b57600080fd5b50565b6001600160801b0381168114610c8b57600080fdfea164736f6c6343000706000a