Architecture
One Anchor program, programs/squeeth (Anchor 0.31.1). Program id on
Solana mainnet: 5sNmL3fVsgLEBEQBiVHDR9gwrdUo2uEn7RWhcWhE8Qf6. Market account: BuUPDFRiV6pcc6UpHxLLKJCndPHscZuVBxRPmwK7auDc.
Accounts
| Account | Seeds | Owner | Holds |
|---|---|---|---|
| Market | ["market"] | program | parameters, NF, pool reserves, price accumulator, total debt, and the pool's SOL as lamports |
| Power mint | ["power"] | SPL Token | the token, 9 decimals, mint authority = Market |
| Pool tokens | ["pool_tokens"] | SPL Token | the pool's tokens, authority = Market |
| Vault | ["vault", owner] | program | one short's SOL collateral (lamports) and debt (token base units) |
| LP position | ["lp", owner] | program | one provider's pool shares |
| Price | 7UVimffxr9ow1uXYxsr4LHAcV58mLzhmwaeKvJ1pjLiE | rec5EKMGg6MxZYaMdyBfgwp4d5rB9T1VQH5pJv5LtFJ | SOL/USD, PriceUpdateV2 |
There is exactly one market per program, because its address is the fixed seed ["market"].
Market fields
| Field | Meaning |
|---|---|
authority | the account that created the market (the upgrade authority) |
nf_wad | normalization factor × 10^18 |
last_funding_ts | last time funding was applied |
funding_period | seconds, set at creation, 60 to 7,776,000 (90 days) |
twap_window | seconds, set at creation, 5 to 3,600 |
pool_sol, pool_tok, lp_total | pool reserves and shares |
cum, cum_ts, prev_cum, prev_ts, cur_cum, cur_ts | the pool price accumulator (Q32 lamports per base unit × seconds) |
total_debt | all tokens minted and not yet repaid |
Who may create the market
init_market checks that the signer is the program's upgrade authority, read from the program data account. Nobody else can create a market with different parameters.
The price reader
read_price accepts only:
- an account owned by the
Pyth receiver, with the PriceUpdateV2discriminator, - verification level Full (byte 40 = 1),
- the SOL/USD feed id at bytes 41 to 72,
- a positive price published at most 120 seconds ago,
- a confidence at most 2% of the price.
Anyone may post a fresher fully verified update, so a buyer or a liquidator never waits for a keeper.
Compute
Measured on the local validator:
| Instruction | Compute units |
|---|---|
| mint_power | 18,078 |
| buy | 15,283 |
| poke | 17,505 |
| liquidate | 30,997 |
| sell | 14,070 |
The mainnet build is 552,328 bytes.