Skip to content
Guides

Quotes and pricing

POST /v3/quote prices one trade without creating anything. Use it for your confirmation screen: “you send X, you receive Y”. It is a required step, because only a quote option can create an order.

Terminal window
curl -sS https://api.hyperstream.dev/v3/quote \
-H "X-API-Key: $KHALANI_API_KEY" -H "Content-Type: application/json" \
-d '{
"send": { "asset": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "amount": "10000000" },
"receive": { "asset": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" }
}'
  • send.amount is what the user sends, fees included, in base units. Quotes are exact-input: the API prices this amount.
  • receive.asset is what the user gets. You don’t send a receive amount. The quote tells you what the user gets.
  • Take both asset ids from GET /v3/catalog. Any listed asset trades against any other, on the same chain or across chains.
  • Khalani sets the slippage. You don’t send one.

The answer holds expiresAt and a list of options, each priced at current market rates. A quote doesn’t hold a price or reserve liquidity, so quote again when the user returns to a stale screen, and expect two quotes seconds apart to differ.

Quoting 10 USDC from Arbitrum to USDC on Base returns one option like this one. The amounts are illustrative, and the long id is shortened:

{
"expiresAt": "2026-11-10T02:50:21Z",
"options": [
{
"id": "opt_eyJ2IjoxLCJz…",
"requires": ["format:evm_call"],
"roles": [
{"role": "payer", "chain": "eip155:42161", "required": true, "defaultFrom": null, "constraint": "sender_bound"},
{"role": "recipient", "chain": "eip155:8453", "required": true, "defaultFrom": null, "constraint": null},
{"role": "refundTo", "chain": "eip155:42161", "required": false, "defaultFrom": "payer", "constraint": null}
],
"terms": {
"send": {"asset": {"id": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "chain": "eip155:42161", "symbol": "USDC", "decimals": 6}, "amount": "10000000"},
"receiveAsset": {"id": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "chain": "eip155:8453", "symbol": "USDC", "decimals": 6},
"minRate": "0.9966671",
"slippageBps": 3,
"fundWithinSeconds": 2400,
"fillWithinSeconds": 3600
},
"display": {
"send": {"asset": {"id": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "chain": "eip155:42161", "symbol": "USDC", "decimals": 6}, "amount": "10000000"},
"receive": {"asset": {"id": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "chain": "eip155:8453", "symbol": "USDC", "decimals": 6}, "amount": "9969662"},
"receiveMin": {"asset": {"id": "eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "chain": "eip155:8453", "symbol": "USDC", "decimals": 6}, "amount": "9966671"},
"protocolFee": {"asset": {"id": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "chain": "eip155:42161", "symbol": "USDC", "decimals": 6}, "amount": "0"},
"flatFee": {"asset": {"id": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "chain": "eip155:42161", "symbol": "USDC", "decimals": 6}, "amount": "0"},
"relayFee": {"asset": {"id": "eip155:42161/slip44:60", "chain": "eip155:42161", "symbol": "ETH", "decimals": 18}, "amount": "0"}
},
"actions": {
"cancel": {
"available": true,
"reason": null,
"signer": "refundTo",
"format": "eip191_cancel_proof"
}
}
}
]
}

The reference has the full shape. Each part of an option follows.

Pass it to POST /v3/orders unchanged, before expiresAt. An option makes one order. Its format can change, so don’t parse it.

Read expiresAt on every quote. The lifetime varies by pair, and is shorter on pairs whose price moves faster.

What you need to be able to do to fund the order. It is an open list: skip an option that requires something you don’t know or can’t do.

Value Meaning
format:evm_call Send contract calls from the payer’s wallet. Every EVM source.
format:transfer Send a plain token transfer, from any wallet. Every non-EVM source.
solana:associated_token_account Derive the returned wallet owner’s ATA for the asset’s mint under the standard SPL Token program, create it idempotently if absent (sender pays rent), and send one exact payment. No memo, split payment or top-up. See Solana funding.

For example, Solana USDT uses solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/token:Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB (six decimals). Its transfer goes to the owner’s ATA for that mint; check the catalog for availability.

A non-EVM chain can add a capability of its own. Notes for specific chains lists them.

The accounts the order needs. You bind them when you create the order. Each role has its chain, whether it is required, the role it defaults to (defaultFrom), and a constraint. sender_bound means the deposit must come from this account. An unknown constraint means you can’t use the option.

Source payer recipient refundTo
EVM Required. Sends the deposit, which must come from this account. Required, on the destination chain. Optional, defaults to payer. Signs cancels.
Non-EVM None: anyone may send the transfer. Required, on the destination chain. Required. Signs cancels.

Roles are an open list, so bind the roles each option lists. The table shows the usual ones.

What the order commits to:

  • minRate: the least a full fill pays per token of send, the whole deposit with fees still in it, in destination tokens. It equals display.receiveMin divided by display.send. Don’t take fees off send before you apply it.
  • slippageBps: the slippage Khalani applied to reach minRate.
  • fundWithinSeconds and fillWithinSeconds: the seconds from creation to the order’s two deadlines, fundBy and fillBy. See Order lifecycle.

What to show the user:

Field Show it as
send What the user pays, fees included.
receive What the user gets at the current price. Show this one.
receiveMin The least a full fill pays. It holds as long as your fees aren’t changed before the order publishes.
protocolFee The flat fee plus Khalani’s fee, rounded up. Your commission isn’t in it.
flatFee The part kept whatever fills, rounded up. An order that doesn’t fill refunds send less flatFee. Show the user that refund before they pay.
relayFee On an EVM source, an estimate of what the deposit pays on top of send, in the chain’s gas token. Null on non-EVM sources.

Source-chain gas is also on top of send. See Fees and commission.

Whether the order can be cancelled early once it trades, the role that signs the cancel (signer), and the signature format it will need. Early cancel is off unless both assets allow it. An unknown format means you can’t cancel early. Tell the user before they pay when they can’t. See Cancel and refunds.

A 200 means the size is fillable right now. The API refuses to price a size it couldn’t fill.

A full fill pays at least receiveMin. The order publishes at terms.minRate, and the hub enforces that rate on every fill.

The rate is guaranteed, the total is not. An order can fill in part. If an order for 1,000 fills 600 and is cancelled, the user receives the 600’s worth at no less than minRate, and the rest of the deposit back less the flat fee. When a shortfall is unacceptable, such as paying an invoice of a fixed amount, read the payout once the order settles and top up.

Answer Meaning What to do
422 AMOUNT_TOO_SMALL Below what would fill. details.minAmount and details.maxAmount give the range that would quote. Quote again within the range.
422 AMOUNT_TOO_LARGE Above what would fill. Same details. Quote again within the range.

details.minAmount and details.maxAmount are AssetAmount objects in the source asset, or null. Send their amount back as send.amount.

At or below the flat fee, details.minAmount only clears the fee and details.maxAmount is null. Quote again at minAmount to learn the full range. The range can move between calls, so a quote at its edge can still fail. If it does, follow the new figures.

For example, quoting 0.001 USDC from Arbitrum to USDT on Ethereum can return:

{
"code": "AMOUNT_TOO_SMALL",
"message": "Deposit is at or below the flat fee, so nothing would be published",
"details": {
"minAmount": { "asset": { "id": "eip155:42161/erc20:0xaf88d065e77c8cC2239327C5EDb3A432268e5831", "chain": "eip155:42161", "symbol": "USDC", "decimals": 6 }, "amount": "99893" },
"maxAmount": null
},
"field": "send.amount",
"recovery": "fix_request",
"retryAfterSeconds": null,
"requestId": "5e43f255-5a23-4c66-a864-2ecb8735142a"
}

The catalog doesn’t list a minimum, because it depends on solvers’ current costs. Only a quote tells you.

Answer What to do
400 UNSUPPORTED_ASSET, 400 UNSUPPORTED_PAIR The asset or pair doesn’t trade. Refresh the catalog.
400 VALIDATION_FAILED Fix the field named in field.
503 PRICE_UNAVAILABLE Pricing failed for now. Retry after retryAfterSeconds, or with a backoff.
503 NO_CAPACITY Nothing is fillable in this direction now. Retry later, without changing the size.
503 MAINTENANCE Quoting and order creation are paused. Retry after retryAfterSeconds.

Every error carries a recovery that tells you what to do, whatever the code. See Errors and retries.