Live app: https://www.afterhoursfi.xyz · Agents demo: https://www.afterhoursfi.xyz/agents · API: https://afterhours-fi.onrender.com/api/health · Kip's agent: https://afterhours-kip.onrender.com
The US market closes Friday at 4pm New York and reopens Monday at 9:30. Tokenized stocks (bStocks, Ondo) keep trading through the weekend on BNB Chain, priced off a reference that has not moved. afterhours.fi lets a holder set a floor under that weekend for a few basis points, and lets a Keeper pool earn those premiums for carrying the risk, fully collateralised and CPPI-sized.
Methodology, research and intuition are written up at afterhoursfi.xyz/docs: how the idea came about, the market research, the history of bad weekends, the two-sided model, the backtest with real numbers and charts, and what it concludes for both sides. Start there if you are curious about the why; this README covers the how.
| folder | what |
|---|---|
backtest/ |
the research: 61,815 ticker-weekends 2005-2026, four pricing engines, Hermee (buyer) and Kip (Keeper) case studies, principal-protection structures, market research, literature, hackathon strategy. Start with backtest/CONCLUSIONS.md and backtest/report/index.html. |
contracts/ |
Hardhat project: KeeperVault (ERC-4626, CPPI floor), CoverMarket (EIP-712 signed quotes, Friday bell, Monday-open settlement, 20% payout cap, coverFor for agents), ReferenceOracle, test tokens. Deployed on BSC Testnet (home) and Ethereum Sepolia. |
server/ |
Node + TypeScript + Express + MongoDB: the v4 pricing engine (pooled vol-scaled tail), quote signing, Binance market-status and price feeds, event indexer, Friday/Monday epoch jobs, admin routes. Ships precompiled in server/dist/. |
client/ |
Next.js + wagmi + viem + RainbowKit: landing page, the app (Protect / Earn / My activity / Agents) and /docs. Dark, calm, gamified-not-gambling. |
agents/ |
Two AI agents that trade cover over x402: kip (underwriter, BNB Agent Studio, ERC-8004) and hermee (buyer, Binance Agentic Wallet on mainnet). See Agents. |
skills/ |
afterhours-weekend-cover, the Binance Agentic Wallet skill. |
shared/ |
INTERFACE.md (the contract between the apps), exported ABIs, and the shared x402 and Hermee agent code. |
# contracts (already deployed to Sepolia; see contracts/deployments/sepolia.json)
cd contracts; npm install; npm test
# server
cd ../server; npm install; copy .env.example .env # fill MONGODB_URI, QUOTER_PRIVATE_KEY (= deployer key for now), ADMIN_SECRET, ALCHEMY_API_KEY
npm run dev # http://localhost:4000/api/health
# client
cd ../client; npm install; copy .env.example .env.local # fill NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID, NEXT_PUBLIC_ALCHEMY_API_KEY
npm run dev # http://localhost:3000The client also runs with no server and no deployment: every server call has a 5s timeout and a static backtest fallback.
- Client → Vercel (
afterhoursfi, root directoryclient). Every push tomaindeploys production. Env:NEXT_PUBLIC_API_URL(the Render URL). The navbar "Testnet" switch picks the network (BNB Chain mainnet by default).NEXT_PUBLIC_*values are baked in at build time, so change them and redeploy. - Server → Render web service. Build
npm ci --omit=dev, startnode dist/index.js, health check/health. The server is committed precompiled, so after changing anything inserver/srcrunnpm run buildinserver/and commitserver/dist/in the same commit. - Kip's agent → Render (
afterhours-kip, rootagents/kip/app/agent). It ships as one prebuilt bundle (npm run bundle, commitbundle/kip.mjs), so Render runsnode bundle/kip.mjswith no install or build. The keystore comes fromWALLET_KEYSTORE_JSON+WALLET_PASSWORD. - Keep-alive. Render's free tier sleeps after 15 idle minutes, which would pause the indexer, the Friday/Monday jobs and Kip's keeper. An uptime pinger (cron-job.org) hits
GET /healthon both services every 10 minutes:https://afterhours-fi.onrender.com/healthandhttps://afterhours-kip.onrender.com/health. Neither route touches a DB or RPC.
Try it: afterhoursfi.xyz/agents. Press Start the agents to watch a real trade between the two agents on BSC Testnet, with every step linked on BscScan.
Buying weekend protection by hand means remembering to do it before 4pm New York every Friday. That is exactly the kind of chore an AI agent should do. So afterhours.fi has two agents that trade with each other:
- Hermee's agent works for a stock holder. Every Friday it looks at what she holds, asks for a price, checks the price against the budget she set, and pays.
- Kip's agent works for the protection pool. It prices the risk, collects the fee, writes the policy on-chain and, on Monday, settles it.
They pay each other with x402, a standard that lets one piece of software pay another over the web the way a browser loads a page: ask, get told the price, pay with a signature, get the goods.
One weekend in numbers (a real trade from the live demo):
- Friday: Hermee's agent asks Kip's agent to protect $1,000 of NVDA below -5%.
- Kip's agent answers "that costs $0.16" (1.6 basis points, priced from 21 years of weekends).
- Hermee's budget allows up to 1% ($10), so her agent signs one payment. Kip's agent collects it and writes policy #0 on-chain, in Hermee's name.
- Monday: if NVDA opens at -8%, the pool pays Hermee $30 (the 3% below her floor), straight to her wallet. If it opens anywhere above -5%, nothing happens and the $0.16 was the cost of sleeping well.
Kip's agent never holds a payout. It only passes the fee into the pool, and the pool pays Hermee by rule.
| Term | What it means here |
|---|---|
| Agent | A program that acts on someone's behalf with its own wallet: it decides, pays and signs within limits its owner set. |
| x402 | The HTTP "402 Payment Required" status turned into a real payment standard (v2). The seller answers a request with a price in a PAYMENT-REQUIRED header; the buyer retries with a PAYMENT-SIGNATURE header; the seller settles the payment on-chain, does the work and returns a PAYMENT-RESPONSE receipt. |
| Binance Agentic Wallet and Wallet Skills | Binance's wallet built for AI agents. The key is held by Binance (MPC) and never given to the agent; spending limits and allowed tokens are set by the human in the Binance App. Agents drive it with the baw CLI and "skills" (instruction packs). Hermee's agent pays with baw x402-payment preview / sign. Mainnet only. |
| BNB Agent Studio | BNB Chain's toolkit for "seller" agents (bag CLI): scaffolds the agent, gives it a wallet it alone controls, an on-chain identity, an MCP server and payment rails. Kip's agent is built with it. |
| ERC-8004 | An on-chain registry of agent identities. Kip's agent is agent #2530 on BSC Testnet, pointing at its public agent card, so any other agent can look up who it is and how to reach it. |
| MCP | Model Context Protocol, the standard way AI agents call tools. Kip's agent offers free tools (quote_cover, market_status, gap_history, pool_health, my_book) any agent can use to check weekend risk. |
| A2A agent card | A small public JSON file describing the agent and its skills: /.well-known/agent-card.json. |
| Permit2 | A standard contract that lets a wallet authorise one exact token transfer with a signature instead of a transaction. x402 uses it on BNB Chain because USDT has no built-in signed transfers. |
| Facilitator | The service that checks an x402 payment and submits it on-chain, paying the gas. On mainnet that is Binance's b402. On testnet afterhours.fi runs a stand-in with the same API (see below). |
Binder / coverFor |
A new CoverMarket function: an agent the market owner has authorised (a "binder") can write a policy for a buyer after collecting the fee off-chain. The policy, payouts and refunds all stay the buyer's. |
Hermee's agent Kip's agent Facilitator BNB Chain
| 1. POST /cover/bind ------->| | |
|<------- 2. 402 + price ------| | |
| 3. check budget, sign once | | |
| 4. retry + PAYMENT-SIGNATURE>| | |
| | 5. verify + settle ------->| 6. USDT Hermee -> Kip|
| | 7. coverFor(quote) ------------------------------>| policy for Hermee,
|<-- 8. 200 + policy + tx ids -| | | fee -> pool
Monday: | 9. settleBatch ---------------------------------->| pool pays Hermee
On-chain that is three kinds of transactions: a one-time Permit2 approval by Hermee, the x402 settlement (through the standard x402ExactPermit2Proxy), and Kip's coverFor. Then on Monday, Kip's settleBatch.
- Hermee's signature fixes the recipient and the amount. The payment can only go to Kip's address, for the quoted fee, before a deadline. The facilitator only pays gas and cannot redirect it.
- Hermee's agent refuses bad offers. It won't pay above its budget, won't pay a different amount, token, network or recipient than offered, asks before signing when a person is in the loop, and retries at most once. On mainnet, the Agentic Wallet also enforces the owner's own daily limit.
- Kip's agent cannot pick the buyer. Each quote is signed by the pricing engine for a specific buyer, and the contract checks that buyer really holds the stock. Kip cannot re-point a quote at itself.
- Kip's agent never touches payouts. Payouts and refunds go from the pool to the buyer. If binding fails after Kip was paid, Kip refunds the fee before answering.
- Nothing that moves money is an AI decision. Kip signs with fixed code using its Studio key; its LLM-facing tools are read-only. The market owner can revoke Kip's binder permission at any time.
Two parts of the stack have no public testnet: the Binance Agentic Wallet (BSC, Base and Solana mainnets only) and b402 (BSC testnet only inside Binance's internal QA environment). So on BSC Testnet:
| Piece | BSC Testnet (live now) | BSC Mainnet (same code) |
|---|---|---|
| Hermee's wallet | a local test key signs the identical x402 payment | Binance Agentic Wallet, HERMEE_WALLET=baw |
| Facilitator | afterhours.fi stand-in (server/src/x402/facilitator.ts), same verify/settle API, only settles our marketplace's payments |
Binance b402, X402_FACILITATOR_URL |
| Kip's agent | Agent Studio, network = bsc-testnet |
Agent Studio, AFTERHOURS_CHAIN_ID=56 |
| Payment contracts | Permit2 0x000000000022D473030F116dDEE9F6B43aC78BA3, proxy 0x402085c248EeA27D92E8b30b2C58ed07f9E20001 |
the same contracts at the same addresses |
- In the browser: afterhoursfi.xyz/agents. Pick a stock, amount and floor, then press Start the agents. The server runs Hermee's agent against Kip's live agent and streams each step.
- From the command line (your own testnet key):
cd agents/hermee && npm install echo "HERMEE_PRIVATE_KEY=0x<throwaway testnet key with a little tBNB>" > .env export KIP_AGENT_URL=https://afterhours-kip.onrender.com npm run hermee -- quote --token NVDAB --amount 1000 --floor 5 # free, over MCP npm run hermee -- protect --token NVDAB --amount 1000 --floor 5 # pays over x402, asks y/N first
- As another agent: call Kip's MCP tools at
https://afterhours-kip.onrender.com/mcp, or follow the raw x402 exchange inskills/afterhours-weekend-cover/references/x402-cover-flow.md. - With the Binance Agentic Wallet (mainnet): install the skill in
skills/afterhours-weekend-cover. It tells the agent exactly whichbawcommands to run and which guardrails to keep.
| Policy | Trade | x402 payment (Hermee → Kip) | Policy bound by Kip |
|---|---|---|---|
| #0 | $1,000 NVDA below -5% for $0.16, from the CLI | 0x45463fbb… |
0x34e252d8… |
| #1 | $1,000 NVDA below -5% for $0.16, from the live server | 0x59008f37… |
0x63eb4c39… |
| #2 | $1,000 TSLA below -5% for $0.44, from the website | 0x79498ec0… |
0x72df0a07… |
- Hermee's agent:
0x7bc4Db58435b586C16a11cB477C257433349844A - Kip's agent:
0x6513a00FB8341ee24Af029EFAf67B19b5914ed4C, ERC-8004 agent #2530 in registry0x8004A818BFB912233c491871b3d84c89A494BD9e
These policies belong to the weekend closing Friday 2 October 2026. Kip's agent settles them at the Monday open on 5 October.
| Path | What |
|---|---|
agents/kip/ |
Kip's agent, scaffolded with Agent Studio. afterhours.fi logic is in app/agent/src/afterhours/: the x402 seller route, MCP tools, keeper loop and fixed-code signing. It ships as app/agent/bundle/kip.mjs. |
agents/hermee/ |
Hermee's agent CLI: status, quote (MCP), protect (x402). Payers: bawPayer.ts for the Agentic Wallet, and the local testnet key. |
shared/hermee/ |
The buyer flow and guardrails, shared by the CLI, the server's live demo and the website. |
shared/x402/ |
x402 v2 exact/Permit2: headers, the signed payload, and the facilitator's seven checks. Used everywhere. |
server/src/x402/, server/src/routes/x402.ts, server/src/routes/agentsDemo.ts |
The testnet facilitator, the agent activity feed, and the streaming live demo. |
contracts/contracts/CoverMarket.sol |
coverFor and setBinder (5 dedicated tests). |
skills/afterhours-weekend-cover/ |
The Binance Agentic Wallet skill (SKILL.md and references). |
client/src/components/agents/ |
The /agents page. |
BSC Testnet is the home network: the app connects to it by default. Ethereum Sepolia runs the same stack. The deployer 0x1d83F122EF31885B83139ABCb4f8fB4eF319DDF9 is owner, admin and quoter on both.
| BSC Testnet | Ethereum Sepolia | |
|---|---|---|
| deploy block | 133,916,239 | 11,800,197 |
| open weekends (epochId) | 1790971200, 1791576000 | 1790971200, 1791576000 |
| authorised binders (agents) | 0x6513a00FB8341ee24Af029EFAf67B19b5914ed4C |
none |
Agent-to-agent (x402) on BSC Testnet uses the canonical, chain-independent contracts: Permit2 0x000000000022D473030F116dDEE9F6B43aC78BA3 and x402ExactPermit2Proxy 0x402085c248EeA27D92E8b30b2C58ed07f9E20001.
Core contracts are source-verified on BscScan and Etherscan. The raw address books are contracts/deployments/bscTestnet.json and contracts/deployments/sepolia.json (copied into server/deployments and client/src/deployments).
- Friday, before the bell. The holder picks a token and a weekly budget (or a floor). The server prices it with the pooled vol-scaled engine, signs an EIP-712 quote, and the holder calls
buyCover. The premium goes into the Keeper vault; the vault locks 20% of the notional as the policy's maximum payout. - The bell. No more purchases (
bindDeadline). The oracle records the Friday close per share. - Monday, 9:30 New York. The oracle records the first official opening print. Anyone calls
settle: payout per $1 = min(max(-barrier - gap, 0), 20%). The holder gets a receipt: "Floor held" or "Floor paid $X". Corporate actions void the weekend and refund the premium.
For the full story in plain numbers (Hermee's weekend, Kip's vault) and the quant methodology behind the pricing, see /docs.
Testnet only. The deployer address owns every contract and can pause, change parameters, force-settle, correct prices and withdraw funds. Not available in restricted jurisdictions. Built for BNB Hack: Tokenized Stocks Edition.