Unanswered
STON.fi Simple TON -> USDT Swap
I'm trying to do a simple TON -> USDT swap on STON.fi. It seems to be more difficult than anticipated. See below for function. Any advise will be appreciated. The transaction goes through but I don't receive the tokens.
async function stonfi(mnemonic) {
const keyPair = await mnemonicToWalletKey(mnemonic.split(' '));
const tonweb = new TonWeb(new TonWeb.HttpProvider('https://toncenter.com/api/v2/jsonRPC', { apiKey: 'e4cf6......' }));
const WalletClass = tonweb.wallet.all.v4R2;
const wallet = new WalletClass(tonweb.provider, {
publicKey: keyPair.publicKey,
});
const address = await wallet.getAddress();
const JETTON0 = 'EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA'; //USDT;
const PROXY_TON = 'EQCM3B12QK1e4yZSf8GtBRT0aLMNyEsBc_DhVfRRtOEffLez';
const router = new Router(tonweb.provider, {
revision: ROUTER_REVISION.V1,
address: ROUTER_REVISION_ADDRESS.V1,
});
const tonToJettonTxParams = await router.buildSwapProxyTonTxParams({
// address of the wallet that holds TON you want to swap
userWalletAddress: address,
proxyTonAddress: PROXY_TON,
// amount of the TON you want to swap
offerAmount: new TonWeb.utils.BN('1000000'),
// address of the jetton you want to receive
askJettonAddress: JETTON0,
// minimal amount of the jetton you want to receive as a result of the swap.
// If the amount of the jetton you want to receive is less than minAskAmount
// the transaction will bounce
minAskAmount: new TonWeb.utils.BN(1),
// query id to identify your transaction in the blockchain (optional)
queryId: 12345,
// address of the wallet to receive the referral fee (optional)
referralAddress: undefined,
});
const seqno = (await wallet.methods.seqno().call()) || 0;
var result = await wallet.methods
.transfer({
secretKey: keyPair.secretKey,
toAddress: ROUTER_REVISION_ADDRESS.V1,
amount: '1000000',
seqno: seqno,
payload: tonToJettonTxParams.payload
})
.send();
}
8K Views
0
Answers
10 months ago
10 months ago
Tags
Similar posts