Quickstart
1
Prerequisites
Before using the SDK, make sure you have:☑️ Node.js 18+ installed☑️ A Sui-compatible wallet (Sui Wallet, Suiet, etc.) for signing transactions☑️ Access to SUI RPC endpoints: The client uses
https://fullnode.mainnet.sui.io:443 for mainnet and https://fullnode.testnet.sui.io:443 for testnet by default2
Installation
- NPM
- YARN
- PNPM
3
Initialize the Bolt client
The SDK supports different environments:
- Mainnet
- Testnet
4
Query all assets
5
Execute a swap
API
Client initialization
Advanced client initialization
Advanced client initialization
Override chain configuration
Override Bolt package ID
Override Outpost contract address
Override assets configuration
Get oracle config
getOracleConfig()Retrieves the current configuration settings from the Bolt Oracle smart contract on Sui. This configuration governs how price feeds are managed, including update thresholds, expiration times, and administrative settings.- Method Signature
- Returns
How to cache Oracle config (best practice)
How to cache Oracle config (best practice)
How to monitor for price updates
How to monitor for price updates
Query prices and assets
getAssets() Retrieves all unique assets available in the Bolt execution layer by querying oracle asset pairs and enriching them with additional metadata from the client’s asset configuration.- Method Signature
- Returns
getAllOracleAssetPairs()Queries the oracle smart contract to retrieve all supported asset pairs with automatic pagination. Each asset pair represents a base/quote relationship that can be used for price queries and swaps.- Method Signature
- Returns
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.- Method Signature
- Returns
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 authorised price feeders and validated against configured thresholds.- Method Signature
- Returns
Verify pool liquidity
getPoolBaseLiquidity() Queries the router smart contract to retrieve the total base asset liquidity for a specific pool. Fetches current liquidity levels for the base asset in the specified pool.- Method Signature
- Returns
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.- Method Signature
- Returns
Get liquidity pools information
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 execution layer.- Method Signature
- Returns
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.- Method Signature
- Returns
getPoolByDenom() Queries the router smart contract to retrieve pool information for a specific base/quote asset pair on Sui. Fetches pool details for the pool matching the provided asset denominations.- Method Signature
- Returns
getPoolConfigByDenom() Retrieves pool configuration by base/quote asset pair. This is a convenience function that combines pool lookup and configuration retrieval.- Method Signature
- Returns
Simulate a swap
simulateSwap() Simulates a swap operation to calculate the expected output amount without executing the transaction. Performs a dry run taking into account current pool conditions, oracle prices, and fees. Use this for accurate estimates before executing.- Method Signature
- Returns
Execute a swap
swap() Executes a token swap transaction on the Bolt execution layer through the router contract. It performs a “swap exact in” operation where you specify exactly how much of the input asset to swap, and receive a variable amount of the output asset based on current pool conditions.- Method Signature
- Returns
Usage examples
Simple swap
Simple swap
Swap with minimum amount out limit
Swap with minimum amount out limit
Swap with custom receiver
Swap with custom receiver
Best practices
Price slippage protection
Price slippage protection
Error handling and retries
Error handling and retries
Gas estimation and optimization
Gas estimation and optimization
Error Handling
Sui Outpost Addresses
Contract addresses for mainnet and testnet.
Off-Chain Quoting
Build price discovery using deterministic quoting.
Contract Math
Understand the pricing formula behind simulateSwap().
Pool State Indexing
Index pool state for real-time integration.