Skip to content
SwapKit is a powerful suite of tools for building blockchain applications.

Performing Swaps

SwapKit provides a unified interface for swapping tokens across different chains and protocols. This guide covers how to get quotes and execute swaps using both the granular and all-in-one approaches.

You can use SwapKit in two ways:

  1. Granular approach - Import only what you need from individual packages (recommended for frontend):

    import { 
    function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
        config?: SKConfigState;
        plugins?: Plugins;
        wallets?: Wallets;
    }): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
        ...;
    }
    SwapKit
    } from "@swapkit/core";
    import {
    const ThorchainPlugin: {
        thorchain: (pluginParams: SwapKitPluginParams) => {
            supportedSwapkitProviders: ProviderName[];
        } & {
            addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
            ... 12 more ...;
            withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
        };
    }
    ThorchainPlugin
    } from "@swapkit/plugins/thorchain";
    import {
    const evmWallet: {
        connectEVMWallet: {
            connectWallet: (connectParams: {
                addChain: AddChainType;
            }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
            supportedChains: EVMChain[];
        };
    }
    evmWallet
    } from "@swapkit/wallets/evm-extensions";
  2. All-in-one approach - Import everything from the SDK (better for backend/Node.js):

    import { 
    function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
        chainflip: {
            supportedSwapkitProviders: ProviderName[];
        } & {
            swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
        };
        ... 5 more ...;
        solana: {
            ...;
        } & {
            ...;
        };
    } & {
        ...;
    } & {
        ...;
    }
    createSwapKit
    } from "@swapkit/sdk";

The typical flow for performing a swap consists of these steps:

  1. Initialize SwapKit and connect wallets
  2. Get a quote for the swap
  3. Approve tokens (if needed)
  4. Execute the swap transaction
import { enum ChainChain } from "@swapkit/helpers";
import { 
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from "@swapkit/core";
import {
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
} from "@swapkit/wallets/evm-extensions";
import {
const keystoreWallet: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 21 more ...;
            SOL?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 18 more ... | Chain.Solana)[];
    };
}
keystoreWallet
} from "@swapkit/wallets/keystore";
import {
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
} from "@swapkit/plugins/thorchain";
import {
const EVMPlugin: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}
EVMPlugin
} from "@swapkit/plugins/evm";
// Initialize SwapKit with necessary plugins and wallets const
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    evm: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
    thorchain: (pluginParams: SwapKitPluginParams) => {
        ...;
    } & {
        ...;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
config?: SKConfigState | undefinedconfig: {
apiKeys?: Partial<{
    blockchair: string;
    kado: string;
    keepKey: string;
    swapKit: string;
    walletConnectProjectId: string;
}> | undefined
apiKeys
: {
swapKit?: string | undefinedswapKit: "your-swapkit-api-key", blockchair?: string | undefinedblockchair: "your-blockchair-api-key", walletConnectProjectId?: string | undefinedwalletConnectProjectId: "your-walletconnect-project-id", }, },
plugins?: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} | undefined
plugins
: { ...
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
, ...
const EVMPlugin: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}
EVMPlugin
},
wallets?: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 21 more ...;
            SOL?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 18 more ... | Chain.Solana)[];
    };
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
} | undefined
wallets
: { ...
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
, ...
const keystoreWallet: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 21 more ...;
            SOL?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 18 more ... | Chain.Solana)[];
    };
}
keystoreWallet
},
}); // Connect necessary wallets async function function connectWallets(): Promise<void>connectWallets() { // Connect EVM wallet for Ethereum await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    evm: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum]);
// If doing cross-chain swaps, connect other chains as needed // For example, to swap from ETH to BTC: await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    evm: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
    ARB?: DerivationPathArray | undefined;
    AVAX?: DerivationPathArray | undefined;
    ... 20 more ...;
    SOL?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore
([enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin], "your secret phrase here");
const const connectedWallets: string[]connectedWallets = var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
Object
.ObjectConstructor.keys(o: {}): string[] (+1 overload)
Returns the names of the enumerable string properties and methods of an object.
@paramo Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
keys
(
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    evm: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
getAllWallets: () => {
    ARB: ChainWallet<Chain.Arbitrum> & {
        estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
            feeOption: FeeOption;
            chain: EVMChain;
        }) => Promise<...>;
        ... 20 more ...;
        validateAddress: (address: string) => boolean;
    };
    ... 21 more ...;
    SOL: ChainWallet<...> & {
        ...;
    };
}
getAllWallets
());
}
import { enum ChainChain } from "@swapkit/helpers";
import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    solana: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
} from "@swapkit/sdk";
// Initialize SwapKit with all plugins and wallets included const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    solana: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    solana: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
({
config?: SKConfigState | undefinedconfig: {
apiKeys?: Partial<{
    blockchair: string;
    kado: string;
    keepKey: string;
    swapKit: string;
    walletConnectProjectId: string;
}> | undefined
apiKeys
: {
swapKit?: string | undefinedswapKit: "your-swapkit-api-key", blockchair?: string | undefinedblockchair: "your-blockchair-api-key", walletConnectProjectId?: string | undefinedwalletConnectProjectId: "your-walletconnect-project-id", }, }, }); // Connect necessary wallets async function function connectWallets(): Promise<void>connectWallets() { // Connect wallets for the chains involved in the swap await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    solana: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
    ARB?: DerivationPathArray | undefined;
    AVAX?: DerivationPathArray | undefined;
    ... 20 more ...;
    SOL?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore
(
[enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum, enum ChainChain.function (enum member) Chain.Bitcoin = "BTC"Bitcoin], "your secret phrase here" ); }

Before executing a swap, you need to get a quote to see available routes, prices, and fees:

import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
// Basic swap quote async function function getSwapQuote(): Promise<any>getSwapQuote() { // Define the assets to swap const const sellAsset: "ETH.ETH"sellAsset = "ETH.ETH"; // Ethereum on Ethereum chain const const buyAsset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"buyAsset = "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; // USDC on Ethereum const const sellAmount: "0.1"sellAmount = "0.1"; // 0.1 ETH try { // Get quotes from all available providers const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset, buyAsset: stringbuyAsset, sellAmount: stringsellAmount, sourceAddress?: string | undefinedsourceAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", slippage?: number | undefinedslippage: 1, }); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success) {
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
(`Failed to get quote: ${
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.error?: string | undefinederror}`);
} // Routes sorted by best rate const const routes: anyroutes =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes;
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// Found ${routes.length} routes for swapping ${sellAmount} ${sellAsset} to ${buyAsset}` // Best rate: 1 ETH = ${Number(routes[0].buyAmount) / Number(sellAmount)} USDC` return const routes: anyroutes; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } } // Get quotes from a specific provider async function function getProviderQuote(): Promise<any>getProviderQuote() { const { const ProviderName: typeof ProviderNameProviderName } = await import("@swapkit/helpers"); // For example, get quotes only from Uniswap V3 const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", buyAsset: stringbuyAsset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", sellAmount: stringsellAmount: "0.1", providers?: string[] | undefinedproviders: [const ProviderName: typeof ProviderNameProviderName.function (enum member) ProviderName.UNISWAP_V3 = "UNISWAP_V3"UNISWAP_V3], // Specify provider(s) sourceAddress?: string | undefinedsourceAddress: "0x742d35Cc6634C0532925a3b844Bc454e4438f44e", }); return
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data?.routes || [];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
}

Once you have a quote, you can execute the swap:


import {
  class AssetValueAssetValue,
  enum ChainChain,
  enum FeeOptionFeeOption,
  enum ProviderNameProviderName,
} from "@swapkit/helpers";
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
import {
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from "@swapkit/core";
import {
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
} from "@swapkit/wallets/evm-extensions";
import {
const EVMPlugin: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}
EVMPlugin
} from "@swapkit/plugins/evm";
// Initialize SwapKit with necessary plugins and wallets const
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
plugins?: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} | undefined
plugins
: { ...
const EVMPlugin: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}
EVMPlugin
},
wallets?: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
} | undefined
wallets
: { ...
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
},
}); // Connect wallet await
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum]);
// Complete swap flow async function
function executeSwap(): Promise<{
    txHash: string;
    txUrl: string;
}>
executeSwap
() {
try { // 1. Get quotes const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", buyAsset: stringbuyAsset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", sellAmount: stringsellAmount: "0.1", sourceAddress?: string | undefinedsourceAddress:
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
slippage?: number | undefinedslippage: 1, }); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success || !
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes.length) {
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
("No swap routes available");
} // 2. Select the best route (first one is usually best rate) const const selectedRoute: anyselectedRoute =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes[0];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// 3. Create asset value for approvals const const assetValue: AssetValueassetValue = await class AssetValueAssetValue.
AssetValue.from<{
    asset: any;
    value: any;
    asyncTokenLookup: true;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: any;
    value: any;
    asyncTokenLookup: true;
} & AssetValueFromParams): Promise<AssetValue>
from
({
asset: anyasset: const selectedRoute: anyselectedRoute.sellAsset, value: anyvalue: const selectedRoute: anyselectedRoute.sellAmount, asyncTokenLookup: trueasyncTokenLookup: true, }); // 4. Check if we need to approve tokens (for ERC20 tokens) if (!const assetValue: AssetValueassetValue.AssetValue.isGasAsset: booleanisGasAsset && const selectedRoute: anyselectedRoute.tx) { const const isApproved: booleanisApproved = await
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.isAssetValueApproved: (assetValue: AssetValue, contractAddress: string) => Promise<boolean>isAssetValueApproved(
const assetValue: AssetValueassetValue, const selectedRoute: anyselectedRoute.tx.from ); if (!const isApproved: booleanisApproved) { // "Approval needed, approving tokens..." await
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.approveAssetValue: (assetValue: AssetValue, contractAddress: string) => Promise<string>approveAssetValue(const assetValue: AssetValueassetValue, const selectedRoute: anyselectedRoute.tx.from);
// "Tokens approved!" } } // 5. Execute the swap const const txHash: stringtxHash = await
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"evm">({ route, pluginName, ...rest }: SwapParams<"evm", {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
route: {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
: const selectedRoute: anyselectedRoute,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast, }) as string; // 6. Get transaction URL const const txUrl: stringtxUrl =
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
getExplorerTxUrl: ({ chain, txHash }: {
    txHash: string;
    chain: Chain;
}) => string
getExplorerTxUrl
({ chain: Chainchain: const assetValue: AssetValueassetValue.AssetValue.chain: Chainchain as enum ChainChain, txHash: stringtxHash });
return { txHash: stringtxHash, txUrl: stringtxUrl }; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } }
import {
  class AssetValueAssetValue,
  enum ChainChain,
  enum FeeOptionFeeOption,
} from "@swapkit/helpers";
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
import {
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    solana: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<...>;
    };
    ... 5 more ...;
    radix: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
} from "@swapkit/sdk";
// Initialize SwapKit const
const swapKit: {
    solana: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<...>;
    };
    ... 5 more ...;
    radix: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    solana: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<...>;
    };
    ... 5 more ...;
    radix: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
// Connect wallet await
const swapKit: {
    solana: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<...>;
    };
    ... 5 more ...;
    radix: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
    ARB?: DerivationPathArray | undefined;
    AVAX?: DerivationPathArray | undefined;
    ... 20 more ...;
    SOL?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore
([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum], "your secret phrase here");
// Execute swap async function function executeSwap(): Promise<any>executeSwap() { try { // 1. Get quotes const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", buyAsset: stringbuyAsset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", sellAmount: stringsellAmount: "0.1", sourceAddress?: string | undefinedsourceAddress:
const swapKit: {
    solana: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<...>;
    };
    ... 5 more ...;
    radix: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
}); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success || !
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes.length) {
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
("No swap routes available");
} // 2. Select the best route const const selectedRoute: anyselectedRoute =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes[0];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// 3. Execute the swap const const txHash: anytxHash = await
const swapKit: {
    solana: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: ({ route }: SwapParams<"solana", QuoteResponseRoute>) => Promise<...>;
    };
    ... 5 more ...;
    radix: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"solana" | "chainflip" | "evm" | "kado" | "mayachain" | "thorchain" | "radix">({ route, pluginName, ...rest }: SwapParams<"solana" | "chainflip" | "evm" | "kado" | "mayachain" | "thorchain" | "radix", {
    sellAsset: string;
    ... 18 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
route: {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
: const selectedRoute: anyselectedRoute,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast, }); return const txHash: anytxHash; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } }

SwapKit supports cross-chain swaps through ChainFlip:

import {
  enum ChainChain,
  enum FeeOptionFeeOption,
  enum ProviderNameProviderName,
} from "@swapkit/helpers";
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
import {
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from "@swapkit/core";
import {
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
} from "@swapkit/wallets/evm-extensions";
import {
const ChainflipPlugin: {
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
}
ChainflipPlugin
} from "@swapkit/plugins/chainflip";
// Initialize SwapKit with necessary plugins const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
plugins?: {
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
} | undefined
plugins
: { ...
const ChainflipPlugin: {
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
}
ChainflipPlugin
},
wallets?: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
} | undefined
wallets
: { ...
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
},
config?: SKConfigState | undefinedconfig: { integrations?: Partial<SKConfigIntegrations> | undefinedintegrations: {
chainflip?: {
    useSDKBroker?: boolean;
    brokerUrl: string;
} | undefined
chainflip
: {
brokerUrl: stringbrokerUrl: "https://broker.chainflip.io", // ChainFlip broker URL }, }, }, }); // Connect source chain wallet (Ethereum) await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum]);
// Perform a cross-chain swap from ETH to BTC async function
function crossChainSwap(): Promise<{
    txHash: any;
}>
crossChainSwap
() {
try { // Get cross-chain quotes const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", // Ethereum buyAsset: stringbuyAsset: "BTC.BTC", // Bitcoin sellAmount: stringsellAmount: "0.1", // 0.1 ETH providers?: string[] | undefinedproviders: [enum ProviderNameProviderName.function (enum member) ProviderName.CHAINFLIP = "CHAINFLIP"CHAINFLIP], // Use ChainFlip for cross-chain sourceAddress?: string | undefinedsourceAddress:
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
destinationAddress?: string | undefineddestinationAddress: "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", // BTC destination }); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success || !
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes.length) {
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
("No cross-chain swap routes available");
} // Select the route const const route: anyroute =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes[0];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// Execute the cross-chain swap const const txHash: anytxHash = await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"chainflip">({ route, pluginName, ...rest }: SwapParams<"chainflip", {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    ... 13 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
route: {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast, // Optional: provide maxBoostFeeBps to speed up the swap if needed }); return { txHash: anytxHash }; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } }

SwapKit also supports swaps through THORChain:

import {
  enum ChainChain,
  enum FeeOptionFeeOption,
  enum ProviderNameProviderName,
} from "@swapkit/helpers";
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
import {
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from "@swapkit/core";
import {
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
} from "@swapkit/wallets/evm-extensions";
import {
const keystoreWallet: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 21 more ...;
            SOL?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 18 more ... | Chain.Solana)[];
    };
}
keystoreWallet
} from "@swapkit/wallets/keystore";
import {
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
} from "@swapkit/plugins/thorchain";
// Initialize SwapKit const
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
plugins?: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} | undefined
plugins
: { ...
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
},
wallets?: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 21 more ...;
            SOL?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 18 more ... | Chain.Solana)[];
    };
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
} | undefined
wallets
: { ...
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
, ...
const keystoreWallet: {
    connectKeystore: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
            ARB?: DerivationPathArray | undefined;
            ... 21 more ...;
            SOL?: DerivationPathArray | undefined;
        } | undefined) => Promise<boolean>;
        supportedChains: (Chain.Arbitrum | ... 18 more ... | Chain.Solana)[];
    };
}
keystoreWallet
},
}); // Setup for THORChain swap async function
function setupAndSwap(): Promise<{
    txHash: any;
}>
setupAndSwap
() {
// Connect source chain wallet (e.g., Ethereum) await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum]);
// Connect THORChain wallet if doing a swap to RUNE await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
    ARB?: DerivationPathArray | undefined;
    AVAX?: DerivationPathArray | undefined;
    ... 20 more ...;
    SOL?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore
([enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain], "your secret phrase here");
// Perform a swap through THORChain try { // Get quotes from THORChain const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            ... 9 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", // Ethereum buyAsset: stringbuyAsset: "THOR.RUNE", // RUNE on THORChain sellAmount: stringsellAmount: "0.1", // 0.1 ETH providers?: string[] | undefinedproviders: [enum ProviderNameProviderName.function (enum member) ProviderName.THORCHAIN = "THORCHAIN"THORCHAIN], // Use THORChain sourceAddress?: string | undefinedsourceAddress:
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
destinationAddress?: string | undefineddestinationAddress:
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.THORChain>(chain: Chain.THORChain) => stringgetAddress(enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain),
}); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success || !
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes.length) {
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
("No THORChain swap routes available");
} // Select the route const const route: anyroute =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes[0];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// Execute the THORChain swap const const txHash: anytxHash = await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"thorchain">({ route, pluginName, ...rest }: SwapParams<"thorchain", {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    meta: {
        tags: PriorityLabel[];
        chainflip?: {
            sellAsset: {
                asset: string;
                chain: string;
            };
            ... 7 more ...;
            maxBoostFeeBps?: number | undefined;
        } | undefined;
        ... 8 more ...;
        referrer?: string | undefined;
    };
    ... 15 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
route: {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    meta: {
        tags: PriorityLabel[];
        chainflip?: {
            sellAsset: {
                asset: string;
                chain: string;
            };
            ... 7 more ...;
            maxBoostFeeBps?: number | undefined;
        } | undefined;
        ... 8 more ...;
        referrer?: string | undefined;
    };
    ... 15 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast, }); return { txHash: anytxHash }; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } }

Before executing a swap, you can estimate the transaction fees:

import {
  class AssetValueAssetValue,
  enum ChainChain,
  enum FeeOptionFeeOption,
} from "@swapkit/helpers";
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
import {
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from "@swapkit/core";
import {
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
} from "@swapkit/wallets/evm-extensions";
import {
const EVMPlugin: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}
EVMPlugin
} from "@swapkit/plugins/evm";
// Initialize SwapKit const
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
plugins?: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} | undefined
plugins
: { ...
const EVMPlugin: {
    evm: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
}
EVMPlugin
},
wallets?: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
} | undefined
wallets
: { ...
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
},
}); // Connect wallet await
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum]);
// Estimate swap fees async function function estimateSwapFees(): Promise<AssetValue | undefined>estimateSwapFees() { try { // 1. Get quotes const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", buyAsset: stringbuyAsset: "ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", sellAmount: stringsellAmount: "0.1", sourceAddress?: string | undefinedsourceAddress:
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
}); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success || !
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes.length) {
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
("No swap routes available");
} // 2. Select a route const const route: anyroute =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        providers: ProviderName[];
        sellAmount: string;
        expectedBuyAmount: string;
        expectedBuyAmountMaxSlippage: string;
        ... 12 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes[0];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// 3. Create asset value const const assetValue: AssetValueassetValue = await class AssetValueAssetValue.
AssetValue.from<{
    asset: any;
    value: any;
    asyncTokenLookup: true;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: any;
    value: any;
    asyncTokenLookup: true;
} & AssetValueFromParams): Promise<AssetValue>
from
({
asset: anyasset: const route: anyroute.sellAsset, value: anyvalue: const route: anyroute.sellAmount, asyncTokenLookup: trueasyncTokenLookup: true, }); // 4. Estimate the swap fee const const estimatedFee: AssetValue | undefinedestimatedFee = await
const swapKit: {
    evm: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        approveAssetValue: ({ assetValue, spenderAddress, }: {
            spenderAddress: string;
            assetValue: AssetValue;
        }) => Promise<string> | Promise<...>;
        isAssetValueApproved: ({ assetValue, spenderAddress, }: {
            ...;
        }) => Promise<...> | Promise<...>;
        swap: ({ route: { tx, sellAsset }, feeOptionKey, }: SwapParams<"evm", QuoteResponseRoute>) => Promise<...>;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
estimateTransactionFee: <"evm">({ type, feeOptionKey, params, }: ({
    type: "transfer";
    params: EVMTransferParams | GenericTransferParams;
} | {
    ...;
} | {
    ...;
}) & {
    ...;
}) => Promise<AssetValue | undefined>
estimateTransactionFee
({
type: "swap"type: "swap", feeOptionKey: FeeOptionfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast,
params: GenericSwapParams<{
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}> & {
    ...;
} & {
    ...;
}
params
: {
route: {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    providers: ProviderName[];
    sellAmount: string;
    expectedBuyAmount: string;
    expectedBuyAmountMaxSlippage: string;
    ... 12 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
,
assetValue: AssetValueassetValue, }, }); return const estimatedFee: AssetValue | undefinedestimatedFee; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } }

For more advanced use cases, you can customize swap parameters:

import {
  enum ChainChain,
  enum FeeOptionFeeOption,
  enum ProviderNameProviderName,
} from "@swapkit/helpers";
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from "@swapkit/helpers/api";
import {
function SwapKit<Plugins extends ReturnType<typeof createPlugin>, Wallets extends ReturnType<typeof createWallet>>({ config, plugins, wallets, }?: {
    config?: SKConfigState;
    plugins?: Plugins;
    wallets?: Wallets;
}): { [key in keyof Plugins]: ReturnType<...>; } & ... 1 more ... & {
    ...;
}
SwapKit
} from "@swapkit/core";
import {
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
} from "@swapkit/wallets/evm-extensions";
import {
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
} from "@swapkit/plugins/thorchain";
import {
const ChainflipPlugin: {
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
}
ChainflipPlugin
} from "@swapkit/plugins/chainflip";
// Initialize SwapKit const
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    chainflip: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
SwapKit<{
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    thorchain: (pluginParams: SwapKitPluginParams) => {
        ...;
    } & {
        ...;
    };
}, {
    ...;
}>({ config, plugins, wallets, }?: {
    ...;
}): {
    ...;
} & ... 1 more ... & {
    ...;
}
SwapKit
({
plugins?: {
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
} | undefined
plugins
: { ...
const ThorchainPlugin: {
    thorchain: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<...>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
}
ThorchainPlugin
, ...
const ChainflipPlugin: {
    chainflip: (pluginParams: SwapKitPluginParams) => {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
}
ChainflipPlugin
},
wallets?: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
} | undefined
wallets
: { ...
const evmWallet: {
    connectEVMWallet: {
        connectWallet: (connectParams: {
            addChain: AddChainType;
        }) => (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>;
        supportedChains: EVMChain[];
    };
}
evmWallet
},
}); // Connect wallets await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    chainflip: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.connectEVMWallet: (chains: Chain[], walletType?: EVMWalletOptions | undefined, eip1193Provider?: Eip1193Provider | undefined) => Promise<boolean>connectEVMWallet([enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum, enum ChainChain.function (enum member) Chain.BinanceSmartChain = "BSC"BinanceSmartChain]);
// Advanced swap with custom parameters async function
function advancedSwap(): Promise<{
    txHash: any;
}>
advancedSwap
() {
try { // Custom quote parameters const
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getBorrowerDetailRaw: (address: string) => Promise<...>;
        ... 6 more ...;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
function getSwapQuote(json: QuoteRequest): Promise<{
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            ... 9 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}>
getSwapQuote
({
sellAsset: stringsellAsset: "ETH.ETH", buyAsset: stringbuyAsset: "BNB.BNB", sellAmount: stringsellAmount: "0.5", // Specific providers to use providers?: string[] | undefinedproviders: [ enum ProviderNameProviderName.function (enum member) ProviderName.THORCHAIN = "THORCHAIN"THORCHAIN, enum ProviderNameProviderName.function (enum member) ProviderName.CHAINFLIP = "CHAINFLIP"CHAINFLIP, ], // Custom addresses sourceAddress?: string | undefinedsourceAddress:
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    chainflip: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.Ethereum>(chain: Chain.Ethereum) => stringgetAddress(enum ChainChain.function (enum member) Chain.Ethereum = "ETH"Ethereum),
destinationAddress?: string | undefineddestinationAddress:
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    chainflip: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.getAddress: <Chain.BinanceSmartChain>(chain: Chain.BinanceSmartChain) => stringgetAddress(enum ChainChain.function (enum member) Chain.BinanceSmartChain = "BSC"BinanceSmartChain),
// Custom slippage tolerance (2.5%) slippage?: number | undefinedslippage: 2.5, // Affiliate fee (optional) // affiliateBps: 20, // 0.2% fee // affiliateAddress: "thor1youraffiliateaddresshere", }); if (!
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.success || !
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes.length) {
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
Property 'success' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
throw new
var Error: ErrorConstructor
new (message?: string, options?: ErrorOptions) => Error (+2 overloads)
Error
("No advanced swap routes available");
} // Get the best route const const route: anyroute =
const quoteResponse: {
    quoteId: string;
    routes: {
        sellAsset: string;
        buyAsset: string;
        destinationAddress: string;
        meta: {
            tags: PriorityLabel[];
            chainflip?: {
                sellAsset: {
                    asset: string;
                    chain: string;
                };
                ... 7 more ...;
                maxBoostFeeBps?: number | undefined;
            } | undefined;
            ... 8 more ...;
            referrer?: string | undefined;
        };
        ... 15 more ...;
        estimatedTime?: {
            ...;
        } | undefined;
    }[];
    error?: string | undefined;
    providerErrors?: {
        ...;
    }[] | undefined;
}
quoteResponse
.data.routes[0];
Property 'data' does not exist on type '{ quoteId: string; routes: { providers: ProviderName[]; sellAsset: string; sellAmount: string; buyAsset: string; expectedBuyAmount: string; expectedBuyAmountMaxSlippage: string; ... 13 more ...; estimatedTime?: { ...; } | undefined; }[]; error?: string | undefined; providerErrors?: { ...; }[] | undefined; }'.
// Execute the swap with custom parameters const const txHash: anytxHash = await
const swapKit: {
    thorchain: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        addLiquidity: ({ baseAssetValue, assetValue, baseAssetAddr, assetAddr, isPendingSymmAsset, mode, }: AddLiquidityParams) => Promise<{
            baseAssetTx: string | void;
            assetTx: string | void;
        }>;
        ... 12 more ...;
        withdraw: ({ memo, assetValue, percent, from, to }: WithdrawParams) => Promise<...>;
    };
    chainflip: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
swap: <"thorchain" | "chainflip">({ route, pluginName, ...rest }: SwapParams<"thorchain" | "chainflip", {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    meta: {
        tags: PriorityLabel[];
        chainflip?: {
            ...;
        } | undefined;
        ... 8 more ...;
        referrer?: string | undefined;
    };
    ... 15 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}>) => any
swap
({
route: {
    sellAsset: string;
    buyAsset: string;
    destinationAddress: string;
    meta: {
        tags: PriorityLabel[];
        chainflip?: {
            sellAsset: {
                asset: string;
                chain: string;
            };
            ... 7 more ...;
            maxBoostFeeBps?: number | undefined;
        } | undefined;
        ... 8 more ...;
        referrer?: string | undefined;
    };
    ... 15 more ...;
    estimatedTime?: {
        ...;
    } | undefined;
}
route
,
feeOptionKey?: FeeOption | undefinedfeeOptionKey: enum FeeOptionFeeOption.function (enum member) FeeOption.Fast = "fast"Fast, // Additional ChainFlip-specific parameters // maxBoostFeeBps: 5, // 0.05% max fee boost }); return { txHash: anytxHash }; } catch (function (local var) error: unknownerror) { throw function (local var) error: unknownerror; } }