Skip to content
API v2 is deprecated. It stays supported, but new integrations should use the Khalani API (v3). See Migrate to v3.
API v2 · Deprecated

Quotes and pricing (v2)

GET /v2/quote prices one direction and size without creating an order. Use it on your confirmation screen: “you send X, you receive Y”. It is a required step, because the price exists nowhere else. The API never invents one.

Send srcAmount, what the user spends. You get back receive.amount, what the user is expected to get, and receive.minAmount, the least they get after slippage.

Terminal window
curl -s "https://api.hyperstream.dev/v2/quote?fromChainId=42161&from=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&toChainId=1&to=0xdAC17F958D2ee523a2206206994597C13D831ec7&srcAmount=100000000" \
-H "X-API-Key: $KHALANI_API_KEY"

Show spend.amount and receive.amount using their respective decimals. They reflect the token fees; source-chain transaction gas and the native-token relay fee in depositTx.value are additional. details.protocolFee is Khalani’s part of the fees and does not include your commission. See Fees and commission.

When slippageBps is above 0, also show receive.minAmount as the least a complete fill pays.

When earlyCancelDisabled is true, tell the user the order can’t be cancelled: it settles when it fills or its deadline passes.

A 200 means the size is fillable right now. Solvers name a minimum and a maximum on every quote, and the API refuses sizes outside them rather than pricing something it would not fill.

Prices move, and a quote reserves nothing. Two quotes seconds apart can differ.

A complete fill pays between receive.minAmount and receive.amount. A quote can carry slippage, in slippageBps. The order then publishes at the quote less the slippage, and the hub enforces that rate on every fill.

The rate per unit is guaranteed; the total is not. Orders can fill partially. If an order for 1,000 fills 600, the user receives 600’s worth at no less than the order’s rate and is refunded the rest, less the flat fee and the percentage fees on the filled 600. When a shortfall is unacceptable, such as paying an invoice of a fixed amount, read the order’s settledOutcome and top up.

build is the /v2/build request, already assembled. Send it back unchanged with the depositor’s address added:

await post("/v2/build", { ...quote.build, depositor });

From a non-EVM chain, send the user’s payoutAddr and refundAddr instead: such an order has no depositor. See Build and deposit.

build.terms is Khalani’s signed attestation of this quote. It pins the build to exactly the numbers you showed the user, and it is valid until build.terms.expiresAt (Unix seconds): five minutes, or 60 seconds on a pair with 50 bps or more of slippage. From that second on the build returns 409 and you quote again. A build with any field of build changed returns 400.

A quote is not used up by a build. You can build the same quote more than once before it expires, and each build creates a separate order.

Too small returns 400 with detail.minSrcAmount. Too large returns 409 with detail.maxSrcAmount. Re-quote at the returned figure.

  • The returned figures are adjusted so that re-quoting at them works. The limits can move between calls, so a retry can still fail. If it does, follow the new figure.
  • A too-small refusal can mean the deposit does not exceed the flat fee, solvers will not fill that little, or the output would round below one destination base unit. The flat-fee check runs first, before solvers are asked, so its minSrcAmount clears only the flat fee: quote again and follow the next figure. The other two refusals return a minSrcAmount that clears all three.
  • There is no minimum in GET /v2/params. Only a quote can tell you.

If solvers cannot be asked for the minimum, a size refusal returns retryable 503 with error: "The solver could not price this direction" and no size bound. Back off and retry the quote.

As of 19 October 2026, quoting 1,000 base units (0.001 USDC) from Arbitrum USDC to Ethereum USDT returned:

{ "error": "Deposit is at or below the flat fee, so nothing would be published", "detail": { "minSrcAmount": "99899" } }

Allow up to five seconds per solver call. Size refusals (400 after the flat-fee check, or 409) probe the minimum and may also price the maximum, for up to three sequential solver calls.

See the GET /v2/quote reference for every field and status.