LendCore
Lending ProtocolSepolia LiveNext.js FrontendA decentralized isolated lending protocol built with Solidity 0.8.30 and Foundry, featuring UUPS upgradeable contracts, multi-sig governance with Timelock, health factor-based liquidations, ERC-4626 vault integration, and a real-time event-driven indexer backed by Supabase with a Next.js monitoring dashboard.
Core Features
Multi-Collateral Support
Whitelisted ERC20 tokens as collateral with health factor-based system preventing over-leveraging. Isolated markets keep risk contained per market pair.
Jump Rate Model
Dynamic interest rates (2%–60% APR) based on utilization. Base 2% → Optimal 80% kink → Steep 60% slope after kink, with 10% protocol fee on interest revenue.
Automated Liquidations
5% liquidation bonus protects lenders. Bad debt is isolated and tracked separately. Underwater positions can be liquidated atomically by any caller.
ERC-4626 Vaults
Standard-compliant vault tokens for yield bearing. Each market has its own Vault for lender deposits, with market-controlled borrowing and share-based accounting.
OracleRouter
Chainlink + TWAP price aggregation with staleness checks, confidence scoring, and 18-decimal internal normalization supporting 6/8/18 decimal tokens safely.
Real-Time Monitoring
Event-driven indexer (viem polling) writes market snapshots every 60s to Supabase. Next.js dashboard surfaces TVL, utilization, borrow rates, and oracle confidence in real time.
Frontend & Monitoring
A Next.js 16 app deployed on Vercel provides a full monitoring and interaction layer over the on-chain protocol. All data flows through a REST API backed by Prisma + Supabase.
Dashboard & Deposit UI
- Market overview — TVL, total borrows, per-market severity
- Deposit collateral and borrow against it per market
- Per-user position tracking with live health factors
- Recent liquidation event feed
Monitoring Sub-Pages
- /monitoring/liquidity — Liquidity depth ratio over time
- /monitoring/utilization — Utilization vs. optimal kink
- /monitoring/rates — Borrow & lending APR history
- /monitoring/oracle — Oracle confidence & price feeds
API Reference
| Endpoint | Method | Description |
|---|---|---|
| /api/vaults | GET | All markets with latest snapshot (TVL, utilization, severity) |
| /api/metrics?vault=<addr> | GET | Current metrics for a specific market |
| /api/history?signal=<type>&range=<r> | GET | Time-series data. Signals: liquidity, utilization, borrowRate, oracle. Ranges: 24h, 7d, 30d, 90d |
| /api/positions?user=<addr> | GET | User positions across all markets (latest per market) |
| /api/liquidations?limit=<n> | GET | Recent liquidation events (default 20, max 100) |
| /api/indexer | GET / POST | Indexer status; start/stop via POST {"action":"start"|"stop"} |
Event-Driven Indexer
The indexer (frontend/src/lib/indexer/) bridges on-chain state to the Supabase database via viem event polling at a 15-second interval. Market snapshots are written every 60 seconds; user positions and liquidations update on each relevant event.
Event Listener
- Polls MarketV1 via
viem.watchContractEvent - CollateralDeposited / CollateralWithdrawn
- Borrowed / Repaid / Liquidated
- GlobalBorrowIndexUpdated
Snapshot Generator
- Multicall reads on every event or 60s tick
- Computes liquidityDepthRatio, distanceToKink
- 4-level severity scoring (liquidity, APR, oracle)
- Writes MarketSnapshot to Supabase
Position & Liquidation Tracker
- Calls
getUserPosition(user)on each user event - Stores collateral value, debt, health factor, borrowing power
- Liquidation events upserted idempotently on (txHash, logIndex)
Database Schema
- Market — static market registry
- MarketSnapshot — periodic state (~1 row/market/60s)
- UserPositionSnapshot — per-user health factor history
- LiquidationEvent — on-chain liquidation records
Upgradeability & Governance
UUPS Proxy Pattern
- ERC1967 compliant proxy contracts
- 49-slot storage gap for safe future upgrades
- Separated storage layout (MarketStorageV1)
- Upgrade authorization enforced in implementation
Timelock Governance
- TimelockController with 2-day delay on all owner actions
- Emergency Guardian for instant borrow-only pause
- Deposits, withdrawals, and repayments unaffected by pause
- Multi-sig ready (Gnosis Safe compatible)
| Role | Capabilities | Delay |
|---|---|---|
| Owner | Upgrade contract, set parameters, add collateral | 2 days (via Timelock) |
| Guardian | Pause borrowing only (emergency) | Instant |
| Timelock | Holds ownership, enforces delay on all owner actions | 2 days |
| Multisig | Proposes and executes timelock operations | — |
Sepolia Testnet Deployment
All contracts are deployed and verified on Sepolia testnet. The monitoring frontend is live on Vercel.
| Contract | Address |
|---|---|
| MarketV1 (Proxy) | 0xC223...E907 |
| Vault (ERC-4626) | 0xE554...D3B |
| OracleRouter | 0xaA6B...8bD7 |
| InterestRateModel | 0x9997...7E0 |
| MarketTimelock | 0xF36B...D838 |
Test Assets (Mock Tokens)
| Token | Address |
|---|---|
| USDC | 0x4949E3c0fBA71d2A0031D9a648A17632E65ae495 |
| WETH | 0x4F61DeD7391d6F7EbEb8002481aFEc2ebd1D535c |
| WBTC | 0x773269dE75Ec35Bd786337407af9E725e0E32dD5 |
Security Architecture
Safety Mechanisms
- ReentrancyGuard on all state-changing functions
- Emergency Guardian for instant borrow-only pause
- Oracle staleness checks prevent stale price exploitation
- 18-decimal internal accounting prevents rounding errors
- Storage Gaps (49 slots) for safe future upgrades
Risk Mitigation
- Health factor prevents over-leveraging (LLTV 85%)
- 5% liquidation bonus protects lenders
- Bad debt isolated and tracked separately
- 2-day Timelock on all governance actions
- High utilization drives rates up, discouraging bank runs
Testing & Validation
91+ passing Foundry tests across unit, integration, governance, and upgrade scenarios. Complete NatSpec documentation throughout.
| Test Category | Focus |
|---|---|
| Market Unit Tests | Collateral, borrowing, repayment, liquidations, health factors, emergency pause |
| Vault / ERC-4626 | Standard compliance, market-controlled borrows, share pricing |
| Oracle | Price feed management, staleness checks, decimal normalization |
| Governance | Timelock delays, guardian pause, role-based access, risk proposals |
| Integration | Full lending cycles, price crash liquidation, bad debt scenarios |
| Upgrade Simulation | UUPS proxy upgrade safety, storage layout compatibility |