allowance
and balanceOf
in OrderBook::buyOrder()
functionThe OrderBook
contract is designed as a peer-to-peer trading system where sellers lock ERC20 tokens (such as wETH, wBTC, or wSOL) and list them at a desired USDC price. Buyers are expected to fill these orders by paying USDC.
The protocol documentation claims that:
While this is technically true, in practice the buyer must first grant sufficient USDC allowance to the OrderBook
contract before calling buyOrder()
. The current implementation does not validate whether the buyer has approved the necessary USDC amount or has enough balance.
As a result, any buyer who attempts to fill an order without setting the allowance beforehand will experience a hard revert from the USDC token contract — typically with an message such as "ERC20: insufficient allowance"
. This leads to failed trades and broken UX, despite the documentation suggesting a straightforward interaction.
Likelihood:
Buyers will commonly attempt to fill an order without first approving USDC, especially if interacting via Etherscan or a minimal frontend.
The documentation implies a one-step on-chain interaction, encouraging users to call buyOrder() directly without realizing an approve() is required.
Impact:
Transactions will revert due to insufficient allowance or balance without any clear custom error from the protocol contract, leading to confusion and poor UX.
This breaks the core trading flow promised by the protocol, and makes it unusable for most first-time users unless a frontend explicitly manages allowance logic.
Adding checks for allowance and balanceOf buyer and revert with custom error
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.