removeLiquidityAndBurn

Remove a specific liquidity that includes follow steps:

  1. decrease liquidity

  2. collect fees

  3. collect rewards

  4. final burn

Signature

removeLiquidity(options: RemoveLiquidityOptions): Promise<Transaction>

Params

interface RemoveLiquidityOptions extends DecreaseLiquidityOptions {
  collectAmountA: string | number;
  collectAmountB: string | number;
  rewardAmounts: (string | number)[];
}

DecreaseLiquidityOptions can be found at page decreaseLiquidity

Examples

const turbosSdk = new TurbosSdk(Network.testnet, {
  url: 'https://fullnode.testnet.sui.io',
});
const signer = turbosSdk.account.getKeypairFromMnemonics("your mnemonic");
const poolId = '0xb32fb8ec0b447a833066496bd7251d3a2ee57a0a97c54bf4cc945a986235582a';
const pool = await turbosSdk.pool.getPool(poolId);
const positionId =
  '0x3b457840790091866473be5fd0365f988d220b593d3af09040daea1dc7bcdf60';
const position = await turbosSdk.nft.getPositionFields(positionId);
const txb = await turbosSdk.pool.removeLiquidity({
  pool: poolId,
  decreaseLiquidity: position.liquidity,
  nft: positionId,
  amountA: position.tokens_owed_a,
  amountB: position.tokens_owed_b,
  slippage: 3,
  address: signer.toSuiAddress(),
  collectAmountA: MAX_UINT_64.toString(), // The maximum value of u64 can be passed in, so the contract will automatically handle extracting all fees.
  collectAmountB: MAX_UINT_64.toString(),
  rewardAmounts: pool.reward_infos.map(() => MAX_UINT_64.toString()),
  deadline: Date.now() + 60 * 60 * 1000,
});
txb.setSender(signer.toSuiAddress());
const result = await turbosSdk.provider.signAndExecuteTransaction({
  transaction: txb,
  signer,
});
console.log(result);

collectAmountA,collectAmountB,rewardAmounts

Pass in the desired number to extract, along with the maximum u64 value, letting the contract automatically handle the extraction process.

Last updated