Developers
Contracts
The seven contracts behind Stonkboxx (baskets + options) and how they fit together.
All contracts live in the contracts/ folder of the repository and are built and tested with Foundry.
| Contract | Role |
|---|---|
MockUSDC | 6 decimal test USDC with a one hour faucet |
Asset | 8 decimal token for each stock or prediction outcome, with a UI multiplier like B20 |
PriceOracle | Keeper pushed prices with 8 decimals and a staleness limit (updated every 2h by Convex) |
BasketRegistry | Baskets, weights, versions, curation and votes |
BasketRouter | Buy, sell and rebalance in one transaction, fee split to creator, referrer and treasury |
OptionVault | Single-writer weekly epoch vault for USDC (Floor puts) and 14 stock pools (Gap calls) |
OptionMarket | ERC-1155 option positions, realized-vol × session pricing, oracle-free exercise & settle, and sellBack |
Flow
- The user approves USDC to the router.
buy(basketId, usdcIn, minValueOut, referrer)takes the USDC, pays the fee split and mints every asset by weight at oracle prices.sell(assets, amounts, minUsdcOut)burns assets and pays USDC at oracle prices minus the fee.rebalance(basketId, minValueOut)values the caller's holdings of that basket and moves them to the current weights.
One purchase, every holding
Units
| Value | Decimals |
|---|---|
| USDC | 6 |
| Prices & option strikes | 8 |
| Asset amounts | 8 (1 option lot = 1e6 = 0.01 shares) |
| Weights | basis points, sum 10000 |
value in USDC = amount x price / 1e10
Mainnet mapping
A mainnet implementation would require real trade routing, liquidity and issuer integration. Those execution paths are not implemented by the demo's mint-and-burn router. Testnet assets have no redemption rights. Builder attribution is attached only when a builder code is configured.
Deployed addresses are in contracts/deployments/84532.json.
Trust and permissions
The registry owner controls the tradable asset allowlist and curated status. Basket creators can change their own weights and metadata. The oracle keeper updates prices; the asset owner or keeper can resolve prediction outcomes. Contract owners can update privileged configuration, and the router owner can pause trading and change the fee up to its 1% cap.
These powers make this an operator-run simulation. The contracts are not independently audited. Existing tests cover access control, invalid allocations, fee splits, stale prices, slippage and fuzzed value conservation; passing tests is not a security certification.
Local development
Use Node 22.18 or newer and Foundry. From the repository root:
npm ci
npm run dev
npm run lint
npm run typecheck
npm run build
node --test tests/*.test.mjs
Run contract tests separately with forge test from contracts/. This does not broadcast transactions. Deployment and keeper scripts need explicit environment configuration; never expose their private key through a NEXT_PUBLIC_ variable.
Live price updates
A Convex cron job (convex/crons.ts) runs every 2 hours (12 runs/day) to fetch live Base DEX prices from GeckoTerminal, push them to PriceOracle, and record the latest quotes in Convex. Server-rendered pages (/options and /baskets/[slug]) overlay these live quotes with 5-minute ISR caching (revalidate = 300) to stay well within the Convex free plan.
Deployment sources
contracts/deployments/84532.json and contracts/deployments/84532-options.json record the Base Sepolia deployment. scripts/sync-deployment.mjs merges both into lib/deployment.json for the web app. After a deliberate redeployment, sync addresses and ABIs (node contracts/scripts/export-abi.mjs) together before rebuilding the interface.
The AI API key stays on the server. See .env.example for optional AI, RPC and attribution settings. The app can render without an AI key; AI requests then return an unavailable response.