DocsProtocol Architecture

Application (Architecture)

The desk blotter — a read-mostly Next.js front end with direct-to-contract writes and an honest paper fallback.

Responsibility. Give depositors and observers a truthful window into desks: NAV, shares, cash, leader, fill tape — plus deposit/redeem/stake/list transactions. Package: app/ (@seat/app). Full docs in the Application section.

Structure

PieceFileJob
Pageapp/src/app/page.tsxRenders DeskBlotter (the only screen)
Blotterapp/src/components/DeskBlotter.tsxAll desk reads/writes, desk picker, tape
Providersapp/src/components/Providers.tsxwagmi + react-query
Chain configapp/src/lib/wagmi.tsdefineChain for 4663/46630, injected connector, SSR
Addressesapp/src/lib/addresses.tsGenerated per-chain contract addresses; canWriteOnChain
Paper dataapp/src/lib/desks.tsClearly-labelled test desk for the fallback UI
Fills APIapp/src/app/api/fills/route.tsServes keeper/data/fills.json
ABIsapp/src/abis/Extracted from Foundry out/ (never hand-written)

Data flow

  • Reads: leader, totalAssetsUsdg, totalShares, cashUsdg, navPerShare, sharesOf, plus factory deskCount/allDesks for the picker.
  • Writes: approve + deposit, redeem; Phase 2 adds stake and list-desk forms when seatToken is wired. Writes are gated by canWriteOnChain(chainId, addresses) — a chain must be Robinhood (4663/46630) and have a non-null vault.
  • Fallback: with no wallet on a Robinhood chain, or no vault wired, the blotter renders the paper desk — test data, labelled as such, never presented as live.

Configuration

NEXT_PUBLIC_RH_TESTNET_RPC_URL / NEXT_PUBLIC_RH_RPC_URL / NEXT_PUBLIC_CHAIN_ID. Placeholder hosts keep the app type-checking when unset. Contract addresses come from scripts/write-addresses.ts after real broadcasts — hand-editing invented addresses is explicitly prohibited by the file's own header.

Failure modes

CaseBehaviour
No vault on connected chainPaper blotter fallback
Factory read failsFalls back to the single wired vault address
fills.json missing/api/fills returns an empty list
Wrong chainWrites disabled; testnet assumed for reads