The protocol does not handle or normalize token decimals for ERC20 tokens in the createSellOrder()
function. It assumes that all tokens use 18 decimals, which leads to incorrect transfer values when dealing with tokens like WBTC (8 decimals) or USDC (6 decimals).
This can result in failed transfers, unintentionally small or large orders, and ultimately prevents users from interacting with the protocol using common tokens.
The function accepts an _amountToSell
parameter and directly calls:
This assumes that the user-provided _amountToSell
is already in the raw format of the token’s actual decimals. However, tokens like:
WBTC (8 decimals)
USDC (6 decimals)
WETH (18 decimals)
...have different levels of precision. If a user mistakenly provides 1e18
for a token like WBTC (which only supports 1e8
units for 1 WBTC), the transfer will revert due to insufficient balance even if the user owns 1 WBTC.
Likelihood: High
Any user interacting with this function using non-18-decimal tokens (e.g., WBTC, USDC) is very likely to encounter a revert or logic error.
Impact: Medium
Users will be unable to create orders using tokens with decimals other than 18, effectively locking them out of the protocol.
This could lead to a denial of service for legitimate users and protocols using common assets like WBTC
Can lead to logic bugs if some tokens are overcharged/undervalued silently in future price calculations or fills.
When processing token transfers (e.g., during order creation), scale the user-provided amount, assumed to be in 18-decimal format down to the token’s native decimal format using this mapping. This ensures accurate token transfers and prevents issues when interacting with non-standard tokens like WBTC (8 decimals)
Ensure the frontend always passes _amountToSell
and _priceInUSDC
in 18-decimal fixed-point format Introduce a tokenDecimals
mapping that stores the decimal precision of each supported token.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.