Baby Shark
AI swaps while you sleep
The problem Baby Shark solves
What Can You Use Baby Shark For?
Baby Shark is a fully autonomous swap agent. Once deployed, it requires no human interaction — no approvals, no signing prompts, no babysitting.
😴 Set It Once, Trade Forever
Describe your strategy once. Baby Shark runs it indefinitely via a cron agent — executing swaps, managing Permit2 approvals, and broadcasting transactions entirely on its own.
🤖 No Confirmation Prompts
Unlike a regular DEX, there's no wallet popup waiting for you to click "confirm." The agent signs and submits on your behalf, end-to-end, while you're completely offline.
🛡️ Autonomous Risk Management
Define your stop-loss or exit condition once. The agent monitors prices and pulls the trigger without asking you first — the way a trading bot should work.
🔄 Self-Running DCA
Dollar-cost averaging shouldn't require you to show up. Baby Shark executes recurring swaps on schedule with zero human touchpoints between setup and execution.
🌐 Always On, Never Waiting for You
No open browser tab. No connected wallet. No active session. The agent lives on a server, watches the market, and acts — whether you're asleep, traveling, or unreachable.
Challenges we ran into
Baby Shark — Technical Challenges & Learnings
Building a fully autonomous on-chain swap agent sounds simple until you're debugging a silent revert at 2am. Here's what we ran into.
1. 🔐 Permit2 Signature Integration
The Uniswap Trading API requires EIP-712 signatures over Permit2 data before a swap can be authorized. Our first swaps reverted silently on-chain because the agent was submitting unsigned or incorrectly structured transactions. We had to decode the raw calldata manually to diagnose the issue, then implement the full Permit2 signing flow — including correctly passing both signature and permitData together to the /swap endpoint.
2. 💾 Baseline State Persistence
The agent's trading logic depends on a rolling price baseline to detect swap opportunities. Initially, the baseline was hardcoded and reset on every cron execution — meaning the agent had no memory between runs and couldn't detect meaningful price movement. Solved with file-based state persistence via /tmp/uniswap-baseline.json, giving the agent continuity across executions.
3. ❌ Baseline Poisoning on Failed Transactions
Even after persistence was in place, the baseline was updating regardless of whether the swap actually succeeded on-chain. A reverted transaction would silently shift the baseline, corrupting future decisions. Fixed by gating baseline updates on status: success — the agent now only learns from confirmed, on-chain-verified outcomes.
4. ✅ Wallet Approval Management
The agent's wallet required an ERC-20 approval before Permit2 could spend WETH on its behalf. Without this, every swap attempt failed at the allowance check. Resolved by auto-granting unlimited Permit2 approval on agent startup, removing the need for any human approval step and keeping the flow fully autonomous.
5. 📏 Minimum Viable Swap Amount
Attempting swaps with 0.00001 WETH returned no routes from the API — the amount was below the threshold for viable liquidity routing. Scaled up to 0.0001 WETH as the minimum execution size, which resolved routing failures without meaningfully changing the capital footprint.
6. ⏱️ Slippage & Deadline Tuning
Initial configuration used 0.5% slippage and a short deadline — parameters suited for manual, real-time trading. The autonomous agent introduced latency between quote and broadcast that caused consistent deadline expiries and slippage rejections. Relaxed to 5% slippage and a 5-minute deadline, balancing execution reliability with acceptable price tolerance for the agent's strategy.
7. 📦 Uniswap Trading API Returns Unsigned Transactions
A non-obvious but critical constraint: the Uniswap Trading API /swap endpoint does not broadcast or sign anything — it returns a raw, unsigned TransactionRequest object (calldata, gas, value). The agent is fully responsible for signing and broadcasting via its own RPC provider. This meant building a complete signing pipeline into the agent — wallet key management, nonce tracking, gas estimation, and broadcast — with no human in the loop to catch errors before they hit the chain.
8. 🤖 LLM Hallucinations in Transaction Construction
Delegating transaction construction to an LLM introduced a class of bugs that don't exist in deterministic code: confident wrong answers. We encountered three concrete hallucination failures:
- Wrong recipient address — The LLM encoded
0x000...0160as the swap recipient instead ofADDRESS_THIS(0x000...0002), sending output tokens to a garbage address with no recovery path. - Decimal unit confusion — The LLM passed
0.000256as a float for USDC instead of256000raw units (6 decimals), resulting in a swap of effectively nothing. - Missing slippage protection —
amountOutMinwas set to2 wei, providing zero meaningful protection against price impact.
All three produced transactions that either reverted silently or executed incorrectly on-chain with real funds at stake. The fix was strict pre-broadcast validation — every LLM-generated transaction is decoded and checked against expected ranges and known constants before it ever reaches the RPC.
Result
A fully operational autonomous swap agent with:
- ✅ Permit2 EIP-712 integration
- ✅ Persistent rolling baseline across cron runs
- ✅ On-chain verified state updates only
- ✅ Zero human interaction post-deployment
- ✅ Pre-broadcast transaction validation against LLM hallucinations
- ✅ ERC-8021 builder code tracking
- ✅ 100% on-chain execution via Uniswap Trading API on Base
Use of AI tools and agents
Baby Shark is built around a Claude-powered autonomous agent that acts as the brain of the system — reasoning about market conditions, constructing transactions, and executing swaps without any human interaction.
The Agent: Claude via OpenClaw
The core agent runs on Claude (claude-haiku-4-5) orchestrated through OpenClaw, a cron-based agent runner. Every scheduled execution, the agent:
- Fetches a live price quote from the Uniswap Trading API
- Compares it against a persistent baseline stored in
/tmp/uniswap-baseline.json - Decides whether market conditions meet the swap threshold
- If yes — constructs the full transaction, signs it via Permit2, and broadcasts it on Base
Claude isn't a helper here. It's the decision-maker and the executor.
How the Agent Reasons
The agent is given a trading skill — a structured prompt that defines:
- The token pair to monitor (e.g. WMON/USDC)
- The price movement threshold that triggers a swap
- The swap direction and sizing rules
- How to interpret API responses and construct valid calldata
This skill acts as the agent's operating manual. Claude reads market data, applies the rules, and either acts or waits — autonomously, on every cron tick.
The Signing Pipeline
One of the hardest problems was giving the agent the ability to sign and broadcast transactions without a human wallet. The pipeline works as follows:
Cron trigger
→ Claude evaluates market conditions
→ Calls Uniswap Trading API /quote
→ Calls /swap → receives unsigned TransactionRequest
→ Signs Permit2 EIP-712 message with agent wallet key
→ Constructs final signed transaction
→ Broadcasts via RPC to Base
→ Reads tx receipt → updates baseline only on success
The agent wallet is a server-side key. No browser. No MetaMask. No human.
Validation Layer: Catching LLM Hallucinations
Because Claude constructs transaction parameters, we introduced a pre-broadcast validation layer to catch hallucinated values before they reach the chain:
- Recipient address checked against known constants (
ADDRESS_THIS,MSG_SENDER) amountInvalidated against expected decimal precision for the tokenamountOutMinchecked to be non-trivially above zero- Deadline verified to be in the future
This layer exists specifically because LLMs are confidently wrong in ways that deterministic code never is — and on an immutable chain, there's no undo.
Tools Working Together
| Component | Role |
|---|---|
| Claude (Haiku 4.5) | Market reasoning, swap decision, transaction construction |
| OpenClaw | Cron-based agent runner, schedules and triggers Claude |
| Uniswap Trading API | Quote generation, unsigned transaction building |
| Trading Skill (prompt) | Defines strategy rules and operating constraints for the agent |
| Validation Layer | Catches LLM hallucinations before broadcast |
| Agent Wallet (server-side) | Signs Permit2 and broadcasts — no human needed |
| Base RPC | On-chain execution and receipt verification |
Tracks Applied (3)
Futurllama
Base Self-Sustaining Autonomous Agents
Base
Integrate the Uniswap API in your platform
Uniswap Foundation
Cheer Project
Cheering for a project means supporting a project you like with as little as 0.0025 ETH. Right now, you can Cheer using ETH on Arbitrum, Optimism and Base.
