You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interest rate is not updated correct after debt repayment, it can cause higher borrowing rate
Summary
In BorrowLogic.sol the interest rate is updated. Due to wrong execution sequence, totalDebt is forwarded through interest rate strategy with wrong number.
Root Cause
The root cause of this problem is wrong sequence diagram. Repaid amount is determined just after the repayDebt() call and we need this data for correct interest rate update.
In order to demonstrate the impact following scenario will be appropriate.
Alice has 100WETH debt.
Alice repaid her debt now totalDebt should be reduced but instead it will keep same.
Borrowing rate will be higher than expected because totalDebt will remain high.
Impact
High - Because of wrong execution sequence, interest rate is affected. Interest rate will affect borrowing index and this is crucial for correct execution and calculation. In the conclusion, it will affect the reserve index.
Reserve indexes is also important, because they are used to calculate the price of shares. Relation between assets and shares is given in following equation:
$Shares * Index = Assets$
If an user repay his debt, the next user have to pay higher than expected because borrow index will be higher than expected.
Mitigation
It should update the interest rate just after determining the nextDebtShares variable
sherlock-admin3
changed the title
Special Macaroon Shetland - Interest rate is not updated correct after debt repayment, it can cause higher borrowing rate
TessKimy - Interest rate is not updated correct after debt repayment, it can cause higher borrowing rate
Oct 3, 2024
TessKimy
Medium
Interest rate is not updated correct after debt repayment, it can cause higher borrowing rate
Summary
In BorrowLogic.sol the interest rate is updated. Due to wrong execution sequence,
totalDebt
is forwarded through interest rate strategy with wrong number.Root Cause
The root cause of this problem is wrong sequence diagram. Repaid amount is determined just after the
repayDebt()
call and we need this data for correct interest rate update.cache.nextDebtShares
should be updated before updating the interest rate because it's used in interest rate calculation process.Internal pre-conditions
N/A
External pre-conditions
N/A
Attack Path
In order to demonstrate the impact following scenario will be appropriate.
totalDebt
should be reduced but instead it will keep same.totalDebt
will remain high.Impact
High - Because of wrong execution sequence, interest rate is affected. Interest rate will affect borrowing index and this is crucial for correct execution and calculation. In the conclusion, it will affect the reserve index.
Reserve indexes is also important, because they are used to calculate the price of shares. Relation between assets and shares is given in following equation:
If an user repay his debt, the next user have to pay higher than expected because borrow index will be higher than expected.
Mitigation
It should update the interest rate just after determining the
nextDebtShares
variableDuplicate of #413
The text was updated successfully, but these errors were encountered: