DeFi

Collateral Ratio

Collateral ratio is the ratio of collateral value to debt value in a lending, borrowing, or minting system.

Collateral ratio measures how much backing exists for a debt.

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.

Sources