diff --git a/.gas-snapshot b/.gas-snapshot index 4e0174def..580b9f645 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,7 +1,7 @@ -GenericPoolOrderBookV3ArbOrderTakerTest:testMinimumOutput((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256,uint256,uint256) (runs: 5096, μ: 2503121, ~: 2502124) -GenericPoolOrderBookV3ArbOrderTakerTest:testTakeOrdersSender((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256) (runs: 5096, μ: 2445228, ~: 2445722) -GenericPoolOrderBookV3FlashBorrowerTest:testMinimumOutput((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256,uint256,uint256) (runs: 5096, μ: 2778300, ~: 2777328) -GenericPoolOrderBookV3FlashBorrowerTest:testTakeOrdersSender((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256) (runs: 5096, μ: 2701886, ~: 2702333) +GenericPoolOrderBookV3ArbOrderTakerTest:testMinimumOutput((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256,uint256,uint256) (runs: 5096, μ: 1118510, ~: 1118456) +GenericPoolOrderBookV3ArbOrderTakerTest:testTakeOrdersSender((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256) (runs: 5096, μ: 1062543, ~: 1063098) +GenericPoolOrderBookV3FlashBorrowerTest:testMinimumOutput((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256,uint256,uint256) (runs: 5096, μ: 1394297, ~: 1393645) +GenericPoolOrderBookV3FlashBorrowerTest:testTakeOrdersSender((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256) (runs: 5096, μ: 1319200, ~: 1319647) LibOrderTest:testHashEqual((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[])) (runs: 5096, μ: 194389, ~: 191140) LibOrderTest:testHashNotEqual((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),(address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[])) (runs: 5096, μ: 298734, ~: 298554) OrderBookAddOrderMockTest:testAddOrderSameAccountWithDifferentConfig(address,((address,uint8,uint256)[],(address,uint8,uint256)[],(address,bytes,uint256[]),bytes),((address,uint8,uint256)[],(address,uint8,uint256)[],(address,bytes,uint256[]),bytes),address,address) (runs: 5096, μ: 2771808, ~: 2761475) @@ -51,5 +51,5 @@ OrderBookWithdrawTest:testWithdrawMany((bool,address,address,uint256,uint248)[]) OrderBookWithdrawTest:testWithdrawPartialVault(address,uint256,uint256,uint256) (runs: 5096, μ: 51929, ~: 51929) OrderBookWithdrawTest:testWithdrawReentrant(address,uint256,uint256,address,address,uint256) (runs: 5096, μ: 506228, ~: 507997) OrderBookWithdrawTest:testWithdrawZero(address,address,uint256) (runs: 5096, μ: 12809, ~: 12809) -RouteProcessorOrderBookV3ArbOrderTakerTest:testMinimumOutput((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256,uint256,uint256) (runs: 5096, μ: 2525859, ~: 2525280) -RouteProcessorOrderBookV3ArbOrderTakerTest:testTakeOrdersSender((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256) (runs: 5096, μ: 2468311, ~: 2468803) \ No newline at end of file +RouteProcessorOrderBookV3ArbOrderTakerTest:testMinimumOutput((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256,uint256,uint256) (runs: 5096, μ: 1140756, ~: 1140707) +RouteProcessorOrderBookV3ArbOrderTakerTest:testTakeOrdersSender((address,bool,(address,address,address),(address,uint8,uint256)[],(address,uint8,uint256)[]),uint256,uint256) (runs: 5096, μ: 1085625, ~: 1086117) \ No newline at end of file diff --git a/test/concrete/GenericPoolOrderBookV3ArbOrderTaker.sender.t.sol b/test/concrete/GenericPoolOrderBookV3ArbOrderTaker.sender.t.sol index 3683e1fa8..596996b54 100644 --- a/test/concrete/GenericPoolOrderBookV3ArbOrderTaker.sender.t.sol +++ b/test/concrete/GenericPoolOrderBookV3ArbOrderTaker.sender.t.sol @@ -12,12 +12,6 @@ import "src/interface/unstable/IOrderBookV3.sol"; import "test/util/concrete/FlashLendingMockOrderBook.sol"; -contract Mock0xProxy { - fallback() external { - Address.sendValue(payable(msg.sender), address(this).balance); - } -} - contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest { function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) { (address deployer, DeployerDiscoverableMetaV2ConstructionConfig memory config) = @@ -34,7 +28,6 @@ contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest { outputIOIndex = bound(outputIOIndex, 0, order.validOutputs.length - 1); FlashLendingMockOrderBook ob = new FlashLendingMockOrderBook(); - Mock0xProxy proxy = new Mock0xProxy(); GenericPoolOrderBookV3ArbOrderTaker arb = GenericPoolOrderBookV3ArbOrderTaker(Clones.clone(iImplementation)); arb.initialize( @@ -52,9 +45,7 @@ contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest { orders[0] = TakeOrderConfig(order, inputIOIndex, outputIOIndex, new SignedContextV1[](0)); arb.arb( - TakeOrdersConfigV2( - 0, type(uint256).max, type(uint256).max, orders, abi.encode(address(proxy), address(proxy), "") - ), + TakeOrdersConfigV2(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), 0 ); } @@ -73,7 +64,6 @@ contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest { vm.assume(minimumOutput > mintAmount); FlashLendingMockOrderBook ob = new FlashLendingMockOrderBook(); - Mock0xProxy proxy = new Mock0xProxy(); GenericPoolOrderBookV3ArbOrderTaker arb = GenericPoolOrderBookV3ArbOrderTaker(Clones.clone(iImplementation)); arb.initialize( @@ -94,9 +84,7 @@ contract GenericPoolOrderBookV3ArbOrderTakerTest is ArbTest { vm.expectRevert(abi.encodeWithSelector(MinimumOutput.selector, minimumOutput, mintAmount)); arb.arb( - TakeOrdersConfigV2( - 0, type(uint256).max, type(uint256).max, orders, abi.encode(address(proxy), address(proxy), "") - ), + TakeOrdersConfigV2(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), minimumOutput ); } diff --git a/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol b/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol index c5ec383c6..76f5ccffe 100644 --- a/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol +++ b/test/concrete/GenericPoolOrderBookV3FlashBorrower.sender.t.sol @@ -11,12 +11,6 @@ import "test/util/concrete/FlashLendingMockOrderBook.sol"; import "src/concrete/GenericPoolOrderBookV3FlashBorrower.sol"; import "src/interface/unstable/IOrderBookV3.sol"; -contract Mock0xProxy { - fallback() external { - Address.sendValue(payable(msg.sender), address(this).balance); - } -} - contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest { function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) { (address deployer, DeployerDiscoverableMetaV2ConstructionConfig memory config) = @@ -33,7 +27,6 @@ contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest { outputIOIndex = bound(outputIOIndex, 0, order.validOutputs.length - 1); FlashLendingMockOrderBook ob = new FlashLendingMockOrderBook(); - Mock0xProxy proxy = new Mock0xProxy(); GenericPoolOrderBookV3FlashBorrower arb = GenericPoolOrderBookV3FlashBorrower(Clones.clone(iImplementation)); arb.initialize( @@ -53,7 +46,7 @@ contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest { arb.arb( TakeOrdersConfigV2(0, type(uint256).max, type(uint256).max, orders, ""), 0, - abi.encode(address(proxy), address(proxy), "") + abi.encode(iRefundoor, iRefundoor, "") ); } @@ -71,7 +64,6 @@ contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest { vm.assume(minimumOutput > mintAmount); FlashLendingMockOrderBook ob = new FlashLendingMockOrderBook(); - Mock0xProxy proxy = new Mock0xProxy(); GenericPoolOrderBookV3FlashBorrower arb = GenericPoolOrderBookV3FlashBorrower(Clones.clone(iImplementation)); arb.initialize( @@ -94,7 +86,7 @@ contract GenericPoolOrderBookV3FlashBorrowerTest is ArbTest { arb.arb( TakeOrdersConfigV2(0, type(uint256).max, type(uint256).max, orders, ""), minimumOutput, - abi.encode(address(proxy), address(proxy), "") + abi.encode(iRefundoor, iRefundoor, "") ); } } diff --git a/test/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sender.t.sol b/test/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sender.t.sol index 1e73026b3..cb0863182 100644 --- a/test/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sender.t.sol +++ b/test/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sender.t.sol @@ -12,12 +12,6 @@ import "test/util/concrete/FlashLendingMockOrderBook.sol"; import "src/concrete/RouteProcessorOrderBookV3ArbOrderTaker.sol"; import "src/interface/unstable/IOrderBookV3.sol"; -contract Mock0xProxy { - fallback() external { - Address.sendValue(payable(msg.sender), address(this).balance); - } -} - contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest { function buildArbTestConstructorConfig() internal returns (ArbTestConstructorConfig memory) { (address deployer, DeployerDiscoverableMetaV2ConstructionConfig memory config) = @@ -34,7 +28,6 @@ contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest { outputIOIndex = bound(outputIOIndex, 0, order.validOutputs.length - 1); FlashLendingMockOrderBook ob = new FlashLendingMockOrderBook(); - Mock0xProxy proxy = new Mock0xProxy(); RouteProcessorOrderBookV3ArbOrderTaker arb = RouteProcessorOrderBookV3ArbOrderTaker(Clones.clone(iImplementation)); @@ -43,7 +36,7 @@ contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest { OrderBookV3ArbOrderTakerConfigV1( address(ob), EvaluableConfigV2(IExpressionDeployerV2(address(0)), "", new uint256[](0)), - abi.encode(address(proxy)) + abi.encode(iRefundoor) ) ) ); @@ -71,7 +64,6 @@ contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest { vm.assume(minimumOutput > mintAmount); FlashLendingMockOrderBook ob = new FlashLendingMockOrderBook(); - Mock0xProxy proxy = new Mock0xProxy(); RouteProcessorOrderBookV3ArbOrderTaker arb = RouteProcessorOrderBookV3ArbOrderTaker(Clones.clone(iImplementation)); @@ -80,7 +72,7 @@ contract RouteProcessorOrderBookV3ArbOrderTakerTest is ArbTest { OrderBookV3ArbOrderTakerConfigV1( address(ob), EvaluableConfigV2(IExpressionDeployerV2(address(0)), "", new uint256[](0)), - abi.encode(address(proxy)) + abi.encode(iRefundoor) ) ) ); diff --git a/test/util/abstract/ArbTest.sol b/test/util/abstract/ArbTest.sol index 795490a76..8d3e2b7ed 100644 --- a/test/util/abstract/ArbTest.sol +++ b/test/util/abstract/ArbTest.sol @@ -8,6 +8,7 @@ import {DeployerDiscoverableMetaV2ConstructionConfig} from "rain.interpreter/src/abstract/DeployerDiscoverableMetaV2.sol"; import {IExpressionDeployerV2} from "rain.interpreter/src/interface/unstable/IExpressionDeployerV2.sol"; import "openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; +import "test/util/concrete/Refundoor.sol"; contract Token is ERC20 { constructor() ERC20("Token", "TKN") {} @@ -27,12 +28,14 @@ abstract contract ArbTest is Test { address immutable iImplementation; Token immutable iTakerInput; Token immutable iTakerOutput; + address immutable iRefundoor; constructor(ArbTestConstructorConfig memory config) { iDeployer = config.deployer; iImplementation = config.implementation; iTakerInput = new Token(); iTakerOutput = new Token(); + iRefundoor = address(new Refundoor()); } function buildConstructorConfig(string memory metaPath) diff --git a/test/util/concrete/Refundoor.sol b/test/util/concrete/Refundoor.sol new file mode 100644 index 000000000..d60874639 --- /dev/null +++ b/test/util/concrete/Refundoor.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: CAL +pragma solidity =0.8.19; + +import "openzeppelin-contracts/contracts/utils/Address.sol"; + +contract Refundoor { + fallback() external { + Address.sendValue(payable(msg.sender), address(this).balance); + } +}