Upload REAL_VS_SIMULATED.md
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292# Real vs Simulated Integration Status
This document tracks which BuilderBrain components are **real APIs** vs **simulated stubs**.
## Quick Reference
| Component | Status | What Works Now | What Needs Credentials ||-----------|--------|---------------|----------------------|| **Quant Engine (Kelly)** | β
REAL | Full `cvxpy` optimization with real math | None || **Correlation Matrix** | β
REAL | Block-diagonal structure with real estimates | None || **Reasoning Agent** | β
REAL | Structured trace generation with SHA256 hashing | None || **Polymarket Market Data** | β
REAL | Live Gamma API calls (`gamma-api.polymarket.com`) | None (public API) || **Polymarket Orderbook** | β
REAL | Live CLOB API calls (`clob.polymarket.com`) | None (public API) || **Builder Code Routing** | β οΈ SIMULATED | Field structure correct; needs `POLY_BUILDER_CODE` + live CLOB key | `POLY_API_KEY`, `POLY_PRIVATE_KEY`, registered builder code || **Circle Gateway** | β οΈ SIMULATED | Real HTTP client skeleton; needs `CIRCLE_API_KEY` + burn intent encoding | `CIRCLE_API_KEY`, depositor address, domain info || **Arc Nanopayments** | β οΈ SIMULATED | App-level ledger; real settlement requires x402 + EIP-3009 + Gateway | Buyer signatures, seller DB, Gateway batch settlement || **USYC Yield** | β οΈ SIMULATED | Balance tracking; real rotation needs Teller contract calls | Web3 provider, Teller contract ABI, wallet || **Paymaster** | β οΈ SIMULATED | Log-only; real needs ERC-4337 UserOp + bundler RPC | Pimlico bundler, EntryPoint address, paymaster contract || **Wallets** | β οΈ SIMULATED | Config only; real needs Circle Wallets API or self-custody | `CIRCLE_WALLET_API_KEY`, `CIRCLE_WALLET_SET_ID` |
---
## Detailed Breakdown
### β
Quant Engine β FULLY REAL
```pythonfrom builderbrain import KellyEngine, CorrelationMatrix
engine = KellyEngine(bankroll_usd=10000)positions = engine.size_positions(edges)# Uses cvxpy + ECOS solver β real convex optimization```
**No credentials needed.** The Kelly criterion implementation uses `cvxpy` for convex quadratic programming. This is production-grade numerical optimization.
**References:** Tepelyan (Bloomberg, 2026) β we implement a QP approximation to his Laplace quadrature method.
---
### β
Reasoning Agent β FULLY REAL
```pythonfrom builderbrain import ReasoningAgent
agent = ReasoningAgent()trace = agent.reason_about_market(...)# Generates structured traces with SHA256 hashing```
**No credentials needed.** The reasoning trace generation, argument structure, risk factor identification, and SHA256 canonical hashing are all implemented and functional.
**What's real:**- `ReasoningTrace` dataclass with full audit trail- `Argument` and `RiskFactor` structures- SHA256 hash of canonical JSON representation- Trade signal generation with urgency classification
---
### β
Polymarket Market Data β FULLY REAL (Public API)
```pythonfrom builderbrain import PolymarketClient
client = PolymarketClient(paper_trade=True)markets = client.fetch_markets(limit=50)# Calls https://gamma-api.polymarket.com/markets (live)```
**No credentials needed for read-only.** The Gamma API is public and requires no authentication.
**What's real:**- Live market data (prices, liquidity, volume, categories)- Orderbook fetching from CLOB API- Market parsing with price normalization
**What needs credentials:**- Order submission to CLOB (`POLY_API_KEY`, `POLY_PRIVATE_KEY`)- Builder code attribution (needs registered builder code)
---
### β οΈ Polymarket Builder Codes β SIMULATED
**Current:** Paper trading with simulated order execution. Builder code is attached as a field in the order struct but never submitted on-chain.
**To make real:**1. Register at https://polymarket.com/settings?tab=builder2. Get your `bytes32` builder code (e.g., `0x0000...0001`)3. Set `POLY_BUILDER_CODE` in `.env`4. Implement CLOB order signing + submission in `polymarket_client.py::_live_execute()`
**Architecture is correct:** Builder code is passed as an order field, serialized on-chain as the `builder` field. This matches Polymarket's documented TypeScript pattern.
---
### β οΈ Circle Gateway β SIMULATED (Real API Skeleton)
**Current:** `CircleGatewayClient` has real HTTP methods but `ArcBridge` falls back to simulation.
**Real API implemented:**```pythonfrom builderbrain import CircleGatewayClient
client = CircleGatewayClient(api_key="sk_test_...")domains = client.get_gateway_info() # GET /v1/gateway-infobalances = client.get_balances("0x...", 0) # POST /v1/balances# attestation = client.create_transfer_attestation(...) # POST /v1/transfer```
**What's simulated:**- Cross-chain routing in `ArcBridge.route_usdc()` (creates fake tx hashes)- No actual burn intent encoding + signing
**To make real:**1. Set `CIRCLE_API_KEY` in `.env`2. Pass `gateway_client=CircleGatewayClient(api_key)` to `ArcBridge`3. Implement burn intent encoding (requires domain info from `get_gateway_info()`)4. Implement depositor signature (requires wallet integration)
**Gateway Info endpoint works without full setup:** You can call `get_gateway_info()` and `get_balances()` with just an API key.
---
### β οΈ Arc Nanopayments β SIMULATED
**Current:** App-level payment ledger with batch aggregation. No actual cryptographic settlement.
**Real architecture (from docs):**1. Buyer signs EIP-3009 authorization (off-chain)2. Seller verifies signature (off-chain)3. Seller logs in own "virtual ledger" DB4. Periodic batch settlement via Circle Gateway transfer on Arc
**What's simulated:**- Payment creation (just appends to list)- Batch settlement (just aggregates and clears list)- No EIP-3009 signatures- No x402 HTTP 402 protocol negotiation
**To make real:**1. Implement EIP-3009 authorization signing (requires buyer wallet)2. Implement signature verification (seller side)3. Add database for virtual ledger4. Wire batch settlement to `CircleGatewayClient`
**No public REST API exists** for `/v1/nanopayments/batches` β this is by design. Settlement is through Gateway.
---
### β οΈ USYC Yield β SIMULATED
**Current:** Balance tracking with simulated rotation.
**Real contracts (Arc Testnet):**- USYC Token: `0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C`- Teller: `0x9fdF14c5B14173D74C08Af27AebFf39240dC105A`- Oracle: `0x52b56c7642E71dc54714d879127d97cd0B3D4581`
**What's simulated:**- `rotate_to_usyc()` just updates balance dict- No Teller contract interaction- No Oracle price fetching
**To make real:**1. Add Web3 provider (e.g., `web3.py` or `ethers.js` via Python wrapper)2. Load Teller ABI3. Call Teller.subscribe() with USDC amount4. Call Oracle for NAV/share price5. Use `https://usyc.dev.hashnote.com/api/price` for reference pricing
---
### β οΈ Paymaster (Gas Abstraction) β SIMULATED
**Current:** Log-only. No actual ERC-4337 UserOperation construction or submission.
**Real architecture (from docs):**- Arc supports standard ERC-4337 EntryPoint- Use Pimlico bundler on Arc- Circle Paymaster: users sign EIP-2612 permit- `paymasterData` = encodePacked([uint8, address, uint256, bytes], [0, usdcAddress, permitAmount, permitSignature])- Submit UserOperation via bundler RPC
**What's simulated:**- `sponsor_transaction()` just logs the intent- No UserOperation construction- No bundler RPC call- No paymaster contract interaction
**To make real:**1. Set `PIMLICO_BUNDLER_URL` in `.env`2. Implement UserOperation construction (standard ERC-4337 library)3. Implement EIP-2612 permit signing4. Submit to Pimlico bundler
---
### β οΈ Wallets β SIMULATED
**Current:** Configuration only. No actual wallet creation or transaction signing.
**Real options:**1. **Circle Dev-Controlled Wallets:** - API: `create-developer-transaction-transfer`, `create-developer-transaction-contract-execution` - Custodied by Circle; no key exposure - Set `CIRCLE_WALLET_API_KEY` + `CIRCLE_WALLET_SET_ID`
2. **Self-custody (EOA or SCA):** - Import private key - Use standard Web3 libraries - For SCA: deploy ERC-4337 smart contract wallet
**What's simulated:**- No wallet addresses- No transaction signing- No API calls to Circle Wallet service
---
## Migration Path: Simulated β Real
### Phase 1: Read-Only Live Data (Day 1)
```python# Already works β just run itbrain = BuilderBrain(paper_trade=True)brain.run_cycle() # Fetches real Polymarket data```
### Phase 2: Real Polymarket Builder Codes (Day 2-3)
1. Register builder code at https://polymarket.com/settings?tab=builder2. Set `POLY_BUILDER_CODE` in `.env`3. Implement CLOB order signing (use `py_clob_client` or Polymarket's Python SDK)4. Switch `paper_trade=False`
### Phase 3: Circle Gateway Integration (Day 3-4)
1. Get Circle API key from https://developers.circle.com/2. Set `CIRCLE_API_KEY` in `.env`3. Test `CircleGatewayClient.get_gateway_info()`4. Implement burn intent encoding for transfers5. Wire `ArcBridge` with real `gateway_client`
### Phase 4: USYC + Paymaster (Day 4-5)
1. Get Arc Testnet USDC from faucet2. Test Teller contract interaction (subscribe/redeem)3. Set up Pimlico bundler for paymaster4. Test ERC-4337 UserOperation flow
### Phase 5: Nanopayments (Day 5-6)
1. Implement EIP-3009 authorization flow2. Set up virtual ledger DB3. Wire batch settlement to Gateway4. Test end-to-end: insight β payment β settlement
---
## What Judges Will See
| Demo Element | What They See | What's Actually Happening ||-------------|--------------|---------------------------|| Market prices | Real Polymarket data | Live Gamma API calls || Kelly sizing | Real optimization | `cvxpy` convex QP solver || Reasoning traces | Structured arguments + risks | SHA256-hashed audit artifacts || Trade execution | Simulated fills with builder codes | Paper trading; fields correct || Cross-chain settlement | Simulated transfer hashes | No actual Gateway call || Nanopayments | Aggregated fee log | No EIP-3009 signatures || USYC rotation | Balance update | No Teller contract call || Gas sponsorship | Log entry | No UserOperation |
**Recommendation for hackathon:** Run in simulated mode for the demo, but show the real API client code and explain the integration path. Judges appreciate architectural thinking and honest documentation.
---
## Credentials Checklist
To go fully live, you need:
- [ ] Circle Developer account + API key- [ ] Polymarket account + API key + private key- [ ] Registered Polymarket builder code- [ ] Arc Testnet RPC endpoint- [ ] Arc Testnet USDC (from faucet)- [ ] Pimlico bundler access (for paymaster)- [ ] Circle Wallet API key + Wallet Set ID (optional, for embedded wallets)
See `.env.example` for all required environment variables.REAL_VS_SIMULATED.mdAdded+292