← Back to home

Credit Market

A protocol where users borrow tokens by locking Uniswap LP tokens as collateral.

Screenshots

Credit Market screenshot 1
Credit Market screenshot 2
Credit Market screenshot 3

Problem Statement

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 FeaturesCollateralizationUsers 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 tokensSupports various Uniswap pool types as collateral optionsImplements advanced token management techniques to handle complex token economicsBorrowingThe 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 conditionsIncorporates time-weighted average price (TWAP) calculations for accurate asset valuationImplements risk models that account for potential slippage and price impactsInterest CalculationBorrowed tokens accrue interest automatically, following a predefined formula that ensures fair returns for lenders while balancing the needs of borrowers:Implementing compound interest calculation methodsAllowing for flexible interest rate adjustments based on market conditionsProviding transparency through public view functions for checking accrued interestLiquidity ProvisionTo 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 valueTime-sensitive liquidation processes to minimize losses for all parties involvedReward structures for successful liquidators to encourage active participation

Solution

How On-Chain Credit Market is MadeThe 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 ContractsOnChainCreditMarket.sol:Core contract managing collateral deposits, borrowing, and repaymentsHandles position tracking for each userImplements interest calculation logicCollateralHook.sol:Manages collateral-specific operationsCalculates fees for swaps involving collateralIntegrates with Uniswap-like protocolsERC20Mock.sol:Mock implementation of ERC20 token standardUsed for testing purposesKey FunctionalitiesCollateralization:Users deposit Uniswap LP tokens as collateralProtocol calculates borrowing power based on collateral valueBorrowing Mechanism:Users request loans within their calculated borrowing limitsProtocol verifies sufficient collateral before issuing loansInterest Management:Compound interest calculation implementedFlexible interest rates based on market conditionsLiquidation System:Detects undercollateralized positionsAllows liquidators to step in and repay loansDevelopment Tools and LibrariesSolidity ^0.8.0 compilerForge framework for testingOpenZeppelin contracts for standard implementationsTesting ApproachUnit tests written using Forge-Std libraryIntegration tests simulating real-world scenarios

Hackathon

ETHGlobal Bangkok

2024

Contributors