Burn liquidity tokens
This section describes how to burn liquidity tokens to free liquidity from a pool
Free liquidity by buring liquidity pool tokens.
import TonWeb from 'tonweb';
import { Router, ROUTER_REVISION, ROUTER_REVISION_ADDRESS } from '@ston-fi/sdk';
(async () => {
const WALLET_ADDRESS = '' // YOUR WALLET ADDRESS
const WALLET_SECRET = '' // YOUR WALLET SECRET
const JETTON0 = 'EQDQoc5M3Bh8eWFephi9bClhevelbZZvWhkqdo80XuY_0qXv';
const JETTON1 = 'EQC_1YoM8RBixN95lz7odcF3Vrkc_N8Ne7gQi7Abtlet_Efi';
const provider = new TonWeb.HttpProvider();
const wallet = new TonWeb(provider).wallet.create({
address: WALLET_ADDRESS,
});
const router = new Router(provider, {
revision: ROUTER_REVISION.V1,
address: ROUTER_REVISION_ADDRESS.V1,
});
const pool = await router.getPool({
jettonAddresses: [JETTON0, JETTON1],
});
if (!pool) {
throw Error(`Pool for ${JETTON0}/${JETTON1} not found`);
}
const lpTokenWallet = await pool.getJettonWallet({ ownerAddress: WALLET_ADDRESS });
const lpTokenWalletData = await lpTokenWallet.getData();
// Build transaction params to burn all LP tokens from JETTON0/JETTON1 account
const params = await pool.buildBurnTxParams({
amount: lpTokenWalletData.balance,
responseAddress: WALLET_ADDRESS,
queryId: 12345,
});
wallet.methods.transfer({
secretKey: new TextEncoder().encode(WALLET_SECRET),
toAddress: params.to,
amount: params.gasAmount,
seqno: (await wallet.methods.seqno().call()) ?? 0,
payload: params.payload,
sendMode: 3,
});
})();
Last modified 1mo ago