Protocol

Settlement

The exact arithmetic that moves USDC between the two sides of a swap.

The arithmetic

For a swap with notional N and fixed rate K that starts at the checkpoint with timestamp t0 and total C0, in a market with reference price P0, the payer's result at a checkpoint with total C and timestamp t is:

Text
floating   = trunc(N × (C − C0) ÷ (P0 × 1000))
fixed      = trunc(N × K × (t − t0) ÷ (1e9 × 31,536,000))
payer      = floating − fixed
receiver   = −payer

trunc rounds toward zero. All values are integers: N in micro-USDC, K with 1e9 meaning 100% a year, C in 1e-9 USD per SOL, P0 in micro-USD per SOL, times in Unix seconds. A year is 365 days.

When a swap starts

Both legs start at the first funding record at or after the fill: the record of the interval that begins next. A swap filled at 10:40 starts at the 11:00 record, and its settlement there moves nothing; from then on each record counts in full for both legs. Phoenix's accumulator shows an hour's funding building up while the hour runs, so the hour already under way is never part of a swap. A fill in the second an interval starts, once that record is published, starts with it.

Inception, not increments

The formula gives the whole result since the swap opened, not the result of one checkpoint. Settlement computes it at the new checkpoint, subtracts what was already settled, and moves only the difference:

Text
move = payer(at this checkpoint) − payer(already settled)

Rounding therefore never accumulates. A swap settled after every checkpoint and a swap settled once at maturity end on the same micro-USDC.

Moving the money

A positive move goes from the receiver's balance to the payer's; a negative one goes the other way. The two balances change by the same amount in opposite directions and the market's liabilities do not change at all. USDC only leaves the vault when someone withdraws.

After each checkpoint, both balances are checked against maintenance margin. A side below it closes the position at that checkpoint; a side that cannot pay the whole move closes it as collateral exhausted. Later checkpoints are not applied to a closed position.

An example

Take a $10,000 swap at 6% in a market whose reference price is $150. One hour later, Phoenix's cumulative total has risen by 0.0012 USD per SOL.

LegAmount
Floating$10,000 ÷ $150 × 0.0012 = $0.0800
Fixed$10,000 × 6% × 1 hour ÷ 1 year = $0.0685
Payer+$0.0115, paid by the receiver

A rise of 0.0012 USD per SOL in an hour, on a $150 SOL, is funding of about 7% a year; the payer of fixed at 6% is a little ahead.

Who settles

settle is permissionless and pays no reward. It takes a position and up to eight checkpoints, and anyone can send it. Tack's crank settles every open position after each new checkpoint, so positions stay within a record or two of the source. A top-up and a liquidation settle first, so neither can act on a stale balance.