Swap
Before making a swap, you need to request the best route from the doritoKit API.
Step 1: Create a QuoteParams Object
QuoteParams Objectinterface QuoteParams {
affiliateBasisPoints?: string;
buyAsset: string;
recipientAddress?: string;
sellAmount: string;
sellAsset: string;
senderAddress?: string;
slippage: string;
}Step 2. Call getQuote from doritoKit API package
// or directly from @doritokit/api
import { SwapKitApi } from '@doritokit/sdk'
const quoteParams = {
sellAsset: 'BTC.BTC',
sellAmount: '1',
buyAsset: 'ETH.ETH',
senderAddress: '...', // A valid Ethereum address
recipientAddress: '...', // A valid Bitcoin address
slippage: '3',
};
const { routes } = await SwapKitApi.getQuote(quoteParams);Step 3: Choose fee option multiplier, route & execute swap
Last updated