Contains data for swap exact input with a single pool.
ExactInputSingleParams
address tokenIn; // source token to swap
address tokenOut; // dest token to receive
uint16 fee; // fee of the pool to swap
address recipient; // the recipient of tokenOut
uint256 deadline; // deadline for the transaction
uint256 amountIn; // the amount of tokenIn to swap
uint256 minAmountOut;// min acceptable amount of tokenOut
uint160 limitSqrtP; // the limit of sqrt price, partial swap if price reaches the limitation
Contains data for swap exact input with one or multiple pools.
ExactInputParams
bytes path; // contains data to identify list of pools to use for the swap
address recipient; // the recipient of token out
uint256 deadline; // deadline for the transaction
uint256 amountIn; // the amount of token in to swap
uint256 minAmountOut; // the min acceptable amount of token out
Callback function that is be triggerred by the pool when swapping tokens. Either deltaQty0 or deltaQty1 must be positive. Positive value means the pool (also the caller) is expecting to receive that amount of token.
Given the params of ExactInputSingleParams, it uses only one pool to swap exact an amountIn of tokenIn to tokenOut and return the amount of tokenOut from the swap. It calls the swap function in the pool contract, the pool will transfer the tokenOut to the Router, and expect to receive the corresponding tokenIn in the swap callback function.
Given the params of ExactInputParams, it uses only one or multiple pools that can be decoded from the path. It calls the swap function in each pool contract that is decoded from the path param, and uses callback to handle transferring tokens.
Given the params of ExactOutputParams, it uses one or multiple pools that can be decoded from the path. It calls the swap function in each pool contract that is decoded from the path param, and uses callback to handle transferring tokens. The list of pools in the path params should be in the reverse order, i.e the last pool first since we don't know the exact amount of token in to be used.
Inherit from an ERC721 contract, it stores all positions of all liquidity providers and mint corresponding NFT.
Users can use the PositionManager to create & unlock pool, mint new position, add/remove liquidity to/from an existing position and burn their reinvestment tokens to receive back the LP fees.
It also inherits from Multicall contract, thus, users can make multiple function/method calls to the PositionManager in a single transaction.
All reinvestment tokens will be held in the contract, thus, it blocks anyone from transferring reinvestment tokens out. As a result, the contract can not support pools with any reinvestment tokens.
Call the _addLiquidity function in the LiquidityHelper contract with the data from *params. It mints a new NFT token represents the position to the recipient, stores the position data and pool information.
Call the _addLiquidity function in the LiquidityHelper contract with the data from params to add more liquidity to a given position (i.e tokenId). Calculate and update the additional reinvestment tokens that the position should have earned.
Call the burn function in the pool contract with the data from params to remove liquidity and get back 2 tokens. Calculate and update the additional reinvestment tokens that the position should have earned.
Call the burnRTokens function in the pool contract to burn all reinvestment tokens from the position and get back 2 tokens. Return the amount of reinvestment tokens to burn and expected amounts of 2 tokens to receive
ExactOutputSingleParams:
address tokenIn; // source token to swap
address tokenOut; // dest token to receive
uint16 fee; // fee of the pool
address recipient; // the recipient of tokenOut
uint256 deadline; // deadline for the transaction
uint256 amountOut; // the amount of tokenOut to expect
uint256 maxAmountIn;// the max amount of tokenIn that is allowed to use
uint160 limitSqrtP; // the limit of sqrt price, partial swap if price reaches the limitation
MintParams
address token0; // the token0 of the pool
address token1; // token1 of the pool, must make sure that token0 < token1
uint16 fee; // the pool's fee in bps
int24 tickLower; // the position's lower tick
int24 tickUpper; // the position's upper tick
int24[2] ticksPrevious; // the nearest tick that has been initialized and lower than or equal to the tickLower and tickUpper, use to help insert the tickLower and tickUpper if haven't initialized
uint256 amount0Desired; // the desired amount for token0
uint256 amount1Desired; // the desired amount for token1
uint256 amount0Min; // min amount of token 0 to add
uint256 amount1Min; // min amount of token 1 to add
address recipient; // the owner of the position
uint256 deadline; // time that the transaction will be expired
IncreaseLiquidityParams
uint256 tokenId // id of the position to increase its liquidity
uint256 amount0Desired // the desired amount for token0
uint256 amount1Desired // the desired amount for token1
uint256 amount0Min // min amount of token 0 to add
uint256 amount1Min // min amount of token 1 to add
uint256 deadline // time that the transaction will be expired
RemoveLiquidityParams
uint256 tokenId // id of the position to remove its liquidity
uint256 amount0Min // min amount of token 0 to receive
uint256 amount1Min // min amount of token 1 to receive
uint256 deadline // time that the transaction will be expired
BurnRTokenParams
uint256 tokenId // id of the position to burn r token
uint256 amount0Min // min amount of token 0 to receive
uint256 amount1Min // min amount of token 1 to receive
uint256 deadline // time that the transaction will be expired
Params:
address token0;
address token1;
uint16 fee;
uint160 currentSqrtP
Returns:
address pool // deployed pool given the set of params