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

THORChain Features

THORChain provides advanced DeFi features beyond simple swaps. SwapKit includes full support for these features through the THORChain plugin.

To use THORChain features, you need:

  1. A connected wallet with RUNE
  2. SwapKit initialized with the THORChain plugin (included by default)
import { 
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
, enum ChainChain, enum FeeOptionFeeOption } from '@swapkit/sdk';
const
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
=
function createSwapKit(config?: Parameters<typeof SwapKit>[0]): {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
createSwapKit
();
// Connect wallet for THORChain await
const swapKit: {
    chainflip: {
        supportedSwapkitProviders: ProviderName[];
    } & {
        swap: (swapParams: RequestSwapDepositAddressParams) => Promise<...>;
    };
    ... 5 more ...;
    near: {
        ...;
    } & {
        ...;
    };
} & {
    ...;
} & {
    ...;
}
swapKit
.
connectKeystore: (chains: Chain[], phrase: string, derivationPathMapOrIndex?: number | {
    ARB?: DerivationPathArray | undefined;
    AVAX?: DerivationPathArray | undefined;
    ... 21 more ...;
    TRX?: DerivationPathArray | undefined;
} | undefined) => Promise<boolean>
connectKeystore
([enum ChainChain.function (enum member) Chain.THORChain = "THOR"THORChain], 'your mnemonic phrase');

THORChain uses an asymmetric liquidity model where you can provide single-sided or dual-sided liquidity.

import { class AssetValueAssetValue } from '@swapkit/sdk';

// Add ETH/RUNE liquidity
const const runeAmount: AssetValueruneAmount = class AssetValueAssetValue.
AssetValue.from<{
    asset: "THOR.RUNE";
    value: number;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "THOR.RUNE";
    value: number;
} & AssetValueFromParams): AssetValue
from
({ asset: "THOR.RUNE"asset: 'THOR.RUNE', value: numbervalue: 100 });
const const ethAmount: AssetValueethAmount = class AssetValueAssetValue.
AssetValue.from<{
    asset: "ETH.ETH";
    value: number;
}>({ value, fromBaseDecimal, asyncTokenLookup, ...fromAssetOrChain }: {
    asset: "ETH.ETH";
    value: number;
} & AssetValueFromParams): AssetValue
from
({ asset: "ETH.ETH"asset: 'ETH.ETH', value: numbervalue: 0.5 });
const const result: anyresult = await
Cannot find name 'swapKit'.
swapKit
.thorchain.addLiquidity({
baseAssetValue: AssetValuebaseAssetValue: const runeAmount: AssetValueruneAmount, // RUNE amount assetValue: AssetValueassetValue: const ethAmount: AssetValueethAmount, // Asset amount baseAssetAddr: anybaseAssetAddr:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain),
assetAddr: anyassetAddr:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.Ethereum),
mode: stringmode: 'sym' // Symmetrical mode }); console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('RUNE tx:', const result: anyresult.baseAssetTx);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('ETH tx:', const result: anyresult.assetTx);
// Add RUNE-only liquidity
const const runeOnly: anyruneOnly = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.addLiquidity({
baseAssetValue: anybaseAssetValue:
Cannot find name 'runeAmount'.
runeAmount
,
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'BTC.BTC', value: numbervalue: 0 }), // Required but can be 0
baseAssetAddr: anybaseAssetAddr:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain),
mode: stringmode: 'baseAsset' // Use 'baseAsset' for RUNE-only }); // Add asset-only liquidity (e.g., BTC only) const const btcAmount: anybtcAmount =
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'BTC.BTC', value: numbervalue: 0.1 });
const const btcOnly: anybtcOnly = await
Cannot find name 'swapKit'.
swapKit
.thorchain.addLiquidity({
baseAssetValue: anybaseAssetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'THOR.RUNE', value: numbervalue: 0 }), // Required but can be 0
assetValue: anyassetValue: const btcAmount: anybtcAmount, assetAddr: anyassetAddr:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.Bitcoin),
mode: stringmode: 'asset' // Use 'asset' for asset-only });

For creating a new liquidity position (bootstrapping a pool):

const const result: anyresult = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.createLiquidity({
baseAssetValue: anybaseAssetValue:
Cannot find name 'runeAmount'.
runeAmount
, // RUNE amount
assetValue: anyassetValue:
Cannot find name 'ethAmount'.
ethAmount
// Asset amount
}); console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('RUNE tx:', const result: anyresult.baseAssetTx);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Asset tx:', const result: anyresult.assetTx);

For more granular control, you can add liquidity parts separately:

const const poolAddress: "BTC.BTC"poolAddress = 'BTC.BTC'; // Pool identifier

await 
Cannot find name 'swapKit'.
swapKit
.thorchain.addLiquidityPart({
assetValue: anyassetValue:
Cannot find name 'btcAmount'.
btcAmount
,
poolAddress: stringpoolAddress, address: anyaddress:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.Bitcoin), // Optional: for symmetric deposits
symmetric: booleansymmetric: true });
// Withdraw 50% of liquidity position
const const withdrawTx: anywithdrawTx = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.withdraw({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'BTC.BTC', value: numbervalue: 0 }), // Pool identifier
percent: numberpercent: 50, // Withdraw 50% from: stringfrom: 'sym', // From position type: 'sym' | 'baseAsset' | 'asset' to: stringto: 'sym' // To asset type: 'sym' | 'baseAsset' | 'asset' }); // Withdraw asymmetric RUNE position to symmetric const const runeToSym: anyruneToSym = await
Cannot find name 'swapKit'.
swapKit
.thorchain.withdraw({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'ETH.ETH', value: numbervalue: 0 }),
percent: numberpercent: 100, // Withdraw 100% from: stringfrom: 'baseAsset', // From RUNE-only position to: stringto: 'sym' // To both RUNE and ETH }); // Withdraw to specific asset only const const toAssetOnly: anytoAssetOnly = await
Cannot find name 'swapKit'.
swapKit
.thorchain.withdraw({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'BTC.BTC', value: numbervalue: 0 }),
percent: numberpercent: 25, // Withdraw 25% from: stringfrom: 'sym', // From symmetric position to: stringto: 'asset' // Receive BTC only });
import { 
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getNameDetails: (name: string) => Promise<THORNameDetails>;
        getNamesByAddress: (address: string) => Promise<...>;
        getNamesByOwner: (address: string) => Promise<...>;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
} from '@swapkit/helpers/api';
const const thorAddress: anythorAddress =
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain);
const
const position: {
    [x: string]: string | AssetValue | SwapKitNumber;
    asset: AssetValue;
    assetPending: AssetValue;
    assetRegisteredAddress: string;
    assetWithdrawn: AssetValue;
    dateFirstAdded: string;
    dateLastAdded: string;
    poolShare: SwapKitNumber;
}[]
position
= await
const SwapKitApi: {
    mayachainMidgard: {
        getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsMayachain>;
        getNameDetails: (name: string) => Promise<THORNameDetails>;
        getNamesByAddress: (address: string) => Promise<...>;
        getNamesByOwner: (address: string) => Promise<...>;
        getLiquidityPosition: (address: string) => Promise<...>;
    };
    ... 14 more ...;
    getChainflipDepositChannel(body: BrokerDepositChannelParams): Promise<...>;
}
SwapKitApi
.
thorchainMidgard: {
    getLiquidityPositionRaw: (address: string) => Promise<MemberDetailsThorchain>;
    getNameDetails: (name: string) => Promise<THORNameDetails>;
    getNamesByAddress: (address: string) => Promise<...>;
    getNamesByOwner: (address: string) => Promise<...>;
    getLiquidityPosition: (address: string) => Promise<...>;
}
thorchainMidgard
.
getLiquidityPosition: (address: string) => Promise<{
    [x: string]: string | AssetValue | SwapKitNumber;
    asset: AssetValue;
    assetPending: AssetValue;
    assetRegisteredAddress: string;
    assetWithdrawn: AssetValue;
    dateFirstAdded: string;
    dateLastAdded: string;
    poolShare: SwapKitNumber;
}[]>
getLiquidityPosition
(const thorAddress: anythorAddress);
// Position details console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Pools:',
const position: {
    [x: string]: string | AssetValue | SwapKitNumber;
    asset: AssetValue;
    assetPending: AssetValue;
    assetRegisteredAddress: string;
    assetWithdrawn: AssetValue;
    dateFirstAdded: string;
    dateLastAdded: string;
    poolShare: SwapKitNumber;
}[]
position
.
Property 'pools' does not exist on type '{ [x: string]: string | AssetValue | SwapKitNumber; asset: AssetValue; assetPending: AssetValue; assetRegisteredAddress: string; assetWithdrawn: AssetValue; dateFirstAdded: string; dateLastAdded: string; poolShare: SwapKitNumber; }[]'.
pools
);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Total value USD:',
const position: {
    [x: string]: string | AssetValue | SwapKitNumber;
    asset: AssetValue;
    assetPending: AssetValue;
    assetRegisteredAddress: string;
    assetWithdrawn: AssetValue;
    dateFirstAdded: string;
    dateLastAdded: string;
    poolShare: SwapKitNumber;
}[]
position
.
Property 'totalValueUSD' does not exist on type '{ [x: string]: string | AssetValue | SwapKitNumber; asset: AssetValue; assetPending: AssetValue; assetRegisteredAddress: string; assetWithdrawn: AssetValue; dateFirstAdded: string; dateLastAdded: string; poolShare: SwapKitNumber; }[]'.
totalValueUSD
);

THORNames are human-readable aliases for wallet addresses across all supported chains.

// Register a new THORName
const const thorname: "myname"thorname = 'myname';
const const years: 1years = 1; // Registration period

// Check availability
const const details: anydetails = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getTHORNameDetails(const thorname: "myname"thorname);
if (const details: anydetails.owner) { console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('THORName already taken');
A 'return' statement can only be used within a function body.
return
;
} // Calculate registration fee (1 RUNE per year + network fee) const const registrationFee: anyregistrationFee =
Cannot find name 'AssetValue'.
AssetValue
.from({
asset: stringasset: 'THOR.RUNE', value: numbervalue: const years: 1years + 0.02 // 1 RUNE/year + ~0.02 network fee }); // Register the name const const registerTx: anyregisterTx = await
Cannot find name 'swapKit'.
swapKit
.thorchain.registerName({
assetValue: anyassetValue: const registrationFee: anyregistrationFee, name: stringname: const thorname: "myname"thorname, chain: stringchain: 'THOR', // Chain identifier for the THORName address: anyaddress:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain),
owner: anyowner:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain), // Optional: different owner
preferredAsset: stringpreferredAsset: 'ETH.ETH' // Optional: set preferred asset });

Configure which asset you want to receive when someone sends to your THORName:

// Set preferred asset to USDC
const const preferredAsset: anypreferredAsset = 
Cannot find name 'AssetValue'.
AssetValue
.from({
asset: stringasset: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', value: numbervalue: 0 }); const const setPreferredTx: anysetPreferredTx = await
Cannot find name 'swapKit'.
swapKit
.thorchain.registerPreferredAsset({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
Cannot find name 'Chain'. Did you mean 'Chai'?
.from({ chain: anychain: Chain.THORChain }), // Min RUNE for tx
name: anyname:
Cannot find name 'thorname'.
thorname
,
ownerAddress: anyownerAddress:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain),
payoutAddress: anypayoutAddress:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.Ethereum) // Where to receive USDC
});

Set addresses for different chains:

// Update Bitcoin address for THORName
const const updateBtcTx: anyupdateBtcTx = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.registerName({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
Cannot find name 'Chain'. Did you mean 'Chai'?
.from({ chain: anychain: Chain.THORChain }), // Min RUNE for tx
name: anyname:
Cannot find name 'thorname'.
thorname
,
chain: stringchain: 'BTC', // Chain identifier address: anyaddress:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.Bitcoin),
owner: anyowner:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.THORChain)
}); // Update multiple chains const
const chainMap: {
    [x: number]: string;
}
chainMap
= {
[
Cannot find name 'Chain'. Did you mean 'Chai'?
Chain
.Ethereum]: 'ETH',
[
Cannot find name 'Chain'. Did you mean 'Chai'?
Chain
.Bitcoin]: 'BTC',
[
Cannot find name 'Chain'.
Chain
.BinanceSmartChain]: 'BSC'
}; for (const [const chain: stringchain, const chainId: stringchainId] of var Object: ObjectConstructor
Provides functionality common to all JavaScript objects.
Object
.
ObjectConstructor.entries<string>(o: {
    [s: string]: string;
} | ArrayLike<string>): [string, string][] (+1 overload)
Returns an array of key/values of the enumerable own properties 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.
entries
(
const chainMap: {
    [x: number]: string;
}
chainMap
)) {
await
Cannot find name 'swapKit'.
swapKit
.thorchain.registerName({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
Cannot find name 'Chain'.
.from({ chain: anychain: Chain.THORChain }),
name: anyname:
Cannot find name 'thorname'.
thorname
,
chain: stringchain: const chainId: stringchainId, address: anyaddress:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'.
.getAddress(const chain: stringchain as Chain),
owner: anyowner:
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'.
.getAddress(Chain.THORChain)
}); }
const const thornameDetails: anythornameDetails = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getTHORNameDetails('thorswap');
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Owner:', const thornameDetails: anythornameDetails.owner);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Preferred asset:', const thornameDetails: anythornameDetails.preferredAsset);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Aliases:', const thornameDetails: anythornameDetails.aliases);
// Get specific chain address const const ethAddress: anyethAddress = const thornameDetails: anythornameDetails.aliases.find(
Parameter 'a' implicitly has an 'any' type.
a
=> a: anya.chain === 'ETH')?.address;

For node operators, SwapKit provides bond management functions.

import { enum MemoTypeMemoType } from '@swapkit/sdk';

const const bondAmount: anybondAmount = 
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'THOR.RUNE', value: numbervalue: 100000 });
const const nodeAddress: "thor1abc..."nodeAddress = 'thor1abc...'; // Your node address const const bondTx: anybondTx = await
Cannot find name 'swapKit'.
swapKit
.thorchain.nodeAction({
type: MemoTypetype: enum MemoTypeMemoType.function (enum member) MemoType.BOND = "BOND"BOND, assetValue: anyassetValue: const bondAmount: anybondAmount, address: stringaddress: const nodeAddress: "thor1abc..."nodeAddress });
// Unbond specific amount
const const unbondTx: anyunbondTx = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.nodeAction({
type: anytype:
Cannot find name 'MemoType'.
MemoType
.UNBOND,
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'THOR.RUNE', value: numbervalue: 50000 }),
address: anyaddress:
Cannot find name 'nodeAddress'.
nodeAddress
}); // Leave (unbond all) const const leaveTx: anyleaveTx = await
Cannot find name 'swapKit'.
swapKit
.thorchain.nodeAction({
type: anytype:
Cannot find name 'MemoType'.
MemoType
.LEAVE,
address: anyaddress:
Cannot find name 'nodeAddress'.
nodeAddress
});

For advanced users, deposit directly to THORChain with custom memos:

// Direct deposit with custom memo
const const customDeposit: anycustomDeposit = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.deposit({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'BTC.BTC', value: numbervalue: 0.1 }),
recipient: stringrecipient: '', // Empty for THORChain protocol deposits memo: stringmemo: 'SWAP:ETH.ETH:thor1...' // Custom memo for any THORChain action }); // Deposit to specific pool const const poolDeposit: anypoolDeposit = await
Cannot find name 'swapKit'.
swapKit
.thorchain.depositToPool({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'ETH.ETH', value: numbervalue: 1 }),
memo: stringmemo: 'ADD:ETH.ETH:thor1...', feeOptionKey: anyfeeOptionKey:
Cannot find name 'FeeOption'. Did you mean 'Option'?
FeeOption
.Fast // Optional: Average, Fast, or Fastest
}); // Protocol deposit (simplified) const const protocolDeposit: anyprotocolDeposit = await
Cannot find name 'swapKit'.
swapKit
.thorchain.depositToProtocol({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({ asset: stringasset: 'THOR.RUNE', value: numbervalue: 10 }),
memo: stringmemo: 'BOND:thor1nodeaddress...' });

For EVM chains, THORChain requires token approvals before deposits:

// Check if token is approved
const const isApproved: anyisApproved = await 
Cannot find name 'swapKit'.
swapKit
.thorchain.isAssetValueApproved({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({
asset: stringasset: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', value: numbervalue: 1000 }) }); if (!const isApproved: anyisApproved) { // Approve token for THORChain router const const approveTx: anyapproveTx = await
Cannot find name 'swapKit'.
swapKit
.thorchain.approveAssetValue({
assetValue: anyassetValue:
Cannot find name 'AssetValue'.
AssetValue
.from({
asset: stringasset: 'ETH.USDC-0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', value: numbervalue: 1000 }) }); console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Approval tx:', const approveTx: anyapproveTx);
}

Maya is a fork of THORChain with similar features. SwapKit supports Maya through the Maya plugin:

// Maya operations use the same interface
// Check Maya positions
const const mayaPosition: anymayaPosition = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.mayachainMidgard.getLiquidityPosition(
Cannot find name 'swapKit'.
swapKit
Cannot find name 'Chain'. Did you mean 'Chai'?
.getAddress(Chain.Maya)
);

Get inbound addresses and gas rates for any supported chain:

// Get inbound data for a specific chain
const const btcInbound: anybtcInbound = await 
Cannot find name 'swapKit'.
swapKit
.thorchain
Cannot find name 'Chain'. Did you mean 'chains'?
.
getInboundDataByChain(Chain.Bitcoin);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('BTC vault address:', const btcInbound: anybtcInbound.address);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('BTC router:', const btcInbound: anybtcInbound.router);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Gas rate:', const btcInbound: anybtcInbound.gas_rate);
console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Chain halted:', const btcInbound: anybtcInbound.halted);
// Check multiple chains const const chains: any[]chains = [
Cannot find name 'Chain'. Did you mean 'chains'?
Chain
Cannot find name 'Chain'. Did you mean 'chains'?
Cannot find name 'Chain'. Did you mean 'chains'?
.Ethereum, Chain.Bitcoin, Chain.BinanceSmartChain];
for (const const chain: anychain of const chains: any[]chains) { const const inbound: anyinbound = await
Cannot find name 'swapKit'.
swapKit
.thorchain.getInboundDataByChain(const chain: anychain);
if (const inbound: anyinbound.halted) { console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`${const chain: anychain} is currently halted`);
} }

Before adding liquidity or making swaps:

const const pools: anypools = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.thorchainMidgard.getPools();
const const btcPool: anybtcPool = const pools: anypools.find(
Parameter 'p' implicitly has an 'any' type.
p
=> p: anyp.asset === 'BTC.BTC');
if (const btcPool: anybtcPool?.status !== 'Available') { console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Pool not available');
A 'return' statement can only be used within a function body.
return
;
}

For large liquidity operations:

const const quote: anyquote = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getSwapQuote({
sellAsset: stringsellAsset: 'THOR.RUNE', sellAmount: stringsellAmount: '1000000000000', // Large amount buyAsset: stringbuyAsset: 'BTC.BTC', // ... other params }); const const slippage: anyslippage = const quote: anyquote.routes[0].fees.slippage; console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
(`Slippage: ${const slippage: anyslippage}%`);

Track THORChain transactions:

const const txStatus: anytxStatus = await 
Cannot find name 'SwapKitApi'.
SwapKitApi
.getTrackerDetails({
txHash: stringtxHash: 'ABCD...', chain: stringchain: 'THOR' }); if (const txStatus: anytxStatus.status === 'completed') { console.Console.log(message?: any, ...optionalParams: any[]): void (+3 overloads)
Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to [`printf(3)`](http://man7.org/linux/man-pages/man3/printf.3.html) (the arguments are all passed to [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args)). ```js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout ``` See [`util.format()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilformatformat-args) for more information.
@sincev0.1.100
log
('Transaction successful');
}

Here’s a complete list of THORChain plugin methods:

  • deposit() - Direct deposit with custom parameters
  • depositToPool() - Deposit to specific pool with memo
  • depositToProtocol() - Simplified protocol deposits
  • addLiquidity() - Add symmetric or asymmetric liquidity
  • addLiquidityPart() - Add liquidity with granular control
  • createLiquidity() - Bootstrap new liquidity pools
  • withdraw() - Withdraw liquidity positions
  • registerName() - Register or update THORNames
  • registerPreferredAsset() - Set preferred payout asset
  • nodeAction() - Bond, unbond, or leave as node operator
  • approveAssetValue() - Approve tokens for router
  • isAssetValueApproved() - Check approval status
  • getInboundDataByChain() - Get vault addresses and gas rates
  • swap() - Execute swaps (used internally by SwapKit)