Description
Recipe showing how to programmatically interact with Aave (v3) lending protocol from TypeScript — deposit collateral, borrow assets, monitor health factor, and repay loans.
Why this matters
Aave is the largest lending protocol in DeFi ($20B+ TVL). The 32-hour Solidity course teaches this with ethers.js scripts on a forked mainnet — but uses outdated patterns. w3-kit modernizes this with viem and current Aave v3 contracts.
Scope
- Deposit collateral (WETH, USDC, etc.) into Aave
- Read user account data (total collateral, total debt, available borrows, health factor, liquidation threshold)
- Borrow assets against collateral (e.g., borrow DAI against ETH)
- Calculate max safe borrow amount using price feeds
- Repay loans (partial and full)
- Monitor health factor and liquidation risk
- Understand aTokens (interest-bearing receipt tokens)
- Mainnet fork testing pattern
w3-kit approach
- viem for all contract interactions
- Multi-chain: Aave v3 is on Ethereum, Arbitrum, Optimism, Polygon, Base
- Practical examples: deposit-borrow-repay lifecycle, health factor monitoring
- Use w3-kit registry for Aave contract addresses per chain
Acceptance criteria
Description
Recipe showing how to programmatically interact with Aave (v3) lending protocol from TypeScript — deposit collateral, borrow assets, monitor health factor, and repay loans.
Why this matters
Aave is the largest lending protocol in DeFi ($20B+ TVL). The 32-hour Solidity course teaches this with ethers.js scripts on a forked mainnet — but uses outdated patterns. w3-kit modernizes this with viem and current Aave v3 contracts.
Scope
w3-kit approach
Acceptance criteria
recipes/evm/.learn.mdexplaining how lending pools work (overcollateralization, liquidation, interest rates)