Planned functions
The names below come from the SDK plan. Parameters and return types aren’t final, so they aren’t listed.getAmountsOutV2
Will quote how much of the last token in a path you get for an input amount. It wraps Router02’sgetAmountsOut(amountIn, path), which returns one amount per token in the path with the 0.30% pool fee already taken out.
buildSwapExactTokensForTokensV2
Will return an unsigned transaction for Router02’sswapExactTokensForTokens. It’s planned to apply a minimum output from your slippage and a deadline, and to throw SlippageTooHighError if the slippage is above the cap. You sign and send the result yourself.
Do it today
The SDK already shipsbdexV2Router02Abi and the Router02 address for both networks.
1
Quote
v2-quote.ts
2
Approve and swap
Approve Router02 to spend your input token, then call
swapExactTokensForTokens(amountIn, amountOutMin, path, to, deadline). The full, tested script is in Swap on BDEX V2. To swap native tBOT without wrapping, use swapExactETHForTokens with the amount as value, as shown in the same guide.Things the helpers will handle for you
Until then, handle these yourself:- Decimals. USDT has 6 decimals on BOT Chain. Use
TOKENSto format amounts. - Paths. For tokens without a direct pair, route through WBOT, for example
[tokenA, wbot, usdt]. - Deadlines. Build the deadline right before you send, in Unix seconds.
- Stale quotes. Quote again right before you swap. See Slippage and deadlines.
Related
BDEX V3
Concentrated liquidity pools.
Approvals
Approve before you swap.