balancednetwork / balanced-java-contracts

Java contracts for Balanced
Apache License 2.0
10 stars 15 forks source link

Soft liquidations in Loans #430

Closed AntonAndell closed 1 month ago

AntonAndell commented 5 months ago

Currently all liquidations on loans are final with a lot of loss to users.

The soft liquidations will replace this: New Parameters

Per collateral -> liquidation threshold (ex 85%) Liquidator fee (ex 4%) daofund fee (ex 1%)

This will deprecate the reserve fund and the daofund will be the reserve and will have to manually cancel any bad debt.

New flow.

A liquidator calls the liquidate method for a user with the amount of bnUSD it wants to spend and for which collateral.

If the position is above the liquidation threshold:

sell users collateral to caller for (oracle price - (Liquidator fee +daofund fee)) which in this case would be 95% of oracle price. Until the specified amount is reached or the users liquidation ratio is below liquidation threshold.

If users collateral goes to 0 while debt remains. Add remaining debt to bad debt and close the position.

If debt is less than a minimum Debt threshold allow to liquidate to 0 to avoid dust positions.

All old liquidation logic should be cleaned up and removed. Reserve should be deprecated.

FezBox commented 4 months ago

working on testing after development

FezBox commented 3 months ago

on testnet