Owner unable to collect fulfillment fee from certain users due to revert error
Summary
Certain users might not be able to call the claimOrder function under certain conditions, resulting in the owner being unable to collect fulfillment fees from the users.
The rounding down to zero is unavoidable in this scenario due to how values are represented. It is not possible to send Alice 0.9 WEI of USDC. The smallest possible amount is 1 WEI.
In this case, it will attempt to transfer a zero amount of tokenOut, which might result in a revert as some tokens disallow the transfer of zero value. As a result, when users call the claimOrder function, it will revert, and the owner will not be able to collect the fulfillment fee from the users.
723: // Transfer tokens owed to user.
724: tokenOut.safeTransfer(user, owed);
Impact
When a user cannot call the claimOrder function due to the revert error, the owner will not be able to collect the fulfillment fee from the user, resulting in a loss of fee for the owner.
xiaoming90
medium
Owner unable to collect fulfillment fee from certain users due to revert error
Summary
Certain users might not be able to call the
claimOrder
function under certain conditions, resulting in the owner being unable to collect fulfillment fees from the users.Vulnerability Detail
https://github.com/sherlock-audit/2023-06-gfx/blob/main/uniswap-v3-limit-orders/src/LimitOrderRegistry.sol#L721
Assume the following:
totalTokenOut
)The following formula and code compute the number of swapped/claimed USDC tokens a user is entitled to.
Based on the above assumptions and computation, Alice will receive zero tokens in return due to a rounding error in Solidity.
The issue will be aggravated under the following conditions:
token0
andtoken1
in the pool is larger$0.95 ~ $1.05
)Note: Some tokens have a low decimal of 2 (e.g., Gemini USD), while others have a high decimal of 24 (e.g.,
YAM-V2
has 24). Refer to https://github.com/d-xo/weird-erc20#low-decimalsThe rounding down to zero is unavoidable in this scenario due to how values are represented. It is not possible to send Alice 0.9 WEI of USDC. The smallest possible amount is 1 WEI.
In this case, it will attempt to transfer a zero amount of
tokenOut,
which might result in a revert as some tokens disallow the transfer of zero value. As a result, when users call theclaimOrder
function, it will revert, and the owner will not be able to collect the fulfillment fee from the users.https://github.com/sherlock-audit/2023-06-gfx/blob/main/uniswap-v3-limit-orders/src/LimitOrderRegistry.sol#L724
Impact
When a user cannot call the
claimOrder
function due to the revert error, the owner will not be able to collect the fulfillment fee from the user, resulting in a loss of fee for the owner.Code Snippet
https://github.com/sherlock-audit/2023-06-gfx/blob/main/uniswap-v3-limit-orders/src/LimitOrderRegistry.sol#L724
Tool used
Manual Review
Recommendation
Consider only transferring the assets if the amount is more than zero.