From 081910a30bd2d2deb0ebcd0948c9b7a44a13a9c1 Mon Sep 17 00:00:00 2001 From: TokenTitan Date: Fri, 26 Jul 2024 17:14:41 +0530 Subject: [PATCH 1/4] refactor: renamed Worked example and Partial function to SelfCheckout and MevTimeCompute --- script/test/SelfCheckout.s.sol | 4 ++-- ...tionTest.t.sol => MEVTimeComputeTest.t.sol} | 8 ++++---- test/WorkedExample.t.sol | 13 ++++++------- test/examples/{ => DeFi}/SelfCheckout.sol | 6 +++--- ...FunctionContract.sol => MEVTimeCompute.sol} | 2 +- .../SelfCheckoutLib.sol} | 10 +++++----- .../MEVTimeComputeLib.sol} | 18 +++++++++--------- 7 files changed, 30 insertions(+), 31 deletions(-) rename test/{PartialFunctionTest.t.sol => MEVTimeComputeTest.t.sol} (84%) rename test/examples/{ => DeFi}/SelfCheckout.sol (95%) rename test/examples/MEVOracle/{PartialFunctionContract.sol => MEVTimeCompute.sol} (97%) rename test/solve-lib/{WorkedExample.sol => DeFi/SelfCheckoutLib.sol} (96%) rename test/solve-lib/{MEVOracle/PartialFunctionExample.sol => MEVTimeOracle/MEVTimeComputeLib.sol} (85%) diff --git a/script/test/SelfCheckout.s.sol b/script/test/SelfCheckout.s.sol index f8efffc..772e80e 100644 --- a/script/test/SelfCheckout.s.sol +++ b/script/test/SelfCheckout.s.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.19; import {Script} from "forge-std/Script.sol"; -import {BaseDeployer} from "../BaseDeployer.s.sol"; -import {SelfCheckout} from "test/examples/SelfCheckout.sol"; +import {BaseDeployer} from "script/BaseDeployer.s.sol"; +import {SelfCheckout} from "test/examples/DeFi/SelfCheckout.sol"; import {MyErc20} from "test/examples/MyErc20.sol"; /* solhint-disable no-console*/ diff --git a/test/PartialFunctionTest.t.sol b/test/MEVTimeComputeTest.t.sol similarity index 84% rename from test/PartialFunctionTest.t.sol rename to test/MEVTimeComputeTest.t.sol index b52374a..12c9cb6 100644 --- a/test/PartialFunctionTest.t.sol +++ b/test/MEVTimeComputeTest.t.sol @@ -4,10 +4,10 @@ pragma solidity 0.8.23; import "forge-std/Test.sol"; import "src/timetravel/CallBreaker.sol"; -import "test/examples/MEVOracle/PartialFunctionContract.sol"; -import "test/solve-lib/MEVOracle/PartialFunctionExample.sol"; +import "test/examples/MEVOracle/MEVTimeCompute.sol"; +import "test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol"; -contract PartialFunctionTest is Test, PartialFunctionExampleLib { +contract MEVTimeComputeTest is Test, MEVTimeComputeLib { address deployer; address pusher; address filler; @@ -31,7 +31,7 @@ contract PartialFunctionTest is Test, PartialFunctionExampleLib { vm.label(filler, "filler"); } - function testPartialFunction() external { + function testMEVTimeCompute() external { uint256 laminatorSequenceNumber; vm.startPrank(pusher); diff --git a/test/WorkedExample.t.sol b/test/WorkedExample.t.sol index 779258f..57f9a19 100644 --- a/test/WorkedExample.t.sol +++ b/test/WorkedExample.t.sol @@ -4,14 +4,13 @@ pragma solidity >=0.6.2 <0.9.0; import "forge-std/Test.sol"; import "forge-std/Vm.sol"; -import "./solve-lib/WorkedExample.sol"; +import "src/lamination/Laminator.sol"; +import "src/timetravel/CallBreaker.sol"; +import "test/examples/DeFi/SelfCheckout.sol"; +import "test/examples/MyErc20.sol"; +import "test/solve-lib/DeFi/SelfCheckoutLib.sol"; -import "../src/lamination/Laminator.sol"; -import "../src/timetravel/CallBreaker.sol"; -import "../test/examples/SelfCheckout.sol"; -import "../test/examples/MyErc20.sol"; - -contract WorkedExampleTest is Test, WorkedExampleLib { +contract WSelfCheckoutTest is Test, SelfCheckoutLib { address deployer; address pusher; address filler; diff --git a/test/examples/SelfCheckout.sol b/test/examples/DeFi/SelfCheckout.sol similarity index 95% rename from test/examples/SelfCheckout.sol rename to test/examples/DeFi/SelfCheckout.sol index 2d15ba0..9561aa5 100644 --- a/test/examples/SelfCheckout.sol +++ b/test/examples/DeFi/SelfCheckout.sol @@ -2,9 +2,9 @@ pragma solidity >=0.6.2 <0.9.0; import "openzeppelin/token/ERC20/IERC20.sol"; -import "../../src/TimeTypes.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../src/timetravel/SmarterContract.sol"; +import "src/TimeTypes.sol"; +import "src/timetravel/CallBreaker.sol"; +import "src/timetravel/SmarterContract.sol"; contract SelfCheckout is SmarterContract { address owner; diff --git a/test/examples/MEVOracle/PartialFunctionContract.sol b/test/examples/MEVOracle/MEVTimeCompute.sol similarity index 97% rename from test/examples/MEVOracle/PartialFunctionContract.sol rename to test/examples/MEVOracle/MEVTimeCompute.sol index 91a6e78..4626ed5 100644 --- a/test/examples/MEVOracle/PartialFunctionContract.sol +++ b/test/examples/MEVOracle/MEVTimeCompute.sol @@ -4,7 +4,7 @@ pragma solidity 0.8.23; import "src/timetravel/CallBreaker.sol"; import "src/timetravel/SmarterContract.sol"; -contract PartialFunctionContract is SmarterContract { +contract MEVTimeCompute is SmarterContract { address public callbreakerAddress; uint256 public initValue; diff --git a/test/solve-lib/WorkedExample.sol b/test/solve-lib/DeFi/SelfCheckoutLib.sol similarity index 96% rename from test/solve-lib/WorkedExample.sol rename to test/solve-lib/DeFi/SelfCheckoutLib.sol index 826ec47..d19d9d0 100644 --- a/test/solve-lib/WorkedExample.sol +++ b/test/solve-lib/DeFi/SelfCheckoutLib.sol @@ -3,12 +3,12 @@ pragma solidity >=0.6.2 <0.9.0; import "forge-std/Vm.sol"; -import "../../src/lamination/Laminator.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../test/examples/SelfCheckout.sol"; -import "../../test/examples/MyErc20.sol"; +import "src/lamination/Laminator.sol"; +import "src/timetravel/CallBreaker.sol"; +import "test/examples/DeFi/SelfCheckout.sol"; +import "test/examples/MyErc20.sol"; -contract WorkedExampleLib { +contract SelfCheckoutLib { CallBreaker public callbreaker; SelfCheckout public selfcheckout; address payable public pusherLaminated; diff --git a/test/solve-lib/MEVOracle/PartialFunctionExample.sol b/test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol similarity index 85% rename from test/solve-lib/MEVOracle/PartialFunctionExample.sol rename to test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol index ee9f70e..c95a1c7 100644 --- a/test/solve-lib/MEVOracle/PartialFunctionExample.sol +++ b/test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol @@ -4,11 +4,11 @@ pragma solidity 0.8.23; import "src/lamination/Laminator.sol"; import "src/timetravel/CallBreaker.sol"; import "src/timetravel/SmarterContract.sol"; -import "test/examples/MEVOracle/PartialFunctionContract.sol"; +import "test/examples/MEVOracle/MEVTimeCompute.sol"; -contract PartialFunctionExampleLib { +contract MEVTimeComputeLib { address payable public pusherLaminated; - PartialFunctionContract public partialFunctionContract; + MEVTimeCompute public mevTimeCompute; Laminator public laminator; CallBreaker public callbreaker; uint256 _tipWei = 33; @@ -19,8 +19,8 @@ contract PartialFunctionExampleLib { callbreaker = new CallBreaker(); laminator = new Laminator(address(callbreaker)); pusherLaminated = payable(laminator.computeProxyAddress(pusher)); - partialFunctionContract = new PartialFunctionContract(address(callbreaker), divisor); - partialFunctionContract.setInitValue(initValue); + mevTimeCompute = new MEVTimeCompute(address(callbreaker), divisor); + mevTimeCompute.setInitValue(initValue); } function userLand() public returns (uint256) { @@ -31,7 +31,7 @@ contract PartialFunctionExampleLib { CallObject[] memory pusherCallObjs = new CallObject[](2); pusherCallObjs[0] = CallObject({ amount: 0, - addr: address(partialFunctionContract), + addr: address(mevTimeCompute), gas: 1000000, callvalue: abi.encodeWithSignature("solve()") }); @@ -42,8 +42,8 @@ contract PartialFunctionExampleLib { } function solverLand(uint256 laminatorSequenceNumber, address filler) public { - uint256 value = partialFunctionContract.initValue(); - uint256 divisor = partialFunctionContract.divisor(); + uint256 value = mevTimeCompute.initValue(); + uint256 divisor = mevTimeCompute.divisor(); uint256 solution = divisor - (value % divisor); CallObject[] memory callObjs = new CallObject[](2); ReturnObject[] memory returnObjs = new ReturnObject[](2); @@ -57,7 +57,7 @@ contract PartialFunctionExampleLib { callObjs[1] = CallObject({ amount: 0, - addr: address(partialFunctionContract), + addr: address(mevTimeCompute), gas: 1000000, callvalue: abi.encodeWithSignature("verifySolution()") }); From b1a5bce32dca2652c7527130386eea706454341e Mon Sep 17 00:00:00 2001 From: TokenTitan Date: Mon, 29 Jul 2024 13:21:33 +0530 Subject: [PATCH 2/4] refactor: renamed cron two and removed incosistency in naming --- ...{CronTwoCounter.s.sol => CronCounter.s.sol} | 18 +++++++++--------- ...{CronTwoExample.t.sol => CronCounter.t.sol} | 6 +++--- ...iquidityTest.t.sol => FlashLiquidity.t.sol} | 4 ++-- test/{FlashPillTest.t.sol => FlashPill.t.sol} | 0 test/LimitOrder.t.sol | 4 ++-- ...eComputeTest.t.sol => MEVTimeCompute.t.sol} | 0 .../{NoopTurnerTest.t.sol => NoopTurner.t.sol} | 0 test/PnP.t.sol | 4 ++-- test/Sandwich.t.sol | 6 +++--- ...{WorkedExample.t.sol => SelfCheckout.t.sol} | 4 ++-- .../{CronTwoCounter.sol => CronCounter.sol} | 2 +- .../{CronTwo.sol => CronCounterLib.sol} | 8 ++++---- ...uidityExample.sol => FlashLiquidityLib.sol} | 2 +- .../{FlashPillExample.sol => FlashPillLib.sol} | 12 +++++------- ...LimitOrderExample.sol => LimitOrderLib.sol} | 11 +++++------ test/solve-lib/{PnPExample.sol => PnPLib.sol} | 2 +- 16 files changed, 40 insertions(+), 43 deletions(-) rename script/test/{CronTwoCounter.s.sol => CronCounter.s.sol} (66%) rename test/{CronTwoExample.t.sol => CronCounter.t.sol} (93%) rename test/{FlashLiquidityTest.t.sol => FlashLiquidity.t.sol} (93%) rename test/{FlashPillTest.t.sol => FlashPill.t.sol} (100%) rename test/{MEVTimeComputeTest.t.sol => MEVTimeCompute.t.sol} (100%) rename test/{NoopTurnerTest.t.sol => NoopTurner.t.sol} (100%) rename test/{WorkedExample.t.sol => SelfCheckout.t.sol} (94%) rename test/examples/{CronTwoCounter.sol => CronCounter.sol} (92%) rename test/solve-lib/{CronTwo.sol => CronCounterLib.sol} (96%) rename test/solve-lib/{FlashLiquidityExample.sol => FlashLiquidityLib.sol} (99%) rename test/solve-lib/{FlashPillExample.sol => FlashPillLib.sol} (91%) rename test/solve-lib/{LimitOrderExample.sol => LimitOrderLib.sol} (94%) rename test/solve-lib/{PnPExample.sol => PnPLib.sol} (99%) diff --git a/script/test/CronTwoCounter.s.sol b/script/test/CronCounter.s.sol similarity index 66% rename from script/test/CronTwoCounter.s.sol rename to script/test/CronCounter.s.sol index 5e07664..5bb2fe7 100644 --- a/script/test/CronTwoCounter.s.sol +++ b/script/test/CronCounter.s.sol @@ -4,22 +4,22 @@ pragma solidity ^0.8.19; import {Script} from "forge-std/Script.sol"; import {BaseDeployer} from "../BaseDeployer.s.sol"; -import {CronTwoCounter} from "test/examples/CronTwoCounter.sol"; +import {CronCounter} from "test/examples/CronCounter.sol"; import {MyErc20} from "test/examples/MyErc20.sol"; /* solhint-disable no-console*/ import {console2} from "forge-std/console2.sol"; -contract DeployCronTwoCounter is Script, BaseDeployer { +contract DeployCronCounter is Script, BaseDeployer { address private _callBreaker; /// @dev Compute the CREATE2 addresses for contracts (proxy, counter). - /// @param salt The salt for the CronTwoCounter contract. + /// @param salt The salt for the CronCounter contract. modifier computeCreate2(bytes32 salt) { _callBreaker = vm.envAddress("CALL_BREAKER_ADDRESS"); _create2addr = - computeCreate2Address(salt, hashInitCode(type(CronTwoCounter).creationCode, abi.encode(_callBreaker))); + computeCreate2Address(salt, hashInitCode(type(CronCounter).creationCode, abi.encode(_callBreaker))); _; } @@ -33,10 +33,10 @@ contract DeployCronTwoCounter is Script, BaseDeployer { computeCreate2(_salt) returns (address) { - console2.log("CronTwoCounter create2 address:", _create2addr, "\n"); + console2.log("CronCounter create2 address:", _create2addr, "\n"); for (uint256 i; i < deployForks.length;) { - console2.log("Deploying CronTwoCounter to chain: ", uint256(deployForks[i]), "\n"); + console2.log("Deploying CronCounter to chain: ", uint256(deployForks[i]), "\n"); createSelectFork(deployForks[i]); @@ -51,10 +51,10 @@ contract DeployCronTwoCounter is Script, BaseDeployer { /// @dev Function to perform actual deployment. function chainDeploySmartedContract() private broadcast(_deployerPrivateKey) { - address cronTwoCounter = address(new CronTwoCounter{salt: _salt}(_callBreaker)); + address cronTwoCounter = address(new CronCounter{salt: _salt}(_callBreaker)); - require(_create2addr == cronTwoCounter, "Address mismatch CronTwoCounter"); + require(_create2addr == cronTwoCounter, "Address mismatch CronCounter"); - console2.log("CronTwoCounter deployed at address:", cronTwoCounter, "\n"); + console2.log("CronCounter deployed at address:", cronTwoCounter, "\n"); } } diff --git a/test/CronTwoExample.t.sol b/test/CronCounter.t.sol similarity index 93% rename from test/CronTwoExample.t.sol rename to test/CronCounter.t.sol index 01ea45f..0dd702a 100644 --- a/test/CronTwoExample.t.sol +++ b/test/CronCounter.t.sol @@ -4,12 +4,12 @@ pragma solidity >=0.6.2 <0.9.0; import "forge-std/Test.sol"; import "forge-std/Vm.sol"; -import "./solve-lib/CronTwo.sol"; +import "./solve-lib/CronCounterLib.sol"; import "../src/lamination/Laminator.sol"; import "../src/timetravel/CallBreaker.sol"; -contract CronTwoTest is Test, CronTwoLib { +contract CronTest is Test, CronCounterLib { address deployer; address pusher; address filler; @@ -33,7 +33,7 @@ contract CronTwoTest is Test, CronTwoLib { vm.label(filler, "filler"); } - function testrun1CronTwo() external { + function testrun1Cron() external { uint256 laminatorSequenceNumber; vm.startPrank(pusher); diff --git a/test/FlashLiquidityTest.t.sol b/test/FlashLiquidity.t.sol similarity index 93% rename from test/FlashLiquidityTest.t.sol rename to test/FlashLiquidity.t.sol index 5959993..c174b9c 100644 --- a/test/FlashLiquidityTest.t.sol +++ b/test/FlashLiquidity.t.sol @@ -5,9 +5,9 @@ pragma solidity >=0.6.2 <0.9.0; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; import "../test/examples/LimitOrder.sol"; -import "../test/solve-lib/FlashLiquidityExample.sol"; +import "../test/solve-lib/FlashLiquidityLib.sol"; -contract FlashLiquidityTest is Test, FlashLiquidityExampleLib { +contract FlashLiquidityTest is Test, FlashLiquidityLib { address deployer; address pusher; address filler; diff --git a/test/FlashPillTest.t.sol b/test/FlashPill.t.sol similarity index 100% rename from test/FlashPillTest.t.sol rename to test/FlashPill.t.sol diff --git a/test/LimitOrder.t.sol b/test/LimitOrder.t.sol index f16dd1d..89bec33 100644 --- a/test/LimitOrder.t.sol +++ b/test/LimitOrder.t.sol @@ -5,9 +5,9 @@ pragma solidity >=0.6.2 <0.9.0; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; import "../test/examples/LimitOrder.sol"; -import "../test/solve-lib/LimitOrderExample.sol"; +import "../test/solve-lib/LimitOrderLib.sol"; -contract LimitOrderTest is Test, LimitOrderExampleLib { +contract LimitOrderTest is Test, LimitOrderLib { address deployer; address pusher; address filler; diff --git a/test/MEVTimeComputeTest.t.sol b/test/MEVTimeCompute.t.sol similarity index 100% rename from test/MEVTimeComputeTest.t.sol rename to test/MEVTimeCompute.t.sol diff --git a/test/NoopTurnerTest.t.sol b/test/NoopTurner.t.sol similarity index 100% rename from test/NoopTurnerTest.t.sol rename to test/NoopTurner.t.sol diff --git a/test/PnP.t.sol b/test/PnP.t.sol index fc71049..d487e24 100644 --- a/test/PnP.t.sol +++ b/test/PnP.t.sol @@ -5,9 +5,9 @@ pragma solidity >=0.6.2 <0.9.0; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; import "../test/examples/PnP.sol"; -import "../test/solve-lib/PnPExample.sol"; +import "../test/solve-lib/PnPLib.sol"; -contract PnPTest is Test, PnPExampleLib { +contract PnPTest is Test, PnPLib { address deployer; address pusher; address filler; diff --git a/test/Sandwich.t.sol b/test/Sandwich.t.sol index 2a6acf7..e523e01 100644 --- a/test/Sandwich.t.sol +++ b/test/Sandwich.t.sol @@ -4,12 +4,12 @@ pragma solidity ^0.8.19; import "forge-std/Test.sol"; import "forge-std/Vm.sol"; -import "./solve-lib/CronTwo.sol"; +import "./solve-lib/CronCounterLib.sol"; import "../src/lamination/Laminator.sol"; import "../src/timetravel/CallBreaker.sol"; -contract CronTwoTest is Test, CronTwoLib { +contract CronTest is Test, CronCounterLib { address deployer; address pusher; address filler; @@ -33,7 +33,7 @@ contract CronTwoTest is Test, CronTwoLib { vm.label(filler, "filler"); } - function testrun1CronTwo() external { + function testrun1Cron() external { uint256 laminatorSequenceNumber; vm.startPrank(pusher); diff --git a/test/WorkedExample.t.sol b/test/SelfCheckout.t.sol similarity index 94% rename from test/WorkedExample.t.sol rename to test/SelfCheckout.t.sol index 57f9a19..da47222 100644 --- a/test/WorkedExample.t.sol +++ b/test/SelfCheckout.t.sol @@ -10,7 +10,7 @@ import "test/examples/DeFi/SelfCheckout.sol"; import "test/examples/MyErc20.sol"; import "test/solve-lib/DeFi/SelfCheckoutLib.sol"; -contract WSelfCheckoutTest is Test, SelfCheckoutLib { +contract SelfCheckoutTest is Test, SelfCheckoutLib { address deployer; address pusher; address filler; @@ -34,7 +34,7 @@ contract WSelfCheckoutTest is Test, SelfCheckoutLib { vm.label(filler, "filler"); } - function test_workedExample() external { + function test_selfCheckout() external { uint256 laminatorSequenceNumber; vm.startPrank(pusher); diff --git a/test/examples/CronTwoCounter.sol b/test/examples/CronCounter.sol similarity index 92% rename from test/examples/CronTwoCounter.sol rename to test/examples/CronCounter.sol index ef091ff..5f67c95 100644 --- a/test/examples/CronTwoCounter.sol +++ b/test/examples/CronCounter.sol @@ -4,7 +4,7 @@ pragma solidity >=0.6.2 <0.9.0; import "../../src/timetravel/SmarterContract.sol"; -contract CronTwoCounter is SmarterContract { +contract CronCounter is SmarterContract { mapping(address => uint256) private _counters; constructor(address _callbreaker) SmarterContract(_callbreaker) {} diff --git a/test/solve-lib/CronTwo.sol b/test/solve-lib/CronCounterLib.sol similarity index 96% rename from test/solve-lib/CronTwo.sol rename to test/solve-lib/CronCounterLib.sol index fc78bef..daec76e 100644 --- a/test/solve-lib/CronTwo.sol +++ b/test/solve-lib/CronCounterLib.sol @@ -5,7 +5,7 @@ import "forge-std/Vm.sol"; import "../../src/lamination/Laminator.sol"; import "../../src/timetravel/CallBreaker.sol"; -import "../../test/examples/CronTwoCounter.sol"; +import "../../test/examples/CronCounter.sol"; import "../../src/timetravel/SmarterContract.sol"; // for the next year, every day: @@ -14,10 +14,10 @@ import "../../src/timetravel/SmarterContract.sol"; // the way we do this is we push a new call at the end of execution -contract CronTwoLib { +contract CronCounterLib { address payable public pusherLaminated; Laminator public laminator; - CronTwoCounter public counter; + CronCounter public counter; CallBreaker public callbreaker; uint32 _blocksInADay = 7150; uint256 _tipWei = 33; @@ -26,7 +26,7 @@ contract CronTwoLib { // Initializing contracts callbreaker = new CallBreaker(); laminator = new Laminator(address(callbreaker)); - counter = new CronTwoCounter(address(callbreaker)); + counter = new CronCounter(address(callbreaker)); pusherLaminated = payable(laminator.computeProxyAddress(pusher)); } diff --git a/test/solve-lib/FlashLiquidityExample.sol b/test/solve-lib/FlashLiquidityLib.sol similarity index 99% rename from test/solve-lib/FlashLiquidityExample.sol rename to test/solve-lib/FlashLiquidityLib.sol index 825b0d4..e9eadfa 100644 --- a/test/solve-lib/FlashLiquidityExample.sol +++ b/test/solve-lib/FlashLiquidityLib.sol @@ -9,7 +9,7 @@ import "../utils/MockERC20Token.sol"; import "../utils/MockSwapRouter.sol"; import "../utils/MockPositionManager.sol"; -contract FlashLiquidityExampleLib { +contract FlashLiquidityLib { address payable public pusherLaminated; MockERC20Token public aToken; MockERC20Token public bToken; diff --git a/test/solve-lib/FlashPillExample.sol b/test/solve-lib/FlashPillLib.sol similarity index 91% rename from test/solve-lib/FlashPillExample.sol rename to test/solve-lib/FlashPillLib.sol index 28c9b39..7fab939 100644 --- a/test/solve-lib/FlashPillExample.sol +++ b/test/solve-lib/FlashPillLib.sol @@ -1,14 +1,12 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.9.0; -import "forge-std/Vm.sol"; +import "src/lamination/Laminator.sol"; +import "src/timetravel/CallBreaker.sol"; +import "src/timetravel/SmarterContract.sol"; +import "test/examples/FlashPill.sol"; -import "../../src/lamination/Laminator.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../test/examples/FlashPill.sol"; -import "../../src/timetravel/SmarterContract.sol"; - -contract FlashPillExampleLib { +contract FlashPillLib { address payable public pusherLaminated; FlashPill public fp; Laminator public laminator; diff --git a/test/solve-lib/LimitOrderExample.sol b/test/solve-lib/LimitOrderLib.sol similarity index 94% rename from test/solve-lib/LimitOrderExample.sol rename to test/solve-lib/LimitOrderLib.sol index 256079a..eb55211 100644 --- a/test/solve-lib/LimitOrderExample.sol +++ b/test/solve-lib/LimitOrderLib.sol @@ -1,16 +1,15 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.6.2 <0.9.0; -import "forge-std/Vm.sol"; -import "../../src/lamination/Laminator.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../test/examples/LimitOrder.sol"; -import "../../src/timetravel/SmarterContract.sol"; +import "src/lamination/Laminator.sol"; +import "src/timetravel/CallBreaker.sol"; +import "test/examples/LimitOrder.sol"; +import "src/timetravel/SmarterContract.sol"; import "../utils/MockERC20Token.sol"; import "../utils/MockSwapRouter.sol"; import "../utils/MockPositionManager.sol"; -contract LimitOrderExampleLib { +contract LimitOrderLib { address payable public pusherLaminated; MockERC20Token public aToken; MockERC20Token public bToken; diff --git a/test/solve-lib/PnPExample.sol b/test/solve-lib/PnPLib.sol similarity index 99% rename from test/solve-lib/PnPExample.sol rename to test/solve-lib/PnPLib.sol index c5dd109..67ddbaf 100644 --- a/test/solve-lib/PnPExample.sol +++ b/test/solve-lib/PnPLib.sol @@ -8,7 +8,7 @@ import "../../src/timetravel/CallBreaker.sol"; import "../../test/examples/PnP.sol"; import "../../src/timetravel/SmarterContract.sol"; -contract PnPExampleLib { +contract PnPLib { address payable public pusherLaminated; PnP public pnp; Laminator public laminator; From 960c4ddcc7e41056d44515669061ce0501d4ae58 Mon Sep 17 00:00:00 2001 From: TokenTitan Date: Mon, 29 Jul 2024 13:33:41 +0530 Subject: [PATCH 3/4] refactor: updated solidity version --- foundry.toml | 2 +- script/BaseDeployer.s.sol | 2 +- script/CallBreaker.s.sol | 2 +- script/Laminator.s.sol | 2 +- script/SmarterContract.s.sol | 2 +- script/test/CronCounter.s.sol | 2 +- script/test/SelfCheckout.s.sol | 2 +- test/CallBreaker.t.sol | 2 +- test/CronCounter.t.sol | 2 +- test/FlashLiquidity.t.sol | 2 +- test/{FlashPill.t.sol => FlashPillTest.t.sol} | 2 +- test/GasSnapshot.t.sol | 2 +- test/Laminator.t.sol | 2 +- test/LimitOrder.t.sol | 2 +- test/MEVTimeCompute.t.sol | 2 +- test/{NoopTurner.t.sol => NoopTurnerTest.t.sol} | 2 +- test/PnP.t.sol | 2 +- test/SelfCheckout.t.sol | 2 +- test/SmarterContract.t.sol | 2 +- test/TimeTypes.t.sol | 2 +- test/contracts/CallBreakerHarness.sol | 2 +- test/contracts/SmarterContractHarness.sol | 2 +- test/examples/CronCounter.sol | 2 +- test/examples/DeFi/SelfCheckout.sol | 2 +- test/examples/FlashLiquidity.sol | 16 ++++++---------- test/examples/FlashPill.sol | 2 +- test/examples/LimitOrder.sol | 2 +- test/examples/MEVOracle/MEVTimeCompute.sol | 2 +- test/examples/MyErc20.sol | 2 +- test/examples/NoopTurner.sol | 2 +- test/examples/PnP.sol | 2 +- test/solve-lib/CronCounterLib.sol | 2 +- test/solve-lib/DeFi/SelfCheckoutLib.sol | 2 +- test/solve-lib/FlashLiquidityLib.sol | 2 +- test/solve-lib/FlashPillLib.sol | 2 +- test/solve-lib/LimitOrderLib.sol | 2 +- .../MEVTimeOracle/MEVTimeComputeLib.sol | 2 +- test/solve-lib/PnPLib.sol | 2 +- test/utils/MockSwapRouter.sol | 2 +- 39 files changed, 44 insertions(+), 48 deletions(-) rename test/{FlashPill.t.sol => FlashPillTest.t.sol} (93%) rename test/{NoopTurner.t.sol => NoopTurnerTest.t.sol} (98%) diff --git a/foundry.toml b/foundry.toml index 4041e2a..a0a5c93 100644 --- a/foundry.toml +++ b/foundry.toml @@ -3,7 +3,7 @@ src = 'src' out = 'out' libs = ['lib'] evm_version = "cancun" -solc = "0.8.23" +solc = "0.8.26" ffi = true ast = true diff --git a/script/BaseDeployer.s.sol b/script/BaseDeployer.s.sol index 9abe059..49b3996 100644 --- a/script/BaseDeployer.s.sol +++ b/script/BaseDeployer.s.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; +pragma solidity 0.8.26; import {Script} from "forge-std/Script.sol"; diff --git a/script/CallBreaker.s.sol b/script/CallBreaker.s.sol index 2ebe48e..3b50ed5 100644 --- a/script/CallBreaker.s.sol +++ b/script/CallBreaker.s.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; +pragma solidity 0.8.26; import {Script} from "forge-std/Script.sol"; import {CallBreaker} from "../src/timetravel/CallBreaker.sol"; diff --git a/script/Laminator.s.sol b/script/Laminator.s.sol index 4ed768d..7c0c793 100644 --- a/script/Laminator.s.sol +++ b/script/Laminator.s.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; +pragma solidity 0.8.26; import {Script} from "forge-std/Script.sol"; import {BaseDeployer} from "./BaseDeployer.s.sol"; diff --git a/script/SmarterContract.s.sol b/script/SmarterContract.s.sol index 83bdb96..f25b108 100644 --- a/script/SmarterContract.s.sol +++ b/script/SmarterContract.s.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; +pragma solidity 0.8.26; import {Script} from "forge-std/Script.sol"; import {BaseDeployer} from "./BaseDeployer.s.sol"; diff --git a/script/test/CronCounter.s.sol b/script/test/CronCounter.s.sol index 5bb2fe7..f5e383d 100644 --- a/script/test/CronCounter.s.sol +++ b/script/test/CronCounter.s.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; +pragma solidity 0.8.26; import {Script} from "forge-std/Script.sol"; import {BaseDeployer} from "../BaseDeployer.s.sol"; diff --git a/script/test/SelfCheckout.s.sol b/script/test/SelfCheckout.s.sol index 772e80e..215cd04 100644 --- a/script/test/SelfCheckout.s.sol +++ b/script/test/SelfCheckout.s.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity ^0.8.19; +pragma solidity 0.8.26; import {Script} from "forge-std/Script.sol"; import {BaseDeployer} from "script/BaseDeployer.s.sol"; diff --git a/test/CallBreaker.t.sol b/test/CallBreaker.t.sol index a1c7c68..334f729 100644 --- a/test/CallBreaker.t.sol +++ b/test/CallBreaker.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; diff --git a/test/CronCounter.t.sol b/test/CronCounter.t.sol index 0dd702a..783679c 100644 --- a/test/CronCounter.t.sol +++ b/test/CronCounter.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "forge-std/Vm.sol"; diff --git a/test/FlashLiquidity.t.sol b/test/FlashLiquidity.t.sol index c174b9c..5f89b4d 100644 --- a/test/FlashLiquidity.t.sol +++ b/test/FlashLiquidity.t.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; diff --git a/test/FlashPill.t.sol b/test/FlashPillTest.t.sol similarity index 93% rename from test/FlashPill.t.sol rename to test/FlashPillTest.t.sol index 2fd9214..b2a9801 100644 --- a/test/FlashPill.t.sol +++ b/test/FlashPillTest.t.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; diff --git a/test/GasSnapshot.t.sol b/test/GasSnapshot.t.sol index d6eb954..89b3e0e 100644 --- a/test/GasSnapshot.t.sol +++ b/test/GasSnapshot.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import {Test} from "forge-std/Test.sol"; import {LaminatorHarness} from "./Laminator.t.sol"; diff --git a/test/Laminator.t.sol b/test/Laminator.t.sol index e20644c..5c154a7 100644 --- a/test/Laminator.t.sol +++ b/test/Laminator.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; diff --git a/test/LimitOrder.t.sol b/test/LimitOrder.t.sol index 89bec33..b725176 100644 --- a/test/LimitOrder.t.sol +++ b/test/LimitOrder.t.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; diff --git a/test/MEVTimeCompute.t.sol b/test/MEVTimeCompute.t.sol index 12c9cb6..99dd23d 100644 --- a/test/MEVTimeCompute.t.sol +++ b/test/MEVTimeCompute.t.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.23; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "src/timetravel/CallBreaker.sol"; diff --git a/test/NoopTurner.t.sol b/test/NoopTurnerTest.t.sol similarity index 98% rename from test/NoopTurner.t.sol rename to test/NoopTurnerTest.t.sol index e3b0adb..2fa7c7e 100644 --- a/test/NoopTurner.t.sol +++ b/test/NoopTurnerTest.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; diff --git a/test/PnP.t.sol b/test/PnP.t.sol index d487e24..ef47df1 100644 --- a/test/PnP.t.sol +++ b/test/PnP.t.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; diff --git a/test/SelfCheckout.t.sol b/test/SelfCheckout.t.sol index da47222..977abbf 100644 --- a/test/SelfCheckout.t.sol +++ b/test/SelfCheckout.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; import "forge-std/Vm.sol"; diff --git a/test/SmarterContract.t.sol b/test/SmarterContract.t.sol index b003560..9d10a83 100644 --- a/test/SmarterContract.t.sol +++ b/test/SmarterContract.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Test.sol"; diff --git a/test/TimeTypes.t.sol b/test/TimeTypes.t.sol index b67ba6e..17121c5 100644 --- a/test/TimeTypes.t.sol +++ b/test/TimeTypes.t.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import {Test} from "forge-std/Test.sol"; import {CallObject, CallObjectStorage} from "../src/TimeTypes.sol"; diff --git a/test/contracts/CallBreakerHarness.sol b/test/contracts/CallBreakerHarness.sol index a2c3b73..73a367e 100644 --- a/test/contracts/CallBreakerHarness.sol +++ b/test/contracts/CallBreakerHarness.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import {CallBreaker, CallObject, ReturnObject} from "src/timetravel/CallBreaker.sol"; diff --git a/test/contracts/SmarterContractHarness.sol b/test/contracts/SmarterContractHarness.sol index bd9b725..38d54c4 100644 --- a/test/contracts/SmarterContractHarness.sol +++ b/test/contracts/SmarterContractHarness.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: UNLICENSED -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import {SmarterContract, CallObject} from "src/timetravel/SmarterContract.sol"; diff --git a/test/examples/CronCounter.sol b/test/examples/CronCounter.sol index 5f67c95..c7374b8 100644 --- a/test/examples/CronCounter.sol +++ b/test/examples/CronCounter.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "../../src/timetravel/SmarterContract.sol"; diff --git a/test/examples/DeFi/SelfCheckout.sol b/test/examples/DeFi/SelfCheckout.sol index 9561aa5..8cd7a70 100644 --- a/test/examples/DeFi/SelfCheckout.sol +++ b/test/examples/DeFi/SelfCheckout.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "openzeppelin/token/ERC20/IERC20.sol"; import "src/TimeTypes.sol"; diff --git a/test/examples/FlashLiquidity.sol b/test/examples/FlashLiquidity.sol index 7789bcc..c36ca9c 100644 --- a/test/examples/FlashLiquidity.sol +++ b/test/examples/FlashLiquidity.sol @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; -import "forge-std/Test.sol"; -import "forge-std/console.sol"; - -import "../utils/interfaces/ISwapRouter.sol"; import "openzeppelin/token/ERC20/ERC20.sol"; -import "../utils/interfaces/IWeth.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../src/timetravel/SmarterContract.sol"; -import "../../src/TimeTypes.sol"; +import "src/timetravel/CallBreaker.sol"; +import "src/timetravel/SmarterContract.sol"; +import "src/TimeTypes.sol"; +import "test/utils/interfaces/ISwapRouter.sol"; +import "test/utils/interfaces/IWeth.sol"; address constant DAI = 0x6B175474E89094C44Da98b954EedeAC495271d0F; address constant WETH9 = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; @@ -73,7 +70,6 @@ contract FlashLiquidity is SmarterContract { // The call to `exactInputSingle` executes the swap. uint256 amountOut = router.exactInputSingle(params); - console.log("WETH", amountOut); // check whether or not CallObject memory callObj = CallObject({ diff --git a/test/examples/FlashPill.sol b/test/examples/FlashPill.sol index 5f1d163..1665c13 100644 --- a/test/examples/FlashPill.sol +++ b/test/examples/FlashPill.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "openzeppelin/token/ERC20/IERC20.sol"; import "../../src/timetravel/CallBreaker.sol"; diff --git a/test/examples/LimitOrder.sol b/test/examples/LimitOrder.sol index ecdb81c..fc34359 100644 --- a/test/examples/LimitOrder.sol +++ b/test/examples/LimitOrder.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.23; +pragma solidity 0.8.26; import "../utils/interfaces/ISwapRouter.sol"; import "../../src/timetravel/CallBreaker.sol"; diff --git a/test/examples/MEVOracle/MEVTimeCompute.sol b/test/examples/MEVOracle/MEVTimeCompute.sol index 4626ed5..eab6f9f 100644 --- a/test/examples/MEVOracle/MEVTimeCompute.sol +++ b/test/examples/MEVOracle/MEVTimeCompute.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.23; +pragma solidity 0.8.26; import "src/timetravel/CallBreaker.sol"; import "src/timetravel/SmarterContract.sol"; diff --git a/test/examples/MyErc20.sol b/test/examples/MyErc20.sol index 332b177..6153ec4 100644 --- a/test/examples/MyErc20.sol +++ b/test/examples/MyErc20.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "openzeppelin/token/ERC20/ERC20.sol"; diff --git a/test/examples/NoopTurner.sol b/test/examples/NoopTurner.sol index 86f01ca..17f4d3e 100644 --- a/test/examples/NoopTurner.sol +++ b/test/examples/NoopTurner.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "../../src/timetravel/CallBreaker.sol"; import "../../src/timetravel/SmarterContract.sol"; diff --git a/test/examples/PnP.sol b/test/examples/PnP.sol index 999d61d..9a1756f 100644 --- a/test/examples/PnP.sol +++ b/test/examples/PnP.sol @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "../../src/timetravel/CallBreaker.sol"; diff --git a/test/solve-lib/CronCounterLib.sol b/test/solve-lib/CronCounterLib.sol index daec76e..ebf29a1 100644 --- a/test/solve-lib/CronCounterLib.sol +++ b/test/solve-lib/CronCounterLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Vm.sol"; diff --git a/test/solve-lib/DeFi/SelfCheckoutLib.sol b/test/solve-lib/DeFi/SelfCheckoutLib.sol index d19d9d0..8ae57de 100644 --- a/test/solve-lib/DeFi/SelfCheckoutLib.sol +++ b/test/solve-lib/DeFi/SelfCheckoutLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Vm.sol"; diff --git a/test/solve-lib/FlashLiquidityLib.sol b/test/solve-lib/FlashLiquidityLib.sol index e9eadfa..f76a7fb 100644 --- a/test/solve-lib/FlashLiquidityLib.sol +++ b/test/solve-lib/FlashLiquidityLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "../../src/lamination/Laminator.sol"; import "../../src/timetravel/CallBreaker.sol"; diff --git a/test/solve-lib/FlashPillLib.sol b/test/solve-lib/FlashPillLib.sol index 7fab939..960bd23 100644 --- a/test/solve-lib/FlashPillLib.sol +++ b/test/solve-lib/FlashPillLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "src/lamination/Laminator.sol"; import "src/timetravel/CallBreaker.sol"; diff --git a/test/solve-lib/LimitOrderLib.sol b/test/solve-lib/LimitOrderLib.sol index eb55211..effc6c0 100644 --- a/test/solve-lib/LimitOrderLib.sol +++ b/test/solve-lib/LimitOrderLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "src/lamination/Laminator.sol"; import "src/timetravel/CallBreaker.sol"; diff --git a/test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol b/test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol index c95a1c7..6510e22 100644 --- a/test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol +++ b/test/solve-lib/MEVTimeOracle/MEVTimeComputeLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.23; +pragma solidity 0.8.26; import "src/lamination/Laminator.sol"; import "src/timetravel/CallBreaker.sol"; diff --git a/test/solve-lib/PnPLib.sol b/test/solve-lib/PnPLib.sol index 67ddbaf..2cea968 100644 --- a/test/solve-lib/PnPLib.sol +++ b/test/solve-lib/PnPLib.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity >=0.6.2 <0.9.0; +pragma solidity 0.8.26; import "forge-std/Vm.sol"; diff --git a/test/utils/MockSwapRouter.sol b/test/utils/MockSwapRouter.sol index 8ca7b97..c8949f6 100644 --- a/test/utils/MockSwapRouter.sol +++ b/test/utils/MockSwapRouter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-3.0 -pragma solidity 0.8.23; +pragma solidity 0.8.26; import {IWETH, IERC20} from "../utils/interfaces/IWeth.sol"; import {ISwapRouter} from "../utils/interfaces/ISwapRouter.sol"; From dc73c7d8b4b95527169b8b3e687162beac74ea4d Mon Sep 17 00:00:00 2001 From: TokenTitan Date: Mon, 29 Jul 2024 15:22:46 +0530 Subject: [PATCH 4/4] refactor: renamed limit order to slippage protection --- test/FlashLiquidity.t.sol | 1 - ...itOrder.t.sol => SlippageProtection.t.sol} | 31 ++++++++++++++----- test/examples/FlashLiquidity.sol | 3 -- .../examples/{LimitOrder.sol => SwapPool.sol} | 13 +++----- test/solve-lib/FlashLiquidityLib.sol | 26 ++++++++-------- ...OrderLib.sol => SlippageProtectionLib.sol} | 26 +++++++--------- 6 files changed, 54 insertions(+), 46 deletions(-) rename test/{LimitOrder.t.sol => SlippageProtection.t.sol} (56%) rename test/examples/{LimitOrder.sol => SwapPool.sol} (96%) rename test/solve-lib/{LimitOrderLib.sol => SlippageProtectionLib.sol} (89%) diff --git a/test/FlashLiquidity.t.sol b/test/FlashLiquidity.t.sol index 5f89b4d..376d38b 100644 --- a/test/FlashLiquidity.t.sol +++ b/test/FlashLiquidity.t.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.26; import "forge-std/Test.sol"; import "../src/timetravel/CallBreaker.sol"; -import "../test/examples/LimitOrder.sol"; import "../test/solve-lib/FlashLiquidityLib.sol"; contract FlashLiquidityTest is Test, FlashLiquidityLib { diff --git a/test/LimitOrder.t.sol b/test/SlippageProtection.t.sol similarity index 56% rename from test/LimitOrder.t.sol rename to test/SlippageProtection.t.sol index b725176..34a08ac 100644 --- a/test/LimitOrder.t.sol +++ b/test/SlippageProtection.t.sol @@ -3,11 +3,10 @@ pragma solidity 0.8.26; import "forge-std/Test.sol"; -import "../src/timetravel/CallBreaker.sol"; -import "../test/examples/LimitOrder.sol"; -import "../test/solve-lib/LimitOrderLib.sol"; +import "src/timetravel/CallBreaker.sol"; +import "test/solve-lib/SlippageProtectionLib.sol"; -contract LimitOrderTest is Test, LimitOrderLib { +contract SlippageProtectionTest is Test, SlippageProtectionLib { address deployer; address pusher; address filler; @@ -31,18 +30,19 @@ contract LimitOrderTest is Test, LimitOrderLib { vm.label(filler, "filler"); } - function testLimitOrder() external { + function testSlippageProtection() external { uint256 laminatorSequenceNumber; + uint256 maxSlippage = 10; vm.startPrank(pusher); - laminatorSequenceNumber = userLand(); + laminatorSequenceNumber = userLand(maxSlippage); vm.stopPrank(); // go forward in time vm.roll(block.number + 1); vm.startPrank(filler); - solverLand(laminatorSequenceNumber, filler); + solverLand(laminatorSequenceNumber, filler, maxSlippage); vm.stopPrank(); assertFalse(callbreaker.isPortalOpen()); @@ -52,4 +52,21 @@ contract LimitOrderTest is Test, LimitOrderLib { assertTrue(init); assertTrue(exec); } + + function testSlippageProtectionRevert() external { + uint256 laminatorSequenceNumber; + uint256 maxSlippage = 1; + + vm.startPrank(pusher); + laminatorSequenceNumber = userLand(maxSlippage); + vm.stopPrank(); + + // go forward in time + vm.roll(block.number + 1); + + vm.startPrank(filler); + vm.expectRevert(); + solverLand(laminatorSequenceNumber, filler, maxSlippage); + vm.stopPrank(); + } } diff --git a/test/examples/FlashLiquidity.sol b/test/examples/FlashLiquidity.sol index c36ca9c..c998fb2 100644 --- a/test/examples/FlashLiquidity.sol +++ b/test/examples/FlashLiquidity.sol @@ -15,9 +15,6 @@ address constant SwapRouter = 0xE592427A0AEce92De3Edee1F18E0157C05861564; // pool fee, 0.3%. uint24 constant poolFee = 3000; -// This example uses fork test: -// FORK_URL=https://eth-mainnet.g.alchemy.com/v2/613t3mfjTevdrCwDl28CVvuk6wSIxRPi -// forge test -vv --gas-report --fork-url $FORK_URL --match-path test/LimitOrder.t.sol contract FlashLiquidity is SmarterContract { address owner; address callbreakerAddress; diff --git a/test/examples/LimitOrder.sol b/test/examples/SwapPool.sol similarity index 96% rename from test/examples/LimitOrder.sol rename to test/examples/SwapPool.sol index fc34359..aead196 100644 --- a/test/examples/LimitOrder.sol +++ b/test/examples/SwapPool.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.26; -import "../utils/interfaces/ISwapRouter.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../src/timetravel/SmarterContract.sol"; -import "../../src/TimeTypes.sol"; +import "src/timetravel/CallBreaker.sol"; +import "src/timetravel/SmarterContract.sol"; +import "src/TimeTypes.sol"; +import "test/utils/interfaces/ISwapRouter.sol"; import {IWETH, IERC20} from "../utils/interfaces/IWeth.sol"; import {IPositionManager} from "../utils/interfaces/IPositionManager.sol"; @@ -12,10 +12,7 @@ import {IPositionManager} from "../utils/interfaces/IPositionManager.sol"; // pool fee, 0.3%. uint24 constant poolFee = 3000; -// This example uses fork test: -// FORK_URL=https://eth-mainnet.g.alchemy.com/v2/613t3mfjTevdrCwDl28CVvuk6wSIxRPi -// forge test -vv --gas-report --fork-url $FORK_URL --match-path test/LimitOrder.t.sol -contract LimitOrder is SmarterContract { +contract SwapPool is SmarterContract { ISwapRouter private immutable router; address owner; diff --git a/test/solve-lib/FlashLiquidityLib.sol b/test/solve-lib/FlashLiquidityLib.sol index f76a7fb..4578484 100644 --- a/test/solve-lib/FlashLiquidityLib.sol +++ b/test/solve-lib/FlashLiquidityLib.sol @@ -1,13 +1,13 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.26; -import "../../src/lamination/Laminator.sol"; -import "../../src/timetravel/CallBreaker.sol"; -import "../../test/examples/LimitOrder.sol"; -import "../../src/timetravel/SmarterContract.sol"; -import "../utils/MockERC20Token.sol"; -import "../utils/MockSwapRouter.sol"; -import "../utils/MockPositionManager.sol"; +import "src/lamination/Laminator.sol"; +import "src/timetravel/CallBreaker.sol"; +import "src/timetravel/SmarterContract.sol"; +import "test/examples/SwapPool.sol"; +import "test/utils/MockERC20Token.sol"; +import "test/utils/MockSwapRouter.sol"; +import "test/utils/MockPositionManager.sol"; contract FlashLiquidityLib { address payable public pusherLaminated; @@ -15,7 +15,7 @@ contract FlashLiquidityLib { MockERC20Token public bToken; MockSwapRouter public swapRouter; MockPositionManager public positionManager; - LimitOrder public limitOrder; + SwapPool public pool; Laminator public laminator; CallBreaker public callbreaker; uint256 _tipWei = 33; @@ -28,7 +28,7 @@ contract FlashLiquidityLib { bToken = new MockERC20Token("BToken", "BT"); swapRouter = new MockSwapRouter(address(aToken), address(bToken)); positionManager = new MockPositionManager(address(swapRouter)); - limitOrder = new LimitOrder( + pool = new SwapPool( address(swapRouter), address(callbreaker), address(positionManager), address(aToken), address(bToken) ); pusherLaminated = payable(laminator.computeProxyAddress(pusher)); @@ -51,11 +51,11 @@ contract FlashLiquidityLib { amount: 0, addr: address(aToken), gas: 1000000, - callvalue: abi.encodeWithSignature("approve(address,uint256)", limitOrder, tokenToApprove) + callvalue: abi.encodeWithSignature("approve(address,uint256)", pool, tokenToApprove) }); pusherCallObjs[3] = CallObject({ amount: 0, - addr: address(limitOrder), + addr: address(pool), gas: 1000000, callvalue: abi.encodeWithSignature("swapDAIForWETH(uint256,uint256)", amountIn, slippagePercent) }); @@ -74,7 +74,7 @@ contract FlashLiquidityLib { callObjs[0] = CallObject({ amount: 0, - addr: address(limitOrder), + addr: address(pool), gas: 1000000, callvalue: abi.encodeWithSignature("provideLiquidityToDAIETHPool(uint256,uint256)", liquidity, liquidity) }); @@ -95,7 +95,7 @@ contract FlashLiquidityLib { callObjs[3] = CallObject({ amount: 0, - addr: address(limitOrder), + addr: address(pool), gas: 1000000, callvalue: abi.encodeWithSignature("withdrawLiquidityFromDAIETHPool()") }); diff --git a/test/solve-lib/LimitOrderLib.sol b/test/solve-lib/SlippageProtectionLib.sol similarity index 89% rename from test/solve-lib/LimitOrderLib.sol rename to test/solve-lib/SlippageProtectionLib.sol index effc6c0..9ac5809 100644 --- a/test/solve-lib/LimitOrderLib.sol +++ b/test/solve-lib/SlippageProtectionLib.sol @@ -3,23 +3,21 @@ pragma solidity 0.8.26; import "src/lamination/Laminator.sol"; import "src/timetravel/CallBreaker.sol"; -import "test/examples/LimitOrder.sol"; -import "src/timetravel/SmarterContract.sol"; -import "../utils/MockERC20Token.sol"; -import "../utils/MockSwapRouter.sol"; -import "../utils/MockPositionManager.sol"; +import "test/examples/SwapPool.sol"; +import "test/utils/MockERC20Token.sol"; +import "test/utils/MockSwapRouter.sol"; +import "test/utils/MockPositionManager.sol"; -contract LimitOrderLib { +contract SlippageProtectionLib { address payable public pusherLaminated; MockERC20Token public aToken; MockERC20Token public bToken; MockSwapRouter public swapRouter; MockPositionManager public positionManager; - LimitOrder public limitOrder; + SwapPool public pool; Laminator public laminator; CallBreaker public callbreaker; - uint256 maxSlippage = 10; - uint256 _tipWei = 33; + uint256 private _tipWei = 33; function deployerLand(address pusher) public { // Initializing contracts @@ -29,7 +27,7 @@ contract LimitOrderLib { bToken = new MockERC20Token("BToken", "BT"); swapRouter = new MockSwapRouter(address(aToken), address(bToken)); positionManager = new MockPositionManager(address(swapRouter)); - limitOrder = new LimitOrder( + pool = new SwapPool( address(swapRouter), address(callbreaker), address(positionManager), address(aToken), address(bToken) ); pusherLaminated = payable(laminator.computeProxyAddress(pusher)); @@ -37,7 +35,7 @@ contract LimitOrderLib { bToken.mint(100e18, address(callbreaker)); } - function userLand() public returns (uint256) { + function userLand(uint256 maxSlippage) public returns (uint256) { // send proxy some eth pusherLaminated.transfer(1 ether); @@ -49,11 +47,11 @@ contract LimitOrderLib { amount: 0, addr: address(aToken), gas: 1000000, - callvalue: abi.encodeWithSignature("approve(address,uint256)", limitOrder, 100e18) + callvalue: abi.encodeWithSignature("approve(address,uint256)", pool, 100e18) }); pusherCallObjs[1] = CallObject({ amount: 0, - addr: address(limitOrder), + addr: address(pool), gas: 1000000, callvalue: abi.encodeWithSignature("swapDAIForWETH(uint256,uint256)", 100, maxSlippage) }); @@ -62,7 +60,7 @@ contract LimitOrderLib { return laminator.pushToProxy(abi.encode(pusherCallObjs), 1); } - function solverLand(uint256 laminatorSequenceNumber, address filler) public { + function solverLand(uint256 laminatorSequenceNumber, address filler, uint256 maxSlippage) public { CallObject[] memory callObjs = new CallObject[](2); ReturnObject[] memory returnObjs = new ReturnObject[](2);