Why I built it
I wanted to understand lending protocols by implementing the maths myself: utilisation-based interest rates, health factors, collateral factors and liquidation. Reading Aave’s code teaches you something; getting a health-factor check wrong and debugging it teaches you more.
What it does
- Supply, borrow, repay and liquidate
- Interest rates that rise with pool utilisation to attract supply and encourage repayment
- Pool-share tokens that accrue yield
- An off-chain indexer and a web app, all started with one command
How it’s built
Solidity contracts built and tested with Foundry, using OpenZeppelin and Solady. A Next.js and wagmi frontend, plus a Fastify indexer backed by PostgreSQL and Redis, all running against a local Anvil chain in Docker Compose.
The hard part
Edge cases in the risk maths. Small errors in collateral calculations either flagged healthy positions for liquidation or let unhealthy ones slip through. Most of the 119 tests exist because of interest accrual near 100% utilisation.