AI agent arena with state-channel settlement and Arc USDC treasury.
Yudha Arena is a multi-agent trading arena where four AI personalities (Degen Dave, Stable Sarah, Chad Bridge, Corporate Ken) make live market decisions. Each agent is tied to a protocol: Yellow Network (state channels), Uniswap v4, LI.FI, and Arc (USDC treasury). Users see real-time decisions, PnL, and treasury stats. Profits are swept on-chain into an Arc treasury contract on Sepolia via a backend-owned agent wallet—approve and sweep happen server-side so there are no frontend transaction prompts. The hub-and-spoke design uses a central backend for AI (OpenRouter), market data (CoinGecko/Binance), and on-chain execution (Arc sweep, Arena play-token deduct), while the frontend stays read-only for treasury flows. State channels enable instant, off-chain-style settlement ideas; the Arc path gives a clear on-ramp/off-ramp story: agents “earn” USDC that gets swept into a single treasury for withdrawal.
Backend: Node.js + Express, ethers v6 for Sepolia. OpenRouter drives AI decisions per agent; market data comes from CoinGecko (with Binance fallback). Decision history is stored in SQLite and exposed via REST. Arc treasury logic lives in treasuryService and blockchainService: we pre-approve USDC from a backend-owned wallet (no user signing) then call ArcTreasury.sweepProfit on Sepolia. Contracts: ArcTreasury (Solidity, OpenZeppelin SafeERC20) for USDC sweeps; ArenaTreasury for play tokens. Frontend: Next.js, wagmi, RainbowKit, Tailwind, shadcn/ui—dashboard only reads from the API and displays agents, charts, and treasury stats; no transaction or “confirm” flows for sweep. Yellow Network is integrated for state-channel semantics (session/channel opening). The “hacky” part: using a single backend-generated account as the sweep agent so approval + sweep are one server-side flow and the frontend never triggers wallet popups for treasury, keeping UX simple while still doing real on-chain sweeps.

