Collateral Ratio Explained in Detail
Collateral ratio compares the value of posted collateral to outstanding debt. For example, $150 of collateral against $100 of debt gives a 150% collateral ratio.
Protocols use this ratio to decide whether users can borrow, mint, withdraw, or be liquidated.
Smart contract example
collateralRatio = collateralValue * 1e18 / debtValue;
Decimals, rounding, and oracle values all affect this result.
Collateral Ratio in Auditing
Collateral ratio is a solvency control. If the required threshold is too strict, users are blocked unfairly. If the calculated ratio is too generous or wrong, the protocol can accumulate bad debt.
Auditors review price sources, token decimals, interest accrual, and boundary rounding.
Red flags in code
-
Token decimals are mixed incorrectly.
-
Stale or manipulable oracle prices are used.
-
Rounding favors borrowers at liquidation boundaries.
-
Interest accrual is ignored before ratio checks.
-
Zero debt or zero collateral edge cases are unsafe.
How to test or review it
-
Fuzz collateral amounts, debt amounts, prices, and decimals.
-
Test exact liquidation thresholds.
-
Simulate price drops and interest accrual.
-
Check behavior for zero debt, zero collateral, and dust amounts.
-
Compare with health factor and liquidation rules.
Keep learning this topic
Health Factor
A health factor is a lending-risk metric that compares a borrower's adjusted collateral value against their debt.
Liquidation
Liquidation is a protocol action that repays or closes an undercollateralized borrow position and transfers collateral according to the protocol's rules.
Oracle Manipulation
Oracle manipulation occurs when an attacker distorts a data source that a smart contract trusts, causing the contract to make decisions from unsafe data.
Practice this in real audit scenarios
Definitions help, but auditors need reps. SCH turns concepts like Collateral Ratio into exploit labs, code review habits, and report-writing practice.
Start the free trial or see the full smart contract auditing course.