Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 25 internal transactions (View All)
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
14994604 | 9 mins ago | 0 ETH | ||||
14994456 | 14 mins ago | 0 ETH | ||||
14994108 | 27 mins ago | 0 ETH | ||||
14993806 | 39 mins ago | 0 ETH | ||||
14993561 | 47 mins ago | 0 ETH | ||||
14991588 | 1 hr ago | 0 ETH | ||||
14991466 | 2 hrs ago | 0 ETH | ||||
14991440 | 2 hrs ago | 0 ETH | ||||
14991407 | 2 hrs ago | 0 ETH | ||||
14991308 | 2 hrs ago | 0 ETH | ||||
14991022 | 2 hrs ago | 0 ETH | ||||
14991022 | 2 hrs ago | 0 ETH | ||||
14991014 | 2 hrs ago | 0 ETH | ||||
14990996 | 2 hrs ago | 0 ETH | ||||
14990979 | 2 hrs ago | 0 ETH | ||||
14990972 | 2 hrs ago | 0 ETH | ||||
14990840 | 2 hrs ago | 0 ETH | ||||
14990816 | 2 hrs ago | 0 ETH | ||||
14990606 | 2 hrs ago | 0 ETH | ||||
14990589 | 2 hrs ago | 0 ETH | ||||
14990475 | 2 hrs ago | 0 ETH | ||||
14990475 | 2 hrs ago | 0 ETH | ||||
14990475 | 2 hrs ago | 0 ETH | ||||
14990469 | 2 hrs ago | 0 ETH | ||||
14990469 | 2 hrs ago | 0 ETH |
Loading...
Loading
Contract Name:
GaugeV2
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 800 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; import "./interfaces/IGaugeV2.sol"; import "./interfaces/INonfungiblePositionManager.sol"; import "./interfaces/IFeeCollector.sol"; import "./libraries/FullMath.sol"; import "../v2/interfaces/IClPool.sol"; import "../v2/libraries/States.sol"; import "@openzeppelin/contracts/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import "@openzeppelin/contracts/utils/math/Math.sol"; import "../interfaces/IVoter.sol"; contract GaugeV2 is Initializable, IGaugeV2 { using SafeERC20 for IERC20; uint256 internal constant WEEK = 1 weeks; uint256 internal constant PRECISION = 10 ** 18; bool internal _unlocked; address public gaugeFactory; IClPool public pool; address public voter; IFeeCollector public feeCollector; INonfungiblePositionManager public nfpManager; /// @inheritdoc IGaugeV2 uint256 public firstPeriod; /// @inheritdoc IGaugeV2 /// @dev period => token => total supply mapping(uint256 => mapping(address => uint256)) public tokenTotalSupplyByPeriod; /// @inheritdoc IGaugeV2 /// @dev period => total boosted seconds mapping(uint256 => uint256) public periodTotalBoostedSeconds; /// @dev period => position hash => bool mapping(uint256 => mapping(bytes32 => bool)) internal periodAmountsWritten; /// @dev period => position hash => seconds in range mapping(uint256 => mapping(bytes32 => uint256)) internal periodNfpSecondsX96; /// @dev period => position hash => boosted seconds in range mapping(uint256 => mapping(bytes32 => uint256)) internal periodNfpBoostedSecondsX96; /// @inheritdoc IGaugeV2 /// @dev period => position hash => reward token => amount mapping(uint256 => mapping(bytes32 => mapping(address => uint256))) public periodClaimedAmount; // token => position hash => period /// @inheritdoc IGaugeV2 mapping(address => mapping(bytes32 => uint256)) public lastClaimByToken; /// @inheritdoc IGaugeV2 address[] public rewards; /// @inheritdoc IGaugeV2 mapping(address => bool) public isReward; /// @dev Mutually exclusive reentrancy protection into the pool to/from a method. This method also prevents entrance /// to a function before the Gauge is initialized. modifier lock() { require(_unlocked, "LOK"); _unlocked = false; _; _unlocked = true; } /// @dev pushes fees from the pool to fee distributor on notify rewards modifier pushFees() { feeCollector.collectProtocolFees(pool); _; } /// @dev disables the initializer constructor() { _disableInitializers(); } /// @inheritdoc IGaugeV2 function initialize( address _gaugeFactory, address _voter, address _nfpManager, address _feeCollector, address _pool ) external override initializer { _unlocked = true; gaugeFactory = _gaugeFactory; voter = _voter; feeCollector = IFeeCollector(_feeCollector); nfpManager = INonfungiblePositionManager(_nfpManager); pool = IClPool(_pool); firstPeriod = _blockTimestamp() / WEEK; address emissionsToken = IVoter(_voter).base(); address xToken = IVoter(_voter).xToken(); address token0 = IClPool(_pool).token0(); address token1 = IClPool(_pool).token1(); rewards.push(emissionsToken); rewards.push(xToken); rewards.push(token0); rewards.push(token1); isReward[emissionsToken] = true; isReward[xToken] = true; isReward[token0] = true; isReward[token1] = true; for (uint256 i; i < rewards.length; i++) { emit RewardAdded(rewards[i]); } } function _blockTimestamp() internal view virtual returns (uint256) { return block.timestamp; } /// @inheritdoc IGaugeV2 function left(address token) external view override returns (uint256) { uint256 period = _blockTimestamp() / WEEK; uint256 remainingTime = ((period + 1) * WEEK) - _blockTimestamp(); return (tokenTotalSupplyByPeriod[period][token] * remainingTime) / WEEK; } /// @inheritdoc IGaugeV2 function rewardRate( address token ) external view returns (uint256 _rewardRate) { uint256 period = _blockTimestamp() / WEEK; if (period > 2830) { _rewardRate = tokenTotalSupplyByPeriod[period][token] / WEEK; } else { _rewardRate = (tokenTotalSupplyByPeriod[period][token] * 4) / (10 * WEEK); } } /// @inheritdoc IGaugeV2 function getRewardTokens() external view override returns (address[] memory) { return rewards; } /// @inheritdoc IGaugeV2 function positionHash( address owner, uint256 index, int24 tickLower, int24 tickUpper ) public pure returns (bytes32) { return keccak256(abi.encodePacked(owner, index, tickLower, tickUpper)); } /// @inheritdoc IGaugeV2 function positionInfo( uint256 tokenId ) external view override returns ( uint128 liquidity, uint128 boostedLiquidity, uint256 veNftTokenId ) { uint256 period = _blockTimestamp() / WEEK; INonfungiblePositionManager _nfpManager = nfpManager; (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = _nfpManager .positions(tokenId); bytes32 _positionHash = positionHash( address(_nfpManager), tokenId, tickLower, tickUpper ); States.PoolStates storage states = States.getStorage(); PositionInfo storage positionData = states.positions[_positionHash]; BoostInfo storage boostInfo = states.boostInfos[period].positions[ _positionHash ]; bytes32 liquiditySlot; bytes32 boostedLiquiditySlot; bytes32 attachedVeNftSlot; bytes32[] memory slots = new bytes32[](3); // define slots to read // both slots are in the 0th slot of the struct assembly { liquiditySlot := positionData.slot boostedLiquiditySlot := boostInfo.slot attachedVeNftSlot := add(positionData.slot, 4) } slots[0] = liquiditySlot; slots[1] = boostedLiquiditySlot; slots[2] = attachedVeNftSlot; // read slots from pool bytes32[] memory data = pool.readStorage(slots); // need to shift data[1] by 128 since this slot has 2 items data[1] = data[1] << 128; data[1] = data[1] >> 128; liquidity = uint128(uint256(data[0])); boostedLiquidity = uint128(uint256(data[1])); veNftTokenId = uint256(data[2]); } function veNftInfo( uint256 veNftTokenId ) external view returns (uint128 timesAttached, uint128 veNftBoostUsedRatio) { uint256 period = _blockTimestamp() / WEEK; States.PoolStates storage states = States.getStorage(); VeNftInfo storage _veNftInfo = states.boostInfos[period].veNftInfos[ veNftTokenId ]; bytes32 veNftInfoSlot; bytes32[] memory slots = new bytes32[](1); // define slots to read // both slots are in the 0th slot of the struct assembly { veNftInfoSlot := _veNftInfo.slot } slots[0] = veNftInfoSlot; // read slots from pool bytes32[] memory data = pool.readStorage(slots); timesAttached = uint128(uint256((data[0] << 128) >> 128)); veNftBoostUsedRatio = uint128(uint256(data[0] >> 128)); } /// @inheritdoc IGaugeV2 function notifyRewardAmount( address token, uint256 amount ) external override pushFees lock { IClPool(pool)._advancePeriod(); uint256 period = _blockTimestamp() / WEEK; if (msg.sender == voter && !isReward[token]) { isReward[token] = true; rewards.push(token); emit RewardAdded(token); } uint256 balanceBefore = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransferFrom(msg.sender, address(this), amount); uint256 balanceAfter = IERC20(token).balanceOf(address(this)); amount = balanceAfter - balanceBefore; tokenTotalSupplyByPeriod[period][token] += amount; emit NotifyReward(msg.sender, token, amount, period); } /// @inheritdoc IGaugeV2 function earned( address token, uint256 tokenId ) external view returns (uint256 reward) { INonfungiblePositionManager _nfpManager = nfpManager; (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = _nfpManager .positions(tokenId); bytes32 _positionHash = positionHash( address(_nfpManager), tokenId, tickLower, tickUpper ); uint256 lastClaim = Math.max( lastClaimByToken[token][_positionHash], firstPeriod ); uint256 currentPeriod = _blockTimestamp() / WEEK; for (uint256 period = lastClaim; period <= currentPeriod; ++period) { reward += periodEarned( period, token, address(_nfpManager), tokenId, tickLower, tickUpper ); } } /// @inheritdoc IGaugeV2 function periodEarned( uint256 period, address token, uint256 tokenId ) public view override returns (uint256) { INonfungiblePositionManager _nfpManager = nfpManager; (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = _nfpManager .positions(tokenId); return periodEarned( period, token, address(_nfpManager), tokenId, tickLower, tickUpper ); } /// @inheritdoc IGaugeV2 function periodEarned( uint256 period, address token, address owner, uint256 index, int24 tickLower, int24 tickUpper ) public view returns (uint256 amount) { (bool success, bytes memory data) = address(this).staticcall( abi.encodeCall( this.cachePeriodEarned, (period, token, owner, index, tickLower, tickUpper, false) ) ); if (!success) { return 0; } return abi.decode(data, (uint256)); } /// @inheritdoc IGaugeV2 /// @dev used by getReward() and saves gas by saving states function cachePeriodEarned( uint256 period, address token, address owner, uint256 index, int24 tickLower, int24 tickUpper, bool caching ) public override returns (uint256 amount) { uint256 periodSecondsInsideX96; uint256 periodBoostedSecondsInsideX96; bytes32 _positionHash = positionHash( owner, index, tickLower, tickUpper ); // get seconds from pool if not already written into storage if (!periodAmountsWritten[period][_positionHash]) { (bool success, bytes memory data) = address(pool).staticcall( abi.encodeCall( IClPoolState.positionPeriodSecondsInRange, (period, owner, index, tickLower, tickUpper) ) ); if (!success) { return 0; } (periodSecondsInsideX96, periodBoostedSecondsInsideX96) = abi .decode(data, (uint256, uint256)); if (period < _blockTimestamp() / WEEK && caching) { periodAmountsWritten[period][_positionHash] = true; periodNfpSecondsX96[period][ _positionHash ] = periodSecondsInsideX96; periodNfpBoostedSecondsX96[period][ _positionHash ] = periodBoostedSecondsInsideX96; } } else { periodSecondsInsideX96 = periodNfpSecondsX96[period][_positionHash]; periodBoostedSecondsInsideX96 = periodNfpBoostedSecondsX96[period][ _positionHash ]; } // Get total rewards uint256 baseRewards = tokenTotalSupplyByPeriod[period][token]; uint256 boostedRewards = (baseRewards * 6) / 10; if (period <= 2830) { baseRewards = baseRewards - boostedRewards; } // Get total boosted seconds uint256 boostedInRange; // Check if boostedInRange is already stored in states if (period < _blockTimestamp() / WEEK) { boostedInRange = periodTotalBoostedSeconds[period]; if (boostedInRange == 0) { uint32 previousPeriod; (previousPeriod, , , , , boostedInRange) = pool.periods(period); if (previousPeriod != 0 && caching) { periodTotalBoostedSeconds[period] = boostedInRange; } } } // Use 1 week if boostedInRange is 0 if (boostedInRange == 0) { boostedInRange = WEEK; } // yes if (period > 2830) { amount = FullMath.mulDiv( baseRewards, periodSecondsInsideX96, WEEK << 96 ); } else { amount = FullMath.mulDiv( baseRewards, periodSecondsInsideX96, WEEK << 96 ) + FullMath.mulDiv( boostedRewards, periodBoostedSecondsInsideX96, WEEK << 96 ); } uint256 claimed = periodClaimedAmount[period][_positionHash][token]; if (amount >= claimed) { amount -= claimed; } else { amount = 0; } return amount; } /// @inheritdoc IGaugeV2 function getPeriodReward( uint256 period, address[] calldata tokens, uint256 tokenId, address receiver ) external override lock { INonfungiblePositionManager _nfpManager = nfpManager; address owner = _nfpManager.ownerOf(tokenId); address operator = _nfpManager.getApproved(tokenId); require( msg.sender == owner || msg.sender == operator, "Not authorized" ); (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = _nfpManager .positions(tokenId); bytes32 _positionHash = positionHash( address(_nfpManager), tokenId, tickLower, tickUpper ); for (uint256 i = 0; i < tokens.length; ++i) { if (period < _blockTimestamp() / WEEK) { lastClaimByToken[tokens[i]][_positionHash] = period; } _getReward( period, tokens[i], address(_nfpManager), tokenId, tickLower, tickUpper, _positionHash, receiver ); } } /// @inheritdoc IGaugeV2 function getPeriodReward( uint256 period, address[] calldata tokens, address owner, uint256 index, int24 tickLower, int24 tickUpper, address receiver ) external override lock { require(msg.sender == owner, "Not authorized"); bytes32 _positionHash = positionHash( owner, index, tickLower, tickUpper ); for (uint256 i = 0; i < tokens.length; ++i) { if (period < _blockTimestamp() / WEEK) { lastClaimByToken[tokens[i]][_positionHash] = period; } _getReward( period, tokens[i], owner, index, tickLower, tickUpper, _positionHash, receiver ); } } function getReward( uint256[] calldata tokenIds, address[] memory tokens ) external { uint256 length = tokenIds.length; for (uint256 i = 0; i < length; ++i) { getReward(tokenIds[i], tokens); } } function getReward(uint256 tokenId, address[] memory tokens) public lock { INonfungiblePositionManager _nfpManager = nfpManager; address owner = _nfpManager.ownerOf(tokenId); address operator = _nfpManager.getApproved(tokenId); require( msg.sender == owner || msg.sender == operator, "Not authorized" ); (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = _nfpManager .positions(tokenId); _getAllRewards( address(_nfpManager), tokenId, tickLower, tickUpper, tokens, msg.sender ); } function getRewardForOwner( uint256 tokenId, address[] memory tokens ) external lock { require( msg.sender == voter || msg.sender == address(nfpManager), "Not authorized" ); INonfungiblePositionManager _nfpManager = nfpManager; address owner = _nfpManager.ownerOf(tokenId); (, , , , , int24 tickLower, int24 tickUpper, , , , , ) = _nfpManager .positions(tokenId); _getAllRewards( address(_nfpManager), tokenId, tickLower, tickUpper, tokens, owner ); } function getReward( address owner, uint256 index, int24 tickLower, int24 tickUpper, address[] memory tokens, address receiver ) external lock { require(msg.sender == owner, "Not authorized"); _getAllRewards(owner, index, tickLower, tickUpper, tokens, receiver); } function _getAllRewards( address owner, uint256 index, int24 tickLower, int24 tickUpper, address[] memory tokens, address receiver ) internal { bytes32 _positionHash = positionHash( owner, index, tickLower, tickUpper ); uint256 currentPeriod = _blockTimestamp() / WEEK; uint256 lastClaim; for (uint256 i = 0; i < tokens.length; ++i) { lastClaim = Math.max( lastClaimByToken[tokens[i]][_positionHash], firstPeriod ); for ( uint256 period = lastClaim; period <= currentPeriod; ++period ) { _getReward( period, tokens[i], owner, index, tickLower, tickUpper, _positionHash, receiver ); } lastClaimByToken[tokens[i]][_positionHash] = currentPeriod - 1; } } function _getReward( uint256 period, address token, address owner, uint256 index, int24 tickLower, int24 tickUpper, bytes32 _positionHash, address receiver ) internal { uint256 _reward = cachePeriodEarned( period, token, owner, index, tickLower, tickUpper, true ); if (_reward > 0) { periodClaimedAmount[period][_positionHash][token] += _reward; IERC20(token).safeTransfer(receiver, _reward); emit ClaimRewards(period, _positionHash, receiver, token, _reward); } } /// @notice Allows the governance to retrieve leftover rewards from unused boost function retrieveLeftovers( address[] calldata tokens, uint256[] calldata periods ) external { for (uint256 i = 0; i < tokens.length; ++i) { address token = tokens[i]; for (uint256 j = 0; j < periods.length; ++j) { uint256 period = periods[j]; require(period <= 2830, "Nope"); // Get total boosted seconds uint256 boostedInRange = periodTotalBoostedSeconds[period]; uint256 amount; // only retrieve for finalized periods if (boostedInRange > 0) { uint256 boostedRewards = (tokenTotalSupplyByPeriod[period][ token ] * 6) / 10; amount = FullMath.mulDiv( boostedRewards, (WEEK - boostedInRange), WEEK ); amount -= periodClaimedAmount[period][bytes32(0)][token]; } if (amount > 0) { // record governance claimed leftovers in position 0 periodClaimedAmount[period][bytes32(0)][token] += amount; address receiver = feeCollector.treasury(); IERC20(token).safeTransfer(receiver, amount); emit ClaimRewards( period, bytes32(0), receiver, token, amount ); } } } } /// @inheritdoc IGaugeV2 function notifyRewardAmountForPeriod( address token, uint256 amount, uint256 period ) external lock { require(isReward[token], "!Whitelisted"); require(period > _blockTimestamp() / WEEK, "Retro"); uint256 balanceBefore = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransferFrom(msg.sender, address(this), amount); uint256 balanceAfter = IERC20(token).balanceOf(address(this)); amount = balanceAfter - balanceBefore; tokenTotalSupplyByPeriod[period][token] += amount; emit NotifyReward(msg.sender, token, amount, period); } /// @inheritdoc IGaugeV2 function notifyRewardAmountNextPeriod( address token, uint256 amount ) external lock { require(isReward[token], "!Whitelisted"); uint256 period = (_blockTimestamp() / WEEK) + 1; uint256 balanceBefore = IERC20(token).balanceOf(address(this)); IERC20(token).safeTransferFrom(msg.sender, address(this), amount); uint256 balanceAfter = IERC20(token).balanceOf(address(this)); amount = balanceAfter - balanceBefore; tokenTotalSupplyByPeriod[period][token] += amount; emit NotifyReward(msg.sender, token, amount, period); } function addRewards(address reward) external { require(msg.sender == voter, "!AUTH"); if (!isReward[reward]) { rewards.push(reward); emit RewardAdded(reward); } } function removeRewards(address reward) external { require(msg.sender == voter, "!AUTH"); if (isReward[reward]) { uint256 idx; for (uint256 i; i < rewards.length; ++i) { if (rewards[i] == reward) { idx = i; break; } } for (uint256 i = idx; i < rewards.length - 1; ++i) { rewards[i] = rewards[i + 1]; } rewards.pop(); isReward[reward] = false; emit RewardRemoved(reward); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^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); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/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`. * * 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; /** * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^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); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/Address.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ```solidity * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized != type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // 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(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1, "Math: mulDiv overflow"); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. 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 for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the 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. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // 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 preconditions 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 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0); } } }
// SPDX-License-Identifier: MIT pragma solidity =0.7.6 || ^0.8.13; pragma abicoder v2; interface IVoter { function _ve() external view returns (address); function governor() external view returns (address); function emergencyCouncil() external view returns (address); function attachTokenToGauge(uint256 _tokenId, address account) external; function detachTokenFromGauge(uint256 _tokenId, address account) external; function emitDeposit( uint256 _tokenId, address account, uint256 amount ) external; function emitWithdraw( uint256 _tokenId, address account, uint256 amount ) external; function isWhitelisted(address token) external view returns (bool); function notifyRewardAmount(uint256 amount) external; function distribute(address _gauge) external; function gauges(address pool) external view returns (address); function feeDistributors(address gauge) external view returns (address); function gaugefactory() external view returns (address); function feeDistributorFactory() external view returns (address); function minter() external view returns (address); function factory() external view returns (address); function length() external view returns (uint256); function pools(uint256) external view returns (address); function isAlive(address) external view returns (bool); function setXRatio(uint256 _xRatio) external; function setPoolXRatio( address[] calldata _gauges, uint256[] calldata _xRaRatios ) external; function resetGaugeXRatio(address[] calldata _gauges) external; function whitelist(address _token) external; function forbid(address _token, bool _status) external; function whitelistOperator() external view returns (address); function gaugeXRatio(address gauge) external view returns (uint256); function isGauge(address gauge) external view returns (bool); function killGauge(address _gauge) external; function reviveGauge(address _gauge) external; function stale(uint256 _tokenID) external view returns (bool); function poolForGauge(address gauge) external view returns (address pool); function recoverFees( address[] calldata fees, address[][] calldata tokens ) external; function designateStale(uint256 _tokenId, bool _status) external; function base() external view returns (address); function xToken() external view returns (address); function addClGaugeReward(address gauge, address reward) external; function removeClGaugeReward(address gauge, address reward) external; }
// 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); }
// 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; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import "@openzeppelin/contracts-upgradeable/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; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.13; import "../../v2/interfaces/IClPool.sol"; interface IFeeCollector { /// @notice Emitted when the treasury address is changed. /// @param oldTreasury The previous treasury address. /// @param newTreasury The new treasury address. event TreasuryChanged(address oldTreasury, address newTreasury); /// @notice Emitted when the treasury fees value is changed. /// @param oldTreasuryFees The previous value of the treasury fees. /// @param newTreasuryFees The new value of the treasury fees. event TreasuryFeesChanged(uint256 oldTreasuryFees, uint256 newTreasuryFees); /// @notice Emitted when protocol fees are collected from a pool and distributed to the fee distributor and treasury. /// @param pool The address of the pool from which the fees were collected. /// @param feeDistAmount0 The amount of fee tokens (token 0) distributed to the fee distributor. /// @param feeDistAmount1 The amount of fee tokens (token 1) distributed to the fee distributor. /// @param treasuryAmount0 The amount of fee tokens (token 0) allocated to the treasury. /// @param treasuryAmount1 The amount of fee tokens (token 1) allocated to the treasury. event FeesCollected( address pool, uint256 feeDistAmount0, uint256 feeDistAmount1, uint256 treasuryAmount0, uint256 treasuryAmount1 ); /// @notice Returns the treasury address. function treasury() external returns (address); /// @notice Sets the treasury address to a new value. /// @param newTreasury The new address to set as the treasury. function setTreasury(address newTreasury) external; /// @notice Sets the value of treasury fees to a new amount. /// @param _treasuryFees The new amount of treasury fees to be set. function setTreasuryFees(uint256 _treasuryFees) external; /// @notice Collects protocol fees from a specified pool and distributes them to the fee distributor and treasury. /// @param pool The pool from which to collect the protocol fees. function collectProtocolFees(IClPool pool) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0 <0.9.0; interface IGaugeV2 { /// @notice Emitted when a reward notification is made. /// @param from The address from which the reward is notified. /// @param reward The address of the reward token. /// @param amount The amount of rewards notified. /// @param period The period for which the rewards are notified. event NotifyReward( address indexed from, address indexed reward, uint256 amount, uint256 period ); /// @notice Emitted when a bribe is made. /// @param from The address from which the bribe is made. /// @param reward The address of the reward token. /// @param amount The amount of tokens bribed. /// @param period The period for which the bribe is made. event Bribe( address indexed from, address indexed reward, uint256 amount, uint256 period ); /// @notice Emitted when rewards are claimed. /// @param period The period for which the rewards are claimed. /// @param _positionHash The identifier of the NFP for which rewards are claimed. /// @param receiver The address of the receiver of the claimed rewards. /// @param reward The address of the reward token. /// @param amount The amount of rewards claimed. event ClaimRewards( uint256 period, bytes32 _positionHash, address receiver, address reward, uint256 amount ); /// @notice Emitted when a new reward token was pushed to the rewards array event RewardAdded(address reward); /// @notice Emitted when a reward token was removed from the rewards array event RewardRemoved(address reward); /// @notice Initializes the contract with the provided gaugeFactory, voter, and pool addresses. /// @param _gaugeFactory The address of the gaugeFactory to set. /// @param _voter The address of the voter to set. /// @param _nfpManager The address of the NFP manager to set. /// @param _feeCollector The address of the fee collector to set. /// @param _pool The address of the pool to set. function initialize( address _gaugeFactory, address _voter, address _nfpManager, address _feeCollector, address _pool ) external; /// @notice Retrieves the value of the firstPeriod variable. /// @return The value of the firstPeriod variable. function firstPeriod() external returns (uint256); /// @notice Retrieves the total supply of a specific token for a given period. /// @param period The period for which to retrieve the total supply. /// @param token The address of the token for which to retrieve the total supply. /// @return The total supply of the specified token for the given period. function tokenTotalSupplyByPeriod( uint256 period, address token ) external view returns (uint256); /// @notice Retrieves the total boosted seconds for a specific period. /// @param period The period for which to retrieve the total boosted seconds. /// @return The total boosted seconds for the specified period. function periodTotalBoostedSeconds( uint256 period ) external view returns (uint256); /// @notice Retrieves the getTokenTotalSupplyByPeriod of the current period. /// @dev included to support voter's left() check during distribute(). /// @param token The address of the token for which to retrieve the remaining amount. /// @return The amount of tokens left to distribute in this period. function left(address token) external view returns (uint256); /// @notice Retrieves the reward rate for a specific reward address. /// @dev this method returns the base rate without boost /// @param token The address of the reward for which to retrieve the reward rate. /// @return The reward rate for the specified reward address. function rewardRate(address token) external view returns (uint256); /// @notice Retrieves the claimed amount for a specific period, position hash, and user address. /// @param period The period for which to retrieve the claimed amount. /// @param _positionHash The identifier of the NFP for which to retrieve the claimed amount. /// @param reward The address of the token for the claimed amount. /// @return The claimed amount for the specified period, token ID, and user address. function periodClaimedAmount( uint256 period, bytes32 _positionHash, address reward ) external view returns (uint256); /// @notice Retrieves the last claimed period for a specific token, token ID combination. /// @param token The address of the reward token for which to retrieve the last claimed period. /// @param _positionHash The identifier of the NFP for which to retrieve the last claimed period. /// @return The last claimed period for the specified token and token ID. function lastClaimByToken( address token, bytes32 _positionHash ) external view returns (uint256); /// @notice Retrieves the reward address at the specified index in the rewards array. /// @param index The index of the reward address to retrieve. /// @return The reward address at the specified index. function rewards(uint256 index) external view returns (address); /// @notice Checks if a given address is a valid reward. /// @param reward The address to check. /// @return A boolean indicating whether the address is a valid reward. function isReward(address reward) external view returns (bool); /// @notice Returns an array of reward token addresses. /// @return An array of reward token addresses. function getRewardTokens() external view returns (address[] memory); /// @notice Returns the hash used to store positions in a mapping /// @param owner The address of the position owner /// @param index The index of the position /// @param tickLower The lower tick boundary of the position /// @param tickUpper The upper tick boundary of the position /// @return _hash The hash used to store positions in a mapping function positionHash( address owner, uint256 index, int24 tickLower, int24 tickUpper ) external pure returns (bytes32); /// @notice Retrieves the liquidity and boosted liquidity for a specific NFP. /// @param tokenId The identifier of the NFP. /// @return liquidity The liquidity of the position token. /// @return boostedLiquidity The boosted liquidity of the position token. /// @return veNftTokenId The attached veNFT function positionInfo( uint256 tokenId ) external view returns ( uint128 liquidity, uint128 boostedLiquidity, uint256 veNftTokenId ); /// @notice Returns the amount of rewards earned for an NFP. /// @param token The address of the token for which to retrieve the earned rewards. /// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards. /// @return reward The amount of rewards earned for the specified NFP and tokens. function earned( address token, uint256 tokenId ) external view returns (uint256 reward); /// @notice Returns the amount of rewards earned during a period for an NFP. /// @param period The period for which to retrieve the earned rewards. /// @param token The address of the token for which to retrieve the earned rewards. /// @param tokenId The identifier of the specific NFP for which to retrieve the earned rewards. /// @return reward The amount of rewards earned for the specified NFP and tokens. function periodEarned( uint256 period, address token, uint256 tokenId ) external view returns (uint256); /// @notice Retrieves the earned rewards for a specific period, token, owner, index, tickLower, and tickUpper. /// @param period The period for which to retrieve the earned rewards. /// @param token The address of the token for which to retrieve the earned rewards. /// @param owner The address of the owner for which to retrieve the earned rewards. /// @param index The index for which to retrieve the earned rewards. /// @param tickLower The tick lower bound for which to retrieve the earned rewards. /// @param tickUpper The tick upper bound for which to retrieve the earned rewards. /// @return The earned rewards for the specified period, token, owner, index, tickLower, and tickUpper. function periodEarned( uint256 period, address token, address owner, uint256 index, int24 tickLower, int24 tickUpper ) external view returns (uint256); /// @notice Retrieves the earned rewards for a specific period, token, owner, index, tickLower, and tickUpper. /// @dev used by getReward() and saves gas by saving states /// @param period The period for which to retrieve the earned rewards. /// @param token The address of the token for which to retrieve the earned rewards. /// @param owner The address of the owner for which to retrieve the earned rewards. /// @param index The index for which to retrieve the earned rewards. /// @param tickLower The tick lower bound for which to retrieve the earned rewards. /// @param tickUpper The tick upper bound for which to retrieve the earned rewards. /// @param caching Whether to cache the results or not. /// @return The earned rewards for the specified period, token, owner, index, tickLower, and tickUpper. function cachePeriodEarned( uint256 period, address token, address owner, uint256 index, int24 tickLower, int24 tickUpper, bool caching ) external returns (uint256); /// @notice Notifies the contract about the amount of rewards to be distributed for a specific token. /// @param token The address of the token for which to notify the reward amount. /// @param amount The amount of rewards to be distributed. function notifyRewardAmount(address token, uint256 amount) external; /// @notice Retrieves the reward amount for a specific period, NFP, and token addresses. /// @param period The period for which to retrieve the reward amount. /// @param tokens The addresses of the tokens for which to retrieve the reward amount. /// @param tokenId The identifier of the specific NFP for which to retrieve the reward amount. /// @param receiver The address of the receiver of the reward amount. function getPeriodReward( uint256 period, address[] calldata tokens, uint256 tokenId, address receiver ) external; /// @notice Retrieves the rewards for a specific period, set of tokens, owner, index, tickLower, tickUpper, and receiver. /// @param period The period for which to retrieve the rewards. /// @param tokens An array of token addresses for which to retrieve the rewards. /// @param owner The address of the owner for which to retrieve the rewards. /// @param index The index for which to retrieve the rewards. /// @param tickLower The tick lower bound for which to retrieve the rewards. /// @param tickUpper The tick upper bound for which to retrieve the rewards. /// @param receiver The address of the receiver of the rewards. function getPeriodReward( uint256 period, address[] calldata tokens, address owner, uint256 index, int24 tickLower, int24 tickUpper, address receiver ) external; function getRewardForOwner( uint256 tokenId, address[] memory tokens ) external; /// @notice Notifies rewards for periods greater than current period /// @dev does not push fees /// @dev requires reward token to be whitelisted function notifyRewardAmountForPeriod( address token, uint256 amount, uint256 period ) external; /// @notice Notifies rewards for the next period /// @dev does not push fees /// @dev requires reward token to be whitelisted function notifyRewardAmountNextPeriod( address token, uint256 amount ) external; function addRewards(address reward) external; function removeRewards(address reward) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol"; import "./IERC721PermitUpgradeable.sol"; import "../../v2-periphery/interfaces/IPeripheryPayments.sol"; import "../../v2-periphery/interfaces/IPeripheryImmutableState.sol"; import "../libraries/PoolAddress.sol"; /// @title Non-fungible token for positions /// @notice Wraps RA V2 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is 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 The address of the veNFTs function votingEscrow() 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 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } // details about the RA 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 veNFT tokenId attached uint256 veNftTokenId; } /// @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 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; function isApprovedOrOwner( address spender, uint256 tokenId ) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.4.0 <0.9.0; /// @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 FullMath { /// @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 + 1) & 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++; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0 <0.9.0; /// @title Provides functions for deriving a pool address from the factory, tokens, and the fee library PoolAddress { // @dev this has to be changed if the optimization runs are changed // bytes32 internal constant POOL_INIT_CODE_HASH = 0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54; bytes32 internal constant POOL_INIT_CODE_HASH = 0x1565b129f2d1790f12d45301b9b084335626f0c92410bc43130763b69971135d; // bytes32 internal constant POOL_INIT_CODE_HASH = 0x5698d96123f1258c1416afb173cca764c73725fcf9189ae4fe4552dc4b25ce5b; /// @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 Uniswap 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 pure returns (address pool) { require(key.token0 < key.token1); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex"ff", factory, keccak256( abi.encode(key.token0, key.token1, key.fee) ), POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import "./pool/IClPoolImmutables.sol"; import "./pool/IClPoolState.sol"; import "./pool/IClPoolDerivedState.sol"; import "./pool/IClPoolActions.sol"; import "./pool/IClPoolOwnerActions.sol"; import "./pool/IClPoolEvents.sol"; /// @title The interface for a CL V2 Pool /// @notice A CL 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 IClPool is IClPoolImmutables, IClPoolState, IClPoolDerivedState, IClPoolActions, IClPoolOwnerActions, IClPoolEvents { /// @notice Initializes a pool with parameters provided function initialize( address _factory, address _nfpManager, address _veRam, address _voter, address _token0, address _token1, uint24 _fee, int24 _tickSpacing ) external; function _advancePeriod() external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Minimal ERC20 interface for RA /// @notice Contains a subset of the full ERC20 interface that is used in RA V2 interface IERC20Minimal { /// @notice Returns the balance of a token /// @param account The account for which to look up the number of tokens it has, i.e. its balance /// @return The number of tokens held by the account function balanceOf(address account) external view returns (uint256); /// @notice Transfers the amount of token from the `msg.sender` to the recipient /// @param recipient The account that will receive the amount transferred /// @param amount The number of tokens to send from the sender to the recipient /// @return Returns true for a successful transfer, false for an unsuccessful transfer function transfer(address recipient, uint256 amount) external returns (bool); /// @notice Returns the current allowance given to a spender by an owner /// @param owner The account of the token owner /// @param spender The account of the token spender /// @return The current allowance granted by `owner` to `spender` function allowance(address owner, address spender) external view returns (uint256); /// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount` /// @param spender The account which will be allowed to spend a given amount of the owners tokens /// @param amount The amount of tokens allowed to be used by `spender` /// @return Returns true for a successful approval, false for unsuccessful function approve(address spender, uint256 amount) external returns (bool); /// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender` /// @param sender The account from which the transfer will be initiated /// @param recipient The recipient of the transfer /// @param amount The amount of the transfer /// @return Returns true for a successful transfer, false for unsuccessful function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); /// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`. /// @param from The account from which the tokens were sent, i.e. the balance decreased /// @param to The account to which the tokens were sent, i.e. the balance increased /// @param value The amount of tokens that were transferred event Transfer(address indexed from, address indexed to, uint256 value); /// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes. /// @param owner The account that approved spending of its tokens /// @param spender The account for which the spending allowance was modified /// @param value The new allowance from the owner to the spender event Approval(address indexed owner, address indexed spender, uint256 value); }
// 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 IClPoolActions { /// @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 IRamsesV2MintCallback#ramsesV2MintCallback /// 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 IRamsesV2MintCallback#ramsesV2MintCallback /// 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 veNFTTokenId The veNFT 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 veNFTTokenId, 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 veNFTTokenId The veNFT 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 veNFTTokenId ) 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 IRamsesV2SwapCallback#ramsesV2SwapCallback /// @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 IRamsesV2FlashCallback#ramsesV2FlashCallback /// @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; }
// 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 IClPoolDerivedState { /// @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 /// @return secondsPerBoostedLiquidityPeriodX128s Cumulative seconds per boosted 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, uint160[] memory secondsPerBoostedLiquidityPeriodX128s ); /// @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. Boosted data is only valid if it's within the same period /// @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 secondsPerBoostedLiquidityInsideX128 The snapshot of seconds per boosted 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, uint160 secondsPerBoostedLiquidityInsideX128, 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 /// @return secondsPerBoostedLiquidityInsideX128 The snapshot of seconds per boosted liquidity for the range function periodCumulativesInside( uint32 period, int24 tickLower, int24 tickUpper ) external view returns ( uint160 secondsPerLiquidityInsideX128, uint160 secondsPerBoostedLiquidityInsideX128 ); }
// 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 IClPoolEvents { /// @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); }
// 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 IClPoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IClPoolFactory interface /// @return The contract address function factory() external view returns (address); /// @notice The contract that manages CL NFPs, which must adhere to the INonfungiblePositionManager interface /// @return The contract address function nfpManager() external view returns (address); /// @notice The contract that manages veNFTs, which must adhere to the IVotingEscrow interface /// @return The contract address function votingEscrow() external view returns (address); /// @notice The contract that manages RA 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); /// @notice returns the current fee set for the pool function currentFee() external view returns (uint24); }
// 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 IClPoolOwnerActions { /// @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); function setFee(uint24 _fee) external; }
// 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 IClPoolState { /// @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 /// endSecondsPerBoostedLiquidityPeriodX128 Seconds per boosted liquidity at period's end function periods( uint256 period ) external view returns ( uint32 previousPeriod, int24 startTick, int24 lastTick, uint160 endSecondsPerLiquidityCumulativeX128, uint160 endSecondsPerBoostedLiquidityCumulativeX128, uint32 boostedInRange ); /// @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); /// @notice The currently in range derived liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function boostedLiquidity() external view returns (uint128); /// @notice Get the boost information for a specific position at a period /// @return boostAmount the amount of boost this position has for this period, /// veNFTAmount the amount of veNFTs attached to this position for this period, /// secondsDebtX96 used to account for changes in the deposit amount during the period /// boostedSecondsDebtX96 used to account for changes in the boostAmount and veNFT locked during the period, function boostInfos( uint256 period, bytes32 key ) external view returns ( uint128 boostAmount, int128 veNFTAmount, int256 secondsDebtX96, int256 boostedSecondsDebtX96 ); /// @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, uint128 boostedLiquidityGross, int128 boostedLiquidityNet, 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, /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke /// @return attachedVeNFTId the veNFT tokenId attached to the position function positions( bytes32 key ) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1, uint256 attachedVeNFTId ); /// @notice Returns a period's total boost amount and total veNFT attached /// @param period Period timestamp /// @return totalBoostAmount The total amount of boost this period has, /// @return totalVeNFTAmount The total amount of veNFTs attached to this period function boostInfos( uint256 period ) external view returns (uint128 totalBoostAmount, int128 totalVeNFTAmount); /// @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 /// @return boostedSecondsDebtX96 boosted seconds the period function positionPeriodDebt( uint256 period, address recipient, uint256 index, int24 tickLower, int24 tickUpper ) external view returns (int256 secondsDebtX96, int256 boostedSecondsDebtX96); /// @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 /// @return periodBoostedSecondsInsideX96 boosted seconds the period function positionPeriodSecondsInRange( uint256 period, address owner, uint256 index, int24 tickLower, int24 tickUpper ) external view returns ( uint256 periodSecondsInsideX96, uint256 periodBoostedSecondsInsideX96 ); /// @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, /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// @return 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, uint160 secondsPerBoostedLiquidityPeriodX128 ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0 <0.9.0; import './../interfaces/IERC20Minimal.sol'; struct Slot0 { // the current price uint160 sqrtPriceX96; // the current tick int24 tick; // the most-recently updated index of the observations array uint16 observationIndex; // the current maximum number of observations that are being stored uint16 observationCardinality; // the next maximum number of observations to store, triggered in observations.write uint16 observationCardinalityNext; // the current protocol fee as a percentage of the swap fee taken on withdrawal // represented as an integer denominator (1/x)% uint8 feeProtocol; // whether the pool is locked bool unlocked; } struct Observation { // the block timestamp of the observation uint32 blockTimestamp; // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized int56 tickCumulative; // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized uint160 secondsPerLiquidityCumulativeX128; // whether or not the observation is initialized bool initialized; // see secondsPerLiquidityCumulativeX128 but with boost, only valid if timestamp < new period // recorded at the end to not breakup struct slot uint160 secondsPerBoostedLiquidityPeriodX128; // the seconds boosted positions were in range in this period uint32 boostedInRange; } // info stored for each user's position struct PositionInfo { // the amount of liquidity owned by this position uint128 liquidity; // fee growth per unit of liquidity as of the last update to liquidity or fees owed uint256 feeGrowthInside0LastX128; uint256 feeGrowthInside1LastX128; // the fees owed to the position owner in token0/token1 uint128 tokensOwed0; uint128 tokensOwed1; uint256 attachedVeNftTokenId; } struct PeriodBoostInfo { // the total amount of boost this period has uint128 totalBoostAmount; // the total amount of veNFT attached to this period int128 totalVeNftAmount; // individual positions' boost info for this period mapping(bytes32 => BoostInfo) positions; // how a veNFT has been attached to this pool mapping(uint256 => VeNftInfo) veNftInfos; } struct VeNftInfo { // how many times a veNFT has been attached to this pool uint128 timesAttached; // boost ratio used, out of 1e18 uint128 veNftBoostUsedRatio; // how much boost ratio is used by each position mapping(bytes32 => uint256) positionBoostUsedRatio; } struct BoostInfo { // the amount of boost this position has for this period uint128 boostAmount; // the amount of veNFT attached to this position for this period int128 veNftAmount; // used to account for changes in the boostAmount and veNFT locked during the period int256 boostedSecondsDebtX96; // used to account for changes in the deposit amount int256 secondsDebtX96; // used to check if starting seconds have already been written bool initialized; // used to account for changes in secondsPerLiquidity int160 secondsPerLiquidityPeriodStartX128; int160 secondsPerBoostedLiquidityPeriodStartX128; } // info stored for each initialized individual tick struct TickInfo { // the total position liquidity that references this tick uint128 liquidityGross; // amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left), int128 liquidityNet; // the total position boosted liquidity that references this tick uint128 cleanUnusedSlot; // clean unused slot int128 cleanUnusedSlot2; // fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick) // only has relative meaning, not absolute — the value depends on when the tick is initialized uint256 feeGrowthOutside0X128; uint256 feeGrowthOutside1X128; // the cumulative tick value on the other side of the tick int56 tickCumulativeOutside; // the seconds per unit of liquidity on the _other_ side of this tick (relative to the current tick) // only has relative meaning, not absolute — the value depends on when the tick is initialized uint160 secondsPerLiquidityOutsideX128; // the seconds spent on the other side of the tick (relative to the current tick) // only has relative meaning, not absolute — the value depends on when the tick is initialized uint32 secondsOutside; // true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0 // these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks bool initialized; // secondsPerLiquidityOutsideX128 separated into periods, placed here to preserve struct slots mapping(uint256 => uint256) periodSecondsPerLiquidityOutsideX128; // see secondsPerLiquidityOutsideX128, for boosted liquidity mapping(uint256 => uint256) periodSecondsPerBoostedLiquidityOutsideX128; // the total position boosted liquidity that references this tick mapping(uint256 => uint128) boostedLiquidityGross; // period amount of net boosted liquidity added (subtracted) when tick is crossed from left to right (right to left), mapping(uint256 => int128) boostedLiquidityNet; } // info stored for each period struct PeriodInfo { uint32 previousPeriod; int24 startTick; int24 lastTick; uint160 endSecondsPerLiquidityPeriodX128; uint160 endSecondsPerBoostedLiquidityPeriodX128; uint32 boostedInRange; } // accumulated protocol fees in token0/token1 units struct ProtocolFees { uint128 token0; uint128 token1; } // Position period and liquidity struct PositionCheckpoint { uint256 period; uint256 liquidity; } library States { bytes32 public constant STATES_SLOT = keccak256('states.storage'); struct PoolStates { address factory; address nfpManager; address votingEscrow; address voter; address token0; address token1; uint24 fee; int24 tickSpacing; uint128 maxLiquidityPerTick; Slot0 slot0; mapping(uint256 => PeriodInfo) periods; uint256 lastPeriod; uint256 feeGrowthGlobal0X128; uint256 feeGrowthGlobal1X128; ProtocolFees protocolFees; uint128 liquidity; uint128 boostedLiquidity; mapping(int24 => TickInfo) _ticks; mapping(int16 => uint256) tickBitmap; mapping(bytes32 => PositionInfo) positions; mapping(uint256 => PeriodBoostInfo) boostInfos; mapping(bytes32 => uint256) cleanUnusedSlot; Observation[65535] observations; mapping(bytes32 => PositionCheckpoint[]) positionCheckpoints; uint24 initialFee; bool initialized; } // Return state storage struct for reading and writing function getStorage() internal pure returns (PoolStates storage storageStruct) { bytes32 position = STATES_SLOT; assembly { storageStruct.slot := position } } /// @dev Returns the block timestamp truncated to 32 bits, i.e. mod 2**32. This method is overridden in tests. function _blockTimestamp() internal view returns (uint32) { return uint32(block.timestamp); // truncation is desired } /// @dev Get the pool's balance of token0 /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize /// check function balance0() internal view returns (uint256) { PoolStates storage states = getStorage(); (bool success, bytes memory data) = states.token0.staticcall( abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)) ); require(success && data.length >= 32); return abi.decode(data, (uint256)); } /// @dev Get the pool's balance of token1 /// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize /// check function balance1() internal view returns (uint256) { PoolStates storage states = getStorage(); (bool success, bytes memory data) = states.token1.staticcall( abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)) ); require(success && data.length >= 32); return abi.decode(data, (uint256)); } }
{ "optimizer": { "enabled": true, "runs": 800 }, "evmVersion": "paris", "viaIR": true, "metadata": { "bytecodeHash": "none" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"reward","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"Bribe","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"},{"indexed":false,"internalType":"bytes32","name":"_positionHash","type":"bytes32"},{"indexed":false,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"address","name":"reward","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"reward","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"period","type":"uint256"}],"name":"NotifyReward","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reward","type":"address"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"reward","type":"address"}],"name":"RewardRemoved","type":"event"},{"inputs":[{"internalType":"address","name":"reward","type":"address"}],"name":"addRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"bool","name":"caching","type":"bool"}],"name":"cachePeriodEarned","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"earned","outputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeCollector","outputs":[{"internalType":"contract IFeeCollector","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"firstPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"gaugeFactory","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"address","name":"receiver","type":"address"}],"name":"getPeriodReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"receiver","type":"address"}],"name":"getPeriodReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"address","name":"receiver","type":"address"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getRewardForOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_gaugeFactory","type":"address"},{"internalType":"address","name":"_voter","type":"address"},{"internalType":"address","name":"_nfpManager","type":"address"},{"internalType":"address","name":"_feeCollector","type":"address"},{"internalType":"address","name":"_pool","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isReward","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"lastClaimByToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"left","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nfpManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"}],"name":"notifyRewardAmountForPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"notifyRewardAmountNextPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"}],"name":"periodClaimedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"periodEarned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"name":"periodEarned","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"periodTotalBoostedSeconds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"contract IClPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"name":"positionHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positionInfo","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint128","name":"boostedLiquidity","type":"uint128"},{"internalType":"uint256","name":"veNftTokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"reward","type":"address"}],"name":"removeRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"periods","type":"uint256[]"}],"name":"retrieveLeftovers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"_rewardRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewards","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tokenTotalSupplyByPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"veNftTokenId","type":"uint256"}],"name":"veNftInfo","outputs":[{"internalType":"uint128","name":"timesAttached","type":"uint128"},{"internalType":"uint128","name":"veNftBoostUsedRatio","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"voter","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
60808060405234620000c6576000549060ff8260081c1662000074575060ff8082160362000038575b6040516138489081620000cc8239f35b60ff90811916176000557f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb3847402498602060405160ff8152a13862000028565b62461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b6064820152608490fd5b600080fdfe610140806040526004610100526101005136101561001c57600080fd5b600061012052610120513560e01c9081630d52333c14612552575080631459457a146120c557806316f0115b1461209c5780631b9e88b114611ee2578063221ca18c14611e3757806329b2f63714611cf95780633e491d4714611bad57806346c96aac14611b845780634d5ce03814611b4157806362da4afd14611a9a57806363100db814611a68578063648172a2146117655780637af618331461171557806389097a6a146114ee5780638ed6a18c1461123757806398bbc3c71461120c57806399bcc0521461117b5780639a32421a14610f4c5780639decce4314610e285780639dfb338114610c99578063a230575614610c61578063a7852afa14610b14578063b66503cf1461095d578063be171c5e1461090a578063c415b95c146108e1578063c4e3a63b146108c1578063c4f59f9b146107f1578063c6cee7581461074e578063e102dac4146106ed578063e73b49b41461065c578063e77b11d214610481578063e92a9fa914610432578063eb6ebc27146103e3578063f301af42146103a05763f5f8d365146101b157600080fd5b3461035b576101bf3661276e565b6101205154906101d460ff8360101c1661284b565b62ff00001980921661012051556001600160a01b038061010051541690604051906331a9108f60e11b825285610100518301526020908183602481875afa92831561030c576101205193610369575b5060405163020604bf60e21b81526101005181018890528281602481885afa92831561030c576101205193610327575b50508061026c9316331491821561031a575b50506128f9565b60405163133f757160e31b8152610100518101859052916101808084602481865afa90811561030c5762010000966102b695610120519261012051946102cc575b50503394613530565b6101205154161761012051556101205161012051f35b80919294506102f09350903d10610305575b6102e881836126c4565b810190612994565b505050505095509350505050909138806102ad565b503d6102de565b6040513d61012051823e3d90fd5b9091501633143880610265565b9080949350813d8311610362575b61033f81836126c4565b8101031261035b578061035461026c946127ee565b9293610253565b6101205180fd5b503d610335565b9092508181813d8311610399575b61038181836126c4565b8101031261035b57610392906127ee565b9138610223565b503d610377565b3461035b57602036600319011261035b576101005135600d5481101561035b576001600160a01b036103d36020926127a1565b9190546040519260031b1c168152f35b3461035b5760c036600319011261035b57602061042a610401612593565b6104096125a9565b90610412612606565b9061041b612616565b9260643591610100513561323f565b604051908152f35b3461035b57604036600319011261035b5761044b612593565b6101005135610120515260066020526001600160a01b036040610120512091166000526020526020604060002054604051908152f35b3461035b57604036600319011261035b5761049a61257d565b6001600160a01b036101205154916104b760ff8460101c1661284b565b62ff00001980931661012051551690816101205152602091600e83526104e660ff60406101205120541661287d565b62093a804204926001840180941161064057604051936370a0823160e01b80865230610100518701528286602481875afa95861561030c576101205196610611575b506105376024353033876132f8565b60405190815230610100518201528281602481875afa90811561030c5761012051916105dc575b50620100009561056d916128c9565b91816101205152600681526040610120512084600052815260406000206105958482546128ec565b90556040519283528201527f52977ea98a2220a03ee9ba5cb003ada08d394ea10155483c95dc2dc77a7eb24b60403392a36101205154161761012051556101205161012051f35b90508281813d831161060a575b6105f381836126c4565b8101031261060557516201000061055e565b600080fd5b503d6105e9565b9095508281813d8311610639575b61062981836126c4565b8101031261060557519486610528565b503d61061f565b634e487b7160e01b610120515260116101005152602461012051fd5b3461035b57602036600319011261035b5761067561257d565b6001600160a01b0361068c81600254163314612b47565b811690816101205152600e60205260ff604061012051205416156106b2575b6101205180f35b7fb13fd610fe4e1b384966826794a9b2f6100ad031f352cc5ec6f22667f6074980916106df602092612802565b604051908152a180806106ab565b3461035b57606036600319011261035b576107066125a9565b61010051356101205152600b6020526040610120512060243561012051526020526001600160a01b036040610120512091166000526020526020604060002054604051908152f35b3461035b5760c036600319011261035b5761076761257d565b61076f612626565b90610778612636565b9060843567ffffffffffffffff811161035b5761079b90369061010051016126fe565b60a435906001600160a01b039384831683036106055762010000956102b6946107e86101205154976107d260ff8a60101c1661284b565b62ff0000198099166101205155821633146128f9565b60243590613530565b3461035b576101205136600319011261035b5760405180600d5480835260208093018091600d61012051527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb590610120515b868282106108a4578686610859828803836126c4565b6040519283928184019082855251809152604084019291610120515b82811061088457505050500390f35b83516001600160a01b031685528695509381019392810192600101610875565b83546001600160a01b031685529093019260019283019201610843565b3461035b576101205136600319011261035b576020600554604051908152f35b3461035b576101205136600319011261035b5760206001600160a01b0360035416604051908152f35b3461035b5760e036600319011261035b57610923612593565b61092b6125a9565b610933612606565b61093b612616565b60c43591821515830361035b5760209461042a94606435916101005135612f7a565b3461035b57604036600319011261035b5761097661257d565b6001600160a01b038060035416816001541690803b1561035b5760405191632a54db0160e01b83526101005183015281602481610120519361012051905af1801561030c57610b05575b506101205154906109d660ff8360101c1661284b565b62ff00001980921661012051558060015416803b1561035b57604051906361707cd960e11b825281610120519181610100519161012051905af1801561030c57610aee575b5062093a804204928160025416331480610acf575b610a78575b16604051926370a0823160e01b9081855230610100518601526020918286602481875afa95861561030c57610120519661061157506105376024353033876132f8565b7fb13fd610fe4e1b384966826794a9b2f6100ad031f352cc5ec6f22667f60749806020838316806101205152600e825260406101205120600160ff19825416179055610ac384612802565b604051908152a1610a35565b508181166101205152600e60205260ff60406101205120541615610a30565b610af790612646565b6101205161035b5783610a1b565b610b0e90612646565b826109c0565b3461035b57610b223661276e565b90610120515490610b3860ff8360101c1661284b565b62ff00001980921661012051556001600160a01b03806002541633148015610c52575b610b64906128f9565b61010051541692604051906331a9108f60e11b82528261010051830152602082602481885afa91821561030c576101205192610c16575b5060405163133f757160e31b81526101005181018490529261018080856024818a5afa91821561030c5762010000976102b69661012051936101205195610be4575b5050613530565b8091929550610c00939450903d10610305576102e881836126c4565b5050505050969550935050505091928980610bdd565b9091506020813d602011610c4a575b81610c32602093836126c4565b8101031261035b57610c43906127ee565b9085610b9b565b3d9150610c25565b50610100515481163314610b5b565b3461035b57608036600319011261035b57602061042a610c7f61257d565b610c87612626565b610c8f612636565b9160243590612b93565b3461035b57602036600319011261035b57610cb261257d565b6001600160a01b038091610ccb82600254163314612b47565b16806101205152600e60205260ff604061012051205416610ced576101205180f35b61012051600d805490929190815b818110610dfe575b50505b8254600019810190811161064057811015610d6c57600181019081811161064057610d66610d356001936127a1565b905487610d41856127a1565b92909360031b1c16906001600160a01b038084549260031b9316831b921b1916179055565b01610d06565b50600d5491508115610de2577f755c47ac85b75fe2251607db5a480aac818b88bb535814bf1e3c4784ae4f6baa926020926000190190610dab826127a1565b909182549160031b1b19169055600d55806101205152600e82526040610120512060ff198154169055604051908152a180806106ab565b634e487b7160e01b610120515260316101005152602461012051fd5b8386610e09836127a1565b90549060031b1c1614610e1e57600101610cfb565b9150508480610d03565b3461035b5760208060031936011261035b5762093a80420461012051527f568f905fee3c29dbecf3583ddfaf086f7336b6bee88b499cc887c595fb7bf1eb815260026040610120512001610100513561012051528152604061012051209060405191610e938361268c565b60018352813681850137610ea683612a50565b526001600160a01b036001541691604051809363e57c0ca960e01b82528180610ed86101205195610100518301612b0b565b03915afa90811561030c576040926101205192610f25575b50610f166fffffffffffffffffffffffffffffffff610f0e84612a50565b511692612a50565b5160801c908351928352820152f35b610f459192503d8061012051833e610f3d81836126c4565b810190612a91565b9083610ef0565b3461035b57604036600319011261035b57610100513567ffffffffffffffff9081811161035b57610f8390369061010051016125d5565b9160249060243590811161035b57610fa190369061010051016126fe565b92610120515b818110610fb5576101205180f35b610fc0818386612945565b35906101205154610fd660ff8260101c1661284b565b62ff00001980911661012051556001600160a01b03908161010051541691604051906331a9108f60e11b8252856101005183015260209081838a81885afa92831561030c576101205193611144575b5060405163020604bf60e21b815261010051810188905282818b81895afa92831561030c576101205193611109575b50508061106c931633149182156110fc5750506128f9565b60405163133f757160e31b8152610100518101859052936101809283868981845afa95861561030c5760019662010000956110ba948d93610120519261012051946110cc5750503394613530565b61012051541617610120515501610fa7565b80919294506110e79350903d10610305576102e881836126c4565b50505050509550935050505090918e806102ad565b9091501633148a80610265565b9080949350813d831161113d575b61112181836126c4565b8101031261035b578061113661106c946127ee565b9293611054565b503d611117565b9092508181813d8311611174575b61115c81836126c4565b8101031261035b5761116d906127ee565b918b611025565b503d611152565b3461035b57602036600319011261035b5761119461257d565b62093a809081420490600182018083116106405783810290808204851490151715610640576111c49042906128c9565b91610120515260066020526001600160a01b03604061012051209116610120515260205260406101205120548181029181830414901517156106405760209160405191048152f35b3461035b576101205136600319011261035b5760206001600160a01b03610100515416604051908152f35b3461035b57608036600319011261035b5760243567ffffffffffffffff811161035b5761126a90369061010051016125d5565b6112726125bf565b60e052610120515461128960ff8260101c1661284b565b62ff0000191661012051556001600160a01b036101005154166040516331a9108f60e11b815260443561010051820152602081602481855afa90811561030c5761012051916114b4575b5060405163020604bf60e21b8152610100516044359082015290602082602481865afa91821561030c57610120519261146e575b50906001600160a01b036113269216331490811561145b575b506128f9565b60405163133f757160e31b81526101005160443590820152610180908181602481865afa801561030c57610120516080526101205160a05261142c575b505061137760a05160805160443584612b93565b60c052610120515b82811061139c5761012051805462ff000019166201000017815580f35b60019062093a8042046101005135106113e7575b6113e160e05160c05160a05160805189886113d76113d2898d60443595612945565b612955565b610100513561334e565b0161137f565b6001600160a01b036113fd6113d2838789612945565b166101205152600c6020526040610120512060c0516101205152602052610100513560406101205120556113b0565b8161144292903d10610305576102e881836126c4565b50505050509550935050505060805260a0528380611363565b6001600160a01b03915016331485611320565b91506020823d6020116114ac575b81611489602093836126c4565b8101031261035b576001600160a01b036114a5611326936127ee565b9250611307565b3d915061147c565b90506020813d6020116114e6575b816114cf602093836126c4565b8101031261035b576114e0906127ee565b846112d3565b3d91506114c2565b3461035b5760208060031936011261035b576101005135906001600160a01b0391826101005154166040519163133f757160e31b83528061010051840152610180908184602481865afa92831561030c5761155994610120519361012051956116e3575b5050612b93565b918261012051527f568f905fee3c29dbecf3583ddfaf086f7336b6bee88b499cc887c595fb7bf1ea8252604061012051209262093a80420461012051527f568f905fee3c29dbecf3583ddfaf086f7336b6bee88b499cc887c595fb7bf1eb83526001604061012051200190610120515282526040610120512092604051936115e085612670565b6003855260603685870137816115f586612a50565b526115ff85612a5d565b52610100510161160e84612a6d565b526001541691604051809363e57c0ca960e01b825281806116386101205195610100518301612b0b565b03915afa90811561030c5760609261012051926116c4575b5061165a82612a5d565b5160801b61166783612a5d565b5261167182612a5d565b5160801c61167e83612a5d565b526fffffffffffffffffffffffffffffffff916116b28361169e83612a50565b5116936116aa83612a5d565b511691612a6d565b51916040519384528301526040820152f35b6116dc9192503d8061012051833e610f3d81836126c4565b9083611650565b80919295506116ff939450903d10610305576102e881836126c4565b5050505050969550935050505091928780611552565b3461035b57604036600319011261035b576001600160a01b0361173661257d565b166101205152600c60205260406101205120602435610120515260205260206040610120512054604051908152f35b3461035b57604036600319011261035b57610100513567ffffffffffffffff9081811161035b5761179c90369061010051016125d5565b9060249260243590811161035b576117ba90369061010051016125d5565b939091610120515b8481106117d0576101205180f35b6117de6113d2828785612945565b610120515b8781106117f45750506001016117c2565b6117ff818988612945565b3590610b0e8211611a3a578161012051526020916007835260406101205120546101205150610120519080611985575b5080611842575b505060019150016117e3565b816101205152600b8452604061012051206101205161012051528452604061012051206001600160a01b03948587169182610120515281526040610120512061188c8482546128ec565b90558560035416908060405180936361d027b360e01b825281610100519161012051905af191821561030c57610120519261191f575b5091600196827fc8c7ebd754a625a8677ab2031c7674259be1e8c1a7f3521cbf5edbca8f48099c96946118f98760a09896866134f6565b604051958652610120519086015216604084015260608301526080820152a18980611836565b93915093918484813d831161197e575b61193981836126c4565b8101031261035b576001967fc8c7ebd754a625a8677ab2031c7674259be1e8c1a7f3521cbf5edbca8f48099c9561197160a0966127ee565b93955091939550966118c2565b503d61192f565b905060069081855260406101205120916001600160a01b0387169283610120515286526040610120512054818102918183041490151715611a1f5762093a80918203918211611a1f57611a199291600a6119df9204613400565b90836101205152600b86526040610120512061012051610120515286526040610120512090610120515285526040610120512054906128c9565b8b61182f565b89634e487b7160e01b61012051526011610100515261012051fd5b60405162461bcd60e51b815261010080516020908301525181880152634e6f706560e01b6044820152606490fd5b3461035b57602036600319011261035b5761010051356101205152600760205260206040610120512054604051908152f35b3461035b57606036600319011261035b57611ab3612593565b6044356001600160a01b036101005154166040519163133f757160e31b83528061010051840152610180908184602481865afa92831561030c5760209561042a9561012051946101205196611b0f575b5050610100513561323f565b8091929650611b2b939550903d10610305576102e881836126c4565b5050505050979550935050505092938780611b03565b3461035b57602036600319011261035b576001600160a01b03611b6261257d565b166101205152600e602052602060ff6040610120512054166040519015158152f35b3461035b576101205136600319011261035b5760206001600160a01b0360025416604051908152f35b3461035b57604036600319011261035b57611bc661257d565b60243590610120515061012051916001600160a01b0380610100515416916040519263133f757160e31b84528161010051850152610180928385602481855afa94851561030c5761012051946101205196611cc7575b5050611c2a85858585612b93565b9086166101205152600c6020526040610120512090610120515260205260406101205120546005546101205150808211600014611cb95750939291909594955b62093a80420494965b85881115611c8657602087604051908152f35b909192939495611ca7611cad91611ca188888888888f61323f565b906128ec565b97612a41565b96959493929190611c73565b905093929190959495611c6a565b8091929650611ce3939550903d10610305576102e881836126c4565b5050505050979550935050505092938780611c1c565b3461035b5760e036600319011261035b5760243567ffffffffffffffff811161035b57611d2c90369061010051016125d5565b611d346125a9565b611d3c612606565b91611d45612616565b6001600160a01b0360c4351660c4350361035b576101205154611d6d60ff8260101c1661284b565b62ff000019166101205155611d8c6001600160a01b03841633146128f9565b611d9a818560643586612b93565b90610120515b838110611dbd5761012051805462ff000019166201000017815580f35b60019062093a804204610100513510611df4575b611dee8585858a8c8b6113d76113d28960c4359860643595612945565b01611da0565b6001600160a01b03611e0a6113d283888c612945565b1661012051526020600c815260406101205120908561012051525261010051356040610120512055611dd1565b3461035b5760208060031936011261035b57611e5161257d565b62093a809042829004610b0e811115611e96576101205152600683526001600160a01b0360406101205120911661012051528252604061012051205404604051908152f35b9091506101205152600682526001600160a01b036040610120512091166101205152815260406101205120548060021b9080820461010051149015171561064057625c4900900461042a565b3461035b57606036600319011261035b57611efb61257d565b604435906001600160a01b03610120515491611f1c60ff8460101c1661284b565b62ff0000198093166101205155168061012051526020600e8152611f4960ff60406101205120541661287d565b62093a80420484111561205657604051936370a0823160e01b80865230610100518701528286602481875afa95861561030c576101205196612027575b50611f956024353033876132f8565b60405190815230610100518201528281602481875afa90811561030c576101205191611ff7575b506201000095611fcb916128c9565b9181610120515260068152604061012051208461012051528152604061012051206105958482546128ec565b90508281813d8311612020575b61200e81836126c4565b8101031261035b575162010000611fbc565b503d612004565b9095508281813d831161204f575b61203f81836126c4565b8101031261035b57519486611f86565b503d612035565b6064906040519062461bcd60e51b825261010051820152600560248201527f526574726f0000000000000000000000000000000000000000000000000000006044820152fd5b3461035b576101205136600319011261035b5760206001600160a01b0360015416604051908152f35b3461035b5760a036600319011261035b576120de61257d565b6120e6612593565b6120ee6125a9565b906120f76125bf565b6084356001600160a01b039081811680910361035b5761012051549060ff8260081c161594858096612545575b801561252e575b156124c2578382916201000060019a60ff19968a8d8983161761012051556124ad575b507fffffffffffffffffff000000000000000000000000000000000000000000ffff76ffffffffffffffffffffffffffffffffffffffff00000061012051549260181b169116171761012051551696847fffffffffffffffffffffffff000000000000000000000000000000000000000091898360025416176002558160039816836003541617600355168161010051541617610100515588541617875562093a804204600555604051635001f3b560e01b815260209687826101005181845afa91821561030c576101205192612476575b50876040518092630445b4cf60e11b82528161010051915afa90811561030c576101205191612441575b5060405190630dfe168160e01b825288826101005181875afa91821561030c57610120519261240a575b5088604051809563d21220a760e01b82528161010051915afa92831561030c57869461012051946123c7575b5084929183826122b08294612802565b6122b983612802565b6122c285612802565b6122cb87612802565b166101205152600e8b52604061012051208c88825416179055166101205152604061012051208a868254161790551661012051526040610120512088848254161790551661012051528560406101205120918254161790556101205150610120519185600d54935b84811061238557508585612348576101205180f35b61012051805461ff00191690556040519182527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249891a180806106ab565b7fb13fd610fe4e1b384966826794a9b2f6100ad031f352cc5ec6f22667f607498087856123b1846127a1565b905490871b1c16604051908152a1018690612333565b94509250908884813d8111612403575b6123e181836126c4565b8101031261035b5785809492816123f881956127ee565b9592505091926122a0565b503d6123d7565b9091508881813d831161243a575b61242281836126c4565b8101031261035b57612433906127ee565b908a612274565b503d612418565b90508781813d831161246f575b61245881836126c4565b8101031261035b57612469906127ee565b8961224a565b503d61244e565b9091508781813d83116124a6575b61248e81836126c4565b8101031261035b5761249f906127ee565b9089612220565b503d612484565b6101019061ffff19161761012051558c61214e565b608460405162461bcd60e51b8152602061010051820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b50303b15801561212b5750600160ff84161461212b565b50600160ff841610612124565b3461035b576101205136600319011261035b576020906001600160a01b03610120515460181c168152f35b600435906001600160a01b038216820361060557565b602435906001600160a01b038216820361060557565b604435906001600160a01b038216820361060557565b606435906001600160a01b038216820361060557565b9181601f840112156106055782359167ffffffffffffffff8311610605576020808501948460051b01011161060557565b608435908160020b820361060557565b60a435908160020b820361060557565b604435908160020b820361060557565b606435908160020b820361060557565b67ffffffffffffffff811161265a57604052565b634e487b7160e01b600052604160045260246000fd5b6080810190811067ffffffffffffffff82111761265a57604052565b6040810190811067ffffffffffffffff82111761265a57604052565b60e0810190811067ffffffffffffffff82111761265a57604052565b90601f8019910116810190811067ffffffffffffffff82111761265a57604052565b67ffffffffffffffff811161265a5760051b60200190565b9080601f83011215610605576020908235612718816126e6565b9361272660405195866126c4565b81855260208086019260051b82010192831161060557602001905b82821061274f575050505090565b81356001600160a01b0381168103610605578152908301908301612741565b90604060031983011261060557600435916024359067ffffffffffffffff82116106055761279e916004016126fe565b90565b600d548110156127d857600d6000527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50190600090565b634e487b7160e01b600052603260045260246000fd5b51906001600160a01b038216820361060557565b600d54906801000000000000000082101561265a5761282a8260016128499401600d556127a1565b9091906001600160a01b038084549260031b9316831b921b1916179055565b565b1561285257565b60405162461bcd60e51b81526020600482015260036024820152624c4f4b60e81b6044820152606490fd5b1561288457565b60405162461bcd60e51b815260206004820152600c60248201527f2157686974656c697374656400000000000000000000000000000000000000006044820152606490fd5b919082039182116128d657565b634e487b7160e01b600052601160045260246000fd5b919082018092116128d657565b1561290057565b60405162461bcd60e51b815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606490fd5b91908110156127d85760051b0190565b356001600160a01b03811681036106055790565b51908160020b820361060557565b51906fffffffffffffffffffffffffffffffff8216820361060557565b9190826101809103126106055781516bffffffffffffffffffffffff8116810361060557916129c5602082016127ee565b916129d2604083016127ee565b916129df606082016127ee565b91608082015162ffffff8116810361060557916129fe60a08201612969565b91612a0b60c08301612969565b91612a1860e08201612977565b91610100820151916101208101519161279e610160612a3a6101408501612977565b9301612977565b60001981146128d65760010190565b8051156127d85760200190565b8051600110156127d85760400190565b8051600210156127d85760600190565b80518210156127d85760209160051b010190565b60209081818403126106055780519067ffffffffffffffff821161060557019180601f84011215610605578251612ac7816126e6565b93612ad560405195866126c4565b818552838086019260051b820101928311610605578301905b828210612afc575050505090565b81518152908301908301612aee565b602090602060408183019282815285518094520193019160005b828110612b33575050505090565b835185529381019392810192600101612b25565b15612b4e57565b60405162461bcd60e51b815260206004820152600560248201527f21415554480000000000000000000000000000000000000000000000000000006044820152606490fd5b9290916040519260208401946bffffffffffffffffffffffff199060601b168552603484015260e81b605483015260e81b6057820152603a81526060810181811067ffffffffffffffff82111761265a5760405251902090565b3d15612c28573d9067ffffffffffffffff821161265a5760405191612c1c601f8201601f1916602001846126c4565b82523d6000602084013e565b606090565b519063ffffffff8216820361060557565b80959193949294600095612c5484868484612b93565b938388526020956008875260408981809b20888252895260ff828220541615600014612f4657505091600094918594936001600160a01b03948560015416958c51948b860196634c8c7ddb60e11b88526024870152166044850152606484015260020b608483015260020b60a482015260a48152612cd1816126a8565b51915afa612cdd612bed565b9015612f3b578481805181010312610605578483820151910151908062093a804204881080612f33575b612edd575b505b866000526006845285600020946001600160a01b038091169586600052855286600020549260068402848104600614851517156128d657600a900491610b0e8a11908115612ecc575b62093a8042048b10612dcd575b5015612db0575050612d7591613467565b945b600052600b8252836000209060005281528260002091600052526000205480821015600014612da95761279e916128c9565b5050600090565b612dc1611ca19293612dc795613467565b92613467565b94612d77565b8a600052600788528960002054612d64576001541660c08b60248c5180948193633a92844160e21b835260048301525afa8015612ec157600091600091612e48575b5063ffffffff809216151580612e40575b612e2b575b50612d64565b8b600052600789521689600020553880612e25565b506001612e20565b91505060c0813d60c011612eb9575b81612e6460c093836126c4565b8101031261060557612eb360a0612e7a83612c2d565b92612e868b8201612969565b50612e928d8201612969565b50612e9f606082016127ee565b50612eac608082016127ee565b5001612c2d565b38612e0f565b3d9150612e57565b8a513d6000823e3d90fd5b9483612ed7916128c9565b94612d57565b87600052600885528660002084600052855286600020600160ff19825416179055876000526009855286600020846000528552866000205586600052600a84528560002083600052845281866000205538612d0c565b506001612d07565b505050505050600090565b945094925050508152600984528181208382528452205485600052600a835284600020826000528352846000205490612d0e565b80969493959295600096612f9085878484612b93565b948389526020966008885260408a81809c208982528a5260ff82822054161560001461320b57505091600094918594936001600160a01b03948560015416958d51948c860196634c8c7ddb60e11b88526024870152166044850152606484015260020b608483015260020b60a482015260a4815261300d816126a8565b51915afa613019612bed565b90156131ff578581805181010312610605578584820151910151948162093a8042048910806131f8575b6131a2575b505b876000526006855286600020956001600160a01b038094169687600052865287600020549360068502858104600614861517156128d657600a900492610b0e8b11918215613191575b62093a8042048c106130b2575b505015612db0575050612d7591613467565b8b600052600789528a600020546130a057600154169060c08c60248d5180958193633a92844160e21b835260048301525afa9081156131865760009260009261312b575b5063ffffffff80931615159081613123575b50156130a0578b6000526007895216896000205538806130a0565b905038613108565b9250905060c0823d60c01161317e575b8161314860c093836126c4565b810103126106055761317760a083612e928e61316f6131678f98612c2d565b978401612969565b508201612969565b90386130f6565b3d915061313b565b8b513d6000823e3d90fd5b958461319c916128c9565b95613093565b88600052600886528760002085600052865287600020600160ff19825416179055886000526009865287600020856000528652876000205587600052600a85528660002084600052855285876000205538613048565b5081613043565b50505050505050600090565b945094925050508152600985528181208482528552205486600052600a84528560002083600052845285600020549461304a565b9391949290604051956020870195635f0b8e2f60e11b875260248801526001600160a01b038092166044880152166064860152608485015260020b60a484015260020b60c48301526000918260e482015260e48152610120810181811067ffffffffffffffff8211176132e457604052518291829190305afa906132c1612bed565b91156132df576020828051810103126132dc57506020015190565b80fd5b905090565b634e487b7160e01b84526041600452602484fd5b9290604051926323b872dd60e01b60208501526001600160a01b03809216602485015216604483015260648201526064815260a081019181831067ffffffffffffffff84111761265a576128499260405261365a565b9491926133619397969491978887612c3e565b908161336f575b5050505050565b7fc8c7ebd754a625a8677ab2031c7674259be1e8c1a7f3521cbf5edbca8f48099c9460a094600092858452600b602052604084208185526020526040808520946001600160a01b0380951695868252602052206133cd8682546128ec565b90556133da8583866134f6565b604051958652602086015216604084015260608301526080820152a13880808080613368565b909190600019838209928082029283808610950394808603951461345a575062093a8091848311156106055709118082038060f91b04600160f91b14911417156128d657634e487b7160e01b600052601160045260246000fd5b9350505062093a80900490565b90919060001983820992808202928380861095039480860395146134dd57506e093a8000000000000000000000000091848311156106055709118082038060991b0473020000000000000000000000000000000000000014911417156128d657634e487b7160e01b600052601160045260246000fd5b935050506e093a80000000000000000000000000900490565b612849926001600160a01b036040519363a9059cbb60e01b602086015216602484015260448301526044825261352b82612670565b61365a565b929395949161354185828487612b93565b9262093a804204600091600019820197828911935b8b5181101561364c576001600160a01b039081613573828f612a7d565b5116600052600c918d6020848152604091826000208d60005282528260002054600554808211600014613632575085918f8f8f908f8f95908f94938f948f938d905b975b8811156135f85750505050505050505090506128d6578f948e936135dd86600198612a7d565b5116600052815281600020908c600052526000205501613556565b613619995061360c899b613614999a612a7d565b51168861334e565b612a41565b85918f918f8f908f8f95908f938f94928f938d906135b7565b905085918f8f8f908f8f95908f94938f948f938d906135b5565b505050505050505050509050565b6001600160a01b0316906136ba6040516136738161268c565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af16136b4612bed565b91613767565b80519182159184831561373f575b5050509050156136d55750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b919381809450010312613763578201519081151582036132dc5750803880846136c8565b5080fd5b919290156137c9575081511561377b575090565b3b156137845790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156137dc5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510613822575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506137ff56fea164736f6c6343000816000a
Deployed Bytecode
0x610140806040526004610100526101005136101561001c57600080fd5b600061012052610120513560e01c9081630d52333c14612552575080631459457a146120c557806316f0115b1461209c5780631b9e88b114611ee2578063221ca18c14611e3757806329b2f63714611cf95780633e491d4714611bad57806346c96aac14611b845780634d5ce03814611b4157806362da4afd14611a9a57806363100db814611a68578063648172a2146117655780637af618331461171557806389097a6a146114ee5780638ed6a18c1461123757806398bbc3c71461120c57806399bcc0521461117b5780639a32421a14610f4c5780639decce4314610e285780639dfb338114610c99578063a230575614610c61578063a7852afa14610b14578063b66503cf1461095d578063be171c5e1461090a578063c415b95c146108e1578063c4e3a63b146108c1578063c4f59f9b146107f1578063c6cee7581461074e578063e102dac4146106ed578063e73b49b41461065c578063e77b11d214610481578063e92a9fa914610432578063eb6ebc27146103e3578063f301af42146103a05763f5f8d365146101b157600080fd5b3461035b576101bf3661276e565b6101205154906101d460ff8360101c1661284b565b62ff00001980921661012051556001600160a01b038061010051541690604051906331a9108f60e11b825285610100518301526020908183602481875afa92831561030c576101205193610369575b5060405163020604bf60e21b81526101005181018890528281602481885afa92831561030c576101205193610327575b50508061026c9316331491821561031a575b50506128f9565b60405163133f757160e31b8152610100518101859052916101808084602481865afa90811561030c5762010000966102b695610120519261012051946102cc575b50503394613530565b6101205154161761012051556101205161012051f35b80919294506102f09350903d10610305575b6102e881836126c4565b810190612994565b505050505095509350505050909138806102ad565b503d6102de565b6040513d61012051823e3d90fd5b9091501633143880610265565b9080949350813d8311610362575b61033f81836126c4565b8101031261035b578061035461026c946127ee565b9293610253565b6101205180fd5b503d610335565b9092508181813d8311610399575b61038181836126c4565b8101031261035b57610392906127ee565b9138610223565b503d610377565b3461035b57602036600319011261035b576101005135600d5481101561035b576001600160a01b036103d36020926127a1565b9190546040519260031b1c168152f35b3461035b5760c036600319011261035b57602061042a610401612593565b6104096125a9565b90610412612606565b9061041b612616565b9260643591610100513561323f565b604051908152f35b3461035b57604036600319011261035b5761044b612593565b6101005135610120515260066020526001600160a01b036040610120512091166000526020526020604060002054604051908152f35b3461035b57604036600319011261035b5761049a61257d565b6001600160a01b036101205154916104b760ff8460101c1661284b565b62ff00001980931661012051551690816101205152602091600e83526104e660ff60406101205120541661287d565b62093a804204926001840180941161064057604051936370a0823160e01b80865230610100518701528286602481875afa95861561030c576101205196610611575b506105376024353033876132f8565b60405190815230610100518201528281602481875afa90811561030c5761012051916105dc575b50620100009561056d916128c9565b91816101205152600681526040610120512084600052815260406000206105958482546128ec565b90556040519283528201527f52977ea98a2220a03ee9ba5cb003ada08d394ea10155483c95dc2dc77a7eb24b60403392a36101205154161761012051556101205161012051f35b90508281813d831161060a575b6105f381836126c4565b8101031261060557516201000061055e565b600080fd5b503d6105e9565b9095508281813d8311610639575b61062981836126c4565b8101031261060557519486610528565b503d61061f565b634e487b7160e01b610120515260116101005152602461012051fd5b3461035b57602036600319011261035b5761067561257d565b6001600160a01b0361068c81600254163314612b47565b811690816101205152600e60205260ff604061012051205416156106b2575b6101205180f35b7fb13fd610fe4e1b384966826794a9b2f6100ad031f352cc5ec6f22667f6074980916106df602092612802565b604051908152a180806106ab565b3461035b57606036600319011261035b576107066125a9565b61010051356101205152600b6020526040610120512060243561012051526020526001600160a01b036040610120512091166000526020526020604060002054604051908152f35b3461035b5760c036600319011261035b5761076761257d565b61076f612626565b90610778612636565b9060843567ffffffffffffffff811161035b5761079b90369061010051016126fe565b60a435906001600160a01b039384831683036106055762010000956102b6946107e86101205154976107d260ff8a60101c1661284b565b62ff0000198099166101205155821633146128f9565b60243590613530565b3461035b576101205136600319011261035b5760405180600d5480835260208093018091600d61012051527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb590610120515b868282106108a4578686610859828803836126c4565b6040519283928184019082855251809152604084019291610120515b82811061088457505050500390f35b83516001600160a01b031685528695509381019392810192600101610875565b83546001600160a01b031685529093019260019283019201610843565b3461035b576101205136600319011261035b576020600554604051908152f35b3461035b576101205136600319011261035b5760206001600160a01b0360035416604051908152f35b3461035b5760e036600319011261035b57610923612593565b61092b6125a9565b610933612606565b61093b612616565b60c43591821515830361035b5760209461042a94606435916101005135612f7a565b3461035b57604036600319011261035b5761097661257d565b6001600160a01b038060035416816001541690803b1561035b5760405191632a54db0160e01b83526101005183015281602481610120519361012051905af1801561030c57610b05575b506101205154906109d660ff8360101c1661284b565b62ff00001980921661012051558060015416803b1561035b57604051906361707cd960e11b825281610120519181610100519161012051905af1801561030c57610aee575b5062093a804204928160025416331480610acf575b610a78575b16604051926370a0823160e01b9081855230610100518601526020918286602481875afa95861561030c57610120519661061157506105376024353033876132f8565b7fb13fd610fe4e1b384966826794a9b2f6100ad031f352cc5ec6f22667f60749806020838316806101205152600e825260406101205120600160ff19825416179055610ac384612802565b604051908152a1610a35565b508181166101205152600e60205260ff60406101205120541615610a30565b610af790612646565b6101205161035b5783610a1b565b610b0e90612646565b826109c0565b3461035b57610b223661276e565b90610120515490610b3860ff8360101c1661284b565b62ff00001980921661012051556001600160a01b03806002541633148015610c52575b610b64906128f9565b61010051541692604051906331a9108f60e11b82528261010051830152602082602481885afa91821561030c576101205192610c16575b5060405163133f757160e31b81526101005181018490529261018080856024818a5afa91821561030c5762010000976102b69661012051936101205195610be4575b5050613530565b8091929550610c00939450903d10610305576102e881836126c4565b5050505050969550935050505091928980610bdd565b9091506020813d602011610c4a575b81610c32602093836126c4565b8101031261035b57610c43906127ee565b9085610b9b565b3d9150610c25565b50610100515481163314610b5b565b3461035b57608036600319011261035b57602061042a610c7f61257d565b610c87612626565b610c8f612636565b9160243590612b93565b3461035b57602036600319011261035b57610cb261257d565b6001600160a01b038091610ccb82600254163314612b47565b16806101205152600e60205260ff604061012051205416610ced576101205180f35b61012051600d805490929190815b818110610dfe575b50505b8254600019810190811161064057811015610d6c57600181019081811161064057610d66610d356001936127a1565b905487610d41856127a1565b92909360031b1c16906001600160a01b038084549260031b9316831b921b1916179055565b01610d06565b50600d5491508115610de2577f755c47ac85b75fe2251607db5a480aac818b88bb535814bf1e3c4784ae4f6baa926020926000190190610dab826127a1565b909182549160031b1b19169055600d55806101205152600e82526040610120512060ff198154169055604051908152a180806106ab565b634e487b7160e01b610120515260316101005152602461012051fd5b8386610e09836127a1565b90549060031b1c1614610e1e57600101610cfb565b9150508480610d03565b3461035b5760208060031936011261035b5762093a80420461012051527f568f905fee3c29dbecf3583ddfaf086f7336b6bee88b499cc887c595fb7bf1eb815260026040610120512001610100513561012051528152604061012051209060405191610e938361268c565b60018352813681850137610ea683612a50565b526001600160a01b036001541691604051809363e57c0ca960e01b82528180610ed86101205195610100518301612b0b565b03915afa90811561030c576040926101205192610f25575b50610f166fffffffffffffffffffffffffffffffff610f0e84612a50565b511692612a50565b5160801c908351928352820152f35b610f459192503d8061012051833e610f3d81836126c4565b810190612a91565b9083610ef0565b3461035b57604036600319011261035b57610100513567ffffffffffffffff9081811161035b57610f8390369061010051016125d5565b9160249060243590811161035b57610fa190369061010051016126fe565b92610120515b818110610fb5576101205180f35b610fc0818386612945565b35906101205154610fd660ff8260101c1661284b565b62ff00001980911661012051556001600160a01b03908161010051541691604051906331a9108f60e11b8252856101005183015260209081838a81885afa92831561030c576101205193611144575b5060405163020604bf60e21b815261010051810188905282818b81895afa92831561030c576101205193611109575b50508061106c931633149182156110fc5750506128f9565b60405163133f757160e31b8152610100518101859052936101809283868981845afa95861561030c5760019662010000956110ba948d93610120519261012051946110cc5750503394613530565b61012051541617610120515501610fa7565b80919294506110e79350903d10610305576102e881836126c4565b50505050509550935050505090918e806102ad565b9091501633148a80610265565b9080949350813d831161113d575b61112181836126c4565b8101031261035b578061113661106c946127ee565b9293611054565b503d611117565b9092508181813d8311611174575b61115c81836126c4565b8101031261035b5761116d906127ee565b918b611025565b503d611152565b3461035b57602036600319011261035b5761119461257d565b62093a809081420490600182018083116106405783810290808204851490151715610640576111c49042906128c9565b91610120515260066020526001600160a01b03604061012051209116610120515260205260406101205120548181029181830414901517156106405760209160405191048152f35b3461035b576101205136600319011261035b5760206001600160a01b03610100515416604051908152f35b3461035b57608036600319011261035b5760243567ffffffffffffffff811161035b5761126a90369061010051016125d5565b6112726125bf565b60e052610120515461128960ff8260101c1661284b565b62ff0000191661012051556001600160a01b036101005154166040516331a9108f60e11b815260443561010051820152602081602481855afa90811561030c5761012051916114b4575b5060405163020604bf60e21b8152610100516044359082015290602082602481865afa91821561030c57610120519261146e575b50906001600160a01b036113269216331490811561145b575b506128f9565b60405163133f757160e31b81526101005160443590820152610180908181602481865afa801561030c57610120516080526101205160a05261142c575b505061137760a05160805160443584612b93565b60c052610120515b82811061139c5761012051805462ff000019166201000017815580f35b60019062093a8042046101005135106113e7575b6113e160e05160c05160a05160805189886113d76113d2898d60443595612945565b612955565b610100513561334e565b0161137f565b6001600160a01b036113fd6113d2838789612945565b166101205152600c6020526040610120512060c0516101205152602052610100513560406101205120556113b0565b8161144292903d10610305576102e881836126c4565b50505050509550935050505060805260a0528380611363565b6001600160a01b03915016331485611320565b91506020823d6020116114ac575b81611489602093836126c4565b8101031261035b576001600160a01b036114a5611326936127ee565b9250611307565b3d915061147c565b90506020813d6020116114e6575b816114cf602093836126c4565b8101031261035b576114e0906127ee565b846112d3565b3d91506114c2565b3461035b5760208060031936011261035b576101005135906001600160a01b0391826101005154166040519163133f757160e31b83528061010051840152610180908184602481865afa92831561030c5761155994610120519361012051956116e3575b5050612b93565b918261012051527f568f905fee3c29dbecf3583ddfaf086f7336b6bee88b499cc887c595fb7bf1ea8252604061012051209262093a80420461012051527f568f905fee3c29dbecf3583ddfaf086f7336b6bee88b499cc887c595fb7bf1eb83526001604061012051200190610120515282526040610120512092604051936115e085612670565b6003855260603685870137816115f586612a50565b526115ff85612a5d565b52610100510161160e84612a6d565b526001541691604051809363e57c0ca960e01b825281806116386101205195610100518301612b0b565b03915afa90811561030c5760609261012051926116c4575b5061165a82612a5d565b5160801b61166783612a5d565b5261167182612a5d565b5160801c61167e83612a5d565b526fffffffffffffffffffffffffffffffff916116b28361169e83612a50565b5116936116aa83612a5d565b511691612a6d565b51916040519384528301526040820152f35b6116dc9192503d8061012051833e610f3d81836126c4565b9083611650565b80919295506116ff939450903d10610305576102e881836126c4565b5050505050969550935050505091928780611552565b3461035b57604036600319011261035b576001600160a01b0361173661257d565b166101205152600c60205260406101205120602435610120515260205260206040610120512054604051908152f35b3461035b57604036600319011261035b57610100513567ffffffffffffffff9081811161035b5761179c90369061010051016125d5565b9060249260243590811161035b576117ba90369061010051016125d5565b939091610120515b8481106117d0576101205180f35b6117de6113d2828785612945565b610120515b8781106117f45750506001016117c2565b6117ff818988612945565b3590610b0e8211611a3a578161012051526020916007835260406101205120546101205150610120519080611985575b5080611842575b505060019150016117e3565b816101205152600b8452604061012051206101205161012051528452604061012051206001600160a01b03948587169182610120515281526040610120512061188c8482546128ec565b90558560035416908060405180936361d027b360e01b825281610100519161012051905af191821561030c57610120519261191f575b5091600196827fc8c7ebd754a625a8677ab2031c7674259be1e8c1a7f3521cbf5edbca8f48099c96946118f98760a09896866134f6565b604051958652610120519086015216604084015260608301526080820152a18980611836565b93915093918484813d831161197e575b61193981836126c4565b8101031261035b576001967fc8c7ebd754a625a8677ab2031c7674259be1e8c1a7f3521cbf5edbca8f48099c9561197160a0966127ee565b93955091939550966118c2565b503d61192f565b905060069081855260406101205120916001600160a01b0387169283610120515286526040610120512054818102918183041490151715611a1f5762093a80918203918211611a1f57611a199291600a6119df9204613400565b90836101205152600b86526040610120512061012051610120515286526040610120512090610120515285526040610120512054906128c9565b8b61182f565b89634e487b7160e01b61012051526011610100515261012051fd5b60405162461bcd60e51b815261010080516020908301525181880152634e6f706560e01b6044820152606490fd5b3461035b57602036600319011261035b5761010051356101205152600760205260206040610120512054604051908152f35b3461035b57606036600319011261035b57611ab3612593565b6044356001600160a01b036101005154166040519163133f757160e31b83528061010051840152610180908184602481865afa92831561030c5760209561042a9561012051946101205196611b0f575b5050610100513561323f565b8091929650611b2b939550903d10610305576102e881836126c4565b5050505050979550935050505092938780611b03565b3461035b57602036600319011261035b576001600160a01b03611b6261257d565b166101205152600e602052602060ff6040610120512054166040519015158152f35b3461035b576101205136600319011261035b5760206001600160a01b0360025416604051908152f35b3461035b57604036600319011261035b57611bc661257d565b60243590610120515061012051916001600160a01b0380610100515416916040519263133f757160e31b84528161010051850152610180928385602481855afa94851561030c5761012051946101205196611cc7575b5050611c2a85858585612b93565b9086166101205152600c6020526040610120512090610120515260205260406101205120546005546101205150808211600014611cb95750939291909594955b62093a80420494965b85881115611c8657602087604051908152f35b909192939495611ca7611cad91611ca188888888888f61323f565b906128ec565b97612a41565b96959493929190611c73565b905093929190959495611c6a565b8091929650611ce3939550903d10610305576102e881836126c4565b5050505050979550935050505092938780611c1c565b3461035b5760e036600319011261035b5760243567ffffffffffffffff811161035b57611d2c90369061010051016125d5565b611d346125a9565b611d3c612606565b91611d45612616565b6001600160a01b0360c4351660c4350361035b576101205154611d6d60ff8260101c1661284b565b62ff000019166101205155611d8c6001600160a01b03841633146128f9565b611d9a818560643586612b93565b90610120515b838110611dbd5761012051805462ff000019166201000017815580f35b60019062093a804204610100513510611df4575b611dee8585858a8c8b6113d76113d28960c4359860643595612945565b01611da0565b6001600160a01b03611e0a6113d283888c612945565b1661012051526020600c815260406101205120908561012051525261010051356040610120512055611dd1565b3461035b5760208060031936011261035b57611e5161257d565b62093a809042829004610b0e811115611e96576101205152600683526001600160a01b0360406101205120911661012051528252604061012051205404604051908152f35b9091506101205152600682526001600160a01b036040610120512091166101205152815260406101205120548060021b9080820461010051149015171561064057625c4900900461042a565b3461035b57606036600319011261035b57611efb61257d565b604435906001600160a01b03610120515491611f1c60ff8460101c1661284b565b62ff0000198093166101205155168061012051526020600e8152611f4960ff60406101205120541661287d565b62093a80420484111561205657604051936370a0823160e01b80865230610100518701528286602481875afa95861561030c576101205196612027575b50611f956024353033876132f8565b60405190815230610100518201528281602481875afa90811561030c576101205191611ff7575b506201000095611fcb916128c9565b9181610120515260068152604061012051208461012051528152604061012051206105958482546128ec565b90508281813d8311612020575b61200e81836126c4565b8101031261035b575162010000611fbc565b503d612004565b9095508281813d831161204f575b61203f81836126c4565b8101031261035b57519486611f86565b503d612035565b6064906040519062461bcd60e51b825261010051820152600560248201527f526574726f0000000000000000000000000000000000000000000000000000006044820152fd5b3461035b576101205136600319011261035b5760206001600160a01b0360015416604051908152f35b3461035b5760a036600319011261035b576120de61257d565b6120e6612593565b6120ee6125a9565b906120f76125bf565b6084356001600160a01b039081811680910361035b5761012051549060ff8260081c161594858096612545575b801561252e575b156124c2578382916201000060019a60ff19968a8d8983161761012051556124ad575b507fffffffffffffffffff000000000000000000000000000000000000000000ffff76ffffffffffffffffffffffffffffffffffffffff00000061012051549260181b169116171761012051551696847fffffffffffffffffffffffff000000000000000000000000000000000000000091898360025416176002558160039816836003541617600355168161010051541617610100515588541617875562093a804204600555604051635001f3b560e01b815260209687826101005181845afa91821561030c576101205192612476575b50876040518092630445b4cf60e11b82528161010051915afa90811561030c576101205191612441575b5060405190630dfe168160e01b825288826101005181875afa91821561030c57610120519261240a575b5088604051809563d21220a760e01b82528161010051915afa92831561030c57869461012051946123c7575b5084929183826122b08294612802565b6122b983612802565b6122c285612802565b6122cb87612802565b166101205152600e8b52604061012051208c88825416179055166101205152604061012051208a868254161790551661012051526040610120512088848254161790551661012051528560406101205120918254161790556101205150610120519185600d54935b84811061238557508585612348576101205180f35b61012051805461ff00191690556040519182527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb384740249891a180806106ab565b7fb13fd610fe4e1b384966826794a9b2f6100ad031f352cc5ec6f22667f607498087856123b1846127a1565b905490871b1c16604051908152a1018690612333565b94509250908884813d8111612403575b6123e181836126c4565b8101031261035b5785809492816123f881956127ee565b9592505091926122a0565b503d6123d7565b9091508881813d831161243a575b61242281836126c4565b8101031261035b57612433906127ee565b908a612274565b503d612418565b90508781813d831161246f575b61245881836126c4565b8101031261035b57612469906127ee565b8961224a565b503d61244e565b9091508781813d83116124a6575b61248e81836126c4565b8101031261035b5761249f906127ee565b9089612220565b503d612484565b6101019061ffff19161761012051558c61214e565b608460405162461bcd60e51b8152602061010051820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152fd5b50303b15801561212b5750600160ff84161461212b565b50600160ff841610612124565b3461035b576101205136600319011261035b576020906001600160a01b03610120515460181c168152f35b600435906001600160a01b038216820361060557565b602435906001600160a01b038216820361060557565b604435906001600160a01b038216820361060557565b606435906001600160a01b038216820361060557565b9181601f840112156106055782359167ffffffffffffffff8311610605576020808501948460051b01011161060557565b608435908160020b820361060557565b60a435908160020b820361060557565b604435908160020b820361060557565b606435908160020b820361060557565b67ffffffffffffffff811161265a57604052565b634e487b7160e01b600052604160045260246000fd5b6080810190811067ffffffffffffffff82111761265a57604052565b6040810190811067ffffffffffffffff82111761265a57604052565b60e0810190811067ffffffffffffffff82111761265a57604052565b90601f8019910116810190811067ffffffffffffffff82111761265a57604052565b67ffffffffffffffff811161265a5760051b60200190565b9080601f83011215610605576020908235612718816126e6565b9361272660405195866126c4565b81855260208086019260051b82010192831161060557602001905b82821061274f575050505090565b81356001600160a01b0381168103610605578152908301908301612741565b90604060031983011261060557600435916024359067ffffffffffffffff82116106055761279e916004016126fe565b90565b600d548110156127d857600d6000527fd7b6990105719101dabeb77144f2a3385c8033acd3af97e9423a695e81ad1eb50190600090565b634e487b7160e01b600052603260045260246000fd5b51906001600160a01b038216820361060557565b600d54906801000000000000000082101561265a5761282a8260016128499401600d556127a1565b9091906001600160a01b038084549260031b9316831b921b1916179055565b565b1561285257565b60405162461bcd60e51b81526020600482015260036024820152624c4f4b60e81b6044820152606490fd5b1561288457565b60405162461bcd60e51b815260206004820152600c60248201527f2157686974656c697374656400000000000000000000000000000000000000006044820152606490fd5b919082039182116128d657565b634e487b7160e01b600052601160045260246000fd5b919082018092116128d657565b1561290057565b60405162461bcd60e51b815260206004820152600e60248201527f4e6f7420617574686f72697a65640000000000000000000000000000000000006044820152606490fd5b91908110156127d85760051b0190565b356001600160a01b03811681036106055790565b51908160020b820361060557565b51906fffffffffffffffffffffffffffffffff8216820361060557565b9190826101809103126106055781516bffffffffffffffffffffffff8116810361060557916129c5602082016127ee565b916129d2604083016127ee565b916129df606082016127ee565b91608082015162ffffff8116810361060557916129fe60a08201612969565b91612a0b60c08301612969565b91612a1860e08201612977565b91610100820151916101208101519161279e610160612a3a6101408501612977565b9301612977565b60001981146128d65760010190565b8051156127d85760200190565b8051600110156127d85760400190565b8051600210156127d85760600190565b80518210156127d85760209160051b010190565b60209081818403126106055780519067ffffffffffffffff821161060557019180601f84011215610605578251612ac7816126e6565b93612ad560405195866126c4565b818552838086019260051b820101928311610605578301905b828210612afc575050505090565b81518152908301908301612aee565b602090602060408183019282815285518094520193019160005b828110612b33575050505090565b835185529381019392810192600101612b25565b15612b4e57565b60405162461bcd60e51b815260206004820152600560248201527f21415554480000000000000000000000000000000000000000000000000000006044820152606490fd5b9290916040519260208401946bffffffffffffffffffffffff199060601b168552603484015260e81b605483015260e81b6057820152603a81526060810181811067ffffffffffffffff82111761265a5760405251902090565b3d15612c28573d9067ffffffffffffffff821161265a5760405191612c1c601f8201601f1916602001846126c4565b82523d6000602084013e565b606090565b519063ffffffff8216820361060557565b80959193949294600095612c5484868484612b93565b938388526020956008875260408981809b20888252895260ff828220541615600014612f4657505091600094918594936001600160a01b03948560015416958c51948b860196634c8c7ddb60e11b88526024870152166044850152606484015260020b608483015260020b60a482015260a48152612cd1816126a8565b51915afa612cdd612bed565b9015612f3b578481805181010312610605578483820151910151908062093a804204881080612f33575b612edd575b505b866000526006845285600020946001600160a01b038091169586600052855286600020549260068402848104600614851517156128d657600a900491610b0e8a11908115612ecc575b62093a8042048b10612dcd575b5015612db0575050612d7591613467565b945b600052600b8252836000209060005281528260002091600052526000205480821015600014612da95761279e916128c9565b5050600090565b612dc1611ca19293612dc795613467565b92613467565b94612d77565b8a600052600788528960002054612d64576001541660c08b60248c5180948193633a92844160e21b835260048301525afa8015612ec157600091600091612e48575b5063ffffffff809216151580612e40575b612e2b575b50612d64565b8b600052600789521689600020553880612e25565b506001612e20565b91505060c0813d60c011612eb9575b81612e6460c093836126c4565b8101031261060557612eb360a0612e7a83612c2d565b92612e868b8201612969565b50612e928d8201612969565b50612e9f606082016127ee565b50612eac608082016127ee565b5001612c2d565b38612e0f565b3d9150612e57565b8a513d6000823e3d90fd5b9483612ed7916128c9565b94612d57565b87600052600885528660002084600052855286600020600160ff19825416179055876000526009855286600020846000528552866000205586600052600a84528560002083600052845281866000205538612d0c565b506001612d07565b505050505050600090565b945094925050508152600984528181208382528452205485600052600a835284600020826000528352846000205490612d0e565b80969493959295600096612f9085878484612b93565b948389526020966008885260408a81809c208982528a5260ff82822054161560001461320b57505091600094918594936001600160a01b03948560015416958d51948c860196634c8c7ddb60e11b88526024870152166044850152606484015260020b608483015260020b60a482015260a4815261300d816126a8565b51915afa613019612bed565b90156131ff578581805181010312610605578584820151910151948162093a8042048910806131f8575b6131a2575b505b876000526006855286600020956001600160a01b038094169687600052865287600020549360068502858104600614861517156128d657600a900492610b0e8b11918215613191575b62093a8042048c106130b2575b505015612db0575050612d7591613467565b8b600052600789528a600020546130a057600154169060c08c60248d5180958193633a92844160e21b835260048301525afa9081156131865760009260009261312b575b5063ffffffff80931615159081613123575b50156130a0578b6000526007895216896000205538806130a0565b905038613108565b9250905060c0823d60c01161317e575b8161314860c093836126c4565b810103126106055761317760a083612e928e61316f6131678f98612c2d565b978401612969565b508201612969565b90386130f6565b3d915061313b565b8b513d6000823e3d90fd5b958461319c916128c9565b95613093565b88600052600886528760002085600052865287600020600160ff19825416179055886000526009865287600020856000528652876000205587600052600a85528660002084600052855285876000205538613048565b5081613043565b50505050505050600090565b945094925050508152600985528181208482528552205486600052600a84528560002083600052845285600020549461304a565b9391949290604051956020870195635f0b8e2f60e11b875260248801526001600160a01b038092166044880152166064860152608485015260020b60a484015260020b60c48301526000918260e482015260e48152610120810181811067ffffffffffffffff8211176132e457604052518291829190305afa906132c1612bed565b91156132df576020828051810103126132dc57506020015190565b80fd5b905090565b634e487b7160e01b84526041600452602484fd5b9290604051926323b872dd60e01b60208501526001600160a01b03809216602485015216604483015260648201526064815260a081019181831067ffffffffffffffff84111761265a576128499260405261365a565b9491926133619397969491978887612c3e565b908161336f575b5050505050565b7fc8c7ebd754a625a8677ab2031c7674259be1e8c1a7f3521cbf5edbca8f48099c9460a094600092858452600b602052604084208185526020526040808520946001600160a01b0380951695868252602052206133cd8682546128ec565b90556133da8583866134f6565b604051958652602086015216604084015260608301526080820152a13880808080613368565b909190600019838209928082029283808610950394808603951461345a575062093a8091848311156106055709118082038060f91b04600160f91b14911417156128d657634e487b7160e01b600052601160045260246000fd5b9350505062093a80900490565b90919060001983820992808202928380861095039480860395146134dd57506e093a8000000000000000000000000091848311156106055709118082038060991b0473020000000000000000000000000000000000000014911417156128d657634e487b7160e01b600052601160045260246000fd5b935050506e093a80000000000000000000000000900490565b612849926001600160a01b036040519363a9059cbb60e01b602086015216602484015260448301526044825261352b82612670565b61365a565b929395949161354185828487612b93565b9262093a804204600091600019820197828911935b8b5181101561364c576001600160a01b039081613573828f612a7d565b5116600052600c918d6020848152604091826000208d60005282528260002054600554808211600014613632575085918f8f8f908f8f95908f94938f948f938d905b975b8811156135f85750505050505050505090506128d6578f948e936135dd86600198612a7d565b5116600052815281600020908c600052526000205501613556565b613619995061360c899b613614999a612a7d565b51168861334e565b612a41565b85918f918f8f908f8f95908f938f94928f938d906135b7565b905085918f8f8f908f8f95908f94938f948f938d906135b5565b505050505050505050509050565b6001600160a01b0316906136ba6040516136738161268c565b6020938482527f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564858301526000808587829751910182855af16136b4612bed565b91613767565b80519182159184831561373f575b5050509050156136d55750565b6084906040519062461bcd60e51b82526004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152fd5b919381809450010312613763578201519081151582036132dc5750803880846136c8565b5080fd5b919290156137c9575081511561377b575090565b3b156137845790565b60405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606490fd5b8251909150156137dc5750805190602001fd5b6040519062461bcd60e51b82528160208060048301528251908160248401526000935b828510613822575050604492506000838284010152601f80199101168101030190fd5b84810182015186860160440152938101938593506137ff56fea164736f6c6343000816000a
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.