All-in cost
How allInBps is measured, and why it's the one number to compare.
allInBps is the total cost of a route against mid-market, in basis points (100 bps = 1%).
allInBps = (1 − amountOut ÷ idealAmountOut) × 10,000idealAmountOut is what the amount would buy at the mid-market rate with nothing charged. USDT and USDC count as one dollar each, because that's how P2P venues price them.
The mid-market rate
For each currency we take the median of the five best ask prices and the five best bid prices on each venue, average them into a venue mid, then take the median across venues. A venue whose book is crossed by more than 2% is left out of the mid.
Leg costs
Each step in route.steps carries its own costBps, measured against that leg's fair value:
| Leg | Cost |
|---|---|
| P2P buy | How far the ad's price is above mid |
| P2P sell | How far the ad's price is below mid |
| Withdrawal | The venue's network fee as a share of the amount |
| Swap | The provider's spread and fees plus the sender's gas |
A negative leg cost means the leg paid you. That's common on swaps from USDC into USDT, since USDT often trades a fraction below USDC.
When there's no reliable mid for a currency, or the destination isn't a dollar stablecoin, allInBps falls back to the sum of leg costs, and the quote says so in warnings.