diff --git a/src/AdvancedOrderEngine.sol b/src/AdvancedOrderEngine.sol index 33dcf3e..bc433a7 100644 --- a/src/AdvancedOrderEngine.sol +++ b/src/AdvancedOrderEngine.sol @@ -46,6 +46,32 @@ contract AdvancedOrderEngine { revert ZeroFacilitatorTargetAddress(); // TBD: use generic error message i.e. ZeroAddress() } + for (uint256 i; i < orders.length; ) { + OrderEngine.Order calldata order = orders[i]; + + bytes32 orderHash; + + if (block.timestamp > order.validTill) { + revert OrderExpired(orderHash); + } + + if (order.buyTokenAmount == 0 || order.sellTokenAmount == 0) { + revert ZeroTokenAmounts(); + } + + if ( + order.maker == address(0) || + order.buyToken == address(0) || + order.sellToken == address(0) + ) { + revert ZeroAddress(); + } + + unchecked { + ++i; + } + } + // Loop start // Perform order specific sanity checks // Verify signatjures diff --git a/src/AdvancedOrderEngineErrors.sol b/src/AdvancedOrderEngineErrors.sol index 8270062..c02a532 100644 --- a/src/AdvancedOrderEngineErrors.sol +++ b/src/AdvancedOrderEngineErrors.sol @@ -4,3 +4,6 @@ pragma solidity 0.8.21; error ArraysLengthMismatch(uint256 ordersArrLen, uint256 clearingPricesArrLen); error ZeroFacilitatorTargetAddress(); error EmptyOrdersArray(); +error OrderExpired(bytes32 orderHash); +error ZeroTokenAmounts(); +error ZeroAddress();