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:
remove liquidity with a specified liquidity
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 operationpos_id: The object id about positioncoin_type_a: The coin type address about coinAcoin_type_b: The coin type address about coinBmin_amount_a: The minimum amount of coin A that a user can acquiremin_amount_b: The minimum amount of coin B that a user can acquiredelta_liquidity: The quantity of liquiditycollect_fee: If you already has one position, you can select collect fees while adding liquidityrewarder_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 operationpos_id: The object id about positioncoin_type_a: The coin type address about coinAcoin_type_b: The coin type address about coinBmin_amount_a: The minimum amount of coin A that a user can acquiremin_amount_b: The minimum amount of coin B that a user can acquiredelta_liquidity: The quantity of liquiditycollect_fee: If you already has one position, you can select collect fees while adding liquidityrewarder_coin_types: If these not empty, it will collect rewarder in this position, if you already open the position.
Last updated