lindy-labs / opus_contracts

Opus Source Code
https://opus.money
Other
0 stars 0 forks source link

fix: align LTV comparison to always exceed benchmark #568

Closed tserg closed 8 months ago

tserg commented 8 months ago

This PR aligns LTV comparisons in recovery mode to always take the form of LTV > benchmark being compared against.

Specifically:

  1. A trove is unhealthy if its LTV > threshold.
  2. Recovery mode is triggered if the Shrine's LTV > target LTV.
  3. Thresholds start to be scaled in recovery mode if Shrine's LTV > target with buffer LTV.
milancermak commented 8 months ago

For future reference, is there a rule of thumb we can apply when dealing with LTV comparisons? 🤔

milancermak commented 8 months ago

Hmm, it's as simple as you've put it in the PR description, innit? "LTV > benchmark"

tserg commented 8 months ago

Hmm, it's as simple as you've put it in the PR description, innit? "LTV > benchmark"

Yes!

tserg commented 8 months ago

After some additional changes in #567, there will still be a few comparisons using >= for LTV, but these are used in relation to numerical bounds regarding the calculation of liquidation penalty rather than a comparison with a benchmark, so I think it is ok?

https://github.com/lindy-labs/opus_contracts/blob/3ae520f7015c24c0d82dbfc7d0c1e15f7dbc77ad/src/core/purger.cairo#L451 https://github.com/lindy-labs/opus_contracts/blob/3ae520f7015c24c0d82dbfc7d0c1e15f7dbc77ad/src/core/purger.cairo#L554 https://github.com/lindy-labs/opus_contracts/blob/3ae520f7015c24c0d82dbfc7d0c1e15f7dbc77ad/src/core/purger.cairo#L564

milancermak commented 8 months ago

Yeah, those comparisons are fine.

Good to go.