diff --git a/.gas-snapshot b/.gas-snapshot index 1a15068f5..e8f6c4669 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,239 +1,237 @@ -GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 5108, μ: 364548, ~: 363555) -GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 5108, μ: 160657, ~: 159645) -GenericPoolOrderBookV4ArbOrderTakerSenderTest:testGenericPoolMinimumOutput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5108, μ: 296404, ~: 295241) -GenericPoolOrderBookV4ArbOrderTakerSenderTest:testGenericPoolTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5108, μ: 251218, ~: 249876) -GenericPoolOrderBookV4FlashBorrowerTest:testGenericPoolOrderBookV4FlashBorrowerMinimumOutput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5108, μ: 495646, ~: 492574) -GenericPoolOrderBookV4FlashBorrowerTest:testGenericPoolOrderBookV4FlashBorrowerTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5108, μ: 449478, ~: 446089) -LibOrderTest:testHashEqual((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 5108, μ: 199682, ~: 196369) -LibOrderTest:testHashNotEqual((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 5108, μ: 302795, ~: 302032) -OrderBookAddOrderEnactTest:testAddLiveOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 914161, ~: 902996) -OrderBookAddOrderEnactTest:testAddLiveOrderRevertNoAdd(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 715113, ~: 706575) -OrderBookAddOrderEnactTest:testAddOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1016936, ~: 1006873) -OrderBookAddOrderEnactTest:testAddOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 640572, ~: 632416) -OrderBookAddOrderEnactTest:testAddOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 699000, ~: 690841) -OrderBookAddOrderEnactTest:testAddOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 688070, ~: 679911) -OrderBookAddOrderEnactTest:testAddOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 3062291, ~: 3055050) -OrderBookAddOrderEnactTest:testAddOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 923580, ~: 915410) -OrderBookAddOrderEnactTest:testAddOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1322322, ~: 1307883) -OrderBookAddOrderMockTest:testAddOrderSameAccountWithDifferentConfig(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,bytes) (runs: 5108, μ: 2579974, ~: 2572953) -OrderBookAddOrderMockTest:testAddOrderTwoAccountsWithDifferentConfig(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,bytes) (runs: 5108, μ: 2461275, ~: 2456303) -OrderBookAddOrderMockTest:testAddOrderTwoAccountsWithSameConfig(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 2325905, ~: 2307743) -OrderBookAddOrderMockTest:testAddOrderWithCalculationsInputsAndOutputsSucceeds(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 1194015, ~: 1173744) -OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaEmitsMetaV1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 1202217, ~: 1182463) -OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 668713, ~: 659383) -OrderBookAddOrderMockTest:testAddOrderWithoutCalculationsDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 658525, ~: 650005) -OrderBookAddOrderMockTest:testAddOrderWithoutInputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 157101, ~: 156228) -OrderBookAddOrderMockTest:testAddOrderWithoutOutputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 157521, ~: 156371) -OrderBookAddOrderNonceTest:testAddOrderNonceDifferentNonceStateChange(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes32) (runs: 5108, μ: 1222168, ~: 1213114) -OrderBookAddOrderNonceTest:testAddOrderNonceSameNonceDifferentOrderStateChange(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1455284, ~: 1450041) -OrderBookAddOrderNonceTest:testAddOrderNonceSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 943936, ~: 930835) -OrderBookAddOrderOwnerTest:testAddOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 5108, μ: 1214089, ~: 1213666) -OrderBookAddOrderOwnerTest:testAddOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 944032, ~: 930931) -OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 640893, ~: 632736) -OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts2(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 642710, ~: 634553) -OrderBookAddOrderTest:testAddOrderRealCalculateInputsRevertsPreference(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 642211, ~: 634054) -OrderBookAddOrderTest:testAddOrderRealNoHandleIODeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 633168, ~: 625011) -OrderBookAddOrderTest:testAddOrderRealNoSourcesDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 612706, ~: 604550) -OrderBookAddOrderTest:testAddOrderRealOneStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 645143, ~: 636986) -OrderBookAddOrderTest:testAddOrderRealThreeStackCalculate(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 657571, ~: 649414) -OrderBookAddOrderTest:testAddOrderRealTwoStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 651268, ~: 643111) -OrderBookAddOrderTest:testAddOrderRealZeroStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 639597, ~: 631440) -OrderBookClearHandleIORevertTest:testClearOrderAliceNoHandleIORevert() (gas: 501293) -OrderBookClearHandleIORevertTest:testClearOrderBobNoHandleIORevert() (gas: 501272) -OrderBookClearHandleIORevertTest:testClearOrderBothNoHandleIORevert() (gas: 481271) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO0() (gas: 534351) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO1() (gas: 529715) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO2() (gas: 529834) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO3() (gas: 534395) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO4() (gas: 544024) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO5() (gas: 507401) -OrderBookClearOrderBadStackTest:testClearOrderBadStackEmptyStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2298365, ~: 2299737) -OrderBookClearOrderBadStackTest:testClearOrderBadStackOneEmpty(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2382630, ~: 2383540) -OrderBookClearOrderBadStackTest:testClearOrderBadStackOneOne(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2389689, ~: 2390604) -OrderBookClearOrderBadStackTest:testClearOrderBadStackOneOtherOne(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2318255, ~: 2319627) -OrderBookClearOrderBadStackTest:testClearOrderBadStackOneStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2311881, ~: 2313253) -OrderBookClearOrderBadStackTest:testClearOrderBadStackOtherEmpty(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2311245, ~: 2312607) -OrderBookClearOrderContextTest:testContextEmptyStack(address,address,uint256,uint256,uint256,uint256) (runs: 5108, μ: 2058476, ~: 2059489) -OrderBookClearTest:testClearSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256,bytes,address,uint256,uint256) (runs: 5108, μ: 518584, ~: 517984) -OrderBookClearTest:testFlashLoanToNonReceiver(uint256,bytes,bytes32,bytes) (runs: 5108, μ: 26163, ~: 26154) -OrderBookDepositEnactTest:testDepositRevertInAction(address,uint256,uint256) (runs: 5108, μ: 94311, ~: 94311) -OrderBookDepositEnactTest:testOrderBookDepositEnactEmptyNoop(address,uint256,uint256) (runs: 5108, μ: 41047, ~: 41047) -OrderBookDepositEnactTest:testOrderBookDepositEnactOneReadState(address,uint256,uint256) (runs: 5108, μ: 101319, ~: 101319) -OrderBookDepositEnactTest:testOrderBookDepositEnactOneStateless(address,uint256,uint256) (runs: 5108, μ: 90425, ~: 90425) -OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256) (runs: 5108, μ: 925173, ~: 924944) -OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSequential(address,uint256,uint256) (runs: 5108, μ: 572302, ~: 572076) -OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSingle(address,uint256,uint256) (runs: 5108, μ: 206376, ~: 206150) -OrderBookDepositEnactTest:testOrderDepositContext(address,uint256,uint256,uint256) (runs: 5108, μ: 809491, ~: 810169) -OrderBookDepositTest:testDepositEvent(address,uint256,uint256) (runs: 5108, μ: 38853, ~: 38853) -OrderBookDepositTest:testDepositFail(address,uint256,uint256) (runs: 5108, μ: 1040440701, ~: 1040440664) -OrderBookDepositTest:testDepositGas00() (gas: 8771) -OrderBookDepositTest:testDepositGas01() (gas: 35148) -OrderBookDepositTest:testDepositMany((address,address,uint256,uint248)[]) (runs: 5097, μ: 2479134, ~: 1708734) -OrderBookDepositTest:testDepositOverflow(address,uint256,uint256,uint256) (runs: 5108, μ: 51608, ~: 51929) -OrderBookDepositTest:testDepositReentrancy(address,uint256,uint256,address,uint256,uint256) (runs: 5108, μ: 606377, ~: 606775) -OrderBookDepositTest:testDepositSimple(address,uint256,uint256) (runs: 5108, μ: 38105, ~: 38105) -OrderBookDepositTest:testDepositZero(address,uint256) (runs: 5108, μ: 12924, ~: 12924) -OrderBookDepositTest:testVaultBalanceNoDeposits(address,uint256) (runs: 5108, μ: 8938, ~: 8938) -OrderBookEnactTest:testOrderBookEvalEmptyNoop(address) (runs: 5108, μ: 14063, ~: 14063) -OrderBookEnactTest:testOrderBookEvalOneReadState(address) (runs: 5108, μ: 71033, ~: 71033) -OrderBookEnactTest:testOrderBookEvalOneStateless(address) (runs: 5108, μ: 60115, ~: 60115) -OrderBookEnactTest:testOrderBookEvalWriteStateDifferentOwnersNamespaced(address,address) (runs: 5108, μ: 831324, ~: 831324) -OrderBookEnactTest:testOrderBookEvalWriteStateSequential() (gas: 519879) -OrderBookEnactTest:testOrderBookEvalWriteStateSingle(address) (runs: 5108, μ: 165041, ~: 165041) -OrderBookQuoteTest:testQuoteContextSender(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 5108, μ: 10167185, ~: 10064132) -OrderBookQuoteTest:testQuoteDeadOrder(((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)[])) (runs: 5108, μ: 6663419, ~: 5832695) -OrderBookQuoteTest:testQuoteMaxOutput(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 5108, μ: 1108902, ~: 1096998) -OrderBookQuoteTest:testQuoteSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 5108, μ: 1102322, ~: 1090401) -OrderBookRemoveOrderEnactTest:testRemoveOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 645135, ~: 638606) -OrderBookRemoveOrderEnactTest:testRemoveOrderDeadOrder(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 354707, ~: 350017) -OrderBookRemoveOrderEnactTest:testRemoveOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1080804, ~: 1066445) -OrderBookRemoveOrderEnactTest:testRemoveOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1139439, ~: 1125079) -OrderBookRemoveOrderEnactTest:testRemoveOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1128561, ~: 1114201) -OrderBookRemoveOrderEnactTest:testRemoveOrderRevertInAction(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1265141, ~: 1248808) -OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 4830163, ~: 4817389) -OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 1364947, ~: 1350575) -OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 2203262, ~: 2176419) -OrderBookRemoveOrderMockTest:testRemoveOrderAddRemoveMulti(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 6809007, ~: 6662571) -OrderBookRemoveOrderMockTest:testRemoveOrderDifferent(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 4771475, ~: 4707793) -OrderBookRemoveOrderMockTest:testRemoveOrderDifferentOwners(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 4605540, ~: 4556938) -OrderBookRemoveOrderMockTest:testRemoveOrderDifferentOwnersDifferent(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 9901135, ~: 9779715) -OrderBookRemoveOrderMockTest:testRemoveOrderDoesNotExist(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 374485, ~: 368808) -OrderBookRemoveOrderMockTest:testRemoveOrderOnlyOwner(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5108, μ: 2473575, ~: 2452298) -OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 5108, μ: 5915110, ~: 5838087) -OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 3398031, ~: 3339431) -OrderBookRemoveOrderOwnerTest:testRemoveOrderWrongOwner(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 5108, μ: 758239, ~: 757542) -OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextHappy() (gas: 2190404) -OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169061) -OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155576) -OrderBookSubParserContextCalculatedMaxOutputTest:testSubParserContextHappy() (gas: 2190731) -OrderBookSubParserContextCalculatedMaxOutputTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169384) -OrderBookSubParserContextCalculatedMaxOutputTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155903) -OrderBookSubParserContextInputTokenDecimalsTest:testSubParserContextHappy() (gas: 2190570) -OrderBookSubParserContextInputTokenDecimalsTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169223) -OrderBookSubParserContextInputTokenDecimalsTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155741) -OrderBookSubParserContextInputTokenTest:testSubParserContextHappy() (gas: 2189107) -OrderBookSubParserContextInputTokenTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2167761) -OrderBookSubParserContextInputTokenTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154280) -OrderBookSubParserContextInputVaultBalanceIncreaseTest:testSubParserContextHappy() (gas: 2190570) -OrderBookSubParserContextInputVaultBalanceIncreaseTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169223) -OrderBookSubParserContextInputVaultBalanceIncreaseTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155741) -OrderBookSubParserContextOrderBookTest:testSubParserContextHappy() (gas: 2188783) -OrderBookSubParserContextOrderBookTest:testSubParserContextHappy() (gas: 2189594) -OrderBookSubParserContextOrderBookTest:testSubParserContextHappy() (gas: 2189756) -OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2167437) -OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2168248) -OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2168410) -OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2153956) -OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154766) -OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154928) -OrderBookSubParserContextOrderClearerTest:testSubParserContextHappy() (gas: 2189431) -OrderBookSubParserContextOrderClearerTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2168085) -OrderBookSubParserContextOrderClearerTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154604) -OrderBookSubParserContextOrderCounterpartyTest:testSubParserContextHappy() (gas: 2190242) -OrderBookSubParserContextOrderCounterpartyTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2168899) -OrderBookSubParserContextOrderCounterpartyTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155414) -OrderBookSubParserContextOrderHashTest:testSubParserContextHappy() (gas: 2188945) -OrderBookSubParserContextOrderHashTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2167599) -OrderBookSubParserContextOrderHashTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154118) -OrderBookSubParserContextOrderOwnerTest:testSubParserContextHappy() (gas: 2189108) -OrderBookSubParserContextOrderOwnerTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2167762) -OrderBookSubParserContextOrderOwnerTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154280) -OrderBookSubParserContextOutputTokenDecimalsTest:testSubParserContextHappy() (gas: 2190732) -OrderBookSubParserContextOutputTokenDecimalsTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169385) -OrderBookSubParserContextOutputTokenDecimalsTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155903) -OrderBookSubParserContextOutputTokenTest:testSubParserContextHappy() (gas: 2189269) -OrderBookSubParserContextOutputTokenTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2167923) -OrderBookSubParserContextOutputTokenTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2154442) -OrderBookSubParserContextOutputVaultBalanceBeforeTest:testSubParserContextHappy() (gas: 2190404) -OrderBookSubParserContextOutputVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169061) -OrderBookSubParserContextOutputVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155576) -OrderBookSubParserContextOutputVaultBalanceDecreaseTest:testSubParserContextHappy() (gas: 2190732) -OrderBookSubParserContextOutputVaultBalanceDecreaseTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2169385) -OrderBookSubParserContextOutputVaultBalanceDecreaseTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155903) -OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextHappy() (gas: 2190242) -OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2168899) -OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2155414) -OrderBookSubParserDescribedByMetaV1Test:testOrderBookSubParserDescribedByMetaV1Happy() (gas: 2107037) -OrderBookSubParserIERC165Test:testOrderBookSubParserIERC165(bytes4) (runs: 5108, μ: 2110113, ~: 2110113) -OrderBookSubParserPointersTest:testSubParserFunctionPointers() (gas: 2121602) -OrderBookSubParserPointersTest:testSubParserOperandParsers() (gas: 2121602) -OrderBookSubParserPointersTest:testSubParserParseMeta() (gas: 254036) -OrderBookSubParserPointersTest:testWordOperandLengthEquivalence() (gas: 4098) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy0() (gas: 2195800) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy1() (gas: 2195834) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy2() (gas: 2195835) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy3() (gas: 2195957) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextUnhappyInput() (gas: 2174344) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextUnhappyNoOperand() (gas: 2151658) -OrderBookSubParserSignedContextTest:testSubParserContextSignedContextUnhappyTooManyOperands() (gas: 2160553) -OrderBookSubParserSignersTest:testSubParserContextSignerHappy0() (gas: 2191256) -OrderBookSubParserSignersTest:testSubParserContextSignerHappy1() (gas: 2191312) -OrderBookSubParserSignersTest:testSubParserContextSignerUnhappyInput() (gas: 2169797) -OrderBookSubParserSignersTest:testSubParserContextSignerUnhappyNoOperand() (gas: 2150334) -OrderBookSubParserSignersTest:testSubParserContextSignerUnhappyTooManyOperands() (gas: 2156254) -OrderBookTakeOrderBadStackTest:testTakeOrderBadStackEmptyStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 939878, ~: 935548) -OrderBookTakeOrderBadStackTest:testTakeOrderBadStackOneStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 946573, ~: 942243) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO0() (gas: 229757) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO1() (gas: 387348) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO10(uint256) (runs: 5108, μ: 615496, ~: 578476) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO2() (gas: 400742) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO3() (gas: 538649) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO4() (gas: 555540) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO5() (gas: 555539) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO6() (gas: 542186) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO7(uint256) (runs: 5108, μ: 788395, ~: 788356) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO8(uint256) (runs: 5108, μ: 940102, ~: 940062) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO9(uint256) (runs: 5108, μ: 697951, ~: 629175) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert0() (gas: 224599) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert1() (gas: 375661) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert2() (gas: 362312) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrders(uint256,uint256) (runs: 5108, μ: 394878, ~: 405610) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrdersMultipleOwners(uint256,uint256,uint256) (runs: 5108, μ: 449781, ~: 462377) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleAnyDeposit(uint256,uint256) (runs: 5108, μ: 248164, ~: 250417) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumInput(uint256,uint256) (runs: 5108, μ: 230806, ~: 231998) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumOutput(uint256) (runs: 5108, μ: 230399, ~: 230357) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderUnlimitedMax(uint256) (runs: 5108, μ: 228250, ~: 228026) -OrderBookTakeOrderMaximumInputTest:testTakeOrderNoopZeroMaxTakerInput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,uint256[],bytes)) (runs: 5108, μ: 184639, ~: 184719) -OrderBookTakeOrderNoopTest:testTakeOrderNoopNonLiveOrderOne((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)) (runs: 5108, μ: 424745, ~: 422709) -OrderBookTakeOrderNoopTest:testTakeOrderNoopNonLiveOrderTwo((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256,(address,uint256[],bytes),(address,uint256[],bytes)) (runs: 5108, μ: 851264, ~: 847042) -OrderBookTakeOrderNoopTest:testTakeOrderNoopZeroOrders() (gas: 12341) -OrderBookTakeOrderPrecisionTest:testTakeOrderPrecisionKnownBad01() (gas: 2120482) -OrderBookTakeOrderTokenMismatchDecimalsTest:testTokenMismatchInputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5108, μ: 613785, ~: 609484) -OrderBookTakeOrderTokenMismatchDecimalsTest:testTokenMismatchOutputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5108, μ: 615268, ~: 611651) -OrderBookTakeOrderTokenMismatchTest:testTokenMismatchInputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5108, μ: 612692, ~: 611023) -OrderBookTakeOrderTokenMismatchTest:testTokenMismatchOutputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5108, μ: 613956, ~: 612339) -OrderBookV4ArbOrderTakerIERC165Test:testOrderBookV4ArbOrderTakerIERC165(bytes4) (runs: 5108, μ: 1977114, ~: 1977114) -OrderBookV4FlashBorrowerIERC165Test:testOrderBookV4FlashBorrowerIERC165(bytes4) (runs: 5108, μ: 2490318, ~: 2490318) -OrderBookV4FlashLenderFeeTest:testFlashFee(address,uint256) (runs: 5108, μ: 6573, ~: 6573) -OrderBookV4FlashLenderIERC165Test:testOrderBookV4FlashLenderIERC165(bytes4) (runs: 5108, μ: 563157, ~: 563157) -OrderBookV4FlashLenderMaxFlashLoanTest:testFlashMaxLoan(uint256) (runs: 5108, μ: 7744, ~: 7744) -OrderBookV4FlashLenderMockSuccessTest:testFlashLoanToReceiver(uint256,bytes) (runs: 5108, μ: 13564, ~: 13557) -OrderBookV4FlashLenderReentrant:testReenterAddOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 18624420, ~: 18599593) -OrderBookV4FlashLenderReentrant:testReenterCheckOrderExists(bytes32,uint256) (runs: 5108, μ: 535399, ~: 535614) -OrderBookV4FlashLenderReentrant:testReenterClear(uint256,address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 37650938, ~: 37548644) -OrderBookV4FlashLenderReentrant:testReenterDeposit(uint256,uint256,uint256) (runs: 5108, μ: 635660, ~: 636074) -OrderBookV4FlashLenderReentrant:testReenterReadVaultBalances(uint256,uint256) (runs: 5108, μ: 580236, ~: 580599) -OrderBookV4FlashLenderReentrant:testReenterRemoveOrder(uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 5108, μ: 18055022, ~: 17982604) -OrderBookV4FlashLenderReentrant:testReenterTakeOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5108, μ: 19199000, ~: 19169665) -OrderBookV4FlashLenderReentrant:testReenterWithdraw(uint256,uint256,uint256) (runs: 5108, μ: 612338, ~: 612752) -OrderBookV4FlashLenderTransferTest:testFlashLoanTransferFail(uint256,uint256,bool) (runs: 5108, μ: 1315070, ~: 1314004) -OrderBookV4FlashLenderTransferTest:testFlashLoanTransferSuccess(uint256,bool) (runs: 5108, μ: 1261028, ~: 1267965) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalEmptyNoop(address,uint256,uint256,uint256) (runs: 5108, μ: 52132, ~: 52592) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneReadState(address,uint256,uint256,uint256) (runs: 5108, μ: 112536, ~: 113358) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneStateless(address,uint256,uint256,uint256) (runs: 5108, μ: 101641, ~: 102463) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256,uint256) (runs: 5108, μ: 957760, ~: 959248) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSequential(address,uint256,uint256,uint256) (runs: 5108, μ: 589806, ~: 590627) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSingle(address,uint256,uint256,uint256) (runs: 5108, μ: 222094, ~: 222915) -OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalRevertInAction(address,uint256,uint256,uint256) (runs: 5108, μ: 105270, ~: 106092) -OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalZeroAmountEvalNoop(address,uint256,uint256) (runs: 5108, μ: 57930, ~: 57699) -OrderBookWithdrawEvalTest:testOrderWithdrawContext(address,uint256,uint256,uint256) (runs: 5108, μ: 963970, ~: 960739) -OrderBookWithdrawTest:testWithdrawEmptyVault(address,address,uint256,uint256) (runs: 5108, μ: 17492, ~: 17492) -OrderBookWithdrawTest:testWithdrawFailure(address,uint256,uint256,uint256) (runs: 5108, μ: 1040417244, ~: 1040398271) -OrderBookWithdrawTest:testWithdrawFullVault(address,uint256,uint256,uint256) (runs: 5101, μ: 39862, ~: 39848) -OrderBookWithdrawTest:testWithdrawMany((bool,address,address,uint256,uint248)[]) (runs: 5108, μ: 3133203, ~: 3125728) -OrderBookWithdrawTest:testWithdrawPartialVault(address,uint256,uint256,uint256) (runs: 5103, μ: 50202, ~: 50202) -OrderBookWithdrawTest:testWithdrawZero(address,address,uint256) (runs: 5108, μ: 13038, ~: 13038) -RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 5108, μ: 364592, ~: 363612) -RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 5108, μ: 160677, ~: 159681) -RouteProcessorOrderBookV4ArbOrderTakerSenderTest:testRouteProcessorMinimumOutput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5108, μ: 296534, ~: 295366) -RouteProcessorOrderBookV4ArbOrderTakerSenderTest:testRouteProcessorTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5108, μ: 251374, ~: 250031) \ No newline at end of file +GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 5098, μ: 414799, ~: 414130) +GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 5098, μ: 163339, ~: 162325) +GenericPoolOrderBookV4ArbOrderTakerSenderTest:testGenericPoolTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5098, μ: 265146, ~: 263786) +GenericPoolOrderBookV4FlashBorrowerTest:testGenericPoolOrderBookV4FlashBorrowerTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5098, μ: 505100, ~: 501748) +LibOrderTest:testHashEqual((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 5098, μ: 200019, ~: 196561) +LibOrderTest:testHashNotEqual((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 5098, μ: 303167, ~: 302381) +OrderBookAddOrderEnactTest:testAddLiveOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 918953, ~: 907494) +OrderBookAddOrderEnactTest:testAddLiveOrderRevertNoAdd(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 719260, ~: 710511) +OrderBookAddOrderEnactTest:testAddOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1026268, ~: 1016050) +OrderBookAddOrderEnactTest:testAddOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 642023, ~: 633667) +OrderBookAddOrderEnactTest:testAddOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 702775, ~: 694416) +OrderBookAddOrderEnactTest:testAddOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 688123, ~: 679764) +OrderBookAddOrderEnactTest:testAddOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 3104764, ~: 3097313) +OrderBookAddOrderEnactTest:testAddOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 936582, ~: 928211) +OrderBookAddOrderEnactTest:testAddOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1330963, ~: 1316168) +OrderBookAddOrderMockTest:testAddOrderSameAccountWithDifferentConfig(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,bytes) (runs: 5098, μ: 2690435, ~: 2683845) +OrderBookAddOrderMockTest:testAddOrderTwoAccountsWithDifferentConfig(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,bytes) (runs: 5098, μ: 2573014, ~: 2568129) +OrderBookAddOrderMockTest:testAddOrderTwoAccountsWithSameConfig(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 2437645, ~: 2418681) +OrderBookAddOrderMockTest:testAddOrderWithCalculationsInputsAndOutputsSucceeds(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 1248121, ~: 1229414) +OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaEmitsMetaV1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 1257410, ~: 1237498) +OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 670685, ~: 661444) +OrderBookAddOrderMockTest:testAddOrderWithoutCalculationsDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 659815, ~: 651084) +OrderBookAddOrderMockTest:testAddOrderWithoutInputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 157582, ~: 156760) +OrderBookAddOrderMockTest:testAddOrderWithoutOutputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 158066, ~: 156903) +OrderBookAddOrderNonceTest:testAddOrderNonceDifferentNonceStateChange(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes32) (runs: 5098, μ: 1225000, ~: 1217394) +OrderBookAddOrderNonceTest:testAddOrderNonceSameNonceDifferentOrderStateChange(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1459125, ~: 1453757) +OrderBookAddOrderNonceTest:testAddOrderNonceSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 946591, ~: 933192) +OrderBookAddOrderOwnerTest:testAddOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 5098, μ: 1216691, ~: 1216089) +OrderBookAddOrderOwnerTest:testAddOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 946687, ~: 933288) +OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 644191, ~: 635834) +OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts2(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 645974, ~: 637617) +OrderBookAddOrderTest:testAddOrderRealCalculateInputsRevertsPreference(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 645537, ~: 637180) +OrderBookAddOrderTest:testAddOrderRealNoHandleIODeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 636273, ~: 627916) +OrderBookAddOrderTest:testAddOrderRealNoSourcesDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 613944, ~: 605588) +OrderBookAddOrderTest:testAddOrderRealOneStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 648501, ~: 640144) +OrderBookAddOrderTest:testAddOrderRealThreeStackCalculate(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 661103, ~: 652746) +OrderBookAddOrderTest:testAddOrderRealTwoStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 654745, ~: 646388) +OrderBookAddOrderTest:testAddOrderRealZeroStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 642911, ~: 634554) +OrderBookClearHandleIORevertTest:testClearOrderAliceNoHandleIORevert() (gas: 520609) +OrderBookClearHandleIORevertTest:testClearOrderBobNoHandleIORevert() (gas: 520610) +OrderBookClearHandleIORevertTest:testClearOrderBothNoHandleIORevert() (gas: 499936) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO0() (gas: 560831) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO1() (gas: 552774) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO2() (gas: 552982) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO3() (gas: 560875) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO4() (gas: 568740) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO5() (gas: 526338) +OrderBookClearOrderBadStackTest:testClearOrderBadStackEmptyStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2308778, ~: 2309858) +OrderBookClearOrderBadStackTest:testClearOrderBadStackOneEmpty(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2394422, ~: 2397339) +OrderBookClearOrderBadStackTest:testClearOrderBadStackOneOne(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2402165, ~: 2405083) +OrderBookClearOrderBadStackTest:testClearOrderBadStackOneOtherOne(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2329938, ~: 2331022) +OrderBookClearOrderBadStackTest:testClearOrderBadStackOneStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2323511, ~: 2324595) +OrderBookClearOrderBadStackTest:testClearOrderBadStackOtherEmpty(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2322267, ~: 2323355) +OrderBookClearOrderContextTest:testContextEmptyStack(address,address,uint256,uint256,uint256,uint256) (runs: 5098, μ: 2176637, ~: 2177740) +OrderBookClearTest:testClearSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256,bytes,address,uint256,uint256) (runs: 5098, μ: 530333, ~: 529545) +OrderBookClearTest:testFlashLoanToNonReceiver(uint256,bytes,bytes32,bytes) (runs: 5098, μ: 28247, ~: 28145) +OrderBookDepositEnactTest:testDepositRevertInAction(address,uint256,uint256) (runs: 5098, μ: 97295, ~: 97295) +OrderBookDepositEnactTest:testOrderBookDepositEnactEmptyNoop(address,uint256,uint256) (runs: 5098, μ: 41751, ~: 41751) +OrderBookDepositEnactTest:testOrderBookDepositEnactOneReadState(address,uint256,uint256) (runs: 5098, μ: 104020, ~: 104020) +OrderBookDepositEnactTest:testOrderBookDepositEnactOneStateless(address,uint256,uint256) (runs: 5098, μ: 89382, ~: 89382) +OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256) (runs: 5098, μ: 959820, ~: 959588) +OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSequential(address,uint256,uint256) (runs: 5098, μ: 594342, ~: 594113) +OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSingle(address,uint256,uint256) (runs: 5098, μ: 212949, ~: 212720) +OrderBookDepositEnactTest:testOrderDepositContext(address,uint256,uint256,uint256) (runs: 5098, μ: 651691, ~: 652102) +OrderBookDepositTest:testDepositEvent(address,uint256,uint256) (runs: 5098, μ: 39527, ~: 39527) +OrderBookDepositTest:testDepositFail(address,uint256,uint256) (runs: 5098, μ: 1040441637, ~: 1040441600) +OrderBookDepositTest:testDepositGas00() (gas: 8940) +OrderBookDepositTest:testDepositGas01() (gas: 35406) +OrderBookDepositTest:testDepositMany((address,address,uint256,uint248)[]) (runs: 5096, μ: 2608801, ~: 1766149) +OrderBookDepositTest:testDepositOverflow(address,uint256,uint256,uint256) (runs: 5097, μ: 53328, ~: 53654) +OrderBookDepositTest:testDepositReentrancy(address,uint256,uint256,address,uint256,uint256) (runs: 5098, μ: 623886, ~: 624277) +OrderBookDepositTest:testDepositSimple(address,uint256,uint256) (runs: 5098, μ: 38760, ~: 38760) +OrderBookDepositTest:testDepositZero(address,uint256) (runs: 5098, μ: 13201, ~: 13201) +OrderBookDepositTest:testVaultBalanceNoDeposits(address,uint256) (runs: 5098, μ: 8947, ~: 8947) +OrderBookEnactTest:testOrderBookEvalEmptyNoop(address) (runs: 5098, μ: 14051, ~: 14051) +OrderBookEnactTest:testOrderBookEvalOneReadState(address) (runs: 5098, μ: 73408, ~: 73408) +OrderBookEnactTest:testOrderBookEvalOneStateless(address) (runs: 5098, μ: 58746, ~: 58746) +OrderBookEnactTest:testOrderBookEvalWriteStateDifferentOwnersNamespaced(address,address) (runs: 5098, μ: 867107, ~: 867107) +OrderBookEnactTest:testOrderBookEvalWriteStateSequential() (gas: 543024) +OrderBookEnactTest:testOrderBookEvalWriteStateSingle(address) (runs: 5098, μ: 170894, ~: 170894) +OrderBookQuoteTest:testQuoteContextSender(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 5098, μ: 10250360, ~: 10145015) +OrderBookQuoteTest:testQuoteDeadOrder(((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)[])) (runs: 5098, μ: 6690092, ~: 5858346) +OrderBookQuoteTest:testQuoteMaxOutput(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 5098, μ: 1116746, ~: 1104627) +OrderBookQuoteTest:testQuoteSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 5098, μ: 1109950, ~: 1097725) +OrderBookRemoveOrderEnactTest:testRemoveOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 659628, ~: 653180) +OrderBookRemoveOrderEnactTest:testRemoveOrderDeadOrder(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 357726, ~: 352918) +OrderBookRemoveOrderEnactTest:testRemoveOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1082921, ~: 1068241) +OrderBookRemoveOrderEnactTest:testRemoveOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1144010, ~: 1129329) +OrderBookRemoveOrderEnactTest:testRemoveOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1129366, ~: 1114685) +OrderBookRemoveOrderEnactTest:testRemoveOrderRevertInAction(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1268373, ~: 1251693) +OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 4878475, ~: 4863634) +OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 1379174, ~: 1364481) +OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 2213534, ~: 2186094) +OrderBookRemoveOrderMockTest:testRemoveOrderAddRemoveMulti(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 7128115, ~: 6977151) +OrderBookRemoveOrderMockTest:testRemoveOrderDifferent(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 4982473, ~: 4919186) +OrderBookRemoveOrderMockTest:testRemoveOrderDifferentOwners(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 4822347, ~: 4771268) +OrderBookRemoveOrderMockTest:testRemoveOrderDifferentOwnersDifferent(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 10331040, ~: 10210350) +OrderBookRemoveOrderMockTest:testRemoveOrderDoesNotExist(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 375408, ~: 369597) +OrderBookRemoveOrderMockTest:testRemoveOrderOnlyOwner(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 5098, μ: 2583139, ~: 2560568) +OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 5098, μ: 5922447, ~: 5846913) +OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 3406001, ~: 3346434) +OrderBookRemoveOrderOwnerTest:testRemoveOrderWrongOwner(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 5098, μ: 759863, ~: 759272) +OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextHappy() (gas: 2102274) +OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080218) +OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065830) +OrderBookSubParserContextCalculatedMaxOutputTest:testSubParserContextHappy() (gas: 2102602) +OrderBookSubParserContextCalculatedMaxOutputTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080542) +OrderBookSubParserContextCalculatedMaxOutputTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2066157) +OrderBookSubParserContextInputTokenDecimalsTest:testSubParserContextHappy() (gas: 2102440) +OrderBookSubParserContextInputTokenDecimalsTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080380) +OrderBookSubParserContextInputTokenDecimalsTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065995) +OrderBookSubParserContextInputTokenTest:testSubParserContextHappy() (gas: 2100978) +OrderBookSubParserContextInputTokenTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2078919) +OrderBookSubParserContextInputTokenTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2064534) +OrderBookSubParserContextInputVaultBalanceIncreaseTest:testSubParserContextHappy() (gas: 2102440) +OrderBookSubParserContextInputVaultBalanceIncreaseTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080380) +OrderBookSubParserContextInputVaultBalanceIncreaseTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065995) +OrderBookSubParserContextOrderBookTest:testSubParserContextHappy() (gas: 2100654) +OrderBookSubParserContextOrderBookTest:testSubParserContextHappy() (gas: 2101464) +OrderBookSubParserContextOrderBookTest:testSubParserContextHappy() (gas: 2101626) +OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2078595) +OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2079405) +OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2079567) +OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2064210) +OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065020) +OrderBookSubParserContextOrderBookTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065182) +OrderBookSubParserContextOrderClearerTest:testSubParserContextHappy() (gas: 2101302) +OrderBookSubParserContextOrderClearerTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2079243) +OrderBookSubParserContextOrderClearerTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2064858) +OrderBookSubParserContextOrderCounterpartyTest:testSubParserContextHappy() (gas: 2102112) +OrderBookSubParserContextOrderCounterpartyTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080056) +OrderBookSubParserContextOrderCounterpartyTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065668) +OrderBookSubParserContextOrderHashTest:testSubParserContextHappy() (gas: 2100816) +OrderBookSubParserContextOrderHashTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2078757) +OrderBookSubParserContextOrderHashTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2064372) +OrderBookSubParserContextOrderOwnerTest:testSubParserContextHappy() (gas: 2100978) +OrderBookSubParserContextOrderOwnerTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2078919) +OrderBookSubParserContextOrderOwnerTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2064534) +OrderBookSubParserContextOutputTokenDecimalsTest:testSubParserContextHappy() (gas: 2102602) +OrderBookSubParserContextOutputTokenDecimalsTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080542) +OrderBookSubParserContextOutputTokenDecimalsTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2066157) +OrderBookSubParserContextOutputTokenTest:testSubParserContextHappy() (gas: 2101140) +OrderBookSubParserContextOutputTokenTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2079081) +OrderBookSubParserContextOutputTokenTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2064696) +OrderBookSubParserContextOutputVaultBalanceBeforeTest:testSubParserContextHappy() (gas: 2102274) +OrderBookSubParserContextOutputVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080218) +OrderBookSubParserContextOutputVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065830) +OrderBookSubParserContextOutputVaultBalanceDecreaseTest:testSubParserContextHappy() (gas: 2102602) +OrderBookSubParserContextOutputVaultBalanceDecreaseTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080542) +OrderBookSubParserContextOutputVaultBalanceDecreaseTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2066157) +OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextHappy() (gas: 2102112) +OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080056) +OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065668) +OrderBookSubParserDescribedByMetaV1Test:testOrderBookSubParserDescribedByMetaV1Happy() (gas: 2018322) +OrderBookSubParserIERC165Test:testOrderBookSubParserIERC165(bytes4) (runs: 5098, μ: 2018691, ~: 2018691) +OrderBookSubParserPointersTest:testSubParserFunctionPointers() (gas: 2029308) +OrderBookSubParserPointersTest:testSubParserOperandParsers() (gas: 2029308) +OrderBookSubParserPointersTest:testSubParserParseMeta() (gas: 172448) +OrderBookSubParserPointersTest:testWordOperandLengthEquivalence() (gas: 4076) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy0() (gas: 2107911) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy1() (gas: 2107946) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy2() (gas: 2107947) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextHappy3() (gas: 2108070) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextUnhappyInput() (gas: 2085743) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextUnhappyNoOperand() (gas: 2061657) +OrderBookSubParserSignedContextTest:testSubParserContextSignedContextUnhappyTooManyOperands() (gas: 2071050) +OrderBookSubParserSignersTest:testSubParserContextSignerHappy0() (gas: 2103198) +OrderBookSubParserSignersTest:testSubParserContextSignerHappy1() (gas: 2103255) +OrderBookSubParserSignersTest:testSubParserContextSignerUnhappyInput() (gas: 2081027) +OrderBookSubParserSignersTest:testSubParserContextSignerUnhappyNoOperand() (gas: 2060334) +OrderBookSubParserSignersTest:testSubParserContextSignerUnhappyTooManyOperands() (gas: 2066585) +OrderBookTakeOrderBadStackTest:testTakeOrderBadStackEmptyStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 945476, ~: 940920) +OrderBookTakeOrderBadStackTest:testTakeOrderBadStackOneStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 952790, ~: 948234) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO0() (gas: 240891) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO1() (gas: 404863) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO10(uint256) (runs: 5098, μ: 647502, ~: 608849) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO2() (gas: 418589) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO3() (gas: 563097) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO4() (gas: 582608) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO5() (gas: 582607) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO6() (gas: 568812) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO7(uint256) (runs: 5098, μ: 827165, ~: 827124) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO8(uint256) (runs: 5098, μ: 985760, ~: 985718) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO9(uint256) (runs: 5098, μ: 734533, ~: 663954) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert0() (gas: 232804) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert1() (gas: 390799) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert2() (gas: 377074) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrders(uint256,uint256) (runs: 5098, μ: 413917, ~: 424640) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrdersMultipleOwners(uint256,uint256,uint256) (runs: 5098, μ: 470108, ~: 482687) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleAnyDeposit(uint256,uint256) (runs: 5098, μ: 259496, ~: 261742) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumInput(uint256,uint256) (runs: 5098, μ: 242216, ~: 243376) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumOutput(uint256) (runs: 5098, μ: 241744, ~: 241704) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderUnlimitedMax(uint256) (runs: 5098, μ: 238736, ~: 238508) +OrderBookTakeOrderMaximumInputTest:testTakeOrderNoopZeroMaxTakerInput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,uint256[],bytes)) (runs: 5098, μ: 185109, ~: 185244) +OrderBookTakeOrderNoopTest:testTakeOrderNoopNonLiveOrderOne((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)) (runs: 5098, μ: 426388, ~: 424494) +OrderBookTakeOrderNoopTest:testTakeOrderNoopNonLiveOrderTwo((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256,(address,uint256[],bytes),(address,uint256[],bytes)) (runs: 5098, μ: 854467, ~: 850191) +OrderBookTakeOrderNoopTest:testTakeOrderNoopZeroOrders() (gas: 12427) +OrderBookTakeOrderPrecisionTest:testTakeOrderPrecisionKnownBad01() (gas: 2221895) +OrderBookTakeOrderTokenMismatchDecimalsTest:testTokenDecimalsMismatchOutputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5098, μ: 617295, ~: 613912) +OrderBookTakeOrderTokenMismatchDecimalsTest:testTokenMismatchInputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5098, μ: 615938, ~: 612089) +OrderBookTakeOrderTokenMismatchTest:testTokenDecimalMismatchOutputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5098, μ: 614040, ~: 612469) +OrderBookTakeOrderTokenMismatchTest:testTokenMismatchInputs((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256,uint256) (runs: 5098, μ: 612768, ~: 611215) +OrderBookV4ArbOrderTakerContextTest:testOrderBookV4ArbOrderTakerContext() (gas: 2602327) +OrderBookV4ArbOrderTakerIERC165Test:testOrderBookV4ArbOrderTakerIERC165(bytes4) (runs: 5098, μ: 2374572, ~: 2374572) +OrderBookV4FlashBorrowerIERC165Test:testOrderBookV4FlashBorrowerIERC165(bytes4) (runs: 5098, μ: 2786827, ~: 2786827) +OrderBookV4FlashLenderFeeTest:testFlashFee(address,uint256) (runs: 5098, μ: 6536, ~: 6536) +OrderBookV4FlashLenderIERC165Test:testOrderBookV4FlashLenderIERC165(bytes4) (runs: 5098, μ: 580452, ~: 580452) +OrderBookV4FlashLenderMaxFlashLoanTest:testFlashMaxLoan(uint256) (runs: 5098, μ: 7981, ~: 7981) +OrderBookV4FlashLenderMockSuccessTest:testFlashLoanToReceiver(uint256,bytes) (runs: 5098, μ: 14786, ~: 14732) +OrderBookV4FlashLenderReentrant:testReenterAddOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 18749924, ~: 18693607) +OrderBookV4FlashLenderReentrant:testReenterCheckOrderExists(bytes32,uint256) (runs: 5098, μ: 553697, ~: 553900) +OrderBookV4FlashLenderReentrant:testReenterClear(uint256,address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 38004449, ~: 37927377) +OrderBookV4FlashLenderReentrant:testReenterDeposit(uint256,uint256,uint256) (runs: 5098, μ: 655149, ~: 655599) +OrderBookV4FlashLenderReentrant:testReenterReadVaultBalances(uint256,uint256) (runs: 5098, μ: 598769, ~: 599187) +OrderBookV4FlashLenderReentrant:testReenterRemoveOrder(uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 5098, μ: 18186416, ~: 18137914) +OrderBookV4FlashLenderReentrant:testReenterTakeOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 5098, μ: 19378697, ~: 19321453) +OrderBookV4FlashLenderReentrant:testReenterWithdraw(uint256,uint256,uint256) (runs: 5098, μ: 631616, ~: 632066) +OrderBookV4FlashLenderTransferTest:testFlashLoanTransferFail(uint256,uint256,bool) (runs: 5098, μ: 1345185, ~: 1344056) +OrderBookV4FlashLenderTransferTest:testFlashLoanTransferSuccess(uint256,bool) (runs: 5098, μ: 1290664, ~: 1297531) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalEmptyNoop(address,uint256,uint256,uint256) (runs: 5098, μ: 53634, ~: 54109) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneReadState(address,uint256,uint256,uint256) (runs: 5098, μ: 115846, ~: 116671) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneStateless(address,uint256,uint256,uint256) (runs: 5098, μ: 101229, ~: 102054) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256,uint256) (runs: 5098, μ: 992910, ~: 994386) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSequential(address,uint256,uint256,uint256) (runs: 5098, μ: 611835, ~: 612659) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSingle(address,uint256,uint256,uint256) (runs: 5098, μ: 229589, ~: 230413) +OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalRevertInAction(address,uint256,uint256,uint256) (runs: 5098, μ: 108833, ~: 109658) +OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalZeroAmountEvalNoop(address,uint256,uint256) (runs: 5098, μ: 60997, ~: 60768) +OrderBookWithdrawEvalTest:testOrderWithdrawContext(address,uint256,uint256,uint256) (runs: 5098, μ: 723218, ~: 721592) +OrderBookWithdrawTest:testWithdrawEmptyVault(address,address,uint256,uint256) (runs: 5098, μ: 17802, ~: 17802) +OrderBookWithdrawTest:testWithdrawFailure(address,uint256,uint256,uint256) (runs: 5098, μ: 1040417757, ~: 1040398990) +OrderBookWithdrawTest:testWithdrawFullVault(address,uint256,uint256,uint256) (runs: 5097, μ: 40862, ~: 40845) +OrderBookWithdrawTest:testWithdrawMany((bool,address,address,uint256,uint248)[]) (runs: 5098, μ: 3240941, ~: 3230705) +OrderBookWithdrawTest:testWithdrawPartialVault(address,uint256,uint256,uint256) (runs: 5097, μ: 51385, ~: 51385) +OrderBookWithdrawTest:testWithdrawZero(address,address,uint256) (runs: 5098, μ: 13382, ~: 13382) +RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 5098, μ: 371115, ~: 370139) +RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 5098, μ: 163363, ~: 162347) +RouteProcessorOrderBookV4ArbOrderTakerSenderTest:testRouteProcessorTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 5098, μ: 265260, ~: 263901) \ No newline at end of file diff --git a/.github/workflows/git-clean.yaml b/.github/workflows/git-clean.yaml index 5d8e779f5..a5ecb4b8d 100644 --- a/.github/workflows/git-clean.yaml +++ b/.github/workflows/git-clean.yaml @@ -14,9 +14,7 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@main # Build metas etc. required to do a correct pointer build. - - run: nix develop -c raindex-prelude - - - run: nix develop -c forge script ./script/BuildPointers.sol + - run: ./pointers.sh # Format the repo after generating pointers so that the pointer files are # formatted too. diff --git a/.github/workflows/rainix.yaml b/.github/workflows/rainix.yaml index a66ef62df..07a4467c3 100644 --- a/.github/workflows/rainix.yaml +++ b/.github/workflows/rainix.yaml @@ -66,18 +66,7 @@ jobs: uses: DeterminateSystems/nix-installer-action@v4 - uses: DeterminateSystems/magic-nix-cache-action@v2 - - run: nix develop -c rainix-sol-prelude - working-directory: lib/rain.interpreter - - run: nix develop -c rainix-rs-prelude - working-directory: lib/rain.interpreter - - run: nix develop -c rainix-sol-prelude - working-directory: lib/rain.interpreter/lib/rain.metadata - - run: nix develop -c rainix-rs-prelude - working-directory: lib/rain.interpreter/lib/rain.metadata - - - run: nix develop -c rainix-sol-prelude - - run: nix develop -c rainix-rs-prelude - - run: nix develop -c raindex-prelude + - run: ./pointers.sh - name: Run ${{ matrix.task }} env: diff --git a/Cargo.lock b/Cargo.lock index 37412d743..18f0309c5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6271,6 +6271,7 @@ version = "0.0.1" dependencies = [ "alloy", "derive_builder 0.20.0", + "httpmock", "reqwest 0.11.27", "serde", "serde_json", diff --git a/crates/settings/Cargo.toml b/crates/settings/Cargo.toml index d90152de2..f48a1f787 100644 --- a/crates/settings/Cargo.toml +++ b/crates/settings/Cargo.toml @@ -16,9 +16,10 @@ serde = { workspace = true, features = ["derive", "rc"] } serde_yaml = { workspace = true } serde_json = { workspace = true } strict-yaml-rust = { workspace = true } -alloy = { workspace = true, features = ["serde"] } +alloy = { workspace = true, features = ["serde", "rand"] } typeshare = { workspace = true } reqwest = { workspace = true } [dev-dependencies] tokio = { workspace = true } +httpmock = "0.7.0" diff --git a/crates/settings/src/config_source.rs b/crates/settings/src/config_source.rs index c3039f29b..a3322b28a 100644 --- a/crates/settings/src/config_source.rs +++ b/crates/settings/src/config_source.rs @@ -205,13 +205,17 @@ impl ConfigSource { #[cfg(test)] mod tests { use super::*; + use httpmock::{Method::GET, MockServer}; + use serde_json::json; #[tokio::test] async fn parse_yaml_into_configstrings() { - let yaml_data = r#" + let mocked_chain_id_server = MockServer::start_async().await; + let yaml_data = format!( + r#" using-networks-from: chainid: - url: https://chainid.network/chains.json + url: {} format: chainid networks: @@ -341,8 +345,36 @@ deployments: scenario: mainScenario order: buyETH -sentry: true"# - .to_string(); +sentry: true"#, + mocked_chain_id_server.url("/json") + ); + + let mocked_chain_id_response = json!([ + { + "name": "Ethereum Mainnet", + "chain": "ETH", + "rpc": ["https://abcd.com/v3/${API_KEY}","https://api.mycryptoapi.com/eth","https://cloudflare-eth.com"], + "nativeCurrency": {"name": "Ether","symbol": "ETH","decimals": 18}, + "infoURL": "https://ethereum.org", + "shortName": "eth", + "chainId": 1, + "networkId": 1 + }, + { + "name": "Polygon Mainnet", + "chain": "Polygon", + "rpc": ["https://polygon-rpc.com/","wss://polygon.drpc.org"], + "nativeCurrency": {"name": "MATIC","symbol": "MATIC","decimals": 18}, + "infoURL": "https://polygon.technology/", + "shortName": "matic", + "chainId": 137, + "networkId": 137 + } + ]); + mocked_chain_id_server.mock(|when, then| { + when.method(GET).path("/json"); + then.json_body_obj(&mocked_chain_id_response); + }); let config = ConfigSource::try_from_string(yaml_data).await.unwrap(); @@ -417,4 +449,39 @@ sentry: true"# assert_eq!(order.deployer, expected_order.deployer); assert_eq!(order.orderbook, expected_order.orderbook); } + + #[tokio::test] + async fn test_remote_chain_configstrings_unhappy() { + let mocked_chain_id_server = MockServer::start_async().await; + let yaml_data = format!( + r#" +using-networks-from: + chainid: + url: {} + format: chainid"#, + mocked_chain_id_server.url("/json") + ); + + let mocked_chain_id_response = json!([ + { + "name": "Ethereum Mainnet", + "chain": "ETH", + "rpc": ["https://abcd.com, wss://abcd.com/ws"], + "nativeCurrency": {"name": "Ether","symbol": "ETH","decimals": 18}, + "infoURL": "https://ethereum.org", + "shortName": "eth", + "chainId": 1, + "networkId": 1 + } + ]); + mocked_chain_id_server.mock(|when, then| { + when.method(GET).path("/json"); + then.json_body_obj(&mocked_chain_id_response); + }); + + let config = ConfigSource::try_from_string(yaml_data) + .await + .expect_err("expected to fail"); + matches!(config, ConfigSourceError::ChainIdError(_)); + } } diff --git a/foundry.toml b/foundry.toml index 68c6c0336..826165d31 100644 --- a/foundry.toml +++ b/foundry.toml @@ -20,8 +20,6 @@ optimizer_runs = 1000000 bytecode_hash = "none" cbor_metadata = false -evm_version = "cancun" - # Build metadata used for testing rain meta aware contracts in this folder rather # than expose ffi to forge. fs_permissions = [ diff --git a/lib/rain.interpreter b/lib/rain.interpreter index 18345a1b8..a29afe65b 160000 --- a/lib/rain.interpreter +++ b/lib/rain.interpreter @@ -1 +1 @@ -Subproject commit 18345a1b86dd89e23630a19fc0e2775716b0361e +Subproject commit a29afe65b34c94b2b6dd9b99bc33061fed5878c6 diff --git a/lib/rain.orderbook.interface b/lib/rain.orderbook.interface index 5f95defc2..c105aa766 160000 --- a/lib/rain.orderbook.interface +++ b/lib/rain.orderbook.interface @@ -1 +1 @@ -Subproject commit 5f95defc22e0c7156d1c59828e483df796179ffd +Subproject commit c105aa7664406d0fa3c25a14861374d490a424f6 diff --git a/pointers.sh b/pointers.sh new file mode 100755 index 000000000..dca03bf46 --- /dev/null +++ b/pointers.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +set -euxo pipefail + +(cd lib/rain.interpreter && nix develop -c rainix-sol-prelude) +(cd lib/rain.interpreter && nix develop -c rainix-rs-prelude) +(cd lib/rain.interpreter && nix develop -c i9r-prelude) +(cd lib/rain.interpreter/lib/rain.metadata && nix develop -c rainix-sol-prelude) +(cd lib/rain.interpreter/lib/rain.metadata && nix develop -c rainix-rs-prelude) + +nix develop -c rainix-sol-prelude +nix develop -c rainix-rs-prelude +nix develop -c raindex-prelude + +nix develop -c forge script script/BuildPointers.sol \ No newline at end of file diff --git a/script/Deploy.sol b/script/Deploy.sol index 9559fdfca..3c7cf41ef 100644 --- a/script/Deploy.sol +++ b/script/Deploy.sol @@ -2,12 +2,12 @@ pragma solidity =0.8.25; import {Script} from "forge-std/Script.sol"; -import {OrderBook, EvaluableV3} from "src/concrete/ob/OrderBook.sol"; +import {OrderBook, EvaluableV3, TaskV1, SignedContextV1} from "src/concrete/ob/OrderBook.sol"; import {OrderBookSubParser} from "src/concrete/parser/OrderBookSubParser.sol"; import {GenericPoolOrderBookV4ArbOrderTaker} from "src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol"; import {RouteProcessorOrderBookV4ArbOrderTaker} from "src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol"; import {GenericPoolOrderBookV4FlashBorrower} from "src/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sol"; -import {OrderBookV4ArbConfigV1} from "src/abstract/OrderBookV4ArbCommon.sol"; +import {OrderBookV4ArbConfigV2} from "src/abstract/OrderBookV4ArbCommon.sol"; import {IMetaBoardV1_2} from "rain.metadata/interface/unstable/IMetaBoardV1_2.sol"; import {LibDescribedByMeta} from "rain.metadata/lib/LibDescribedByMeta.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; @@ -86,23 +86,36 @@ contract Deploy is Script { // Order takers. new GenericPoolOrderBookV4ArbOrderTaker( - OrderBookV4ArbConfigV1( - address(raindex), EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), ""), "" + OrderBookV4ArbConfigV2( + address(raindex), + TaskV1({ + evaluable: EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), hex""), + signedContext: new SignedContextV1[](0) + }), + "" ) ); new RouteProcessorOrderBookV4ArbOrderTaker( - OrderBookV4ArbConfigV1( + OrderBookV4ArbConfigV2( address(raindex), - EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), ""), + TaskV1({ + evaluable: EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), hex""), + signedContext: new SignedContextV1[](0) + }), abi.encode(routeProcessor) ) ); // Flash borrowers. new GenericPoolOrderBookV4FlashBorrower( - OrderBookV4ArbConfigV1( - raindex, EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), ""), "" + OrderBookV4ArbConfigV2( + raindex, + TaskV1({ + evaluable: EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), hex""), + signedContext: new SignedContextV1[](0) + }), + "" ) ); } diff --git a/scripts/build.js b/scripts/build.js index ea76cc457..3dcd2570f 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -6,9 +6,9 @@ fs.writeFileSync( "./cjs.js", '"use strict";\n\nmodule.exports = require("./dist/cjs/index");\n' ); -fs.writeFileSync("./cjs.d.ts", 'export * from "./dist/cjs/index";\n'); +fs.writeFileSync("./cjs.d.ts", 'export * from "./dist/types/index";\n'); fs.writeFileSync("./esm.js", 'export * from "./dist/esm/index";\n'); -fs.writeFileSync("./esm.d.ts", 'export * from "./dist/esm/index";\n'); +fs.writeFileSync("./esm.d.ts", 'export * from "./dist/types/index";\n'); // create dist dir fs.mkdirSync("./dist/cjs", { recursive: true }); @@ -20,7 +20,7 @@ execSync("npm run build-wasm"); // build specified packages and include them in final index file // list of packages to build can be extended by adding new package -// names to the below list +// names to the list below const packages = ["common", "quote"]; for (const package of packages) { execSync(`node scripts/buildPackage ${package}`); diff --git a/src/abstract/OrderBookV4ArbCommon.sol b/src/abstract/OrderBookV4ArbCommon.sol index d10754d51..131848659 100644 --- a/src/abstract/OrderBookV4ArbCommon.sol +++ b/src/abstract/OrderBookV4ArbCommon.sol @@ -7,36 +7,24 @@ import { SourceIndexV2, DEFAULT_STATE_NAMESPACE } from "rain.interpreter.interface/interface/IInterpreterV3.sol"; -import {IOrderBookV4} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; +import {IOrderBookV4, TaskV1} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; import {LibNamespace} from "rain.interpreter.interface/lib/ns/LibNamespace.sol"; import {LibEvaluable} from "rain.interpreter.interface/lib/caller/LibEvaluable.sol"; -/// Thrown when the minimum output for the sender is not met after the arb. -/// @param minimum The minimum output expected by the sender. -/// @param actual The actual output that would be received by the sender. -error MinimumOutput(uint256 minimum, uint256 actual); - -/// Thrown when the stack is not empty after the access control dispatch. -error NonZeroBeforeArbStack(); - -/// Thrown when the lender is not the trusted `OrderBook`. -/// @param badLender The untrusted lender calling `onFlashLoan`. -error BadLender(address badLender); - /// Configuration for an arb contract to construct. /// @param orderBook The `OrderBook` contract to arb against. -/// @param evaluable The `EvaluableV3` to use as a pre-hook for each arb. +/// @param tasks The tasks to use as post for each arb. /// @param implementationData The constructor data for the specific /// implementation of the arb contract. -struct OrderBookV4ArbConfigV1 { +struct OrderBookV4ArbConfigV2 { address orderBook; - EvaluableV3 evaluable; + TaskV1 task; bytes implementationData; } -/// Thrown when the evaluable does not match the expected hash. -error WrongEvaluable(); +/// Thrown when the task does not match the expected hash. +error WrongTask(); /// @dev "Before arb" is evaluated before the flash loan is taken. Ostensibly /// allows for some kind of access control to the arb. @@ -45,36 +33,22 @@ SourceIndexV2 constant BEFORE_ARB_SOURCE_INDEX = SourceIndexV2.wrap(0); abstract contract OrderBookV4ArbCommon { using LibEvaluable for EvaluableV3; - event Construct(address sender, OrderBookV4ArbConfigV1 config); + event Construct(address sender, OrderBookV4ArbConfigV2 config); - bytes32 public immutable iEvaluableHash; + bytes32 public immutable iTaskHash = 0; - constructor(OrderBookV4ArbConfigV1 memory config) { + constructor(OrderBookV4ArbConfigV2 memory config) { // Emit events before any external calls are made. emit Construct(msg.sender, config); - iEvaluableHash = config.evaluable.hash(); + if (config.task.evaluable.bytecode.length != 0) { + iTaskHash = keccak256(abi.encode(config.task)); + } } - modifier onlyValidEvaluable(EvaluableV3 calldata evaluable) { - if (evaluable.hash() != iEvaluableHash) { - revert WrongEvaluable(); - } - if (evaluable.bytecode.length > 0) { - (uint256[] memory stack, uint256[] memory kvs) = evaluable.interpreter.eval3( - evaluable.store, - LibNamespace.qualifyNamespace(DEFAULT_STATE_NAMESPACE, address(this)), - evaluable.bytecode, - BEFORE_ARB_SOURCE_INDEX, - LibContext.build(new uint256[][](0), new SignedContextV1[](0)), - new uint256[](0) - ); - // We don't care about the stack. - (stack); - // Persist any state changes from the expression. - if (kvs.length > 0) { - evaluable.store.set(DEFAULT_STATE_NAMESPACE, kvs); - } + modifier onlyValidTask(TaskV1 memory task) { + if (iTaskHash != bytes32(0) && iTaskHash != keccak256(abi.encode(task))) { + revert WrongTask(); } _; } diff --git a/src/abstract/OrderBookV4ArbOrderTaker.sol b/src/abstract/OrderBookV4ArbOrderTaker.sol index 6b5412a16..6606e2772 100644 --- a/src/abstract/OrderBookV4ArbOrderTaker.sol +++ b/src/abstract/OrderBookV4ArbOrderTaker.sol @@ -16,21 +16,17 @@ import {IOrderBookV4, NoOrders} from "rain.orderbook.interface/interface/IOrderB import { IOrderBookV4, IOrderBookV4ArbOrderTakerV2, - IOrderBookV4OrderTaker + IOrderBookV4OrderTaker, + TaskV1 } from "rain.orderbook.interface/interface/unstable/IOrderBookV4ArbOrderTakerV2.sol"; import {IInterpreterV3, DEFAULT_STATE_NAMESPACE} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; import {TakeOrdersConfigV3} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; -import { - BadLender, - MinimumOutput, - NonZeroBeforeArbStack, - OrderBookV4ArbConfigV1, - EvaluableV3, - OrderBookV4ArbCommon -} from "./OrderBookV4ArbCommon.sol"; +import {OrderBookV4ArbConfigV2, EvaluableV3, OrderBookV4ArbCommon, SignedContextV1} from "./OrderBookV4ArbCommon.sol"; import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol"; +import {LibOrderBook} from "../lib/LibOrderBook.sol"; +import {LibOrderBookArb, NonZeroBeforeArbStack, BadLender} from "../lib/LibOrderBookArb.sol"; /// Thrown when "before arb" wants inputs that we don't have. error NonZeroBeforeArbInputs(uint256 inputs); @@ -47,7 +43,7 @@ abstract contract OrderBookV4ArbOrderTaker is { using SafeERC20 for IERC20; - constructor(OrderBookV4ArbConfigV1 memory config) OrderBookV4ArbCommon(config) {} + constructor(OrderBookV4ArbConfigV2 memory config) OrderBookV4ArbCommon(config) {} /// @inheritdoc IERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { @@ -56,12 +52,12 @@ abstract contract OrderBookV4ArbOrderTaker is } /// @inheritdoc IOrderBookV4ArbOrderTakerV2 - function arb3( - IOrderBookV4 orderBook, - TakeOrdersConfigV3 calldata takeOrders, - uint256 minimumSenderOutput, - EvaluableV3 calldata evaluable - ) external payable nonReentrant onlyValidEvaluable(evaluable) { + function arb3(IOrderBookV4 orderBook, TakeOrdersConfigV3 calldata takeOrders, TaskV1 calldata task) + external + payable + nonReentrant + onlyValidTask(task) + { // Mimic what OB would do anyway if called with zero orders. if (takeOrders.orders.length == 0) { revert NoOrders(); @@ -76,27 +72,7 @@ abstract contract OrderBookV4ArbOrderTaker is (totalInput, totalOutput); IERC20(ordersInputToken).safeApprove(address(orderBook), 0); - // Send all unspent input tokens to the sender. - uint256 inputBalance = IERC20(ordersInputToken).balanceOf(address(this)); - if (inputBalance < minimumSenderOutput) { - revert MinimumOutput(minimumSenderOutput, inputBalance); - } - if (inputBalance > 0) { - IERC20(ordersInputToken).safeTransfer(msg.sender, inputBalance); - } - // Send all unspent output tokens to the sender. - uint256 outputBalance = IERC20(ordersOutputToken).balanceOf(address(this)); - if (outputBalance > 0) { - IERC20(ordersOutputToken).safeTransfer(msg.sender, outputBalance); - } - - // Send any remaining gas to the sender. - // Slither false positive here. We want to send everything to the sender - // because this contract should be empty of all gas and tokens between - // uses. Anyone who sends tokens or gas to an arb contract without - // calling `arb` is going to lose their tokens/gas. - // See https://github.com/crytic/slither/issues/1658 - Address.sendValue(payable(msg.sender), address(this).balance); + LibOrderBookArb.finalizeArb(task, ordersInputToken, ordersOutputToken); } /// @inheritdoc IOrderBookV4OrderTaker diff --git a/src/abstract/OrderBookV4FlashBorrower.sol b/src/abstract/OrderBookV4FlashBorrower.sol index 94dc226e4..360ebcc6d 100644 --- a/src/abstract/OrderBookV4FlashBorrower.sol +++ b/src/abstract/OrderBookV4FlashBorrower.sol @@ -12,17 +12,13 @@ import { } from "rain.interpreter.interface/lib/deprecated/caller/LibEncodedDispatch.sol"; import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol"; import {ON_FLASH_LOAN_CALLBACK_SUCCESS} from "rain.orderbook.interface/interface/ierc3156/IERC3156FlashBorrower.sol"; -import {IOrderBookV4, TakeOrdersConfigV3, NoOrders} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; +import {IOrderBookV4, TakeOrdersConfigV3, NoOrders, TaskV1} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; import {IERC3156FlashBorrower} from "rain.orderbook.interface/interface/ierc3156/IERC3156FlashBorrower.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; -import { - BadLender, - MinimumOutput, - NonZeroBeforeArbStack, - OrderBookV4ArbConfigV1, - OrderBookV4ArbCommon -} from "./OrderBookV4ArbCommon.sol"; +import {OrderBookV4ArbConfigV2, OrderBookV4ArbCommon} from "./OrderBookV4ArbCommon.sol"; import {EvaluableV3, SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol"; +import {LibOrderBook} from "../lib/LibOrderBook.sol"; +import {LibOrderBookArb, NonZeroBeforeArbStack, BadLender} from "../lib/LibOrderBookArb.sol"; /// Thrown when the initiator is not the order book. /// @param badInitiator The untrusted initiator of the flash loan. @@ -68,7 +64,7 @@ abstract contract OrderBookV4FlashBorrower is IERC3156FlashBorrower, ReentrancyG using Address for address; using SafeERC20 for IERC20; - constructor(OrderBookV4ArbConfigV1 memory config) OrderBookV4ArbCommon(config) {} + constructor(OrderBookV4ArbConfigV2 memory config) OrderBookV4ArbCommon(config) {} /// @inheritdoc IERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { @@ -130,13 +126,6 @@ abstract contract OrderBookV4FlashBorrower is IERC3156FlashBorrower, ReentrancyG /// sender. /// /// @param takeOrders As per `IOrderBookV4.takeOrders2`. - /// @param minimumSenderOutput The minimum output that must be sent to the - /// sender by the end of the arb call. This, in combination with the - /// orderbook's own asset handling, is expected to REPLACE the standard - /// slippage protection that would be provided by a DEX. The sender is - /// expected to calculate absolute values based on prevailing conditions - /// such as gas price and the risk of holding the assets any arb profit is - /// denominated in. /// @param exchangeData Arbitrary bytes that will be passed to `_exchange` /// after the flash loan is taken. The inheriting contract is responsible /// for decoding this data and defining how it controls interactions with @@ -145,10 +134,9 @@ abstract contract OrderBookV4FlashBorrower is IERC3156FlashBorrower, ReentrancyG function arb3( IOrderBookV4 orderBook, TakeOrdersConfigV3 calldata takeOrders, - uint256 minimumSenderOutput, bytes calldata exchangeData, - EvaluableV3 calldata evaluable - ) external payable nonReentrant onlyValidEvaluable(evaluable) { + TaskV1 calldata task + ) external payable nonReentrant onlyValidTask(task) { // Mimic what OB would do anyway if called with zero orders. if (takeOrders.orders.length == 0) { revert NoOrders(); @@ -175,26 +163,6 @@ abstract contract OrderBookV4FlashBorrower is IERC3156FlashBorrower, ReentrancyG } IERC20(ordersInputToken).safeApprove(address(orderBook), 0); - // Send all unspent input tokens to the sender. - uint256 inputBalance = IERC20(ordersInputToken).balanceOf(address(this)); - if (inputBalance < minimumSenderOutput) { - revert MinimumOutput(minimumSenderOutput, inputBalance); - } - if (inputBalance > 0) { - IERC20(ordersInputToken).safeTransfer(msg.sender, inputBalance); - } - // Send all unspent output tokens to the sender. - uint256 outputBalance = IERC20(ordersOutputToken).balanceOf(address(this)); - if (outputBalance > 0) { - IERC20(ordersOutputToken).safeTransfer(msg.sender, outputBalance); - } - - // Send any remaining gas to the sender. - // Slither false positive here. We want to send everything to the sender - // because the borrower contract should be empty of all gas and tokens - // between uses. Anyone who sends tokens or gas to an arb contract - // without calling `arb` is going to lose their tokens/gas. - // See https://github.com/crytic/slither/issues/1658 - Address.sendValue(payable(msg.sender), address(this).balance); + LibOrderBookArb.finalizeArb(task, ordersInputToken, ordersOutputToken); } } diff --git a/src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol b/src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol index 3c2474877..491bf4326 100644 --- a/src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol +++ b/src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol @@ -5,17 +5,13 @@ import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol"; -import { - OrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1, - MinimumOutput -} from "../../abstract/OrderBookV4ArbOrderTaker.sol"; +import {OrderBookV4ArbOrderTaker, OrderBookV4ArbConfigV2} from "../../abstract/OrderBookV4ArbOrderTaker.sol"; contract GenericPoolOrderBookV4ArbOrderTaker is OrderBookV4ArbOrderTaker { using SafeERC20 for IERC20; using Address for address; - constructor(OrderBookV4ArbConfigV1 memory config) OrderBookV4ArbOrderTaker(config) {} + constructor(OrderBookV4ArbConfigV2 memory config) OrderBookV4ArbOrderTaker(config) {} /// @inheritdoc OrderBookV4ArbOrderTaker function onTakeOrders( diff --git a/src/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sol b/src/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sol index a99af3268..991e8a860 100644 --- a/src/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sol +++ b/src/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sol @@ -6,12 +6,11 @@ import {IERC3156FlashBorrower} from "rain.orderbook.interface/interface/ierc3156 import { OrderBookV4FlashBorrower, - MinimumOutput, SafeERC20, IERC20, Address, TakeOrdersConfigV3, - OrderBookV4ArbConfigV1 + OrderBookV4ArbConfigV2 } from "../../abstract/OrderBookV4FlashBorrower.sol"; /// @title GenericPoolOrderBookV4FlashBorrower @@ -28,7 +27,7 @@ contract GenericPoolOrderBookV4FlashBorrower is OrderBookV4FlashBorrower { using SafeERC20 for IERC20; using Address for address; - constructor(OrderBookV4ArbConfigV1 memory config) OrderBookV4FlashBorrower(config) {} + constructor(OrderBookV4ArbConfigV2 memory config) OrderBookV4FlashBorrower(config) {} /// @inheritdoc OrderBookV4FlashBorrower function _exchange(TakeOrdersConfigV3 memory takeOrders, bytes memory exchangeData) internal virtual override { diff --git a/src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol b/src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol index d6bfc3c5d..c8cad2a52 100644 --- a/src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol +++ b/src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol @@ -6,11 +6,7 @@ import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol"; -import { - OrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1, - MinimumOutput -} from "../../abstract/OrderBookV4ArbOrderTaker.sol"; +import {OrderBookV4ArbOrderTaker, OrderBookV4ArbConfigV2} from "../../abstract/OrderBookV4ArbOrderTaker.sol"; contract RouteProcessorOrderBookV4ArbOrderTaker is OrderBookV4ArbOrderTaker { using SafeERC20 for IERC20; @@ -18,7 +14,7 @@ contract RouteProcessorOrderBookV4ArbOrderTaker is OrderBookV4ArbOrderTaker { IRouteProcessor public immutable iRouteProcessor; - constructor(OrderBookV4ArbConfigV1 memory config) OrderBookV4ArbOrderTaker(config) { + constructor(OrderBookV4ArbConfigV2 memory config) OrderBookV4ArbOrderTaker(config) { (address routeProcessor) = abi.decode(config.implementationData, (address)); iRouteProcessor = IRouteProcessor(routeProcessor); } diff --git a/src/concrete/ob/OrderBook.sol b/src/concrete/ob/OrderBook.sol index c26a30288..fdf7d38d2 100644 --- a/src/concrete/ob/OrderBook.sol +++ b/src/concrete/ob/OrderBook.sol @@ -68,9 +68,7 @@ error ReentrancyGuardReentrantCall(); error NotOrderOwner(address sender, address owner); /// Thrown when the input and output tokens don't match, in either direction. -/// @param aliceToken The input or output of one order. -/// @param bobToken The input or output of the other order that doesn't match a. -error TokenMismatch(address aliceToken, address bobToken); +error TokenMismatch(); /// Thrown when the input and output token decimals don't match, in either /// direction. @@ -443,24 +441,18 @@ contract OrderBook is IOrderBookV4, IMetaV1_2, ReentrancyGuard, Multicall, Order takeOrderConfig = config.orders[i]; order = takeOrderConfig.order; // Every order needs the same input token. - if ( - order.validInputs[takeOrderConfig.inputIOIndex].token - != config.orders[0].order.validInputs[config.orders[0].inputIOIndex].token - ) { - revert TokenMismatch( - order.validInputs[takeOrderConfig.inputIOIndex].token, - config.orders[0].order.validInputs[config.orders[0].inputIOIndex].token - ); - } // Every order needs the same output token. if ( - order.validOutputs[takeOrderConfig.outputIOIndex].token - != config.orders[0].order.validOutputs[config.orders[0].outputIOIndex].token + ( + order.validInputs[takeOrderConfig.inputIOIndex].token + != config.orders[0].order.validInputs[config.orders[0].inputIOIndex].token + ) + || ( + order.validOutputs[takeOrderConfig.outputIOIndex].token + != config.orders[0].order.validOutputs[config.orders[0].outputIOIndex].token + ) ) { - revert TokenMismatch( - order.validOutputs[takeOrderConfig.outputIOIndex].token, - config.orders[0].order.validOutputs[config.orders[0].outputIOIndex].token - ); + revert TokenMismatch(); } // Every order needs the same input token decimals. if ( @@ -623,13 +615,16 @@ contract OrderBook is IOrderBookV4, IMetaV1_2, ReentrancyGuard, Multicall, Order revert SameOwner(aliceOrder.owner); } if ( - aliceOrder.validOutputs[clearConfig.aliceOutputIOIndex].token - != bobOrder.validInputs[clearConfig.bobInputIOIndex].token + ( + aliceOrder.validOutputs[clearConfig.aliceOutputIOIndex].token + != bobOrder.validInputs[clearConfig.bobInputIOIndex].token + ) + || ( + bobOrder.validOutputs[clearConfig.bobOutputIOIndex].token + != aliceOrder.validInputs[clearConfig.aliceInputIOIndex].token + ) ) { - revert TokenMismatch( - aliceOrder.validOutputs[clearConfig.aliceOutputIOIndex].token, - bobOrder.validInputs[clearConfig.bobInputIOIndex].token - ); + revert TokenMismatch(); } if ( @@ -642,16 +637,6 @@ contract OrderBook is IOrderBookV4, IMetaV1_2, ReentrancyGuard, Multicall, Order ); } - if ( - bobOrder.validOutputs[clearConfig.bobOutputIOIndex].token - != aliceOrder.validInputs[clearConfig.aliceInputIOIndex].token - ) { - revert TokenMismatch( - aliceOrder.validInputs[clearConfig.aliceInputIOIndex].token, - bobOrder.validOutputs[clearConfig.bobOutputIOIndex].token - ); - } - if ( bobOrder.validOutputs[clearConfig.bobOutputIOIndex].decimals != aliceOrder.validInputs[clearConfig.aliceInputIOIndex].decimals diff --git a/src/generated/OrderBookSubParser.pointers.sol b/src/generated/OrderBookSubParser.pointers.sol index 9cdc7c8a4..7aa7d534c 100644 --- a/src/generated/OrderBookSubParser.pointers.sol +++ b/src/generated/OrderBookSubParser.pointers.sol @@ -9,7 +9,7 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0xf2c8bcc6888ae6f36e9c20719b8596a95b0f5d3f52030503a340855dc1ef4491); +bytes32 constant BYTECODE_HASH = bytes32(0x890dde7c5bd8253e7e359fa9f7d6e91d299ce7042b67a8e8d9ac08d1d3d3b430); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xdfd338fdf179bf832d2bc3222c6b2ac399d0e341fe38960e1bbd59aa6ccfbf9b); @@ -43,13 +43,13 @@ uint8 constant PARSE_META_BUILD_DEPTH = 1; /// to things that happen entirely on the interpreter such as well known /// constants and references to the context grid. bytes constant SUB_PARSER_WORD_PARSERS = - hex"172e174b175a176917781788179717a717b617c617d617e517f5180418141824183418431852172e175a176917781887172e175a1769177818871897"; + hex"176a1789179a17ab17bb17cc17dd17ee17ff18101821183118421853186418751886189618a6176a179a17ab17bb18dc176a179a17ab17bb18dc18ed"; /// @dev Every two bytes is a function pointer for an operand handler. /// These positional indexes all map to the same indexes looked up in the parse /// meta. bytes constant OPERAND_HANDLER_FUNCTION_POINTERS = - hex"19b419b419b419b419b419b419b419b419b419b419b419b419b419b419b419b419b419f61a8319b419b419b419b419b419b419b419b419b419b419b4"; + hex"1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a521ae11a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d1a0d"; /// @dev Every two bytes is a function pointer for a literal parser. /// Literal dispatches are determined by the first byte(s) of the literal diff --git a/src/lib/LibOrderBook.sol b/src/lib/LibOrderBook.sol index 5b0678d8f..a9a03da6b 100644 --- a/src/lib/LibOrderBook.sol +++ b/src/lib/LibOrderBook.sol @@ -93,16 +93,20 @@ library LibOrderBook { TaskV1 memory task; for (uint256 i = 0; i < post.length; ++i) { task = post[i]; - (uint256[] memory stack, uint256[] memory writes) = task.evaluable.interpreter.eval3( - task.evaluable.store, - LibNamespace.qualifyNamespace(namespace, address(this)), - task.evaluable.bytecode, - SourceIndexV2.wrap(0), - LibContext.build(context, task.signedContext), - new uint256[](0) - ); - (stack); - task.evaluable.store.set(namespace, writes); + if (task.evaluable.bytecode.length > 0) { + (uint256[] memory stack, uint256[] memory writes) = task.evaluable.interpreter.eval3( + task.evaluable.store, + LibNamespace.qualifyNamespace(namespace, address(this)), + task.evaluable.bytecode, + SourceIndexV2.wrap(0), + LibContext.build(context, task.signedContext), + new uint256[](0) + ); + (stack); + if (writes.length > 0) { + task.evaluable.store.set(namespace, writes); + } + } } } } diff --git a/src/lib/LibOrderBookArb.sol b/src/lib/LibOrderBookArb.sol new file mode 100644 index 000000000..6b1120a57 --- /dev/null +++ b/src/lib/LibOrderBookArb.sol @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: CAL +pragma solidity ^0.8.19; + +import {TaskV1} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; +import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; +import {LibOrderBook} from "./LibOrderBook.sol"; +import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol"; +import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol"; +import {LibFixedPointDecimalScale} from "rain.math.fixedpoint/lib/LibFixedPointDecimalScale.sol"; +import {IERC20Metadata} from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol"; + +/// Thrown when the stack is not empty after the access control dispatch. +error NonZeroBeforeArbStack(); + +/// Thrown when the lender is not the trusted `OrderBook`. +/// @param badLender The untrusted lender calling `onFlashLoan`. +error BadLender(address badLender); + +library LibOrderBookArb { + using SafeERC20 for IERC20; + + function finalizeArb(TaskV1 memory task, address ordersInputToken, address ordersOutputToken) internal { + uint256[][] memory context = new uint256[][](1); + uint256[] memory col = new uint256[](3); + + { + // Send all unspent input tokens to the sender. + uint256 inputBalance = IERC20(ordersInputToken).balanceOf(address(this)); + if (inputBalance > 0) { + IERC20(ordersInputToken).safeTransfer(msg.sender, inputBalance); + } + uint256 inputDecimals = IERC20Metadata(ordersInputToken).decimals(); + col[0] = LibFixedPointDecimalScale.scale18( + inputBalance, + inputDecimals, + // Error on overflow. + // Rounding down is the default. + 0 + ); + } + + { + // Send all unspent output tokens to the sender. + uint256 outputBalance = IERC20(ordersOutputToken).balanceOf(address(this)); + if (outputBalance > 0) { + IERC20(ordersOutputToken).safeTransfer(msg.sender, outputBalance); + } + + uint256 outputDecimals = IERC20Metadata(ordersOutputToken).decimals(); + col[1] = LibFixedPointDecimalScale.scale18( + outputBalance, + outputDecimals, + // Error on overflow. + // Rounding down is the default. + 0 + ); + } + + { + // Send any remaining gas to the sender. + // Slither false positive here. We want to send everything to the sender + // because this contract should be empty of all gas and tokens between + // uses. Anyone who sends tokens or gas to an arb contract without + // calling `arb` is going to lose their tokens/gas. + // See https://github.com/crytic/slither/issues/1658 + uint256 gasBalance = address(this).balance; + Address.sendValue(payable(msg.sender), gasBalance); + col[2] = gasBalance; + } + + context[0] = col; + + TaskV1[] memory post = new TaskV1[](1); + post[0] = task; + LibOrderBook.doPost(context, post); + } +} diff --git a/test/abstract/OrderBookV4ArbOrderTaker.context.t.sol b/test/abstract/OrderBookV4ArbOrderTaker.context.t.sol new file mode 100644 index 000000000..941028410 --- /dev/null +++ b/test/abstract/OrderBookV4ArbOrderTaker.context.t.sol @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: CAL +pragma solidity =0.8.25; + +import { + ChildOrderBookV4ArbOrderTaker, + TaskV1, + SignedContextV1, + EvaluableV3 +} from "../util/concrete/ChildOrderBookV4ArbOrderTaker.sol"; +import {OrderBookExternalRealTest} from "../util/abstract/OrderBookExternalRealTest.sol"; +import { + TakeOrdersConfigV3, + TakeOrderConfigV3, + IO, + OrderConfigV3, + OrderV3, + IInterpreterV3 +} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; +import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; +import {IERC20Metadata} from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol"; +import {StateNamespace, LibNamespace} from "src/concrete/ob/OrderBook.sol"; + +contract OrderBookV4ArbOrderTakerContextTest is OrderBookExternalRealTest { + function testOrderBookV4ArbOrderTakerContext() external { + address alice = address(999999); + address bob = address(999998); + ChildOrderBookV4ArbOrderTaker arbOrderTaker = new ChildOrderBookV4ArbOrderTaker(); + + OrderConfigV3 memory aliceOrderConfig; + { + IO[] memory aliceValidInputs = new IO[](1); + aliceValidInputs[0] = IO({token: address(iToken0), decimals: 12, vaultId: 0}); + + IO[] memory aliceValidOutputs = new IO[](1); + aliceValidOutputs[0] = IO({token: address(iToken1), decimals: 12, vaultId: 0}); + + aliceOrderConfig = OrderConfigV3({ + evaluable: EvaluableV3(iInterpreter, iStore, ""), + validInputs: aliceValidInputs, + validOutputs: aliceValidOutputs, + nonce: 0, + secret: 0, + meta: "" + }); + } + + OrderV3 memory aliceOrder = OrderV3({ + owner: alice, + evaluable: aliceOrderConfig.evaluable, + validInputs: aliceOrderConfig.validInputs, + validOutputs: aliceOrderConfig.validOutputs, + nonce: aliceOrderConfig.nonce + }); + + TakeOrderConfigV3 memory aliceTakeOrderConfig = TakeOrderConfigV3({ + order: aliceOrder, + inputIOIndex: 0, + outputIOIndex: 0, + signedContext: new SignedContextV1[](0) + }); + + TakeOrderConfigV3[] memory orders = new TakeOrderConfigV3[](1); + orders[0] = aliceTakeOrderConfig; + TakeOrdersConfigV3 memory takeOrdersConfig = TakeOrdersConfigV3({ + minimumInput: 0, + maximumInput: type(uint256).max, + maximumIORatio: type(uint256).max, + orders: orders, + data: "" + }); + + TaskV1 memory task = TaskV1({ + evaluable: EvaluableV3({ + interpreter: iInterpreter, + store: iStore, + bytecode: iParserV2.parse2( + bytes( + string.concat( + ":ensure(equal-to(context<1 0>() 3) \"input token\"),", + ":ensure(equal-to(context<1 1>() 4) \"output token\"),", + ":ensure(equal-to(context<1 2>() 5) \"gas balance\");" + ) + ) + ) + }), + signedContext: new SignedContextV1[](0) + }); + + vm.mockCall(address(iToken0), abi.encodeWithSelector(IERC20.approve.selector), abi.encode(true)); + vm.mockCall(address(iToken0), abi.encodeWithSelector(IERC20.allowance.selector), abi.encode(0)); + vm.mockCall( + address(iToken0), + abi.encodeWithSelector(IERC20.balanceOf.selector, address(arbOrderTaker)), + abi.encode(3e12) + ); + vm.mockCall( + address(iToken1), + abi.encodeWithSelector(IERC20.balanceOf.selector, address(arbOrderTaker)), + abi.encode(4e12) + ); + vm.mockCall(address(iToken0), abi.encodeWithSelector(IERC20.transfer.selector), abi.encode(true)); + vm.mockCall(address(iToken1), abi.encodeWithSelector(IERC20.transfer.selector), abi.encode(true)); + vm.mockCall(address(iToken0), abi.encodeWithSelector(IERC20Metadata.decimals.selector), abi.encode(12)); + vm.mockCall(address(iToken1), abi.encodeWithSelector(IERC20Metadata.decimals.selector), abi.encode(12)); + + vm.deal(address(arbOrderTaker), 5e18); + vm.prank(bob); + arbOrderTaker.arb3(iOrderbook, takeOrdersConfig, task); + } +} diff --git a/test/abstract/OrderBookV4ArbOrderTaker.ierc165.t.sol b/test/abstract/OrderBookV4ArbOrderTaker.ierc165.t.sol index f3abc16c1..f5923e825 100644 --- a/test/abstract/OrderBookV4ArbOrderTaker.ierc165.t.sol +++ b/test/abstract/OrderBookV4ArbOrderTaker.ierc165.t.sol @@ -7,25 +7,14 @@ import { OrderBookV4ArbOrderTaker, IOrderBookV4ArbOrderTakerV2, EvaluableV3, - OrderBookV4ArbConfigV1, - IOrderBookV4OrderTaker + OrderBookV4ArbConfigV2, + IOrderBookV4OrderTaker, + TaskV1, + SignedContextV1 } from "src/abstract/OrderBookV4ArbOrderTaker.sol"; import {IInterpreterV3} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; - -/// @dev We need a contract that is deployable in order to test the abstract -/// base contract. -contract ChildOrderBookV4ArbOrderTaker is OrderBookV4ArbOrderTaker { - constructor() - OrderBookV4ArbOrderTaker( - OrderBookV4ArbConfigV1( - address(0), - EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), ""), - abi.encode(address(0)) - ) - ) - {} -} +import {ChildOrderBookV4ArbOrderTaker} from "../util/concrete/ChildOrderBookV4ArbOrderTaker.sol"; contract OrderBookV4ArbOrderTakerIERC165Test is Test { /// Test that ERC165 and IOrderBookV4ArbOrderTaker are supported interfaces diff --git a/test/abstract/OrderBookV4FlashBorrower.ierc165.t.sol b/test/abstract/OrderBookV4FlashBorrower.ierc165.t.sol index 8889dd2ff..ab5d50ef9 100644 --- a/test/abstract/OrderBookV4FlashBorrower.ierc165.t.sol +++ b/test/abstract/OrderBookV4FlashBorrower.ierc165.t.sol @@ -6,8 +6,10 @@ import {IERC165} from "openzeppelin-contracts/contracts/utils/introspection/IERC import { OrderBookV4FlashBorrower, IERC3156FlashBorrower, - EvaluableV3, - OrderBookV4ArbConfigV1 + OrderBookV4ArbConfigV2, + TaskV1, + SignedContextV1, + EvaluableV3 } from "src/abstract/OrderBookV4FlashBorrower.sol"; import {IInterpreterV3} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; @@ -17,9 +19,12 @@ import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpr contract ChildOrderBookV4FlashBorrower is OrderBookV4FlashBorrower { constructor() OrderBookV4FlashBorrower( - OrderBookV4ArbConfigV1( + OrderBookV4ArbConfigV2( address(0), - EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), ""), + TaskV1({ + evaluable: EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), hex""), + signedContext: new SignedContextV1[](0) + }), abi.encode(address(0)) ) ) diff --git a/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.expression.t.sol b/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.expression.t.sol index 306a6127d..40b18c514 100644 --- a/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.expression.t.sol +++ b/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.expression.t.sol @@ -4,7 +4,7 @@ pragma solidity =0.8.25; import {GenericPoolOrderBookV4ArbOrderTakerTest} from "test/util/abstract/GenericPoolOrderBookV4ArbOrderTakerTest.sol"; import { GenericPoolOrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1 + OrderBookV4ArbConfigV2 } from "src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol"; import { OrderV3, @@ -13,16 +13,18 @@ import { TakeOrdersConfigV3, IInterpreterV3, IInterpreterStoreV2, - SignedContextV1 + SignedContextV1, + TaskV1 } from "rain.orderbook.interface/interface/IOrderBookV4.sol"; import {LibContext} from "rain.interpreter.interface/lib/caller/LibContext.sol"; import { LibNamespace, DEFAULT_STATE_NAMESPACE, BEFORE_ARB_SOURCE_INDEX, - WrongEvaluable + WrongTask } from "src/abstract/OrderBookV4ArbCommon.sol"; import {CALCULATE_ORDER_ENTRYPOINT} from "src/concrete/ob/OrderBook.sol"; +import {StateNamespace, FullyQualifiedNamespace} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; contract GenericPoolOrderBookV4ArbOrderTakerExpressionTest is GenericPoolOrderBookV4ArbOrderTakerTest { function expression() internal virtual override returns (bytes memory) { @@ -42,12 +44,11 @@ contract GenericPoolOrderBookV4ArbOrderTakerExpressionTest is GenericPoolOrderBo ); TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); - vm.expectRevert(abi.encodeWithSelector(WrongEvaluable.selector)); + vm.expectRevert(abi.encodeWithSelector(WrongTask.selector)); GenericPoolOrderBookV4ArbOrderTaker(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), - 0, - evaluable + TaskV1({evaluable: evaluable, signedContext: new SignedContextV1[](0)}) ); } @@ -60,41 +61,34 @@ contract GenericPoolOrderBookV4ArbOrderTakerExpressionTest is GenericPoolOrderBo ) public { TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); + StateNamespace ns = StateNamespace.wrap(uint256(uint160(address(this)))); + FullyQualifiedNamespace fqns = LibNamespace.qualifyNamespace(ns, address(iArb)); + vm.mockCall( address(iInterpreter), - abi.encodeWithSelector( - IInterpreterV3.eval3.selector, - iInterpreterStore, - LibNamespace.qualifyNamespace(DEFAULT_STATE_NAMESPACE, address(iArb)) - ), + abi.encodeWithSelector(IInterpreterV3.eval3.selector, iInterpreterStore, fqns), abi.encode(stack, kvs) ); vm.expectCall( - address(iInterpreter), - abi.encodeWithSelector( - IInterpreterV3.eval3.selector, - iInterpreterStore, - LibNamespace.qualifyNamespace(DEFAULT_STATE_NAMESPACE, address(iArb)) - ) + address(iInterpreter), abi.encodeWithSelector(IInterpreterV3.eval3.selector, iInterpreterStore, fqns) ); if (kvs.length > 0) { vm.mockCall( address(iInterpreterStore), - abi.encodeWithSelector(IInterpreterStoreV2.set.selector, DEFAULT_STATE_NAMESPACE, kvs), + abi.encodeWithSelector(IInterpreterStoreV2.set.selector, ns, kvs), abi.encode("") ); - vm.expectCall( - address(iInterpreterStore), - abi.encodeWithSelector(IInterpreterStoreV2.set.selector, DEFAULT_STATE_NAMESPACE, kvs) - ); + vm.expectCall(address(iInterpreterStore), abi.encodeWithSelector(IInterpreterStoreV2.set.selector, ns, kvs)); } GenericPoolOrderBookV4ArbOrderTaker(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), - 0, - EvaluableV3(iInterpreter, iInterpreterStore, expression()) + TaskV1({ + evaluable: EvaluableV3(iInterpreter, iInterpreterStore, expression()), + signedContext: new SignedContextV1[](0) + }) ); } } diff --git a/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sender.t.sol b/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sender.t.sol index 03ae24fc0..f6f2cb964 100644 --- a/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sender.t.sol +++ b/test/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sender.t.sol @@ -5,8 +5,7 @@ import {GenericPoolOrderBookV4ArbOrderTakerTest} from "test/util/abstract/Generi import { GenericPoolOrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1, - MinimumOutput + OrderBookV4ArbConfigV2 } from "src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol"; import { OrderV3, @@ -14,7 +13,9 @@ import { TakeOrderConfigV3, TakeOrdersConfigV3, IInterpreterV3, - IInterpreterStoreV2 + IInterpreterStoreV2, + TaskV1, + SignedContextV1 } from "rain.orderbook.interface/interface/IOrderBookV4.sol"; contract GenericPoolOrderBookV4ArbOrderTakerSenderTest is GenericPoolOrderBookV4ArbOrderTakerTest { @@ -26,30 +27,10 @@ contract GenericPoolOrderBookV4ArbOrderTakerSenderTest is GenericPoolOrderBookV4 GenericPoolOrderBookV4ArbOrderTaker(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), - 0, - EvaluableV3(iInterpreter, iInterpreterStore, "") - ); - } - - function testGenericPoolMinimumOutput( - OrderV3 memory order, - uint256 inputIOIndex, - uint256 outputIOIndex, - uint256 minimumOutput, - uint256 mintAmount - ) public { - mintAmount = bound(mintAmount, 0, type(uint256).max - 1); - minimumOutput = bound(minimumOutput, mintAmount + 1, type(uint256).max); - iTakerOutput.mint(iArb, mintAmount); - - TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); - - vm.expectRevert(abi.encodeWithSelector(MinimumOutput.selector, minimumOutput, mintAmount)); - GenericPoolOrderBookV4ArbOrderTaker(iArb).arb3( - iOrderBook, - TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), - minimumOutput, - EvaluableV3(iInterpreter, iInterpreterStore, "") + TaskV1({ + evaluable: EvaluableV3(iInterpreter, iInterpreterStore, ""), + signedContext: new SignedContextV1[](0) + }) ); } } diff --git a/test/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sender.t.sol b/test/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sender.t.sol index 704eecb23..c348f676d 100644 --- a/test/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sender.t.sol +++ b/test/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sender.t.sol @@ -5,8 +5,7 @@ import {ArbTest} from "test/util/abstract/ArbTest.sol"; import { GenericPoolOrderBookV4FlashBorrower, - MinimumOutput, - OrderBookV4ArbConfigV1 + OrderBookV4ArbConfigV2 } from "src/concrete/arb/GenericPoolOrderBookV4FlashBorrower.sol"; import { OrderV3, @@ -14,11 +13,13 @@ import { EvaluableV3, TakeOrdersConfigV3, IInterpreterV3, - IInterpreterStoreV2 + IInterpreterStoreV2, + TaskV1, + SignedContextV1 } from "rain.orderbook.interface/interface/IOrderBookV4.sol"; contract GenericPoolOrderBookV4FlashBorrowerTest is ArbTest { - function buildArb(OrderBookV4ArbConfigV1 memory config) internal override returns (address) { + function buildArb(OrderBookV4ArbConfigV2 memory config) internal override returns (address) { return address(new GenericPoolOrderBookV4FlashBorrower(config)); } @@ -34,32 +35,11 @@ contract GenericPoolOrderBookV4FlashBorrowerTest is ArbTest { GenericPoolOrderBookV4FlashBorrower(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, ""), - 0, abi.encode(iRefundoor, iRefundoor, ""), - EvaluableV3(iInterpreter, iInterpreterStore, "") - ); - } - - function testGenericPoolOrderBookV4FlashBorrowerMinimumOutput( - OrderV3 memory order, - uint256 inputIOIndex, - uint256 outputIOIndex, - uint256 minimumOutput, - uint256 mintAmount - ) public { - mintAmount = bound(mintAmount, 0, type(uint256).max - 1); - minimumOutput = bound(minimumOutput, mintAmount + 1, type(uint256).max); - iTakerOutput.mint(iArb, mintAmount); - - TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); - - vm.expectRevert(abi.encodeWithSelector(MinimumOutput.selector, minimumOutput, mintAmount)); - GenericPoolOrderBookV4FlashBorrower(iArb).arb3( - iOrderBook, - TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, ""), - minimumOutput, - abi.encode(iRefundoor, iRefundoor, ""), - EvaluableV3(iInterpreter, iInterpreterStore, "") + TaskV1({ + evaluable: EvaluableV3(iInterpreter, iInterpreterStore, ""), + signedContext: new SignedContextV1[](0) + }) ); } } diff --git a/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.expression.t.sol b/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.expression.t.sol index 50de089cd..7771cd030 100644 --- a/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.expression.t.sol +++ b/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.expression.t.sol @@ -9,10 +9,13 @@ import { TakeOrderConfigV3, TakeOrdersConfigV3, IInterpreterV3, - IInterpreterStoreV2 + IInterpreterStoreV2, + TaskV1, + SignedContextV1 } from "rain.orderbook.interface/interface/IOrderBookV4.sol"; -import {LibNamespace, DEFAULT_STATE_NAMESPACE, WrongEvaluable} from "src/abstract/OrderBookV4ArbCommon.sol"; +import {LibNamespace, DEFAULT_STATE_NAMESPACE, WrongTask} from "src/abstract/OrderBookV4ArbCommon.sol"; import {RouteProcessorOrderBookV4ArbOrderTaker} from "src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol"; +import {StateNamespace, FullyQualifiedNamespace} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; contract RouteProcessorOrderBookV4ArbOrderTakerExpressionTest is RouteProcessorOrderBookV4ArbOrderTakerTest { function expression() internal virtual override returns (bytes memory) { @@ -32,12 +35,11 @@ contract RouteProcessorOrderBookV4ArbOrderTakerExpressionTest is RouteProcessorO ); TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); - vm.expectRevert(abi.encodeWithSelector(WrongEvaluable.selector)); + vm.expectRevert(abi.encodeWithSelector(WrongTask.selector)); RouteProcessorOrderBookV4ArbOrderTaker(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), - 0, - evaluable + TaskV1({evaluable: evaluable, signedContext: new SignedContextV1[](0)}) ); } @@ -50,41 +52,32 @@ contract RouteProcessorOrderBookV4ArbOrderTakerExpressionTest is RouteProcessorO ) public { TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); + StateNamespace ns = StateNamespace.wrap(uint256(uint160(address(this)))); + FullyQualifiedNamespace fqns = LibNamespace.qualifyNamespace(ns, address(iArb)); + vm.mockCall( address(iInterpreter), - abi.encodeWithSelector( - IInterpreterV3.eval3.selector, - iInterpreterStore, - LibNamespace.qualifyNamespace(DEFAULT_STATE_NAMESPACE, address(iArb)) - ), + abi.encodeWithSelector(IInterpreterV3.eval3.selector, iInterpreterStore, fqns), abi.encode(stack, kvs) ); vm.expectCall( - address(iInterpreter), - abi.encodeWithSelector( - IInterpreterV3.eval3.selector, - iInterpreterStore, - LibNamespace.qualifyNamespace(DEFAULT_STATE_NAMESPACE, address(iArb)) - ) + address(iInterpreter), abi.encodeWithSelector(IInterpreterV3.eval3.selector, iInterpreterStore, fqns) ); if (kvs.length > 0) { vm.mockCall( - address(iInterpreterStore), - abi.encodeWithSelector(IInterpreterStoreV2.set.selector, DEFAULT_STATE_NAMESPACE, kvs), - abi.encode("") - ); - vm.expectCall( - address(iInterpreterStore), - abi.encodeWithSelector(IInterpreterStoreV2.set.selector, DEFAULT_STATE_NAMESPACE, kvs) + address(iInterpreterStore), abi.encodeWithSelector(IInterpreterStoreV2.set.selector, ns), abi.encode("") ); + vm.expectCall(address(iInterpreterStore), abi.encodeWithSelector(IInterpreterStoreV2.set.selector, ns)); } RouteProcessorOrderBookV4ArbOrderTaker(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(iRefundoor, iRefundoor, "")), - 0, - EvaluableV3(iInterpreter, iInterpreterStore, expression()) + TaskV1({ + evaluable: EvaluableV3(iInterpreter, iInterpreterStore, expression()), + signedContext: new SignedContextV1[](0) + }) ); } } diff --git a/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sender.t.sol b/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sender.t.sol index b3f11d446..2fdde30ae 100644 --- a/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sender.t.sol +++ b/test/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sender.t.sol @@ -9,12 +9,13 @@ import { TakeOrderConfigV3, TakeOrdersConfigV3, IInterpreterV3, - IInterpreterStoreV2 + IInterpreterStoreV2, + TaskV1, + SignedContextV1 } from "rain.orderbook.interface/interface/IOrderBookV4.sol"; import { RouteProcessorOrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1, - MinimumOutput + OrderBookV4ArbConfigV2 } from "src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol"; contract RouteProcessorOrderBookV4ArbOrderTakerSenderTest is RouteProcessorOrderBookV4ArbOrderTakerTest { @@ -26,30 +27,10 @@ contract RouteProcessorOrderBookV4ArbOrderTakerSenderTest is RouteProcessorOrder RouteProcessorOrderBookV4ArbOrderTaker(iArb).arb3( iOrderBook, TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(bytes("0x00"))), - 0, - EvaluableV3(iInterpreter, iInterpreterStore, "") - ); - } - - function testRouteProcessorMinimumOutput( - OrderV3 memory order, - uint256 inputIOIndex, - uint256 outputIOIndex, - uint256 minimumOutput, - uint256 mintAmount - ) public { - mintAmount = bound(mintAmount, 0, type(uint256).max - 1); - minimumOutput = bound(minimumOutput, mintAmount + 1, type(uint256).max); - iTakerOutput.mint(iArb, mintAmount); - - TakeOrderConfigV3[] memory orders = buildTakeOrderConfig(order, inputIOIndex, outputIOIndex); - - vm.expectRevert(abi.encodeWithSelector(MinimumOutput.selector, minimumOutput, mintAmount)); - RouteProcessorOrderBookV4ArbOrderTaker(iArb).arb3( - iOrderBook, - TakeOrdersConfigV3(0, type(uint256).max, type(uint256).max, orders, abi.encode(bytes("0x00"))), - minimumOutput, - EvaluableV3(iInterpreter, iInterpreterStore, expression()) + TaskV1({ + evaluable: EvaluableV3(iInterpreter, iInterpreterStore, ""), + signedContext: new SignedContextV1[](0) + }) ); } } diff --git a/test/concrete/ob/OrderBook.takeOrder.tokenMismatch.t.sol b/test/concrete/ob/OrderBook.takeOrder.tokenMismatch.t.sol index a80485002..3f75df6bd 100644 --- a/test/concrete/ob/OrderBook.takeOrder.tokenMismatch.t.sol +++ b/test/concrete/ob/OrderBook.takeOrder.tokenMismatch.t.sol @@ -50,17 +50,13 @@ contract OrderBookTakeOrderTokenMismatchTest is OrderBookExternalRealTest { orders[0] = TakeOrderConfigV3(a, aInputIOIndex, aOutputIOIndex, new SignedContextV1[](0)); orders[1] = TakeOrderConfigV3(b, bInputIOIndex, bOutputIOIndex, new SignedContextV1[](0)); TakeOrdersConfigV3 memory config = TakeOrdersConfigV3(0, maxTakerInput, maxIORatio, orders, ""); - vm.expectRevert( - abi.encodeWithSelector( - TokenMismatch.selector, b.validInputs[bInputIOIndex].token, a.validInputs[aInputIOIndex].token - ) - ); + vm.expectRevert(abi.encodeWithSelector(TokenMismatch.selector)); (uint256 totalTakerInput, uint256 totalTakerOutput) = iOrderbook.takeOrders2(config); (totalTakerInput, totalTakerOutput); } /// Test a mismatch in the output tokens. - function testTokenMismatchOutputs( + function testTokenDecimalMismatchOutputs( OrderV3 memory a, uint256 aInputIOIndex, uint256 aOutputIOIndex, @@ -89,11 +85,7 @@ contract OrderBookTakeOrderTokenMismatchTest is OrderBookExternalRealTest { orders[0] = TakeOrderConfigV3(a, aInputIOIndex, aOutputIOIndex, new SignedContextV1[](0)); orders[1] = TakeOrderConfigV3(b, bInputIOIndex, bOutputIOIndex, new SignedContextV1[](0)); TakeOrdersConfigV3 memory config = TakeOrdersConfigV3(0, maxTakerInput, maxIORatio, orders, ""); - vm.expectRevert( - abi.encodeWithSelector( - TokenMismatch.selector, b.validOutputs[bOutputIOIndex].token, a.validOutputs[aOutputIOIndex].token - ) - ); + vm.expectRevert(abi.encodeWithSelector(TokenMismatch.selector)); (uint256 totalTakerInput, uint256 totalTakerOutput) = iOrderbook.takeOrders2(config); (totalTakerInput, totalTakerOutput); } diff --git a/test/concrete/ob/OrderBook.takeOrder.tokenMismatchDecimals.t.sol b/test/concrete/ob/OrderBook.takeOrder.tokenMismatchDecimals.t.sol index 00b639f39..83049d18b 100644 --- a/test/concrete/ob/OrderBook.takeOrder.tokenMismatchDecimals.t.sol +++ b/test/concrete/ob/OrderBook.takeOrder.tokenMismatchDecimals.t.sol @@ -62,7 +62,7 @@ contract OrderBookTakeOrderTokenMismatchDecimalsTest is OrderBookExternalRealTes } /// Test a mismatch in the output tokens decimals. - function testTokenMismatchOutputs( + function testTokenDecimalsMismatchOutputs( OrderV3 memory a, uint256 aInputIOIndex, uint256 aOutputIOIndex, diff --git a/test/util/abstract/ArbTest.sol b/test/util/abstract/ArbTest.sol index 88c0bed19..0e9650182 100644 --- a/test/util/abstract/ArbTest.sol +++ b/test/util/abstract/ArbTest.sol @@ -13,10 +13,11 @@ import { OrderV3, TakeOrderConfigV3, IO, - SignedContextV1 + SignedContextV1, + EvaluableV3 } from "test/util/concrete/FlashLendingMockOrderBook.sol"; -import {OrderBookV4ArbConfigV1} from "src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol"; -import {EvaluableV3} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; +import {OrderBookV4ArbConfigV2} from "src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol"; +import {TaskV1} from "rain.orderbook.interface/interface/IOrderBookV4.sol"; import {IInterpreterV3} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; @@ -39,13 +40,13 @@ abstract contract ArbTest is Test { address immutable iArb; /// Mimics the `Construct` event from `OrderBookV4ArbCommon`. - event Construct(address sender, OrderBookV4ArbConfigV1 config); + event Construct(address sender, OrderBookV4ArbConfigV2 config); function expression() internal virtual returns (bytes memory) { return ""; } - function buildArb(OrderBookV4ArbConfigV1 memory config) internal virtual returns (address); + function buildArb(OrderBookV4ArbConfigV2 memory config) internal virtual returns (address); constructor() { iInterpreter = IInterpreterV3(address(uint160(uint256(keccak256("interpreter.rain.test"))))); @@ -62,8 +63,13 @@ abstract contract ArbTest is Test { iOrderBook = new FlashLendingMockOrderBook(); vm.label(address(iOrderBook), "iOrderBook"); - OrderBookV4ArbConfigV1 memory config = OrderBookV4ArbConfigV1( - address(iOrderBook), EvaluableV3(iInterpreter, iInterpreterStore, expression()), abi.encode(iRefundoor) + OrderBookV4ArbConfigV2 memory config = OrderBookV4ArbConfigV2( + address(iOrderBook), + TaskV1({ + evaluable: EvaluableV3(iInterpreter, iInterpreterStore, expression()), + signedContext: new SignedContextV1[](0) + }), + abi.encode(iRefundoor) ); vm.expectEmit(); diff --git a/test/util/abstract/GenericPoolOrderBookV4ArbOrderTakerTest.sol b/test/util/abstract/GenericPoolOrderBookV4ArbOrderTakerTest.sol index 19f7c1e18..71e8c3b63 100644 --- a/test/util/abstract/GenericPoolOrderBookV4ArbOrderTakerTest.sol +++ b/test/util/abstract/GenericPoolOrderBookV4ArbOrderTakerTest.sol @@ -4,11 +4,11 @@ pragma solidity =0.8.25; import {ArbTest} from "./ArbTest.sol"; import { GenericPoolOrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1 + OrderBookV4ArbConfigV2 } from "src/concrete/arb/GenericPoolOrderBookV4ArbOrderTaker.sol"; contract GenericPoolOrderBookV4ArbOrderTakerTest is ArbTest { - function buildArb(OrderBookV4ArbConfigV1 memory config) internal override returns (address) { + function buildArb(OrderBookV4ArbConfigV2 memory config) internal override returns (address) { return address(new GenericPoolOrderBookV4ArbOrderTaker(config)); } diff --git a/test/util/abstract/RouteProcessorOrderBookV4ArbOrderTakerTest.sol b/test/util/abstract/RouteProcessorOrderBookV4ArbOrderTakerTest.sol index b4290a069..0647e03e5 100644 --- a/test/util/abstract/RouteProcessorOrderBookV4ArbOrderTakerTest.sol +++ b/test/util/abstract/RouteProcessorOrderBookV4ArbOrderTakerTest.sol @@ -4,11 +4,11 @@ pragma solidity =0.8.25; import {ArbTest} from "./ArbTest.sol"; import { RouteProcessorOrderBookV4ArbOrderTaker, - OrderBookV4ArbConfigV1 + OrderBookV4ArbConfigV2 } from "src/concrete/arb/RouteProcessorOrderBookV4ArbOrderTaker.sol"; contract RouteProcessorOrderBookV4ArbOrderTakerTest is ArbTest { - function buildArb(OrderBookV4ArbConfigV1 memory config) internal override returns (address) { + function buildArb(OrderBookV4ArbConfigV2 memory config) internal override returns (address) { return address(new RouteProcessorOrderBookV4ArbOrderTaker(config)); } diff --git a/test/util/concrete/ChildOrderBookV4ArbOrderTaker.sol b/test/util/concrete/ChildOrderBookV4ArbOrderTaker.sol new file mode 100644 index 000000000..0a371ab2a --- /dev/null +++ b/test/util/concrete/ChildOrderBookV4ArbOrderTaker.sol @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: CAL +pragma solidity =0.8.25; + +import { + OrderBookV4ArbOrderTaker, + SignedContextV1, + EvaluableV3, + TaskV1, + OrderBookV4ArbConfigV2 +} from "src/abstract/OrderBookV4ArbOrderTaker.sol"; +import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; +import {IInterpreterV3} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; + +/// @dev We need a contract that is deployable in order to test the abstract +/// base contract. +contract ChildOrderBookV4ArbOrderTaker is OrderBookV4ArbOrderTaker { + constructor() + OrderBookV4ArbOrderTaker( + OrderBookV4ArbConfigV2( + address(0), + TaskV1({ + evaluable: EvaluableV3(IInterpreterV3(address(0)), IInterpreterStoreV2(address(0)), ""), + signedContext: new SignedContextV1[](0) + }), + abi.encode(address(0)) + ) + ) + {} +}