Remove Liquidity
emove
There are two ways to remove liquidity:
1. Remove with Both Amounts:
// Get position and pool information
const pool = await sdk.Pool.getPool(pool_id)
const position = await sdk.Position.getPosition(position_id)
const { active_id, bin_step, bin_manager } = pool
// Get active bin information
const active_bin = await sdk.Pool.getBinInfo(bin_manager.bin_manager_handle, active_id, bin_step)
const liquidity_shares_data = parseLiquidityShares(position.liquidity_shares, bin_step, position.lower_bin_id, active_bin)
// Calculate removal amounts
const calculateOption = {
bins: liquidity_shares_data.bins,
active_id,
fix_amount_a: true,
coin_amount: '100000'
}
const bin_infos = sdk.Position.calculateRemoveLiquidityInfo(calculateOption)
// Build and send transaction
const removeOption = {
pool_id,
bin_infos,
coin_type_a: pool.coin_type_a,
coin_type_b: pool.coin_type_b,
position_id,
active_id,
slippage: 0.01,
reward_coins: [],
collect_fee: true,
reward_coins: [],
bin_step,
remove_percent: 0.5, // If remove_percent is specified, bin_infos will not be effective
}
const tx = sdk.Position.removeLiquidityPayload(removeOption)
2. Remove Only One Token:
const calculateOption = {
bins: liquidity_shares_data.bins,
active_id,
is_only_a: true, // true for token A, false for token B
coin_amount: '100000'
}
Last updated