Liquidation
How the DegenPrime liquidation system works: health monitoring, execution mechanics, and the 3.5% bonus structure.
Overview
When a Smart Loan's health ratio drops below 1.0, it becomes eligible for liquidation. Any user can liquidate the loan by repaying a portion of its debt and receiving the equivalent collateral value plus a 3.5% bonus.
Health Threshold
< 1.0
Loans below this are liquidatable
Liquidation Bonus
3.5%
Reward for liquidators
Fee Split
50/50
Liquidator / Treasury
Health Ratio Monitoring
The health ratio is calculated as the threshold-weighted collateral value divided by total debt. Each asset tier has different LTV thresholds that affect how much collateral value counts toward solvency.
| Health Ratio | Status | Action |
|---|---|---|
| > 1.5 | Healthy | No action needed |
| 1.0 - 1.5 | Warning | Consider adding collateral or repaying debt |
| < 1.0 | Liquidatable | Can be liquidated by anyone |
// Monitor health ratio for a loan
const healthRatio = await client.readContract({
address: loanAddress,
abi: viewFacetAbi,
functionName: "getHealthRatio",
});
const hr = Number(healthRatio) / 1e18;
if (hr < 1.0) {
console.log("LIQUIDATABLE! Health ratio:", hr);
}Finding Liquidation Opportunities
Use the MoltPrime liquidation API to discover loans eligible for liquidation. The endpoint returns opportunities sorted by urgency.
// Fetch liquidation opportunities from MoltPrime API
const response = await fetch(
"https://moltprime.io/api/protocol/liquidations"
);
const { data } = await response.json();
for (const opp of data) {
console.log(
`Loan: ${opp.loanAddress}`,
`Health: ${opp.healthRatio}`,
`Bonus: $${opp.bonus}`,
);
}Executing a Liquidation
Important: Liquidation transactions must be wrapped with RedStone price data. The solvency check verifies the loan is indeed below the threshold before allowing liquidation.
import { WrapperBuilder } from "@redstone-finance/evm-connector";
// 1. Identify debts to repay
const debtTokens = [
keccak256(encodePacked(["string"], ["USDC"])),
keccak256(encodePacked(["string"], ["WETH"])),
];
const repayAmounts = [
500n * 10n ** 6n, // Repay 500 USDC
parseEther("0.25"), // Repay 0.25 WETH
];
// 2. Approve tokens to the loan address
await walletClient.writeContract({
address: usdcAddress,
abi: erc20Abi,
functionName: "approve",
args: [targetLoanAddress, repayAmounts[0]],
});
// 3. Wrap with RedStone and execute
const wrappedContract = WrapperBuilder
.wrap(contract)
.usingDataService({
dataServiceId: "redstone-arbitrum-prod",
uniqueSignersCount: 3,
});
const tx = await wrappedContract.liquidateLoan(
debtTokens,
repayAmounts,
);
// You receive collateral + 3.5% bonusLiquidation Bot Strategy
- 1Poll
/api/protocol/liquidationsevery 15 seconds to discover new opportunities. - 2Verify on-chain that the health ratio is still below 1.0 before submitting.
- 3Pre-approve repayment tokens to avoid extra transaction latency.
- 4Use flashbots or private mempool submission to avoid frontrunning.
- 5Immediately swap received collateral to stablecoins to lock in profit.