RECKLESS is one Anchor program, a stateless keeper and a web app. There is no backend database.
Accounts
| Account | Seeds | Holds |
|---|---|---|
Config | ["config"] | Admin, mints, treasury, parameters, pool accounting, staking totals |
| Vault | ["vault"] | The pool's USDC |
| Venue mint | ["venue_mint"] | The venue token; the program is its mint authority |
| Stake vault | ["stake_vault"] | Staked venue tokens |
| Buyback | ["buyback"] | USDC set aside for buyback and burn |
Market | ["market", feed_id] | Feed id, price exponent, market parameters, open interest and the book's size per side |
Position | ["position", owner, nonce] | One position: side, margin, leverage, terms, status, entry, claim, emission epoch and weight |
StakeAccount | ["stake", owner] | One staker's amount, reward debt and cooldown |
Emission | ["emission"] | Open epoch, high-water mark and a ring of the last 64 epochs |
Flow of one trade
| Step | Instruction | Accounts written |
|---|---|---|
| 1 | request_open | Position (created), Market open interest, Vault, Config pool |
| 2 | execute_open | Position entry and status, Market book size |
| 3 | request_close | Position status |
| 4 | execute_close or liquidate | Position, Market, Config pool, Vault, Emission weight |
| 5 | close_epoch | Emission record |
| 6 | claim_emission | Venue mint supply, the trader's token account |
Marking the book without visiting it
Each market keeps long_size, long_notional, short_size and short_notional. Traders' unrealised profit at any price is linear in these sums, so close_epoch can value the whole pool across every market with one price per market and no list of positions.
The keeper
The keeper watches pending positions and posts the first eligible signed price with post_price and fills with execute_open or execute_close. It earns the escrowed keeper_fee per fill. Anyone can run it; fills are permissionless and the price it must use is fixed by the program.