Old swap params - V1
These parameters will not be deprecated.
1. Build fast swap transaction.
import { AggregatorClient } from "@cetusprotocol/aggregator-sdk"
import { Transaction } from '@mysten/sui/transactions';
import BN from "bn.js"
const client = new AggregatorClient()
const amount = new BN(1000000)
const from = "0x2::sui::SUI"
const target = "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS"
const routers = await client.findRouters({
from,
target,
amount,
byAmountIn: true, // `true` means fix input amount, `false` means fix output amount
})
const txb = new Transaction()
await client.fastRouterSwap({
routers: routerRes.routes,
byAmountIn,
txb,
slippage: 0.01,
isMergeTragetCoin: true,
refreshAllCoins: true,
})2. Build swap transaction and return target coin object.
Last updated