Docs, Build

Architecture

Accounts, instructions and the keeper

RECKLESS is one Anchor program, a stateless keeper and a web app. There is no backend database.

Accounts

AccountSeedsHolds
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

StepInstructionAccounts written
1request_openPosition (created), Market open interest, Vault, Config pool
2execute_openPosition entry and status, Market book size
3request_closePosition status
4execute_close or liquidatePosition, Market, Config pool, Vault, Emission weight
5close_epochEmission record
6claim_emissionVenue 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.

NextIntegration