Skip to content
Calldata Pipeline

Recipe System

Deterministic TX templates stored in tx.db. The self-healing loop learns new recipes from on-chain transactions when calldata fails — infinite retry with 30-error stuck detection.

The Pipeline Overview introduced three routing paths: Express, Recipe, and Discovery. This page dives into how recipes work, how they accumulate, and how the self-healing loop creates new ones from chain data.

What is a recipe

A recipe is a deterministic template for building transaction calldata. It maps a user intent (protocol + action + parameters) to a specific contract call with argument patterns.

{
  "protocol": "euler",
  "action": "deposit",
  "chain": "ethereum",
  "contract": "0x...",
  "selector": "deposit(uint256,address)",
  "args_pattern": [
    {"name": "amount", "source": "intent.amount", "transform": "to_wei(6)"},
    {"name": "receiver", "source": "intent.wallet_address"}
  ]
}

Recipes live in tx.db. Once a recipe exists for a protocol + action combination, all future transactions use the deterministic path — no LLM, no API calls, pure SQL lookup and parameter binding.

Self-healing loop

When a transaction fails, the pipeline doesn't give up. It enters an infinite retry loop that learns from each failure:

REVERT TX fails on Anvil ANALYZE Decode error FETCH Working TX from chain LEARN Save recipe to DB RETRY WITH NEW RECIPE Infinite loop until success · 30-error stuck detection · recipes accumulate
The loop retries until success. After 30 consecutive errors on the same pattern, stuck detection kicks in and the pipeline reports what it learned so far.

Discovery path in detail

When no recipe exists and templates can't handle the action:

01
Query Etherscan
V2 API for recent successful transactions to the target contract.
02
Decode calldata
Using the contract ABI from Etherscan or raw.db.
03
Classify arguments
Is it an amount? An address? A deadline? A selector?
04
Build template
args_pattern mapping intent fields to contract args.
05
Save recipe
Persisted to tx.db for all future use.
06
Re-run pipeline
Now uses the deterministic Recipe path. No LLM needed.

Recipes accumulate with use. More interactions = more deterministic paths, fewer LLM calls.

Once a recipe produces calldata, it goes through simulation — a full dry run on an Anvil fork before any real funds are at risk.