How it works

1. The index

The program reads the Pyth SOL/USD price P and computes what one token should be worth:

index (in SOL per token) = NF × P / 100
index (in dollars)       = NF × P² / 100

NF starts at exactly 1 (stored as nf_wad = 10^18) and only changes through funding.

2. A short mints

A short opens a vault, deposits SOL, and calls mint_power(amount). The program:

  1. Reads the price (read_price), applies funding.
  2. Adds amount to the vault's debt.
  3. Checks collateral × 10,000 ≥ debt value × 15,000: the vault must stay at 150% or more.
  4. Mints amount tokens to the short.

The debt value of amount base units is amount × NF × P / 100 lamports (debt_value). The token has 9 decimals.

3. Holders buy from the pool

The pool holds SOL and tokens. buy(lamports_in, min_out) swaps SOL for tokens with the constant product rule and a 0.3% fee:

out = reserve_out × a / (reserve_in × 10,000 + a),  a = amount_in × (10,000 − 30)

The tokens land in the buyer's own token account. That is the whole long position: a token in a wallet. sell(tokens_in, min_out) is the reverse.

4. Funding

The pool keeps a running sum of its price over time. The market price used for funding (mark) is the pool's average over one to two TWAP windows. On every update:

ratio = clamp(mark / index, 0.8, 1.25)
NF   ← NF × ratio ^ (−dt / funding_period),   dt capped at 86,400 s

If the token trades above its index (ratio > 1), NF shrinks. Every short's debt is measured in NF-adjusted value, so it shrinks too. Holders pay shorts without a single transfer. If the token trades below its index, NF grows and shorts pay holders.

5. Liquidation

When a vault is under 150%, anyone may call liquidate(amount):

6. Closing a short

burn_power(amount) repays debt with tokens and needs no price, because it only makes a vault safer. withdraw(lamports) takes SOL out and, if debt remains, checks the 150% line again.

Next: Architecture