swap
Swap from one coin to another one with specific pools.
Signature
swap(options: SwapOptions): Promise<Transaction>
Params
interface SwapOptions {
routes: Array<{
// Pool object ID
pool: string;
// Swap from coinA to coinB
a2b: boolean;
// computed next tick index
nextTickIndex: number;
}>;
// Coin A address
coinTypeA: string;
// Coin B address
coinTypeB: string;
// User's wallet address
address: string;
// Amount of coinA
amountA: string | number;
// Amount of coinB
amountB: string | number;
// When `true`, amountA is input by user.
// When `false`, amountB is input by user.
amountSpecifiedIsInput: boolean;
// Acceptable wasted amount percentage. Range: [0, 100)
slippage: string | number;
// Expires timeout(ms), defaults 60_000
deadline?: number;
// Custom transaction handler
txb?: Transaction;
}Examples
Last updated