Compound (V2)

Compound Finance V2, the canonical pooled-liquidity lending protocol in DeFi, launched in 2019. The most-forked lending contract ever shipped. Composed of cToken contracts, a Comptroller for cross-market policy, an Interest Rate Model, and a price oracle.

Compound V2 is the second version of the Compound Finance protocol, launched in 2019 by Compound Labs. It established the dominant design pattern for pooled-liquidity lending in DeFi — a pattern that has been forked hundreds of times across EVM chains.

The Core Design

The protocol is organized around four contract categories:

  • cToken contracts: one per supported asset. cUSDC, cDAI, cETH, etc. Each cToken is both a market (holding the asset pool and tracking borrows) and an ERC-20 token representing supplier shares.
  • Comptroller: a single contract that enforces cross-market policy. Can this user borrow? Is this user eligible for liquidation? What's the user's total collateral value across all markets?
  • Interest Rate Model: given a market's utilization, returns borrow APR and supply APR. Typically piecewise linear with a kink at ~80% utilization.
  • Price Oracle: provides asset prices to the Comptroller for collateral valuation. Originally a simple admin-updatable oracle; production deployments use Chainlink.

Key Mechanics

Supply: users deposit an asset into its cToken market, receiving cTokens at the current exchange rate. As the market earns interest, the exchange rate grows. Redeeming cTokens returns the underlying plus accumulated interest.

Borrow: users supply one or more assets as collateral, enter those markets, then borrow any other supported asset (up to their collateral factor limit). Borrow balances accumulate interest block-by-block.

Liquidation: if a user's total borrow value exceeds their total collateral value (adjusted by collateral factors), anyone can liquidate them — repaying some of their debt in exchange for their collateral at a ~5-8% discount.

Accrual: interest does not compound per transaction on each user. It compounds per block, triggered by any interaction with a cToken. This is gas-efficient but means the on-chain state reflects the last interaction block, not the current block, for reads.

Why It Got Forked So Much

Compound V2's code is clean, well-tested, and permissively licensed. Teams launching lending protocols on new chains (BSC, Avalanche, Fantom, Arbitrum, Optimism, Canto, and many more) typically forked Compound V2 as the starting point. Within a couple of years of V2's launch, forks outnumbered original deployments dozens-to-one.

This is also why Compound V2 is central to security work. Auditors reviewing lending protocols usually spend most of their time on V2-family code. Many shipped exploits target the specific modifications forks made to the original — custom interest rate models, added KYC layers, swapped oracles, different asset types.

Well-Known Forks (and Their Fates)

  • Cream Finance — multiple exploits traced to issues in forked and extended V2 code.
  • Iron Bank — a credit-line layer on top of Compound V2.
  • Flux Finance — V2 fork with KYC/compliance checks. Shadow Arena target at Zealynx Academy.
  • Canto v2 Lending — V2 fork with a custom interest rate model tied to Canto's algorithmic stablecoin (cNote). Shadow Arena target.
  • Benqi (Avalanche), Hundred (multi-chain), Venus (BSC) — each notable large deployments of V2 with their own modifications.

Each of these is a case study in what can go wrong when modifying Compound V2 — specific patterns the Compound V2 module in Zealynx Academy is designed to surface.

Evolution to V3

Compound V3 (2022+) is a major redesign. Each V3 market has one borrowable asset and many collateral-only assets — an asymmetric model different from V2's symmetric cToken-per-market design. V3 also uses different precision math and a different liquidation approach. Compound Labs' own production is now V3, but V2 remains the widely-forked pattern and the common language of DeFi lending.

Need expert guidance on Compound (V2)?

Our team at Zealynx has deep expertise in blockchain security and DeFi protocols. Whether you need an audit or consultation, we're here to help.

Get a Quote