Skip to main content
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. Package: @bolt-liquidity-hq/cosmwasm-client

Prerequisites

  • Node.js 18+
  • Archway-compatible wallet (Keplr, Leap, or equivalent)
  • RPC endpoint (defaults provided for mainnet and testnet)
NetworkDefault RPC Endpoint
Mainnethttps://rpc.mainnet.archway.io
Testnethttps://rpc.constantine.archway.io
For production integrations, use a dedicated RPC provider. Public endpoints have rate limits that may affect high-frequency quoting.

Installation

npm install @bolt-liquidity-hq/cosmwasm-client

Quick start

1

Install the package

Choose your package manager above and install @bolt-liquidity-hq/cosmwasm-client.
2

Initialise the client

import { BoltCosmWasmClient } from "@bolt-liquidity-hq/cosmwasm-client";

// Mainnet (default)
const client = new BoltCosmWasmClient();

// Testnet
const client = new BoltCosmWasmClient({ environment: "testnet" });
3

Fetch oracle prices

const prices = await client.getAllPrices();
console.log(prices);
4

Simulate a swap

const quote = await client.simulateSwap({
  assetIn: "ibc/usdc_denom",
  amountIn: "1000000",
  assetOut: "aarch",
});

console.log(quote.amountOut, quote.totalFees);

Advanced initialization

The client supports full customization for non-standard environments, custom chain configs, or pre-existing signer instances.
const client = new BoltCosmWasmClient({
  environment: "mainnet", // or "testnet"
  customOverride: {
    chainConfig: {
      id: "archway-1",
      name: "Archway",
      rpcEndpoint: "https://your-rpc.example.com",
      restEndpoint: "https://your-rest.example.com",
    },
    contracts: {
      oracle: "archway1...",
      router: "archway1...",
    },
    nativeTokenDenom: "aarch",
    assetsConfig: {
      // Custom asset configuration
    },
  },
  cosmWasmClient: existingClient,       // Optional: pass pre-existing CosmWasmClient or ArchwayClient
  signer: offlineSigner,                // Optional: pass OfflineSigner for transactions
  signingCosmWasmClient: signingClient, // Optional: pass pre-existing SigningCosmWasmClient or SigningArchwayClient
});
All fields in customOverride are optional. Use them when you need to point the client at a custom deployment or pass in your own RPC/signer instances.

API Reference

Oracle methods

The oracle is the pricing backbone of every Bolt swap. These methods give you access to the deterministic reference prices that the Outpost validates against.
Returns the oracle contract configuration.
const config = await client.getOracleConfig();
Returns: OracleConfig
FieldTypeDescription
adminAddressOracle admin address
priceThresholdRatiostringMax deviation ratio before rejection
priceExpireTimeDuration or nullStaleness window ({secs, nanos})

Asset methods

Query which assets are supported on the Outpost and their oracle configurations.
Returns all supported assets with metadata.
const assets = await client.getAssets();
Returns: Asset[]
FieldTypeDescription
symbolstringTrading symbol (e.g., "ARCH")
namestringFull asset name
chainIdstringBlockchain identifier
denomstringChain-specific denomination (IBC or native)
decimalsnumberDecimal precision
logostring?Optional logo URL
coingeckoIdstring?Optional CoinGecko identifier

Router and pool methods

Inspect the Router configuration and Outpost pool state. The Router is the entry-point contract unique to the Archway deployment.
Returns the Router’s default configuration.
const routerConfig = await client.getRouterConfig();
Returns: RouterConfig
FieldTypeDescription
adminstringRouter admin address
defaultPriceOracleContractstringDefault oracle contract
defaultProtocolFeeRecipientstringFee destination
defaultProtocolFeestringDefault protocol fee rate
defaultLpFeestringDefault LP fee rate

Swap methods

Simulate swaps off-chain for quoting, then execute on-chain when ready.
Simulates a swap without executing it. Returns the expected output, fee breakdown, and settling pool address.
const quote = await client.simulateSwap({
  assetIn: "ibc/usdc_denom",
  amountIn: "1000000",
  assetOut: "aarch",
});
Returns: SimulateSwapResult
FieldTypeDescription
poolAddressstringPool that would settle this trade
amountOutstringExpected output amount
assetOutstringOutput asset denomination
protocolFeestringProtocol fee component
lpFeestringLP fee component
dynamicFeePercentagestring?Dynamic fee if applicable
totalFeesstringCombined fees
Bolt quotes are deterministic. Given the same pool state and oracle price, simulateSwap() returns identical results whether called off-chain or on-chain.

Type definitions

type Asset = {
  symbol: string;       // "ARCH"
  name: string;         // "Archway"
  chainId: string;      // Chain identifier
  denom: string;        // Native or IBC denom
  decimals: number;     // 18
  logo?: string;        // Optional logo URL
  coingeckoId?: string; // Optional CoinGecko ID
};
type SwapParams = {
  assetIn: string;          // Input asset denom
  amountIn: string;         // Amount in smallest units
  assetOut: string;         // Output asset denom
  minimumAmountOut?: string; // Slippage protection
  receiver?: Address;       // Recipient (defaults to sender)
};
Use minimumAmountOut rather than a slippage percentage. Calculate it from your simulateSwap() result: amountOut * (1 - tolerance).
type Pool = {
  poolAddress: string;   // Contract address
  baseDenom: string;     // Base asset denomination
  quoteDenoms: string[]; // Supported quote assets
};

type PoolConfig = {
  priceOracleContract: string;
  protocolFeeRecipient: string;
  protocolFee: string;
  lpFee: string;
  allowanceMode: string;
  lps: string[];
  minBaseOut: string;
};

type BaseLiquidityDetails = {
  baseLiquidity: Coin;  // { amount: string, denom: string }
  totalShares: string;
};
type Price = {
  assetPair: string;  // "baseDenom:quoteDenom"
  price: string;      // Decimal string
  expiryTime: string; // Unix nanoseconds
};

type InvertiblePrice = {
  assetPair: string;
  price: string;
  expiryTime: string;
  isInverse: boolean;
};
type OracleConfig = {
  admin: Address;
  priceThresholdRatio: string;
  priceExpireTime: Duration | null;
};

type Duration = {
  secs: number;
  nanos: number;
};

type RouterConfig = {
  admin: string;
  defaultPriceOracleContract: string;
  defaultProtocolFeeRecipient: string;
  defaultProtocolFee: string;
  defaultLpFee: string;
};

type OracleAssetPair = {
  base: OracleAsset;
  quote: OracleAsset;
};

type OracleAsset = {
  name: string;
  symbol: string;
  precision: number;
};
type SimulateSwapResult = {
  poolAddress: string;
  amountOut: string;
  assetOut: string;
  protocolFee: string;
  lpFee: string;
  dynamicFeePercentage?: string;
  totalFees: string;
};

type SwapResult<ExecuteResult> = {
  txOutput: ExecuteResult;
  amountOut: string;
  assetOut: string;
  txHash: string;
};

Error handling

The SDK provides typed error classes for all failure modes. Wrap SDK calls in try-catch blocks and handle each type appropriately.
ErrorCauseFix
NotFoundErrorAsset, pool, or oracle not foundVerify denoms and pool addresses
InvalidParameterErrorBad address or negative amountValidate inputs before calling
InvalidObjectErrorObject does not exist on-chainConfirm addresses and network
InvalidTypeErrorType mismatch in paramsEnsure denoms and amounts are strings
MissingParameterErrorRequired field omittedProvide all non-optional fields
TransactionFailedErrorOn-chain execution failedCheck gas, inventory, oracle freshness
ParseErrorFailed to deserialize dataRetry or switch RPC endpoint
import {
  NotFoundError,
  InvalidParameterError,
  TransactionFailedError,
} from "@bolt-liquidity-hq/cosmwasm-client";

try {
  const quote = await client.simulateSwap({
    assetIn: "ibc/usdc_denom",
    amountIn: "1000000",
    assetOut: "aarch",
  });
} catch (error) {
  if (error instanceof NotFoundError) {
    console.error("Asset or pool not found:", error.message);
  } else if (error instanceof TransactionFailedError) {
    console.error("Transaction failed:", error.message);
  } else {
    throw error;
  }
}

Archway 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.