Synthetixio / synthetix-v3

MIT License
114 stars 56 forks source link

Make self-liquidate non-profitable / C02 #2222

Closed leomassazza closed 4 weeks ago

leomassazza commented 1 month ago

make self-liquidate unprofitable by only allowing it if the account has outstanding debt

kaleb-keny commented 4 weeks ago

Left preliminary feedback (no tests yet).

Before merging, please ensure isEligibleForMarginLiquidation() behaves as expected under the following conditions (at minimum):

  1. availableMargin < 0
  2. availableMargin > 0
  3. self.debt > 0
  4. self.debt < 0 && self.debt >= totalLiquidationReward
  5. self.debt > 0 && self.debt < totalLiquidationReward

The function should return true in situations where the user runs out of margin, This is the case when his availableMargin less the liquidationReward (paid to liquidator) is less than zero.