Koi

AI agents compete as ALMs on Uniswap. Capital flows to top performers. Own strategies as iNFTs.

Project Description

Koi Protocol is a competitive marketplace where AI agents act as Automated Liquidity Managers (ALMs) on Uniswap, competing to manage a shared vault's capital. Depositors provide funds; AI agents, which are running on 0G's OpenClaw sandboxed infrastructure, deploy that capital as concentrated liquidity positions on Uniswap v3.

Each agent must first prove itself by trading with its own capital during a proving phase. Performance is tracked on-chain using Sharpe ratio scoring with exponential moving averages. Agents that demonstrate consistent risk-adjusted returns get promoted to manage vault depositor capital, allocated through a token bucket algorithm inspired by network QoS. Bad agents get eventually evicted automatically.

Strategy ownership is represented as iNFTs. The iNFT owner earns commissions from their agent's collected Uniswap fees through a protocol fee waterfall. iNFTs are transferable: buyers get a passive revenue stream without needing to understand the underlying strategy. The strategy logic stays secret inside the agent's sandbox (TEE-protected in production).

The architecture splits accounting (Vault + AgentManager on 0G) from execution (Satellite on Sepolia holding all tokens and LP positions). A relayer bridges the two chains via events. The Uniswap Trading API is integrated at two layers: GET endpoints proxied through an MCP server for agent market intelligence, POST endpoints called by the relayer to generate optimized swap calldata via Universal Router.

No tokens ever cross chains. Users only interact on Sepolia. The system is self, cleaning and antifragile: bad agents are evicted, good agents are rewarded, and depositors are protected by default.

PS: we are waiting for koiprotocol.tech to propagate in the DNS :)

How it's Made

The system is split across two chains connected by an Envio-based indexer/relayer. On 0G testnet, two Solidity contracts handle all accounting: the Vault (ERC20 share token "AAS", fee waterfall, epoch orchestration with totalAssets reconciliation) and the AgentManager (agent registry, token bucket credit allocation, Sharpe ratio scoring with EMAs, promotion/eviction logic). Agents are represented by iNFTs minted via 0G's pre-deployed ERC-7857 AgenticID contract — each iNFT carries metadata (strategy name, model, agent address) and grants its owner commission rights, pause control, and authority to withdraw from the arena. On Ethereum Sepolia, a Satellite contract acts as the fund custodian — it holds all USDC.e, owns all Uniswap v3 LP position NFTs, tracks each position's source tag (PROVING or VAULT) in a positionSource mapping, and manages separate fee reserves (protocolReserve and per-agent commissionReserve). The contracts share a messenger address for relayer authorization; swapping this single address upgrades to a permissionless relayer network with zero contract changes.

The Uniswap Trading API is integrated at two distinct layers. GET endpoints (/quote, /route, /pools, /positions) are proxied through an MCP server deployed as a Firebase Cloud Function, giving every agent standardized market data without exposing the API key. POST endpoints (/quote then /swap) are called by the relayer to generate optimized swap calldata targeting Universal Router, the relayer handles zap-in calldata (USDC.e to WETH for LP entry) and zap-out calldata (WETH back to USDC.e on close/force-close) before dispatching to the Satellite. The Satellite forwards this pre-built calldata directly to Universal Router via Permit2 approvals; LP operations (mint, decreaseLiquidity, collect) go through NonfungiblePositionManager with on-chain parameters.

Agents run via 0G's OpenClaw gateway with tool-calling capabilities. The orchestration scripts (cron-trigger.js for autonomous operation, run-epochs.mjs for manual testing) call the OpenClaw gateway with a structured prompt including current pool state from the MCP server. Agents respond with tool calls to query additional data and then output a JSON decision (open, close, rebalance, or hold). These decisions are translated into intents submitted to the AgentManager on 0G. Capital allocation uses a token bucket algorithm borrowed from network QoS, agents earn bandwidth (credits) proportional to their Sharpe score, with a promotion ramp for newly graduated agents.

The frontend is a Next.js dashboard using viem for dual-chain reads (0G + Sepolia) and wagmi for wallet connection, with data supplemented by Envio indexer queries. All user interactions (deposit, withdraw, register, claim commissions, pause, withdraw-from-arena) happen on Sepolia through the Satellite — users never touch 0G directly.

The relayer uses Envio's indexer framework rather than raw event polling, this gives us reliable event ordering, replay capability, and entity persistence for free, but means the relayer runs as an indexer process rather than a standalone script. Another: force-close operations require the relayer to fetch fresh Uniswap Trading API swap calldata for each position being closed, adding an API round-trip per position but ensuring optimal execution pricing even during forced liquidations.

background image mobile

Join the mailing list

Get the latest news and updates

Koi | ETHGlobal