Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: early return dutch decay if none #241

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a little strange that the decay times are not validated if startAmount==endAmount

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about putting this check after the time based ones?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

part of the point of this issue is that the time-based ones are irrelevant if startamount == endamount, which is always true for one of inputs or outputs. timings will be validated for whichever one is decaying

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
Loading