Docs

Concepts

Rates and the spread

Where a rate comes from and how the spread is built, term by term.

On this page

The rate

Ferry prices every currency in US dollars from its Pyth FX feed, EUR/USD for the euro. A pair's rate is the ratio of the two dollar prices, so EUR to USD and USD to EUR read the same feed. The dollar is the unit: USDC is priced at one dollar.

The rate never comes from a pool. Pyth sets the price; the pools' balances only move the spread.

The spread

spread = base + ⌈imbalance × k⌉ + ⌈(confidence A + confidence B) × c⌉
TermInstant laneFixing laneWhat moves it
base8 bps4 bpsFixed in Ferry's Config
k × imbalancek = 1%k = 1%How far the pair's pools sit from their target weights
c × confidencec = 1c = 1The width of Pyth's confidence interval
Pyth ratebasek × imbalancec × confidence0246810bps10 bps
The spread on one quote, in basis points: the 8 bps base, one more for a pool slightly off its target, and the oracle's confidence on top.

Imbalance

Each pool has a target weight; two pools target half the pair's dollar value each. Imbalance is how far, in basis points, the first pool's share of that value sits from its target. The balances change with deposits, withdrawals and earnings. Every 100 bps of imbalance adds 1 bp to the spread, rounded up to a whole basis point.

Confidence

Pyth publishes a confidence interval with every price. Ferry expresses each feed's interval in basis points of its price and adds the two. The dollar side has none. A feed whose interval is wider than 100 bps isn't used.

From the spread to the amount

  1. Gross amount: your amount times the input price, divided by the output price, rounded down to the token's smallest unit.
  2. Spread: the gross amount times the spread, rounded up.
  3. What they receive: the gross amount less the spread. On the instant lane the quote states this figure exactly, and the payment carries it.

On the fixing lane, the part of an order that crosses an opposite order pays no spread; only the rest pays the fixing spread. See The fixing.

Fresh prices

Every quote uses a Pyth price published within the last 30 seconds and holds for at most 30 seconds. When the payment lands, Ferry reads the signed price account again and recomputes the amount. If the result differs from the quote by a single unit, nothing is sent and you request a new quote.

Esc