DeFi lending protocols like Aave, Compound, and MakerDAO have created a parallel financial system where anyone can lend or borrow digital assets without intermediaries. These protocols manage billions in deposits using smart contracts that automate interest accrual, collateral management, and liquidation. Understanding their architecture is essential for developers building in the DeFi space.
Pool-Based Lending Architecture
Most DeFi lending protocols use a pool-based model. Lenders deposit assets into a shared liquidity pool and receive interest-bearing tokens (aTokens in Aave, cTokens in Compound) that represent their share of the pool. Borrowers take assets from the pool by posting collateral worth more than the loan value. Interest rates are determined algorithmically based on the utilisation rate — the ratio of borrowed assets to total deposits. When utilisation is low, rates are low to incentivise borrowing. As utilisation increases, rates rise to attract more deposits and discourage excessive borrowing. This creates a self-balancing market without human intervention.
Overcollateralisation and Liquidation
Since DeFi lending is permissionless and pseudonymous, all loans must be overcollateralised. The mechanics work as follows:
- Collateral factors: Each asset has a loan-to-value ratio determining how much can be borrowed against it. ETH might have a factor of 80%, meaning you can borrow up to 80% of your ETH collateral's value.
- Health factor: A ratio tracking the safety of a position. When collateral value drops relative to debt (due to price movements), the health factor decreases. Below 1.0, the position becomes eligible for liquidation.
- Liquidation: Third-party liquidators repay a portion of the borrower's debt and receive collateral at a discount (the liquidation bonus). This incentivises rapid liquidation to keep the protocol solvent.
Oracle Dependency
Price oracles are critical infrastructure for lending protocols. They provide the real-time asset prices used to calculate collateral values, health factors, and liquidation thresholds. Chainlink is the most widely used oracle network, providing decentralised price feeds aggregated from multiple data sources. Oracle manipulation — feeding incorrect prices to a protocol — has been the attack vector behind some of the largest DeFi exploits. Protocols mitigate this risk using time-weighted average prices, multiple oracle sources, circuit breakers that pause operations on extreme price movements, and governance-controlled price deviation thresholds.
Building a Lending Protocol
Developing a lending protocol requires deep expertise in financial engineering, smart contract security, and risk management. The core contracts handle deposit and withdrawal logic, interest rate calculations, collateral accounting, and liquidation mechanics. Supporting infrastructure includes oracle integration, governance modules for parameter updates, and analytics dashboards for monitoring protocol health. Every parameter — from collateral factors to liquidation bonuses — must be carefully calibrated through economic modelling and stress testing. At Born Digital, we work with DeFi teams to architect and implement lending protocols with robust risk management, drawing on our experience in Malta's growing blockchain ecosystem.