Trade
Program

Program

Program

The Solana program: its accounts, who signs what, available equity and escape.

The Strobe program holds the USDC collateral, records each trader's settled equity from the engine's batches, and pays withdrawals. It is an Anchor program, version 0.1.0, at k6XskrgGjNWmqPpDvxuchdUD2aytjLJE8vfk3S945x4.

Accounts it owns

AccountAddressHolds
ConfigPDA ["config"]The admin, the sequencer, the fee recipient, the USDC mint and vault, the escape window and where settlement stands. One per program.
VaultPDA ["vault"]A USDC token account whose authority is the config. Every trader's collateral and the unswept protocol fees.
TraderPDA ["trader", owner]One per wallet: its deposits, withdrawals, settled equity, session key and last batch. Created by the first deposit or register_session.

Accounts lists every field.

Who signs what

  • The trader's wallet signs deposit, register_session and escape_withdraw, and signs withdraw together with the sequencer.
  • The sequencer (the engine's key) signs post_batch and co-signs withdraw. It co-signs only after the engine has checked the withdrawal against free margin.
  • The admin signs initialize and update_config.
  • sweep_fees needs no particular signer: it can only pay the fee recipient.

Available equity

What a trader can take out is computed in the program from the trader account:

Text
available = settled_equity
        + (deposited - deposits_credited)
        - (withdrawn - withdrawals_credited)

floored at zero. settled_equity is the equity from the last batch that carried the account. The two brackets add deposits that landed after that batch and subtract withdrawals paid since, so a deposit counts at once and a withdrawal can't be paid twice. withdraw pays up to this amount, and so does escape_withdraw, which is further capped at what the vault holds beyond unswept fees.

Fees in the vault

Each batch reports the cumulative protocol fees the engine has charged. They stay in the vault, separate from trader equity, until sweep_fees pays everything reported and not yet swept to the fee recipient's USDC associated token account.

Escape

config.last_batch_slot records the slot of the last batch (the initialize slot before the first). Once the current slot is more than 1,500 past it, escape_withdraw pays each trader who calls it their available equity and closes their trader account (Escape).

Events

Instructions that move money or change a trader emit an event through a CPI to the program's event authority, so the events appear in the transaction's inner instructions rather than in its logs. Errors and events lists them.