09 defi

09 — DeFi (Decentralized Finance)

Aplicações financeiras em smart contracts: AMMs, lending, derivatives, stablecoins, RWA, perpetuals, restaking. *VL combinado* ~US$ 200B (mai/2026).


1. Pilares

Categoria Função Top protocolos
*EX (AMM)* Trocas spot Uniswap, Curve, Balancer, PancakeSwap, Aerodrome
*EX (orderbook)* Order-book trading dYdX, Hyperliquid, Drift, Serum
*ending/Borrowing* Empréstimos colateralizados Aave, Compound, Morpho, Spark
*erivatives / Perps* Futuros perpétuos Hyperliquid, dYdX, GMX, Vertex, Drift
*tablecoins* Tokens pegged ao USD USDT, USDC, DAI, ENA, FRAX, crvUSD
*iquid staking (LSTs)* ETH/SOL stake líquido Lido, Rocket Pool, Jito
*iquid restaking (LRTs)* EigenLayer stake líquido Ether.fi, Renzo, Puffer
*ield aggregators* Otimização passiva Yearn, Beefy, Convex, Aura
*ridges* Cross-chain LayerZero, Wormhole, Stargate, Across
*racles* Dados off-chain Chainlink, Pyth, RedStone, API3
*WA* Real-world assets Ondo, Centrifuge, MakerDAO, BlackRock BUIDL
*nsurance* Cobertura smart contract Nexus Mutual, InsurAce
*rediction markets* Apostas sobre eventos Polymarket, Kalshi (US-regulated)
*AOs / Governance* Coordenação on-chain Snapshot, Tally, Aragon, Safe

2. AMMs (Automated Market Makers)

Constant-product (Uniswap v1/v2)

$\(x \cdot y = k\)$

Pool com \(x\) tokens A + \(y\) tokens B; produto constante. Swap de \(\Delta x\) tokens A: $\(\Delta y = y - \frac{k}{x + \Delta x \cdot (1 - \text{fee})}\)$

*ee*(0.3% Uniswap v2) acumula no pool, beneficiando LPs.

Uniswap v1 (nov/2018)

  • Hayden Adams (ex-Siemens engineer).
  • ETH ↔ ERC-20 only.
  • 0.3% fee.
  • Hello-world AMM.

Uniswap v2 (mai/2020)

  • Tokentoken pairs (qualquer ERC20 ↔ qualquer ERC-20).
  • *lash swaps* borrow + return em mesma tx.
  • TWAP price oracles built-in.

Uniswap v3 (mai/2021)

  • *oncentrated liquidity* LPs choose price ranges (capital efficient).
  • Fee tiers: 0.05%, 0.3%, 1% (later 0.01%).
  • Non-fungible LP positions (NFTs).
  • Inspirou copies em todo lugar (PancakeSwap v3, etc.).

Uniswap v4 (jan/2024)

  • *ooks* pre/post swap callbacks → custom AMM logic per pool.
  • *ingleton contract* todos pools em um contrato. Gas saving.
  • *lash accounting* net deltas instead of intermediate transfers.
  • Hooks enable: dynamic fees, custom oracles, MEVprotection, onchain limit orders.

Curve

*ichael Egorov 2020* Stableswap formula: $\(\sum x_i + (D \prod 1) = ...\text{(invariant blends sum + product)}\)$

Otimizado para *ssets de preço próximo*(USDTUSDCDAI; ETH/stETH). Slippage minimal em meio do range, growth fora.

  • *RV* governance token.
  • *eCRV*(voteescrowed): lock CRV para boost rewards + governance weight. Pioneer "vetokenomics".
  • *urve Wars* Convex acumulou veCRV → controla emissões → protocols (Frax, Yearn) bid for Convex influence.

Balancer

  • *eighted pools*(multi-asset, custom weights).
  • *table pools*(Curve-like).
  • *oosted pools*(composable LP).
  • *oW Protocol*(related entity): batch auction MEV-resistant.

PancakeSwap

BSC primary (later multi-chain). Uniswap fork. Largest DEX em BSC. Cake token.

Aerodrome (Base)

Velodrome fork em Base. ve(3,3) tokenomics. Top DEX em Base — TVL ~US$ 1B.

SushiSwap

Vampireattacked Uniswap v2 em set/2020. Drama, rollercoaster. Multichain, declined.

Maverick, Trader Joe v2.1, Camelot

Concentrated liquidity variations.


3. Stableswap variants

Specialized for stable assets:

  • *urve*(above).
  • *addle* Curve fork (defunct as major).
  • *llipsis*(BSC Curve fork).

4. Orderbook DEX

dYdX

  • *3*(StarkEx L2, 2021–2023): Top decentralized perp DEX initially.
  • *4*(Cosmos appchain, 2023): migrated. Offchain orderbook + onchain settle. ~US$ 1B/day volume.

Hyperliquid

  • App-specific L1 (custom HyperBFT consensus).
  • *op decentralized perp DEX*20242026. ~US$ 510B daily volume.
  • HYPE token TGE nov/2024.

Drift, Vertex, Serum (legacy)

Solana-based orderbook DEXes.

Aevo

Optimistic rollup focused on options + perps.


5. Lending

Compound (jun/2018)

  • *ioneer* floating-rate lending pools.
  • COMP token (jun/2020) initiated *iquidity mining*= DeFi summer.
  • Compound III (USDC-base) 2022.

Aave (formerly ETHLend)

  • v1 (2020), v2 (2020), v3 (2022).
  • Multi-collateral pools.
  • *lash loans* borrow + repay em 1 tx (no collateral).
  • *Mode* same-class assets boosted LTV.
  • *solation mode*for new assets.
  • Multi-chain.

Morpho

  • *orpho Optimizer*(legacy): peertopeer matching atop Aave/Compound.
  • *orpho Blue*(jan/2024): minimal isolated lending markets, 650 lines code, immutable.
  • MetaMorpho vaults: curated allocations.
  • Top growth DeFi 2024-2025. TVL ~US$ 8B.

Spark (MakerDAO)

Aave fork by MakerDAO/Sky. DAI-centric. SubDAO of Sky ecosystem.

Outras

  • *uler v2*(relaunched após hack 2023).
  • *ilo Finance*
  • *adiant*(omnichain lending via LayerZero).
  • *iquity*(LUSD stablecoin lending).

6. Stablecoins

Centralized (custodial)

Token Issuer Reserves Chain dominante Marketcap (mai/2026)
*SDT (Tether)* Tether Ltd Mix (treasuries, cash, BTC, etc.) Tron, Ethereum ~US$ 150B
*SDC* Circle (with Coinbase) Treasuries + cash Ethereum, Solana, Base ~US$ 60B
*YUSD* Paxos for PayPal Treasuries + cash Ethereum, Solana ~US$ 1B
*DUSD* First Digital Trust Treasuries BSC ~US$ 2B
*USD* TrustToken / Techteryx Treasuries Multi-chain ~US$ 0.5B
*SDe (Ethena)* Ethena Labs Synthetic delta-neutral (ETH + perps short) Ethereum ~US$ 5B

Crypto-collateralized

Token Protocol Backing
*AI* MakerDAO / Sky Multi-collateral (ETH, RWA via private credit, USDC)
*SDS* Sky (rebrand DAI 2024) Idem
*rvUSD* Curve LLAMMA-AMM liquidations
*HO* Aave Multi-collateral debt
*USD* Liquity ETH-only, immutable

Algorithmic / hybrid

Token Mechanism Status
*RAX* Hybrid (partial collateral + protocol-controlled value) Active, ~US$ 0.6B
*ST (Terra)* Algorithmic via LUNA mint/burn *EAD 2022*(US$ 60B collapse)
*SDe (Ethena)* Delta-neutral synthetic Active, growing

USDe (Ethena) — case interessante

*uy Young 2023* *ynthetic dollar*

  • Holds long ETH spot.
  • Shorts ETH perpetual futures (delta-neutral).
  • Funding rate revenue → yield to *USDe*stakers.
  • Risks: funding rate negative (custos), exchange counterparty (centralized perp venues).

ENA token. ~US$ 5B circulating mid-2026.

Stablecoin GENIUS Act (US, 2025)

Federal framework. Bank-issued stablecoins legitimized. Big banks (JPM, Citi) launching tokens.

Brasil — Drex (CBDC)

Digital Real do Banco Central. Phased rollout 20252026. Privacy concerns; regulatorcontrolled.


7. Liquid Staking (LSTs)

ETH staked via protocol → liquid wrapped token.

Token Protocol TVL
*tETH* Lido US$ 30B (30% all staked ETH)
*ETH* Rocket Pool ~US$ 4B
*bETH* Coinbase ~US$ 2B
*stETH* wrapped stETH (rebasing fix) derivative
*rxETH* Frax ~US$ 1B

Solana LSTs

  • *itoSOL* Jito-Solana validator client + MEV revenue. Top LST Solana.
  • *SOL* Marinade.
  • *SOL* BlazeStake.

Concerns

  • *ido centralization* 30% threshold debated; Vitalik wrote about ETH staking centralization risks.
  • *lashing risk* pool slashing affects all stakers.
  • *iquidity peg* stETH:ETH peg deviates em stress (mai/2022 LUNA stress: 0.94, recovered).

8. Liquid Restaking (LRTs)

Wrapping EigenLayer restaked ETH:

Token Protocol TVL
*ETH* Ether.fi ~US$ 3B
*zETH* Renzo ~US$ 2B
*ufETH* Puffer ~US$ 1B
*sETH* Kelp ~US$ 1B

Risks

  • *ecursive leverage* LRT → LP em DeFi → re-collateralized.
  • *VS slashing risk*propagates.
  • *epeg events*(jan/2024 ezETH brief depeg under conditions).

9. Yield aggregators

  • *earn Finance (YFI)* Andre Cronje. Fair-launch 2020 (no premine). Vaults strategically deploy capital.
  • *onvex (CVX)* Curve gauge bribes + boost.
  • *ura* Convex-style for Balancer.
  • *eefy* crosschain autocompounding.
  • *endle* yield tokenization (split principal + yield).

10. Oracles

Smart contracts can't access off-chain data natively — oracles ponte.

  • Largest oracle network. Decentralized aggregator.
  • *rice feeds* thousands of pairs.
  • *RF* verifiable randomness.
  • *utomation*(formerly Keepers): scheduled triggers.
  • *CIP* Cross-Chain Interoperability Protocol.
  • LINK token.

Pyth Network

  • *ull oracle* lowlatency price feeds. Originally Solana, now multichain.
  • Publishers: Jane Street, CBOE, Cumberland, Susquehanna.
  • ~400 price feeds, ~80 chains.

RedStone

  • *odular oracle* On-demand or push.
  • Many integrations em LRT pricing.

API3

  • *irst-party oracles* data providers run own nodes (no aggregator middleman).
  • *APIs*

UMA

  • *ptimistic oracle* assert + dispute.
  • Used by Polymarket for resolution.

Outras

Tellor, DIA, Band, Nest.


11. RWA (Real-World Assets)

Tokenization de assets tradicionais. Growing fast 2024-2026.

BlackRock BUIDL (US Treasury fund tokenizado)

  • Launched mar/2024 em Ethereum.
  • US$ 500M+ AUM em 2025.
  • Distributed via Securitize.

Ondo Finance (ONDO)

  • USDY (yield-bearing US Treasury wrapper).
  • OUSG (institutional Treasury).
  • US$ 600M+ AUM.

Centrifuge

  • Real-estate, invoice financing tokenization.
  • Integrated with MakerDAO collateral.

MakerDAO RWA collateral

  • ~50% of DAI collateral em RWA (treasuries, US bank loans).
  • Sky (rebranded MakerDAO 2024) doubling down.

Backed Finance, Securitize, Polymath

Tokenization platforms.

TVL trend

US\( 8B em 2023 → US\) 50B em 2025 → US$ 100B+ esperado 2026.


12. Prediction markets

Polymarket

  • Polygon-based.
  • US$ 3.5B+ volume in 2024 election season.
  • USDC-denominated.
  • UMA optimistic oracle resolution.
  • Banned em US during 2022-2024 CFTC settlement; relaunched US 2025 sob Trump admin.

Kalshi

  • US-regulated event exchange (CFTC).
  • Not crypto-native but adjacent. Election markets approved 2024.

Augur (legacy)

Pioneer prediction market 2018. Defunct.


13. Insurance

Nexus Mutual

  • Member-owned mutual.
  • NXM token.
  • Coverages: smart contract, exchange, custody.
  • ~US$ 250M cover total active.

Outras

Sherlock, InsurAce, Bridge Mutual, Etherisc.


14. DAO governance

Snapshot

  • Off-chain voting (gasless via signed messages).
  • IPFS-hosted proposals.
  • Quadratic, weighted, delegations.
  • Used by 99% of token-voting DAOs.

Tally

  • On-chain executive (after Snapshot vote).
  • Governor contract integration.

Safe (Gnosis Safe)

  • Multisig wallet standard.
  • Used by 95% of DAOs for treasury.

Governance models

  • *oken-weighted* 1 token = 1 vote. Crítica: plutocracy.
  • *uadratic voting* \(\sqrt{\text{tokens}}\) vote weight. Anti-whale.
  • *elegated* hold tokens, delegate vote (UNI, COMP, AAVE).
  • *onviction voting* longer hold = more weight (1Hive).
  • *ptimistic governance* pass unless challenged.

Major DAOs

  • *akerDAO/Sky* complex, sub-DAOs (SparkDAO, etc.).
  • *niswap DAO* UNI holders. Famously inactive on fee switch debate.
  • *ave DAO* GHO, V4, deployments.
  • *ompound DAO* smaller activity.
  • *ptimism Collective* Citizens' House (impact attestations) + Token House (technical).
  • *NS DAO*
  • *itcoinDAO*

Governance attacks

  • *eanstalk*(apr/2022): flash-loan to acquire 67% voting power → drain treasury (US$ 182M).
  • *ornado Cash gov takeover*(mai/2023).

15. Métricas DeFi

TVL (Total Value Locked)

DeFi Llama (defillama.com) is reference. ~US$ 200B (mai/2026). Top chains:

Chain TVL
Ethereum L1 ~US$ 80B
Solana ~US$ 12B
BSC ~US$ 10B
Tron ~US$ 8B (mainly USDT)
Base ~US$ 8B
Arbitrum ~US$ 7B
Bitcoin (BTCFi) ~US$ 5B
Sui ~US$ 3B
Avalanche ~US$ 2B
Outros ~US$ 65B

DEX volume

US$ 2-5B/day. Uniswap dominante (40%), seguido Aerodrome, Pancake, Curve.

Perp volume

US$ 8-15B/day. Hyperliquid dominante (50%), dYdX, GMX.

Stablecoin supply

~US$ 250B em 2026. USDT 60%, USDC 25%, restante 15%.


16. Key Innovations Timeline

Ano Innovation Protocol
2017 First DEX EtherDelta, Bancor
2017 First lending ETHLend (later Aave)
2018 First AMM Uniswap v1
2019 Stablecoin DeFi DAI multi-collateral
2020 Yield farming Compound COMP launch
2020 Vampire attack SushiSwap
2020 yToken / vault Yearn
2020 Stableswap Curve
2021 Concentrated liquidity Uniswap v3
2021 ve-tokenomics Curve veCRV; later Velodrome ve(3,3)
2022 Optimistic oracle UMA
2023 Restaking thesis EigenLayer
2024 Hooks (modular AMM) Uniswap v4
2024 Modular lending Morpho Blue
2024 Tokenized treasuries mainstream BlackRock BUIDL
2025 Intent-based DeFi Anoma, Brink, ChainKit

17. Anti-patterns / risks específicos DeFi

❌ Oracle manipulation via flash loan (use Chainlink TWAP, not spot). ❌ Reentrancy em lending (CEI pattern obrigatório). ❌ Front-running em swaps grandes (use private mempool ou TWAP execution). ❌ Slippage protection ausente. ❌ Approval unlimited persistente (use Permit2 / scoped). ❌ Liquidity providing sem entender impermanent loss. ❌ Stake em LRT recursive sem entender slashing exposure. ❌ Yield "100%+ APY" sem fonte real de rendimento (provavelmente Ponzitokenemission).


18. Tools / dashboards

  • *eFi Llama*(TVL, yields, prices).
  • *une Analytics*(custom queries).
  • *oken Terminal*(revenue, fees).
  • *ansen*(on-chain analytics + smart money).
  • *rkham*(entity labeling).
  • *therscan, Basescan, etc.*(block explorers).
  • *EXScreener*(real-time DEX prices).
  • *erion, DeBank, Zapper*(portfolio dashboards).

19. Referência cruzada

  • L1s onde DeFi vive: 04-l1-bitcoin.md, 05-l1-ethereum.md, 06-l1-alt.md.
  • L2s scaling DeFi: 07-l2-scaling.md.
  • Smart contracts (linguagens, patterns): 08-smart-contracts.md.
  • Tokens (governance, vesting): 12-tokenomics.md.
  • DeFi hacks: 14-incidentes.md.
  • Regulação (SEC vs DeFi, MiCA): 13-regulacao.md.

Source: ../home/koder/dev/koder/meta/docs/blockchain/compendium/09-defi.md