Bolt SUI TypeScript SDK
Integrate with Bolt Liquidity Protocol using TypeScript.
Overview
The Bolt TypeScript SDK enables seamless integration with the Bolt Liquidity Protocol across multiple blockchain networks. Built with extensibility in mind, this SDK provides developers with a comprehensive, type-safe interface to access all protocol functionality including price feeds, token swaps, liquidity management, and pool operations.
Quickstart
Prerequisites
Before using the SDK, make sure you have:
Installation
npm install @bolt-liquidity-hq/sui-clientyarn add @bolt-liquidity-hq/sui-clientpnpm install @bolt-liquidity-hq/sui-clientInitialize the Bolt Client
The SDK supports different environments:
type Environment = 'mainnet' | 'testnet';import { BoltSuiClient } from '@bolt-liquidity-hq/sui-client';
const client = new BoltSuiClient();import { BoltSuiClient } from '@bolt-liquidity-hq/sui-client';
const client = new BoltSuiClient({
environment: 'testnet',
});Query all assets
// Get all supported assets
const assets = await client.getAssets();
assets.forEach((asset) => {
console.log(`${asset.symbol} (${asset.name}): ${asset.denom}`);
console.log(` Decimals: ${asset.decimals}`);
});
// Find a specific asset
const suiAsset = assets.find((a) => a.symbol === 'SUI');
console.log(`SUI type: ${suiAsset?.denom}`); // "0x2::sui::SUI"Execute a swap
// Get signer from wallet (implementation depends on wallet)
const signer: Signer = await getSuiWalletSigner();
// Execute a swap: exactly 1 SUI for USDC
const result = await client.swap({
assetIn: '0x2::sui::SUI',
amountIn: '1000000000', // 1 SUI (9 decimals)
assetOut: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC', // USDC
minimumAmountOut: '1900000', // Minimum 1.9 USDC (6 decimals)
}, signer);
console.log(`Swapped 1 SUI for ${result.amountOut} USDC`);
console.log(`Transaction digest: ${result.txHash}`);
console.log(`Gas cost: ${result.txOutput.effects.gasUsed.computationCost}`);
console.log(`Status: ${result.txOutput.effects.status.status}`);API
Client Initialization
import { BoltSuiClient } from '@bolt-liquidity-hq/sui-client';
// Initialize client
const client = new BoltSuiClient({
environment: 'mainnet', // 'testnet' | 'mainnet'
customOverride: {
chainConfig: {
rpcEndpoint: 'https://my-custom-rpc-endpoint...', // Remove this if you want to use the default public RPC endpoint
}
}
});Get oracle config
Returns a Promise object containing the oracle's configuration parameters:
Usage example
Integration Examples
Query prices and assets
Usage example
Usage example
Usage example
Usage example
Verify pool liquidity
Usage example
Usage example
Get liquidity pools information
Usage example
Usage example
Usage example
Usage example
Simulate a swap
Usage example
How to execute a swap
Basic usage examples
Best practices
Error Handling
The SDK provides custom error types for better error handling:
NotFoundError - Resource not found
InvalidParameterError - Invalid parameter provided
InvalidObjectError - Invalid object structure
InvalidTypeError - Invalid type provided
MissingParameterError - Required parameter missing
TransactionFailedError - Transaction execution failed
ParseError - Failed to parse response data