Guide for teaching AI agents DeFi fundamentals — key concepts, protocol categories, transaction patterns, and common user requests. Essential for any OpenClaw agent that helps users with DeFi tasks including swapping, lending, yield farming, and portfolio management.
This skill teaches OpenClaw agents the DeFi fundamentals needed to help users interact with decentralized finance protocols.
What they do: Enable token swaps without intermediaries
| Type | Examples | How It Works | |------|----------|-------------| | AMM (V2) | Uniswap V2, SushiSwap, Camelot V2 | Constant product (x × y = k), full-range liquidity | | AMM (V3) | Uniswap V3, Camelot V3 | Concentrated liquidity in price ranges | | Order Book | dYdX, Vertex | Traditional order matching on-chain | | Batch Auction | CowSwap | Batch trades for MEV protection |
Key concepts: Liquidity pools, slippage, price impact, impermanent loss, fee tiers
What they do: Enable borrowing and lending of tokens
| Protocol | Model | Key Feature | |----------|-------|-------------| | Aave V3 | Pool-based | E-mode, flash loans, isolation mode | | Compound V3 | Single-asset | Simplified, one base asset per market | | Spark | Maker-powered | DAI-focused lending |
Key concepts: Supply APY, borrow APY, health factor, liquidation threshold, collateral factor, utilization rate
What they do: Maintain a $1 peg while potentially generating yield
| Type | Examples | Mechanism | |------|----------|-----------| | Fiat-backed | USDC, USDT | 1:1 reserves in bank accounts | | Crypto-backed | DAI, LUSD | Over-collateralized with crypto | | Auto-yield | USDs (Sperax) | 100% backed, yield auto-distributed via rebase |
What they do: Automate yield optimization
| Protocol | Approach | |----------|----------| | Yearn V3 | Multi-strategy vaults | | Beefy | Auto-compound across chains | | Convex | Boost Curve yields |
What they do: Provide leveraged trading and options
| Protocol | Type | |----------|------| | GMX | Perpetual futures | | dYdX | Perps + spot | | Lyra | Options |
Agent workflow:
Agent workflow:
Agent workflow:
Agent workflow:
1. approve(routerAddress, tokenAmount) on token contract
2. swap(tokenIn, tokenOut, amount, minOutput, deadline) on router
1. approve(lendingPool, amount) on token contract
2. supply(token, amount, onBehalf, referralCode) on lending pool
1. approve(router, tokenA_amount) on tokenA
2. approve(router, tokenB_amount) on tokenB
3. addLiquidity(tokenA, tokenB, amountA, amountB, ...) on router
4. approve(farmContract, lpTokenAmount) on LP token
5. deposit(poolId, lpAmount) on farm contract
| Chain | ID | Native Token | Key DeFi | |-------|----|-------------|----------| | Ethereum | 1 | ETH | Uniswap, Aave, Maker, Curve | | Arbitrum | 42161 | ETH | Camelot, GMX, Sperax (USDs), Aave | | Base | 8453 | ETH | Aerodrome, Uniswap, Aave | | Optimism | 10 | ETH | Velodrome, Aave, Synthetix | | Polygon | 137 | MATIC | QuickSwap, Aave, Balancer | | BSC | 56 | BNB | PancakeSwap, Venus, Alpaca |
Category:stocks-finance