Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trachev - Debt rates will be wrongly set when debt is repaid #225

Closed
sherlock-admin3 opened this issue Sep 10, 2024 · 0 comments
Closed
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A High severity issue. Reward A payout will be made for this issue

Comments

@sherlock-admin3
Copy link
Contributor

sherlock-admin3 commented Sep 10, 2024

trachev

Medium

Debt rates will be wrongly set when debt is repaid

Summary

In executeRepay interest rates are updated before the debt is repaid, causing the new debt rates to be calculated wrongly as vars.totalDebt will be set to a value prior to the repayment.

Root Cause

  • In executeRepay the interest rates are calculated before the debt is actually repaid and the previous value of totalSupplies.debtShares, prior to the repayment, is used when getting vars.totalDebt. vars.totalDebt is used when calculating what the debt rate should be when calling calculateInterestRates. Thus, as the total debt includes the debt that is removed/repaid, vars.totalDebt will be higher, causing the borrow rate to be higher than expected.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

No response

Impact

  • The borrow rate will be higher than expected after debt is repaid. This causes a loss of funds for borrowers and potential unexpected liquidations as borrowers will have to account for the higher borrow rate.

PoC

No response

Mitigation

The borrow rate should be updated after the debt is repaid, just as it is currently done in executeBorrow. In executeBorrow when updateInterestRates is called the new value of _cache.nextDebtShares is used.

Duplicate of #413

@github-actions github-actions bot added Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A High severity issue. labels Sep 20, 2024
@sherlock-admin3 sherlock-admin3 changed the title Curly Pineapple Armadillo - Debt rates will be wrongly set when debt is repaid trachev - Debt rates will be wrongly set when debt is repaid Oct 3, 2024
@sherlock-admin3 sherlock-admin3 added the Reward A payout will be made for this issue label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate A valid issue that is a duplicate of an issue with `Has Duplicates` label High A High severity issue. Reward A payout will be made for this issue
Projects
None yet
Development

No branches or pull requests

1 participant