Technical Reference
V2Pool Deployer
Deploy: Deploys a pool with the given parameters by transiently setting the parameters storage slot and then clearing it after deploying the pool.
V2Factory
CreatePool: Creates a pool for the given two tokens and fee. 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.
SetOwner: Updates the owner of the factory. Must be called by the current owner
EnableFeeAmount: Enables a fee amount with the given tickSpacing. Enables a fee amount with the given tickSpacing
Pool
_blockTimestamp: Returns the block timestamp truncated to 32 bits, i.e. mod 2^32. This method is overridden in tests.
SnapshotCumulativesInside: Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range. 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.
Observe: Returns the cumulative tick and liquidity as of each timestamp secondsAgo
from the current block timestamp. 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]. 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.
IncreaseObservationCardinalityNext: Increase the maximum number of price and liquidity observations that this pool will store. This method is no-op if the pool already has an observationCardinalityNext greater than or equal to the input observationCardinalityNext.
Initialize: Sets the initial price for the pool. not locked because it initializes unlocked
Mint: Adds liquidity for the given recipient/tickLower/tickUpper position. noDelegateCall is applied indirectly via _modifyPosition
Collect: Collects tokens owed to a position. 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.
Burn: Burn liquidity from the sender and account tokens owed for the liquidity to the position. noDelegateCall is applied indirectly via _modifyPosition
Swap: Swap token0 for token1, or token1 for token0. The caller of this method receives a callback in the form of IV2SwapCallback
SetFeeProtocol: Set the denominator of the protocol's % share of the fees
CollectProtocol: Collect the protocol fee accrued to the pool********
NonfungiblePositionManager
Positions: Returns the position information associated with a given token ID.
mint: Creates a new position wrapped in a NFT. 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.
tokenURI: Returns a URI describing a particular token ID
baseURI
increaseLiquidity: Increases the amount of liquidity in a position, with tokens paid by the msg.sender
decreaseLiquidity: Decreases the amount of liquidity in a position and accounts it to the position
Collect: Collects up to a maximum amount of fees owed to a specific position to the recipient. The account that should receive the tokens, amount0Max The maximum amount of token0 to collect, amount1Max The maximum amount of token1 to collect
Burn: Burns a token ID, which deletes it from the NFT contract. The token must have 0 liquidity and all tokens must be collected first.
_getAndIncrementNonce
getApproved: Returns the account approved for tokenId
token. Requirements
_approve: Overrides _approve to use the operator in the position, which is packed with the position permit nonce
NonfungibleTokenPositionDescriptor
tokenURI: Produces the URI describing a particular token ID for a position manager. Note this URI may be a data: URI with the JSON contents directly inlined
flipRatio
tokenRatioPriority
IUniswapV3SwapCallback
Called to msg.sender
after executing a swap via IPearlV2Pool.
In the implementation you must pay the pool tokens owed for the swap. The caller of this method must be checked to be a V2Pool deployed by the canonical PearlV2Factory. amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
IUniswapV3MintCallback
Called to msg.sender
after minting liquidity to a position from IPearlV2Pool. In the implementation you must pay the pool tokens owed for the minted liquidity. The caller of this method must be checked to be a V2Pool deployed by the canonical PearlV2Factory.
Swap Router
Use special swap routes exactInputSingleFeeOnTransfer
and exactInputFeeOnTransfer
, specifically designed to handle rounding for rebase and fee-on-transfer tokens.
Single Swap
MultiHop
Last updated