OrderBook::createSellOrder()
functionUnder normal behavior, the createSellOrder
function allows a user (seller) to list a token for sale by specifying the token address, amount, price in USDC, and deadline. The contract performs validations on token address, amount, price, and deadline duration.
However, the function does not check the seller's balance or allowance for the _tokenToSell before calling safeTransferFrom(). This causes the transaction to revert if the seller has not approved the token or has insufficient balance — without giving a clear explanation to the user. In an on-chain only system with no frontend handling UX errors, this leads to poor user experience.
Additionally, the function violates the Checks-Effects-Interactions
(CEI) pattern by performing an external token transfer before updating protocol state.
Likelihood:
This will occur when the seller forgets to approve the token or doesn't have enough balance at the time of createSellOrder
call.
The function will revert due to ERC20 safeTransferFrom() failure, without any custom error message, leading to UX failure.
Impact:
Users will be unable to create sell orders directly on-chain unless they manually approve tokens.
Frustration for users due to unexplained transaction reverts.
Protocol may be perceived as broken or unreliable when used without frontend abstraction.
Additionally, move state changes (order registration) before external calls if reentrancy could become a concern in future token integrations.
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.