Position

Function Interface introduction

1. Increase Liquidity

  • Contract Interface

    • 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
          );
  • Param Explanation

    • tokenId (uint256): Identifier of the token position for which liquidity is being increased. This ID is unique to the position within the liquidity pool and is used to track and manage the corresponding liquidity.

    • amount0Desired (uint256): The desired amount of token0 that the caller wishes to contribute to the liquidity pool. This value represents how much of token0 the caller is willing to spend to increase liquidity.

    • amount1Desired (uint256): Similar to amount0Desired, this is the desired amount of token1 that the caller is willing to contribute to the pool.

    • amount0Min (uint256): The minimum acceptable amount of token0 that must be spent to prevent significant price slippage. This parameter is crucial for ensuring that the caller does not experience unfavorable trade conditions due to market volatility.

    • amount1Min (uint256): The minimum acceptable amount of token1 that must be spent, serving the same purpose as amount0Min for token1.

    • deadline (uint256): A UNIX timestamp specifying the latest time by which the transaction must be mined for the liquidity increase to take effect. This safeguard prevents the transaction from being executed under possibly changed market conditions

2. Mint(Open Position)

  • Contract Interface

  • Param Explanation

    • token0 (address): The contract address of the first token in the token pair for which liquidity is being provided.

    • token1 (address): The contract address of the second token in the pair.

    • fee (uint24): The fee tier of the pool to which liquidity is being added. Fees are typically specified in basis points (e.g., 500 for a 0.05% fee).

    • tickLower (int24): The lower bound of the desired price range for the position. In the Uniswap v3 context, ticks are used to define price ranges within which liquidity is active.

    • tickUpper (int24): The upper bound of the price range.

    • amount0Desired (uint256): The desired amount of token0 to be contributed to the pool.

    • amount1Desired (uint256): The desired amount of token1 to be contributed.

    • amount0Min (uint256): The minimum amount of token0 that must be contributed, serving as a protection against slippage.

    • amount1Min (uint256): The minimum amount of token1 that must be contributed, similarly serving as slippage protection.

    • recipient (address): The address that will receive the NFT representing the liquidity position.

    • deadline (uint256): A UNIX timestamp indicating the latest time by which the transaction must be executed

3. Decrease Liquidity

  • Contract Interface

  • Param Explanation

    • tokenId (uint256): The identifier of the token position from which liquidity is being withdrawn. This unique ID is associated with a specific liquidity provision within the pool.

    • liquidity (uint128): The magnitude of liquidity to be removed from the position. This value dictates how much of the position's current liquidity will be decreased.

    • amount0Min (uint256): The minimum amount of token0 that must be received for the liquidity being removed. This serves as a safeguard against slippage, ensuring that the liquidity provider does not receive less than this threshold.

    • amount1Min (uint256): Similar to amount0Min, this is the minimum amount of token1 that must be accounted for when the specified liquidity is removed from the pool.

    • deadline (uint256): A UNIX timestamp indicating the latest time by which the transaction must be executed to apply the liquidity decrease. This parameter is crucial for timing the operation according to market conditions and the liquidity provider's strategy.

4. Collect Fee

  • Contract Interface

  • Param Explanation

    • tokenId (uint256): The identifier of the NFT representing the liquidity position from which fees are being collected. This NFT ID is unique and directly correlates with a specific liquidity provision within the pool.

    • recipient (address): The address to which the collected fees will be sent. This allows the fees to potentially be directed to a different account than the one executing the transaction.

    • amount0Max (uint128): The maximum amount of the first token (token0) in the pair that should be collected as fees. This acts as a cap to prevent accidental collection of unexpected amounts.

    • amount1Max (uint128): Similar to amount0Max, this is the maximum amount of the second token (token1) that should be collected as fees.

5. Close position (burn)

  • Contract Interface

  • Param Explanation

    • tokenId (uint256): The unique identifier of the NFT that is to be burned. This ID corresponds to a specific liquidity position or other forms of representation within the NFT contract.

6. Stake

  • Contract Interface function safeTransferFrom(

  • Param Explannation

    • from(address): The address of user.

    • to(address): The contract address of MasterChefV3.

    • tokenId(address): The unique identifier of the NFT that is to be staked. This ID corresponds to a specific liquidity position or other forms of representation within the NFT contract.

7. Collect Reward

  • Contract Interface

  • Param Explannation

    • _to(address): The address of user.

    • _tokenId(uint256): The unique identifier of the NFT that is to collect reward. This ID corresponds to a specific liquidity position or other forms of representation within the NFT contract.

8. Unstake

  • Contract Interface

  • Param Explannation

    • _tokenId(uint256): The unique identifier of the NFT that is to unstake. This ID corresponds to a specific liquidity position or other forms of representation within the NFT contract.

    • _to(address): The address of user.

Last updated