Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escape special characters +-&|!(){}[]^"~*?:\ - e.g. \+ \* \!
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
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();
}
-1
-1
Posted 10 months ago
Votes Newest

Answers