Skip to content

Commit

Permalink
feat: early return dutch decay if none
Browse files Browse the repository at this point in the history
If startAmount == endAmount, early return. This is always true for
either the inputs or outputs of an order, so saves the decay calculation
half the time
  • Loading branch information
marktoda committed Apr 18, 2024
1 parent 166db86 commit 45008f8
Show file tree
Hide file tree
Showing 46 changed files with 48 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
181594
181506
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
196531
196355
Original file line number Diff line number Diff line change
@@ -1 +1 @@
206231
206011
Original file line number Diff line number Diff line change
@@ -1 +1 @@
259817
259553
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190063
189887
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148015
147927
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133577
133489
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157326
157238
Original file line number Diff line number Diff line change
@@ -1 +1 @@
181758
181670
Original file line number Diff line number Diff line change
@@ -1 +1 @@
196837
196661
Original file line number Diff line number Diff line change
@@ -1 +1 @@
206532
206312
Original file line number Diff line number Diff line change
@@ -1 +1 @@
260132
259868
Original file line number Diff line number Diff line change
@@ -1 +1 @@
190363
190187
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148178
148090
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133745
133657
Original file line number Diff line number Diff line change
@@ -1 +1 @@
157493
157405
Original file line number Diff line number Diff line change
@@ -1 +1 @@
188652
188514
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V2DutchOrder-ExclusiveFiller.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158766
158695
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V2DutchOrder-ExecuteBatch.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
210728
210452
Original file line number Diff line number Diff line change
@@ -1 +1 @@
220997
220677
Original file line number Diff line number Diff line change
@@ -1 +1 @@
275168
274804
Original file line number Diff line number Diff line change
@@ -1 +1 @@
204254
203978
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V2DutchOrder-ExecuteSingle.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
155069
154931
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140631
140493
Original file line number Diff line number Diff line change
@@ -1 +1 @@
164380
164242
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V2DutchOrder-InputOverride.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
159055
158984
2 changes: 1 addition & 1 deletion .forge-snapshots/Base-V2DutchOrder-OutputOverride.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
158793
158722
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroSingleOrder.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
136170
136082
Original file line number Diff line number Diff line change
@@ -1 +1 @@
174742
174610
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTestEth1Output.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
147347
147259
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTestEth2Outputs.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170518
170342
Original file line number Diff line number Diff line change
@@ -1 +1 @@
434221
433825
2 changes: 1 addition & 1 deletion .forge-snapshots/DirectFillerFillMacroTwoOrders.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
255883
255663
Original file line number Diff line number Diff line change
@@ -1 +1 @@
362870
362562
2 changes: 1 addition & 1 deletion .forge-snapshots/EthOutputTestEthOutput.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156044
155866
Original file line number Diff line number Diff line change
@@ -1 +1 @@
176277
176145
Original file line number Diff line number Diff line change
@@ -1 +1 @@
162269
162137
Original file line number Diff line number Diff line change
@@ -1 +1 @@
165610
165478
Original file line number Diff line number Diff line change
@@ -1 +1 @@
146437
146305
2 changes: 1 addition & 1 deletion .forge-snapshots/ProtocolFeesGasComparisonTest-NoFees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
148973
148885
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124635
124547
2 changes: 1 addition & 1 deletion .forge-snapshots/SwapRouter02ExecutorExecute.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
262869
262691
Original file line number Diff line number Diff line change
@@ -1 +1 @@
117988
117810
2 changes: 1 addition & 1 deletion .forge-snapshots/testExclusiveFillerSucceeds.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
173887
173799
4 changes: 3 additions & 1 deletion src/lib/DutchDecayLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ library DutchDecayLib {
view
returns (uint256 decayedAmount)
{
if (decayEndTime <= decayStartTime) {
if (startAmount == endAmount) {
return startAmount;
} else if (decayEndTime <= decayStartTime) {
revert EndTimeBeforeStartTime();
} else if (decayEndTime <= block.timestamp) {
decayedAmount = endAmount;
Expand Down
1 change: 1 addition & 0 deletions test/lib/DutchDecayLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ contract DutchDecayLibTest is Test {
uint256 decayStartTime,
uint256 decayEndTime
) public {
vm.assume(startAmount != endAmount);
vm.assume(decayEndTime < decayStartTime);
vm.expectRevert(DutchDecayLib.EndTimeBeforeStartTime.selector);
DutchDecayLib.decay(startAmount, endAmount, decayStartTime, decayEndTime);
Expand Down

0 comments on commit 45008f8

Please sign in to comment.