-
Notifications
You must be signed in to change notification settings - Fork 0
oxcm - [H] Newly created positions can claim old claimable #113
Comments
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). Compared to the available APYs on Alchemix (2-5% max), the discrepancy between early depositors and late depositors is effectively near zero and negligible. |
dup #114. |
Escalate for 10 USDC |
You've created a valid escalation for 10 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Escalation accepted Considering this issue as a duplicate of #44 |
This issue's escalations have been accepted! Contestants' payouts and scores will be updated according to the changes made on this issue. |
oxcm
high
[H] Newly created positions can claim old claimable
Summary
Newly created positions have a default value of
0
foramount_claimed
, lead to an immediate value in_claimable_for_token()
, that should be0
.Vulnerability Detail
The
_claimable_for_token()
function is responsible for calculating the pending WETH for a given token_id.When a new position is created, its
amount_claimed
default value is0
, If theamount_claimable_per_share
has a value, then the_claimable_for_token
function of the new position will immediately have a value.This is because the calculation of
_claimable_for_token
is based ontotal_claimable_for_position
-position.amount_claimed
, wheretotal_claimable_for_position
is derived from the multiplication of theshares_owned
of the position and the currentamount_claimable_per_share
. As theshares_owned
of the new position are not zero, the_claimable_for_token
will have a value immediately.Impact
if a new position owner claims this amount, the protocol will not have enough funds to pay the original investors' rewards, and some claim transactions will fail due to insufficient funds.
Code Snippet
https://github.com/sherlock-audit/2023-02-fair-funding/blob/main/fair-funding/contracts/Vault.vy#L428-L440
https://github.com/sherlock-audit/2023-02-fair-funding/blob/main/fair-funding/contracts/Vault.vy#L198-L232
Tool used
Manual Review / ChatGPT PLUS
Recommendation
One possible solution is to add a new storage variable
last_amount_claimable_per_share
in the Position.Then, in the
register_deposit
function, check ifposition.last_amount_claimable_per_share
is0
. If so, setposition.last_amount_claimable_per_share
toself.amount_claimable_per_share
.Finally, modify the
_claimable_for_token
function.The modified code snippets for these changes are as follows:
Duplicate of #44
The text was updated successfully, but these errors were encountered: