TMRW IntelJuly 15, 2026 · 09:00 UTC

How to automate DeFi rebalancing with agentic recipes.

Agentic recipes let you automate DeFi rebalancing by encoding portfolio rules as executable intent that autonomous agents monitor and act on without manual intervention. Define a threshold, let the agent observe state, and trigger on-chain settlement only when drift is real.

Note: TMRW Browser is pre-mainnet as of this writing, with a public launch scheduled for Q2 2026. The agentic recipe library is in preview — treat performance figures and templates as testnet-stage data while the platform moves toward production.

What you'll build

A working agentic recipe that maintains a target portfolio allocation (say, 60% ETH / 40% USDC) across Uniswap and Aave, fires a rebalance when drift exceeds a defined threshold, and logs every action to an on-chain audit trail. The same recipe structure extends to yield farming, liquidity provision, and cross-chain bridging.

Prerequisites: familiarity with Solidity or a TypeScript agent framework, a wallet on an EVM chain (Base is a natural choice given its agent tooling), and a basic understanding of AMM mechanics.

What an agentic recipe actually does

An agentic recipe is an executable intent layer: a structured set of rules that an autonomous agent reads, evaluates against live on-chain state, and acts on without waiting for a human to open a dashboard. Think of it like a thermostat wired directly to your portfolio. The thermostat doesn't ask permission every time the room cools; it reads the sensor, compares it to the target, and fires the heater. Your recipe is the target temperature, and the agent is the thermostat.

The observe–evaluate–execute loop

  1. Observe: Agent reads current pool weights from Uniswap and collateral ratios from Aave every block.
  2. Evaluate: Compares live allocation against the 60/40 target and calculates drift.
  3. Execute: If drift exceeds the recipe's threshold, the agent routes a swap through the optimal path and settles on-chain.

A human checking dashboards at 9am misses the 3am drift event entirely.

The three layers: intent, execution, verification

Intent layer — writing the recipe

A minimal recipe specifies four things: target allocation, drift tolerance, permitted protocols, and a gas budget ceiling. In practice: rebalance when ETH weight drifts beyond ±5% of 60%, using Uniswap V4 swap routes, with max gas 0.005 ETH per action. That single rule is enough for an agent to act autonomously for weeks. A programmable wallet architecture (an agentic wallet) lets AI agents execute on-chain transactions under strict user-defined parameters — coded budgets and rulebooks that cap spending, whitelist protocols, and log every operation.

Execution layer — routing and settlement

The execution layer selects the optimal swap route, checks slippage, and submits the transaction. Uniswap's AI Skills support tasks such as preparing liquidity strategies or configuring V4 hooks while maintaining predictable execution paths — calling a standardized interface produces a durable integration rather than one that breaks on the next protocol upgrade. For teams building on Base, Coinbase's Agentic Wallets let you build agents that monitor yields, execute trades, and manage liquidity positions around the clock, with no approval needed because permissions and controls are already set.

Verification layer — audit trail and slippage checks

Every executed action should write a proof: the pre-trade allocation, the post-trade allocation, slippage realised vs. tolerance, and gas consumed. This is where institutional operators separate themselves from retail bots. TMRW Browser's Proof Mesh layer produces tamper-evident records that satisfy compliance requirements without manual overhead.

Layer responsibilities at a glance

  • Intent — Define rules and thresholds. Tooling: TMRW recipe DSL. Miss it and the agent acts without boundaries. Setup: 1–2 hours.
  • Execution — Route trades, check slippage. Tooling: Uniswap V4 Hooks / Coinbase AgentKit. Miss it and you get suboptimal fills and failed txns. Setup: 2–4 hours.
  • Verification — Audit trail, proof of correctness. Tooling: TMRW Proof Mesh / on-chain event logs. Miss it and you have no compliance record and no debugging. Setup: 1–3 hours.

Beyond rebalancing: recipes across the DeFi stack

The recipe pattern is protocol-agnostic. The same observe–evaluate–execute loop applies broadly.

Yield farming and auto-compounding

Set-and-forget yield farming is giving way to active, agent-managed liquidity positions that rebalance hourly to minimize impermanent loss. A harvest recipe monitors pending rewards on Aave or Compound, calculates whether compounding now beats gas cost, and executes only when the math is positive.

Liquidity provision on Uniswap V4

Uniswap V4 introduces Hooks — external smart contracts attached to individual pools. An agent recipe can attach a rebalancing hook that auto-adjusts the position range whenever price moves outside a defined band, eliminating the manual "remove and re-add" cycle that most liquidity providers dread.

Cross-chain bridging and NFT workflows

AIUSD launched multi-chain yield optimization agents in January 2026, automatically bridging assets when rate differentials justify gas costs. For NFT minting workflows, a recipe can monitor a contract's mint window, check wallet balance, and submit at the optimal gas moment — no countdown timer required.

Mistakes that break automation

Drift thresholds set too tight

A 1% rebalance threshold sounds precise. In practice, gas costs on mainnet can exceed the value recovered from a 1% drift correction on a small position. A recipe running a 1% drift threshold on a $500 ETH/USDC position will routinely spend $12 in gas to recover $8 of drift — a net loss of $4 per cycle. Size thresholds relative to position: rebalance when drift exceeds 5% OR position value exceeds $50k prevents the agent from trading itself into losses.

MEV exposure

A sandwich attack detects a large pending transaction in the mempool, places one transaction immediately before it and another immediately after, and captures the spread. Autonomous agents are particularly vulnerable because their transaction patterns are predictable. Use private RPC endpoints such as Flashbots Protect and set tight slippage tolerances in the recipe's execution layer.

Ambiguous intent specification

"Rebalance when ETH is high" is a wish, not a recipe. Every condition in your intent layer needs a concrete numeric trigger, a permitted action set, and an explicit gas ceiling. Before mainnet deployment, run the recipe against a forked state to confirm it behaves exactly as written.

Pre-deployment checklist

  • Audit gas budget against expected drift frequency.
  • Test slippage tolerance under live mempool conditions on a testnet fork.
  • Validate operator incentive alignment — staked operators have skin in the game; anonymous bots don't.
  • Confirm the verification layer writes a proof for every execution.
  • Add a circuit-breaker: suspend rebalancing if the 1-hour price change on any asset exceeds a defined percentage, resume after a cooldown.

Key takeaways

  • The three-layer recipe structure (intent, execution, verification) is what gives an autonomous agent durability across gas spikes and protocol changes that would break a brittle script.
  • Drift thresholds must be sized against gas cost relative to position value, or the agent will trade itself into losses chasing small corrections.
  • Uniswap V4 Hooks and Coinbase's AgentKit on Base provide protocol-native primitives for recipe execution in 2026.
  • Predictable agent transaction patterns are a sandwich-attack target — private RPC endpoints and tight slippage tolerances belong in every production recipe from day one.
  • For institutional capital, build the verification layer first — retrofitting a compliance-grade audit trail is far harder than building it in.

Define the threshold. Let the agent observe. Settle only when the math is positive.

Author: TMRW W3AI