Skip to content

Commit

Permalink
forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
codyborn committed Oct 17, 2024
1 parent 847737b commit caec474
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 37 deletions.
8 changes: 5 additions & 3 deletions src/lib/NonlinearDutchDecayLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ library NonlinearDutchDecayLib {
view
returns (OutputToken memory result)
{
uint256 decayedOutput =
decay(output.curve, output.startAmount, decayStartBlock, output.minAmount, type(uint256).max, v3LinearOutputDecay);
uint256 decayedOutput = decay(
output.curve, output.startAmount, decayStartBlock, output.minAmount, type(uint256).max, v3LinearOutputDecay
);
result = OutputToken(output.token, decayedOutput, output.recipient);
}

Expand Down Expand Up @@ -134,7 +135,8 @@ library NonlinearDutchDecayLib {
view
returns (InputToken memory result)
{
uint256 decayedInput = decay(input.curve, input.startAmount, decayStartBlock, 0, input.maxAmount, v3LinearInputDecay);
uint256 decayedInput =
decay(input.curve, input.startAmount, decayStartBlock, 0, input.maxAmount, v3LinearInputDecay);
result = InputToken(input.token, decayedInput, input.maxAmount);
}

Expand Down
43 changes: 9 additions & 34 deletions test/lib/NonLinearDutchDecayLib.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,9 @@ contract NonlinearDutchDecayLibTest is Test, GasSnapshot {
NonlinearDutchDecay memory curve,
uint256 startAmount,
uint256 decayStartBlock,
uint256 maxAmount) internal view returns (uint256 decayedAmount) {

V3DutchInput memory input = V3DutchInput(
tokenIn,
startAmount,
curve,
maxAmount,
0
);
uint256 maxAmount
) internal view returns (uint256 decayedAmount) {
V3DutchInput memory input = V3DutchInput(tokenIn, startAmount, curve, maxAmount, 0);
return NonlinearDutchDecayLib.decay(input, decayStartBlock).amount;
}

Expand All @@ -68,14 +62,7 @@ contract NonlinearDutchDecayLibTest is Test, GasSnapshot {
uint256 decayStartBlock,
uint256 minAmount
) internal view returns (uint256 decayedAmount) {
V3DutchOutput memory output = V3DutchOutput(
address(tokenOut),
startAmount,
curve,
address(0),
minAmount,
0
);
V3DutchOutput memory output = V3DutchOutput(address(tokenOut), startAmount, curve, address(0), minAmount, 0);
return NonlinearDutchDecayLib.decay(output, decayStartBlock).amount;
}

Expand Down Expand Up @@ -160,19 +147,11 @@ contract NonlinearDutchDecayLibTest is Test, GasSnapshot {
function testDutchDecayNoDecay(uint256 startAmount, uint256 decayStartBlock) public {
// Empty curve
snapStart("V3-DutchDecayNoDecay");
assertEq(
decayOutput(
CurveBuilder.emptyCurve(), startAmount, decayStartBlock, startAmount
),
startAmount
);
assertEq(decayOutput(CurveBuilder.emptyCurve(), startAmount, decayStartBlock, startAmount), startAmount);

// Single value with 0 amount change
assertEq(
decayOutput(
CurveBuilder.singlePointCurve(1, 0), startAmount, decayStartBlock, startAmount
),
startAmount
decayOutput(CurveBuilder.singlePointCurve(1, 0), startAmount, decayStartBlock, startAmount), startAmount
);
snapEnd();
}
Expand All @@ -185,15 +164,11 @@ contract NonlinearDutchDecayLibTest is Test, GasSnapshot {
snapStart("V3-DutchDecayNoDecayYet");
vm.roll(100);
// at decayStartBlock
assertEq(
decayOutput(curve, startAmount, decayStartBlock, startAmount), startAmount
);
assertEq(decayOutput(curve, startAmount, decayStartBlock, startAmount), startAmount);

vm.roll(80);
// before decayStartBlock
assertEq(
decayOutput(curve, startAmount, decayStartBlock, startAmount), startAmount
);
assertEq(decayOutput(curve, startAmount, decayStartBlock, startAmount), startAmount);
snapEnd();
}

Expand Down Expand Up @@ -685,4 +660,4 @@ contract NonlinearDutchDecayLibTest is Test, GasSnapshot {
"Should be fully decayed for block delta beyond uint16.max"
);
}
}
}

0 comments on commit caec474

Please sign in to comment.