Architecture

Program, accounts, keeper and site.

CARRY is one Anchor program, one keeper process and a static site. The program owns all state and money. The keeper only posts prints. The site reads the chain and the venues and builds transactions for your wallet.

flowchart TB
  subgraph Solana
    Pool[Pool PDA]
    Vault[(USDC vault PDA)]
    Fee[(Fee vault PDA)]
    M1[Market PDAs]
    Pos[Position PDAs]
    LP[LP account PDAs]
  end
  Keeper -->|post_print| M1
  Authority -->|create_market, update_pool| Pool
  Wallet -->|open, close, settle, deposit, withdraw| Pool
  Pool --- Vault
  Pool --- Fee
  linkStyle 0 stroke:#d1a148,stroke-width:3px

Accounts

AccountSeedsSizeHolds
Pool["pool"]261 BAuthority, keeper, fee settings, lp_cash, total_margin, trader_pnl, share supply
USDC vault["vault"]token accountLP cash and every trader's margin
Fee vault["fee_vault"]token accountProtocol share of fees until swept
Market["market", venue u8, coin [u8;8], maturity i64 LE]198 BSchedule, risk parameters, anchor, cumulative index, net notional
Position["position", market, owner, id u32 LE]122 BSide, notional, margin, fixed rate, entry period and index
LP account["lp", owner]65 BShares and any pending withdrawal

Venue byte is 0 for Hyperliquid and 1 for Binance. The coin is up to eight uppercase ASCII letters or digits, zero padded. Because the venue, coin and maturity are the seeds, exactly one market exists for each series.

Invariants the tests assert

  • vault balance == lp_cash + total_margin after every instruction that moves USDC.
  • pool.trader_pnl equals the sum of every position's own accrual, recomputed from all positions after each test phase.
  • Every rounding goes against the trader: fixed rate up for payers and down for receivers, margin and fees up, trader value down.

The keeper

node keeper/keeper.ts run posts every finished period, in order, with the exact decimal rate from Hyperliquid fundingHistory and Binance fundingRate. node keeper/keeper.ts roll opens the next 28-day series for each launch market, signed by the pool authority, with an anchor equal to the EMA of the venue's last 60 days of funding.

Cost at launch: 75 prints a day across the four markets at about 8,000 compute units each, which is 0.000375 SOL a day in base fees.

The site

The landing and the app read funding history straight from the two venues' public APIs and read pool and market accounts from Solana. The app builds each transaction in your browser and your wallet signs it first. A trade is one instruction with your wallet as the only signer and no address lookup table.