square-codeBolt 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

1

Prerequisites

Before using the SDK, make sure you have:

2

Installation

npm install @bolt-liquidity-hq/sui-client
3

Initialize the Bolt Client

The SDK supports different environments:

type Environment = 'mainnet' | 'testnet';
import { BoltSuiClient } from '@bolt-liquidity-hq/sui-client';

const client = new BoltSuiClient();
4

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"
5

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
    }
  }
});
chevron-rightAdvanced client initializationhashtag

Environment configuration

Parameter
Type
Default
Description

environment

mainnet | testnet

mainnet

Specifies to which network to connect.

Override chain configuration

Parameter
Type
Default (mainnet)
Default (testnet)
Description

chainConfig.id

string

101

103

Chain identifier

chainConfig.name

string

SUI

SUITestnet

Human-readable chain name

Override Bolt package ID

Parameter
Type
Default (mainnet)
Description

packageId

string

0x71a61b841cc90a74607e99084e47818a7d1424649f4047ad375d9c2a4111e658

Bolt protocol package ID

Override Outpost contract address

Parameter
Type
Default (mainnet)
Description

contracts.oracle

string

0xfa3975b98f3d0e3df18ed88ae6e69db31836b3f4212df02fae144b1e5a89ca8e

Oracle contract address

Override assets configuration

Parameter
Type
Description

assetsConfig

Record<string, Asset>

Custom asset configurations indexed by denomination

Override SUI client

Parameter
Type
Description

suiClient

SuiClient

Pre-existing SuiClient instance to use for blockchain interactions

Get oracle config

circle-info

getOracleConfig()

The getOracleConfig method retrieves the current configuration settings from the Bolt Liquidity Protocol's Oracle smart contract on the Sui blockchain. This configuration governs how price feeds are managed, including update thresholds, expiration times, and administrative settings.

Usage example

Integration Examples

chevron-rightHow to cache Oracle config (best practice)hashtag
chevron-rightHow to monitor for price updateshashtag

Query prices and assets

circle-info

getAssets()

Retrieves all unique assets available in the Bolt protocol by querying oracle asset pairs and enriching them with additional metadata from the client's asset configuration.

Usage example

circle-info

getAllOracleAssetPairs()

Queries the oracle smart contract to retrieve all supported asset pairs with automatic pagination handling. Each asset pair represents a base/quote relationship that can be used for price queries and swaps.

Usage example

circle-info

getAllPrices()

Queries the oracle smart contract to retrieve all available price feeds with automatic pagination. More efficient than making multiple individual price queries when you need prices for multiple pairs.

Usage example

circle-info

getPrice()

Queries the oracle smart contract to retrieve the current price for a specific asset pair. Fetches the latest price feed that is updated by authorized price feeders and validated against configured thresholds.

Usage example

Verify pool liquidity

circle-info

getPoolBaseLiquidity()

Queries the router smart contract to retrieve the total base asset liquidity across all pools with automatic pagination. Fetches current liquidity levels for all base assets in their respective pools.

Usage example

circle-info

getAllBaseAssetsLiquidity()

Queries the router smart contract to retrieve the base asset liquidity across all pools. Fetches current liquidity levels for all the base assets in their respective pools.

Usage example

Get liquidity pools information

circle-info

getAllPools()

Queries the router smart contract to retrieve information about all deployed pools with automatic pagination. Fetches a comprehensive list of all pools in the Bolt protocol.

Usage example

circle-info

getPoolConfig()

Retrieves the configuration settings of a liquidity pool contract. Queries the contract to fetch its current configuration parameters including fees, LP settings, and oracle integration.

Usage example

circle-info

getPoolByDenom()

Queries the router smart contract to retrieve pool information for a specific base asset on the Archway Blockchain, or a specific base/quote asset pair on the Sui Blockchain. Fetches pool details for the pool matching the provided asset denom(s).

Usage example

circle-info

getPoolConfigByDenom()

Retrieves the configuration settings of a liquidity pool contract identified by its base asset on the Archway Blockchain, or by the base/quote asset pair on the Sui Blockchain. This is a convenience function that combines pool lookup and configuration retrieval.

Usage example

Simulate a swap

circle-info

getRouterConfig()

Simulates a swap operation to calculate the expected output amount without executing the transaction. Performs a dry run of the swap, taking into account current pool conditions, oracle prices, and fees. It's useful for getting accurate estimates before executing a swap.

Usage example

How to execute a swap

circle-info

swap()

The swap method executes a token swap transaction on the Bolt Liquidity Protocol through the router contract. It performs a "swap exact in" operation where users specify exactly how much of the input asset they want to swap, and receive a variable amount of the output asset based on current pool conditions.

Basic usage examples

chevron-rightSimple swaphashtag
chevron-rightSwap with minimum amount out limithashtag
chevron-rightSwap with custom receiverhashtag

Best practices

chevron-rightPrice slippage protectionhashtag
chevron-rightError handling and retrieshashtag
chevron-rightGas estimation and optimizationhashtag
chevron-rightTransaction monitoringhashtag
chevron-rightBalance validationhashtag

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