Docs / Protocol

Program and accounts(16)

Program id: published here at deployment

The program is written with Anchor. Every account below is a PDA of the program, derived from the seeds shown. Integers in seeds are little-endian.

AccountSeedsHolds
Config["config"]admin, pending admin, keeper, treasury, signer set and threshold, token settings, fee and curve parameters, house state, counters
Vault["vault"]the USDC token account holding all collateral; its authority is the Config PDA
Market["market", id u16]feed id, Pyth account and feed id, leverage and caps, open interest, impact parameters, active, retired, frozen price
PriceBook["book", id u16]a ring of 64 verified grid prices
UserAccount["user", owner]available, locked, paper, reward debt, rewards owed, session key and expiry, claim index, open counts
Request["request", id u64]a pending open or close with its fill timestamp; closed at execution or cancel, rent to its payer
Position["position", id u64]side, margin, leverage, size, entry and bust price, open time; closed at settlement, rent to its payer
Claim["claim", owner, index u32]start, end, collected; closed when fully paid and collected, rent to its payer

Instructions

InstructionWho can call it
initializeadmin, once
add_market, update_market, retire_marketadmin
set_opens_paused, set_signers, set_token, set_treasury, set_keeperadmin
transfer_admin / accept_adminadmin / the proposed admin
create_userthe owner, who pays its rent
deposit, withdrawthe owner only, never a session key
create_session, revoke_sessionthe owner
request_open, request_closethe owner or its active session key
cancel_requestanyone, after the TTL, never once executed
post_price, execute, execute_with_proof, liquidateanyone
collect_claim, claim_rewardsthe owner
donate, push_excess, withdraw_treasuryanyone

Events

The program emits Anchor events that the site reads for history, among them RequestCreated, PositionOpened, PositionClosed, PositionLiquidated, Queued, QueuePaid, PaperMinted and RewardsDistributed.

Units

QuantityUnit
MoneyUSDC base units, 6 decimals
Prices8 decimals, RedStone format: price × 1e8
Paper6 decimals, stored as u128
Ratesbasis points, 10,000 = 100 %