Source Code
Overview
ETH Balance
0 ETH
Token Holdings
More Info
ContractCreator
Multichain Info
N/A
Latest 25 from a total of 29 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Create And Mint ... | 7036664 | 26 days ago | IN | 0.001 ETH | 0.03354072 | ||||
Create And Mint ... | 6938951 | 41 days ago | IN | 0.001 ETH | 0.0083152 | ||||
Create And Mint ... | 6874569 | 51 days ago | IN | 0.001 ETH | 0.12110452 | ||||
Create And Mint ... | 6672640 | 84 days ago | IN | 0.001 ETH | 0.10611634 | ||||
Create And Mint ... | 6557398 | 103 days ago | IN | 0.001 ETH | 0.00068117 | ||||
Create And Mint ... | 6538510 | 106 days ago | IN | 0.001 ETH | 0.00149997 | ||||
Create And Mint ... | 6531374 | 107 days ago | IN | 0.001 ETH | 0.00145936 | ||||
Create And Mint ... | 6525659 | 108 days ago | IN | 0.001 ETH | 0.00844704 | ||||
Create And Mint ... | 6512300 | 110 days ago | IN | 0.001 ETH | 0.00109853 | ||||
Create And Mint ... | 6512161 | 110 days ago | IN | 0.001 ETH | 0.02241723 | ||||
Create And Mint ... | 6506600 | 111 days ago | IN | 0.001 ETH | 0.00239165 | ||||
Create And Mint ... | 6506535 | 111 days ago | IN | 0.001 ETH | 0.0008025 | ||||
Create And Mint ... | 6506524 | 111 days ago | IN | 0.001 ETH | 0.00080121 | ||||
Create And Mint ... | 6506505 | 111 days ago | IN | 0.001 ETH | 0.00903594 | ||||
Create And Mint ... | 6506378 | 111 days ago | IN | 0.001 ETH | 0.03901921 | ||||
Create And Mint ... | 6506369 | 111 days ago | IN | 0.001 ETH | 0.00521388 | ||||
Create And Mint ... | 6498928 | 112 days ago | IN | 0.001 ETH | 0.00921301 | ||||
Create And Mint ... | 6494585 | 113 days ago | IN | 0.001 ETH | 0.00159915 | ||||
Create And Mint ... | 6494551 | 113 days ago | IN | 0.001 ETH | 0.00270936 | ||||
Create And Mint ... | 6494499 | 113 days ago | IN | 0.001 ETH | 0.03236211 | ||||
Create And Mint ... | 6494456 | 113 days ago | IN | 0.001 ETH | 0.02781061 | ||||
Create And Mint ... | 6487421 | 114 days ago | IN | 0.001 ETH | 0.01349485 | ||||
Create And Mint ... | 6474781 | 116 days ago | IN | 0.001 ETH | 0.01890331 | ||||
Create And Mint ... | 6464369 | 118 days ago | IN | 0.001 ETH | 0.00205893 | ||||
Create And Mint ... | 6464341 | 118 days ago | IN | 0.001 ETH | 0.00201234 |
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
7036664 | 26 days ago | 0.001 ETH | ||||
6938951 | 41 days ago | 0.001 ETH | ||||
6874569 | 51 days ago | 0.001 ETH | ||||
6672640 | 84 days ago | 0.001 ETH | ||||
6557398 | 103 days ago | 0.001 ETH | ||||
6538510 | 106 days ago | 0.001 ETH | ||||
6531374 | 107 days ago | 0.001 ETH | ||||
6525659 | 108 days ago | 0.001 ETH | ||||
6512300 | 110 days ago | 0.001 ETH | ||||
6512161 | 110 days ago | 0.001 ETH | ||||
6506600 | 111 days ago | 0.001 ETH | ||||
6506535 | 111 days ago | 0.001 ETH | ||||
6506524 | 111 days ago | 0.001 ETH | ||||
6506505 | 111 days ago | 0.001 ETH | ||||
6506378 | 111 days ago | 0.001 ETH | ||||
6506369 | 111 days ago | 0.001 ETH | ||||
6498928 | 112 days ago | 0.001 ETH | ||||
6494585 | 113 days ago | 0.001 ETH | ||||
6494551 | 113 days ago | 0.001 ETH | ||||
6494499 | 113 days ago | 0.001 ETH | ||||
6494456 | 113 days ago | 0.001 ETH | ||||
6487421 | 114 days ago | 0.001 ETH | ||||
6474781 | 116 days ago | 0.001 ETH | ||||
6464369 | 118 days ago | 0.001 ETH | ||||
6464341 | 118 days ago | 0.001 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
ERC20PoolFactory
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 1000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.24; pragma abicoder v2; /* &&&&&& &&&&& &% &&&&&&&&&&&&&&& && &&&&&&&&&&% &&&&&&& &&&&& #&&&&&&&&&&&&& &&&&& &&&&&&& && &&&& &% &&&&&&& &&. &&&&&&&&&& & %&&&&&&& &&&& &&&& *&&&&&&&&& &&&&&&&&& &&&& .&&& &&&&&&&& &&&&&&&& &&& .&&&&&&& &&&&&&& &&&% &&&&&& &&&&&& &&&&& /&&&&. &&&& %&&& #&&&, &&&&( &&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&& &&&% &&&&&&&&&&&&&&&&&&&&&&&&& &&& &&& &&&* &&&&&&&&&&&&&&&&&&&&& &&* &&& .&&&&&& &&&&&&&&&&&&&&&&&&&& &&&&& && &&& #&&&&&& &&&&&&&&&&&&&&&&&&&&& &&&&& && &&& &&&& &&&&&&&&&&&&&&&&&&&&&& #&& &&& &&& &&&&&&&&&&&&&&&&&&&&&&&&, *&&& (&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&% &&&&&&&&&&&&&&&&& &&&&& &&&&&&&&&&&&&&&&&& %&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&# &&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&& */ /* * Pool Factory contract * This contract is used to create a liquidity pool on Uniswap V3 */ /// @title PoolFactory /// @author Smithii import {Payable} from "./utils/Payable.sol"; import {IERC721Receiver} from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; import {TransferHelper} from "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol"; import {IUniswapV3Factory} from '@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol'; import {IUniswapV3Pool} from '@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol'; import { Math } from "@openzeppelin/contracts/utils/math/Math.sol"; import { INonfungiblePositionManager } from './interfaces/INonfungiblePositionManager.sol'; contract ERC20PoolFactory is IERC721Receiver, Payable { /// @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; uint256 private constant padding = 100; // Constants uint256 private constant Q96 = 2 ** 96; struct Deposit { address owner; uint128 liquidity; address token0; address token1; } INonfungiblePositionManager public immutable nonfungiblePositionManager; IUniswapV3Factory public immutable v3Factory; /// events event PositionMinted( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ); event FeesCollected(uint256 amount0, uint256 amount1); event LiquidityIncreased( uint256 liquidity, uint256 amount0, uint256 amount1 ); event LiquidityDecreased(uint256 amount0, uint256 amount1); /// mappings mapping(uint256 => Deposit) public deposits; constructor( address _nonfungiblePositionManager, address _v3Factory, address _payments, string memory _serviceId ) Payable(_payments, _serviceId) { nonfungiblePositionManager = INonfungiblePositionManager( _nonfungiblePositionManager ); v3Factory = IUniswapV3Factory(_v3Factory); } function encodePriceSqrt(uint256 reserve0, uint256 reserve1) public pure returns (uint160 sqrtPriceX96) { require(reserve0 > 0 && reserve1 > 0, "Reserves must be positive"); uint256 ratio = Math.sqrt(((reserve1 * padding) / reserve0) / padding) * Q96; sqrtPriceX96 = uint160(ratio); } /// @inheritdoc IERC721Receiver function onERC721Received( address operator, address, uint256 tokenId, bytes calldata ) external override returns (bytes4) { // get position information //console.log('received a token', tokenId); _createDeposit(operator, tokenId); return this.onERC721Received.selector; } /// Create Depoisit function /// @param owner the owner of the deposit /// @param tokenId the id of the deposit function _createDeposit(address owner, uint256 tokenId) internal { ( , , address token0, address token1, , , , uint128 liquidity, , , , ) = nonfungiblePositionManager.positions(tokenId); // set the owner and data for position // operator is msg.sender deposits[tokenId] = Deposit({ owner: owner, liquidity: liquidity, token0: token0, token1: token1 }); } /// Creates a pool /// @param _token0 the address of the token0 /// @param _token1 the address of the token1 /// @param _amount0ToMint the amount of token0 to mint /// @param _amount1ToMint the amount of token1 to mint /// @param _fee the pool fee function _createPool ( address _token0, address _token1, uint256 _amount0ToMint, uint256 _amount1ToMint, uint24 _fee ) internal { address pool = getPoolAddress(_token0, _token1, _fee); ///@notice do not create a pool if already exists if(pool == address(0)) { IUniswapV3Pool _pool = IUniswapV3Pool(v3Factory.createPool(_token0, _token1, _fee)); uint160 sqrtPriceX96 = encodePriceSqrt(_amount0ToMint, _amount1ToMint); _pool.initialize(sqrtPriceX96); } } /// Gets the pool address /// @param token0 the base token /// @param token1 the qoute token /// @param fee the pool fee function getPoolAddress( address token0, address token1, uint24 fee ) public view returns (address pool) { return v3Factory.getPool( address(token0), address(token1), fee ); } /// @notice Mint a new position, creates the pool and mints a token /// @param _token0 the address of the token0 /// @param _token1 the address of the token1 /// @param _amount0ToMint the amount of token0 to mint /// @param _amount1ToMint the amount of token1 to mint /// @param _fee the pool fee /// @return tokenId the id of the erc721 /// @return liquidity the amount of liquidity /// @return amount0 the amount of token0 /// @return amount1 the amount of token1 function createAndMintNewPosition ( address _token0, address _token1, uint256 _amount0ToMint, uint256 _amount1ToMint, uint24 _fee, bytes32 _projectId ) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ) { //guarantee always the same pool ( address token0, address token1, uint256 amount0ToMint, uint256 amount1ToMint ) = _token0 < _token1 ? (_token0, _token1, _amount0ToMint, _amount1ToMint) : (_token1, _token0, _amount1ToMint, _amount0ToMint); _createPool( token0, token1, amount0ToMint, amount1ToMint, _fee ); ( tokenId, liquidity, amount0, amount1 ) = _mintNewPosition( token0, token1, amount0ToMint, amount1ToMint, _fee ); payService(_projectId, _token0, 1); return (tokenId, liquidity, amount0, amount1); } /// @notice Mint a new position /// @param _token0 the address of the token0 /// @param _token1 the address of the token1 /// @param _amount0ToMint the amount of token0 to mint /// @param _amount1ToMint the amount of token1 to mint /// @param _fee the pool fee /// @return tokenId the id of the erc721 /// @return liquidity the amount of liquidity /// @return amount0 the amount of token0 /// @return amount1 the amount of token1 function mintNewPosition( address _token0, address _token1, uint256 _amount0ToMint, uint256 _amount1ToMint, uint24 _fee, bytes32 _projectId ) external payable returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ) { //guarantee always the same pool ( address token0, address token1, uint256 amount0ToMint, uint256 amount1ToMint ) = _token0 < _token1 ? (_token0, _token1, _amount0ToMint, _amount1ToMint) : (_token1, _token0, _amount1ToMint, _amount0ToMint); ( tokenId, liquidity, amount0, amount1 ) = _mintNewPosition( token0, token1, amount0ToMint, amount1ToMint, _fee ); payService(_projectId, _token0, 1); return (tokenId, liquidity, amount0, amount1); } /// @notice Mint a new position /// @param _token0 the address of the token0 /// @param _token1 the address of the token1 /// @param _amount0ToMint the amount of token0 to mint /// @param _amount1ToMint the amount of token1 to mint /// @param _fee the pool fee /// @return tokenId the id of the erc721 /// @return liquidity the amount of liquidity /// @return amount0 the amount of token0 /// @return amount1 the amount of token1 function _mintNewPosition( address _token0, address _token1, uint256 _amount0ToMint, uint256 _amount1ToMint, uint24 _fee ) internal returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 ) { // transfer tokens to contract TransferHelper.safeTransferFrom( _token0, msg.sender, address(this), _amount0ToMint ); TransferHelper.safeTransferFrom( _token1, msg.sender, address(this), _amount1ToMint ); // Approve the position manager TransferHelper.safeApprove( _token0, address(nonfungiblePositionManager), _amount0ToMint ); TransferHelper.safeApprove( _token1, address(nonfungiblePositionManager), _amount1ToMint ); INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({ token0: _token0, token1: _token1, fee: _fee, tickLower: MIN_TICK, tickUpper: MAX_TICK, amount0Desired: _amount0ToMint, amount1Desired: _amount1ToMint, amount0Min: 0, amount1Min: 0, recipient: address(this), deadline: block.timestamp }); ///@dev must already be created and initialized in order to mint (tokenId, liquidity, amount0, amount1) = nonfungiblePositionManager .mint(params); _createDeposit(msg.sender, tokenId); // Remove allowance and refund in both assets. if (amount0 < _amount0ToMint) { TransferHelper.safeApprove( _token0, address(nonfungiblePositionManager), 0 ); uint256 refund0 = _amount0ToMint - amount0; TransferHelper.safeTransfer(_token0, msg.sender, refund0); } if (amount1 < _amount1ToMint) { TransferHelper.safeApprove( _token1, address(nonfungiblePositionManager), 0 ); uint256 refund1 = _amount1ToMint - amount1; TransferHelper.safeTransfer(_token1, msg.sender, refund1); } emit PositionMinted(tokenId, liquidity, amount0, amount1); return (tokenId, liquidity, amount0, amount1); } /// Collect all fees from a position /// @param tokenId The id of the erc721 /// @return amount0 the amount of token0 /// @return amount1 the amount of token1 function collectAllFees( uint256 tokenId ) external returns (uint256 amount0, uint256 amount1) { // Caller must own the ERC721 position // Call to safeTransfer will trigger `onERC721Received` which must return the selector else transfer will fail nonfungiblePositionManager.safeTransferFrom( msg.sender, address(this), tokenId ); // set amount0Max and amount1Max to uint256.max to collect all fees // alternatively can set recipient to msg.sender and avoid another transaction in `sendToOwner` INonfungiblePositionManager.CollectParams memory params = INonfungiblePositionManager.CollectParams({ tokenId: tokenId, recipient: address(this), amount0Max: type(uint128).max, amount1Max: type(uint128).max }); (amount0, amount1) = nonfungiblePositionManager.collect(params); // send collected feed back to owner _sendToOwner(tokenId, amount0, amount1); emit FeesCollected(amount0, amount1); return (amount0, amount1); } /// @notice Transfers funds to owner of NFT /// @param tokenId The id of the erc721 /// @param amount0 The amount of token0 /// @param amount1 The amount of token1 function _sendToOwner( uint256 tokenId, uint256 amount0, uint256 amount1 ) internal { // get owner of contract address owner = deposits[tokenId].owner; address token0 = deposits[tokenId].token0; address token1 = deposits[tokenId].token1; // send collected fees to owner TransferHelper.safeTransfer(token0, owner, amount0); TransferHelper.safeTransfer(token1, owner, amount1); } /// /// @param tokenId The id of the erc721 /// @param amountAdd0 the amount to add of token0 /// @param amountAdd1 the amount to add of token1 /// @return liquidity the amount of liquidity /// @return amount0 the amount of token0 /// @return amount1 the amount of token1 function increaseLiquidityCurrentRange( uint256 tokenId, uint256 amountAdd0, uint256 amountAdd1 ) external returns (uint128 liquidity, uint256 amount0, uint256 amount1) { TransferHelper.safeTransferFrom( deposits[tokenId].token0, msg.sender, address(this), amountAdd0 ); TransferHelper.safeTransferFrom( deposits[tokenId].token1, msg.sender, address(this), amountAdd1 ); TransferHelper.safeApprove( deposits[tokenId].token0, address(nonfungiblePositionManager), amountAdd0 ); TransferHelper.safeApprove( deposits[tokenId].token1, address(nonfungiblePositionManager), amountAdd1 ); INonfungiblePositionManager.IncreaseLiquidityParams memory params = INonfungiblePositionManager .IncreaseLiquidityParams({ tokenId: tokenId, amount0Desired: amountAdd0, amount1Desired: amountAdd1, amount0Min: 0, amount1Min: 0, deadline: block.timestamp }); (liquidity, amount0, amount1) = nonfungiblePositionManager .increaseLiquidity(params); emit LiquidityIncreased(liquidity, amount0, amount1); } /// /// @param tokenId The id of the erc721 /// @param newLiquidity the new liquidity /// @return amount0 the amount of token0 /// @return amount1 the amount of token1 function decreaseLiquidity( uint256 tokenId, uint128 newLiquidity ) external returns (uint256 amount0, uint256 amount1) { // caller must be the owner of the NFT require(msg.sender == deposits[tokenId].owner, "Not the owner"); // get liquidity data for tokenId uint128 liquidity = deposits[tokenId].liquidity; //uint128 halfLiquidity = liquidity / 2; require( newLiquidity < liquidity, "New liquidity must be lesser than current liquidity" ); // amount0Min and amount1Min are price slippage checks // if the amount received after burning is not greater than these minimums, transaction will fail INonfungiblePositionManager.DecreaseLiquidityParams memory params = INonfungiblePositionManager .DecreaseLiquidityParams({ tokenId: tokenId, liquidity: newLiquidity, amount0Min: 0, amount1Min: 0, deadline: block.timestamp }); (amount0, amount1) = nonfungiblePositionManager.decreaseLiquidity( params ); /// @notice send liquidity back to owner _sendToOwner(tokenId, amount0, amount1); emit LiquidityDecreased(amount0, amount1); return (amount0, amount1); } /// @notice Transfers the NFT to the owner /// @param tokenId The id of the erc721 function retrieveNFT(uint256 tokenId) external { // must be the owner of the NFT require(msg.sender == deposits[tokenId].owner, 'Not the owner'); // transfer ownership to original owner nonfungiblePositionManager.safeTransferFrom(address(this), msg.sender, tokenId); //remove information related to tokenId delete deposits[tokenId]; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the 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: 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: 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.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the 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/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 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.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); 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 overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { 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 division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds 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. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = 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^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 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^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @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 + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @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; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @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: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title The interface for the Uniswap V3 Factory /// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol fees interface IUniswapV3Factory { /// @notice Emitted when the owner of the factory is changed /// @param oldOwner The owner before the owner was changed /// @param newOwner The owner after the owner was changed event OwnerChanged(address indexed oldOwner, address indexed newOwner); /// @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 fee amount is enabled for pool creation via the factory /// @param fee The enabled fee, denominated in hundredths of a bip /// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing); /// @notice Returns the current owner of the factory /// @dev Can be changed by the current owner via setOwner /// @return The address of the factory owner function owner() external view returns (address); /// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled /// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context /// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee /// @return The tick spacing function feeAmountTickSpacing(uint24 fee) external view returns (int24); /// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist /// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order /// @param tokenA The contract address of either token0 or token1 /// @param tokenB The contract address of the other token /// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip /// @return pool The pool address function getPool( address tokenA, address tokenB, uint24 fee ) external view returns (address pool); /// @notice Creates a pool for the given two tokens and fee /// @param tokenA One of the two tokens in the desired pool /// @param tokenB The other of the two tokens in the desired pool /// @param fee The desired fee for the pool /// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved /// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments /// are invalid. /// @return pool The address of the newly created pool function createPool( address tokenA, address tokenB, uint24 fee ) external returns (address pool); /// @notice Updates the owner of the factory /// @dev Must be called by the current owner /// @param _owner The new owner of the factory function setOwner(address _owner) external; /// @notice Enables a fee amount with the given tickSpacing /// @dev Fee amounts may never be removed once enabled /// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6) /// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount function enableFeeAmount(uint24 fee, int24 tickSpacing) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import './pool/IUniswapV3PoolImmutables.sol'; import './pool/IUniswapV3PoolState.sol'; import './pool/IUniswapV3PoolDerivedState.sol'; import './pool/IUniswapV3PoolActions.sol'; import './pool/IUniswapV3PoolOwnerActions.sol'; import './pool/IUniswapV3PoolEvents.sol'; /// @title The interface for a Uniswap V3 Pool /// @notice A Uniswap 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 IUniswapV3Pool is IUniswapV3PoolImmutables, IUniswapV3PoolState, IUniswapV3PoolDerivedState, IUniswapV3PoolActions, IUniswapV3PoolOwnerActions, IUniswapV3PoolEvents { }
// 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 IUniswapV3PoolActions { /// @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 tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice 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 tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice 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 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 IUniswapV3PoolDerivedState { /// @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 Events emitted by a pool /// @notice Contains all events emitted by the pool interface IUniswapV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IUniswapV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory 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 Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IUniswapV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees /// @param feeProtocol0 new protocol fee for token0 of the pool /// @param feeProtocol1 new protocol fee for token1 of the pool function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) 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); }
// 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 IUniswapV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// observationIndex The index of the last oracle observation that was written, /// observationCardinality The current maximum number of observations stored in the pool, /// observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper, /// liquidityNet how much liquidity changes when the pool price crosses the tick, /// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// secondsOutside the seconds spent on the other side of the tick from the current tick, /// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks(int24 tick) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return _liquidity The amount of liquidity in the position, /// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke 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, /// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// Returns initialized whether the observation has been initialized and the values are safe to use function observations(uint256 index) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; /// @title ERC721 with permit /// @notice Extension to ERC721 that includes a permit function for signature based approvals interface IERC721Permit is IERC721 { /// @notice The permit typehash used in the permit signature /// @return The typehash for the permit function PERMIT_TYPEHASH() external pure returns (bytes32); /// @notice The domain separator used in the permit signature /// @return The domain seperator used in encoding of permit signature function DOMAIN_SEPARATOR() external view returns (bytes32); /// @notice Approve of a specific token ID for spending by spender via signature /// @param spender The account that is being approved /// @param tokenId The ID of the token that is being approved for spending /// @param deadline The deadline timestamp by which the call must be mined for the approve to work /// @param v Must produce valid secp256k1 signature from the holder along with `r` and `s` /// @param r Must produce valid secp256k1 signature from the holder along with `v` and `s` /// @param s Must produce valid secp256k1 signature from the holder along with `r` and `v` function permit( address spender, uint256 tokenId, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external payable; }
// 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 factory function factory() external view returns (address); /// @return Returns the address of WETH9 function WETH9() external view returns (address); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; /// @title Periphery Payments /// @notice Functions to ease deposits and withdrawals of ETH interface IPeripheryPayments { /// @notice Unwraps the contract's WETH9 balance and sends it to recipient as ETH. /// @dev The amountMinimum parameter prevents malicious contracts from stealing WETH9 from users. /// @param amountMinimum The minimum amount of WETH9 to unwrap /// @param recipient The address receiving ETH function unwrapWETH9(uint256 amountMinimum, address recipient) external payable; /// @notice Refunds any ETH balance held by this contract to the `msg.sender` /// @dev Useful for bundling with mint or increase liquidity that uses ether, or exact output swaps /// that use ether for the input amount function refundETH() external payable; /// @notice Transfers the full amount of a token held by this contract to recipient /// @dev The amountMinimum parameter prevents malicious contracts from stealing the token from users /// @param token The contract address of the token which will be transferred to `recipient` /// @param amountMinimum The minimum amount of token required for a transfer /// @param recipient The destination address of the token function sweepToken( address token, uint256 amountMinimum, address recipient ) external payable; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title Creates and initializes V3 Pools /// @notice Provides a method for creating and initializing a pool, if necessary, for bundling with other methods that /// require the pool to exist. interface IPoolInitializer { /// @notice Creates a new pool if it does not exist, then initializes if not initialized /// @dev This method can be bundled with others via IMulticall for the first action (e.g. mint) performed against a pool /// @param token0 The contract address of token0 of the pool /// @param token1 The contract address of token1 of the pool /// @param fee The fee amount of the v3 pool for the specified token pair /// @param sqrtPriceX96 The initial square root price of the pool as a Q64.96 value /// @return pool Returns the pool address based on the pair of tokens and fee, will return the newly created pool address if necessary function createAndInitializePoolIfNecessary( address token0, address token1, uint24 fee, uint160 sqrtPriceX96 ) external payable returns (address pool); }
// 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: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IPoolInitializer.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IERC721Permit.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryPayments.sol"; import "@uniswap/v3-periphery/contracts/interfaces/IPeripheryImmutableState.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 IPoolInitializer, IPeripheryPayments, IPeripheryImmutableState, IERC721Metadata, IERC721Enumerable, IERC721Permit { /// @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 nonce The nonce for permits /// @return operator The address that is approved for spending /// @return token0 The address of the token0 for a specific pool /// @return token1 The address of the token1 for a specific pool /// @return fee The fee associated with the pool /// @return tickLower The lower end of the tick range for the position /// @return tickUpper The higher end of the tick range for the position /// @return liquidity The liquidity of the position /// @return feeGrowthInside0LastX128 The fee growth of token0 as of the last action on the individual position /// @return feeGrowthInside1LastX128 The fee growth of token1 as of the last action on the individual position /// @return tokensOwed0 The uncollected amount of token0 owed to the position as of the last computation /// @return tokensOwed1 The uncollected amount of token1 owed to the position as of the last computation function positions( uint256 tokenId ) external view returns ( uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); struct MintParams { address token0; address token1; uint24 fee; int24 tickLower; int24 tickUpper; uint256 amount0Desired; uint256 amount1Desired; uint256 amount0Min; uint256 amount1Min; address recipient; uint256 deadline; } /// @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; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.24; /* * IPayments interface */ /// @title Payments /// @author Smithii interface IPayments { struct Service { bytes32 serviceId; uint256 pricePerItem; bool active; } struct Invoice { address user; Service service; uint256 qty; uint256 total; uint256 timestamp; } /// Events event ServiceAdded(bytes32 serviceId, string name, uint256 price); event ServiceSet(bytes32 serviceId, bool active); event ServicePaid( bytes32 projectId, address contractAddress, bytes32 serviceId, address user, uint256 amount, uint256 timestamp ); event ServiceWithdraw( bytes32 projectId, address contractAddress, bytes32 serviceId, uint256 amount ); /// Errors error ServiceNotActive(bytes32 serviceId); error InvalidTotalAmount(); error ServiceAlreadyPaid( bytes32 projectId, address contractAddress, bytes32 serviceId ); /// Add a service to the payment program /// @param _serviceId the service id /// @param _pricePerItem the price per item function addService(bytes32 _serviceId, uint256 _pricePerItem) external; /// Set the service active status /// @param _serviceId the service id /// @param _active the active status function setService(bytes32 _serviceId, bool _active) external; /// function payService by projectId and contract address /// @param _projectId bytes32 projectId /// @param _contract the contract address /// @param _serviceId the service id /// @param _qty the qty of items to pay function payService( bytes32 _projectId, address _contract, bytes32 _serviceId, uint256 _qty ) external payable; /// Withdraw per invoice /// @param _projectId the project id /// @param _contract the contract address /// @param _serviceId the service id /// @param _to the address to withdraw the balance function withdraw( bytes32 _projectId, address _contract, bytes32 _serviceId, address payable _to ) external; /// Withdraw the contract balance /// @param _to the address to withdraw the balance function withdrawAll(address payable _to) external; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.24; /// @title Payable /// @author Smithii import {IPayments} from "../interfaces/marketplace/IPayments.sol"; abstract contract Payable { address public payments = address(0); bytes32 public serviceId; constructor(address _payments, string memory _serviceId) { payments = _payments; serviceId = keccak256(abi.encodePacked(_serviceId)); } /// /// @param _projectId the project id /// @param _token the token address /// @param qty the qty of items to pay function payService( bytes32 _projectId, address _token, uint256 qty ) public payable { IPayments(payments).payService{value: msg.value}( _projectId, _token, serviceId, qty ); } receive() external payable {} }
{ "optimizer": { "enabled": true, "runs": 1000 }, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_nonfungiblePositionManager","type":"address"},{"internalType":"address","name":"_v3Factory","type":"address"},{"internalType":"address","name":"_payments","type":"address"},{"internalType":"string","name":"_serviceId","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"FeesCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"LiquidityDecreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"liquidity","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount0","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount1","type":"uint256"}],"name":"LiquidityIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"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":"PositionMinted","type":"event"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"collectAllFees","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"},{"internalType":"uint256","name":"_amount0ToMint","type":"uint256"},{"internalType":"uint256","name":"_amount1ToMint","type":"uint256"},{"internalType":"uint24","name":"_fee","type":"uint24"},{"internalType":"bytes32","name":"_projectId","type":"bytes32"}],"name":"createAndMintNewPosition","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":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint128","name":"newLiquidity","type":"uint128"}],"name":"decreaseLiquidity","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"deposits","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reserve0","type":"uint256"},{"internalType":"uint256","name":"reserve1","type":"uint256"}],"name":"encodePriceSqrt","outputs":[{"internalType":"uint160","name":"sqrtPriceX96","type":"uint160"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"token0","type":"address"},{"internalType":"address","name":"token1","type":"address"},{"internalType":"uint24","name":"fee","type":"uint24"}],"name":"getPoolAddress","outputs":[{"internalType":"address","name":"pool","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"amountAdd0","type":"uint256"},{"internalType":"uint256","name":"amountAdd1","type":"uint256"}],"name":"increaseLiquidityCurrentRange","outputs":[{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_token0","type":"address"},{"internalType":"address","name":"_token1","type":"address"},{"internalType":"uint256","name":"_amount0ToMint","type":"uint256"},{"internalType":"uint256","name":"_amount1ToMint","type":"uint256"},{"internalType":"uint24","name":"_fee","type":"uint24"},{"internalType":"bytes32","name":"_projectId","type":"bytes32"}],"name":"mintNewPosition","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":[],"name":"nonfungiblePositionManager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_projectId","type":"bytes32"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"qty","type":"uint256"}],"name":"payService","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"payments","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"retrieveNFT","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"serviceId","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"v3Factory","outputs":[{"internalType":"contract IUniswapV3Factory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60c0604052600080546001600160a01b03191690553480156200002157600080fd5b506040516200227238038062002272833981016040819052620000449162000106565b600080546001600160a01b0319166001600160a01b0384161790556040518290829062000076908290602001620001f7565b60408051601f1981840301815291905280516020909101206001555050506001600160a01b03928316608052501660a05262000215565b80516001600160a01b0381168114620000c557600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b83811015620000fd578181015183820152602001620000e3565b50506000910152565b600080600080608085870312156200011d57600080fd5b6200012885620000ad565b93506200013860208601620000ad565b92506200014860408601620000ad565b60608601519092506001600160401b03808211156200016657600080fd5b818701915087601f8301126200017b57600080fd5b815181811115620001905762000190620000ca565b604051601f8201601f19908116603f01168101908382118183101715620001bb57620001bb620000ca565b816040528281528a6020848701011115620001d557600080fd5b620001e8836020830160208801620000e0565b979a9699509497505050505050565b600082516200020b818460208701620000e0565b9190910192915050565b60805160a051611fce620002a46000396000818161026f01528181610a4a01526116e501526000818161037901528181610482015281816106330152818161070b0152818161083d015281816108830152818161092b01528181610c2f01528181610e880152818161105f0152818161108a0152818161113a015281816111e901526112380152611fce6000f3fe6080604052600436106100ec5760003560e01c806399d7b5941161008a578063cd309ec911610059578063cd309ec91461039b578063d8bbe869146103bb578063da20ec6a146103ce578063f4b61222146103f257600080fd5b806399d7b59414610291578063a6d23e10146102b1578063b02c43d0146102d1578063b44a27221461036757600080fd5b806346ce96dd116100c657806346ce96dd146101ab578063617d6d6e146101e0578063696d6283146102255780637c887c591461025d57600080fd5b80630a1d7c5f146100f8578063150b7a021461011a57806334addb231461017057600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046119bc565b610405565b005b34801561012657600080fd5b5061013a6101353660046119ed565b61055e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b61018361017e366004611a9d565b610595565b604080519485526001600160801b039093166020850152918301526060820152608001610167565b3480156101b757600080fd5b506101cb6101c63660046119bc565b610604565b60408051928352602083019190915201610167565b3480156101ec57600080fd5b506102006101fb366004611b04565b6107c9565b604080516001600160801b039094168452602084019290925290820152606001610167565b34801561023157600080fd5b50610245610240366004611b30565b6109fc565b6040516001600160a01b039091168152602001610167565b34801561026957600080fd5b506102457f000000000000000000000000000000000000000000000000000000000000000081565b34801561029d57600080fd5b506101cb6102ac366004611b90565b610abf565b3480156102bd57600080fd5b50600054610245906001600160a01b031681565b3480156102dd57600080fd5b5061032b6102ec3660046119bc565b600260208190526000918252604090912080546001820154928201546003909201546001600160a01b03918216936001600160801b0316928216911684565b604080516001600160a01b0395861681526001600160801b03909416602085015291841691830191909152919091166060820152608001610167565b34801561037357600080fd5b506102457f000000000000000000000000000000000000000000000000000000000000000081565b3480156103a757600080fd5b506102456103b6366004611bc0565b610cf5565b6101836103c9366004611a9d565b610d95565b3480156103da57600080fd5b506103e460015481565b604051908152602001610167565b610118610400366004611be2565b610dea565b6000818152600260205260409020546001600160a01b031633146104605760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b60448201526064015b60405180910390fd5b604051632142170760e11b8152306004820152336024820152604481018290527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906342842e0e90606401600060405180830381600087803b1580156104ce57600080fd5b505af11580156104e2573d6000803e3d6000fd5b50505060009182525060026020819052604090912080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811682556001820180547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905591810180548316905560030180549091169055565b600061056a8685610e81565b507f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6000806000806000806000808c6001600160a01b03168e6001600160a01b0316106105c3578c8e8c8e6105c8565b8d8d8d8d5b93509350935093506105dd848484848e61103b565b929a50909850965094506105f3898f6001610dea565b505050509650965096509692505050565b604051632142170760e11b81523360048201523060248201526044810182905260009081906001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906342842e0e90606401600060405180830381600087803b15801561067757600080fd5b505af115801561068b573d6000803e3d6000fd5b50506040805160808101825286815230602082019081526001600160801b038284018181526060840182815294517ffc6f78650000000000000000000000000000000000000000000000000000000081528451600482015292516001600160a01b03908116602485015290518216604484015293511660648201529093507f0000000000000000000000000000000000000000000000000000000000000000909116915063fc6f78659060840160408051808303816000875af1158015610756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077a9190611c1a565b909350915061078a8484846112d6565b60408051848152602081018490527f49d512bf9cb224241c05691e73eb9fab078cf350c7dbcbcf66788f1fc0cc8b0b910160405180910390a150915091565b600083815260026020819052604082200154819081906107f4906001600160a01b0316333088611322565b60008681526002602052604090206003015461081b906001600160a01b0316333087611322565b60008681526002602081905260409091200154610862906001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000087611457565b6000868152600260205260409020600301546108a8906001600160a01b03167f000000000000000000000000000000000000000000000000000000000000000086611457565b6040805160c08101825287815260208101878152818301878152600060608401818152608085019182524260a0860190815295517f219f5d1700000000000000000000000000000000000000000000000000000000815285516004820152935160248501529151604484015290516064830152516084820152915160a4830152907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063219f5d179060c4016060604051808303816000875af115801561097c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a09190611c4e565b604080516001600160801b03851681526020810184905290810182905292965090945092507f3e7eb8fbb7b6a8eb3e381b450c3f3d92463dfc879765790e9853f3024269edd99060600160405180910390a15093509350939050565b6040517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152838116602483015262ffffff831660448301526000917f000000000000000000000000000000000000000000000000000000000000000090911690631698ee8290606401602060405180830381865afa158015610a93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab79190611c90565b949350505050565b60008281526002602052604081205481906001600160a01b03163314610b175760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b6044820152606401610457565b6000848152600260205260409020600101546001600160801b039081169084168111610bab5760405162461bcd60e51b815260206004820152603360248201527f4e6577206c6971756964697479206d757374206265206c65737365722074686160448201527f6e2063757272656e74206c6971756964697479000000000000000000000000006064820152608401610457565b6040805160a0810182528681526001600160801b0386811660208301908152600083850181815260608501918252426080860190815295517f0c49ccbe0000000000000000000000000000000000000000000000000000000081528551600482015292519093166024830152915160448201529051606482015291516084830152907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031690630c49ccbe9060a40160408051808303816000875af1158015610c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca39190611c1a565b9094509250610cb38685856112d6565b60408051858152602081018590527f1d2b5032c2dc8e0a8b4c12f9b228a208691193c1033f45048873edcc8fe22653910160405180910390a150509250929050565b60008083118015610d065750600082115b610d525760405162461bcd60e51b815260206004820152601960248201527f5265736572766573206d75737420626520706f736974697665000000000000006044820152606401610457565b60006c01000000000000000000000000610d8b606486610d728288611cc3565b610d7c9190611cf0565b610d869190611cf0565b61158b565b610ab79190611cc3565b6000806000806000806000808c6001600160a01b03168e6001600160a01b031610610dc3578c8e8c8e610dc8565b8d8d8d8d5b9350935093509350610ddd848484848e61167a565b6105dd848484848e61103b565b6000546001546040517f8690b8c9000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b038581166024830152604482019290925260648101849052911690638690b8c99034906084016000604051808303818588803b158015610e6357600080fd5b505af1158015610e77573d6000803e3d6000fd5b5050505050505050565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166399fbab88856040518263ffffffff1660e01b8152600401610ed491815260200190565b61018060405180830381865afa158015610ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f169190611d2f565b5050505097505050509450945050506040518060800160405280866001600160a01b03168152602001826001600160801b03168152602001846001600160a01b03168152602001836001600160a01b03168152506002600086815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160801b0302191690836001600160801b0316021790555060408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b031602179055509050505050505050565b60008060008061104d8933308a611322565b61105988333089611322565b611084897f000000000000000000000000000000000000000000000000000000000000000089611457565b6110af887f000000000000000000000000000000000000000000000000000000000000000088611457565b60006040518061016001604052808b6001600160a01b031681526020018a6001600160a01b031681526020018762ffffff168152602001620d89e71960020b8152602001620d89e71961110190611e10565b60020b81526020018981526020018881526020016000815260200160008152602001306001600160a01b031681526020014281525090507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166388316456826040518263ffffffff1660e01b81526004016111849190611e32565b6080604051808303816000875af11580156111a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c79190611ef6565b929750909550935091506111db3386610e81565b8783101561122a5761120f8a7f00000000000000000000000000000000000000000000000000000000000000006000611457565b600061121b848a611f34565b90506112288b33836117e4565b505b868210156112795761125e897f00000000000000000000000000000000000000000000000000000000000000006000611457565b600061126a8389611f34565b90506112778a33836117e4565b505b604080518681526001600160801b0386166020820152908101849052606081018390527f7180ba4ffa4be9136434b7fa9b09c2c9e382d100e6850652637d0406f33110ff9060800160405180910390a15095509550955095915050565b60008381526002602081905260409091208054918101546003909101546001600160a01b0392831692918216911661130f8284876117e4565b61131a8184866117e4565b505050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03167f23b872dd00000000000000000000000000000000000000000000000000000000179052915160009283929088169161139f9190611f47565b6000604051808303816000865af19150503d80600081146113dc576040519150601f19603f3d011682016040523d82523d6000602084013e6113e1565b606091505b509150915081801561140b57508051158061140b57508080602001905181019061140b9190611f76565b61131a5760405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152606401610457565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03167f095ea7b30000000000000000000000000000000000000000000000000000000017905291516000928392908716916114cc9190611f47565b6000604051808303816000865af19150503d8060008114611509576040519150601f19603f3d011682016040523d82523d6000602084013e61150e565b606091505b50915091508180156115385750805115806115385750808060200190518101906115389190611f76565b6115845760405162461bcd60e51b815260206004820152600260248201527f53410000000000000000000000000000000000000000000000000000000000006044820152606401610457565b5050505050565b60008160000361159d57506000919050565b600060016115aa84611911565b901c6001901b905060018184816115c3576115c3611cda565b048201901c905060018184816115db576115db611cda565b048201901c905060018184816115f3576115f3611cda565b048201901c9050600181848161160b5761160b611cda565b048201901c9050600181848161162357611623611cda565b048201901c9050600181848161163b5761163b611cda565b048201901c9050600181848161165357611653611cda565b048201901c90506116738182858161166d5761166d611cda565b046119a6565b9392505050565b60006116878686846109fc565b90506001600160a01b03811661131a576040517fa16712950000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152868116602483015262ffffff841660448301526000917f00000000000000000000000000000000000000000000000000000000000000009091169063a1671295906064016020604051808303816000875af1158015611730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117549190611c90565b905060006117628686610cf5565b6040517ff637731d0000000000000000000000000000000000000000000000000000000081526001600160a01b0380831660048301529192509083169063f637731d90602401600060405180830381600087803b1580156117c257600080fd5b505af11580156117d6573d6000803e3d6000fd5b505050505050505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916118599190611f47565b6000604051808303816000865af19150503d8060008114611896576040519150601f19603f3d011682016040523d82523d6000602084013e61189b565b606091505b50915091508180156118c55750805115806118c55750808060200190518101906118c59190611f76565b6115845760405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152606401610457565b600080608083901c1561192657608092831c92015b604083901c1561193857604092831c92015b602083901c1561194a57602092831c92015b601083901c1561195c57601092831c92015b600883901c1561196e57600892831c92015b600483901c1561198057600492831c92015b600283901c1561199257600292831c92015b600183901c156119a0576001015b92915050565b60008183106119b55781611673565b5090919050565b6000602082840312156119ce57600080fd5b5035919050565b6001600160a01b03811681146119ea57600080fd5b50565b600080600080600060808688031215611a0557600080fd5b8535611a10816119d5565b94506020860135611a20816119d5565b935060408601359250606086013567ffffffffffffffff80821115611a4457600080fd5b818801915088601f830112611a5857600080fd5b813581811115611a6757600080fd5b896020828501011115611a7957600080fd5b9699959850939650602001949392505050565b62ffffff811681146119ea57600080fd5b60008060008060008060c08789031215611ab657600080fd5b8635611ac1816119d5565b95506020870135611ad1816119d5565b945060408701359350606087013592506080870135611aef81611a8c565b8092505060a087013590509295509295509295565b600080600060608486031215611b1957600080fd5b505081359360208301359350604090920135919050565b600080600060608486031215611b4557600080fd5b8335611b50816119d5565b92506020840135611b60816119d5565b91506040840135611b7081611a8c565b809150509250925092565b6001600160801b03811681146119ea57600080fd5b60008060408385031215611ba357600080fd5b823591506020830135611bb581611b7b565b809150509250929050565b60008060408385031215611bd357600080fd5b50508035926020909101359150565b600080600060608486031215611bf757600080fd5b833592506020840135611c09816119d5565b929592945050506040919091013590565b60008060408385031215611c2d57600080fd5b505080516020909101519092909150565b8051611c4981611b7b565b919050565b600080600060608486031215611c6357600080fd5b8351611c6e81611b7b565b602085015160409095015190969495509392505050565b8051611c49816119d5565b600060208284031215611ca257600080fd5b8151611673816119d5565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176119a0576119a0611cad565b634e487b7160e01b600052601260045260246000fd5b600082611d0d57634e487b7160e01b600052601260045260246000fd5b500490565b8051611c4981611a8c565b8051600281900b8114611c4957600080fd5b6000806000806000806000806000806000806101808d8f031215611d5257600080fd5b8c516bffffffffffffffffffffffff81168114611d6e57600080fd5b9b50611d7c60208e01611c85565b9a50611d8a60408e01611c85565b9950611d9860608e01611c85565b9850611da660808e01611d12565b9750611db460a08e01611d1d565b9650611dc260c08e01611d1d565b9550611dd060e08e01611c3e565b94506101008d015193506101208d01519250611def6101408e01611c3e565b9150611dfe6101608e01611c3e565b90509295989b509295989b509295989b565b60008160020b627fffff198103611e2957611e29611cad565b60000392915050565b81516001600160a01b0316815261016081016020830151611e5e60208401826001600160a01b03169052565b506040830151611e75604084018262ffffff169052565b506060830151611e8a606084018260020b9052565b506080830151611e9f608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611ee5828501826001600160a01b03169052565b505061014092830151919092015290565b60008060008060808587031215611f0c57600080fd5b845193506020850151611f1e81611b7b565b6040860151606090960151949790965092505050565b818103818111156119a0576119a0611cad565b6000825160005b81811015611f685760208186018101518583015201611f4e565b506000920191825250919050565b600060208284031215611f8857600080fd5b8151801515811461167357600080fdfea264697066735822122046befc68e9fc2c633935c0a9f796042c52dfcfe9c4d5d39cc9879ec3d4235da664736f6c634300081800330000000000000000000000001238536071e1c677a632429e3655c799b22cda520000000000000000000000000227628f3f023bb0b980b67d528571c95c6dac1c000000000000000000000000ee6017869f117ac037f8f4b213ba95442bc877b3000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000104552433230506f6f6c466163746f727900000000000000000000000000000000
Deployed Bytecode
0x6080604052600436106100ec5760003560e01c806399d7b5941161008a578063cd309ec911610059578063cd309ec91461039b578063d8bbe869146103bb578063da20ec6a146103ce578063f4b61222146103f257600080fd5b806399d7b59414610291578063a6d23e10146102b1578063b02c43d0146102d1578063b44a27221461036757600080fd5b806346ce96dd116100c657806346ce96dd146101ab578063617d6d6e146101e0578063696d6283146102255780637c887c591461025d57600080fd5b80630a1d7c5f146100f8578063150b7a021461011a57806334addb231461017057600080fd5b366100f357005b600080fd5b34801561010457600080fd5b506101186101133660046119bc565b610405565b005b34801561012657600080fd5b5061013a6101353660046119ed565b61055e565b6040517fffffffff0000000000000000000000000000000000000000000000000000000090911681526020015b60405180910390f35b61018361017e366004611a9d565b610595565b604080519485526001600160801b039093166020850152918301526060820152608001610167565b3480156101b757600080fd5b506101cb6101c63660046119bc565b610604565b60408051928352602083019190915201610167565b3480156101ec57600080fd5b506102006101fb366004611b04565b6107c9565b604080516001600160801b039094168452602084019290925290820152606001610167565b34801561023157600080fd5b50610245610240366004611b30565b6109fc565b6040516001600160a01b039091168152602001610167565b34801561026957600080fd5b506102457f0000000000000000000000000227628f3f023bb0b980b67d528571c95c6dac1c81565b34801561029d57600080fd5b506101cb6102ac366004611b90565b610abf565b3480156102bd57600080fd5b50600054610245906001600160a01b031681565b3480156102dd57600080fd5b5061032b6102ec3660046119bc565b600260208190526000918252604090912080546001820154928201546003909201546001600160a01b03918216936001600160801b0316928216911684565b604080516001600160a01b0395861681526001600160801b03909416602085015291841691830191909152919091166060820152608001610167565b34801561037357600080fd5b506102457f0000000000000000000000001238536071e1c677a632429e3655c799b22cda5281565b3480156103a757600080fd5b506102456103b6366004611bc0565b610cf5565b6101836103c9366004611a9d565b610d95565b3480156103da57600080fd5b506103e460015481565b604051908152602001610167565b610118610400366004611be2565b610dea565b6000818152600260205260409020546001600160a01b031633146104605760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b60448201526064015b60405180910390fd5b604051632142170760e11b8152306004820152336024820152604481018290527f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526001600160a01b0316906342842e0e90606401600060405180830381600087803b1580156104ce57600080fd5b505af11580156104e2573d6000803e3d6000fd5b50505060009182525060026020819052604090912080547fffffffffffffffffffffffff000000000000000000000000000000000000000090811682556001820180547fffffffffffffffffffffffffffffffff0000000000000000000000000000000016905591810180548316905560030180549091169055565b600061056a8685610e81565b507f150b7a020000000000000000000000000000000000000000000000000000000095945050505050565b6000806000806000806000808c6001600160a01b03168e6001600160a01b0316106105c3578c8e8c8e6105c8565b8d8d8d8d5b93509350935093506105dd848484848e61103b565b929a50909850965094506105f3898f6001610dea565b505050509650965096509692505050565b604051632142170760e11b81523360048201523060248201526044810182905260009081906001600160a01b037f0000000000000000000000001238536071e1c677a632429e3655c799b22cda5216906342842e0e90606401600060405180830381600087803b15801561067757600080fd5b505af115801561068b573d6000803e3d6000fd5b50506040805160808101825286815230602082019081526001600160801b038284018181526060840182815294517ffc6f78650000000000000000000000000000000000000000000000000000000081528451600482015292516001600160a01b03908116602485015290518216604484015293511660648201529093507f0000000000000000000000001238536071e1c677a632429e3655c799b22cda52909116915063fc6f78659060840160408051808303816000875af1158015610756573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061077a9190611c1a565b909350915061078a8484846112d6565b60408051848152602081018490527f49d512bf9cb224241c05691e73eb9fab078cf350c7dbcbcf66788f1fc0cc8b0b910160405180910390a150915091565b600083815260026020819052604082200154819081906107f4906001600160a01b0316333088611322565b60008681526002602052604090206003015461081b906001600160a01b0316333087611322565b60008681526002602081905260409091200154610862906001600160a01b03167f0000000000000000000000001238536071e1c677a632429e3655c799b22cda5287611457565b6000868152600260205260409020600301546108a8906001600160a01b03167f0000000000000000000000001238536071e1c677a632429e3655c799b22cda5286611457565b6040805160c08101825287815260208101878152818301878152600060608401818152608085019182524260a0860190815295517f219f5d1700000000000000000000000000000000000000000000000000000000815285516004820152935160248501529151604484015290516064830152516084820152915160a4830152907f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526001600160a01b03169063219f5d179060c4016060604051808303816000875af115801561097c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a09190611c4e565b604080516001600160801b03851681526020810184905290810182905292965090945092507f3e7eb8fbb7b6a8eb3e381b450c3f3d92463dfc879765790e9853f3024269edd99060600160405180910390a15093509350939050565b6040517f1698ee820000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152838116602483015262ffffff831660448301526000917f0000000000000000000000000227628f3f023bb0b980b67d528571c95c6dac1c90911690631698ee8290606401602060405180830381865afa158015610a93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ab79190611c90565b949350505050565b60008281526002602052604081205481906001600160a01b03163314610b175760405162461bcd60e51b815260206004820152600d60248201526c2737ba103a34329037bbb732b960991b6044820152606401610457565b6000848152600260205260409020600101546001600160801b039081169084168111610bab5760405162461bcd60e51b815260206004820152603360248201527f4e6577206c6971756964697479206d757374206265206c65737365722074686160448201527f6e2063757272656e74206c6971756964697479000000000000000000000000006064820152608401610457565b6040805160a0810182528681526001600160801b0386811660208301908152600083850181815260608501918252426080860190815295517f0c49ccbe0000000000000000000000000000000000000000000000000000000081528551600482015292519093166024830152915160448201529051606482015291516084830152907f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526001600160a01b031690630c49ccbe9060a40160408051808303816000875af1158015610c7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ca39190611c1a565b9094509250610cb38685856112d6565b60408051858152602081018590527f1d2b5032c2dc8e0a8b4c12f9b228a208691193c1033f45048873edcc8fe22653910160405180910390a150509250929050565b60008083118015610d065750600082115b610d525760405162461bcd60e51b815260206004820152601960248201527f5265736572766573206d75737420626520706f736974697665000000000000006044820152606401610457565b60006c01000000000000000000000000610d8b606486610d728288611cc3565b610d7c9190611cf0565b610d869190611cf0565b61158b565b610ab79190611cc3565b6000806000806000806000808c6001600160a01b03168e6001600160a01b031610610dc3578c8e8c8e610dc8565b8d8d8d8d5b9350935093509350610ddd848484848e61167a565b6105dd848484848e61103b565b6000546001546040517f8690b8c9000000000000000000000000000000000000000000000000000000008152600481018690526001600160a01b038581166024830152604482019290925260648101849052911690638690b8c99034906084016000604051808303818588803b158015610e6357600080fd5b505af1158015610e77573d6000803e3d6000fd5b5050505050505050565b60008060007f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526001600160a01b03166399fbab88856040518263ffffffff1660e01b8152600401610ed491815260200190565b61018060405180830381865afa158015610ef2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f169190611d2f565b5050505097505050509450945050506040518060800160405280866001600160a01b03168152602001826001600160801b03168152602001846001600160a01b03168152602001836001600160a01b03168152506002600086815260200190815260200160002060008201518160000160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060208201518160010160006101000a8154816001600160801b0302191690836001600160801b0316021790555060408201518160020160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b031602179055509050505050505050565b60008060008061104d8933308a611322565b61105988333089611322565b611084897f0000000000000000000000001238536071e1c677a632429e3655c799b22cda5289611457565b6110af887f0000000000000000000000001238536071e1c677a632429e3655c799b22cda5288611457565b60006040518061016001604052808b6001600160a01b031681526020018a6001600160a01b031681526020018762ffffff168152602001620d89e71960020b8152602001620d89e71961110190611e10565b60020b81526020018981526020018881526020016000815260200160008152602001306001600160a01b031681526020014281525090507f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526001600160a01b03166388316456826040518263ffffffff1660e01b81526004016111849190611e32565b6080604051808303816000875af11580156111a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111c79190611ef6565b929750909550935091506111db3386610e81565b8783101561122a5761120f8a7f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526000611457565b600061121b848a611f34565b90506112288b33836117e4565b505b868210156112795761125e897f0000000000000000000000001238536071e1c677a632429e3655c799b22cda526000611457565b600061126a8389611f34565b90506112778a33836117e4565b505b604080518681526001600160801b0386166020820152908101849052606081018390527f7180ba4ffa4be9136434b7fa9b09c2c9e382d100e6850652637d0406f33110ff9060800160405180910390a15095509550955095915050565b60008381526002602081905260409091208054918101546003909101546001600160a01b0392831692918216911661130f8284876117e4565b61131a8184866117e4565b505050505050565b604080516001600160a01b0385811660248301528481166044830152606480830185905283518084039091018152608490920183526020820180516001600160e01b03167f23b872dd00000000000000000000000000000000000000000000000000000000179052915160009283929088169161139f9190611f47565b6000604051808303816000865af19150503d80600081146113dc576040519150601f19603f3d011682016040523d82523d6000602084013e6113e1565b606091505b509150915081801561140b57508051158061140b57508080602001905181019061140b9190611f76565b61131a5760405162461bcd60e51b815260206004820152600360248201527f53544600000000000000000000000000000000000000000000000000000000006044820152606401610457565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03167f095ea7b30000000000000000000000000000000000000000000000000000000017905291516000928392908716916114cc9190611f47565b6000604051808303816000865af19150503d8060008114611509576040519150601f19603f3d011682016040523d82523d6000602084013e61150e565b606091505b50915091508180156115385750805115806115385750808060200190518101906115389190611f76565b6115845760405162461bcd60e51b815260206004820152600260248201527f53410000000000000000000000000000000000000000000000000000000000006044820152606401610457565b5050505050565b60008160000361159d57506000919050565b600060016115aa84611911565b901c6001901b905060018184816115c3576115c3611cda565b048201901c905060018184816115db576115db611cda565b048201901c905060018184816115f3576115f3611cda565b048201901c9050600181848161160b5761160b611cda565b048201901c9050600181848161162357611623611cda565b048201901c9050600181848161163b5761163b611cda565b048201901c9050600181848161165357611653611cda565b048201901c90506116738182858161166d5761166d611cda565b046119a6565b9392505050565b60006116878686846109fc565b90506001600160a01b03811661131a576040517fa16712950000000000000000000000000000000000000000000000000000000081526001600160a01b038781166004830152868116602483015262ffffff841660448301526000917f0000000000000000000000000227628f3f023bb0b980b67d528571c95c6dac1c9091169063a1671295906064016020604051808303816000875af1158015611730573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117549190611c90565b905060006117628686610cf5565b6040517ff637731d0000000000000000000000000000000000000000000000000000000081526001600160a01b0380831660048301529192509083169063f637731d90602401600060405180830381600087803b1580156117c257600080fd5b505af11580156117d6573d6000803e3d6000fd5b505050505050505050505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b03167fa9059cbb0000000000000000000000000000000000000000000000000000000017905291516000928392908716916118599190611f47565b6000604051808303816000865af19150503d8060008114611896576040519150601f19603f3d011682016040523d82523d6000602084013e61189b565b606091505b50915091508180156118c55750805115806118c55750808060200190518101906118c59190611f76565b6115845760405162461bcd60e51b815260206004820152600260248201527f53540000000000000000000000000000000000000000000000000000000000006044820152606401610457565b600080608083901c1561192657608092831c92015b604083901c1561193857604092831c92015b602083901c1561194a57602092831c92015b601083901c1561195c57601092831c92015b600883901c1561196e57600892831c92015b600483901c1561198057600492831c92015b600283901c1561199257600292831c92015b600183901c156119a0576001015b92915050565b60008183106119b55781611673565b5090919050565b6000602082840312156119ce57600080fd5b5035919050565b6001600160a01b03811681146119ea57600080fd5b50565b600080600080600060808688031215611a0557600080fd5b8535611a10816119d5565b94506020860135611a20816119d5565b935060408601359250606086013567ffffffffffffffff80821115611a4457600080fd5b818801915088601f830112611a5857600080fd5b813581811115611a6757600080fd5b896020828501011115611a7957600080fd5b9699959850939650602001949392505050565b62ffffff811681146119ea57600080fd5b60008060008060008060c08789031215611ab657600080fd5b8635611ac1816119d5565b95506020870135611ad1816119d5565b945060408701359350606087013592506080870135611aef81611a8c565b8092505060a087013590509295509295509295565b600080600060608486031215611b1957600080fd5b505081359360208301359350604090920135919050565b600080600060608486031215611b4557600080fd5b8335611b50816119d5565b92506020840135611b60816119d5565b91506040840135611b7081611a8c565b809150509250925092565b6001600160801b03811681146119ea57600080fd5b60008060408385031215611ba357600080fd5b823591506020830135611bb581611b7b565b809150509250929050565b60008060408385031215611bd357600080fd5b50508035926020909101359150565b600080600060608486031215611bf757600080fd5b833592506020840135611c09816119d5565b929592945050506040919091013590565b60008060408385031215611c2d57600080fd5b505080516020909101519092909150565b8051611c4981611b7b565b919050565b600080600060608486031215611c6357600080fd5b8351611c6e81611b7b565b602085015160409095015190969495509392505050565b8051611c49816119d5565b600060208284031215611ca257600080fd5b8151611673816119d5565b634e487b7160e01b600052601160045260246000fd5b80820281158282048414176119a0576119a0611cad565b634e487b7160e01b600052601260045260246000fd5b600082611d0d57634e487b7160e01b600052601260045260246000fd5b500490565b8051611c4981611a8c565b8051600281900b8114611c4957600080fd5b6000806000806000806000806000806000806101808d8f031215611d5257600080fd5b8c516bffffffffffffffffffffffff81168114611d6e57600080fd5b9b50611d7c60208e01611c85565b9a50611d8a60408e01611c85565b9950611d9860608e01611c85565b9850611da660808e01611d12565b9750611db460a08e01611d1d565b9650611dc260c08e01611d1d565b9550611dd060e08e01611c3e565b94506101008d015193506101208d01519250611def6101408e01611c3e565b9150611dfe6101608e01611c3e565b90509295989b509295989b509295989b565b60008160020b627fffff198103611e2957611e29611cad565b60000392915050565b81516001600160a01b0316815261016081016020830151611e5e60208401826001600160a01b03169052565b506040830151611e75604084018262ffffff169052565b506060830151611e8a606084018260020b9052565b506080830151611e9f608084018260020b9052565b5060a083015160a083015260c083015160c083015260e083015160e083015261010080840151818401525061012080840151611ee5828501826001600160a01b03169052565b505061014092830151919092015290565b60008060008060808587031215611f0c57600080fd5b845193506020850151611f1e81611b7b565b6040860151606090960151949790965092505050565b818103818111156119a0576119a0611cad565b6000825160005b81811015611f685760208186018101518583015201611f4e565b506000920191825250919050565b600060208284031215611f8857600080fd5b8151801515811461167357600080fdfea264697066735822122046befc68e9fc2c633935c0a9f796042c52dfcfe9c4d5d39cc9879ec3d4235da664736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000001238536071e1c677a632429e3655c799b22cda520000000000000000000000000227628f3f023bb0b980b67d528571c95c6dac1c000000000000000000000000ee6017869f117ac037f8f4b213ba95442bc877b3000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000104552433230506f6f6c466163746f727900000000000000000000000000000000
-----Decoded View---------------
Arg [0] : _nonfungiblePositionManager (address): 0x1238536071E1c677A632429e3655c799b22cDA52
Arg [1] : _v3Factory (address): 0x0227628f3F023bb0B980b67D528571c95c6DaC1c
Arg [2] : _payments (address): 0xeE6017869F117aC037f8F4b213BA95442BC877b3
Arg [3] : _serviceId (string): ERC20PoolFactory
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000001238536071e1c677a632429e3655c799b22cda52
Arg [1] : 0000000000000000000000000227628f3f023bb0b980b67d528571c95c6dac1c
Arg [2] : 000000000000000000000000ee6017869f117ac037f8f4b213ba95442bc877b3
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000080
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000010
Arg [5] : 4552433230506f6f6c466163746f727900000000000000000000000000000000
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.