ERC-721
Overview
Max Total Supply
105 SHADOW-V3-NFP
Holders
74
Total Transfers
-
Market
Onchain Market Cap
-
Circulating Supply Market Cap
-
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.
Contract Source Code Verified (Exact Match)
Contract Name:
NonfungiblePositionManager
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 2633 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; pragma abicoder v2; import {ERC721} from '@openzeppelin/contracts/token/ERC721/ERC721.sol'; import {ERC721Enumerable, IERC165} from '@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol'; import {Multicall} from './base/Multicall.sol'; import {IRamsesV3Pool} from '../core/interfaces/IRamsesV3Pool.sol'; import {FixedPoint128} from '../core/libraries/FixedPoint128.sol'; import {FullMath} from '../core/libraries/FullMath.sol'; import {INonfungiblePositionManager, IERC721, IERC721Metadata} from './interfaces/INonfungiblePositionManager.sol'; import {INonfungibleTokenPositionDescriptor} from './interfaces/INonfungibleTokenPositionDescriptor.sol'; import {PositionKey} from './libraries/PositionKey.sol'; import {PoolAddress} from './libraries/PoolAddress.sol'; import {LiquidityManagement} from './base/LiquidityManagement.sol'; import {PeripheryImmutableState} from './base/PeripheryImmutableState.sol'; import {PeripheryValidation} from './base/PeripheryValidation.sol'; import {PoolInitializer} from './base/PoolInitializer.sol'; import {IGaugeV3} from '../gauge/interfaces/IGaugeV3.sol'; import {IVoter} from '../../interfaces/IVoter.sol'; import {IAccessHub} from '../../interfaces/IAccessHub.sol'; /// @title NFT positions /// @notice Wraps Ramses V3 positions in the ERC721 non-fungible token interface contract NonfungiblePositionManager is Multicall, PeripheryImmutableState, PoolInitializer, LiquidityManagement, PeripheryValidation, ERC721, ERC721Enumerable, INonfungiblePositionManager { /// @dev details about the Ramses position struct Position { /// @dev the ID of the pool with which this token is connected uint80 poolId; /// @dev the tick range of the position int24 tickLower; int24 tickUpper; /// @dev the liquidity of the position uint128 liquidity; /// @dev the fee growth of the aggregate position as of the last action on the individual position uint256 feeGrowthInside0LastX128; uint256 feeGrowthInside1LastX128; /// @dev how many uncollected tokens are owed to the position, as of the last computation uint128 tokensOwed0; uint128 tokensOwed1; } /// @dev IDs of pools assigned by this contract mapping(address pool => uint80 id) private _poolIds; /// @dev Pool keys by pool ID, to save on SSTOREs for position data mapping(uint80 id => PoolAddress.PoolKey key) private _poolIdToPoolKey; /// @dev The token ID position data mapping(uint256 tokenId => Position position) private _positions; /// @dev The ID of the next token that will be minted. Skips 0 uint176 private _nextId = 1; /// @dev The ID of the next pool that is used for the first time. Skips 0 uint80 private _nextPoolId = 1; /// @dev The address of the token descriptor contract, which handles generating token URIs for position tokens address private immutable _tokenDescriptor; /// @dev access control hub IAccessHub private immutable accessHub; /// @dev the address of the voter contract address private voter; constructor( address _deployer, address _WETH9, address _tokenDescriptor_, address _accessHub ) ERC721('Shadow V3 Positions NFT', 'SHADOW-V3-NFP') PeripheryImmutableState(_deployer, _WETH9) { _tokenDescriptor = _tokenDescriptor_; accessHub = IAccessHub(_accessHub); } /// @inheritdoc INonfungiblePositionManager function positions( uint256 tokenId ) external view override returns ( address token0, address token1, int24 tickSpacing, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ) { Position memory position = _positions[tokenId]; if (position.poolId == 0) revert InvalidTokenId(tokenId); PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId]; return ( poolKey.token0, poolKey.token1, poolKey.tickSpacing, position.tickLower, position.tickUpper, position.liquidity, position.feeGrowthInside0LastX128, position.feeGrowthInside1LastX128, position.tokensOwed0, position.tokensOwed1 ); } /// @dev Caches a pool key function cachePoolKey(address pool, PoolAddress.PoolKey memory poolKey) private returns (uint80 poolId) { poolId = _poolIds[pool]; if (poolId == 0) { _poolIds[pool] = (poolId = _nextPoolId++); _poolIdToPoolKey[poolId] = poolKey; } } /// @inheritdoc INonfungiblePositionManager function mint( MintParams calldata params ) external payable override checkDeadline(params.deadline) returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) { IRamsesV3Pool pool; unchecked { tokenId = _nextId++; } (liquidity, amount0, amount1, pool) = addLiquidity( AddLiquidityParams({ token0: params.token0, token1: params.token1, tickSpacing: params.tickSpacing, recipient: address(this), index: tokenId, tickLower: params.tickLower, tickUpper: params.tickUpper, amount0Desired: params.amount0Desired, amount1Desired: params.amount1Desired, amount0Min: params.amount0Min, amount1Min: params.amount1Min }) ); _mint(params.recipient, tokenId); bytes32 positionKey = PositionKey.compute(address(this), tokenId, params.tickLower, params.tickUpper); (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(positionKey); /// @dev idempotent set uint80 poolId = cachePoolKey( address(pool), PoolAddress.PoolKey({token0: params.token0, token1: params.token1, tickSpacing: params.tickSpacing}) ); _positions[tokenId] = Position({ poolId: poolId, tickLower: params.tickLower, tickUpper: params.tickUpper, liquidity: liquidity, feeGrowthInside0LastX128: feeGrowthInside0LastX128, feeGrowthInside1LastX128: feeGrowthInside1LastX128, tokensOwed0: 0, tokensOwed1: 0 }); emit IncreaseLiquidity(tokenId, liquidity, amount0, amount1); } modifier isAuthorizedForToken(uint256 tokenId) { address owner = _ownerOf(tokenId); _checkAuthorized(owner, msg.sender, tokenId); _; } function tokenURI(uint256 tokenId) public view override(ERC721, IERC721Metadata) returns (string memory) { _requireOwned(tokenId); return INonfungibleTokenPositionDescriptor(_tokenDescriptor).tokenURI(this, tokenId); } /// @inheritdoc INonfungiblePositionManager function increaseLiquidity( IncreaseLiquidityParams calldata params ) external payable override checkDeadline(params.deadline) returns (uint128 liquidity, uint256 amount0, uint256 amount1) { Position storage position = _positions[params.tokenId]; PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId]; IRamsesV3Pool pool; (liquidity, amount0, amount1, pool) = addLiquidity( AddLiquidityParams({ token0: poolKey.token0, token1: poolKey.token1, tickSpacing: poolKey.tickSpacing, tickLower: position.tickLower, tickUpper: position.tickUpper, amount0Desired: params.amount0Desired, amount1Desired: params.amount1Desired, amount0Min: params.amount0Min, amount1Min: params.amount1Min, recipient: address(this), index: params.tokenId }) ); bytes32 positionKey = PositionKey.compute( address(this), params.tokenId, position.tickLower, position.tickUpper ); /// @dev this is now updated to the current transaction (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(positionKey); unchecked { position.tokensOwed0 += uint128( FullMath.mulDiv( feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128, position.liquidity, FixedPoint128.Q128 ) ); position.tokensOwed1 += uint128( FullMath.mulDiv( feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128, position.liquidity, FixedPoint128.Q128 ) ); } position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128; position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128; unchecked { position.liquidity += liquidity; } emit IncreaseLiquidity(params.tokenId, liquidity, amount0, amount1); } /// @inheritdoc INonfungiblePositionManager function decreaseLiquidity( DecreaseLiquidityParams calldata params ) external payable override isAuthorizedForToken(params.tokenId) checkDeadline(params.deadline) returns (uint256 amount0, uint256 amount1) { require(params.liquidity > 0); Position storage position = _positions[params.tokenId]; uint128 positionLiquidity = position.liquidity; require(positionLiquidity >= params.liquidity); PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId]; IRamsesV3Pool pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey)); (amount0, amount1) = pool.burn(params.tokenId, position.tickLower, position.tickUpper, params.liquidity); if (amount0 < params.amount0Min || amount1 < params.amount1Min) revert CheckSlippage(); bytes32 positionKey = PositionKey.compute( address(this), params.tokenId, position.tickLower, position.tickUpper ); /// @dev this is now updated to the current transaction (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions(positionKey); unchecked { position.tokensOwed0 += uint128(amount0) + uint128( FullMath.mulDiv( feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128, positionLiquidity, FixedPoint128.Q128 ) ); position.tokensOwed1 += uint128(amount1) + uint128( FullMath.mulDiv( feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128, positionLiquidity, FixedPoint128.Q128 ) ); } position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128; position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128; /// @dev subtraction is safe because we checked positionLiquidity is gte params.liquidity unchecked { position.liquidity = positionLiquidity - params.liquidity; } emit DecreaseLiquidity(params.tokenId, params.liquidity, amount0, amount1); } /// @inheritdoc INonfungiblePositionManager function collect( CollectParams calldata params ) external payable override isAuthorizedForToken(params.tokenId) returns (uint256 amount0, uint256 amount1) { require(params.amount0Max > 0 || params.amount1Max > 0); /// @dev allow collecting to the nft position manager address with address 0 address recipient = params.recipient == address(0) ? address(this) : params.recipient; Position storage position = _positions[params.tokenId]; PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId]; IRamsesV3Pool pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey)); (uint128 tokensOwed0, uint128 tokensOwed1) = (position.tokensOwed0, position.tokensOwed1); /// @dev trigger an update of the position fees owed and fee growth snapshots if it has any liquidity if (position.liquidity > 0) { pool.burn(params.tokenId, position.tickLower, position.tickUpper, 0); (, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, , ) = pool.positions( PositionKey.compute(address(this), params.tokenId, position.tickLower, position.tickUpper) ); unchecked { tokensOwed0 += uint128( FullMath.mulDiv( feeGrowthInside0LastX128 - position.feeGrowthInside0LastX128, position.liquidity, FixedPoint128.Q128 ) ); tokensOwed1 += uint128( FullMath.mulDiv( feeGrowthInside1LastX128 - position.feeGrowthInside1LastX128, position.liquidity, FixedPoint128.Q128 ) ); } position.feeGrowthInside0LastX128 = feeGrowthInside0LastX128; position.feeGrowthInside1LastX128 = feeGrowthInside1LastX128; } /// @dev compute the arguments to give to the pool#collect method (uint128 amount0Collect, uint128 amount1Collect) = ( params.amount0Max > tokensOwed0 ? tokensOwed0 : params.amount0Max, params.amount1Max > tokensOwed1 ? tokensOwed1 : params.amount1Max ); /// @dev the actual amounts collected are returned (amount0, amount1) = pool.collect( recipient, params.tokenId, position.tickLower, position.tickUpper, amount0Collect, amount1Collect ); /// @dev sometimes there will be a few less wei than expected due to rounding down in core, but we just subtract the full amount expected /// @dev instead of the actual amount so we can burn the token unchecked { (position.tokensOwed0, position.tokensOwed1) = (tokensOwed0 - amount0Collect, tokensOwed1 - amount1Collect); } emit Collect(params.tokenId, recipient, amount0Collect, amount1Collect); } /// @inheritdoc INonfungiblePositionManager function getReward(uint256 tokenId, address[] calldata tokens) external isAuthorizedForToken(tokenId) { Position storage position = _positions[tokenId]; PoolAddress.PoolKey memory poolKey = _poolIdToPoolKey[position.poolId]; IGaugeV3 gauge = IGaugeV3(IVoter(voter).gaugeForPool(PoolAddress.computeAddress(deployer, poolKey))); gauge.getRewardForOwner(tokenId, tokens); } /// @inheritdoc INonfungiblePositionManager function burn(uint256 tokenId) external payable override isAuthorizedForToken(tokenId) { Position storage position = _positions[tokenId]; if (position.liquidity > 0 || position.tokensOwed0 > 0 || position.tokensOwed1 > 0) revert NotCleared(); delete _positions[tokenId]; _burn(tokenId); } /// @notice extra function that allows for the 2-step deployment of CL first, then governance later /// @dev gated to the timelock function setVoter(address _voter) external { require(msg.sender == accessHub.timelock()); voter = _voter; } //** Overrides */ function _update( address to, uint256 tokenId, address auth ) internal override(ERC721, ERC721Enumerable) returns (address) { return super._update(to, tokenId, auth); } function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) { super._increaseBalance(account, value); } function supportsInterface( bytes4 interfaceId ) public view override(ERC721, IERC165, ERC721Enumerable) returns (bool) { return super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.20; import {IERC721} from "./IERC721.sol"; import {IERC721Metadata} from "./extensions/IERC721Metadata.sol"; import {ERC721Utils} from "./utils/ERC721Utils.sol"; import {Context} from "../../utils/Context.sol"; import {Strings} from "../../utils/Strings.sol"; import {IERC165, ERC165} from "../../utils/introspection/ERC165.sol"; import {IERC721Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC-721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ abstract contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Errors { using Strings for uint256; // Token name string private _name; // Token symbol string private _symbol; mapping(uint256 tokenId => address) private _owners; mapping(address owner => uint256) private _balances; mapping(uint256 tokenId => address) private _tokenApprovals; mapping(address owner => mapping(address operator => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual returns (uint256) { if (owner == address(0)) { revert ERC721InvalidOwner(address(0)); } return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual returns (address) { return _requireOwned(tokenId); } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual returns (string memory) { _requireOwned(tokenId); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overridden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual { _approve(to, tokenId, _msgSender()); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual returns (address) { _requireOwned(tokenId); return _getApproved(tokenId); } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom(address from, address to, uint256 tokenId) public virtual { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } // Setting an "auth" arguments enables the `_isAuthorized` check which verifies that the token exists // (from != 0). Therefore, it is not needed to verify that the return value is not 0 here. address previousOwner = _update(to, tokenId, _msgSender()); if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId) public { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual { transferFrom(from, to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data); } /** * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist * * IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the * core ERC-721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @dev Returns the approved address for `tokenId`. Returns 0 if `tokenId` is not minted. */ function _getApproved(uint256 tokenId) internal view virtual returns (address) { return _tokenApprovals[tokenId]; } /** * @dev Returns whether `spender` is allowed to manage `owner`'s tokens, or `tokenId` in * particular (ignoring whether it is owned by `owner`). * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _isAuthorized(address owner, address spender, uint256 tokenId) internal view virtual returns (bool) { return spender != address(0) && (owner == spender || isApprovedForAll(owner, spender) || _getApproved(tokenId) == spender); } /** * @dev Checks if `spender` can operate on `tokenId`, assuming the provided `owner` is the actual owner. * Reverts if: * - `spender` does not have approval from `owner` for `tokenId`. * - `spender` does not have approval to manage all of `owner`'s assets. * * WARNING: This function assumes that `owner` is the actual owner of `tokenId` and does not verify this * assumption. */ function _checkAuthorized(address owner, address spender, uint256 tokenId) internal view virtual { if (!_isAuthorized(owner, spender, tokenId)) { if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } else { revert ERC721InsufficientApproval(spender, tokenId); } } } /** * @dev Unsafe write access to the balances, used by extensions that "mint" tokens using an {ownerOf} override. * * NOTE: the value is limited to type(uint128).max. This protect against _balance overflow. It is unrealistic that * a uint256 would ever overflow from increments when these increments are bounded to uint128 values. * * WARNING: Increasing an account's balance using this function tends to be paired with an override of the * {_ownerOf} function to resolve the ownership of the corresponding tokens so that balances and ownership * remain consistent with one another. */ function _increaseBalance(address account, uint128 value) internal virtual { unchecked { _balances[account] += value; } } /** * @dev Transfers `tokenId` from its current owner to `to`, or alternatively mints (or burns) if the current owner * (or `to`) is the zero address. Returns the owner of the `tokenId` before the update. * * The `auth` argument is optional. If the value passed is non 0, then this function will check that * `auth` is either the owner of the token, or approved to operate on the token (by the owner). * * Emits a {Transfer} event. * * NOTE: If overriding this function in a way that tracks balances, see also {_increaseBalance}. */ function _update(address to, uint256 tokenId, address auth) internal virtual returns (address) { address from = _ownerOf(tokenId); // Perform (optional) operator check if (auth != address(0)) { _checkAuthorized(from, auth, tokenId); } // Execute the update if (from != address(0)) { // Clear approval. No need to re-authorize or emit the Approval event _approve(address(0), tokenId, address(0), false); unchecked { _balances[from] -= 1; } } if (to != address(0)) { unchecked { _balances[to] += 1; } } _owners[tokenId] = to; emit Transfer(from, to, tokenId); return from; } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner != address(0)) { revert ERC721InvalidSender(address(0)); } } /** * @dev Mints `tokenId`, transfers it to `to` and checks for `to` acceptance. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual { _mint(to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), address(0), to, tokenId, data); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal { address previousOwner = _update(address(0), tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer(address from, address to, uint256 tokenId) internal { if (to == address(0)) { revert ERC721InvalidReceiver(address(0)); } address previousOwner = _update(to, tokenId, address(0)); if (previousOwner == address(0)) { revert ERC721NonexistentToken(tokenId); } else if (previousOwner != from) { revert ERC721IncorrectOwner(from, tokenId, previousOwner); } } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking that contract recipients * are aware of the ERC-721 standard to prevent tokens from being forever locked. * * `data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is like {safeTransferFrom} in the sense that it invokes * {IERC721Receiver-onERC721Received} on the receiver, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `tokenId` token must exist and be owned by `from`. * - `to` cannot be the zero address. * - `from` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer(address from, address to, uint256 tokenId) internal { _safeTransfer(from, to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeTransfer-address-address-uint256-}[`_safeTransfer`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual { _transfer(from, to, tokenId); ERC721Utils.checkOnERC721Received(_msgSender(), from, to, tokenId, data); } /** * @dev Approve `to` to operate on `tokenId` * * The `auth` argument is optional. If the value passed is non 0, then this function will check that `auth` is * either the owner of the token, or approved to operate on all tokens held by this owner. * * Emits an {Approval} event. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address to, uint256 tokenId, address auth) internal { _approve(to, tokenId, auth, true); } /** * @dev Variant of `_approve` with an optional flag to enable or disable the {Approval} event. The event is not * emitted in the context of transfers. */ function _approve(address to, uint256 tokenId, address auth, bool emitEvent) internal virtual { // Avoid reading the owner unless necessary if (emitEvent || auth != address(0)) { address owner = _requireOwned(tokenId); // We do not use _isAuthorized because single-token approvals should not be able to call approve if (auth != address(0) && owner != auth && !isApprovedForAll(owner, auth)) { revert ERC721InvalidApprover(auth); } if (emitEvent) { emit Approval(owner, to, tokenId); } } _tokenApprovals[tokenId] = to; } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Requirements: * - operator can't be the address zero. * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll(address owner, address operator, bool approved) internal virtual { if (operator == address(0)) { revert ERC721InvalidOperator(operator); } _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Reverts if the `tokenId` doesn't have a current owner (it hasn't been minted, or it has been burned). * Returns the owner. * * Overrides to ownership logic should be done to {_ownerOf}. */ function _requireOwned(uint256 tokenId) internal view returns (address) { address owner = _ownerOf(tokenId); if (owner == address(0)) { revert ERC721NonexistentToken(tokenId); } return owner; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.20; import {ERC721} from "../ERC721.sol"; import {IERC721Enumerable} from "./IERC721Enumerable.sol"; import {IERC165} from "../../../utils/introspection/ERC165.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the ERC that adds enumerability * of all the token ids in the contract as well as all token ids owned by each account. * * CAUTION: {ERC721} extensions that implement custom `balanceOf` logic, such as {ERC721Consecutive}, * interfere with enumerability and should not be used together with {ERC721Enumerable}. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { mapping(address owner => mapping(uint256 index => uint256)) private _ownedTokens; mapping(uint256 tokenId => uint256) private _ownedTokensIndex; uint256[] private _allTokens; mapping(uint256 tokenId => uint256) private _allTokensIndex; /** * @dev An `owner`'s token query was out of bounds for `index`. * * NOTE: The owner being `address(0)` indicates a global out of bounds index. */ error ERC721OutOfBoundsIndex(address owner, uint256 index); /** * @dev Batch mint is not allowed. */ error ERC721EnumerableForbiddenBatchMint(); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual returns (uint256) { if (index >= balanceOf(owner)) { revert ERC721OutOfBoundsIndex(owner, index); } return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual returns (uint256) { if (index >= totalSupply()) { revert ERC721OutOfBoundsIndex(address(0), index); } return _allTokens[index]; } /** * @dev See {ERC721-_update}. */ function _update(address to, uint256 tokenId, address auth) internal virtual override returns (address) { address previousOwner = super._update(to, tokenId, auth); if (previousOwner == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (previousOwner != to) { _removeTokenFromOwnerEnumeration(previousOwner, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (previousOwner != to) { _addTokenToOwnerEnumeration(to, tokenId); } return previousOwner; } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = balanceOf(to) - 1; _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = balanceOf(from); uint256 tokenIndex = _ownedTokensIndex[tokenId]; mapping(uint256 index => uint256) storage _ownedTokensByOwner = _ownedTokens[from]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokensByOwner[lastTokenIndex]; _ownedTokensByOwner[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokensByOwner[lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * See {ERC721-_increaseBalance}. We need that to account tokens that were minted in batch */ function _increaseBalance(address account, uint128 amount) internal virtual override { if (amount > 0) { revert ERC721EnumerableForbiddenBatchMint(); } super._increaseBalance(account, amount); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; pragma abicoder v2; import '../interfaces/IMulticall.sol'; /// @title Multicall /// @notice Enables calling multiple methods in a single call to the contract abstract contract Multicall is IMulticall { /// @inheritdoc IMulticall function multicall(bytes[] calldata data) public payable override returns (bytes[] memory results) { results = new bytes[](data.length); for (uint256 i = 0; i < data.length; i++) { (bool success, bytes memory result) = address(this).delegatecall(data[i]); if (!success) { // Next 5 lines from https://ethereum.stackexchange.com/a/83577 if (result.length < 68) revert(); assembly { result := add(result, 0x04) } revert(abi.decode(result, (string))); } results[i] = result; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IRamsesV3PoolImmutables} from './pool/IRamsesV3PoolImmutables.sol'; import {IRamsesV3PoolState} from './pool/IRamsesV3PoolState.sol'; import {IRamsesV3PoolDerivedState} from './pool/IRamsesV3PoolDerivedState.sol'; import {IRamsesV3PoolActions} from './pool/IRamsesV3PoolActions.sol'; import {IRamsesV3PoolOwnerActions} from './pool/IRamsesV3PoolOwnerActions.sol'; import {IRamsesV3PoolErrors} from './pool/IRamsesV3PoolErrors.sol'; import {IRamsesV3PoolEvents} from './pool/IRamsesV3PoolEvents.sol'; /// @title The interface for a Ramses V3 Pool /// @notice A Ramses 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 IRamsesV3Pool is IRamsesV3PoolImmutables, IRamsesV3PoolState, IRamsesV3PoolDerivedState, IRamsesV3PoolActions, IRamsesV3PoolOwnerActions, IRamsesV3PoolErrors, IRamsesV3PoolEvents { /// @notice if a new period, advance on interaction function _advancePeriod() external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint128 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) library FixedPoint128 { uint256 internal constant Q128 = 0x100000000000000000000000000000000; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; /// @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) { unchecked { // 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 = (0 - denominator) & denominator; // Divide denominator by power of two assembly { denominator := div(denominator, twos) } // Divide [prod1 prod0] by the factors of two assembly { prod0 := div(prod0, twos) } // Shift in bits from prod1 into prod0. For this we need // to flip `twos` such that it is 2**256 / twos. // If twos is zero, then it becomes one assembly { twos := add(div(sub(0, twos), twos), 1) } prod0 |= prod1 * twos; // Invert denominator mod 2**256 // Now that denominator is an odd number, it has an inverse // modulo 2**256 such that denominator * inv = 1 mod 2**256. // Compute the inverse by starting with a seed that is correct // correct for four bits. That is, denominator * inv = 1 mod 2**4 uint256 inv = (3 * denominator) ^ 2; // Now use Newton-Raphson iteration to improve the precision. // Thanks to Hensel's lifting lemma, this also works in modular // arithmetic, doubling the correct bits in each step. inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 inv *= 2 - denominator * inv; // inverse mod 2**256 // Because the division is now exact we can divide by multiplying // with the modular inverse of denominator. This will give us the // correct result modulo 2**256. Since the precoditions guarantee // that the outcome is less than 2**256, this is the final result. // We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inv; return result; } } /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 /// @param a The multiplicand /// @param b The multiplier /// @param denominator The divisor /// @return result The 256-bit result function mulDivRoundingUp(uint256 a, uint256 b, uint256 denominator) internal pure returns (uint256 result) { unchecked { 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.7.5; pragma abicoder v2; import {IPoolInitializer} from './IPoolInitializer.sol'; import {IPeripheryPayments} from './IPeripheryPayments.sol'; import {IPeripheryImmutableState} from './IPeripheryImmutableState.sol'; import {PoolAddress} from '../libraries/PoolAddress.sol'; import {IERC721} from '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import {IERC721Metadata} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol'; import {IERC721Enumerable} from '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol'; import {IPeripheryErrors} from './IPeripheryErrors.sol'; /// @title Non-fungible token for positions /// @notice Wraps Uniswap V3 positions in a non-fungible token interface which allows for them to be transferred /// and authorized. interface INonfungiblePositionManager is IPeripheryErrors, IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721, IERC721Metadata, IERC721Enumerable { /// @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 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 token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return tickSpacing The tickSpacing 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 ( address token0, address token1, int24 tickSpacing, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; int24 tickSpacing; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @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; /// @notice Claims gauge rewards from liquidity incentives for a specific tokenId /// @param tokenId The ID of the token to claim rewards from /// @param tokens an array of reward tokens to claim function getReward(uint256 tokenId, address[] calldata tokens) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './INonfungiblePositionManager.sol'; /// @title Describes position NFT tokens via URI interface INonfungibleTokenPositionDescriptor { /// @notice Produces the URI describing a particular token ID for a position manager /// @dev Note this URI may be a data: URI with the JSON contents directly inlined /// @param positionManager The position manager for which to describe the token /// @param tokenId The ID of the token for which to produce a description, which may not be valid /// @return The URI of the ERC721-compliant metadata function tokenURI(INonfungiblePositionManager positionManager, uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; library PositionKey { /// @dev Returns the key of the position in the core library function compute(address owner, uint256 index, int24 tickLower, int24 tickUpper) internal pure returns (bytes32) { return keccak256(abi.encodePacked(owner, index, tickLower, tickUpper)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Provides functions for deriving a pool address from the deployer, tokens, and the fee library PoolAddress { bytes32 internal constant POOL_INIT_CODE_HASH = 0xc701ee63862761c31d620a4a083c61bdc1e81761e6b9c9267fd19afd22e0821d; /// @notice The identifying key of the pool struct PoolKey { address token0; address token1; int24 tickSpacing; } /// @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 tickSpacing The tickSpacing of the pool /// @return Poolkey The pool details with ordered token0 and token1 assignments function getPoolKey(address tokenA, address tokenB, int24 tickSpacing) internal pure returns (PoolKey memory) { if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA); return PoolKey({token0: tokenA, token1: tokenB, tickSpacing: tickSpacing}); } /// @notice Deterministically computes the pool address given the deployer and PoolKey /// @param deployer The Uniswap V3 deployer contract address /// @param key The PoolKey /// @return pool The contract address of the V3 pool function computeAddress(address deployer, PoolKey memory key) internal pure returns (address pool) { require(key.token0 < key.token1, "!TokenOrder"); pool = address( uint160( uint256( keccak256( abi.encodePacked( hex'ff', deployer, keccak256(abi.encode(key.token0, key.token1, key.tickSpacing)), POOL_INIT_CODE_HASH ) ) ) ) ); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; pragma abicoder v2; import '../../core/interfaces/IRamsesV3Factory.sol'; import '../../core/interfaces/callback/IUniswapV3MintCallback.sol'; import '../../core/libraries/TickMath.sol'; import '../libraries/PoolAddress.sol'; import '../libraries/CallbackValidation.sol'; import '../libraries/LiquidityAmounts.sol'; import './PeripheryPayments.sol'; import './PeripheryImmutableState.sol'; /// @title Liquidity management functions /// @notice Internal functions for safely managing liquidity in Ramses V3 abstract contract LiquidityManagement is IUniswapV3MintCallback, PeripheryImmutableState, PeripheryPayments { error Slippage(); struct MintCallbackData { PoolAddress.PoolKey poolKey; address payer; } /// @inheritdoc IUniswapV3MintCallback function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external override { MintCallbackData memory decoded = abi.decode(data, (MintCallbackData)); CallbackValidation.verifyCallback(deployer, decoded.poolKey); if (amount0Owed > 0) pay(decoded.poolKey.token0, decoded.payer, msg.sender, amount0Owed); if (amount1Owed > 0) pay(decoded.poolKey.token1, decoded.payer, msg.sender, amount1Owed); } struct AddLiquidityParams { address token0; address token1; int24 tickSpacing; address recipient; uint256 index; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; } /// @notice Add liquidity to an initialized pool function addLiquidity( AddLiquidityParams memory params ) internal returns (uint128 liquidity, uint256 amount0, uint256 amount1, IRamsesV3Pool pool) { PoolAddress.PoolKey memory poolKey = PoolAddress.PoolKey({ token0: params.token0, token1: params.token1, tickSpacing: params.tickSpacing }); pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey)); /// @dev compute the liquidity amount { (uint160 sqrtPriceX96, , , , , , ) = pool.slot0(); uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(params.tickLower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(params.tickUpper); liquidity = LiquidityAmounts.getLiquidityForAmounts( sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, params.amount0Desired, params.amount1Desired ); } (amount0, amount1) = pool.mint( params.recipient, params.index, params.tickLower, params.tickUpper, liquidity, abi.encode(MintCallbackData({poolKey: poolKey, payer: msg.sender})) ); if (amount0 < params.amount0Min || amount1 < params.amount1Min) revert Slippage(); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; import '../interfaces/IPeripheryImmutableState.sol'; /// @title Immutable state /// @notice Immutable state used by periphery contracts abstract contract PeripheryImmutableState is IPeripheryImmutableState { /// @inheritdoc IPeripheryImmutableState address public immutable override deployer; /// @inheritdoc IPeripheryImmutableState address public immutable override WETH9; constructor(address _deployer, address _WETH9) { deployer = _deployer; WETH9 = _WETH9; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; import './BlockTimestamp.sol'; abstract contract PeripheryValidation is BlockTimestamp { error Old(); modifier checkDeadline(uint256 deadline) { if (_blockTimestamp() > deadline) revert Old(); _; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; import '../../core/interfaces/IRamsesV3Factory.sol'; import '../../core/interfaces/IRamsesV3Pool.sol'; import '../../core/interfaces/IRamsesV3PoolDeployer.sol'; import './PeripheryImmutableState.sol'; import '../interfaces/IPoolInitializer.sol'; /// @title Creates and initializes V3 Pools abstract contract PoolInitializer is IPoolInitializer, PeripheryImmutableState { /// @inheritdoc IPoolInitializer function createAndInitializePoolIfNecessary( address token0, address token1, int24 tickSpacing, uint160 sqrtPriceX96 ) external payable override returns (address pool) { require(token0 < token1); IRamsesV3Factory factory = IRamsesV3Factory(IRamsesV3PoolDeployer(deployer).RamsesV3Factory()); pool = factory.getPool(token0, token1, tickSpacing); if (pool == address(0)) { pool = factory.createPool(token0, token1, tickSpacing, sqrtPriceX96); } else { (uint160 sqrtPriceX96Existing, , , , , , ) = IRamsesV3Pool(pool).slot0(); if (sqrtPriceX96Existing == 0) { IRamsesV3Pool(pool).initialize(sqrtPriceX96); } } } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; interface IGaugeV3 { error NOT_AUTHORIZED(); error NOT_VOTER(); error NOT_GT_ZERO(); error CANT_CLAIM_FUTURE(); error RETRO(); /// @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 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 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. function positionInfo( uint256 tokenId ) external view returns (uint128 liquidity); */ /// @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; /// @notice retrieves rewards based on an NFP id and an array of tokens function getReward(uint256 tokenId, address[] memory tokens) external; /// @notice retrieves rewards based on an array of NFP ids and an array of tokens function getReward( uint256[] calldata tokenIds, address[] memory tokens ) external; /// @notice get reward for an owner of an NFP function getRewardForOwner( uint256 tokenId, address[] memory tokens ) external; function addRewards(address reward) external; function removeRewards(address reward) 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; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; pragma abicoder v2; interface IVoter { error ACTIVE_GAUGE(address gauge); error GAUGE_INACTIVE(address gauge); error ALREADY_WHITELISTED(); error NOT_AUTHORIZED(address caller); error NOT_WHITELISTED(); error NOT_POOL(); error FORBIDDEN(); error NOT_INIT(); error LENGTH_MISMATCH(); error NO_GAUGE(); error ALREADY_DISTRIBUTED(address gauge, uint256 period); error ZERO_VOTE(address pool); error RATIO_TOO_HIGH(); error NOT_GT_ZERO(); error VOTE_UNSUCCESSFUL(); error UNAUTHORIZED(); event GaugeCreated( address indexed gauge, address creator, address feeDistributor, address indexed pool ); event GaugeKilled(address indexed gauge); event GaugeRevived(address indexed gauge); event Voted(address indexed owner, uint256 weight, address indexed pool); event Abstained(address indexed owner, uint256 weight); event Deposit( address indexed lp, address indexed gauge, address indexed owner, uint256 amount ); event Withdraw( address indexed lp, address indexed gauge, address indexed owner, uint256 amount ); event NotifyReward( address indexed sender, address indexed reward, uint256 amount ); event DistributeReward( address indexed sender, address indexed gauge, uint256 amount ); event EmissionsRatio( address indexed caller, uint256 oldRatio, uint256 newRatio ); event NewGovernor(address indexed sender, address indexed governor); event Whitelisted(address indexed whitelister, address indexed token); event WhitelistRevoked( address indexed forbidder, address indexed token, bool status ); event CustomGaugeCreated( address indexed gauge, address creator, address indexed token ); event MainTickSpacingChanged( address indexed token0, address indexed token1, int24 indexed newMainTickSpacing ); event Poke(address indexed user); function initialize( address _emissionsToken, address _legacyFactory, address _gauges, address _feeDistributorFactory, address _minter, address _msig, address _xShadow, address _clFactory, address _clGaugeFactory, address _nfpManager, address _feeRecipientFactory, address _voteModule, address _launcherPlugin ) external; /// @notice denominator basis function BASIS() external view returns (uint256); /// @notice ratio of xShadow emissions globally function xRatio() external view returns (uint256); /// @notice xShadow contract address function xShadow() external view returns (address); /// @notice legacy factory address (uni-v2/stableswap) function legacyFactory() external view returns (address); /// @notice concentrated liquidity factory function clFactory() external view returns (address); /// @notice gauge factory for CL function clGaugeFactory() external view returns (address); /// @notice legacy fee recipient factory function feeRecipientFactory() external view returns (address); /// @notice peripheral NFPManager contract function nfpManager() external view returns (address); /// @notice returns the address of the current governor /// @return _governor address of the governor function governor() external view returns (address _governor); /// @notice the address of the vote module /// @return _voteModule the vote module contract address function voteModule() external view returns (address _voteModule); /// @notice address of the central access Hub function accessHub() external view returns (address); /// @notice the address of the shadow launcher plugin to enable third party launchers /// @return _launcherPlugin the address of the plugin function launcherPlugin() external view returns (address _launcherPlugin); /// @notice distributes emissions from the minter to the voter /// @param amount the amount of tokens to notify function notifyRewardAmount(uint256 amount) external; /// @notice distributes the emissions for a specific gauge /// @param _gauge the gauge address function distribute(address _gauge) external; /// @notice returns the address of the gauge factory /// @param _gaugeFactory gauge factory address function gaugeFactory() external view returns (address _gaugeFactory); /// @notice returns the address of the feeDistributor factory /// @return _feeDistributorFactory feeDist factory address function feeDistributorFactory() external view returns (address _feeDistributorFactory); /// @notice returns the address of the minter contract /// @return _minter address of the minter function minter() external view returns (address _minter); /// @notice check if the gauge is active for governance use /// @param _gauge address of the gauge /// @return _trueOrFalse if the gauge is alive function isAlive(address _gauge) external view returns (bool _trueOrFalse); /// @notice allows the token to be paired with other whitelisted assets to participate in governance /// @param _token the address of the token function whitelist(address _token) external; /// @notice effectively disqualifies a token from governance /// @param _token the address of the token function revokeWhitelist(address _token) external; /// @notice returns if the address is a gauge /// @param gauge address of the gauge /// @return _trueOrFalse boolean if the address is a gauge function isGauge(address gauge) external view returns (bool _trueOrFalse); /// @notice disable a gauge from governance /// @param _gauge address of the gauge function killGauge(address _gauge) external; /// @notice re-activate a dead gauge /// @param _gauge address of the gauge function reviveGauge(address _gauge) external; /// @notice re-cast a tokenID's votes /// @param owner address of the owner function poke(address owner) external; /// @notice sets the main tickspacing of a token pairing /// @param tokenA address of tokenA /// @param tokenB address of tokenB /// @param tickSpacing the main tickspacing to set to function setMainTickSpacing( address tokenA, address tokenB, int24 tickSpacing ) external; /// @notice create a legacy-type gauge for an arbitrary token /// @param _depositToken 'token' to be used /// @return _arbitraryGauge the address of the new custom gauge function createArbitraryGauge( address _depositToken ) external returns (address _arbitraryGauge); /// @notice returns if the address is a fee distributor /// @param _feeDistributor address of the feeDist /// @return _trueOrFalse if the address is a fee distributor function isFeeDistributor( address _feeDistributor ) external view returns (bool _trueOrFalse); /// @notice returns the address of the emission's token /// @return _emissionsToken emissions token contract address function emissionsToken() external view returns (address _emissionsToken); /// @notice returns the address of the pool's gauge, if any /// @param _pool pool address /// @return _gauge gauge address function gaugeForPool(address _pool) external view returns (address _gauge); /// @notice returns the address of the pool's feeDistributor, if any /// @param _gauge address of the gauge /// @return _feeDistributor address of the pool's feedist function feeDistributorForGauge( address _gauge ) external view returns (address _feeDistributor); /// @notice returns the new toPool that was redirected fromPool /// @param fromPool address of the original pool /// @return toPool the address of the redirected pool function poolRedirect( address fromPool ) external view returns (address toPool); /// @notice returns the gauge address of a CL pool /// @param tokenA address of token A in the pair /// @param tokenB address of token B in the pair /// @param tickSpacing tickspacing of the pool /// @return gauge address of the gauge function gaugeForClPool( address tokenA, address tokenB, int24 tickSpacing ) external view returns (address gauge); /// @notice returns the array of all tickspacings for the tokenA/tokenB combination /// @param tokenA address of token A in the pair /// @param tokenB address of token B in the pair /// @return _ts array of all the tickspacings function tickSpacingsForPair( address tokenA, address tokenB ) external view returns (int24[] memory _ts); /// @notice returns the main tickspacing used in the gauge/governance process /// @param tokenA address of token A in the pair /// @param tokenB address of token B in the pair /// @return _ts the main tickspacing function mainTickSpacingForPair( address tokenA, address tokenB ) external view returns (int24 _ts); /// @notice returns the block.timestamp divided by 1 week in seconds /// @return period the period used for gauges function getPeriod() external view returns (uint256 period); /// @notice cast a vote to direct emissions to gauges and earn incentives /// @param owner address of the owner /// @param _pools the list of pools to vote on /// @param _weights an arbitrary weight per pool which will be normalized to 100% regardless of numerical inputs function vote( address owner, address[] calldata _pools, uint256[] calldata _weights ) external; /// @notice reset the vote of an address /// @param owner address of the owner function reset(address owner) external; /// @notice set the governor address /// @param _governor the new governor address function setGovernor(address _governor) external; /// @notice recover stuck emissions /// @param _gauge the gauge address /// @param _period the period function stuckEmissionsRecovery(address _gauge, uint256 _period) external; /// @notice whitelists extra rewards for a gauge /// @param _gauge the gauge to whitelist rewards to /// @param _reward the reward to whitelist function whitelistGaugeRewards(address _gauge, address _reward) external; /// @notice removes a reward from the gauge whitelist /// @param _gauge the gauge to remove the whitelist from /// @param _reward the reward to remove from the whitelist function removeGaugeRewardWhitelist( address _gauge, address _reward ) external; /// @notice creates a legacy gauge for the pool /// @param _pool pool's address /// @return _gauge address of the new gauge function createGauge(address _pool) external returns (address _gauge); /// @notice create a concentrated liquidity gauge /// @param tokenA the address of tokenA /// @param tokenB the address of tokenB /// @param tickSpacing the tickspacing of the pool /// @return _clGauge address of the new gauge function createCLGauge( address tokenA, address tokenB, int24 tickSpacing ) external returns (address _clGauge); /// @notice claim concentrated liquidity gauge rewards for specific NFP token ids /// @param _gauges array of gauges /// @param _tokens two dimensional array for the tokens to claim /// @param _nfpTokenIds two dimensional array for the NFPs function claimClGaugeRewards( address[] calldata _gauges, address[][] calldata _tokens, uint256[][] calldata _nfpTokenIds ) external; /// @notice claim arbitrary rewards from specific feeDists /// @param owner address of the owner /// @param _feeDistributors address of the feeDists /// @param _tokens two dimensional array for the tokens to claim function claimIncentives( address owner, address[] calldata _feeDistributors, address[][] calldata _tokens ) external; /// @notice claim arbitrary rewards from specific gauges /// @param _gauges address of the gauges /// @param _tokens two dimensional array for the tokens to claim function claimRewards( address[] calldata _gauges, address[][] calldata _tokens ) external; /// @notice distribute emissions to a gauge for a specific period /// @param _gauge address of the gauge /// @param _period value of the period function distributeForPeriod(address _gauge, uint256 _period) external; /// @notice attempt distribution of emissions to all gauges function distributeAll() external; /// @notice distribute emissions to gauges by index /// @param startIndex start of the loop /// @param endIndex end of the loop function batchDistributeByIndex( uint256 startIndex, uint256 endIndex ) external; /// @notice returns the votes cast for a tokenID /// @param owner address of the owner /// @return votes an array of votes casted /// @return weights an array of the weights casted per pool function getVotes( address owner, uint256 period ) external view returns (address[] memory votes, uint256[] memory weights); /// @notice returns an array of all the gauges /// @return _gauges the array of gauges function getAllGauges() external view returns (address[] memory _gauges); /// @notice returns an array of all the feeDists /// @return _feeDistributors the array of feeDists function getAllFeeDistributors() external view returns (address[] memory _feeDistributors); /// @notice sets the xShadowRatio default function setGlobalRatio(uint256 _xRatio) external; /// @notice returns the array of all custom/arbitrary pools function getAllCustomPools() external view returns (address[] memory _customPools); /// @notice whether the token is whitelisted in governance function isWhitelisted(address _token) external view returns (bool _tf); /// @notice function for removing malicious or stuffed tokens function removeFeeDistributorReward( address _feeDist, address _token ) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; interface IAccessHub { error SAME_ADDRESS(); error NOT_TIMELOCK(address); error MANUAL_EXECUTION_FAILURE(bytes); /// @dev Struct to hold initialization parameters struct InitParams { address timelock; address treasury; address voter; address minter; address launcherPlugin; address xShadow; address x33; address ramsesV3PoolFactory; address poolFactory; address clGaugeFactory; address gaugeFactory; address feeRecipientFactory; address feeDistributorFactory; address feeCollector; address voteModule; } /// @notice protocol timelock address function timelock() external view returns (address timelock); /// @notice protocol treasury address function treasury() external view returns (address treasury); /// @notice concentrated (v3) gauge factory function clGaugeFactory() external view returns (address _clGaugeFactory); /// @notice legacy gauge factory address function gaugeFactory() external view returns (address _gaugeFactory); /// @notice the feeDistributor factory address function feeDistributorFactory() external view returns (address _feeDistributorFactory); /// @notice initializing function for setting values in the AccessHub function initialize(InitParams calldata params) external; /// @notice sets the swap fees for multiple pairs function setSwapFees( address[] calldata _pools, uint24[] calldata _swapFees, bool[] calldata _concentrated ) external; /// @notice sets the split of fees between LPs and voters function setFeeSplitCL( address[] calldata _pools, uint8[] calldata _feeProtocol ) external; /// @notice sets the split of fees between LPs and voters for legacy pools function setFeeSplitLegacy( address[] calldata _pools, uint256[] calldata _feeSplits ) external; /** Voter governance */ /// @notice sets a new governor address in the voter.sol contract function setNewGovernorInVoter(address _newGovernor) external; /// @notice whitelists a token for governance, or removes if boolean is set to false function governanceWhitelist( address[] calldata _token, bool[] calldata _whitelisted ) external; /// @notice kills active gauges, removing them from earning further emissions, and claims their fees prior function killGauge(address[] calldata _pairs) external; /// @notice revives inactive/killed gauges function reviveGauge(address[] calldata _pairs) external; /// @notice sets the ratio of xShadow/Shadow awarded globally to LPs function setEmissionsRatioInVoter(uint256 _pct) external; /// @notice allows governance to retrieve emissions in the voter contract that will not be distributed due to the gauge being inactive /// @dev allows per-period retrieval for granularity function retrieveStuckEmissionsToGovernance( address _gauge, uint256 _period ) external; /// @notice allows governance to designate a tickspacing as the "main" one, to prevent governance spam and confusion function setMainTickSpacingInVoter( address tokenA, address tokenB, int24 tickSpacing ) external; /// @notice allows governance to create an arbitrary gauge using any deposit token that conforms to common token standards function createArbitraryGauge(address _depositToken) external; /** xShadow Functions */ /// @notice enables or disables the transfer whitelist in xShadow function transferWhitelistInXShadow( address[] calldata _who, bool[] calldata _whitelisted ) external; /// @notice enables or disables the governance in xShadow function toggleXShadowGovernance(bool enable) external; /// @notice allows redemption from the operator function operatorRedeemXShadow(uint256 _amount) external; /// @notice migrates the xShadow operator function migrateOperator(address _operator) external; /// @notice rescues any trapped tokens in xShadow function rescueTrappedTokens( address[] calldata _tokens, uint256[] calldata _amounts ) external; /** X33 Functions */ /// @notice transfers the x33 operator address function transferOperatorInX33(address _newOperator) external; /** Minter Functions */ /// @notice sets the inflation multiplier /// @param _multiplier the multiplier function setEmissionsMultiplierInMinter(uint256 _multiplier) external; /** Reward List Functions */ /// @notice function for adding or removing rewards for pools function augmentGaugeRewardsForPair( address[] calldata _pools, address[] calldata _rewards, bool[] calldata _addReward ) external; /// @notice function for removing rewards for feeDistributors function removeFeeDistributorRewards( address[] calldata _pools, address[] calldata _rewards ) external; /** LauncherPlugin specific functions */ /// @notice allows migrating the parameters from one pool to the other /// @param _oldPool the current address of the pair /// @param _newPool the new pool's address function migratePoolInLauncherPlugin( address _oldPool, address _newPool ) external; /// @notice set launcher configurations for a pool /// @param _pool address of the pool /// @param _take the fee that goes to the designated recipient /// @param _recipient the address that receives the fees function setConfigsInLauncherPlugin( address _pool, uint256 _take, address _recipient ) external; /// @notice enables the pool for LauncherConfigs /// @param _pool address of the pool function enablePoolInLauncherPlugin(address _pool) external; /// @notice disables the pool for LauncherConfigs /// @dev clears mappings /// @param _pool address of the pool function disablePoolInLauncherPlugin(address _pool) external; /// @notice sets a new operator address /// @param _newOperator new operator address function setOperatorInLauncherPlugin(address _newOperator) external; /// @notice gives authority to a new contract/address /// @param _newAuthority the suggested new authority function grantAuthorityInLauncherPlugin( address _newAuthority, string calldata _label ) external; /// @notice governance ability to label each authority in the system with an arbitrary string function labelAuthorityInLauncherPlugin( address _authority, string calldata _label ) external; /// @notice removes authority from a contract/address /// @param _oldAuthority the to-be-removed authority function revokeAuthorityInLauncherPlugin(address _oldAuthority) external; /** FeeCollector functions */ /// @notice Sets the treasury address to a new value. /// @param newTreasury The new address to set as the treasury. function setTreasuryInFeeCollector(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 setTreasuryFeesInFeeCollector(uint256 _treasuryFees) external; /** FeeRecipientFactory functions */ /// @notice set the fee % to be sent to the treasury /// @param _feeToTreasury the fee % to be sent to the treasury function setFeeToTreasuryInFeeRecipientFactory( uint256 _feeToTreasury ) external; /// @notice set a new treasury address /// @param _treasury the new address function setTreasuryInFeeRecipientFactory(address _treasury) external; /** CL Pool Factory functions */ /// @notice enables a tickSpacing with the given initialFee amount /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @dev tickSpacings may never be removed once enabled /// @param tickSpacing The spacing between ticks to be enforced for all pools created /// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6) function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external; /// @notice sets the feeProtocol (feeSplit) for new CL pools and stored in the factory function setGlobalClFeeProtocol(uint8 _feeProtocolGlobal) external; /// @notice sets the address of the voter in the v3 factory for gauge fee setting function setVoterAddressInFactoryV3(address _voter) external; /// @notice sets the address of the feeCollector in the v3 factory for fee routing function setFeeCollectorInFactoryV3(address _newFeeCollector) external; /** Legacy Pool Factory functions */ /// @notice sets the treasury address in the legacy factory function setTreasuryInLegacyFactory(address _treasury) external; /// @notice enables or disables if there is a feeSplit when no gauge for legacy pairs function setFeeSplitWhenNoGauge(bool status) external; /// @notice set the default feeSplit in the legacy factory function setLegacyFeeSplitGlobal(uint256 _feeSplit) external; /// @notice set the default swap fee for legacy pools function setLegacyFeeGlobal(uint256 _fee) external; /// @notice sets whether a pair can have skim() called or not for rebasing purposes function setSkimEnabledLegacy(address _pair, bool _status) external; /** VoteModule Functions*/ /// @notice sets addresses as exempt or removes their exemption function setCooldownExemption( address[] calldata _candidates, bool[] calldata _exempt ) external; /// @notice function to alter the duration that rebases are streamed in the voteModule function setNewRebaseStreamingDuration(uint256 _newDuration) external; /// @notice function to change the cooldown in the voteModule function setNewVoteModuleCooldown(uint256 _newCooldown) external; /** Timelock gated functions */ /// @notice timelock gated payload execution in case tokens get stuck or other unexpected behaviors function execute(address _target, bytes calldata _payload) external; /// @notice timelock gated function to change the timelock function setNewTimelock(address _timelock) external; /// @notice function for initializing the voter contract with its dependencies function initializeVoter( address _emissionsToken, address _legacyFactory, address _gauges, address _feeDistributorFactory, address _minter, address _msig, address _xShadow, address _clFactory, address _clGaugeFactory, address _nfpManager, address _feeRecipientFactory, address _voteModule, address _launcherPlugin ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC-721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * 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 ERC-721 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 ERC-721 * 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 address zero. * * 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 (last updated v5.0.0) (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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 v5.1.0) (token/ERC721/utils/ERC721Utils.sol) pragma solidity ^0.8.20; import {IERC721Receiver} from "../IERC721Receiver.sol"; import {IERC721Errors} from "../../../interfaces/draft-IERC6093.sol"; /** * @dev Library that provide common ERC-721 utility functions. * * See https://eips.ethereum.org/EIPS/eip-721[ERC-721]. * * _Available since v5.1._ */ library ERC721Utils { /** * @dev Performs an acceptance check for the provided `operator` by calling {IERC721-onERC721Received} * on the `to` address. The `operator` is generally the address that initiated the token transfer (i.e. `msg.sender`). * * The acceptance call is not executed and treated as a no-op if the target address doesn't contain code (i.e. an EOA). * Otherwise, the recipient must implement {IERC721Receiver-onERC721Received} and return the acceptance magic value to accept * the transfer. */ function checkOnERC721Received( address operator, address from, address to, uint256 tokenId, bytes memory data ) internal { if (to.code.length > 0) { try IERC721Receiver(to).onERC721Received(operator, from, tokenId, data) returns (bytes4 retval) { if (retval != IERC721Receiver.onERC721Received.selector) { // Token rejected revert IERC721Errors.ERC721InvalidReceiver(to); } } catch (bytes memory reason) { if (reason.length == 0) { // non-IERC721Receiver implementer revert IERC721Errors.ERC721InvalidReceiver(to); } else { assembly ("memory-safe") { revert(add(32, reason), mload(reason)) } } } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant HEX_DIGITS = "0123456789abcdef"; uint8 private constant ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; assembly ("memory-safe") { ptr := add(buffer, add(32, length)) } while (true) { ptr--; assembly ("memory-safe") { mstore8(ptr, byte(mod(value, 10), HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal * representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH); } /** * @dev Converts an `address` with fixed length of 20 bytes to its checksummed ASCII `string` hexadecimal * representation, according to EIP-55. */ function toChecksumHexString(address addr) internal pure returns (string memory) { bytes memory buffer = bytes(toHexString(addr)); // hash the hex part of buffer (skip length + 2 bytes, length 40) uint256 hashValue; assembly ("memory-safe") { hashValue := shr(96, keccak256(add(buffer, 0x22), 40)) } for (uint256 i = 41; i > 1; --i) { // possible values for buffer[i] are 48 (0) to 57 (9) and 97 (a) to 102 (f) if (hashValue & 0xf > 7 && uint8(buffer[i]) > 96) { // case shift by xoring with 0x20 buffer[i] ^= 0x20; } hashValue >>= 4; } return string(buffer); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.20; import {IERC721} from "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @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: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Multicall interface /// @notice Enables calling multiple methods in a single call to the contract interface IMulticall { /// @notice Call multiple functions in the current contract and return the data from all of them if they all succeed /// @dev The `msg.value` should not be trusted for any method callable from multicall. /// @param data The encoded function data for each of the calls to make to this contract /// @return results The results from each of the calls passed in via data function multicall(bytes[] calldata data) external payable returns (bytes[] memory results); }
// 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 IRamsesV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IRamsesV3Factory interface /// @return The contract address function factory() 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); }
// 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 IRamsesV3PoolState { /// @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 /// @return 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. /// @return observationIndex The index of the last oracle observation that was written, /// @return observationCardinality The current maximum number of observations stored in the pool, /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// @return 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 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 /// @return The liquidity at the current price of the pool function liquidity() external view returns (uint128); /// @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 /// @return liquidityNet how much liquidity changes when the pool price crosses the tick, /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// @return secondsOutside the seconds spent on the other side of the tick from the current tick, /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks( int24 tick ) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return liquidity The amount of liquidity in the position, /// @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 function positions( bytes32 key ) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @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 ); /// @notice get the period seconds in range of a specific position /// @param period the period number /// @param owner owner address /// @param index position index /// @param tickLower lower bound of range /// @param tickUpper upper bound of range /// @return periodSecondsInsideX96 seconds the position was not in range for the period function positionPeriodSecondsInRange( uint256 period, address owner, uint256 index, int24 tickLower, int24 tickUpper ) external view returns (uint256 periodSecondsInsideX96); }
// 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 IRamsesV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe( uint32[] calldata secondsAgos ) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside( int24 tickLower, int24 tickUpper ) external view returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside); }
// 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 IRamsesV3PoolActions { /// @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 /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// 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 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, 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 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 /// @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 Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @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 IUniswapV3FlashCallback#uniswapV3FlashCallback /// @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 Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IRamsesV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees 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 Errors emitted by a pool /// @notice Contains all events emitted by the pool interface IRamsesV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); error SPL(); }
// 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 IRamsesV3PoolEvents { /// @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.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param tickSpacing The tickSpacing of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary( address token0, address token1, int24 tickSpacing, uint160 sqrtPriceX96 ) external payable returns (address pool); }
// 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.5.0; /// @title Immutable state /// @notice Functions that return immutable state of the router interface IPeripheryImmutableState { /// @return Returns the address of the Uniswap V3 deployer function deployer() 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.5.0; /// @title Errors emitted by the NonFungiblePositionManager /// @notice Contains all events emitted by the NfpManager interface IPeripheryErrors { error InvalidTokenId(uint256 tokenId); error CheckSlippage(); error NotCleared(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Ramses V3 Factory /// @notice The Ramses V3 Factory facilitates creation of Ramses V3 pools and control over the protocol fees interface IRamsesV3Factory { error IT(); /// @dev Fee Too Large error FTL(); error A0(); error F0(); error PE(); /// @notice Emitted when a pool is created /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param pool The address of the created pool event PoolCreated( address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool ); /// @notice Emitted when a new tickspacing amount is enabled for pool creation via the factory /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param fee The fee, denominated in hundredths of a bip event TickSpacingEnabled(int24 indexed tickSpacing, uint24 indexed fee); /// @notice Emitted when the protocol fee is changed /// @param feeProtocolOld The previous value of the protocol fee /// @param feeProtocolNew The updated value of the protocol fee event SetFeeProtocol(uint8 feeProtocolOld, uint8 feeProtocolNew); /// @notice Emitted when the protocol fee is changed /// @param pool The pool address /// @param feeProtocolOld The previous value of the protocol fee /// @param feeProtocolNew The updated value of the protocol fee event SetPoolFeeProtocol(address pool, uint8 feeProtocolOld, uint8 feeProtocolNew); /// @notice Emitted when a pool's fee is changed /// @param pool The pool address /// @param newFee The updated value of the protocol fee event FeeAdjustment(address pool, uint24 newFee); /// @notice Emitted when the fee collector is changed /// @param oldFeeCollector The previous implementation /// @param newFeeCollector The new implementation event FeeCollectorChanged(address indexed oldFeeCollector, address indexed newFeeCollector); /// @notice Returns the PoolDeployer address /// @return The address of the PoolDeployer contract function ramsesV3PoolDeployer() external returns (address); /// @notice Returns the fee amount for a given tickSpacing, if enabled, or 0 if not enabled /// @dev A tickSpacing can never be removed, so this value should be hard coded or cached in the calling context /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tickSpacing The enabled tickSpacing. Returns 0 in case of unenabled tickSpacing /// @return initialFee The initial fee function tickSpacingInitialFee(int24 tickSpacing) external view returns (uint24 initialFee); /// @notice Returns the pool address for a given pair of tokens and a tickSpacing, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param tickSpacing The tickSpacing of the pool /// @return pool The pool address function getPool(address tokenA, address tokenB, int24 tickSpacing) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param tickSpacing The desired tickSpacing for the pool /// @param sqrtPriceX96 initial sqrtPriceX96 of the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. /// @dev The call will revert if the pool already exists, the tickSpacing is invalid, or the token arguments are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, int24 tickSpacing, uint160 sqrtPriceX96 ) external returns (address pool); /// @notice Enables a tickSpacing with the given initialFee amount /// @dev unlike UniswapV3, we map via the tickSpacing rather than the fee tier /// @dev tickSpacings may never be removed once enabled /// @param tickSpacing The spacing between ticks to be enforced for all pools created /// @param initialFee The initial fee amount, denominated in hundredths of a bip (i.e. 1e-6) function enableTickSpacing(int24 tickSpacing, uint24 initialFee) external; /// @notice returns the default protocol fee. /// @return _feeProtocol the default feeProtocol function feeProtocol() external view returns (uint8 _feeProtocol); /// @notice returns the % of fees directed to governance /// @dev if the fee is 0, or the pool is uninitialized this will return the Factory's default feeProtocol /// @param pool the address of the pool /// @return _feeProtocol the feeProtocol for the pool function poolFeeProtocol(address pool) external view returns (uint8 _feeProtocol); /// @notice Sets the default protocol's % share of the fees /// @param _feeProtocol new default protocol fee for token0 and token1 function setFeeProtocol(uint8 _feeProtocol) external; /// @notice Get the parameters to be used in constructing the pool, set transiently during pool creation. /// @dev Called by the pool constructor to fetch the parameters of the pool /// @return factory The factory address /// @return token0 The first token of the pool by address sort order /// @return token1 The second token of the pool by address sort order /// @return fee The initialized feetier of the pool, denominated in hundredths of a bip /// @return tickSpacing The minimum number of ticks between initialized ticks function parameters() external view returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing); /// @notice Sets the fee collector address /// @param _feeCollector the fee collector address function setFeeCollector(address _feeCollector) external; /// @notice sets the swap fee for a specific pool /// @param _pool address of the pool /// @param _fee the fee to be assigned to the pool, scaled to 1_000_000 = 100% function setFee(address _pool, uint24 _fee) external; /// @notice Returns the address of the fee collector contract /// @dev Fee collector decides where the protocol fees go (fee distributor, treasury, etc.) function feeCollector() external view returns (address); /// @notice sets the feeProtocol of a specific pool /// @param pool address of the pool /// @param _feeProtocol the fee protocol to assign function setPoolFeeProtocol(address pool, uint8 _feeProtocol) external; /// @notice sets the feeProtocol upon a gauge's creation /// @param pool address of the pool function gaugeFeeSplitEnable(address pool) external; /// @notice sets the the voter address /// @param _voter the address of the voter function setVoter(address _voter) external; function initialize(address poolDeployer) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @dev original UniswapV3 callbacks maintained to ensure seamless integrations /// @title Callback for IUniswapV3PoolActions#mint /// @notice Any contract that calls IUniswapV3PoolActions#mint must implement this interface interface IUniswapV3MintCallback { /// @notice Called to `msg.sender` after minting liquidity to a position from IUniswapV3Pool#mint. /// @dev In the implementation you must pay the pool tokens owed for the minted liquidity. /// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory. /// @param amount0Owed The amount of token0 due to the pool for the minted liquidity /// @param amount1Owed The amount of token1 due to the pool for the minted liquidity /// @param data Any data passed through by the caller via the IUniswapV3PoolActions#mint call function uniswapV3MintCallback(uint256 amount0Owed, uint256 amount1Owed, bytes calldata data) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; /// @title Math library for computing sqrt prices from ticks and vice versa /// @notice Computes sqrt price for ticks of size 1.0001, i.e. sqrt(1.0001^tick) as fixed point Q64.96 numbers. Supports /// prices between 2**-128 and 2**128 library TickMath { error T(); error R(); /// @dev The minimum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**-128 int24 internal constant MIN_TICK = -887272; /// @dev The maximum tick that may be passed to #getSqrtRatioAtTick computed from log base 1.0001 of 2**128 int24 internal constant MAX_TICK = -MIN_TICK; /// @dev The minimum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MIN_TICK) uint160 internal constant MIN_SQRT_RATIO = 4295128739; /// @dev The maximum value that can be returned from #getSqrtRatioAtTick. Equivalent to getSqrtRatioAtTick(MAX_TICK) uint160 internal constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342; /// @notice Calculates sqrt(1.0001^tick) * 2^96 /// @dev Throws if |tick| > max tick /// @param tick The input tick for the above formula /// @return sqrtPriceX96 A Fixed point Q64.96 number representing the sqrt of the ratio of the two assets (token1/token0) /// at the given tick function getSqrtRatioAtTick(int24 tick) internal pure returns (uint160 sqrtPriceX96) { unchecked { uint256 absTick = tick < 0 ? uint256(-int256(tick)) : uint256(int256(tick)); if (absTick > uint256(int256(MAX_TICK))) revert T(); uint256 ratio = absTick & 0x1 != 0 ? 0xfffcb933bd6fad37aa2d162d1a594001 : 0x100000000000000000000000000000000; if (absTick & 0x2 != 0) ratio = (ratio * 0xfff97272373d413259a46990580e213a) >> 128; if (absTick & 0x4 != 0) ratio = (ratio * 0xfff2e50f5f656932ef12357cf3c7fdcc) >> 128; if (absTick & 0x8 != 0) ratio = (ratio * 0xffe5caca7e10e4e61c3624eaa0941cd0) >> 128; if (absTick & 0x10 != 0) ratio = (ratio * 0xffcb9843d60f6159c9db58835c926644) >> 128; if (absTick & 0x20 != 0) ratio = (ratio * 0xff973b41fa98c081472e6896dfb254c0) >> 128; if (absTick & 0x40 != 0) ratio = (ratio * 0xff2ea16466c96a3843ec78b326b52861) >> 128; if (absTick & 0x80 != 0) ratio = (ratio * 0xfe5dee046a99a2a811c461f1969c3053) >> 128; if (absTick & 0x100 != 0) ratio = (ratio * 0xfcbe86c7900a88aedcffc83b479aa3a4) >> 128; if (absTick & 0x200 != 0) ratio = (ratio * 0xf987a7253ac413176f2b074cf7815e54) >> 128; if (absTick & 0x400 != 0) ratio = (ratio * 0xf3392b0822b70005940c7a398e4b70f3) >> 128; if (absTick & 0x800 != 0) ratio = (ratio * 0xe7159475a2c29b7443b29c7fa6e889d9) >> 128; if (absTick & 0x1000 != 0) ratio = (ratio * 0xd097f3bdfd2022b8845ad8f792aa5825) >> 128; if (absTick & 0x2000 != 0) ratio = (ratio * 0xa9f746462d870fdf8a65dc1f90e061e5) >> 128; if (absTick & 0x4000 != 0) ratio = (ratio * 0x70d869a156d2a1b890bb3df62baf32f7) >> 128; if (absTick & 0x8000 != 0) ratio = (ratio * 0x31be135f97d08fd981231505542fcfa6) >> 128; if (absTick & 0x10000 != 0) ratio = (ratio * 0x9aa508b5b7a84e1c677de54f3e99bc9) >> 128; if (absTick & 0x20000 != 0) ratio = (ratio * 0x5d6af8dedb81196699c329225ee604) >> 128; if (absTick & 0x40000 != 0) ratio = (ratio * 0x2216e584f5fa1ea926041bedfe98) >> 128; if (absTick & 0x80000 != 0) ratio = (ratio * 0x48a170391f7dc42444e8fa2) >> 128; if (tick > 0) ratio = type(uint256).max / ratio; /// @dev this divides by 1<<32 rounding up to go from a Q128.128 to a Q128.96. /// @dev we then downcast because we know the result always fits within 160 bits due to our tick input constraint /// @dev we round up in the division so getTickAtSqrtRatio of the output price is always consistent sqrtPriceX96 = uint160((ratio >> 32) + (ratio % (1 << 32) == 0 ? 0 : 1)); } } /// @notice Calculates the greatest tick value such that getRatioAtTick(tick) <= ratio /// @dev Throws in case sqrtPriceX96 < MIN_SQRT_RATIO, as MIN_SQRT_RATIO is the lowest value getRatioAtTick may /// ever return. /// @param sqrtPriceX96 The sqrt ratio for which to compute the tick as a Q64.96 /// @return tick The greatest tick for which the ratio is less than or equal to the input ratio function getTickAtSqrtRatio(uint160 sqrtPriceX96) internal pure returns (int24 tick) { unchecked { /// @dev second inequality must be < because the price can never reach the price at the max tick if (!(sqrtPriceX96 >= MIN_SQRT_RATIO && sqrtPriceX96 < MAX_SQRT_RATIO)) revert R(); uint256 ratio = uint256(sqrtPriceX96) << 32; uint256 r = ratio; uint256 msb = 0; assembly { let f := shl(7, gt(r, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(6, gt(r, 0xFFFFFFFFFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(5, gt(r, 0xFFFFFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(4, gt(r, 0xFFFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(3, gt(r, 0xFF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(2, gt(r, 0xF)) msb := or(msb, f) r := shr(f, r) } assembly { let f := shl(1, gt(r, 0x3)) msb := or(msb, f) r := shr(f, r) } assembly { let f := gt(r, 0x1) msb := or(msb, f) } if (msb >= 128) r = ratio >> (msb - 127); else r = ratio << (127 - msb); int256 log_2 = (int256(msb) - 128) << 64; assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(63, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(62, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(61, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(60, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(59, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(58, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(57, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(56, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(55, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(54, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(53, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(52, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(51, f)) r := shr(f, r) } assembly { r := shr(127, mul(r, r)) let f := shr(128, r) log_2 := or(log_2, shl(50, f)) } int256 log_sqrt10001 = log_2 * 255738958999603826347141; /// @dev 128.128 number int24 tickLow = int24((log_sqrt10001 - 3402992956809132418596140100660247210) >> 128); int24 tickHi = int24((log_sqrt10001 + 291339464771989622907027621153398088495) >> 128); tick = tickLow == tickHi ? tickLow : getSqrtRatioAtTick(tickHi) <= sqrtPriceX96 ? tickHi : tickLow; } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.0; import '../../core/interfaces/IRamsesV3Pool.sol'; import './PoolAddress.sol'; /// @notice Provides validation for callbacks from Ramses V3 Pools library CallbackValidation { /// @notice Returns the address of a valid Ramses V3 Pool /// @param deployer The contract address of the Ramses V3 deployer /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param tickSpacing The tickSpacing of the pool /// @return pool The V3 pool contract address function verifyCallback( address deployer, address tokenA, address tokenB, int24 tickSpacing ) internal view returns (IRamsesV3Pool pool) { return verifyCallback(deployer, PoolAddress.getPoolKey(tokenA, tokenB, tickSpacing)); } /// @notice Returns the address of a valid Ramses V3 Pool /// @param deployer The contract address of the Ramses V3 deployer /// @param poolKey The identifying key of the V3 pool /// @return pool The V3 pool contract address function verifyCallback( address deployer, PoolAddress.PoolKey memory poolKey ) internal view returns (IRamsesV3Pool pool) { pool = IRamsesV3Pool(PoolAddress.computeAddress(deployer, poolKey)); require(msg.sender == address(pool)); } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import '../../core/libraries/FullMath.sol'; import '../../core/libraries/FixedPoint96.sol'; /// @title Liquidity amount functions /// @notice Provides functions for computing liquidity amounts from token amounts and prices library LiquidityAmounts { /// @notice Downcasts uint256 to uint128 /// @param x The uint258 to be downcasted /// @return y The passed value, downcasted to uint128 function toUint128(uint256 x) private pure returns (uint128 y) { require((y = uint128(x)) == x); } /// @notice Computes the amount of liquidity received for a given amount of token0 and price range /// @dev Calculates amount0 * (sqrt(upper) * sqrt(lower)) / (sqrt(upper) - sqrt(lower)) /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount0 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount0( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); uint256 intermediate = FullMath.mulDiv(sqrtRatioAX96, sqrtRatioBX96, FixedPoint96.Q96); unchecked { return toUint128(FullMath.mulDiv(amount0, intermediate, sqrtRatioBX96 - sqrtRatioAX96)); } } /// @notice Computes the amount of liquidity received for a given amount of token1 and price range /// @dev Calculates amount1 / (sqrt(upper) - sqrt(lower)). /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount1 The amount1 being sent in /// @return liquidity The amount of returned liquidity function getLiquidityForAmount1( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); unchecked { return toUint128(FullMath.mulDiv(amount1, FixedPoint96.Q96, sqrtRatioBX96 - sqrtRatioAX96)); } } /// @notice Computes the maximum amount of liquidity received for a given amount of token0, token1, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param amount0 The amount of token0 being sent in /// @param amount1 The amount of token1 being sent in /// @return liquidity The maximum amount of liquidity received function getLiquidityForAmounts( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint256 amount0, uint256 amount1 ) internal pure returns (uint128 liquidity) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { liquidity = getLiquidityForAmount0(sqrtRatioAX96, sqrtRatioBX96, amount0); } else if (sqrtRatioX96 < sqrtRatioBX96) { uint128 liquidity0 = getLiquidityForAmount0(sqrtRatioX96, sqrtRatioBX96, amount0); uint128 liquidity1 = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioX96, amount1); liquidity = liquidity0 < liquidity1 ? liquidity0 : liquidity1; } else { liquidity = getLiquidityForAmount1(sqrtRatioAX96, sqrtRatioBX96, amount1); } } /// @notice Computes the amount of token0 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 function getAmount0ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0) { unchecked { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); return FullMath.mulDiv( uint256(liquidity) << FixedPoint96.RESOLUTION, sqrtRatioBX96 - sqrtRatioAX96, sqrtRatioBX96 ) / sqrtRatioAX96; } } /// @notice Computes the amount of token1 for a given amount of liquidity and a price range /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount1 The amount of token1 function getAmount1ForLiquidity( uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); unchecked { return FullMath.mulDiv(liquidity, sqrtRatioBX96 - sqrtRatioAX96, FixedPoint96.Q96); } } /// @notice Computes the token0 and token1 value for a given amount of liquidity, the current /// pool prices and the prices at the tick boundaries /// @param sqrtRatioX96 A sqrt price representing the current pool prices /// @param sqrtRatioAX96 A sqrt price representing the first tick boundary /// @param sqrtRatioBX96 A sqrt price representing the second tick boundary /// @param liquidity The liquidity being valued /// @return amount0 The amount of token0 /// @return amount1 The amount of token1 function getAmountsForLiquidity( uint160 sqrtRatioX96, uint160 sqrtRatioAX96, uint160 sqrtRatioBX96, uint128 liquidity ) internal pure returns (uint256 amount0, uint256 amount1) { if (sqrtRatioAX96 > sqrtRatioBX96) (sqrtRatioAX96, sqrtRatioBX96) = (sqrtRatioBX96, sqrtRatioAX96); if (sqrtRatioX96 <= sqrtRatioAX96) { amount0 = getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } else if (sqrtRatioX96 < sqrtRatioBX96) { amount0 = getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, liquidity); amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, liquidity); } else { amount1 = getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '../interfaces/IPeripheryPayments.sol'; import '../interfaces/external/IWETH9.sol'; import '../libraries/TransferHelper.sol'; import './PeripheryImmutableState.sol'; abstract contract PeripheryPayments is IPeripheryPayments, PeripheryImmutableState { receive() external payable { require(msg.sender == WETH9, 'Not WETH9'); } /// @inheritdoc IPeripheryPayments function unwrapWETH9(uint256 amountMinimum, address recipient) public payable override { uint256 balanceWETH9 = IWETH9(WETH9).balanceOf(address(this)); require(balanceWETH9 >= amountMinimum, 'Insufficient WETH9'); if (balanceWETH9 > 0) { IWETH9(WETH9).withdraw(balanceWETH9); TransferHelper.safeTransferETH(recipient, balanceWETH9); } } /// @inheritdoc IPeripheryPayments function sweepToken( address token, uint256 amountMinimum, address recipient ) public payable override { uint256 balanceToken = IERC20(token).balanceOf(address(this)); require(balanceToken >= amountMinimum, 'Insufficient token'); if (balanceToken > 0) { TransferHelper.safeTransfer(token, recipient, balanceToken); } } /// @inheritdoc IPeripheryPayments function refundETH() external payable override { if (address(this).balance > 0) TransferHelper.safeTransferETH(msg.sender, address(this).balance); } /// @param token The token to pay /// @param payer The entity that must pay /// @param recipient The entity that will receive payment /// @param value The amount to pay function pay( address token, address payer, address recipient, uint256 value ) internal { if (token == WETH9 && address(this).balance >= value) { // pay with WETH9 IWETH9(WETH9).deposit{value: value}(); // wrap only what is needed to pay IWETH9(WETH9).transfer(recipient, value); } else if (payer == address(this)) { // pay with tokens already in the contract (for the exact input multihop case) TransferHelper.safeTransfer(token, recipient, value); } else { // pull payment TransferHelper.safeTransferFrom(token, payer, recipient, value); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; /// @title Function for getting block timestamp /// @dev Base contract that is overridden for tests abstract contract BlockTimestamp { /// @dev Method that exists purely to be overridden for tests /// @return The current block timestamp function _blockTimestamp() internal view virtual returns (uint256) { return block.timestamp; } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title An interface for a contract that is capable of deploying Ramses V3 Pools /// @notice A contract that constructs a pool must implement this to pass arguments to the pool /// @dev This is used to avoid having constructor arguments in the pool contract, which results in the init code hash /// of the pool being constant allowing the CREATE2 address of the pool to be cheaply computed on-chain interface IRamsesV3PoolDeployer { /// @notice Get the parameters to be used in constructing the pool, set transiently during pool creation. /// @dev Called by the pool constructor to fetch the parameters of the pool /// Returns factory The factory address /// Returns token0 The first token of the pool by address sort order /// Returns token1 The second token of the pool by address sort order /// Returns fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// Returns tickSpacing The minimum number of ticks between initialized ticks function parameters() external view returns (address factory, address token0, address token1, uint24 fee, int24 tickSpacing); /// @dev Deploys a pool with the given parameters by transiently setting the parameters storage slot and then /// clearing it after deploying the pool. /// @param token0 The first token of the pool by address sort order /// @param token1 The second token of the pool by address sort order /// @param tickSpacing The tickSpacing of the pool function deploy(address token0, address token1, int24 tickSpacing) external returns (address pool); function RamsesV3Factory() external view returns (address factory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC 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 v5.1.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC-721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC-721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(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 towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * 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²⁵⁶ and mod 2²⁵⁶ - 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²⁵⁶ + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) 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²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_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. uint256 twos = denominator & (0 - denominator); 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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. 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⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // 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²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, 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; } } /** * @dev 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) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * 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; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, int256 a, int256 b) internal pure returns (int256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * int256(SafeCast.toUint(condition))); } } /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return ternary(a < b, a, b); } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // Formula from the "Bit Twiddling Hacks" by Sean Eron Anderson. // Since `n` is a signed integer, the generated bytecode will use the SAR opcode to perform the right shift, // taking advantage of the most significant (or "sign" bit) in two's complement representation. // This opcode adds new most significant bits set to the value of the previous most significant bit. As a result, // the mask will either be `bytes32(0)` (if n is positive) or `~bytes32(0)` (if n is negative). int256 mask = n >> 255; // A `bytes32(0)` mask leaves the input unchanged, while a `~bytes32(0)` mask complements it. return uint256((n + mask) ^ mask); } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.4.0; /// @title FixedPoint96 /// @notice A library for handling binary fixed point numbers, see https://en.wikipedia.org/wiki/Q_(number_format) /// @dev Used in SqrtPriceMath.sol library FixedPoint96 { uint8 internal constant RESOLUTION = 96; uint256 internal constant Q96 = 0x1000000000000000000000000; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ 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 value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` 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 value) external returns (bool); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; /// @title Interface for WETH9 interface IWETH9 is IERC20 { /// @notice Deposit ether to get wrapped ether function deposit() external payable; /// @notice Withdraw wrapped ether to get ether function withdraw(uint256) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.6.0; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; library TransferHelper { /// @notice Transfers tokens from the targeted address to the given destination /// @notice Errors with 'STF' if transfer fails /// @param token The contract address of the token to be transferred /// @param from The originating address from which the tokens will be transferred /// @param to The destination address of the transfer /// @param value The amount to be transferred function safeTransferFrom( address token, address from, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call( abi.encodeWithSelector(IERC20.transferFrom.selector, from, to, value) ); require(success && (data.length == 0 || abi.decode(data, (bool))), 'STF'); } /// @notice Transfers tokens from msg.sender to a recipient /// @dev Errors with ST if transfer fails /// @param token The contract address of the token which will be transferred /// @param to The recipient of the transfer /// @param value The value of the transfer function safeTransfer( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.transfer.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'ST'); } /// @notice Approves the stipulated contract to spend the given allowance in the given token /// @dev Errors with 'SA' if transfer fails /// @param token The contract address of the token to be approved /// @param to The target of the approval /// @param value The amount of the given token the target will be allowed to spend function safeApprove( address token, address to, uint256 value ) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(IERC20.approve.selector, to, value)); require(success && (data.length == 0 || abi.decode(data, (bool))), 'SA'); } /// @notice Transfers ETH to the recipient address /// @dev Fails with `STE` /// @param to The destination of the transfer /// @param value The value to be transferred function safeTransferETH(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(new bytes(0)); require(success, 'STE'); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
{ "remappings": [ "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/", "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@forge-std-1.9.4/=dependencies/forge-std-1.9.4/", "@openzeppelin-contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@openzeppelin-contracts/contracts/=dependencies/@openzeppelin-contracts-5.1.0/", "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/", "forge-std/=dependencies/forge-std-1.9.4/src/", "permit2/=lib/permit2/", "@openzeppelin-3.4.2/=node_modules/@openzeppelin-3.4.2/", "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/", "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std-1.9.4/=dependencies/forge-std-1.9.4/src/", "hardhat/=node_modules/hardhat/", "solmate/=node_modules/solmate/" ], "optimizer": { "enabled": true, "runs": 2633 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": { "contracts/CL/periphery/libraries/NFTDescriptor.sol": { "NFTDescriptor": "0x1Ca484EE7aE7FE5fD3bc4BAEF07905796EFD6Cda" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_deployer","type":"address"},{"internalType":"address","name":"_WETH9","type":"address"},{"internalType":"address","name":"_tokenDescriptor_","type":"address"},{"internalType":"address","name":"_accessHub","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"CheckSlippage","type":"error"},{"inputs":[],"name":"ERC721EnumerableForbiddenBatchMint","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721IncorrectOwner","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721InsufficientApproval","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC721InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"operator","type":"address"}],"name":"ERC721InvalidOperator","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"ERC721InvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC721InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC721InvalidSender","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ERC721NonexistentToken","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"ERC721OutOfBoundsIndex","type":"error"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"InvalidTokenId","type":"error"},{"inputs":[],"name":"NotCleared","type":"error"},{"inputs":[],"name":"Old","type":"error"},{"inputs":[],"name":"Slippage","type":"error"},{"inputs":[],"name":"T","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"Collect","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"DecreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint128","name":"liquidity","type":"uint128"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"IncreaseLiquidity","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"WETH9","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint128","name":"amount0Max","type":"uint128"},{"internalType":"uint128","name":"amount1Max","type":"uint128"}],"internalType":"struct INonfungiblePositionManager.CollectParams","name":"params","type":"tuple"}],"name":"collect","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"name":"createAndInitializePoolIfNecessary","outputs":[{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.DecreaseLiquidityParams","name":"params","type":"tuple"}],"name":"decreaseLiquidity","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"deployer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"}],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.IncreaseLiquidityParams","name":"params","type":"tuple"}],"name":"increaseLiquidity","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint256","name":"amount0Desired","type":"uint256"},{"internalType":"uint256","name":"amount1Desired","type":"uint256"},{"internalType":"uint256","name":"amount0Min","type":"uint256"},{"internalType":"uint256","name":"amount1Min","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"deadline","type":"uint256"}],"internalType":"struct INonfungiblePositionManager.MintParams","name":"params","type":"tuple"}],"name":"mint","outputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"positions","outputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"int24","name":"tickSpacing","type":"int24"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"feeGrowthInside0LastX128","type":"uint256"},{"internalType":"uint256","name":"feeGrowthInside1LastX128","type":"uint256"},{"internalType":"uint128","name":"tokensOwed0","type":"uint128"},{"internalType":"uint128","name":"tokensOwed1","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"refundETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_voter","type":"address"}],"name":"setVoter","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount0Owed","type":"uint256"},{"internalType":"uint256","name":"amount1Owed","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3MintCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountMinimum","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"}],"name":"unwrapWETH9","outputs":[],"stateMutability":"payable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
610100604052346103ee57614e656080813803918261001d816103f2565b9384928339810103126103ee5761003381610417565b61003f60208301610417565b91610058606061005160408401610417565b9201610417565b9061006360406103f2565b93601785527f536861646f7720563320506f736974696f6e73204e4654000000000000000000602086015261009860406103f2565b600d81526c0534841444f572d56332d4e465609c1b602082015260809490945260a05283516001600160401b038111610302575f54600181811c911680156103e4575b60208210146102e457601f8111610382575b50602094601f8211600114610321579481929394955f92610316575b50508160011b915f199060031b1c1916175f555b82516001600160401b03811161030257600154600181811c911680156102f8575b60208210146102e457601f8111610281575b506020601f821160011461021e57819293945f92610213575b50508160011b915f199060031b1c1916176001555b760100000000000000000000000000000000000000000001600d5560c0526001600160a01b031660e052604051614a39908161042c82396080518181816106e501528181611d5a01528181611f36015281816122760152818161313d015261392f015260a051818181610fdf015281816110fa01528181613300015261408e015260c05181611c77015260e051816111710152f35b015190505f80610169565b601f1982169060015f52805f20915f5b81811061026957509583600195969710610251575b505050811b0160015561017e565b01515f1960f88460031b161c191690555f8080610243565b9192602060018192868b01518155019401920161022e565b60015f527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6601f830160051c810191602084106102da575b601f0160051c01905b8181106102cf5750610150565b5f81556001016102c2565b90915081906102b9565b634e487b7160e01b5f52602260045260245ffd5b90607f169061013e565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610109565b601f198216955f8052805f20915f5b88811061036a57508360019596979810610352575b505050811b015f5561011d565b01515f1960f88460031b161c191690555f8080610345565b91926020600181928685015181550194019201610330565b5f80527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563601f830160051c810191602084106103da575b601f0160051c01905b8181106103cf57506100ed565b5f81556001016103c2565b90915081906103b9565b90607f16906100db565b5f80fd5b6040519190601f01601f191682016001600160401b0381118382101761030257604052565b51906001600160a01b03821682036103ee5756fe60806040526004361015610022575b3615610018575f80fd5b6100206132f6565b005b5f3560e01c806301ffc9a71461022157806306fdde031461021c578063081812fc14610217578063095ea7b3146102125780630c49ccbe1461020d57806312210e8a1461020857806318160ddd14610203578063219f5d17146101fe57806323b872dd146101f95780632f745c59146101f457806342842e0e146101ef57806342966c68146101ea57806349404b7c146101e55780634aa4a4fc146101e05780634bc2a657146101db5780634f6ccce7146101d65780636352211e146101d15780636d70c415146101cc57806370a08231146101c757806395d89b41146101c257806399fbab88146101bd578063a22cb465146101b8578063ac9650d8146101b3578063b88d4fde146101ae578063c87b56dd146101a9578063d3487997146101a4578063d5f394881461019f578063df2ab5bb1461019a578063e985e9c514610195578063f126fb6714610190578063f5f8d3651461018b5763fc6f78650361000e5761237c565b6121d0565b611ea5565b611e34565b611d7e565b611d3b565b611cd9565b611c18565b611b88565b6119dc565b611855565b61169e565b6115e9565b6115ba565b6112b9565b61128a565b61120b565b61111e565b6110db565b610f8e565b610eaa565b610e81565b610dee565b610dd7565b610a90565b610a73565b610a57565b610607565b6104db565b61048d565b61039d565b610254565b7fffffffff0000000000000000000000000000000000000000000000000000000081160361025057565b5f80fd5b34610250576020600319360112610250577fffffffff0000000000000000000000000000000000000000000000000000000060043561029281610226565b167f780e9d630000000000000000000000000000000000000000000000000000000081149081156102cc575b506040519015158152602090f35b7f80ac58cd00000000000000000000000000000000000000000000000000000000811491508115610330575b8115610306575b505f6102be565b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150145f6102ff565b7f5b5e139f00000000000000000000000000000000000000000000000000000000811491506102f8565b5f91031261025057565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b90602061039a928181520190610364565b90565b34610250575f600319360112610250576040515f5f548060011c9060018116908115610483575b60208310821461046f5782855260208501919081156104565750600114610406575b610402846103f681860382611b09565b60405191829182610389565b0390f35b5f8080529250907f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b818410610442575050016103f6826103e6565b80548484015260209093019260010161042f565b60ff191682525090151560051b0190506103f6826103e6565b634e487b7160e01b5f52602260045260245ffd5b91607f16916103c4565b34610250576020600319360112610250576004356104aa8161336c565b505f52600460205260206001600160a01b0360405f205416604051908152f35b6001600160a01b0381160361025057565b34610250576040600319360112610250576004356104f8816104ca565b602435906105058261336c565b331515806105f4575b806105b4575b610588578261002093610560926001600160a01b0380861691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a45f52600460205260405f2090565b906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b7fa9fbf51f000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b5060ff6105ec336105d6846001600160a01b03165f52600560205260405f2090565b906001600160a01b03165f5260205260405f2090565b541615610514565b50336001600160a01b038216141561050e565b60a060031936011261025057600435805f526002602052610637816001600160a01b0360405f20541633906133b8565b6084354211610a2f5761065b6001600160801b0361065361281e565b161515612842565b61066d815f52600c60205260405f2090565b80549161067a8360801c90565b9161069261068661281e565b6001600160801b031690565b926106a96001600160801b03821694851015612842565b610715610709806106e36106de69ffffffffffffffffffff8a165b69ffffffffffffffffffff165f52600b60205260405f2090565b612849565b7f00000000000000000000000000000000000000000000000000000000000000006134c2565b6001600160a01b031690565b60406107316107278860501c60020b90565b9760681c60020b90565b61073961281e565b82517f6847456a000000000000000000000000000000000000000000000000000000008152600481018890526002998a0b60248201529190980b60448201526001600160801b039097166064880152866084815f855af19485156109c0575f965f966109f8575b50604435871080156109ed575b6109c55760a0610818926107de86546107d66107cc8260501c60020b90565b9160681c60020b90565b90893061363a565b9060405180809681947f514ea4bf000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b03915afa9182156109c0575f905f93610989575b506001850182815483039061084091613697565b6001600160801b03166001600160801b038a8116919091011660038701908154610870906001600160801b031690565b016001600160801b031681546fffffffffffffffffffffffffffffffff19166001600160801b03909116178155600287019384548603906108b091613697565b81546001600160801b038082169281168c82160116608091821c01901b6fffffffffffffffffffffffffffffffff191617905555556108ed61281e565b90036001600160801b031681546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916179055818361092961281e565b60405192839261095392846040919493926001600160801b03606083019616825260208201520152565b037f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b491a260408051928352602083019190915290f35b90506109ae91925060a03d60a0116109b9575b6109a68183611b09565b8101906128a6565b50509291505f61082c565b503d61099c565b61289b565b7f0c971c7b000000000000000000000000000000000000000000000000000000005f5260045ffd5b5060643586106107ad565b909550610a1e91965060403d604011610a28575b610a168183611b09565b810190612885565b959095945f6107a0565b503d610a0c565b7fb8e3f2bf000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f6003193601126102505747610a6957005b6100204733613833565b34610250575f600319360112610250576020600854604051908152f35b60c06003193601126102505760a4354211610a2f576001600160a01b03600435610ac2815f52600c60205260405f2090565b90610bae8254610ae16106de6106c48369ffffffffffffffffffff1690565b80516001600160a01b031691610b0f6040610b0660208501516001600160a01b031690565b93015160020b90565b90610b206107cc8260501c60020b90565b610b9260243591610b8860443594610b7160643597610b676084355b9a610b57610b48611b2c565b6001600160a01b03909e168e52565b6001600160a01b031660208d0152565b60020b60408b0152565b3060608a0152608089018b905260020b60a0890152565b60020b60c0870152565b60e08501526101008401526101208301526101408201526138f2565b93919590929460a0610c1b825496610be1610bcc8960501c60020b90565b610bd98a60681c60020b90565b90883061363a565b6040519586809481937f514ea4bf000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b0392165afa80156109c05761040295610d1b935f905f93610d84575b50610c6061068660018601936001600160801b03610c59865486039260801c90565b1690613697565b91610caf610c8a6003870194610c7d86546001600160801b031690565b016001600160801b031690565b84906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b610d0a6002860193610ce2610cd861068687548903610cd26106868c5460801c90565b90613697565b825460801c610c7d565b6001600160801b036fffffffffffffffffffffffffffffffff1983549260801b169116179055565b5555610ce286610c7d835460801c90565b604080516001600160801b0386168152602081018790529081018390527f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f90606090a2604051938493846040919493926001600160801b03606083019616825260208201520152565b9050610da091925060a03d60a0116109b9576109a68183611b09565b50509291505f610c37565b600319606091011261025057600435610dc3816104ca565b90602435610dd0816104ca565b9060443590565b3461025057610020610de836610dab565b916128e5565b3461025057604060031936011261025057600435610e0b816104ca565b6001600160a01b0360243591610e2081612cbb565b831015610e5257165f52600660205260405f20905f5260205261040260405f2054604051918291829190602083019252565b7fa57d13dc000000000000000000000000000000000000000000000000000000005f521660045260245260445ffd5b3461025057610020610e9236610dab565b9060405192610ea2602085611b09565b5f8452612f43565b602060031936011261025057600435805f526002602052610eda816001600160a01b0360405f20541633906133b8565b805f52600c60205260405f20805460801c1590811591610f77575b8115610f5e575b50610f365780610f31610f1a610020935f52600c60205260405f2090565b60035f918281558260018201558260028201550155565b613b56565b7f92a032ca000000000000000000000000000000000000000000000000000000005f5260045ffd5b60030154610f6f915060801c610686565b15155f610efc565b60038101546001600160801b031615159150610ef5565b604060031936011261025057602435600435610fa9826104ca565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016929091602083602481875afa9283156109c0575f936110a6575b5061102690831015612a89565b8161102d57005b823b15610250575f60405180947f2e1a7d4d00000000000000000000000000000000000000000000000000000000825281838161107288600483019190602083019252565b03925af19283156109c0576100209361108c575b50613833565b8061109a5f6110a093611b09565b8061035a565b5f611086565b6110269193506110cd9060203d6020116110d4575b6110c58183611b09565b810190612a7a565b9290611019565b503d6110bb565b34610250575f6003193601126102505760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346102505760206003193601126102505760043561113b816104ca565b6040517fd33219b40000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa80156109c0576001600160a01b03915f916111dc575b50163303610250576001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19600e541617600e555f80f35b6111fe915060203d602011611204575b6111f68183611b09565b810190612ad4565b5f6111a9565b503d6111ec565b346102505760206003193601126102505760043560085481101561125b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30154604051908152602090f35b7fa57d13dc000000000000000000000000000000000000000000000000000000005f525f60045260245260445ffd5b346102505760206003193601126102505760206112a860043561336c565b6001600160a01b0360405191168152f35b61016060031936011261025057610144354211610a2f5761141375ffffffffffffffffffffffffffffffffffffffffffff61130b600d5475ffffffffffffffffffffffffffffffffffffffffffff1690565b61135782600183011675ffffffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffff00000000000000000000000000000000000000000000600d541617600d55565b166113a4611363612afd565b61136b612b09565b611373612b22565b61137b612b2e565b611383612b3a565b610b9260a43591610b8860c43594610b7160e43597610b6761010435610b3c565b6113bb856113b6979597949394612b15565b613d1d565b60a06001600160a01b036113d86113d0612b2e565b6107d6612b3a565b921691604051809681927f514ea4bf000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b0381845afa9384156109c05761040294611513925f925f9261158e575b5061148e9061143d612afd565b90611489611449612b09565b61147f611454612b22565b9161146f611460611b3e565b6001600160a01b039097168752565b6001600160a01b03166020860152565b60020b6040840152565b613f31565b916114d761149a612b2e565b6114cd6114a5612b3a565b916114c36114b1611b4d565b69ffffffffffffffffffff9098168852565b60020b6020870152565b60020b6040850152565b6001600160801b0389166060840152608083015260a08201525f60c08201525f60e082015261150e865f52600c60205260405f2090565b612b46565b837f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f6040518061155f86868b846040919493926001600160801b03606083019616825260208201520152565b0390a260405194859485909493926001600160801b036060936080840197845216602083015260408201520152565b61148e93506115ad91925060a03d60a0116109b9576109a68183611b09565b5050939150929190611430565b346102505760206003193601126102505760206115e16004356115dc816104ca565b612cbb565b604051908152f35b34610250575f600319360112610250576040515f6001548060011c9060018116908115611694575b60208310821461046f578285526020850191908115610456575060011461164257610402846103f681860382611b09565b60015f9081529250907fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b818410611680575050016103f6826103e6565b80548484015260209093019260010161166d565b91607f1691611611565b34610250576020600319360112610250576004356116cc6116c7825f52600c60205260405f2090565b612d05565b9069ffffffffffffffffffff6116ec835169ffffffffffffffffffff1690565b1615611820575061170d6106de6106c4835169ffffffffffffffffffff1690565b9061040261172283516001600160a01b031690565b91611745604061173c60208701516001600160a01b031690565b95015160020b90565b90611754602082015160020b90565b604082015160020b60608301516001600160801b031660808401519160a08501519361179e60e061178f60c08901516001600160801b031690565b9701516001600160801b031690565b966040519a8b9a8b98969492909a99979593916101408a019b6001600160a01b03168a526001600160a01b031660208a015260020b604089015260020b606088015260020b60808701526001600160801b031660a086015260c085015260e08401526001600160801b03166101008301526001600160801b0316906101200152565b7fed15e6cf000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b8015150361025057565b3461025057604060031936011261025057600435611872816104ca565b60243561187e8161184b565b6001600160a01b038216918215611902576118b590335f52600560205260405f20906001600160a01b03165f5260205260405f2090565b60ff1981541660ff831515161790557f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31604051806118fd339482919091602081019215159052565b0390a3005b827f5b08ba18000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9181601f840112156102505782359167ffffffffffffffff8311610250576020808501948460051b01011161025057565b602081016020825282518091526040820191602060408360051b8301019401925f915b83831061199157505050505090565b90919293946020806119cd837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc086600196030187528951610364565b97019301930191939290611982565b60206003193601126102505760043567ffffffffffffffff811161025057611a0890369060040161192e565b90611a1282612de3565b915f5b818110611a2a5760405180610402868261195f565b5f80611a37838587612e2b565b90611a4760405180938193612e90565b0390305af4611a54612e9d565b9015611a7a5790600191611a688287612f2f565b52611a738186612f2f565b5001611a15565b604481511061025057611a9c816024806004611ab49501518301019101612ecc565b60405191829162461bcd60e51b835260048301610389565b0390fd5b634e487b7160e01b5f52604160045260245ffd5b6060810190811067ffffffffffffffff821117611ae857604052565b611ab8565b6040810190811067ffffffffffffffff821117611ae857604052565b90601f601f19910116810190811067ffffffffffffffff821117611ae857604052565b60405190611b3c61016083611b09565b565b60405190611b3c606083611b09565b60405190611b3c61010083611b09565b60405190611b3c604083611b09565b67ffffffffffffffff8111611ae857601f01601f191660200190565b3461025057608060031936011261025057600435611ba5816104ca565b60243590611bb2826104ca565b6044356064359267ffffffffffffffff8411610250573660238501121561025057836004013592611be284611b6c565b93611bf06040519586611b09565b8085523660248288010111610250576020815f92602461002099018389013786010152612f43565b3461025057602060031936011261025057600435611c358161336c565b50604051907fe9dc637500000000000000000000000000000000000000000000000000000000825230600483015260248201525f816044816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa80156109c057610402915f91611cb7575b5060405191829182610389565b611cd391503d805f833e611ccb8183611b09565b810190612ecc565b5f611caa565b346102505760606003193601126102505760443560243560043567ffffffffffffffff831161025057366023840112156102505782600401359167ffffffffffffffff83116102505736602484860101116102505760246100209401916130bb565b34610250575f6003193601126102505760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b606060031936011261025057600435611d96816104ca565b602435604435611da5816104ca565b604051917f70a082310000000000000000000000000000000000000000000000000000000083523060048401526020836024816001600160a01b0388165afa9283156109c0575f93611e0f575b50611dff908310156131ca565b81611e0657005b610020926141e2565b611dff919350611e2d9060203d6020116110d4576110c58183611b09565b9290611df2565b3461025057604060031936011261025057602060ff611e8e600435611e58816104ca565b6001600160a01b0360243591611e6d836104ca565b165f526005845260405f20906001600160a01b03165f5260205260405f2090565b54166040519015158152f35b8060020b0361025057565b608060031936011261025057600435611ebd816104ca565b60243590611eca826104ca565b604435611ed681611e9a565b60643592611ee3846104ca565b611f006001600160a01b0382166001600160a01b03851610612842565b6040517f9f38f7400000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa80156109c0576001600160a01b03915f916121b1575b506040517f28af8d0b0000000000000000000000000000000000000000000000000000000081526001600160a01b03868116600483015284166024820152600285900b604482015291169190602081606481865afa9081156109c0575f91612192575b506001600160a01b038116806120905750506040517f232aa5ac0000000000000000000000000000000000000000000000000000000081526001600160a01b039485166004820152908416602482015260029290920b604483015292909116606482015290602090829060849082905f905af180156109c057610402915f91612071575b505b6040516001600160a01b0390911681529081906020820190565b61208a915060203d602011611204576111f68183611b09565b5f612055565b9350935050506040517f3850c7bd00000000000000000000000000000000000000000000000000000000815260e081600481855afa80156109c0576001600160a01b03915f9161215d575b5016156120ee575b506104029150612057565b803b15610250576040517ff637731d0000000000000000000000000000000000000000000000000000000081526001600160a01b039390931660048401525f908390602490829084905af19182156109c05761040292156120e3578061109a5f61215793611b09565b5f6120e3565b61217f915060e03d60e01161218b575b6121778183611b09565b810190613224565b5050505050505f6120db565b503d61216d565b6121ab915060203d602011611204576111f68183611b09565b5f611fd1565b6121ca915060203d602011611204576111f68183611b09565b5f611f6e565b346102505760406003193601126102505760043560243567ffffffffffffffff81116102505761220490369060040161192e565b825f939293526002602052612228826001600160a01b0360405f20541633906133b8565b6122df60206122586106de6106c4612248875f52600c60205260405f2090565b5469ffffffffffffffffffff1690565b61229a612273610709610709600e546001600160a01b031690565b917f00000000000000000000000000000000000000000000000000000000000000006134c2565b9060405180809581947f2045be90000000000000000000000000000000000000000000000000000000008352600483019190916001600160a01b036020820193169052565b03915afa80156109c0576001600160a01b03915f9161235d575b5016803b156102505761233f935f8094604051968795869485937fa7852afa0000000000000000000000000000000000000000000000000000000085526004850161328f565b03925af180156109c05761234f57005b8061109a5f61002093611b09565b612376915060203d602011611204576111f68183611b09565b5f6122f9565b608060031936011261025057600435805f5260026020526123ac816001600160a01b0360405f20541633906133b8565b6001600160801b036123bc61282a565b16158015906127f5575b6123cf90612842565b6001600160a01b036123df612b09565b166127e857305b6123f8825f52600c60205260405f2090565b9182549161241b6107096106e36106de6106c48769ffffffffffffffffffff1690565b90600385019485549561243e612437886001600160801b031690565b9760801c90565b87819761244e6106868260801c90565b612671575b50505061245e61282a565b6001600160801b0388811691161115612661578687945b61247d612836565b6001600160801b03898116911611156126535787935b546124a18160501c60020b90565b6040517fa02f10690000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018b9052600292830b604483015260689390931c90910b60648201526001600160801b039a8b16608482015299851660a48b0152168860c4815a6040945f91f19687156109c0575f985f9861260c575b50836125bd87946001600160801b03809c996104029b9996612598837f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f019b6125f099031685906001600160801b036fffffffffffffffffffffffffffffffff1983549260801b169116179055565b03166001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b604051938493849160409194936001600160801b0380926001600160a01b03606087019816865216602085015216910152565b0390a26040805191851682529290931660208401528291820190565b8697959294969399508691985060403d60401161264c575b61262e8183611b09565b8101612639916132dd565b969096989194929597509892959861252a565b503d612624565b61265b612836565b93612493565b61266961282a565b968794612475565b9097506126e691985060406001600160a01b038716916126976107cc8260501c60020b90565b82517f6847456a000000000000000000000000000000000000000000000000000000008152600481018b9052600292830b6024820152910b60448201525f606482015292839081906084820190565b03815f855af19182156109c057612727926127ca575b5060a08454916107de6127128460501c60020b90565b61271f8560681c60020b90565b908b3061363a565b03915afa9182156109c05761275d985f915f94612799575b5061276e61278e91610c7d61068660018a019d8e5487039760801c90565b966001600160801b03881690613697565b9a610c7d6106866002890195610cd287548903916001600160801b031690565b9855555f8080612453565b61278e91945061276e92506127bc9060a03d60a0116109b9576109a68183611b09565b50509391509294915061273f565b6127e29060403d604011610a2857610a168183611b09565b506126fc565b6127f0612b09565b6123e6565b506123cf612804610686612836565b151590506123c6565b6001600160801b0381160361025057565b60243561039a8161280d565b60443561039a8161280d565b60643561039a8161280d565b1561025057565b9060405161285681611acc565b6040600182946001600160a01b03815416845201546001600160a01b038116602084015260a01c60020b910152565b9190826040910312610250576020825192015190565b6040513d5f823e3d90fd5b908160a09103126102505780516128bc8161280d565b91602082015191604081015191608060608301516128d98161280d565b92015161039a8161280d565b91906001600160a01b038116928315612a4e576001600160a01b0391835f52600260205261291e60405f206001600160a01b0390541690565b9033612a3e575b848483169687158015612a0e575b61294e846001600160a01b03165f52600360205260405f2090565b6001815401905561296b84610560855f52600260205260405f2090565b82828a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a4156129f8576129a08261494f565b87036129e8575b505050168083036129b757505050565b7f64283d7b000000000000000000000000000000000000000000000000000000005f5260045260245260445260645ffd5b6129f1916149ab565b5f846129a7565b8781146129a057612a0982856148cb565b6129a0565b612a17836142c6565b612a32856001600160a01b03165f52600360205260405f2090565b80545f19019055612933565b612a498533846133b8565b612925565b7f64a0ae92000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b90816020910312610250575190565b15612a9057565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420574554483900000000000000000000000000006044820152fd5b90816020910312610250575161039a816104ca565b634e487b7160e01b5f52603260045260245ffd5b60043561039a816104ca565b60243561039a816104ca565b6101243561039a816104ca565b60443561039a81611e9a565b60643561039a81611e9a565b60843561039a81611e9a565b90610ce260e06003611b3c94612b8569ffffffffffffffffffff865116829069ffffffffffffffffffff1669ffffffffffffffffffff19825416179055565b602085015160020b7fffffffffffffffffffffffffffffffffffffff000000ffffffffffffffffffff82549160501b6cffffff00000000000000000000169116178155612c1b612bd9604087015160020b90565b82907fffffffffffffffffffffffffffffffff000000ffffffffffffffffffffffffff82549160681b6fffffff00000000000000000000000000169116179055565b612c5b612c3260608701516001600160801b031690565b82546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916178255565b6080850151600182015560a085015160028201550192612cad612c8860c08301516001600160801b031690565b85906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b01516001600160801b031690565b6001600160a01b03168015612cd9575f52600360205260405f205490565b7f89c62b64000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b9060405161010081019080821067ffffffffffffffff831117611ae857611b3c9160405260e0612dbd60038396612d93612d83825469ffffffffffffffffffff81168852612d63612d598260501c60020b90565b60020b60208a0152565b612d7d612d738260681c60020b90565b60020b60408a0152565b60801c90565b6001600160801b03166060870152565b60018101546080860152600281015460a086015201546001600160801b03811660c0850152612d7d565b6001600160801b0316910152565b67ffffffffffffffff8111611ae85760051b60200190565b90612ded82612dcb565b612dfa6040519182611b09565b828152601f19612e0a8294612dcb565b01905f5b828110612e1a57505050565b806060602080938501015201612e0e565b9190811015612e8b5760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561025057019081359167ffffffffffffffff8311610250576020018236038113610250579190565b612ae9565b908092918237015f815290565b3d15612ec7573d90612eae82611b6c565b91612ebc6040519384611b09565b82523d5f602084013e565b606090565b6020818303126102505780519067ffffffffffffffff8211610250570181601f8201121561025057805190612f0082611b6c565b92612f0e6040519485611b09565b8284526020838301011161025057815f9260208093018386015e8301015290565b8051821015612e8b5760209160051b010190565b909291612f518185846128e5565b833b612f5e575b50505050565b602091612f9960405194859384937f150b7a020000000000000000000000000000000000000000000000000000000085523360048601614021565b03815f6001600160a01b0387165af15f918161308a575b506130035750612fbe612e9d565b8051919082612ffc577f64a0ae92000000000000000000000000000000000000000000000000000000005f526001600160a01b03821660045260245ffd5b9050602001fd5b7fffffffff000000000000000000000000000000000000000000000000000000007f150b7a020000000000000000000000000000000000000000000000000000000091160361305657505f808080612f58565b7f64a0ae92000000000000000000000000000000000000000000000000000000005f526001600160a01b031660045260245ffd5b6130ad91925060203d6020116130b4575b6130a58183611b09565b81019061400c565b905f612fb0565b503d61309b565b92918091928101039260808412610250576060604051946130db86611aed565b12610250576131616060604051936130f285611acc565b80356130fd816104ca565b8552602081013561310d816104ca565b6020860152604081013561312081611e9a565b6040860152848752013592613134846104ca565b602086019384527f000000000000000000000000000000000000000000000000000000000000000061404f565b50806131a3575b508161317357505050565b61319c61318e6020611b3c955101516001600160a01b031690565b91516001600160a01b031690565b3391614081565b8351516131c491906001600160a01b031683516001600160a01b031661319c565b5f613168565b156131d157565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420746f6b656e00000000000000000000000000006044820152fd5b519061ffff8216820361025057565b908160e091031261025057805161323a816104ca565b91602082015161324981611e9a565b9161325660408201613215565b9161326360608301613215565b9161327060808201613215565b9160a082015160ff811681036102505760c09092015161039a8161184b565b9081526040602082018190528101839052606001915f5b8181106132b35750505090565b9091926020806001926001600160a01b0387356132cf816104ca565b1681520194019291016132a6565b919082604091031261025057602082516128d98161280d565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016330361332857565b606460405162461bcd60e51b815260206004820152600960248201527f4e6f7420574554483900000000000000000000000000000000000000000000006044820152fd5b805f5260026020526001600160a01b0360405f20541690811561338d575090565b7f7e273289000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9190916133d66001600160a01b038416801515908161345057501590565b6133df57505050565b6001600160a01b0316613417577f7e273289000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7f177e802f000000000000000000000000000000000000000000000000000000005f526001600160a01b0390911660045260245260445ffd5b6001600160a01b0384168082149250821561348f575b50811561347257501590565b9050835f5260046020526001600160a01b0360405f205416141590565b9091505f52600560205260ff6134b98660405f20906001600160a01b03165f5260205260405f2090565b5416905f613466565b906001600160a01b038151169160208201926001600160a01b0384511611156135f6576135496135e761039a948461355761351d6040610b0661350f6107099a516001600160a01b031690565b95516001600160a01b031690565b604080516001600160a01b0395861660208201908152959094169084015260020b606083015281608081015b03601f198101835282611b09565b51902060405192839160208301958690917fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006055937fff00000000000000000000000000000000000000000000000000000000000000845260601b16600183015260158201527fc701ee63862761c31d620a4a083c61bdc1e81761e6b9c9267fd19afd22e0821d60358201520190565b5190206001600160a01b031690565b606460405162461bcd60e51b815260206004820152600b60248201527f21546f6b656e4f726465720000000000000000000000000000000000000000006044820152fd5b929091604051927fffffffffffffffffffffffffffffffffffffffff000000000000000000000000602085019560601b168552603484015260e81b605483015260e81b6057820152603a8152613691605a82611b09565b51902090565b5f1982820990828102928380841093039280840393146136f05782700100000000000000000000000000000000111561025057700100000000000000000000000000000000910990828211900360801b910360801c1790565b50505060801c90565b5f196c010000000000000000000000008209918160601b9182808510940393808503941461378e576c01000000000000000000000000829161373c868411612842565b0981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50915061379c821515612842565b0490565b5f1982820990828102928380841093039280840393146137f157826c010000000000000000000000001115610250576c01000000000000000000000000910990828211900360a01b910360601c1790565b50505060601c90565b90915f1983830992808302928380861095039480860395146138245790829161373c868411612842565b5050915061379c821515612842565b5f9190829160405190613847602083611b09565b83825260208201915f36843751925af161385f612e9d565b501561386757565b606460405162461bcd60e51b815260206004820152600360248201527f53544500000000000000000000000000000000000000000000000000000000006044820152fd5b929360c0946001600160801b03936001600160a01b0361039a999894168652602086015260020b604085015260020b60608401521660808201528160a08201520190610364565b80516001600160a01b03169061392661391560208301516001600160a01b031690565b61147f611454604085015160020b90565b613953610709837f00000000000000000000000000000000000000000000000000000000000000006134c2565b6001600160a01b038116936040517f3850c7bd00000000000000000000000000000000000000000000000000000000815260e081600481895afa80156109c0576040915f91613b31575b5060a08501966139df6139b96139b48a5160020b90565b614315565b9260c08801936139cd6139b4865160020b90565b60e08a0151916101008b0151936146c9565b975f87613aa5613549613a6f613a1a613a126080613a0760608801516001600160a01b031690565b960151975160020b90565b985160020b90565b9c613a23611b5d565b90815233602082015289519283916020830191909160606001600160a01b03602060808401956040815184815116875284848201511684880152015160020b6040860152015116910152565b8c88519c8d98899788967f8221b8c1000000000000000000000000000000000000000000000000000000008852600488016138ab565b03925af19283156109c0575f945f94613b0a575b50838561012083015111918215613afb575b5050613ad357565b7f7dd37f70000000000000000000000000000000000000000000000000000000005f5260045ffd5b61014001511190505f80613acb565b909350613b2791945060403d604011610a2857610a168183611b09565b939093925f613ab9565b613b4a915060e03d60e01161218b576121778183611b09565b5050505050505f61399d565b805f5260026020526001600160a01b0360405f205416801590811580613ced575b613b89845f52600260205260405f2090565b73ffffffffffffffffffffffffffffffffffffffff198154169055835f837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a48215613cd95750613bdb8361494f565b6008545f19810190808211613cd457845f5260096020528060405f2054921015612e8b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee281015490821015612e8b577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee382018190555f908152600960205260409020555f838152600960205260408120556008548015613cc0575f19810190600854821015612e8b5760085f8181527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee290920191909155555061338d5750565b634e487b7160e01b5f52603160045260245ffd5b613e5c565b15613bdb57613ce883826148cb565b613bdb565b613cf6846142c6565b613d11826001600160a01b03165f52600360205260405f2090565b80545f19019055613b77565b906001600160a01b038216918215612a4e575f828152600260205260409020546001600160a01b0316916001600160a01b0383169384159485159586613e2c575b613d79856001600160a01b03165f52600360205260405f2090565b60018154019055613d9685610560865f52600260205260405f2090565b8383837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a415613e1657613dcb8361494f565b03613e06575b505050613dda57565b7f73c6ac6e000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b613e0f916149ab565b5f80613dd1565b808214613dcb57613e2783866148cb565b613dcb565b613e35846142c6565b613e50866001600160a01b03165f52600360205260405f2090565b80545f19019055613d5e565b634e487b7160e01b5f52601160045260245ffd5b6001604091613eac6001600160a01b0385511682906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b0191613ee86001600160a01b0360208301511684906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b01517fffffffffffffffffff000000ffffffffffffffffffffffffffffffffffffffff82549160a01b76ffffff0000000000000000000000000000000000000000169116179055565b9190916001600160a01b0381165f52600a60205269ffffffffffffffffffff60405f205416928315613f61575050565b909250600d54908160b01c9169ffffffffffffffffffff8314613cd457826140079175ffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff000000000000000000000000000000000000000000006001611b3c970160b01b16911617600d556001600160a01b038196165f52600a6020526106c48160405f209069ffffffffffffffffffff1669ffffffffffffffffffff19825416179055565b613e70565b90816020910312610250575161039a81610226565b90926001600160a01b036080938161039a979616845216602083015260408201528160608201520190610364565b6001600160a01b0391614061916134c2565b169081330361025057565b90816020910312610250575161039a8161184b565b9290926001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001693846001600160a01b03831614806141d8575b156141af575050823b1561025057604051927fd0e30db00000000000000000000000000000000000000000000000000000000084525f8460048185855af19283156109c05761415f9460209461419b575b505f6040518096819582947fa9059cbb00000000000000000000000000000000000000000000000000000000845260048401602090939291936001600160a01b0360408201951681520152565b03925af180156109c0576141705750565b6141919060203d602011614194575b6141898183611b09565b81019061406c565b50565b503d61417f565b8061109a5f6141a993611b09565b5f614112565b9093509091906001600160a01b03811630036141cf5750611b3c926141e2565b611b3c93614769565b50824710156140c1565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082019081526001600160a01b03909316602482015260448101939093525f9283929083906142398160648101613549565b51925af1614245612e9d565b81614297575b501561425357565b606460405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152fd5b80518015925082156142ac575b50505f61424b565b6142bf925060208091830101910161406c565b5f806142a4565b6142d8905f52600460205260405f2090565b805473ffffffffffffffffffffffffffffffffffffffff19169055565b8015614301575f190490565b634e487b7160e01b5f52601260045260245ffd5b60020b5f8112156146c357805f035b620d89e8811161469b576001600160a01b039160018216156146725770ffffffffffffffffffffffffffffffffff6ffffcb933bd6fad37aa2d162d1a5940015b169160028116614656575b6004811661463a575b6008811661461e575b60108116614602575b602081166145e6575b604081166145ca575b608081166145ae575b6101008116614592575b6102008116614576575b610400811661455a575b610800811661453e575b6110008116614522575b6120008116614506575b61400081166144ea575b61800081166144ce575b6201000081166144b2575b620200008116614497575b62040000811661447c575b6208000016614463575b5f12614455575b61443e6144348260201c90565b9163ffffffff1690565b61444c5760ff5f5b16011690565b60ff6001614446565b61445e906142f5565b614427565b6b048a170391f7dc42444e8fa290910260801c90614420565b6d2216e584f5fa1ea926041bedfe9890920260801c91614416565b916e5d6af8dedb81196699c329225ee6040260801c9161440b565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c91614400565b916f31be135f97d08fd981231505542fcfa60260801c916143f5565b916f70d869a156d2a1b890bb3df62baf32f70260801c916143eb565b916fa9f746462d870fdf8a65dc1f90e061e50260801c916143e1565b916fd097f3bdfd2022b8845ad8f792aa58250260801c916143d7565b916fe7159475a2c29b7443b29c7fa6e889d90260801c916143cd565b916ff3392b0822b70005940c7a398e4b70f30260801c916143c3565b916ff987a7253ac413176f2b074cf7815e540260801c916143b9565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c916143af565b916ffe5dee046a99a2a811c461f1969c30530260801c916143a5565b916fff2ea16466c96a3843ec78b326b528610260801c9161439c565b916fff973b41fa98c081472e6896dfb254c00260801c91614393565b916fffcb9843d60f6159c9db58835c9266440260801c9161438a565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c91614381565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91614378565b916ffff97272373d413259a46990580e213a0260801c9161436f565b70ffffffffffffffffffffffffffffffffff700100000000000000000000000000000000614364565b7f2bc80f3a000000000000000000000000000000000000000000000000000000005f5260045ffd5b80614324565b936001600160a01b0383166001600160a01b03831611614761575b6001600160a01b0385811695908316861161470557505061039a9350614882565b92909391946001600160a01b038216115f1461475557829161472b916147319594614882565b93614852565b6001600160801b0381166001600160801b038316105f14614750575090565b905090565b91505061039a92614852565b9091906146e4565b905f80949381946001600160a01b03604051928160208501967f23b872dd0000000000000000000000000000000000000000000000000000000088521660248501521660448301526064820152606481526147c5608482611b09565b51925af16147d1612e9d565b81614823575b50156147df57565b606460405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215614838575b50505f6147d7565b61484b925060208091830101910161406c565b5f80614830565b916001600160a01b0361039a93614877938281168383161161487c575b0316906136f9565b6149ef565b9061486f565b916148779161039a936001600160a01b0382166001600160a01b038216116148c5575b6001600160a01b03906148bc8284168383166137a0565b920316916137fa565b906148a5565b5f91614921916148da81612cbb565b9180855260076020526001600160a01b0360408620549216855260066020526040852091838103614924575b5084526007602052836040812055905f5260205260405f2090565b55565b838652826020526040862054818752836020528060408820558652600760205260408620555f614906565b600854815f5260096020528060405f205568010000000000000000811015611ae85760018101600855600854811015612e8b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b906149b582612cbb565b5f19810192908311613cd4576001600160a01b03165f52600660205260405f20825f526020528060405f20555f52600760205260405f2055565b906001600160801b0382169182036102505756fea26469706673582212208103820990dac3fda197293f297bbb259483e09536c065869106adf6334ba79164736f6c634300081c00330000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d59000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38000000000000000000000000daa4b06a6710576441367ab90b31689a562c46070000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f
Deployed Bytecode
0x60806040526004361015610022575b3615610018575f80fd5b6100206132f6565b005b5f3560e01c806301ffc9a71461022157806306fdde031461021c578063081812fc14610217578063095ea7b3146102125780630c49ccbe1461020d57806312210e8a1461020857806318160ddd14610203578063219f5d17146101fe57806323b872dd146101f95780632f745c59146101f457806342842e0e146101ef57806342966c68146101ea57806349404b7c146101e55780634aa4a4fc146101e05780634bc2a657146101db5780634f6ccce7146101d65780636352211e146101d15780636d70c415146101cc57806370a08231146101c757806395d89b41146101c257806399fbab88146101bd578063a22cb465146101b8578063ac9650d8146101b3578063b88d4fde146101ae578063c87b56dd146101a9578063d3487997146101a4578063d5f394881461019f578063df2ab5bb1461019a578063e985e9c514610195578063f126fb6714610190578063f5f8d3651461018b5763fc6f78650361000e5761237c565b6121d0565b611ea5565b611e34565b611d7e565b611d3b565b611cd9565b611c18565b611b88565b6119dc565b611855565b61169e565b6115e9565b6115ba565b6112b9565b61128a565b61120b565b61111e565b6110db565b610f8e565b610eaa565b610e81565b610dee565b610dd7565b610a90565b610a73565b610a57565b610607565b6104db565b61048d565b61039d565b610254565b7fffffffff0000000000000000000000000000000000000000000000000000000081160361025057565b5f80fd5b34610250576020600319360112610250577fffffffff0000000000000000000000000000000000000000000000000000000060043561029281610226565b167f780e9d630000000000000000000000000000000000000000000000000000000081149081156102cc575b506040519015158152602090f35b7f80ac58cd00000000000000000000000000000000000000000000000000000000811491508115610330575b8115610306575b505f6102be565b7f01ffc9a7000000000000000000000000000000000000000000000000000000009150145f6102ff565b7f5b5e139f00000000000000000000000000000000000000000000000000000000811491506102f8565b5f91031261025057565b90601f19601f602080948051918291828752018686015e5f8582860101520116010190565b90602061039a928181520190610364565b90565b34610250575f600319360112610250576040515f5f548060011c9060018116908115610483575b60208310821461046f5782855260208501919081156104565750600114610406575b610402846103f681860382611b09565b60405191829182610389565b0390f35b5f8080529250907f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e5635b818410610442575050016103f6826103e6565b80548484015260209093019260010161042f565b60ff191682525090151560051b0190506103f6826103e6565b634e487b7160e01b5f52602260045260245ffd5b91607f16916103c4565b34610250576020600319360112610250576004356104aa8161336c565b505f52600460205260206001600160a01b0360405f205416604051908152f35b6001600160a01b0381160361025057565b34610250576040600319360112610250576004356104f8816104ca565b602435906105058261336c565b331515806105f4575b806105b4575b610588578261002093610560926001600160a01b0380861691167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9255f80a45f52600460205260405f2090565b906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b7fa9fbf51f000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b5060ff6105ec336105d6846001600160a01b03165f52600560205260405f2090565b906001600160a01b03165f5260205260405f2090565b541615610514565b50336001600160a01b038216141561050e565b60a060031936011261025057600435805f526002602052610637816001600160a01b0360405f20541633906133b8565b6084354211610a2f5761065b6001600160801b0361065361281e565b161515612842565b61066d815f52600c60205260405f2090565b80549161067a8360801c90565b9161069261068661281e565b6001600160801b031690565b926106a96001600160801b03821694851015612842565b610715610709806106e36106de69ffffffffffffffffffff8a165b69ffffffffffffffffffff165f52600b60205260405f2090565b612849565b7f0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d596134c2565b6001600160a01b031690565b60406107316107278860501c60020b90565b9760681c60020b90565b61073961281e565b82517f6847456a000000000000000000000000000000000000000000000000000000008152600481018890526002998a0b60248201529190980b60448201526001600160801b039097166064880152866084815f855af19485156109c0575f965f966109f8575b50604435871080156109ed575b6109c55760a0610818926107de86546107d66107cc8260501c60020b90565b9160681c60020b90565b90893061363a565b9060405180809681947f514ea4bf000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b03915afa9182156109c0575f905f93610989575b506001850182815483039061084091613697565b6001600160801b03166001600160801b038a8116919091011660038701908154610870906001600160801b031690565b016001600160801b031681546fffffffffffffffffffffffffffffffff19166001600160801b03909116178155600287019384548603906108b091613697565b81546001600160801b038082169281168c82160116608091821c01901b6fffffffffffffffffffffffffffffffff191617905555556108ed61281e565b90036001600160801b031681546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916179055818361092961281e565b60405192839261095392846040919493926001600160801b03606083019616825260208201520152565b037f26f6a048ee9138f2c0ce266f322cb99228e8d619ae2bff30c67f8dcf9d2377b491a260408051928352602083019190915290f35b90506109ae91925060a03d60a0116109b9575b6109a68183611b09565b8101906128a6565b50509291505f61082c565b503d61099c565b61289b565b7f0c971c7b000000000000000000000000000000000000000000000000000000005f5260045ffd5b5060643586106107ad565b909550610a1e91965060403d604011610a28575b610a168183611b09565b810190612885565b959095945f6107a0565b503d610a0c565b7fb8e3f2bf000000000000000000000000000000000000000000000000000000005f5260045ffd5b5f6003193601126102505747610a6957005b6100204733613833565b34610250575f600319360112610250576020600854604051908152f35b60c06003193601126102505760a4354211610a2f576001600160a01b03600435610ac2815f52600c60205260405f2090565b90610bae8254610ae16106de6106c48369ffffffffffffffffffff1690565b80516001600160a01b031691610b0f6040610b0660208501516001600160a01b031690565b93015160020b90565b90610b206107cc8260501c60020b90565b610b9260243591610b8860443594610b7160643597610b676084355b9a610b57610b48611b2c565b6001600160a01b03909e168e52565b6001600160a01b031660208d0152565b60020b60408b0152565b3060608a0152608089018b905260020b60a0890152565b60020b60c0870152565b60e08501526101008401526101208301526101408201526138f2565b93919590929460a0610c1b825496610be1610bcc8960501c60020b90565b610bd98a60681c60020b90565b90883061363a565b6040519586809481937f514ea4bf000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b0392165afa80156109c05761040295610d1b935f905f93610d84575b50610c6061068660018601936001600160801b03610c59865486039260801c90565b1690613697565b91610caf610c8a6003870194610c7d86546001600160801b031690565b016001600160801b031690565b84906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b610d0a6002860193610ce2610cd861068687548903610cd26106868c5460801c90565b90613697565b825460801c610c7d565b6001600160801b036fffffffffffffffffffffffffffffffff1983549260801b169116179055565b5555610ce286610c7d835460801c90565b604080516001600160801b0386168152602081018790529081018390527f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f90606090a2604051938493846040919493926001600160801b03606083019616825260208201520152565b9050610da091925060a03d60a0116109b9576109a68183611b09565b50509291505f610c37565b600319606091011261025057600435610dc3816104ca565b90602435610dd0816104ca565b9060443590565b3461025057610020610de836610dab565b916128e5565b3461025057604060031936011261025057600435610e0b816104ca565b6001600160a01b0360243591610e2081612cbb565b831015610e5257165f52600660205260405f20905f5260205261040260405f2054604051918291829190602083019252565b7fa57d13dc000000000000000000000000000000000000000000000000000000005f521660045260245260445ffd5b3461025057610020610e9236610dab565b9060405192610ea2602085611b09565b5f8452612f43565b602060031936011261025057600435805f526002602052610eda816001600160a01b0360405f20541633906133b8565b805f52600c60205260405f20805460801c1590811591610f77575b8115610f5e575b50610f365780610f31610f1a610020935f52600c60205260405f2090565b60035f918281558260018201558260028201550155565b613b56565b7f92a032ca000000000000000000000000000000000000000000000000000000005f5260045ffd5b60030154610f6f915060801c610686565b15155f610efc565b60038101546001600160801b031615159150610ef5565b604060031936011261025057602435600435610fa9826104ca565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3816929091602083602481875afa9283156109c0575f936110a6575b5061102690831015612a89565b8161102d57005b823b15610250575f60405180947f2e1a7d4d00000000000000000000000000000000000000000000000000000000825281838161107288600483019190602083019252565b03925af19283156109c0576100209361108c575b50613833565b8061109a5f6110a093611b09565b8061035a565b5f611086565b6110269193506110cd9060203d6020116110d4575b6110c58183611b09565b810190612a7a565b9290611019565b503d6110bb565b34610250575f6003193601126102505760206040516001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38168152f35b346102505760206003193601126102505760043561113b816104ca565b6040517fd33219b40000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f165afa80156109c0576001600160a01b03915f916111dc575b50163303610250576001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19600e541617600e555f80f35b6111fe915060203d602011611204575b6111f68183611b09565b810190612ad4565b5f6111a9565b503d6111ec565b346102505760206003193601126102505760043560085481101561125b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30154604051908152602090f35b7fa57d13dc000000000000000000000000000000000000000000000000000000005f525f60045260245260445ffd5b346102505760206003193601126102505760206112a860043561336c565b6001600160a01b0360405191168152f35b61016060031936011261025057610144354211610a2f5761141375ffffffffffffffffffffffffffffffffffffffffffff61130b600d5475ffffffffffffffffffffffffffffffffffffffffffff1690565b61135782600183011675ffffffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffff00000000000000000000000000000000000000000000600d541617600d55565b166113a4611363612afd565b61136b612b09565b611373612b22565b61137b612b2e565b611383612b3a565b610b9260a43591610b8860c43594610b7160e43597610b6761010435610b3c565b6113bb856113b6979597949394612b15565b613d1d565b60a06001600160a01b036113d86113d0612b2e565b6107d6612b3a565b921691604051809681927f514ea4bf000000000000000000000000000000000000000000000000000000008352600483019190602083019252565b0381845afa9384156109c05761040294611513925f925f9261158e575b5061148e9061143d612afd565b90611489611449612b09565b61147f611454612b22565b9161146f611460611b3e565b6001600160a01b039097168752565b6001600160a01b03166020860152565b60020b6040840152565b613f31565b916114d761149a612b2e565b6114cd6114a5612b3a565b916114c36114b1611b4d565b69ffffffffffffffffffff9098168852565b60020b6020870152565b60020b6040850152565b6001600160801b0389166060840152608083015260a08201525f60c08201525f60e082015261150e865f52600c60205260405f2090565b612b46565b837f3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f6040518061155f86868b846040919493926001600160801b03606083019616825260208201520152565b0390a260405194859485909493926001600160801b036060936080840197845216602083015260408201520152565b61148e93506115ad91925060a03d60a0116109b9576109a68183611b09565b5050939150929190611430565b346102505760206003193601126102505760206115e16004356115dc816104ca565b612cbb565b604051908152f35b34610250575f600319360112610250576040515f6001548060011c9060018116908115611694575b60208310821461046f578285526020850191908115610456575060011461164257610402846103f681860382611b09565b60015f9081529250907fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf65b818410611680575050016103f6826103e6565b80548484015260209093019260010161166d565b91607f1691611611565b34610250576020600319360112610250576004356116cc6116c7825f52600c60205260405f2090565b612d05565b9069ffffffffffffffffffff6116ec835169ffffffffffffffffffff1690565b1615611820575061170d6106de6106c4835169ffffffffffffffffffff1690565b9061040261172283516001600160a01b031690565b91611745604061173c60208701516001600160a01b031690565b95015160020b90565b90611754602082015160020b90565b604082015160020b60608301516001600160801b031660808401519160a08501519361179e60e061178f60c08901516001600160801b031690565b9701516001600160801b031690565b966040519a8b9a8b98969492909a99979593916101408a019b6001600160a01b03168a526001600160a01b031660208a015260020b604089015260020b606088015260020b60808701526001600160801b031660a086015260c085015260e08401526001600160801b03166101008301526001600160801b0316906101200152565b7fed15e6cf000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b8015150361025057565b3461025057604060031936011261025057600435611872816104ca565b60243561187e8161184b565b6001600160a01b038216918215611902576118b590335f52600560205260405f20906001600160a01b03165f5260205260405f2090565b60ff1981541660ff831515161790557f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31604051806118fd339482919091602081019215159052565b0390a3005b827f5b08ba18000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9181601f840112156102505782359167ffffffffffffffff8311610250576020808501948460051b01011161025057565b602081016020825282518091526040820191602060408360051b8301019401925f915b83831061199157505050505090565b90919293946020806119cd837fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc086600196030187528951610364565b97019301930191939290611982565b60206003193601126102505760043567ffffffffffffffff811161025057611a0890369060040161192e565b90611a1282612de3565b915f5b818110611a2a5760405180610402868261195f565b5f80611a37838587612e2b565b90611a4760405180938193612e90565b0390305af4611a54612e9d565b9015611a7a5790600191611a688287612f2f565b52611a738186612f2f565b5001611a15565b604481511061025057611a9c816024806004611ab49501518301019101612ecc565b60405191829162461bcd60e51b835260048301610389565b0390fd5b634e487b7160e01b5f52604160045260245ffd5b6060810190811067ffffffffffffffff821117611ae857604052565b611ab8565b6040810190811067ffffffffffffffff821117611ae857604052565b90601f601f19910116810190811067ffffffffffffffff821117611ae857604052565b60405190611b3c61016083611b09565b565b60405190611b3c606083611b09565b60405190611b3c61010083611b09565b60405190611b3c604083611b09565b67ffffffffffffffff8111611ae857601f01601f191660200190565b3461025057608060031936011261025057600435611ba5816104ca565b60243590611bb2826104ca565b6044356064359267ffffffffffffffff8411610250573660238501121561025057836004013592611be284611b6c565b93611bf06040519586611b09565b8085523660248288010111610250576020815f92602461002099018389013786010152612f43565b3461025057602060031936011261025057600435611c358161336c565b50604051907fe9dc637500000000000000000000000000000000000000000000000000000000825230600483015260248201525f816044816001600160a01b037f000000000000000000000000daa4b06a6710576441367ab90b31689a562c4607165afa80156109c057610402915f91611cb7575b5060405191829182610389565b611cd391503d805f833e611ccb8183611b09565b810190612ecc565b5f611caa565b346102505760606003193601126102505760443560243560043567ffffffffffffffff831161025057366023840112156102505782600401359167ffffffffffffffff83116102505736602484860101116102505760246100209401916130bb565b34610250575f6003193601126102505760206040516001600160a01b037f0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d59168152f35b606060031936011261025057600435611d96816104ca565b602435604435611da5816104ca565b604051917f70a082310000000000000000000000000000000000000000000000000000000083523060048401526020836024816001600160a01b0388165afa9283156109c0575f93611e0f575b50611dff908310156131ca565b81611e0657005b610020926141e2565b611dff919350611e2d9060203d6020116110d4576110c58183611b09565b9290611df2565b3461025057604060031936011261025057602060ff611e8e600435611e58816104ca565b6001600160a01b0360243591611e6d836104ca565b165f526005845260405f20906001600160a01b03165f5260205260405f2090565b54166040519015158152f35b8060020b0361025057565b608060031936011261025057600435611ebd816104ca565b60243590611eca826104ca565b604435611ed681611e9a565b60643592611ee3846104ca565b611f006001600160a01b0382166001600160a01b03851610612842565b6040517f9f38f7400000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d59165afa80156109c0576001600160a01b03915f916121b1575b506040517f28af8d0b0000000000000000000000000000000000000000000000000000000081526001600160a01b03868116600483015284166024820152600285900b604482015291169190602081606481865afa9081156109c0575f91612192575b506001600160a01b038116806120905750506040517f232aa5ac0000000000000000000000000000000000000000000000000000000081526001600160a01b039485166004820152908416602482015260029290920b604483015292909116606482015290602090829060849082905f905af180156109c057610402915f91612071575b505b6040516001600160a01b0390911681529081906020820190565b61208a915060203d602011611204576111f68183611b09565b5f612055565b9350935050506040517f3850c7bd00000000000000000000000000000000000000000000000000000000815260e081600481855afa80156109c0576001600160a01b03915f9161215d575b5016156120ee575b506104029150612057565b803b15610250576040517ff637731d0000000000000000000000000000000000000000000000000000000081526001600160a01b039390931660048401525f908390602490829084905af19182156109c05761040292156120e3578061109a5f61215793611b09565b5f6120e3565b61217f915060e03d60e01161218b575b6121778183611b09565b810190613224565b5050505050505f6120db565b503d61216d565b6121ab915060203d602011611204576111f68183611b09565b5f611fd1565b6121ca915060203d602011611204576111f68183611b09565b5f611f6e565b346102505760406003193601126102505760043560243567ffffffffffffffff81116102505761220490369060040161192e565b825f939293526002602052612228826001600160a01b0360405f20541633906133b8565b6122df60206122586106de6106c4612248875f52600c60205260405f2090565b5469ffffffffffffffffffff1690565b61229a612273610709610709600e546001600160a01b031690565b917f0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d596134c2565b9060405180809581947f2045be90000000000000000000000000000000000000000000000000000000008352600483019190916001600160a01b036020820193169052565b03915afa80156109c0576001600160a01b03915f9161235d575b5016803b156102505761233f935f8094604051968795869485937fa7852afa0000000000000000000000000000000000000000000000000000000085526004850161328f565b03925af180156109c05761234f57005b8061109a5f61002093611b09565b612376915060203d602011611204576111f68183611b09565b5f6122f9565b608060031936011261025057600435805f5260026020526123ac816001600160a01b0360405f20541633906133b8565b6001600160801b036123bc61282a565b16158015906127f5575b6123cf90612842565b6001600160a01b036123df612b09565b166127e857305b6123f8825f52600c60205260405f2090565b9182549161241b6107096106e36106de6106c48769ffffffffffffffffffff1690565b90600385019485549561243e612437886001600160801b031690565b9760801c90565b87819761244e6106868260801c90565b612671575b50505061245e61282a565b6001600160801b0388811691161115612661578687945b61247d612836565b6001600160801b03898116911611156126535787935b546124a18160501c60020b90565b6040517fa02f10690000000000000000000000000000000000000000000000000000000081526001600160a01b038881166004830152602482018b9052600292830b604483015260689390931c90910b60648201526001600160801b039a8b16608482015299851660a48b0152168860c4815a6040945f91f19687156109c0575f985f9861260c575b50836125bd87946001600160801b03809c996104029b9996612598837f40d0efd1a53d60ecbf40971b9daf7dc90178c3aadc7aab1765632738fa8b8f019b6125f099031685906001600160801b036fffffffffffffffffffffffffffffffff1983549260801b169116179055565b03166001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b604051938493849160409194936001600160801b0380926001600160a01b03606087019816865216602085015216910152565b0390a26040805191851682529290931660208401528291820190565b8697959294969399508691985060403d60401161264c575b61262e8183611b09565b8101612639916132dd565b969096989194929597509892959861252a565b503d612624565b61265b612836565b93612493565b61266961282a565b968794612475565b9097506126e691985060406001600160a01b038716916126976107cc8260501c60020b90565b82517f6847456a000000000000000000000000000000000000000000000000000000008152600481018b9052600292830b6024820152910b60448201525f606482015292839081906084820190565b03815f855af19182156109c057612727926127ca575b5060a08454916107de6127128460501c60020b90565b61271f8560681c60020b90565b908b3061363a565b03915afa9182156109c05761275d985f915f94612799575b5061276e61278e91610c7d61068660018a019d8e5487039760801c90565b966001600160801b03881690613697565b9a610c7d6106866002890195610cd287548903916001600160801b031690565b9855555f8080612453565b61278e91945061276e92506127bc9060a03d60a0116109b9576109a68183611b09565b50509391509294915061273f565b6127e29060403d604011610a2857610a168183611b09565b506126fc565b6127f0612b09565b6123e6565b506123cf612804610686612836565b151590506123c6565b6001600160801b0381160361025057565b60243561039a8161280d565b60443561039a8161280d565b60643561039a8161280d565b1561025057565b9060405161285681611acc565b6040600182946001600160a01b03815416845201546001600160a01b038116602084015260a01c60020b910152565b9190826040910312610250576020825192015190565b6040513d5f823e3d90fd5b908160a09103126102505780516128bc8161280d565b91602082015191604081015191608060608301516128d98161280d565b92015161039a8161280d565b91906001600160a01b038116928315612a4e576001600160a01b0391835f52600260205261291e60405f206001600160a01b0390541690565b9033612a3e575b848483169687158015612a0e575b61294e846001600160a01b03165f52600360205260405f2090565b6001815401905561296b84610560855f52600260205260405f2090565b82828a7fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a4156129f8576129a08261494f565b87036129e8575b505050168083036129b757505050565b7f64283d7b000000000000000000000000000000000000000000000000000000005f5260045260245260445260645ffd5b6129f1916149ab565b5f846129a7565b8781146129a057612a0982856148cb565b6129a0565b612a17836142c6565b612a32856001600160a01b03165f52600360205260405f2090565b80545f19019055612933565b612a498533846133b8565b612925565b7f64a0ae92000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b90816020910312610250575190565b15612a9057565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420574554483900000000000000000000000000006044820152fd5b90816020910312610250575161039a816104ca565b634e487b7160e01b5f52603260045260245ffd5b60043561039a816104ca565b60243561039a816104ca565b6101243561039a816104ca565b60443561039a81611e9a565b60643561039a81611e9a565b60843561039a81611e9a565b90610ce260e06003611b3c94612b8569ffffffffffffffffffff865116829069ffffffffffffffffffff1669ffffffffffffffffffff19825416179055565b602085015160020b7fffffffffffffffffffffffffffffffffffffff000000ffffffffffffffffffff82549160501b6cffffff00000000000000000000169116178155612c1b612bd9604087015160020b90565b82907fffffffffffffffffffffffffffffffff000000ffffffffffffffffffffffffff82549160681b6fffffff00000000000000000000000000169116179055565b612c5b612c3260608701516001600160801b031690565b82546001600160801b031660809190911b6fffffffffffffffffffffffffffffffff1916178255565b6080850151600182015560a085015160028201550192612cad612c8860c08301516001600160801b031690565b85906001600160801b03166fffffffffffffffffffffffffffffffff19825416179055565b01516001600160801b031690565b6001600160a01b03168015612cd9575f52600360205260405f205490565b7f89c62b64000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b9060405161010081019080821067ffffffffffffffff831117611ae857611b3c9160405260e0612dbd60038396612d93612d83825469ffffffffffffffffffff81168852612d63612d598260501c60020b90565b60020b60208a0152565b612d7d612d738260681c60020b90565b60020b60408a0152565b60801c90565b6001600160801b03166060870152565b60018101546080860152600281015460a086015201546001600160801b03811660c0850152612d7d565b6001600160801b0316910152565b67ffffffffffffffff8111611ae85760051b60200190565b90612ded82612dcb565b612dfa6040519182611b09565b828152601f19612e0a8294612dcb565b01905f5b828110612e1a57505050565b806060602080938501015201612e0e565b9190811015612e8b5760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561025057019081359167ffffffffffffffff8311610250576020018236038113610250579190565b612ae9565b908092918237015f815290565b3d15612ec7573d90612eae82611b6c565b91612ebc6040519384611b09565b82523d5f602084013e565b606090565b6020818303126102505780519067ffffffffffffffff8211610250570181601f8201121561025057805190612f0082611b6c565b92612f0e6040519485611b09565b8284526020838301011161025057815f9260208093018386015e8301015290565b8051821015612e8b5760209160051b010190565b909291612f518185846128e5565b833b612f5e575b50505050565b602091612f9960405194859384937f150b7a020000000000000000000000000000000000000000000000000000000085523360048601614021565b03815f6001600160a01b0387165af15f918161308a575b506130035750612fbe612e9d565b8051919082612ffc577f64a0ae92000000000000000000000000000000000000000000000000000000005f526001600160a01b03821660045260245ffd5b9050602001fd5b7fffffffff000000000000000000000000000000000000000000000000000000007f150b7a020000000000000000000000000000000000000000000000000000000091160361305657505f808080612f58565b7f64a0ae92000000000000000000000000000000000000000000000000000000005f526001600160a01b031660045260245ffd5b6130ad91925060203d6020116130b4575b6130a58183611b09565b81019061400c565b905f612fb0565b503d61309b565b92918091928101039260808412610250576060604051946130db86611aed565b12610250576131616060604051936130f285611acc565b80356130fd816104ca565b8552602081013561310d816104ca565b6020860152604081013561312081611e9a565b6040860152848752013592613134846104ca565b602086019384527f0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d5961404f565b50806131a3575b508161317357505050565b61319c61318e6020611b3c955101516001600160a01b031690565b91516001600160a01b031690565b3391614081565b8351516131c491906001600160a01b031683516001600160a01b031661319c565b5f613168565b156131d157565b606460405162461bcd60e51b815260206004820152601260248201527f496e73756666696369656e7420746f6b656e00000000000000000000000000006044820152fd5b519061ffff8216820361025057565b908160e091031261025057805161323a816104ca565b91602082015161324981611e9a565b9161325660408201613215565b9161326360608301613215565b9161327060808201613215565b9160a082015160ff811681036102505760c09092015161039a8161184b565b9081526040602082018190528101839052606001915f5b8181106132b35750505090565b9091926020806001926001600160a01b0387356132cf816104ca565b1681520194019291016132a6565b919082604091031261025057602082516128d98161280d565b6001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad3816330361332857565b606460405162461bcd60e51b815260206004820152600960248201527f4e6f7420574554483900000000000000000000000000000000000000000000006044820152fd5b805f5260026020526001600160a01b0360405f20541690811561338d575090565b7f7e273289000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9190916133d66001600160a01b038416801515908161345057501590565b6133df57505050565b6001600160a01b0316613417577f7e273289000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b7f177e802f000000000000000000000000000000000000000000000000000000005f526001600160a01b0390911660045260245260445ffd5b6001600160a01b0384168082149250821561348f575b50811561347257501590565b9050835f5260046020526001600160a01b0360405f205416141590565b9091505f52600560205260ff6134b98660405f20906001600160a01b03165f5260205260405f2090565b5416905f613466565b906001600160a01b038151169160208201926001600160a01b0384511611156135f6576135496135e761039a948461355761351d6040610b0661350f6107099a516001600160a01b031690565b95516001600160a01b031690565b604080516001600160a01b0395861660208201908152959094169084015260020b606083015281608081015b03601f198101835282611b09565b51902060405192839160208301958690917fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006055937fff00000000000000000000000000000000000000000000000000000000000000845260601b16600183015260158201527fc701ee63862761c31d620a4a083c61bdc1e81761e6b9c9267fd19afd22e0821d60358201520190565b5190206001600160a01b031690565b606460405162461bcd60e51b815260206004820152600b60248201527f21546f6b656e4f726465720000000000000000000000000000000000000000006044820152fd5b929091604051927fffffffffffffffffffffffffffffffffffffffff000000000000000000000000602085019560601b168552603484015260e81b605483015260e81b6057820152603a8152613691605a82611b09565b51902090565b5f1982820990828102928380841093039280840393146136f05782700100000000000000000000000000000000111561025057700100000000000000000000000000000000910990828211900360801b910360801c1790565b50505060801c90565b5f196c010000000000000000000000008209918160601b9182808510940393808503941461378e576c01000000000000000000000000829161373c868411612842565b0981805f03168092046002816003021880820260020302808202600203028082026002030280820260020302808202600203028091026002030293600183805f03040190848311900302920304170290565b50915061379c821515612842565b0490565b5f1982820990828102928380841093039280840393146137f157826c010000000000000000000000001115610250576c01000000000000000000000000910990828211900360a01b910360601c1790565b50505060601c90565b90915f1983830992808302928380861095039480860395146138245790829161373c868411612842565b5050915061379c821515612842565b5f9190829160405190613847602083611b09565b83825260208201915f36843751925af161385f612e9d565b501561386757565b606460405162461bcd60e51b815260206004820152600360248201527f53544500000000000000000000000000000000000000000000000000000000006044820152fd5b929360c0946001600160801b03936001600160a01b0361039a999894168652602086015260020b604085015260020b60608401521660808201528160a08201520190610364565b80516001600160a01b03169061392661391560208301516001600160a01b031690565b61147f611454604085015160020b90565b613953610709837f0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d596134c2565b6001600160a01b038116936040517f3850c7bd00000000000000000000000000000000000000000000000000000000815260e081600481895afa80156109c0576040915f91613b31575b5060a08501966139df6139b96139b48a5160020b90565b614315565b9260c08801936139cd6139b4865160020b90565b60e08a0151916101008b0151936146c9565b975f87613aa5613549613a6f613a1a613a126080613a0760608801516001600160a01b031690565b960151975160020b90565b985160020b90565b9c613a23611b5d565b90815233602082015289519283916020830191909160606001600160a01b03602060808401956040815184815116875284848201511684880152015160020b6040860152015116910152565b8c88519c8d98899788967f8221b8c1000000000000000000000000000000000000000000000000000000008852600488016138ab565b03925af19283156109c0575f945f94613b0a575b50838561012083015111918215613afb575b5050613ad357565b7f7dd37f70000000000000000000000000000000000000000000000000000000005f5260045ffd5b61014001511190505f80613acb565b909350613b2791945060403d604011610a2857610a168183611b09565b939093925f613ab9565b613b4a915060e03d60e01161218b576121778183611b09565b5050505050505f61399d565b805f5260026020526001600160a01b0360405f205416801590811580613ced575b613b89845f52600260205260405f2090565b73ffffffffffffffffffffffffffffffffffffffff198154169055835f837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8280a48215613cd95750613bdb8361494f565b6008545f19810190808211613cd457845f5260096020528060405f2054921015612e8b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee281015490821015612e8b577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee382018190555f908152600960205260409020555f838152600960205260408120556008548015613cc0575f19810190600854821015612e8b5760085f8181527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee290920191909155555061338d5750565b634e487b7160e01b5f52603160045260245ffd5b613e5c565b15613bdb57613ce883826148cb565b613bdb565b613cf6846142c6565b613d11826001600160a01b03165f52600360205260405f2090565b80545f19019055613b77565b906001600160a01b038216918215612a4e575f828152600260205260409020546001600160a01b0316916001600160a01b0383169384159485159586613e2c575b613d79856001600160a01b03165f52600360205260405f2090565b60018154019055613d9685610560865f52600260205260405f2090565b8383837fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5f80a415613e1657613dcb8361494f565b03613e06575b505050613dda57565b7f73c6ac6e000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b613e0f916149ab565b5f80613dd1565b808214613dcb57613e2783866148cb565b613dcb565b613e35846142c6565b613e50866001600160a01b03165f52600360205260405f2090565b80545f19019055613d5e565b634e487b7160e01b5f52601160045260245ffd5b6001604091613eac6001600160a01b0385511682906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b0191613ee86001600160a01b0360208301511684906001600160a01b031673ffffffffffffffffffffffffffffffffffffffff19825416179055565b01517fffffffffffffffffff000000ffffffffffffffffffffffffffffffffffffffff82549160a01b76ffffff0000000000000000000000000000000000000000169116179055565b9190916001600160a01b0381165f52600a60205269ffffffffffffffffffff60405f205416928315613f61575050565b909250600d54908160b01c9169ffffffffffffffffffff8314613cd457826140079175ffffffffffffffffffffffffffffffffffffffffffff7fffffffffffffffffffff000000000000000000000000000000000000000000006001611b3c970160b01b16911617600d556001600160a01b038196165f52600a6020526106c48160405f209069ffffffffffffffffffff1669ffffffffffffffffffff19825416179055565b613e70565b90816020910312610250575161039a81610226565b90926001600160a01b036080938161039a979616845216602083015260408201528160608201520190610364565b6001600160a01b0391614061916134c2565b169081330361025057565b90816020910312610250575161039a8161184b565b9290926001600160a01b037f000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad381693846001600160a01b03831614806141d8575b156141af575050823b1561025057604051927fd0e30db00000000000000000000000000000000000000000000000000000000084525f8460048185855af19283156109c05761415f9460209461419b575b505f6040518096819582947fa9059cbb00000000000000000000000000000000000000000000000000000000845260048401602090939291936001600160a01b0360408201951681520152565b03925af180156109c0576141705750565b6141919060203d602011614194575b6141898183611b09565b81019061406c565b50565b503d61417f565b8061109a5f6141a993611b09565b5f614112565b9093509091906001600160a01b03811630036141cf5750611b3c926141e2565b611b3c93614769565b50824710156140c1565b6040517fa9059cbb00000000000000000000000000000000000000000000000000000000602082019081526001600160a01b03909316602482015260448101939093525f9283929083906142398160648101613549565b51925af1614245612e9d565b81614297575b501561425357565b606460405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152fd5b80518015925082156142ac575b50505f61424b565b6142bf925060208091830101910161406c565b5f806142a4565b6142d8905f52600460205260405f2090565b805473ffffffffffffffffffffffffffffffffffffffff19169055565b8015614301575f190490565b634e487b7160e01b5f52601260045260245ffd5b60020b5f8112156146c357805f035b620d89e8811161469b576001600160a01b039160018216156146725770ffffffffffffffffffffffffffffffffff6ffffcb933bd6fad37aa2d162d1a5940015b169160028116614656575b6004811661463a575b6008811661461e575b60108116614602575b602081166145e6575b604081166145ca575b608081166145ae575b6101008116614592575b6102008116614576575b610400811661455a575b610800811661453e575b6110008116614522575b6120008116614506575b61400081166144ea575b61800081166144ce575b6201000081166144b2575b620200008116614497575b62040000811661447c575b6208000016614463575b5f12614455575b61443e6144348260201c90565b9163ffffffff1690565b61444c5760ff5f5b16011690565b60ff6001614446565b61445e906142f5565b614427565b6b048a170391f7dc42444e8fa290910260801c90614420565b6d2216e584f5fa1ea926041bedfe9890920260801c91614416565b916e5d6af8dedb81196699c329225ee6040260801c9161440b565b916f09aa508b5b7a84e1c677de54f3e99bc90260801c91614400565b916f31be135f97d08fd981231505542fcfa60260801c916143f5565b916f70d869a156d2a1b890bb3df62baf32f70260801c916143eb565b916fa9f746462d870fdf8a65dc1f90e061e50260801c916143e1565b916fd097f3bdfd2022b8845ad8f792aa58250260801c916143d7565b916fe7159475a2c29b7443b29c7fa6e889d90260801c916143cd565b916ff3392b0822b70005940c7a398e4b70f30260801c916143c3565b916ff987a7253ac413176f2b074cf7815e540260801c916143b9565b916ffcbe86c7900a88aedcffc83b479aa3a40260801c916143af565b916ffe5dee046a99a2a811c461f1969c30530260801c916143a5565b916fff2ea16466c96a3843ec78b326b528610260801c9161439c565b916fff973b41fa98c081472e6896dfb254c00260801c91614393565b916fffcb9843d60f6159c9db58835c9266440260801c9161438a565b916fffe5caca7e10e4e61c3624eaa0941cd00260801c91614381565b916ffff2e50f5f656932ef12357cf3c7fdcc0260801c91614378565b916ffff97272373d413259a46990580e213a0260801c9161436f565b70ffffffffffffffffffffffffffffffffff700100000000000000000000000000000000614364565b7f2bc80f3a000000000000000000000000000000000000000000000000000000005f5260045ffd5b80614324565b936001600160a01b0383166001600160a01b03831611614761575b6001600160a01b0385811695908316861161470557505061039a9350614882565b92909391946001600160a01b038216115f1461475557829161472b916147319594614882565b93614852565b6001600160801b0381166001600160801b038316105f14614750575090565b905090565b91505061039a92614852565b9091906146e4565b905f80949381946001600160a01b03604051928160208501967f23b872dd0000000000000000000000000000000000000000000000000000000088521660248501521660448301526064820152606481526147c5608482611b09565b51925af16147d1612e9d565b81614823575b50156147df57565b606460405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152fd5b8051801592508215614838575b50505f6147d7565b61484b925060208091830101910161406c565b5f80614830565b916001600160a01b0361039a93614877938281168383161161487c575b0316906136f9565b6149ef565b9061486f565b916148779161039a936001600160a01b0382166001600160a01b038216116148c5575b6001600160a01b03906148bc8284168383166137a0565b920316916137fa565b906148a5565b5f91614921916148da81612cbb565b9180855260076020526001600160a01b0360408620549216855260066020526040852091838103614924575b5084526007602052836040812055905f5260205260405f2090565b55565b838652826020526040862054818752836020528060408820558652600760205260408620555f614906565b600854815f5260096020528060405f205568010000000000000000811015611ae85760018101600855600854811015612e8b5760085f527ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee30155565b906149b582612cbb565b5f19810192908311613cd4576001600160a01b03165f52600660205260405f20825f526020528060405f20555f52600760205260405f2055565b906001600160801b0382169182036102505756fea26469706673582212208103820990dac3fda197293f297bbb259483e09536c065869106adf6334ba79164736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d59000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38000000000000000000000000daa4b06a6710576441367ab90b31689a562c46070000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f
-----Decoded View---------------
Arg [0] : _deployer (address): 0x8BBDc15759a8eCf99A92E004E0C64ea9A5142d59
Arg [1] : _WETH9 (address): 0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38
Arg [2] : _tokenDescriptor_ (address): 0xdaA4B06A6710576441367aB90b31689a562C4607
Arg [3] : _accessHub (address): 0x5e7A9eea6988063A4dBb9CcDDB3E04C923E8E37f
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 0000000000000000000000008bbdc15759a8ecf99a92e004e0c64ea9a5142d59
Arg [1] : 000000000000000000000000039e2fb66102314ce7b64ce5ce3e5183bc94ad38
Arg [2] : 000000000000000000000000daa4b06a6710576441367ab90b31689a562c4607
Arg [3] : 0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.