File size: 10,826 Bytes
58cb4a0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 | # 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
```python
from 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
```python
from 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)
```python
from 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=builder
2. 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:**
```python
from builderbrain import CircleGatewayClient
client = CircleGatewayClient(api_key="sk_test_...")
domains = client.get_gateway_info() # GET /v1/gateway-info
balances = 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" DB
4. 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 ledger
4. 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 ABI
3. Call Teller.subscribe() with USDC amount
4. Call Oracle for NAV/share price
5. 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 signing
4. 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 it
brain = 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=builder
2. 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 transfers
5. Wire `ArcBridge` with real `gateway_client`
### Phase 4: USYC + Paymaster (Day 4-5)
1. Get Arc Testnet USDC from faucet
2. Test Teller contract interaction (subscribe/redeem)
3. Set up Pimlico bundler for paymaster
4. Test ERC-4337 UserOperation flow
### Phase 5: Nanopayments (Day 5-6)
1. Implement EIP-3009 authorization flow
2. Set up virtual ledger DB
3. Wire batch settlement to Gateway
4. 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.
|