Skip to content

fix(loan_manager): correct oracle rate sanity check condition in comp… - #1477

Open
barry01-hash wants to merge 1 commit into
LabsCrypt:mainfrom
barry01-hash:fix/631-oracle-rate-sanity-check
Open

fix(loan_manager): correct oracle rate sanity check condition in comp…#1477
barry01-hash wants to merge 1 commit into
LabsCrypt:mainfrom
barry01-hash:fix/631-oracle-rate-sanity-check

Conversation

@barry01-hash

Copy link
Copy Markdown

Closes #1297

…ute_interest_rate

The sanity check meant to reject an oracle rate that falls outside the min/max band could never trigger because && was used instead of ||. A u32 value cannot be simultaneously less than min_rate AND greater than max_rate, so the condition was always false and the intended fallback branch was dead code.

A stale or compromised oracle could push the rate to zero (free loans) or to an extreme value without being caught.

Changed && to || so the check correctly triggers when the oracle rate is below the minimum OR above the maximum band.

Fixes #631.

File: contracts/loan_manager/src/lib.rs
Function: compute_interest_rate

Pull Request Checklist

Please ensure your PR follows these steps, mirroring our CONTRIBUTING.md guidelines.

  • I have read the CONTRIBUTING.md document.
  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation accordingly.
  • I have verified the changes locally.

…ute_interest_rate

The sanity check meant to reject an oracle rate that falls outside
the min/max band could never trigger because && was used instead of
||. A u32 value cannot be simultaneously less than min_rate AND
greater than max_rate, so the condition was always false and the
intended fallback branch was dead code.

A stale or compromised oracle could push the rate to zero (free
loans) or to an extreme value without being caught.

Changed && to || so the check correctly triggers when the oracle
rate is below the minimum OR above the maximum band.

Fixes LabsCrypt#631.

File: contracts/loan_manager/src/lib.rs
Function: compute_interest_rate
@barry01-hash

Copy link
Copy Markdown
Author

Please merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant