๐Ÿ“ Math behind Liquidations

We have made our own liquidation formula to allow users to choose their preferred liquidation target. Some might want to be liquidated close to the maximum, and some close to the minimum. As the price goes down, every user gets liquidated to the same position, as there is a limit on how far stepped liquidations go, as we don't want the liquidation fees to be less than gas and swap fees.

Value
Description
Possible Values

e

1 ETH, aka 10ยนโธ wei

1 ETH

debt

User's debt value in dollars

0 - โˆž

collateral

User's real collateral value in dollars (not adjusted to the maximum collateral ratio)

0 - โˆž

health

Target health ratio

0 - 1 ETH

mcr

Maximum collateral ratio

0 - 1 ETH

fee

Liquidation fee added onto collateral

0 - 1 ETH

The equation used to determine debt and borrow + fee change needed to reach target health.

Code we use to calculate the debt and collateral change for a user.

Last updated