Section 15 of 18
Liquidation: Comptroller Side
Key takeaway: Compound V2's liquidation logic enforces a 50% close factor (a single liquidation can only close half of a borrower's debt in a market) and an 8% liquidation incentive (
liquidationIncentive = 1.08) paid to the liquidator from the borrower's collateral. TheliquidateCalculateSeizeTokensmath converts repaid debt to seizable collateral viarepayAmount * priceBorrowed * 1.08 / (priceCollateral * exchangeRate). The 50% cap gives the borrower a recovery window; the 8% bonus makes liquidations profitable enough to attract liquidator bots.
What You Are Building
You are building the Comptroller's liquidation policy: the rules that decide WHEN someone can be liquidated, HOW MUCH of their debt can be repaid in one transaction, and HOW MANY collateral tokens the liquidator receives. This is the brain of the liquidation system. The next section builds the CToken execution side that carries out the actual seizure.
Uniswap V2 has no equivalent because it has no lending. Liquidation exists specifically because lending protocols allow borrowers to take on debt backed by volatile collateral. When collateral value drops below the debt, someone needs to step in and unwind the position before it creates bad debt that suppliers cannot recover.
Your Code
Requirements
Sign up free — keep reading + earn 20 Lynx
Zealynx Academy is free. Track your progress, earn Lynx, and climb the leaderboard.
Sign up free to continueAlready have an account? Log in