Kind Golden Otter
High
Launch::updateParticipation
contains two issues where token amounts and currency amounts are incorrectly compared. These issues arise due to mismatched units (tokens
vs. currency
) in the validation logic, leading to flawed checks for minimum and maximum token allocation thresholds. This can result in users either bypassing or being incorrectly restricted by the allocation limits.
The root cause is the improper comparison of values denominated in different units (tokens
and currency
). Specifically:
- Minimum Token Allocation Check: The function compares
userTokenAmount - refundCurrencyAmount
(whereuserTokenAmount
is in tokens andrefundCurrencyAmount
is in currency) againstsettings.minTokenAmountPerUser
(in tokens).
- Maximum Token Allocation Check: The function compares
userTokenAmount + additionalCurrencyAmount
(whereuserTokenAmount
is in tokens andadditionalCurrencyAmount
is in currency) againstsettings.maxTokenAmountPerUser
(in tokens).
These comparisons are invalid because they mix units, leading to incorrect validation logic.
- A user have an existing participation he want to update
- Signer sign a valid update request
none
-
Flawed Minimum Allocation Check:
- Users may bypass the minimum token allocation requirement, allowing them to participate with fewer tokens than intended.
- Users may be incorrectly prevented from adjusting their participation even if they meet the minimum token threshold.
-
Flawed Maximum Allocation Check:
- Users may be improperly restricted from increasing their participation, even if they are within the correct token limits.
- The function may fail to enforce the maximum token allocation, allowing users to exceed the allowed limit.
No response
To resolve these issues, ensure that all comparisons are performed in the correct unit (tokens):
-
Fix for Minimum Token Allocation Check: Replace the incorrect comparison with:
if (request.tokenAmount < settings.minTokenAmountPerUser) { revert MinUserTokenAllocationNotReached( request.launchGroupId, request.userId, userTokenAmount, request.tokenAmount ); }
-
Fix for Maximum Token Allocation Check: Replace the incorrect comparison with:
uint256 totalTokenAmount = request.tokenAmount; if (totalTokenAmount > settings.maxTokenAmountPerUser) { revert MaxUserTokenAllocationReached( request.launchGroupId, request.userId, userTokenAmount, request.tokenAmount ); }