The on-chain program is ~600 LOC of Anchor. The off-chain side is a TanStack-React app + a Fastify indexer + a Node keeper. All the load-bearing logic lives on-chain.
The program
Anchor 0.32 program, four instructions. Token-2022 aware viaanchor-spl's InterfaceAccount. Hardcoded constants (treasury multisig, Jupiter program id, payment mint allowlist, protocol fee rate, expiry caps, bounty bounds) — no admin functions, no upgrade path post-renounce.
PDAs
- Commitment: seeds
["commitment", owner, nonce]. The nonce makes each (owner, nonce) pair a fresh address; combined withinit(notinit_if_needed) this eliminates reinit attack surface entirely. - Vault authority: seeds
["vault", commitment]. Used as the signer for token transfers + the Jupiter CPI. Canonical bumps are stored on the Commitment account so subsequent ixs verify viacreate_program_address(cheaper thanfind_program_address).
nonce is set client-side (typically Date.now()) so the same owner can keep many open orders without seed collision.The Jupiter CPI
This is the load-bearing path. The keeper passes Jupiter's sharedAccountsRoute instruction payload as a byte array; the program validates the discriminator + program id, reconstructs the 13-account fixed prefix from typed/constrained accounts (so the keeper can't swap in a malicious source ATA or output mint), and forwards the per-AMM tail with signer flags force-stripped.
Then:
- Skim 20 bps to treasury (signed by vault authority).
- Snapshot
owner_target_ata.amount. invoke_signedJupiter with the vault authority as signer.- Reload both accounts post-CPI (Anchor does NOT auto-refresh — this is mandatory).
- Compute
tokens_out = post - pre; require ≥min_fillANDvault.amount == 0(full-fill enforcement). - Compute
effective_price = ceil_div(spent × 1e18, tokens_out); require ≤max_price. - Pay bounty, close accounts.
effective_price ≤ max_price — rounding the computed price up means any imprecision lands in the buyer's favor.Token-2022 extension rejection
Target mints with these extensions are rejected via TLV walk: TransferFeeConfig, TransferHook, PermanentDelegate, NonTransferable, DefaultAccountState, ConfidentialTransferMint, ConfidentialTransferFeeConfig, MintCloseAuthority, InterestBearingConfig, Pausable.
The check runs at both create_commitment and execute_commitment — some extensions (TransferHook, InterestBearingConfig) can be added after init by a malicious mint authority, so we re-verify on every execute.
Off-chain components
- App — Next.js 14, Privy auth, TanStack Query, sonner. Reads chain state directly via getProgramAccounts; falls back to the indexer for history (closed accounts).
- Indexer — Fastify v5 + Postgres. Polls the chain every 15s, upserts commitments, exposes REST endpoints. Helius LaserStream gRPC subscription is a planned upgrade.
- Keeper — Node + @solana/web3.js. Polls active commitments, fetches Jupiter quote + swap-instructions, simulates, submits. Bounded concurrency + per-route revert cooldown.
Immutability
Pre-mainnet, the upgrade authority is the deploy wallet. After audit, the authority will be set to --final via solana program set-upgrade-authority --final, which is irreversible. There is no admin function in the program; the only mutability vector before that step is the upgrade authority itself, and after renounce there is none.