Skip to content

jainkrati/L-B

Repository files navigation

Lending/Borrowing Protocol

A simplified lending and borrowing protocol inspired by Aave/Compound, built with Solidity and Hardhat.

Features

  • Deposit tokens as collateral
  • Borrow against collateral
  • Dynamic interest rate model
  • Liquidation mechanism
  • Price oracle integration
  • Reentrancy protection
  • Access control

Smart Contracts

  1. MockToken.sol: A simple ERC20 token for testing
  2. InterestRateModel.sol: Implements a simplified version of Compound's interest rate model
  3. PriceOracle.sol: Provides price feeds for collateral valuation
  4. LendingPool.sol: Main contract handling deposits, withdrawals, borrowing, and liquidations

Key Parameters

  • Collateral Factor: 75%
  • Liquidation Threshold: 80%
  • Liquidation Penalty: 5%
  • Reserve Factor: 10%

Interest Rate Model

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

Security Features

  • ReentrancyGuard for all external functions
  • Access control for admin functions
  • Price oracle with minimum update intervals
  • Collateral and liquidation checks
  • Safe math operations

Development

Prerequisites

  • Node.js
  • npm
  • Hardhat

Installation

npm install

Compile Contracts

npx hardhat compile

Run Tests

npx hardhat test

Deploy

npx hardhat run scripts/deploy.ts --network <network>

Usage

  1. Deploy the contracts using the deployment script
  2. Set up the price oracle with initial prices
  3. Users can:
    • Deposit tokens as collateral
    • Borrow against their collateral
    • Repay their loans
    • Withdraw their collateral
    • Liquidate undercollateralized positions

Security Considerations

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

License

MIT

About

Lending and Borrowing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors