On-chain Programs — packages/programs (Anchor 0.30)
graph LR
subgraph PROG["Terrace Program · 8dDXHX1x6didMogjFcMCNL6ZoY4XkP2RkSCKcCiaQssF"]
direction TB
subgraph MARKET["Market Instructions"]
CM["create_market\n(question, expiry, is_flash, is_private)"]
PB["place_bet\n(outcome, stake_usdc)"]
SM["settle_market\n(outcome)"]
CM --> PB --> SM
end
subgraph PARLAY_IX["Parlay Instructions"]
CP["create_parlay\n(legs[], stake_usdc, nonce)"]
SP["settle_parlay\n(remaining_accounts)"]
CL["claim_parlay"]
CP --> SP --> CL
end
subgraph MATCHUP_IX["Matchup Instructions"]
CH["challenge\n(market, outcome, stake)"]
AC["accept_challenge"]
DEC["decline_challenge"]
SET["settle_matchup"]
CH --> AC --> SET
CH --> DEC
end
subgraph PRIVATE_IX["Private Market (Arcium)"]
IPM["init_private_market_state"]
PPB["place_private_bet"]
RPM["reveal_private_market"]
IPM --> PPB --> RPM
end
subgraph PDAS["PDAs"]
MPDA["Market PDA\n[market, creator, nonce]"]
PPDA["Parlay PDA\n[parlay, creator, nonce]"]
MUPDA["Matchup PDA\n[matchup, challenger, nonce]"]
RPDA["Reputation PDA\n[reputation, wallet]"]
PVPDA["PrivateMarketState PDA"]
end
end
ARCIUM["Arcium MPC\narcium_anchor + arcium_macros"]
PROG --- ARCIUM
style PROG fill:#0a0a0a,stroke:#333,color:#e5e5e5
style MARKET fill:#052e16,stroke:#166534,color:#4ade80
style PARLAY_IX fill:#0c1a2e,stroke:#1e40af,color:#93c5fd
style MATCHUP_IX fill:#1e1030,stroke:#6b21a8,color:#c084fc
style PRIVATE_IX fill:#1c0505,stroke:#7f1d1d,color:#fca5a5
style PDAS fill:#111,stroke:#333,color:#ccc
style ARCIUM fill:#1c0505,stroke:#7f1d1d,color:#fca5a5
Data & Event Flow
flowchart TD
USER["👤 Fan (Mobile App)"]
TG_USER["💬 Fan (Telegram)"]
subgraph APP["📱 Mobile App"]
HOOKS["React hooks\nuseParlay · useMatchup\nuseFollowing · useHeliusEvents"]
SDK2["@terrace/sdk\nbuildInstruction helpers"]
WALLET["Wallet Layer\nPrivy embedded · MWA/Phantom"]
end
subgraph INFRA["Infrastructure"]
WORKER2["☁️ Cloudflare Workers\nREST API + KV"]
KV2["Cloudflare KV\nWallet↔TG identity\nDevice push tokens"]
end
subgraph BOT["💬 Telegram Bot"]
GRAMMY["Grammy handlers\n/bet /me /challenge /link"]
GEMINI2["Gemini AI 2.0 Flash\nReputation narrative"]
end
subgraph CHAIN["⛓️ Solana Devnet"]
PROGRAM2["Terrace Program\nAnchor 0.30"]
HELIUS2["Helius RPC\n+ Websockets"]
JUPITER2["Jupiter\nSwap aggregation"]
ARCIUM2["Arcium MPC\nPrivate compute"]
end
subgraph EXTERNAL["External Data"]
POLY["Polymarket\nMarket depth + liquidity"]
PUSH["Push Notifications\nExpo / FCM / APNs"]
end
USER --> APP
TG_USER --> BOT
APP --> SDK2 --> WALLET --> PROGRAM2
APP --> HELIUS2
HOOKS --> HELIUS2
HELIUS2 -- "Real-time\non-chain events" --> HOOKS
PROGRAM2 -- "PDAs · Vaults" --> HELIUS2
PROGRAM2 <--> ARCIUM2
SDK2 --> JUPITER2
BOT --> WORKER2
WORKER2 --> KV2
WORKER2 --> HELIUS2
GRAMMY --> GEMINI2
WORKER2 -- "deep link\n/link/:token" --> USER
WORKER2 -- "DM via\nBot API" --> TG_USER
HELIUS2 -- "settlement\nevents" --> WORKER2
WORKER2 --> PUSH --> USER
POLY -- "day-one\nliquidity" --> APP
style APP fill:#0c1a2e,stroke:#1e40af,color:#93c5fd
style INFRA fill:#1c1300,stroke:#92400e,color:#fde68a
style BOT fill:#1a1a0a,stroke:#713f12,color:#fcd34d
style CHAIN fill:#052e16,stroke:#166534,color:#86efac
style EXTERNAL fill:#1e1030,stroke:#6b21a8,color:#d8b4fe