Liquidity Provision
Mint
Function:
mint
Pull liquidity of a token pair from
msg.sender
(should have approved enough amount), provide liquidity to Uniswap v3 pool, keep the liquidity position NFT in Particle contract. At the same time, createLiquidityPosition.Info
to bookkeep the ownership oftokenId
tomsg.sender
.
Increase liquidity
Function:
increaseLiquidity
Increase liquidity to existing
tokenId
via Uniswap’s NonfungiblePositionManager.Note: there are two internal functions of
increaseLiquidity
. The external facing one (takeslps
storage as calldata input) authenticates the caller. The inner function is used in two cases: (1) this external facing function for an LP to add liquidity and (2) returning liquidity back to LP when closing a position in_closePosition
.
Decrease liquidity
Function:
decreaseLiquidity
Decrease liquidity from existing
tokenId
via Uniswap’s NonfungiblePositionManager.Note: the decreased liquidity is stored in owed tokens. Withdrawing the actual amount needs the
collectLiquidity
function below.Note: similar to
increaseLiquidity
, there are two internal functions ofdecreaseLiquidity
. The external one (takeslps
storage as calldata input) authenticates the caller. The inner function is used in two cases: (1) this external facing function for an LP to decrease liquidity and (2) borrowing liquidity from an LP position inopenPosition
.
Collect liquidity
Function:
collectLiquidity
Collect fees and liquidity from owed tokens to the caller (LP) wallet.
Note: there are two internal functions of
collectLiquidity
. The external one (takeslps
storage as calldata input) authenticates the caller. The inner function is used in two cases: (1) this external facing function for an LP to collect fees and (2) borrowing liquidity from an LP position inopenPosition
.Note: this function imposes
amountMax
such that borrowing liquidity wouldn’t withdraw more amounts than requested.
Last updated