Swap (v0.5)
Legacy v0.5 swap guide - exchange TON for Jettons using deprecated SDK
Swap TON to jetton
import TonWeb from "tonweb";
import { DEX, pTON } from "@ston-fi/sdk";
const router = new DEX.v1.Router({
tonApiClient: new TonWeb.HttpProvider(),
});
// swap 1 TON to STON but not less than 1 nano STON
const txParams = await router.buildSwapTonToJettonTxParams({
userWalletAddress: "", // ! replace with your address
proxyTonAddress: pTON.v1.address,
offerAmount: new TonWeb.utils.BN("1000000000"),
askJettonAddress: "EQA2kCVNwVsil2EM2mB0SkXytxCqQjS4mttjDpnXmwG9T6bO", // STON
minAskAmount: new TonWeb.utils.BN("1"),
queryId: 12345,
});
// To execute the transaction, you need to send a transaction to the blockchain.
// This code will be different based on the wallet you are using to send the tx from
// logging is used for demonstration purposes
console.log({
to: txParams.to,
amount: txParams.gasAmount,
payload: txParams.payload,
});Swap jetton to jetton
Swap jetton to TON
Recommended gas values
Type
Tx TON
Forward TON
Formulas:
Last updated