Project Name: QuickLend Goal: Create a decentralized, non-custodial liquidity protocol where users can participate as Suppliers (providing liquidity to earn interest) or Borrowers (taking over-collateralized loans).
- Pooled Liquidity: No peer-to-peer matching; users interact with a smart contract pool.
- Over-collateralization: All loans must be backed by more value than the debt to ensure solvency.
- Algorithmic Interest: Rates are determined by the ratio of borrowed funds to supplied funds (utilization).
- Supply: Users deposit supported ERC-20 tokens into the protocol. In return, they receive "qTokens" (ERC-20 Tokens) representing their share of the pool plus accrued interest.
- Withdraw: Users burn qTokens to reclaim their underlying assets. Withdrawal is only permitted if the user’s remaining collateral is sufficient to cover their active borrows.
- Borrow: Users can borrow an asset against their supplied collateral. The maximum amount is governed by the Loan-to-Value (LTV) ratio of the collateral.
- Repay: Users return the borrowed asset plus accrued interest to close their debt and "unlock" their collateral.
- The protocol must support multiple pools (e.g., ETH, USDC, WBTC).
- A user should be able to supply Asset A and borrow Asset B.
- The system calculates the total value of all collateral vs. total value of all debt in a single USD-denominated "Health Factor."
Interest rates should be a function of Utilization ():
Utilization = Total_Borrowed / Total_Supplied
As approaches 100%, the interest rate increases sharply to encourage repayments and new deposits.
- Borrow Rate (): .
Borrow_Rate = Base_Rate + (Utilization * Slope_Value)
- Supply Rate (): .
Supply_Rate = Borrow_Rate * Utilization * (1 - Reserve_Factor)
The determines if a position is safe or eligible for liquidation.
Health_Factor = (Sum_of(Collateral_i * Liquidation_Threshold_i)) / Total_Debt_in_USD
- Health Factor > 1.0: The position is healthy.
- Health Factor < 1.0: The position is under-collateralized and can be liquidated.
If , a third-party "liquidator" can:
- Repay a portion of the borrower's debt (e.g., up to 50%).
- Receive an equivalent amount of the borrower's collateral plus a Liquidation Bonus (e.g., 5-10%) as an incentive.
- Core/LendingPool: The main entry point for user interactions (Supply, Borrow, Repay, Withdraw).
- Price Oracle: A contract (e.g., Chainlink) to provide real-time price feeds for LTV and calculations.
- InterestRateModel: A standalone contract that calculates rates based on pool state.
- qToken: An ERC-20 compliant token representing the user's deposit share.
- User calls
supply(asset, amount)-> Pool transfers tokens and mints qTokens. - User calls
borrow(asset, amount). - Pool checks Oracle for asset prices.
- Pool calculates Health Factor.
- If , Pool transfers borrowed tokens to User.
- Price Manipulation Protection: Use decentralized oracles (Chainlink) rather than spot prices from a single DEX to prevent "Flash Loan" price manipulation attacks.
- Reentrancy Guard: Apply
nonReentrantmodifiers to all functions involving asset transfers. - Emergency Pause: A "Circuit Breaker" controlled by an admin/DAO to pause deposits and borrows in case of a detected exploit.
- Dashboard: Show Total Market Size, Total Borrows, and Net APY.
- Account View: Display User Health Factor, Max Borrow Power, and "Liquidation Price" for their collateral.
- Asset List: A table showing Supply APY, Borrow APY, and LTV for each supported token.