lindy-labs / opus_contracts

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

feat: disallow triggering of recovery mode; modify threshold adjustment #527

Closed tserg closed 8 months ago

tserg commented 10 months ago

Fix https://github.com/code-423n4/2024-01-opus-findings/issues/9

Summary of changes:

  1. A trove action will revert if it moves the Shrine from normal mode into recovery mode (i.e. worsens Shrine's LTV to 70% of Shrine's threshold).
  2. Once in recovery mode, thresholds are not immediately scaled. Instead, they are scaled after an additional buffer of 5% of the Shrine's threshold is exceeded i.e. the Shrine's LTV reaches 75% of its threshold.
  3. Once in recovery mode, if a trove's LTV is worse than its target recovery mode LTV (i.e. 70% of its threshold), then any trove action that worsens the LTV will revert.
  4. Once in recovery mode, if a trove's LTV is not worse than its target recovery mode LTV, then it can take any action provided its LTV does not exceed target recovery mode LTV (i.e. 70% of its threshold), in which case it would revert.
  5. When in recovery mode, a trove's threshold is scaled based on how far its current LTV exceeds it target recovery mode LTV.

Note that once in recovery mode, there are two different thresholds for a trove: 1. the recovery mode target threshold, which acts as a limitation by preventing forge and withdraw if they would cause the trove's LTV to worsen [UPDATE - a better name for this would actually be recovery mode target LTV]; 2. the threshold for liquidation, which is likely different from (1) once it starts to be scaled after the Shrine's LTV exceeds the buffer.