Bolt Archway TypeScript SDK
Integrate with Bolt Liquidity Protocol on Archway network 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/cosmwasm-clientyarn add @bolt-liquidity-hq/cosmwasm-clientpnpm add @bolt-liquidity-hq/cosmwasm-clientInitialize the Bolt Client
The SDK supports different environments:
type Environment = 'mainnet' | 'testnet';Mainnet
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';
const client = new BoltCosmWasmClient();Testnet
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';
const client = new BoltCosmWasmClient({
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 archAsset = assets.find((a) => a.symbol === 'ARCH');
console.log(`ARCH denom: ${archAsset?.denom}`); // "aarch"Execute a swap
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
// Get signer from wallet (implementation depends on wallet)
const signer = await DirectSecp256k1HdWallet.fromMnemonic("my mnemonic goes here", {
prefix: 'archway',
});
// Execute a swap: exactly 1 ARCH for USDC
const result = await client.swap({
assetIn: 'aarch',
amountIn: '1000000000000000000', // 1 ARCH (18 decimals)
assetOut: 'ibc/43897B9739BD63E3A08A88191999C632E052724AB96BD4C74AE31375C991F48D', // USDC
minimumAmountOut: '1900000', // Minimum 1.9 USDC (6 decimals)
, signer});
console.log(`Swapped 1 ARCH for ${result.amountOut} USDC`);
console.log(`Transaction hash: ${result.txHash}`);
console.log(`Gas cost: ${result.txOutput.gasUsed}`);
console.log(`Status: ${result.txOutput.code === 0 ? 'success' : 'failed'}`);API
Client Initialization
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';
// Initialize client
const client = new BoltCosmWasmClient({
environment: 'mainnet', // 'testnet' | 'mainnet'
customOverride: {
chainConfig: {
rpcEndpoint: 'https://my-custom-rpc-endpoint...', // Remove this if you want to use 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 Router contract config
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