A decentralized protocol where users can borrow tokens by locking Uniswap LP tokens as collateral, leveraging blockchain technology for secure and transparent credit transactions.
Main Features
Collateralization
Users deposit Uniswap LP tokens (representing liquidity in pools) as collateral. This innovative approach allows users to utilize their liquidity positions as security for borrowing, providing a unique value proposition in the DeFi space.
- Utilizes IERC20 standard for interacting with LP tokens
- Supports various Uniswap pool types as collateral options
- Implements advanced token management techniques to handle complex token economics
Borrowing
The protocol calculates borrowing power based on the value of locked LP tokens, ensuring that borrowers only receive loans they can reasonably repay. To mitigate risks associated with impermanent loss, the system incorporates sophisticated volatility calculations:
- Dynamically adjusts borrowing limits based on market conditions
- Incorporates time-weighted average price (TWAP) calculations for accurate asset valuation
- Implements risk models that account for potential slippage and price impacts
Interest Calculation
Borrowed tokens accrue interest automatically, following a predefined formula that ensures fair returns for lenders while balancing the needs of borrowers:
- Implementing compound interest calculation methods
- Allowing for flexible interest rate adjustments based on market conditions
- Providing transparency through public view functions for checking accrued interest
Liquidity Provision
To incentivize participation and maintain market stability, the protocol introduces a mechanism for liquidators to step in when loans become undercollateralized:
- Liquidation threshold calculations based on market data and collateral value
- Time-sensitive liquidation processes to minimize losses for all parties involved
- Reward structures for successful liquidators to encourage active participation
How On-Chain Credit Market is Made
The On-Chain Credit Market protocol is built using Solidity, the programming language for Ethereum smart contracts. Here's a breakdown of its key components:
Smart Contracts
-
OnChainCreditMarket.sol:
- Core contract managing collateral deposits, borrowing, and repayments
- Handles position tracking for each user
- Implements interest calculation logic
-
CollateralHook.sol:
- Manages collateral-specific operations
- Calculates fees for swaps involving collateral
- Integrates with Uniswap-like protocols
-
ERC20Mock.sol:
- Mock implementation of ERC20 token standard
- Used for testing purposes
Key Functionalities
-
Collateralization:
- Users deposit Uniswap LP tokens as collateral
- Protocol calculates borrowing power based on collateral value
-
Borrowing Mechanism:
- Users request loans within their calculated borrowing limits
- Protocol verifies sufficient collateral before issuing loans
-
Interest Management:
- Compound interest calculation implemented
- Flexible interest rates based on market conditions
-
Liquidation System:
- Detects undercollateralized positions
- Allows liquidators to step in and repay loans
Development Tools and Libraries
- Solidity ^0.8.0 compiler
- Forge framework for testing
- OpenZeppelin contracts for standard implementations
Testing Approach
- Unit tests written using Forge-Std library
- Integration tests simulating real-world scenarios