> ## Documentation Index
> Fetch the complete documentation index at: https://docs.boltliquidity.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Off-Chain Quoting

> Technical reference for Bolt's deterministic off-chain quoting model. Understand why quotes are stable, how state freshness works, and when to use off-chain simulation.

Bolt's pricing and execution logic is fully deterministic given the current pool state and oracle price. This allows integrators to 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.

<Info>
  Bolt quotes are deterministic. Given the same pool state and oracle price, the output is identical on-chain and off-chain. This eliminates quote staleness and enables batch route evaluation at scale.
</Info>

***

## Why this model is different

Traditional AMMs derive price from a bonding curve where every trade moves the price. A quote becomes stale the moment another trade executes, because the curve has shifted. Bolt's prop-AMM references an external oracle instead, so trade size does not affect the quoted price and quotes remain stable across consecutive trades.

This has three practical consequences for integrators:

**No gas overhead.** Simulate routes without paying transaction costs. The math is reproducible locally.

**No MEV exposure.** Off-chain quotes are not broadcast on-chain, eliminating front-running risk during route evaluation.

**Batch efficiency.** Test hundreds of routes in parallel. Because each quote is a pure function of pool state and oracle price, there is no interaction between simulations.

***

## The quoting flow

<Steps>
  <Step title="Index pool state">
    Cache the current inventory, fee parameters, and pool thresholds for each Bolt pool. Pool state changes infrequently between swaps, so local caching is effective.
  </Step>

  <Step title="Fetch oracle price">
    Obtain the current oracle price for the asset pair. This is the authoritative reference for all settlement math.
  </Step>

  <Step title="Apply contract math">
    Compute `amountOut` using the oracle price, fee rate, and inventory constraints. See [Contract Math](/developers/reference/protocol/contract-math) for the full formula.
  </Step>

  <Step title="Evaluate inventory">
    Confirm that available pool inventory is sufficient to settle the requested `amountIn`. If insufficient, the quote is not executable.
  </Step>

  <Step title="Return quote">
    The deterministic `amountOut` is valid as long as pool state and oracle price remain unchanged.
  </Step>
</Steps>

***

## SDK shortcut: simulateSwap()

For integrations that don't need to implement the full contract math locally, the SDK's `simulateSwap()` method performs a deterministic dry run with no gas cost.

```typescript theme={null}
import { BoltSuiClient } from '@bolt-liquidity-hq/sui-client';

const client = new BoltSuiClient();

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}`);
```

<Tip>
  Use `simulateSwap()` for single-pair checks and UI price displays. Reserve the full off-chain math implementation for batch route evaluation across many pools and pairs simultaneously.
</Tip>

***

## State freshness

<AccordionGroup>
  <Accordion title="When to refresh pool state">
    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.
  </Accordion>

  <Accordion title="Oracle price expiry">
    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.
  </Accordion>

  <Accordion title="Re-validating before submission">
    For high-value trades, re-check pool inventory immediately before on-chain submission. Setting `minimumAmountOut` on the swap call provides a safety net against state changes between simulation and execution.
  </Accordion>
</AccordionGroup>

***

## Reference materials

<Warning>
  The contract math formulas and reference test vectors are distributed directly by the Bolt team to ensure they stay in sync with the live Outpost. [Contact the team](https://t.me/BoltOnboarding) or [book a call](https://calendar.google.com/calendar/u/0/appointments/schedules/AcZssZ0h8Dz0XD9uiYnrWu6PUHvRfnuoNjXyCJYnzFX8t548I1YO-qnJxJSOrvuWeenqacByagNyyB0E) to obtain the latest version.
</Warning>

<CardGroup cols={2}>
  <Card title="Contract Math" icon="square-root-variable" href="/contract-math">
    Oracle-anchored pricing formulas and fee calculations.
  </Card>

  <Card title="Pool State Indexing" icon="database" href="/pool-state-indexing">
    How to index and subscribe to Outpost state changes.
  </Card>
</CardGroup>
