Burn LP Tokens (v2)
Burn liquidity tokens on STON.fi v2 - withdraw liquidity with enhanced vault mechanics
Mainnet workflow
import { Client, dexFactory } from "@ston-fi/sdk";
import { StonApiClient } from "@ston-fi/api";
const tonClient = new Client({
endpoint: "https://toncenter.com/api/v2/jsonRPC",
apiKey: process.env.TON_API_KEY, // optional but recommended for higher rate limits
});
const apiClient = new StonApiClient();
// Discover the pool you want to exit (replace addresses with your assets)
const [poolInfo] = await apiClient.getPoolsByAssetPair({
asset0Address: "<token A address or 'ton'>",
asset1Address: "<token B address>",
});
if (!poolInfo) {
throw new Error("Liquidity pool not found for the provided asset pair");
}
// Load router metadata and initialise contracts
const routerMetadata = await apiClient.getRouter(poolInfo.routerAddress);
const dexContracts = dexFactory(routerMetadata);
const pool = tonClient.open(
dexContracts.Pool.create(poolInfo.address),
);
// Fetch the LP wallet owned by the user and read the balance
const lpWallet = tonClient.open(
await pool.getJettonWallet({ ownerAddress: "<your wallet address>" }),
);
const { balance } = await lpWallet.getWalletData();
const burnTxParams = await pool.getBurnTxParams({
amount: balance,
userWalletAddress: "<your wallet address>",
queryId: 12345,
});Testnet burn (manual setup)
Last updated