Redelegator Finance
Redelegator Finance is an agentic portfolio manager built on MetaMask Smart Accounts (ERC-7710/7715 + EIP-7702). Users grant one scoped permission with a single MetaMask prompt; an AI orchestrator rea
視頻




技術堆疊
描述
Redelegator Finance

Autonomous DeFi portfolio manager — delegate once, a chain of specialist agents coordinates the rest.
Live Demo: https://redelegator-finance.vercel.app
Documentation: https://hxz-1.gitbook.io/redelegator-finance
Overview
Redelegator Finance is an agentic portfolio manager built on MetaMask Smart Accounts (ERC-7710/7715 + EIP-7702). Users grant one scoped permission with a single MetaMask prompt; an AI orchestrator reasons over the intent with Venice AI, then redelegates a narrowing budget down a chain of specialist agents — Dex Aggregator, Liquid Staking, Yield — and the 1Shot public relayer redeems the whole delegation chain on-chain with gas paid in USDC. The resulting asset is delivered straight back to the user's wallet. Redelegation is the substrate; the agents are the workers that keep authority narrow.
One grant. Many agents. One rule: authority only ever narrows.
- User intent: Venice AI turns plain language into a validated, capped strategy.
- Agent chain: each hop re-signs a delegation with a smaller Erc20TransferAmount cap — enforced by the DelegationManager, not by trust.
- Output: the swap recipient is the user's wallet. No agent ever holds the result.
What Makes Redelegator Special
Who This Is For
Meet Maya. She holds USDC on Base and knows exactly what she should be doing with it: stake a slice into wstETH, park another slice in a yield vault, maybe LP the rest. Each of those is three approvals, two bridges of attention, and one 3am gas-price check away from actually happening.
She tried an "AI trading bot" once. It asked for an unlimited USDC approval to an EOA she'd never seen before. She closed the tab.
Maya's problem isn't a missing protocol. It's that every automation tool asks her to choose between doing everything manually and handing a bot a blank check. There's no middle ground where an agent can act for her while a cryptographic cap — not a promise — bounds what it can ever spend, and where firing the agent is one click.
Redelegator is that middle ground. One MetaMask prompt grants a per-day, per-token, expiring permission. Specialist agents coordinate the execution. The chain of authority can only shrink. And the kill-switch disables every agent at once, on-chain.
The Problem
Autonomous DeFi agents have an authority problem. To act for you, a bot needs spending power — and today that means either:
- Blanket ERC-20 approvals — one malicious route or bug drains the allowance; revoking is an afterthought.
- Custodial bots — the agent holds your funds in its own wallet; you trust its operator completely.
- Single-agent designs — one key does reasoning, routing, and execution; compromise one thing, lose everything.
- Manual everything — safe, but the whole point of an agent disappears.
And none of them let agents coordinate with each other — handing a task down a chain where each participant gets exactly the authority its sub-task needs and nothing more.
How might we build a multi-agent portfolio manager where authority flows down a chain of agents, can only ever narrow, never custodies the user's assets, and dies with one revocation?
The Solution
Redelegator solves this with six core primitives built on the MetaMask Smart Accounts Kit:
1. One Scoped Grant via ERC-7715. The app calls wallet_requestExecutionPermissions on the MetaMask extension: an erc20-token-periodic permission for USDC to the Orchestrator, sized budget + fee headroom, 24-hour period, 1-hour expiry. Off-chain EIP-712, no gas. decodeDelegations turns the returned context into the signed root delegation.
2. AI Reasoning with Venice. The Orchestrator sends the user's intent to Venice AI (qwen3-235b-a22b-instruct-2507, strict JSON schema, 25s timeout, deterministic fallback) and gets back a zod-validated Strategy: allocations, split ratios, and per-leg spend caps.
3. Attenuated Redelegation (A2A). The server builds Orchestrator -> Dex Aggregator -> Deployer -> 1Shot target, each hop re-signed by that agent's own key with a narrowed Erc20TransferAmount caveat. The DelegationManager enforces every cap on-chain; a buggy or malicious agent cannot widen its own authority.
4. Gasless Redemption via 1Shot. The full delegation chain goes to the 1Shot public relayer (permissionless JSON-RPC): estimate -> fee-adjust -> send. The relayer redeems the chain on-chain and takes its fee in USDC (~0.01). The user never needs ETH.
5. Zero Custody of Outcomes. The final LI.FI swap sets toAddress to the user's connected wallet, so wstETH lands in MetaMask, not in any agent. For Uniswap LP, the mint is built server-side with the v3 SDK but signed by the user — the LP NFT is minted directly to the user's address.
6. One-Click Kill-Switch. disableDelegation on the root delegation instantly disables every agent downstream. The UI shows a live Permission Report (allows / prevents / worst case) computed from the actual grant, so the user always knows the exact blast radius.
Every run is a chain of delegations where each arrow is a signed, capped, on-chain-enforced hand-off. The Orchestrator picks the legs every run — no user input beyond the intent.
Staking Leg
- Trigger: intent mentions Lido / staking
- Chain: You -> Orchestrator -> Dex Aggregator -> Liquid Staking -> 1Shot target
- Cap per hop: Erc20TransferAmount narrowed to the leg amount (+ fee on leg 0)
- Execution: 1Shot relayer redeems; deployer swaps USDC -> wstETH via LI.FI
- Output lands in: your wallet (LI.FI toAddress = you)
- Gas: paid by relayer in USDC
- Story: "Stake without babysitting"
Yield Leg
- Trigger: intent mentions yield / LI.FI / Earn
- Chain: You -> Orchestrator -> Dex Aggregator -> Yield Agent -> 1Shot target
- Cap per hop: Erc20TransferAmount narrowed to the leg amount
- Execution: 1Shot relayer redeems; routes into LI.FI Earn
- Output lands in: your wallet
- Gas: paid by relayer in USDC
- Story: "Park idle USDC productively"
LP Leg
- Trigger: intent mentions Uniswap / LP
- Chain: client-side — approve + mint signed by you
- Cap per hop: USDC approve = exact mintAmounts only
- Execution: NonfungiblePositionManager multicall (mint + refund)
- Output lands in: your wallet (LP NFT minted to you)
- Gas: tiny ETH (Base) from your wallet
- Story: "Provide liquidity via prompting"
Why the split intent matters
"Split 0.00001 USDC across Lido and LI.FI" fans the redelegation out to two deployers in one run — two parallel attenuated chains, two relayer redemptions, one grant. That is the clearest possible demonstration of agent-to-agent coordination: the Dex Aggregator receives one budget and re-delegates two narrower ones.
Decision flow per run
intent -> Venice AI -> Strategy { allocations[] }
for each allocation:
if protocol == "Lido" -> leg: liquidStaking (relayer chain)
if protocol == "Uniswap" -> leg: uniswapLp (client-side mint, solo only)
else -> leg: yieldAgent (relayer chain)
guard: LP cannot mix with other legs in one strategy (explicit error, no silent drop)
Features
- One-Prompt Delegation via ERC-7715: wallet_requestExecutionPermissions from the MetaMask extension — per-token, per-period, expiring, revocable; no gas, no blanket approval.
- AI Strategy Reasoning: Venice AI converts plain language to a zod-validated strategy with per-leg spend caps; deterministic fallback if the model misbehaves.
- Attenuated A2A Redelegation: every agent hop re-signs with a narrower Erc20TransferAmount caveat; enforced by the DelegationManager on Base.
- Stablecoin Gas via 1Shot: the public relayer redeems the delegation chain and is paid in USDC — the user needs zero ETH for the main flow.
- Zero-Custody Outputs: LI.FI swap recipient = user's wallet; Uniswap LP NFT minted to the user; agents only ever touch capped USDC for seconds.
- Headless Uniswap LP: pool read on-chain (slot0 / liquidity) -> Position.fromAmount1 full-range -> NonfungiblePositionManager.addCallParameters with useNative — proven by an anvil fork test (approve + mint succeed, NFT lands in the user's wallet).
- Permission Report: live ALLOWS / PREVENTS / WORST CASE panel computed from the actual grant, shown beside the A2A animation during every run.
- Full-Screen Live Activity: A2A flow diagram (marching-dash hops light up agent by agent) + timestamped feed with per-service chips, durations, 1Shot task ids, and BaseScan links.
- Clickable Agents, Real Data: LI.FI Earn vaults (APY/TVL + logos), Lido stETH APR (7-day series + chart), LI.FI tokens/DEXs/bridges, Uniswap pools (pair logos), Ondo RWA tokens — all live, server-proxied, TTL-cached.
- On-Chain Kill-Switch: one click disableDelegation -> the whole agent chain is dead; the UI greys out instantly.
- Live Agent Graph: pannable/zoomable radial constellation with state rings (amber active / emerald done / red revoked) over a minimalist grid canvas.
Tech Stack
- Frontend: Next.js 16 (App Router, Turbopack), React 19 (+ React Compiler), TypeScript strict, Tailwind CSS v4
- Lint/Format: Biome (pre-commit gate with tsc + build)
- Wallet Integration: wagmi v3 + viem 2 (MetaMask injected connector)
- Smart Accounts: @metamask/smart-accounts-kit — ERC-7715 grants, delegation create/redelegate/redeem/revoke, Stateless7702 agents
- Blockchain: Base Mainnet (chainId 8453)
- AI Reasoning: Venice AI (qwen3-235b-a22b-instruct-2507, strict JSON schema)
- Relayer: 1Shot public relayer (permissionless ERC-7710 redemption, USDC gas)
- Routing / Yield: LI.FI quote + tokens + tools + Earn vaults
- Staking Data: Lido protocol API (stETH APR)
- LP Engine: @uniswap/v3-sdk + @uniswap/sdk-core (headless mint calldata)
- RWA Data: Ondo tokens via the LI.FI token list
- Charts / Motion: Recharts (gradient area), Framer Motion
- Validation: Zod 4 on every external payload
METAMASK x 1SHOT x VENICE INTEGRATION
Every run is produced by the Smart Accounts Kit, redeemed by the 1Shot relayer, and reasoned by Venice. Core integration points:
- ERC-7715 Grant (frontend/src/hooks/useDelegationFlow.ts): erc7715ProviderActions -> wallet_requestExecutionPermissions (erc20-token-periodic, budget + fee headroom, 24h period, 1h expiry) -> decodeDelegations -> signed root delegation.
- Agent Smart Accounts (frontend/src/lib/web3/smartAccount.ts): toMetaMaskSmartAccount with Implementation.Stateless7702 — the five agents are EIP-7702-upgraded EOAs that can sign and redeem delegations.
- Redelegation (frontend/src/lib/delegation/redelegate.ts): createDelegation({ parentDelegation, caveats }) + the delegator agent's signature — one narrowed hop.
- Spend-Cap Caveats (frontend/src/lib/delegation/caveats.ts): createCaveatBuilder(env).addCaveat(CaveatType.Erc20TransferAmount, { tokenAddress, maxAmount }).
- Chain Runner (frontend/src/lib/agents/runner.ts): builds Orchestrator -> Dex -> Deployer -> 1Shot target per leg, fee leg + work leg executions, estimate -> adjust -> send loop.
- 1Shot Client (frontend/src/lib/oneshot/relayer.ts): relayer_getCapabilities, relayer_getFeeData, relayer_estimate7710Transaction, relayer_send7710Transaction, relayer_getStatus.
- Venice Reasoning (frontend/src/lib/venice/reasoning.ts): intent -> strict-JSON strategy with 25s abort + deterministic fallback; zod-validated before any delegation is minted.
- Zero-Custody Swap (frontend/src/lib/agents/deployerSwap.ts): deployer swaps the redeemed USDC via LI.FI with toAddress = user — wstETH lands in the user's wallet.
- Headless Uniswap LP (frontend/src/lib/uniswap/lp.ts): on-chain pool read -> Position.fromAmount1 -> addCallParameters({ useNative }) -> exact approve + mint tx the user signs.
- Kill-Switch (frontend/src/lib/delegation/revoke.ts): DelegationManager.encode.disableDelegation(root) — one userOp disables the whole chain.
- Permission Report (frontend/src/components/pages/(main)/PermissionReport.tsx): allows / prevents / worst-case rows computed from the live strategy + grant parameters.
- Agent Setup Scripts (frontend/scripts/fund.mjs + frontend/scripts/upgrade-agents.mjs): funder distributes gas ETH; each agent self-upgrades via EIP-7702 signAuthorization to the Stateless7702 implementation.
External Endpoints in Use
- MetaMask (ERC-7715): wallet_requestExecutionPermissions — the one user grant, scoped, periodic, expiring USDC permission.
- 1Shot relayer: POST https://relayer.1shotapi.com/relayers (JSON-RPC) — capabilities, USDC fee quote, estimate, send, status; redeems the delegation chain, gas in USDC.
- Venice AI: POST /api/v1/chat/completions (strict json_schema) — intent -> validated strategy.
- LI.FI: GET /v1/quote — swap calldata (USDC -> wstETH) with toAddress = user.
- LI.FI Earn: GET https://earn.li.fi/v1/vaults?chainId=8453 — real Base vaults (APY/TVL) for the Yield Agent card.
- LI.FI: GET /v1/tokens + GET /v1/tools — token logos + live DEX/bridge lists for the Dex Aggregator card.
- Lido: GET https://eth-api.lido.fi/v1/protocol/steth/apr/{sma,last} — real stETH APR + 7-day series for the Liquid Staking card.
- DeFiLlama: GET https://yields.llama.fi/pools — top Uniswap pools on Base (TVL/APY) for the LP card.
System Flow
1. User types an intent ("Split 0.00001 USDC across Lido and LI.FI").
2. Frontend asks Venice AI to reason -> zod-validated Strategy.
3. Frontend calls wallet_requestExecutionPermissions on MetaMask (erc20-token-periodic).
4. MetaMask returns a permission context -> decodeDelegations -> signed root delegation.
5. Frontend POSTs /api/execute (root + legs) to the agent chain (server).
6. Agents build Orchestrator -> Dex -> Deployer redelegations with narrowing caps.
7. Agents call the 1Shot relayer: estimate -> fee-adjust -> send7710Transaction.
8. Relayer calls redeemDelegations on the DelegationManager (Base); gas paid in USDC.
9. DelegationManager releases USDC under the caps.
10. Deployer swaps USDC -> wstETH via LI.FI with toAddress = user.
11. wstETH lands in the user's wallet.
Anytime: the user calls disableDelegation -> every agent dies at once.
Authority Pipeline
ERC-7715 grant (budget + fee headroom / 24h / 1h expiry)
-> Orchestrator (Venice-reasoned strategy)
-> Dex Aggregator (cap: total + fee)
-> Liquid Staking (cap: leg amount) -> 1Shot target
-> Yield Agent (cap: leg amount) -> 1Shot target
-> 1Shot target redeems the chain on-chain
-> LI.FI swap (recipient = USER wallet)
ERC-7715 grant is revocable -> disableDelegation (kill-switch)
Every edge narrows: the DelegationManager rejects any redemption above a hop's Erc20TransferAmount cap, regardless of what the agent's code tries to do.
How It Works
User Flow (Delegator)
Connect MetaMask -> Type Intent -> One ERC-7715 Prompt -> Watch the Agents -> Receive the Asset
1. Connect: MetaMask extension via wagmi (the kit is signer-agnostic; the extension provides ERC-7715).
2. Intent: type it or tap a policy-style chip ("...allow Lido only, prevent spending above the cap").
3. Grant: one MetaMask permission prompt — per-day USDC cap, 1-hour expiry, adjustable, revocable.
4. Watch: the full-screen activity card shows the Permission Report beside the live A2A flow; every step gets a timestamp, service chip, task id, and BaseScan link.
5. Receive: wstETH / vault exposure / LP NFT arrives in your wallet; "Strategy complete — no agent ever held your funds".
Agent Flow (A2A)
Reason -> Narrow -> Redelegate -> Redeem -> Deliver
1. Reason: Orchestrator sends the intent to Venice; strategy is zod-validated (split ratios sum to 1, caps <= budget).
2. Narrow: Orchestrator signs a delegation to the Dex Aggregator capped at total + fee.
3. Redelegate: Dex Aggregator signs per-leg delegations to each deployer, capped at that leg's amount.
4. Redeem: the 1Shot relayer redeems each chain through its target contract; the fee leg pays the relayer in USDC.
5. Deliver: on redeem confirmation the deployer swaps via LI.FI with the user as recipient; the feed links every tx.
On-Chain Flow
User EOA (MetaMask) Server (agent keys) Base Mainnet
| | |
|-- ERC-7715 grant (EIP-712) -->| |
| |-- redelegate xN (narrowing) -->| (signatures only, off-chain)
| |-- send7710Transaction -------->| 1Shot relayer
| | -- redeemDelegations ----->| DelegationManager enforces caps
| | -- USDC transfer -->| fee -> relayer, work -> deployer
| |-- LI.FI swap (to = User) ------>| wstETH -> User wallet
| | |
|<- disableDelegation (anytime) ----------------------------------> every downstream agent disabled
CONTRACT DETAILS
Addresses (Base Mainnet)
- EIP7702StatelessDeleGatorImpl: 0x63c0c19a282a1B52b07dD5a65b58948A07DAE32B — MetaMask Stateless7702 implementation, each agent EOA's 7702 bytecode.
- DelegationManager: via getSmartAccountsEnvironment(8453) — validates + enforces every caveat at redemption.
- 1Shot targetAddress: 0x26a529124f0bbf9af9d8f9f84a43efe47cf1199a — leaf delegate that redeems the chain.
- 1Shot feeCollector: 0xE936e8FAf4A5655469182A49a505055B71C17604 — receives the USDC relayer fee.
- USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 — the delegated asset.
- wstETH: 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 — staking output (delivered to the user).
- LI.FI Diamond: 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE — swap router for the zero-custody leg.
- Uniswap NonfungiblePositionManager: 0x03a520b32C04BF3bEEf7BEb72E919cf822Ed34f1 — LP mint target (verified on-chain: WETH9(), factory()).
- Uniswap USDC/WETH 0.05% pool: 0xd0b53d9277642d899df5c87a3966a349a798f224 — default LP pool (spacing 10, full-range via nearestUsableTick).
Key Functions — Smart Accounts Kit surface
wallet_requestExecutionPermissions(erc20-token-periodic) — the single user grant (ERC-7715)
decodeDelegations(context) — permission context -> signed root delegation
createDelegation({ from, to, parentDelegation, caveats }) — one narrowed redelegation hop
CaveatType.Erc20TransferAmount — the per-hop spend cap
DelegationManager.encode.disableDelegation(root) — kill-switch
toMetaMaskSmartAccount(Implementation.Stateless7702) — agent smart accounts
Key Functions — Project service modules
parseIntent(input) — Venice reasoning -> zod-validated Strategy
executeStrategy({ root, legs }) — builds + submits the full redelegation bundle to 1Shot
redelegateErc20Narrowed({ parent, cap }) — one signed narrowing hop
send7710Transaction(params) — relayer submission (USDC gas)
executeDeployerSwap({ recipient: user }) — LI.FI swap, output to the user's wallet
buildLpPlan({ walletAddress, amount }) — headless Uniswap v3 mint plan (approve + mint, user-signed)
encodeDisableDelegation(root) — encode the on-chain revoke
Authority should only ever narrow — Redelegator Finance
黑客松進展
MVP
籌資狀態
-