← Back to home

CredBook

On-chain orderbook for DeFi lending - competiting liquidity pools give best rates to borrowers

Problem Statement

What is this project? This project introduces an on-chain orderbook-based lending platform that revolutionizes how borrowers access liquidity in DeFi. Instead of borrowing from a single pool at a fixed rate, borrowers interact with a unified orderbook that aggregates quotes from multiple competing lending pools, each with different interest rate models and risk parameters. The Problem Current DeFi lending platforms (Aave, Compound) force users to borrow from monolithic pools with single interest rate curves. This creates inefficiencies:Borrowers can't easily compare rates across different pools No competition between different capital providers Lenders can't differentiate strategies to earn higher yields Rate discovery is poorOur Solution We've built a two-layer architecture: Layer 1: Competing Lending PoolsMultiple isolated lending pools (inspired by Morpho Blue's minimal design) Each pool has its own Interest Rate Model (IRM) - linear curves, kinked curves, or custom models Pools compete to fill borrower orders by offering competitive rates Each pool quotes 5 orders on the orderbook representing tranches of liquidity at different rates (based on utilization)Layer 2: On-Chain Orderbook & Matching EngineA sophisticated orderbook aggregates all pool quotes (20 orders from 4 pools in our demo) Uses an efficient sorting algorithm to maintain orders sorted by interest rate. Borrowers submit market or limit orders Matching engine automatically fills orders from the cheapest available liquidity When orders are filled, affected pools requote their 5 orders based on new utilization Orderbook re-sorts all orders to maintain best-executionKey InnovationsDynamic Rate Discovery: Pools continuously requote based on utilization, creating real-time market rates Best Execution: Borrowers automatically get the lowest available rate across all pools Lender Choice: Lenders can analyze historical pool performance and choose which pools to supply based on yield/risk Scalability: Permissionless pool creation means anyone can deploy pools with custom IRMs Capital Efficiency: Each pool only needs $1000 minimum per order tick (configurable)Use CasesBorrowers: Get best rates without manually checking multiple protocols Lenders: Choose aggressive vs conservative pools based on historical fill rates Market Makers: Create specialized pools targeting specific utilization ranges Institutions: Deploy private pools with custom risk parameters

Solution

Technology Stack Smart ContractsCore lending pools with supply, borrow, repay, and collateral management Multiple interest rate models: linear curves and kinked models (Aave-style) that compete for borrower orders Orderbook matching engine using Red-Black Tree for efficient O(log n) sorting of pool quotes by interest rate Shares-based accounting for lenders (similar to aTokens) with compound interest accrualPyth NetworkReal-time price feeds for collateral valuation with sub-second updates Pull-based oracle model ensures orderbook always has fresh prices for accurate LTV calculations 400ms updates vs traditional oracles' minutes enables safer lending at higher LTVsFrontend (Next.js)Real-time orderbook visualization showing aggregated rates across all pools Historical pool performance analytics for lenders to compare yields One-click borrowing at best available rates

Hackathon

ETHOnline 2025

2025

Contributors