Remove liquidity

When you want to adjust the liquidity of your position or withdraw liquidity from the position, you can use the following method.

When you withdraw liquidity, you also have the option to collect fees or rewards at the same time. Please refer to the parameter description below for more details.

There are two situations:

  1. remove liquidity with a specified liquidity

  2. remove liquidity with fixed coin amount.

1. Remove liquidity by inputting liquidity value

Use sdk.Position.removeLiquidityPayload() method.

Function Parameters

  • pool_id: The object id about which pool you want to operation

  • pos_id: The object id about position

  • coin_type_a: The coin type address about coinA

  • coin_type_b: The coin type address about coinB

  • min_amount_a: The minimum amount of coin A that a user can acquire

  • min_amount_b: The minimum amount of coin B that a user can acquire

  • delta_liquidity: The quantity of liquidity

  • collect_fee: If you already has one position, you can select collect fees while adding liquidity

  • rewarder_coin_types: If these not empty, it will collect rewarder in this position, if you already open the position

Important Notes

  • Because of pool price will change, the amount of coin A and coin B will change. So the min_amount_a and min_amount_b means no matter how the price moves, the amount quantity that I need to receive at least is typically obtained by adding the amount potentially acquired through calculations to the slippage adjustment.

Example

2. Remove liquidity with a fixed coin amount

Use sdk.Position.removeLiquidityPayload() method.

Function Parameters

  • pool_id: The object id about which pool you want to operation

  • pos_id: The object id about position

  • coin_type_a: The coin type address about coinA

  • coin_type_b: The coin type address about coinB

  • min_amount_a: The minimum amount of coin A that a user can acquire

  • min_amount_b: The minimum amount of coin B that a user can acquire

  • delta_liquidity: The quantity of liquidity

  • collect_fee: If you already has one position, you can select collect fees while adding liquidity

  • rewarder_coin_types: If these not empty, it will collect rewarder in this position, if you already open the position.

Last updated