ebtc-protocol/ebtc

Refactor

Closed this issue · 0 comments

The code for surplus will benefit by a refactoring which I can apply after we merge down the rest of the code

The logic is basically a 4x4
-> Underwater or Not
-> Full or Partial Liq

If not underwater then math is straightforward

If underwater:

  • Assumption 1 Partial doesn't create Bad debt since it leaves some CDP left -> Need to think about this one further
  • Assumption 2 Full Liquidation is capped (less coll than debt), so we basically sell discounted coll per debt, which is why we do the extra math back from shares to Value

This causes some of the additional checks to be skippable in different scenarios (gas savings)

The logic is sound, imo can be clarified, and I have a draft refactoring I can send once we merge down this + any conflict

Lastly @dapp-whisperer the naming here doesn't have shares not even in the new PR, worth figuring this one out before doing any code changes