Use this file to discover all available pages before exploring further.
A type-safe CosmWasm client for interacting with Bolt’s zero slippage execution layer on Archway. Query oracle prices, inspect pool state, simulate swaps off-chain, and execute trades programmatically.
An Archway-compatible wallet (Keplr, Leap, etc.) for signing transactions
Access to Archway RPC endpoints (the client uses https://rpc.mainnet.archway.io for mainnet and https://rpc.constantine.archway.io for testnet by default)
2
Installation
NPM
YARN
PNPM
npm install @bolt-liquidity-hq/cosmwasm-client
yarn add @bolt-liquidity-hq/cosmwasm-client
pnpm add @bolt-liquidity-hq/cosmwasm-client
3
Initialize the Bolt client
The SDK supports different environments:
type Environment = 'mainnet' | 'testnet';
Mainnet
Testnet
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';const client = new BoltCosmWasmClient();
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';const client = new BoltCosmWasmClient({ environment: 'testnet',});
4
Query all assets
// Get all supported assetsconst assets = await client.getAssets();assets.forEach((asset) => { console.log(`${asset.symbol} (${asset.name}): ${asset.denom}`); console.log(` Decimals: ${asset.decimals}`);});// Find a specific assetconst archAsset = assets.find((a) => a.symbol === 'ARCH');console.log(`ARCH denom: ${archAsset?.denom}`); // "aarch"
5
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 USDCconst 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'}`);
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';// Initialise clientconst client = new BoltCosmWasmClient({ environment: 'mainnet', // 'testnet' | 'mainnet' customOverride: { chainConfig: { rpcEndpoint: 'https://my-custom-rpc-endpoint...', // Remove this if you want to use the default public RPC endpoint } }});
getOracleConfig() retrieves the current configuration settings from the Bolt Oracle smart contract on Archway. This configuration governs how price feeds are managed, including update thresholds, expiration times, and administrative settings.
Method Signature
Returns
async getOracleConfig(): Promise<OracleConfig>
type OracleConfig = { admin: Address; // Archway address authorised to update oracle settings and prices priceThresholdRatio: string; // Minimum price change ratio required for updates (decimal string) priceExpireTime: Duration | null; // Time duration before prices become stale};type Duration = { secs: number; // Seconds component nanos: number; // Nanoseconds component (always 0 in current implementation)};
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
async getAssets(): Promise<Asset[]>
type Asset = { symbol: string; // Trading symbol (e.g., "ARCH", "USDC") name: string; // Full asset name (e.g., "Archway", "USD Coin") chainId: string; // Blockchain network identifier denom: string; // Chain-specific denomination decimals: number; // Number of decimal places logo?: string; // Optional logo URL coingeckoId?: string; // Optional CoinGecko identifier};
Usage example
import { BoltCosmWasmClient } from '@bolt-liquidity-hq/cosmwasm-client';const client = new BoltCosmWasmClient();const assets = await client.getAssets();console.log('Available assets:', assets.length);assets.forEach(asset => { console.log(`${asset.symbol}: ${asset.name} (${asset.decimals} decimals)`);});// Find a specific assetconst archAsset = assets.find((a) => a.symbol === 'ARCH');console.log(`ARCH denom: ${archAsset?.denom}`); // "aarch"
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.
type OracleAssetPair = { base: OracleAsset; // Base asset information quote: OracleAsset; // Quote asset information};type OracleAsset = { name: string; // Asset name (currently same as symbol) symbol: string; // Trading symbol (e.g., "ARCH", "ATOM") precision: number; // Number of decimal places};
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
async getAllPrices(): Promise<Price[]>
type Price = { assetPair: string; // Currently empty string due to contract limitations price: string; // Current price as decimal string expiryTime: string; // Unix timestamp in nanoseconds when price expires};
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.
type InvertiblePrice = { assetPair: string; // Trading pair in format "baseDenom:quoteDenom" price: string; // Current price as decimal string expiryTime: string; // Unix timestamp in nanoseconds when price expires isInverse: boolean; // Always false in current implementation};
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.
type BaseLiquidityDetails = { baseLiquidity: Coin; // Base asset liquidity information totalShares: string; // Total liquidity shares};type Coin = { amount: string; // Quantity of base asset liquidity denom: string; // Type of the base asset};
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.
type BaseLiquidityDetails = { baseLiquidity: Coin; // Base asset liquidity information totalShares: string; // Total liquidity shares};type Coin = { amount: string; // Quantity of base asset liquidity denom: string; // Type of the base asset};
getRouterConfig() queries the router smart contract to retrieve its current configuration settings. The Router is the entry-point contract unique to the Archway deployment that governs how swaps are executed, fees are collected, and new pools are deployed.
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 on Archway.
Method Signature
Returns
async getAllPools(): Promise<Pool[]>
type Pool = { poolAddress: string; // Contract address of the pool baseDenom: string; // Type of the base asset quoteDenoms: string[]; // Array of available quote asset types};
Usage example
const allPools = await client.getAllPools();console.log(`Total pools available: ${allPools.length}`);// Display all pools and their trading pairsallPools.forEach((pool, index) => { console.log(`\nPool ${index + 1}: ${pool.poolAddress}`); console.log(` Base asset: ${pool.baseDenom}`); console.log(` Quote assets: ${pool.quoteDenoms.length}`); pool.quoteDenoms.forEach(quote => { console.log(` - ${quote}`); });});// Find pools for specific base assetconst archPools = allPools.filter(pool => pool.baseDenom === "aarch");console.log(`ARCH pools found: ${archPools.length}`);
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.
getPoolByDenom() queries the router smart contract to retrieve pool information for a specific base asset on Archway. Fetches pool details for the pool matching the provided asset denomination.
type Pool = { poolAddress: string; // Contract address of the pool baseDenom: string; // Type of the base asset quoteDenoms: string[]; // Array of available quote asset types};
Usage example
// Get pool for ATOM base assetconst pool = await client.getPoolByDenom('ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2');console.log('Pool Address:', pool.poolAddress);console.log('Base Asset:', pool.baseDenom);console.log('Quote Assets:', pool.quoteDenoms.length);pool.quoteDenoms.forEach(quote => { console.log(` - ${quote}`);});
getPoolConfigByDenom() retrieves pool configuration by base asset denomination. This is a convenience function that combines pool lookup and configuration retrieval.
type PoolConfig = { priceOracleContract: string; // Price oracle contract used by this pool protocolFeeRecipient: string; // Address that receives protocol fees protocolFee: string; // Protocol fee percentage (e.g., "0.003" = 0.3%) lpFee: string; // LP fee percentage (e.g., "0.002" = 0.2%) allowanceMode: string; // Allowance mode for pool operations lps: string[]; // Array of authorised LP addresses minBaseOut: string; // Minimum base asset output amount for trades};
Usage example
// Get pool configuration for ATOM base assetconst config = await client.getPoolConfigByDenom('ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2');console.log('Price Oracle:', config.priceOracleContract);console.log('Protocol Fee Recipient:', config.protocolFeeRecipient);console.log('Protocol Fee:', config.protocolFee);console.log('LP Fee:', config.lpFee);console.log('Allowance Mode:', config.allowanceMode);console.log('Authorized LPs:', config.lps.length);console.log('Min Base Out:', config.minBaseOut);
simulateSwap() simulates a swap operation to calculate the expected output amount without executing the transaction. Performs a dry run that takes into account current pool conditions, oracle prices, and fees. Use this for accurate estimates before executing.
type SimulateSwapResult = { poolAddress: string; // Contract address of the pool amountOut: string; // Amount expected to be received after the swap assetOut: string; // Denom of the asset that will be received protocolFee: string; // Protocol fee amount that would be charged lpFee: string; // LP fee amount that would be charged dynamicFeePercentage?: string; // Percentage going to dynamic fees totalFees: string; // Sum of protocolFee and lpFee (dynamic fee distributed between both)};
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
async swap(params: SwapParams, signer: Signer): Promise<SwapResult<ExecuteResult>>type SwapParams = { assetIn: string; // Denomination of the asset being sold amountIn: string; // Exact amount of input asset to swap (in minimal units) assetOut: string; // Denomination of the asset being bought minimumAmountOut?: string; // Optional minimum acceptable amount of output asset receiver?: Address; // Optional recipient address for swapped assets};
type SwapResult<ExecuteResult> = { txOutput: ExecuteResult; // Complete transaction response amountOut: string; // Actual amount of output asset received assetOut: string; // Output asset denomination txHash: string; // Transaction hash for tracking};