This section describes how to refund tokens that were sent to lp account but weren't added to a liquidity pool yet
Refund tokens deposited on liquidity pool account but not added to a liquidity pool yet.
import TonWeb from'tonweb';import { Router, ROUTER_REVISION, ROUTER_REVISION_ADDRESS } from'@ston-fi/sdk';/** * This example shows how to refund liquidity from the your lp-account */(async () => {constWALLET_ADDRESS=''; // ! replace with your addressconstJETTON0='EQA2kCVNwVsil2EM2mB0SkXytxCqQjS4mttjDpnXmwG9T6bO'; // STONconstJETTON1='EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA'; // jUSDTconstprovider=newTonWeb.HttpProvider();constrouter=newRouter(provider, { revision:ROUTER_REVISION.V1, address:ROUTER_REVISION_ADDRESS.V1, });constpool=awaitrouter.getPool({ jettonAddresses: [JETTON0,JETTON1], });if (!pool) {throwError(`Pool for ${JETTON0}/${JETTON1} not found`); }constlpAccount=awaitpool.getLpAccount({ ownerAddress:WALLET_ADDRESS });if (!lpAccount) {throwError(`LpAccount for ${WALLET_ADDRESS} at ${JETTON0}/${JETTON1} pool not found`, ); }// transaction to refund all tokens from JETTON0/JETTON1 lp-account contractconstrefundTxParams=awaitlpAccount.buildRefundTxParams({// query id to identify your transaction in the blockchain (optional) queryId:12345, });// to execute the transaction you need to send transaction to the blockchain// (replace with your wallet implementation, logging is used for demonstration purposes)console.log({ to:refundTxParams.to, amount:refundTxParams.gasAmount, payload:refundTxParams.payload, });})();