Skip to main content
Bolt’s pricing and execution logic is fully deterministic given the current pool state and oracle price. This means you can simulate amountIn to amountOut off-chain without issuing repeated on-chain quote calls, and get identical results to what the Outpost would return on-chain.
Off-chain simulation is recommended for applications that require sub-300ms quote latency, route optimization across many liquidity sources, or trade splitting and pathfinding. If you only need a quick quote for a single swap, simulateSwap() in the SDK handles this in one call.

How off-chain quoting works

Unlike traditional AMMs, where price depends on pool depth and changes with every trade, Bolt’s oracle-anchored pricing is independent of pool depth. A quote remains valid as long as the oracle price and pool inventory are unchanged. No bonding curve, no price impact, no quote staleness between trades.
1

Index current pool state

Pull the current inventory, fee parameters, and pool thresholds from the Bolt Outpost. Pool state changes infrequently between swaps, so you can cache it locally.
import { BoltSuiClient } from '@bolt-liquidity-hq/sui-client';

const client = new BoltSuiClient();

// Get all pools and their configurations
const pools = await client.getAllPools();
const poolConfig = await client.getPoolConfigByDenom(
  '0x2::sui::SUI',
  '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'
);

console.log('Protocol fee:', poolConfig.protocolFee);
console.log('LP fee:', poolConfig.lpFee);
2

Fetch the current oracle price

Query the Bolt Oracle for the live reference price. This is the authoritative price used for all settlement math.
// Get price for a specific pair
const price = await client.getPrice(
  '0x2::sui::SUI',
  '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC'
);

console.log(`SUI/USDC price: ${price.price}`);
console.log(`Expires: ${new Date(Number(price.expiryTime) / 1000000)}`);

// Or fetch all prices at once for batch evaluation
const allPrices = await client.getAllPrices();
3

Apply the Bolt contract math

Compute amountOut using the oracle price, fee rates, and inventory constraints. Because pricing is deterministic, the result is identical to what the on-chain Outpost would return.
Contact the Bolt team to obtain the latest contract math formulas and reference test vectors. These must always match the current on-chain implementation. Reach out on Telegram or book a call.
4

Evaluate inventory and execute

Confirm that pool inventory is sufficient to settle the requested amount. If inventory is available, submit the swap on-chain with confidence that the quote matches.
// Check pool liquidity before submitting
const liquidity = await client.getAllBaseAssetsLiquidity();

Object.entries(liquidity).forEach(([denom, details]) => {
  console.log(`${denom}: ${details.baseLiquidity.amount} available`);
});

Quick path: simulateSwap()

If you don’t need to implement the full contract math locally, the SDK’s simulateSwap() method performs a deterministic dry run against the current pool state and oracle price with no gas cost.
const simulation = await client.simulateSwap({
  assetIn: '0x2::sui::SUI',
  amountIn: '1000000000', // 1 SUI (9 decimals)
  assetOut: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
});

console.log(`Expected output: ${simulation.amountOut}`);
console.log(`Protocol fee: ${simulation.protocolFee}`);
console.log(`LP fee: ${simulation.lpFee}`);
console.log(`Total fees: ${simulation.totalFees}`);
simulateSwap() is the fastest way to get a quote. Use it for single-pair checks and UI price displays. Reserve the full off-chain math implementation for batch route evaluation across many pools and pairs.

Determinism guarantees

Given identical pool state and oracle price, the computed amountOut is exactly the same whether calculated on-chain by the Outpost or off-chain by your integration. There is no randomness, no auction, and no variable spread.
Traditional AMMs derive price from a bonding curve where every trade moves the price. Bolt’s prop-AMM references an external oracle, so trade size does not affect the quoted price. A 10 USDC swap and a 1,000 USDC swap receive the same rate per unit.
Because pricing is oracle-anchored rather than inventory-derived, quotes remain valid across multiple consecutive trades as long as the oracle price and pool inventory are unchanged. This eliminates the “quote goes stale the moment someone else trades” problem.

Use cases

Aggregators evaluate multiple routes simultaneously by simulating swaps across all available pools. Off-chain quoting enables batch route evaluation without repeated RPC calls.
1

Cache pool state for all Bolt pools

2

Compute quotes for all possible routes in parallel

3

Select the route with the best amountOut

4

Submit a single on-chain settlement


Handling state freshness

Pool state changes when swaps execute or when pool parameters are updated. For most integrations, refreshing every 10 to 15 seconds provides a good balance between accuracy and RPC efficiency. For high-frequency applications, use WebSocket subscriptions to the Outpost contract if your RPC provider supports them.
Every oracle price includes an expiryTime field (Unix timestamp in nanoseconds). Always check that the price has not expired before using it in your local math. The SDK’s getOracleConfig() method returns the priceExpireTime setting so you can anticipate refresh intervals.
const config = await client.getOracleConfig();
console.log('Price expiry window:', config.priceExpireTime?.secs, 'seconds');
For high-value trades, re-check pool inventory immediately before on-chain submission. Pool state can change between your simulation and the transaction landing on-chain. Setting minimumAmountOut on the swap call provides an additional safety net.

Reference materials

Bolt provides swap math formulas, worked examples, and reference test vectors for off-chain implementation. These must always match the current on-chain contracts.
The contract math and test vectors are distributed directly by the Bolt team to ensure they stay in sync with the live Outpost. Contact the team or book a call to obtain the latest version.

Contract Math

Oracle-anchored pricing formulas and fee calculations.

Pool State Indexing

How to index and subscribe to Outpost state changes.

Sui TypeScript SDK

Full API reference including simulateSwap() and pool queries.

Sui Outpost Addresses

Contract addresses for mainnet and testnet.