Buildathons.ai
DeFi Protocols: Uniswap, Aave & Yield Strategies Course…
Explore decentralized finance. Understand AMMs, liquidity pools, lending protocols, and how to interact with Uniswap and Aave programmatically. Follow this…
Course overview
Explore decentralized finance. Understand AMMs, liquidity pools, lending protocols, and how to interact with Uniswap and Aave programmatically.
Automated Market Makers (AMMs)
Traditional exchanges use order books. DeFi's AMMs replace order books with mathematical formulas: Uniswap v2 uses the constant product formula: x × y = k x = reserve of token A y = reserve of token B k = constant (invariant) When you trade A for B: 1. You add Δx of token A 2. The pool returns Δy = y - k/(x + Δx) of token B 3. k stays constant (minus 0.3% fee) Price impact: Large trades relative to pool size = worse execution. This is 'slippage'.
Aave: Decentralized Lending
Aave lets users supply assets to earn yield and borrow against collateral — all without a bank. Key concepts: aTokens: When you supply ETH, you receive aETH — interest accrues in real-time in your wallet Health Factor: Collateral value / borrowed value (scaled by liquidation threshold). If HF < 1, anyone can liquidate you Flash Loans: Borrow any amount with no collateral — must be returned in the same transaction. Used for arbitrage and collateral swaps.
Flash Loans & MEV
Flash loans are uncollateralized loans that must be repaid within a single Ethereum transaction block. They enable: Arbitrage: Buy cheap on DEX A, sell high on DEX B, repay loan Collateral swaps: Swap collateral type without closing a loan Self-liquidation: Close at-risk positions before being liquidated by bots MEV (Maximal Extractable Value): Miners/validators can reorder/insert/censor transactions to extract value. Frontrunning, sandwich attacks, and backrunning are all MEV strategies.