-
Notifications
You must be signed in to change notification settings - Fork 0
oxcm - [H] Not update amount_claimed
when deposit to existing positions lead to claimable_for_token
incorrect increased
#114
Comments
We will remove the option to deposit multiple times for the same position/token. |
It mitigates the primary issue described here, but I think the bigger issue is raised in #113, where a depositor have immediate claims because of
|
Conceptually the auction phase of a Fair Funding campaign will be limited and rather short (for example first Fair Funding campaign will run 16 days / 16 auctions). |
Amount of yield accumulated and recorded in |
Agree with the Sponsor comment. |
oxcm
high
[H] Not update
amount_claimed
when deposit to existing positions lead toclaimable_for_token
incorrect increasedSummary
the
amount_claimed
variable in a position is not properly updated when an existing position is deposit with additional funds. This can lead to incorrect calculation of_claimable_for_token
for the affected position.Vulnerability Detail
When an existing position is deposit, the corresponding
shares_owned
value in the Position is correctly increased, but theamount_claimed
value is not updated to reflect the additional funds.This means that the calculation in the
_claimable_for_token
function will be incorrect, as it is based on theshares_owned
multiplied by theamount_claimable_per_share
, minus theamount_claimed
. Since theamount_claimed
value remains the same after deposit, the calculated_claimable_for_token
value will be higher than it should be.Impact
This vulnerability could result in an incorrect increase in the
_claimable_for_token
value for existing positions that are topped up. it could lead to insufficient funds being available to cover claims, which could result in failed transactions for some token holders.Code Snippet
https://github.com/sherlock-audit/2023-02-fair-funding/blob/main/fair-funding/contracts/Vault.vy#L427-L441
Tool used
Manual Review / ChatGPT PLUS
Recommendation
updating the
amount_claimed
value in the Position when existing positions are deposit, to ensure that the calculated_claimable_for_token
value is correct.This can be done by adjusting the
amount_claimed
value by the same proportion as the increase in theshares_owned
value, so that the calculated_claimable_for_token
value remains consistent.Or add a new storage variable
last_amount_claimable_per_share
in the Position, and addclaim
before addshares_issued
toposition.shares_owned
when deposit to existing position. seeRecommendation
in other issue.The text was updated successfully, but these errors were encountered: