Migrate to v4
import { function getUtxoToolbox<T extends keyof UTXOToolboxes>(chain: T, params?: UtxoToolboxParams[T] | {
phrase?: string;
derivationPath?: DerivationPathArray;
index?: number;
}): Promise<UTXOToolboxes[T]>
getUtxoToolbox } from "@swapkit/toolboxes/utxo"
import { function getEvmToolbox<T extends EVMChain>(chain: T, params?: EVMToolboxParams): Promise<{
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}>
getEvmToolbox } from "@swapkit/toolboxes/evm"
import { enum Chain
Chain, function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
kado: {
supportedSwapkitProviders: ProviderName[];
} & {
createPopover: (url: string) => HTMLDivElement;
... 5 more ...;
swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
...;
};
};
... 5 more ...;
thorchain: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
createSwapKit, const DerivationPath: Record<Chain, string>
DerivationPath } from "@swapkit/sdk"
const const btc: {
accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & {
outputs: TargetOutput[];
chain: UTXOChain;
}) => {
...;
} | {
...;
};
... 13 more ...;
estimateMaxSendableAmount: ({ from, memo, feeRate, feeOptionKey, recipients, }: {
from: string;
memo?: string;
feeRate?: number;
feeOptionKey?: FeeOption;
recipients?: number | TargetOutput[];
}) => Promise<...>;
}
btc = await getUtxoToolbox<Chain.Bitcoin>(chain: Chain.Bitcoin, params?: {
phrase?: string;
derivationPath?: DerivationPathArray;
index?: number;
} | {
signer: ChainSigner<Psbt, Psbt>;
} | undefined): Promise<...>
getUtxoToolbox(enum Chain
Chain.function (enum member) Chain.Bitcoin = "BTC"
Bitcoin)
const const eth: {
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}
eth = await getEvmToolbox<Chain.Ethereum>(chain: Chain.Ethereum, params?: EVMToolboxParams): Promise<{
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}>
getEvmToolbox(enum Chain
Chain.function (enum member) Chain.Ethereum = "ETH"
Ethereum)
const const avax: {
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}
avax = await getEvmToolbox<Chain.Avalanche>(chain: Chain.Avalanche, params?: EVMToolboxParams): Promise<{
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}>
getEvmToolbox(enum Chain
Chain.function (enum member) Chain.Avalanche = "AVAX"
Avalanche)
const const avaxNetwork: NetworkParams | undefined
avaxNetwork = const avax: {
estimateTransactionFee: ({ feeOption, chain, ...txObject }: EIP1559TxParams & {
feeOption: FeeOption;
chain: EVMChain;
}) => Promise<...>;
... 20 more ...;
validateAddress: (address: string) => boolean;
} | {
...;
} | {
...;
}
avax.getNetworkParams: () => NetworkParams | undefined
getNetworkParams()
const const btcKeys: ECPairInterface
btcKeys = await const btc: {
accumulative: ({ inputs, outputs, feeRate: initialFeeRate, chain, }: UTXOCalculateTxSizeParams & {
outputs: TargetOutput[];
chain: UTXOChain;
}) => {
...;
} | {
...;
};
... 13 more ...;
estimateMaxSendableAmount: ({ from, memo, feeRate, feeOptionKey, recipients, }: {
from: string;
memo?: string;
feeRate?: number;
feeOptionKey?: FeeOption;
recipients?: number | TargetOutput[];
}) => Promise<...>;
}
btc.createKeysForPath: (params: {
wif?: string;
phrase?: string;
derivationPath?: string;
}) => ECPairInterface
createKeysForPath({
phrase?: string | undefined
phrase: "...",
derivationPath?: string | undefined
derivationPath: `${const DerivationPath: Record<Chain, string>
DerivationPath.type BTC: string
BTC}/0`,
})
const const publicKey: Buffer<ArrayBufferLike> | undefined
publicKey = const btcKeys: ECPairInterface
btcKeys.Signer.getPublicKey?(): Buffer
getPublicKey?.();
const const skClient: {
kado: {
supportedSwapkitProviders: ProviderName[];
} & {
createPopover: (url: string) => HTMLDivElement;
getAssets: () => Promise<{
_id: string;
name: string;
... 9 more ...;
priority: number;
}[]>;
... 4 more ...;
swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
...;
};
};
... 5 more ...;
thorchain: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
skClient = function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
kado: {
supportedSwapkitProviders: ProviderName[];
} & {
createPopover: (url: string) => HTMLDivElement;
... 5 more ...;
swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
...;
};
};
... 5 more ...;
thorchain: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
createSwapKit()
const skClient: {
kado: {
supportedSwapkitProviders: ProviderName[];
} & {
createPopover: (url: string) => HTMLDivElement;
getAssets: () => Promise<{
_id: string;
name: string;
... 9 more ...;
priority: number;
}[]>;
... 4 more ...;
swap: ({ route }: SwapParams<"evm", QuoteResponseRoute>) => {
...;
};
};
... 5 more ...;
thorchain: {
...;
} & {
...;
};
} & {
...;
} & {
...;
}
skClient.- approveAssetValue
- chainflip
- connectBitget
- connectCoinbaseWallet
- connectCtrl
- connectEVMWallet
- connectExodusWallet
- connectKeepkey
- connectKeepkeyBex
- connectKeplr
- connectKeystore
- connectLedger
- connectOkx
- connectOnekeyWallet
- connectPhantom
- connectPolkadotJs
- connectRadixWallet
- connectTalisman
- connectTrezor
- connectWalletconnect
- disconnectAll
- disconnectChain
- estimateTransactionFee
- evm
- getAddress
- getAllWallets
- getBalance
- getExplorerAddressUrl
- getExplorerTxUrl
- getWallet
- getWalletWithBalance
- isAssetValueApproved
- kado
- mayachain
- radix
- signMessage
- solana
- swap
- thorchain
- transfer
- verifyMessage
swap: <T extends "kado" | "chainflip" | "radix" | "solana" | "evm" | "mayachain" | "thorchain">({ route, pluginName, ...rest }: SwapParams<T, {
providers: ProviderName[];
sellAsset: string;
sellAmount: string;
buyAsset: string;
... 15 more ...;
estimatedTime?: {
...;
} | undefined;
}>) => any
swap
MIGRATE FROM CORE v3 to v4
Section titled “MIGRATE FROM CORE v3 to v4”[!IMPORTANT]Read before continue We migrated to combined functionality packages to simplify developer experience. You will have to change imports to use the new version of the packages.
To help with migration we noted how imports changed in the following sections with the format:
swapkitPackage => migratedSwapkitPackage
Package Migrations
Section titled “Package Migrations”Installation
Section titled “Installation”before
# Toolboxes
$ bun install @swapkit/toolbox-cosmos @swapkit/toolbox-evm @swapkit/toolbox-radix @swapkit/toolbox-solana @swapkit/toolbox-substrate @swapkit/toolbox-utxo
# Plugins
$ bun install @swapkit/plugin-chainflip @swapkit/plugin-evm @swapkit/plugin-kado @swapkit/plugin-radix @swapkit/plugin-thorchain
# Wallets
$ bun install @swapkit/wallet-bitget @swapkit/wallet-coinbase @swapkit/wallet-ctrl @swapkit/wallet-evm-extensions @swapkit/wallet-exodus @swapkit/wallet-keepkey @swapkit/wallet-keepkey-bex @swapkit/wallet-ledger @swapkit/wallet-okx @swapkit/wallet-phantom @swapkit/wallet-polkadotjs @swapkit/wallet-radix @swapkit/wallet-tailsman @swapkit/wallet-trezor @swapkit/wallet-wc
# Helpers and others
$ bun install @swapkit/helpers @swapkit/api @swapkit/contracts @swapkit/tokens
after
# Toolboxes
$ bun install @swapkit/toolboxes
# Plugins
$ bun install @swapkit/plugins
# Wallets
$ bun install @swapkit/wallets
# Helpers and others
$ bun install @swapkit/helpers
Imports
Section titled “Imports”Old | New |
---|---|
@swapkit/api | @swapkit/helpers/api |
@swapkit/contracts | @swapkit/helpers/contracts |
@swapkit/tokens | @swapkit/helpers/tokens |
@swapkit/plugin-chainflip | @swapkit/plugins/chainflip |
@swapkit/plugin-evm | @swapkit/plugins/evm |
@swapkit/plugin-kado | @swapkit/plugins/kado |
@swapkit/plugin-radix | @swapkit/plugins/radix |
@swapkit/plugin-thorchain | @swapkit/plugins/thorchain |
@swapkit/toolbox-cosmos | @swapkit/toolboxes/cosmos |
@swapkit/toolbox-evm | @swapkit/toolboxes/evm |
@swapkit/toolbox-radix | @swapkit/toolboxes/radix |
@swapkit/toolbox-solana | @swapkit/toolboxes/solana |
@swapkit/toolbox-substrate | @swapkit/toolboxes/substrate |
@swapkit/toolbox-utxo | @swapkit/toolboxes/utxo |
@swapkit/wallet-bitget | @swapkit/wallets/bitget |
@swapkit/wallet-coinbase | @swapkit/wallets/coinbase |
@swapkit/wallet-ctrl | @swapkit/wallets/ctrl |
@swapkit/wallet-evm-extensions | @swapkit/wallets/evm-extensions |
@swapkit/wallet-exodus | @swapkit/wallets/exodus |
@swapkit/wallet-keepkey | @swapkit/wallets/keepkey |
@swapkit/wallet-keepkey-bex | @swapkit/wallets/keepkey-bex |
@swapkit/wallet-ledger | @swapkit/wallets/ledger |
@swapkit/wallet-okx | @swapkit/wallets/okx |
@swapkit/wallet-phantom | @swapkit/wallets/phantom |
@swapkit/wallet-polkadotjs | @swapkit/wallets/polkadotjs |
@swapkit/wallet-radix | @swapkit/wallets/radix |
@swapkit/wallet-tailsman | @swapkit/wallets/tailsman |
@swapkit/wallet-trezor | @swapkit/wallets/trezor |
@swapkit/wallet-wc | @swapkit/wallets/walletconnect |
@swapkit/helpers
Section titled “@swapkit/helpers”SKConfig
- configuration module for handling api keys and other configuration optionscreatePlugin
- factory function to create a new plugin- Now combines
@swapkit/api
,@swapkit/contracts
,@swapkit/tokens
under a single package
@swapkit/plugins
Section titled “@swapkit/plugins”- Now combines
@swapkit/plugin-chainflip
,@swapkit/plugin-evm
,@swapkit/plugin-kado
,@swapkit/plugin-radix
,@swapkit/plugin-thorchain
under a single package
@swapkit/toolboxes
Section titled “@swapkit/toolboxes”- Now combines
@swapkit/toolbox-evm
,@swapkit/toolbox-cosmos
,@swapkit/toolbox-solana
,@swapkit/toolbox-substrate
,@swapkit/toolbox-utxo
under a single package
Removed
Section titled “Removed”@swapkit/api => @swapkit/helpers/api
Section titled “@swapkit/api => @swapkit/helpers/api”Methods were scoped under SwapKitApi
object and split into related api endpoints.
getSwapQuoteV2
-> usegetSwapQuote
directlygetTokenListV2
-> usegetTokenList
directly- for thornode requests use
SwapKitApi.thornode
- for mayachain midgard requests use
SwapKitApi.mayachainMidgard
- for thorchain midgard requests use
SwapKitApi.thorchainMidgard
- for microgard requests use
SwapKitApi.microgard
@swapkit/core
Section titled “@swapkit/core”validateAddress
-> Migrated to@swapkit/toolboxes
-> usegetAddressValidator
directlyapi
-> useSwapKitApi
directly. For configuration useSKConfig
@swapkit/helpers
Section titled “@swapkit/helpers”ensureEVMApiKeys
-> removedsetRequestClientConfig
-> removed - useSKConfig
directly —>