Off-chain services
Four small services, in services/ in the repository. None of them holds funds. Anyone can run the keeper, and anyone can recompute points.
Indexer
Subscribes to program logs over WebSocket (with a webhook option), decodes Anchor events, and writes them to Postgres. Backfills from signatures if it falls behind. Every row keeps its slot and signature so state can be rebuilt from scratch.
Points engine
Runs every hour. Reads each wallet’s open positions as of the snapshot slot, applies the rates and multipliers for that hour, and appends to an append-only ledger. Referral points are derived from the ledger, never stored separately. Totals and ranks are a materialized view.
points(wallet, hour) =
Σ positions rate(product) × size × multiplier(product) × season_multiplier(hour)
+ Σ referees referral_share × points(referee, hour)Keeper
| Job | When | Does |
|---|---|---|
| settle_cooldown | Each epoch boundary | Finds tickets whose stake has deactivated, fetches a SOL to ONyc route, settles. |
| refresh | Every few hours | Brings each loan up to date with its stake’s growth, so NAV counts loans at their current value. |
| liquidate | Continuous | Watches LTV; liquidates positions above the threshold. |
All keeper instructions are permissionless. The protocol runs one; others are welcome to.
API
| Endpoint | Returns |
|---|---|
| GET /v1/vault | TVL, NAV per sqLP, APY breakdown, instant capacity, allocation |
| GET /v1/market | Supply, borrows, utilization, rates, rewards |
| GET /v1/quote/unstake?lamports= | Fee, payout and route for an instant unstake |
| GET /v1/points/:wallet | Points, rate per day, rank, referral stats |
| GET /v1/leaderboard | Top wallets for the current season |
| POST /v1/referrals | Binds a wallet to a referral code, with a signed message |
The app reads chain state directly where it can and uses the API for derived data. If the API is down, deposits and withdrawals still work.
Data model
events(slot, sig, program, kind, wallet, data jsonb)
positions(wallet, product, ref, size, opened_slot, closed_slot)
points_ledger(wallet, hour, product, points) -- append only
referrals(wallet primary key, referrer, bound_at, sig)
snapshots(slot, hour, vault_nav, lp_supply, sol_px, onyc_px, utilization)