Every quote shows exactly what the user pays, in US dollars, line by line. Nothing is hidden in the exchange rate: the fees add up to the difference between what the user sends and what they receive, plus the gas they pay.

Fee types

A quote’s fees has a total (totalUsd) and a list of items. Each item has a kind and an amount in dollars. A fee can be "0.00". It’s listed so you can see it was counted. New kinds may appear over time, so show any kind you don’t recognize by its amount.

Other numbers in a quote

Dollar amounts are strings with two decimals, rounded down. A swap’s status keeps the numbers from when it was quoted.

An example

Here’s a quote for 1,000 USDC on Base to USDC on Starknet:
  • The user sends $1,000.00 and receives $998.82, a difference of $1.18.
  • They also pay $0.02 in gas for the deposit.
  • So the total cost is $1.20, or 0.12%. That’s fees.totalUsd and costBps.
  • The $0.70 network fee is gas on both chains, including the user's $0.02. The $0.50 is the solver’s margin.
  • Price impact is 0, because swapping USDC for USDC needs no trade.

What to show your users

  • What they’ll receive: to.amount, plus to.minAmount as the minimum when there is one.
  • The total cost: for example, “Total cost $1.20 (0.12%)”.
  • The breakdown, if they ask: each fee, and price impact when it isn’t zero.
  • Only what’s there: every number except the amounts is optional. Leave out anything a quote doesn’t include.
These numbers describe the swap when it was quoted. What the solver commits to is the amount, not the fee breakdown.

How prices are set

  • Cross-chain swaps: solvers compete for every quote, and the best price wins. The winning solver reports the fees. If its fees don’t add up to within a cent, Tern leaves the breakdown out and shows only the amounts.
  • Same-chain swaps: Tern asks DEX aggregators for routes and picks the best. The dollar values come from the aggregators’ own pricing.
  • Private swaps: priced like same-chain swaps, with privacy in place of network.