You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A decentralized isolated lending protocol built with Solidity 0.8.30, Foundry, and a full-stack TypeScript platform. Features UUPS upgradeable contracts, multi-sig governance with Timelock, a Jump Rate interest model, health factor-based liquidations, ERC-4626 vault integration, and a deterministic block-based indexer backed by Supabase PostgreSQL.
Isolated markets — Each market is a standalone MarketV1 + Vault pair with its own oracle and interest rate model. Risk is fully isolated per market — a WBTC liquidation cascade cannot affect the USDC market.
Deterministic block-based indexer — Processes getLogs per confirmed block (tip − 12 confirmations) in strict block/log order. Survives restarts via SyncState cursor. Detects and rolls back reorgs using a 20-block IndexedBlock hash window.
Separated backend service — The indexer and data API run as a persistent Node.js/Express process on Railway, decoupled from the Next.js frontend. Vercel serverless functions cannot run persistent event listeners.
Severity system — Each metric dimension (liquidity depth, APR convexity, oracle confidence) has its own 0–3 severity level. A composite maximum drives dashboard alerts and colour coding.
Jump Rate Model — Interest rates rise gradually up to 80% utilization (the "kink"), then spike steeply above it to incentivise repayment and protect lender liquidity.
Smart Contracts
Core Contracts
Contract
Purpose
Key Features
MarketV1
UUPS upgradeable lending market
Multi-collateral, health factor, liquidations, emergency pause
The backend (backend/) is a standalone Node.js + Express service that runs persistently on Railway. It owns the indexer and serves all data API endpoints.
On startup recovery — reads SyncState.lastProcessedBlock, calls processBlockRange(lastProcessed+1, safeHead) to catch up any blocks missed during downtime, then resumes live polling. No events are silently skipped across restarts.
Cron Jobs
Schedule
Job
Every 1 min
Market snapshot for all active markets (TVL, utilization, rates, oracle, severity)
Every 10 min
Recompute health factors for recently-active user positions
Daily midnight
Analytics aggregation
Internal Endpoints
Endpoint
Auth
Purpose
POST /internal/resync
ADMIN_SECRET
Replay from lastProcessedBlock − REORG_BUFFER to catch up
POST /internal/recompute-markets
CRON_SECRET
Force market snapshot recomputation (called by GitHub Actions)
GET /health
None
DB + RPC connectivity check + lastIndexedBlock
Frontend
The frontend (frontend/) is a Next.js 15 app deployed on Vercel. It reads all data from the backend REST API via NEXT_PUBLIC_API_URL.
Pages
Page
Route
Description
Landing
/
Marketing page with protocol overview
Dashboard
/dashboard
Market table, protocol metrics, clickable market sidebar with interest rate curve graph and deposit/withdraw form
git clone https://github.com/Enricrypto/Isolated-Lending-Market.git
cd Isolated-Lending-Market
# Install Foundry dependencies
forge install
# Build contracts
forge build
# Run tests
forge test
Backend Setup
cd backend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your DATABASE_URL, RPC_URL, DEPLOYMENT_BLOCK, secrets# Generate Prisma client
npx prisma generate
# Push schema to database (run once, or after schema changes)
npx prisma db push
# Start dev server
npx tsx src/app.ts
# Or build and run
npm run build && node dist/app.js
Frontend Setup
cd frontend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env — set NEXT_PUBLIC_API_URL to your backend URL# Start dev server (reads data from backend)
npm run dev
# All tests
forge test# Specific test file
forge test --match-path test/unit/RiskEngineTest.t.sol
# With gas report
forge test --gas-report
# Verbose traces
forge test -vvvv
Test Coverage
Area
Focus
Market
Collateral, borrowing, repayment, liquidations, health factors, emergency pause
# After first deploy: run DB migration
railway run npx prisma db push
# Seed the Market table with your deployed contract addresses
railway run npx tsx prisma/seed.ts
CONFIRMATIONS = 12 — blocks to wait before processing (finality buffer)
REORG_BUFFER = 20 — blocks to retain for reorg detection
DEPLOYMENT_BLOCK = ? — first block to index from (set to contract deploy block)
Foundry — Solidity development and testing framework
Chainlink — Decentralized oracle network
Compound Finance — Jump Rate Model inspiration
Aave — Liquidation mechanism design patterns
Supabase — Managed PostgreSQL
Railway — Backend hosting
Vercel — Frontend deployment
About
A production-ready DeFi lending protocol built for secure, scalable borrowing and lending with multi-collateral support and ERC-4626 vault architecture, enabling seamless yield strategy integration and precise asset accounting. It features dynamic interest rates, health factor–based liquidations, and a robust access control + governance system.