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
{{ message }}
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
sherlock-admin opened this issue
Jul 5, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
_update_debt implementation error, can not realize the interest calculation, interest is always zero.
Vulnerability Detail
@internaldef _update_debt(_debt_token: address):
""" @notice Accounts for any accrued interest since the last update. """ifblock.timestamp==self.last_debt_update[_debt_token]:
return# already up to date, nothing to doself.last_debt_update[_debt_token] =block.timestampifself.total_debt_amount[_debt_token] ==0:
return# no debt, no interestself.total_debt_amount[_debt_token] +=self._debt_interest_since_last_update(
_debt_token
)
@internal@viewdef _debt_interest_since_last_update(_debt_token: address) ->uint256:
return (
(block.timestamp-self.last_debt_update[_debt_token])
*self._current_interest_per_second(_debt_token)
*self.total_debt_amount[_debt_token]
/ PERCENTAGE_BASE
/ PRECISION
)
_update_debt will set self.last_debt_update[_debt_token] = block.timestamp, so _debt_interest_since_last_update always return 0
Impact
Unable to achieve interest calculation, users can borrow interest-free, affecting the protocol and staking users income.
This will also affect the internal accounting system, because amount_per_debt_share / debt_shares_to_amount all contain correctly calculated interest, which will lead to bookkeeping confusion.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
kutugu
high
The vault interest was miscalculated
Summary
_update_debt
implementation error, can not realize the interest calculation, interest is always zero.Vulnerability Detail
_update_debt
will setself.last_debt_update[_debt_token] = block.timestamp
, so_debt_interest_since_last_update
always return0
Impact
Unable to achieve interest calculation, users can borrow interest-free, affecting the protocol and staking users income.
This will also affect the internal accounting system, because
amount_per_debt_share
/debt_shares_to_amount
all contain correctly calculated interest, which will lead to bookkeeping confusion.Code Snippet
Tool used
Manual Review
Recommendation
Calculate the interest first, and then update 'self.last_debt_update[_debt_token] = block.timestamp'
Duplicate of #167
The text was updated successfully, but these errors were encountered: