Installation
pnpm add turbos-clmm-sdk @mysten/sui
Modules
- contract
- trade
- pool
- nft
- account
- math
Initial SDK
import { JsonRpcProvider, testnetConnection } from '@mysten/sui';
import { Network, TurbosSdk } from 'turbos-clmm-sdk';
// Choose one way
export const sdk = new TurbosSdk(Network.testnet);
export const sdk = new TurbosSdk(Network.testnet, testnetConnection);
export const sdk = new TurbosSdk(Network.testnet, new JsonRpcProvider(testnetConnection));
Module:Contract
getConfig
import type { Contract } from 'turbos-clmm-sdk';
const contract = await sdk.contract.getConfig(); // interface: Contract.Config
getFees
import type { Contract } from 'turbos-clmm-sdk';
const fees = await sdk.contract.getFees(); // interface: Contract.Fee[]
Module:Trade
computeSwapResult
import type { Trade } from 'turbos-clmm-sdk';
// interface: Trade.ComputedSwapResult[]
const swapResults = await sdk.trade.computeSwapResult({
pools: Array<{
pool: string;
a2b: boolean;
}>,
address: string;
amountSpecified: number | string;
amountSpecifiedIsInput: boolean;
});
swap
const txb = await sdk.trade.swap({
/**
* nextTickIndex = sdk.math.bitsToNumber(swapResult.tick_current_index.bits)
*/
routes: { pool: string; a2b: boolean; nextTickIndex: number }[];
coinTypeA: string;
coinTypeB: string;
address: string;
amountA: number | string;
amountB: number | string;
amountSpecifiedIsInput: boolean;
slippage: string;
txb?: Transaction;
});