Skip to content

Commit

Permalink
fix: remove redundant code
Browse files Browse the repository at this point in the history
- Order expiration is handled by permit2
- Dutch decay validation happens in dutchdecaylib

Fixes: L-07
  • Loading branch information
marktoda committed Aug 22, 2023
1 parent 0d81086 commit 36a0a28
Show file tree
Hide file tree
Showing 45 changed files with 46 additions and 68 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
181978
150708
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
196879
196805
Original file line number Diff line number Diff line change
@@ -1 +1 @@
206650
206576
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260307
260233
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190411
190337
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148194
148157
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133756
133719
Original file line number Diff line number Diff line change
@@ -1 +1 @@
137605
157468
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150633
182105
Original file line number Diff line number Diff line change
@@ -1 +1 @@
197283
197121
Original file line number Diff line number Diff line change
@@ -1 +1 @@
207049
206887
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260720
260558
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190809
190647
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148401
148320
Original file line number Diff line number Diff line change
@@ -1 +1 @@
95568
133887
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157716
157635
Original file line number Diff line number Diff line change
@@ -1 +1 @@
178116
146845
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-LimitOrderReactor-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
189056
188982
Original file line number Diff line number Diff line change
@@ -1 +1 @@
197889
197815
Original file line number Diff line number Diff line change
@@ -1 +1 @@
250617
250543
Original file line number Diff line number Diff line change
@@ -1 +1 @@
182582
182508
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-LimitOrderReactor-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144333
144296
Original file line number Diff line number Diff line change
@@ -1 +1 @@
129895
129858
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133743
153606
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroSingleOrder.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
136213
136176
Original file line number Diff line number Diff line change
@@ -1 +1 @@
175064
175027
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTestEth1Output.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
147390
147353
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTestEth2Outputs.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170604
170530
Original file line number Diff line number Diff line change
@@ -1 +1 @@
435187
435076
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTwoOrders.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
255972
255898
Original file line number Diff line number Diff line change
@@ -1 +1 @@
363478
363367
2 changes: 1 addition & 1 deletion .forge-snapshots/EthOutputTestEthOutput.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156223
156186
Original file line number Diff line number Diff line change
@@ -1 +1 @@
176915
176834
Original file line number Diff line number Diff line change
@@ -1 +1 @@
162907
162826
Original file line number Diff line number Diff line change
@@ -1 +1 @@
166046
165965
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146873
146792
2 changes: 1 addition & 1 deletion .forge-snapshots/ProtocolFeesGasComparisonTest-NoFees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
149267
149186
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124929
124848
2 changes: 1 addition & 1 deletion .forge-snapshots/SwapRouter02ExecutorExecute.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
262973
262936
Original file line number Diff line number Diff line change
@@ -1 +1 @@
118092
118055
2 changes: 1 addition & 1 deletion .forge-snapshots/testExclusiveFillerSucceeds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174066
174029
7 changes: 0 additions & 7 deletions src/lib/ResolvedOrderLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ library ResolvedOrderLib {
/// @notice thrown when the order targets a different reactor
error InvalidReactor();

/// @notice thrown if the order has expired
error DeadlinePassed();

/// @notice Validates a resolved order, reverting if invalid
/// @param filler The filler of the order
function validate(ResolvedOrder memory resolvedOrder, address filler) internal view {
if (address(this) != address(resolvedOrder.info.reactor)) {
revert InvalidReactor();
}

if (block.timestamp > resolvedOrder.info.deadline) {
revert DeadlinePassed();
}

if (address(resolvedOrder.info.additionalValidationContract) != address(0)) {
resolvedOrder.info.additionalValidationContract.validate(filler, resolvedOrder);
}
Expand Down
7 changes: 0 additions & 7 deletions src/reactors/ExclusiveDutchOrderReactor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ contract ExclusiveDutchOrderReactor is BaseReactor {
/// @notice thrown when an order's deadline is before its end time
error DeadlineBeforeEndTime();

/// @notice thrown when an order's end time is before its start time
error OrderEndTimeBeforeStartTime();

/// @notice thrown when an order's inputs and outputs both decay
error InputAndOutputDecay();

Expand Down Expand Up @@ -71,10 +68,6 @@ contract ExclusiveDutchOrderReactor is BaseReactor {
revert DeadlineBeforeEndTime();
}

if (order.decayEndTime < order.decayStartTime) {
revert OrderEndTimeBeforeStartTime();
}

if (order.input.startAmount != order.input.endAmount) {
unchecked {
for (uint256 i = 0; i < order.outputs.length; i++) {
Expand Down
9 changes: 5 additions & 4 deletions test/lib/OrderQuoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ contract OrderQuoterTest is Test, PermitSignature, ReactorEvents, DeployPermit2
uint256 constant ONE = 10 ** 18;
address constant PROTOCOL_FEE_OWNER = address(1);

error SignatureExpired(uint256 deadline);

OrderQuoter quoter;
MockERC20 tokenIn;
MockERC20 tokenOut;
Expand Down Expand Up @@ -128,15 +130,14 @@ contract OrderQuoterTest is Test, PermitSignature, ReactorEvents, DeployPermit2
uint256 timestamp = block.timestamp;
vm.warp(timestamp + 100);
tokenIn.forceApprove(swapper, address(permit2), ONE);
uint256 deadline = block.timestamp - 1;
LimitOrder memory order = LimitOrder({
info: OrderInfoBuilder.init(address(limitOrderReactor)).withSwapper(address(swapper)).withDeadline(
block.timestamp - 1
),
info: OrderInfoBuilder.init(address(limitOrderReactor)).withSwapper(address(swapper)).withDeadline(deadline),
input: InputToken(tokenIn, ONE, ONE),
outputs: OutputsBuilder.single(address(tokenOut), ONE, address(swapper))
});
bytes memory sig = signOrder(swapperPrivateKey, address(permit2), order);
vm.expectRevert(ResolvedOrderLib.DeadlinePassed.selector);
vm.expectRevert(abi.encodeWithSelector(SignatureExpired.selector, deadline));
quoter.quote(abi.encode(order), sig);
}

Expand Down
9 changes: 0 additions & 9 deletions test/lib/ResolvedOrderLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ contract ResolvedOrderLibTest is Test {
resolvedOrderLib.validate(mockResolvedOrder, address(0));
}

function testDeadlinePassed() public {
uint256 timestamp = block.timestamp;
vm.warp(timestamp + 100);
mockResolvedOrder.info = OrderInfoBuilder.init(address(resolvedOrderLib)).withDeadline(block.timestamp - 1);

vm.expectRevert(ResolvedOrderLib.DeadlinePassed.selector);
resolvedOrderLib.validate(mockResolvedOrder, address(0));
}

function testValid() public {
mockResolvedOrder.info = OrderInfoBuilder.init(address(resolvedOrderLib));
resolvedOrderLib.validate(mockResolvedOrder, address(0));
Expand Down

0 comments on commit 36a0a28

Please sign in to comment.