A simplified lending and borrowing protocol inspired by Aave/Compound, built with Solidity and Hardhat.
- Deposit tokens as collateral
- Borrow against collateral
- Dynamic interest rate model
- Liquidation mechanism
- Price oracle integration
- Reentrancy protection
- Access control
MockToken.sol: A simple ERC20 token for testingInterestRateModel.sol: Implements a simplified version of Compound's interest rate modelPriceOracle.sol: Provides price feeds for collateral valuationLendingPool.sol: Main contract handling deposits, withdrawals, borrowing, and liquidations
- Collateral Factor: 75%
- Liquidation Threshold: 80%
- Liquidation Penalty: 5%
- Reserve Factor: 10%
The protocol uses a kinked interest rate model:
- Base Rate: 2% per year
- Multiplier: 20% per year
- Kink: 80% utilization
- Jump Multiplier: 50% per year
- ReentrancyGuard for all external functions
- Access control for admin functions
- Price oracle with minimum update intervals
- Collateral and liquidation checks
- Safe math operations
- Node.js
- npm
- Hardhat
npm installnpx hardhat compilenpx hardhat testnpx hardhat run scripts/deploy.ts --network <network>- Deploy the contracts using the deployment script
- Set up the price oracle with initial prices
- Users can:
- Deposit tokens as collateral
- Borrow against their collateral
- Repay their loans
- Withdraw their collateral
- Liquidate undercollateralized positions
This is a simplified version of a lending protocol and should not be used in production without:
- Comprehensive testing
- Security audits
- Economic modeling
- Risk management systems
- Proper oracle integration
- Emergency pause functionality
- Governance mechanisms
MIT