While Solidity 0.8.0 protects against direct uint256
overflows by reverting, extremely large amountToSell
or priceInUSDC
values can lead to two issues: 1) Products in calculations (like priceInUSDC * FEE
) potentially exceeding uint256
maximum, causing reverts; 2) Transactions involving massive numbers of tokens or values hitting Ethereum's block gas limit. This can make such orders uncreatable or unfillable.
Root Cause:
uint256
Maximum: Even though vast, uint256
has a limit. Multiplications with large inputs can still exceed it.
EVM Gas Limit: Operations on very large numbers or transfers of extreme quantities can consume excessive gas, causing transactions to fail.
Solidity
Likelihood: Medium. While uint256
overflow is rare with typical values, hitting gas limits with extremely large real-world token amounts is more plausible.
Impact: Low to Medium.
Transaction Reversion: Orders involving values exceeding practical limits simply fail.
Loss of Functionality: Extremely high-value transactions might be impossible to execute.
Not a Direct Fund Loss: Funds are not stolen; transactions merely revert.
While direct uint256
overflows are theoretical for common values, consider the gas impact: A safeTransferFrom
of an absurdly large token amount (e.g., 10^70
tokens) might hit the block gas limit, causing the createSellOrder
or buyOrder
transaction to revert, even if the numbers fit uint256
.
Implement practical upper limits for amountToSell
and priceInUSDC
in createSellOrder
and amendSellOrder
. These limits should be well below type(uint256).max
to ensure arithmetic operations remain safe and transactions stay within gas limits.
Diff
Choose MAX_ORDER_AMOUNT
and MAX_ORDER_PRICE
based on realistic token values and market expectations.
Reference Files:
src/OrderBook.sol
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.