diff --git a/.gas-snapshot b/.gas-snapshot index f906d5dc2..018e5946d 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,107 +1,112 @@ -GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 30, μ: 431441, ~: 426614) -GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 30, μ: 170093, ~: 168794) -GenericPoolOrderBookV4ArbOrderTakerSenderTest:testGenericPoolTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 30, μ: 273592, ~: 271336) -GenericPoolOrderBookV4FlashBorrowerTest:testGenericPoolOrderBookV4FlashBorrowerTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 30, μ: 522441, ~: 517262) -LibOrderTest:testHashEqual((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 120, μ: 196758, ~: 185247) -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: 120, μ: 303709, ~: 288071) -OrderBookAddOrderEnactTest:testAddLiveOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 943074, ~: 889022) -OrderBookAddOrderEnactTest:testAddLiveOrderRevertNoAdd(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 737740, ~: 696173) -OrderBookAddOrderEnactTest:testAddOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 1045640, ~: 1001791) -OrderBookAddOrderEnactTest:testAddOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 659270, ~: 620393) -OrderBookAddOrderEnactTest:testAddOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 720030, ~: 681137) -OrderBookAddOrderEnactTest:testAddOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 705378, ~: 666485) -OrderBookAddOrderEnactTest:testAddOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 3273330, ~: 3280060) -OrderBookAddOrderEnactTest:testAddOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 953859, ~: 914910) -OrderBookAddOrderEnactTest:testAddOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 1362298, ~: 1291950) -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: 120, μ: 2768347, ~: 2720274) -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: 120, μ: 2616512, ~: 2642029) -OrderBookAddOrderMockTest:testAddOrderTwoAccountsWithSameConfig(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 2435598, ~: 2461148) -OrderBookAddOrderMockTest:testAddOrderWithCalculationsInputsAndOutputsSucceeds(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 1285282, ~: 1179797) -OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaEmitsMetaV1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 1294905, ~: 1189304) -OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 690182, ~: 636539) -OrderBookAddOrderMockTest:testAddOrderWithoutCalculationsDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 706725, ~: 665020) -OrderBookAddOrderMockTest:testAddOrderWithoutInputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 169387, ~: 165247) -OrderBookAddOrderMockTest:testAddOrderWithoutOutputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 166523, ~: 162469) -OrderBookAddOrderNonceTest:testAddOrderNonceDifferentNonceStateChange(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes32) (runs: 120, μ: 1271608, ~: 1282006) -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: 120, μ: 1435409, ~: 1406287) -OrderBookAddOrderNonceTest:testAddOrderNonceSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1015185, ~: 953426) -OrderBookAddOrderOwnerTest:testAddOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 120, μ: 1149077, ~: 1201727) -OrderBookAddOrderOwnerTest:testAddOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1015281, ~: 953522) -OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 687910, ~: 648848) -OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts2(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 689693, ~: 650631) -OrderBookAddOrderTest:testAddOrderRealCalculateInputsRevertsPreference(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 689256, ~: 650194) -OrderBookAddOrderTest:testAddOrderRealNoHandleIODeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 679992, ~: 640930) -OrderBookAddOrderTest:testAddOrderRealNoSourcesDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 657650, ~: 618598) -OrderBookAddOrderTest:testAddOrderRealOneStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 692220, ~: 653158) -OrderBookAddOrderTest:testAddOrderRealThreeStackCalculate(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 704822, ~: 665760) -OrderBookAddOrderTest:testAddOrderRealTwoStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 698464, ~: 659402) -OrderBookAddOrderTest:testAddOrderRealZeroStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 686630, ~: 647568) -OrderBookClearHandleIORevertTest:testClearOrderAliceNoHandleIORevert() (gas: 521011) -OrderBookClearHandleIORevertTest:testClearOrderBobNoHandleIORevert() (gas: 521012) -OrderBookClearHandleIORevertTest:testClearOrderBothNoHandleIORevert() (gas: 500338) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO0() (gas: 561233) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO1() (gas: 553176) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO2() (gas: 553384) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO3() (gas: 561277) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO4() (gas: 569142) -OrderBookClearHandleIORevertTest:testClearOrderHandleIO5() (gas: 526740) -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: 120, μ: 2374769, ~: 2424878) -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: 120, μ: 2461435, ~: 2503676) -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: 120, μ: 2469182, ~: 2511420) -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: 120, μ: 2395937, ~: 2446051) -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: 120, μ: 2389510, ~: 2439624) -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: 120, μ: 2388262, ~: 2438367) -OrderBookClearOrderContextTest:testContextEmptyStack(address,address,uint256,uint256,uint256,uint256) (runs: 30, μ: 2163795, ~: 2166500) -OrderBookClearSameTokenTest:testClearSameToken(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: 30, μ: 1586753, ~: 1610409) -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: 120, μ: 528352, ~: 525266) -OrderBookClearTest:testFlashLoanToNonReceiver(uint256,bytes,bytes32,bytes) (runs: 5116, μ: 28247, ~: 28145) -OrderBookDepositEnactTest:testDepositRevertInAction(address,uint256,uint256) (runs: 30, μ: 97295, ~: 97295) -OrderBookDepositEnactTest:testOrderBookDepositEnactEmptyNoop(address,uint256,uint256) (runs: 30, μ: 41751, ~: 41751) -OrderBookDepositEnactTest:testOrderBookDepositEnactOneReadState(address,uint256,uint256) (runs: 30, μ: 104020, ~: 104020) -OrderBookDepositEnactTest:testOrderBookDepositEnactOneStateless(address,uint256,uint256) (runs: 30, μ: 89382, ~: 89382) -OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256) (runs: 30, μ: 959679, ~: 959588) -OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSequential(address,uint256,uint256) (runs: 30, μ: 594204, ~: 594113) -OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSingle(address,uint256,uint256) (runs: 30, μ: 212811, ~: 212720) -OrderBookDepositEnactTest:testOrderDepositContext(address,uint256,uint256,uint256) (runs: 30, μ: 638475, ~: 631576) -OrderBookDepositTest:testDepositEvent(address,uint256,uint256) (runs: 120, μ: 39527, ~: 39527) -OrderBookDepositTest:testDepositFail(address,uint256,uint256) (runs: 120, μ: 1040441656, ~: 1040441612) +GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 34, μ: 428801, ~: 424733) +GenericPoolOrderBookV4ArbOrderTakerExpressionTest:testGenericPoolTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 34, μ: 170749, ~: 160600) +GenericPoolOrderBookV4ArbOrderTakerSenderTest:testGenericPoolTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 34, μ: 274813, ~: 261494) +GenericPoolOrderBookV4FlashBorrowerTest:testGenericPoolOrderBookV4FlashBorrowerTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 34, μ: 524833, ~: 497497) +LibOrderTest:testHashEqual((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 124, μ: 197448, ~: 186039) +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: 124, μ: 302512, ~: 286228) +OrderBookAddOrderEnactTest:testAddLiveOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 949267, ~: 900199) +OrderBookAddOrderEnactTest:testAddLiveOrderRevertNoAdd(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 742523, ~: 704793) +OrderBookAddOrderEnactTest:testAddOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 1050387, ~: 1010578) +OrderBookAddOrderEnactTest:testAddOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 663683, ~: 628394) +OrderBookAddOrderEnactTest:testAddOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 724444, ~: 689141) +OrderBookAddOrderEnactTest:testAddOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 709792, ~: 674489) +OrderBookAddOrderEnactTest:testAddOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 3220985, ~: 3209629) +OrderBookAddOrderEnactTest:testAddOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 958281, ~: 922929) +OrderBookAddOrderEnactTest:testAddOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 1370425, ~: 1306555) +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: 124, μ: 2779085, ~: 2737709) +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: 124, μ: 2608876, ~: 2614417) +OrderBookAddOrderMockTest:testAddOrderTwoAccountsWithSameConfig(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 2424811, ~: 2432732) +OrderBookAddOrderMockTest:testAddOrderWithCalculationsInputsAndOutputsSucceeds(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 1287450, ~: 1193623) +OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaEmitsMetaV1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 1297086, ~: 1203601) +OrderBookAddOrderMockTest:testAddOrderWithNonEmptyMetaReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 691347, ~: 644037) +OrderBookAddOrderMockTest:testAddOrderWithoutCalculationsDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 707113, ~: 661336) +OrderBookAddOrderMockTest:testAddOrderWithoutInputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 169722, ~: 165526) +OrderBookAddOrderMockTest:testAddOrderWithoutOutputsReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 166365, ~: 161072) +OrderBookAddOrderNonceTest:testAddOrderNonceDifferentNonceStateChange(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes32) (runs: 124, μ: 1273547, ~: 1273546) +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: 124, μ: 1442764, ~: 1411510) +OrderBookAddOrderNonceTest:testAddOrderNonceSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1015735, ~: 948036) +OrderBookAddOrderOwnerTest:testAddOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 124, μ: 1139373, ~: 1185421) +OrderBookAddOrderOwnerTest:testAddOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1015831, ~: 948132) +OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts1(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 688267, ~: 645417) +OrderBookAddOrderTest:testAddOrderRealCalculateInputsReverts2(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 690050, ~: 647200) +OrderBookAddOrderTest:testAddOrderRealCalculateInputsRevertsPreference(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 689613, ~: 646763) +OrderBookAddOrderTest:testAddOrderRealNoHandleIODeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 680349, ~: 637499) +OrderBookAddOrderTest:testAddOrderRealNoSourcesDeploys(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 658007, ~: 615168) +OrderBookAddOrderTest:testAddOrderRealOneStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 692577, ~: 649727) +OrderBookAddOrderTest:testAddOrderRealThreeStackCalculate(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 705179, ~: 662329) +OrderBookAddOrderTest:testAddOrderRealTwoStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 698821, ~: 655971) +OrderBookAddOrderTest:testAddOrderRealZeroStackCalculateReverts(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 686987, ~: 644137) +OrderBookClearHandleIORevertTest:testClearOrderAliceNoHandleIORevert() (gas: 517719) +OrderBookClearHandleIORevertTest:testClearOrderBobNoHandleIORevert() (gas: 517720) +OrderBookClearHandleIORevertTest:testClearOrderBothNoHandleIORevert() (gas: 497046) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO0() (gas: 557941) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO1() (gas: 549884) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO2() (gas: 550092) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO3() (gas: 557985) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO4() (gas: 566438) +OrderBookClearHandleIORevertTest:testClearOrderHandleIO5() (gas: 524036) +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: 124, μ: 2367720, ~: 2393602) +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: 124, μ: 2454275, ~: 2470804) +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: 124, μ: 2462022, ~: 2478546) +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: 124, μ: 2388888, ~: 2414772) +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: 124, μ: 2382461, ~: 2408345) +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: 124, μ: 2381213, ~: 2407088) +OrderBookClearOrderContextTest:testContextEmptyStack(address,address,uint256,uint256,uint256,uint256) (runs: 34, μ: 2162782, ~: 2164743) +OrderBookClearSameTokenTest:testClearSameToken(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: 34, μ: 1570894, ~: 1571631) +OrderBookClearTest:testClear2ZeroRatioAliceAndBob(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,address,uint256,uint256) (runs: 123, μ: 3920244, ~: 4040801) +OrderBookClearTest:testClear2ZeroRatioAliceOnly(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,address,uint256,uint256) (runs: 123, μ: 3920360, ~: 4040917) +OrderBookClearTest:testClear2ZeroRatioBobOnly(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,address,uint256,uint256) (runs: 123, μ: 3920344, ~: 4040901) +OrderBookClearTest:testClearFuzzIoRatio(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,address,uint256,uint256,uint256,uint256) (runs: 123, μ: 3858134, ~: 3863695) +OrderBookClearTest:testClearFuzzIoRatioError(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,address,uint256,uint256,uint256,uint256) (runs: 123, μ: 3856745, ~: 3852981) +OrderBookClearTest:testClearSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes,address,uint256,uint256) (runs: 123, μ: 3961198, ~: 4081752) +OrderBookClearTest:testFlashLoanToNonReceiver(uint256,bytes,bytes32,bytes) (runs: 5120, μ: 28247, ~: 28145) +OrderBookDepositEnactTest:testDepositRevertInAction(address,uint256,uint256) (runs: 34, μ: 97295, ~: 97295) +OrderBookDepositEnactTest:testOrderBookDepositEnactEmptyNoop(address,uint256,uint256) (runs: 34, μ: 41751, ~: 41751) +OrderBookDepositEnactTest:testOrderBookDepositEnactOneReadState(address,uint256,uint256) (runs: 34, μ: 104020, ~: 104020) +OrderBookDepositEnactTest:testOrderBookDepositEnactOneStateless(address,uint256,uint256) (runs: 34, μ: 89382, ~: 89382) +OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256) (runs: 34, μ: 959677, ~: 959588) +OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSequential(address,uint256,uint256) (runs: 34, μ: 594214, ~: 594113) +OrderBookDepositEnactTest:testOrderBookDepositEvalWriteStateSingle(address,uint256,uint256) (runs: 34, μ: 212821, ~: 212720) +OrderBookDepositEnactTest:testOrderDepositContext(address,uint256,uint256,uint256) (runs: 34, μ: 639026, ~: 630019) +OrderBookDepositTest:testDepositEvent(address,uint256,uint256) (runs: 124, μ: 39527, ~: 39527) +OrderBookDepositTest:testDepositFail(address,uint256,uint256) (runs: 124, μ: 1040441656, ~: 1040441629) OrderBookDepositTest:testDepositGas00() (gas: 8940) OrderBookDepositTest:testDepositGas01() (gas: 35406) -OrderBookDepositTest:testDepositMany((address,address,uint256,uint248)[]) (runs: 104, μ: 2341676, ~: 1527003) -OrderBookDepositTest:testDepositOverflow(address,uint256,uint256,uint256) (runs: 119, μ: 53340, ~: 53654) -OrderBookDepositTest:testDepositReentrancy(address,uint256,uint256,address,uint256,uint256) (runs: 120, μ: 623779, ~: 624277) -OrderBookDepositTest:testDepositSimple(address,uint256,uint256) (runs: 120, μ: 38760, ~: 38760) -OrderBookDepositTest:testDepositZero(address,uint256) (runs: 120, μ: 13201, ~: 13201) -OrderBookDepositTest:testVaultBalanceNoDeposits(address,uint256) (runs: 5116, μ: 8947, ~: 8947) -OrderBookEnactTest:testOrderBookEvalEmptyNoop(address) (runs: 120, μ: 14051, ~: 14051) -OrderBookEnactTest:testOrderBookEvalOneReadState(address) (runs: 120, μ: 73408, ~: 73408) -OrderBookEnactTest:testOrderBookEvalOneStateless(address) (runs: 120, μ: 58746, ~: 58746) -OrderBookEnactTest:testOrderBookEvalWriteStateDifferentOwnersNamespaced(address,address) (runs: 120, μ: 867107, ~: 867107) +OrderBookDepositTest:testDepositMany((address,address,uint256,uint248)[]) (runs: 105, μ: 2295057, ~: 1431474) +OrderBookDepositTest:testDepositOverflow(address,uint256,uint256,uint256) (runs: 123, μ: 53324, ~: 53654) +OrderBookDepositTest:testDepositReentrancy(address,uint256,uint256,address,uint256,uint256) (runs: 124, μ: 623635, ~: 624277) +OrderBookDepositTest:testDepositSimple(address,uint256,uint256) (runs: 124, μ: 38760, ~: 38760) +OrderBookDepositTest:testDepositZero(address,uint256) (runs: 124, μ: 13201, ~: 13201) +OrderBookDepositTest:testVaultBalanceNoDeposits(address,uint256) (runs: 5120, μ: 8947, ~: 8947) +OrderBookEnactTest:testOrderBookEvalEmptyNoop(address) (runs: 124, μ: 14051, ~: 14051) +OrderBookEnactTest:testOrderBookEvalOneReadState(address) (runs: 124, μ: 73408, ~: 73408) +OrderBookEnactTest:testOrderBookEvalOneStateless(address) (runs: 124, μ: 58746, ~: 58746) +OrderBookEnactTest:testOrderBookEvalWriteStateDifferentOwnersNamespaced(address,address) (runs: 124, μ: 867107, ~: 867107) OrderBookEnactTest:testOrderBookEvalWriteStateSequential() (gas: 543024) -OrderBookEnactTest:testOrderBookEvalWriteStateSingle(address) (runs: 120, μ: 170894, ~: 170894) -OrderBookQuoteSameTokenTest:testQuoteSameToken(((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)[])) (runs: 30, μ: 7875634, ~: 7965690) -OrderBookQuoteTest:testQuoteContextSender(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 120, μ: 10904292, ~: 11063023) -OrderBookQuoteTest:testQuoteDeadOrder(((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)[])) (runs: 120, μ: 6619696, ~: 5534272) -OrderBookQuoteTest:testQuoteMaxOutput(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 120, μ: 1188835, ~: 1207423) -OrderBookQuoteTest:testQuoteSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 120, μ: 1182167, ~: 1200421) -OrderBookRemoveOrderEnactTest:testRemoveOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 687363, ~: 661455) -OrderBookRemoveOrderEnactTest:testRemoveOrderDeadOrder(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 380772, ~: 359784) -OrderBookRemoveOrderEnactTest:testRemoveOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1162539, ~: 1091632) -OrderBookRemoveOrderEnactTest:testRemoveOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1223651, ~: 1152727) -OrderBookRemoveOrderEnactTest:testRemoveOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1209007, ~: 1138083) -OrderBookRemoveOrderEnactTest:testRemoveOrderRevertInAction(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1355858, ~: 1277355) -OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 4998149, ~: 4996303) -OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 1458888, ~: 1387903) -OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 2365186, ~: 2230637) -OrderBookRemoveOrderMockTest:testRemoveOrderAddRemoveMulti(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 7378289, ~: 6693347) -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: 120, μ: 4964653, ~: 4909064) -OrderBookRemoveOrderMockTest:testRemoveOrderDifferentOwners(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 4820881, ~: 4857836) -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: 120, μ: 10602665, ~: 10658666) -OrderBookRemoveOrderMockTest:testRemoveOrderDoesNotExist(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 388030, ~: 355582) -OrderBookRemoveOrderMockTest:testRemoveOrderOnlyOwner(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 120, μ: 2581550, ~: 2606274) -OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 120, μ: 5571616, ~: 5772034) -OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 3664516, ~: 3421522) -OrderBookRemoveOrderOwnerTest:testRemoveOrderWrongOwner(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 120, μ: 718199, ~: 750627) +OrderBookEnactTest:testOrderBookEvalWriteStateSingle(address) (runs: 124, μ: 170894, ~: 170894) +OrderBookQuoteSameTokenTest:testQuoteSameToken(((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)[])) (runs: 34, μ: 7316072, ~: 7067047) +OrderBookQuoteTest:testQuoteContextSender(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 124, μ: 10906401, ~: 10884984) +OrderBookQuoteTest:testQuoteDeadOrder(((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)[])) (runs: 124, μ: 6489058, ~: 5413815) +OrderBookQuoteTest:testQuoteMaxOutput(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 124, μ: 1189125, ~: 1188024) +OrderBookQuoteTest:testQuoteSimple(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),uint256) (runs: 124, μ: 1182417, ~: 1181022) +OrderBookRemoveOrderEnactTest:testRemoveOrderContext(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 687566, ~: 659378) +OrderBookRemoveOrderEnactTest:testRemoveOrderDeadOrder(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 380947, ~: 357984) +OrderBookRemoveOrderEnactTest:testRemoveOrderEmptyNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1163197, ~: 1085367) +OrderBookRemoveOrderEnactTest:testRemoveOrderOneReadState(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1224309, ~: 1146461) +OrderBookRemoveOrderEnactTest:testRemoveOrderOneStateless(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1209665, ~: 1131817) +OrderBookRemoveOrderEnactTest:testRemoveOrderRevertInAction(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1356567, ~: 1270473) +OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateDifferentOwnersNamespaced(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 4976864, ~: 4872948) +OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSequential(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 1459547, ~: 1381630) +OrderBookRemoveOrderEnactTest:testRemoveOrderWriteStateSingle(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 2366455, ~: 2218703) +OrderBookRemoveOrderMockTest:testRemoveOrderAddRemoveMulti(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 7390386, ~: 6778974) +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: 124, μ: 4963217, ~: 4909064) +OrderBookRemoveOrderMockTest:testRemoveOrderDifferentOwners(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 4798479, ~: 4800278) +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: 124, μ: 10532784, ~: 10582773) +OrderBookRemoveOrderMockTest:testRemoveOrderDoesNotExist(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 388673, ~: 359875) +OrderBookRemoveOrderMockTest:testRemoveOrderOnlyOwner(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),bytes) (runs: 124, μ: 2569832, ~: 2575893) +OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerDifferentOwnerStateChange(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 124, μ: 5520750, ~: 5685104) +OrderBookRemoveOrderOwnerTest:testRemoveOrderOwnerSameOrderNoop(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 3666333, ~: 3401225) +OrderBookRemoveOrderOwnerTest:testRemoveOrderWrongOwner(((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes),address,address) (runs: 124, μ: 712164, ~: 740525) OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextHappy() (gas: 2102274) OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080218) OrderBookSubParserContextCalculatedIORatioTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065830) @@ -154,7 +159,7 @@ OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextHappy() (gas OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedInputs() (gas: 2080056) OrderBookSubParserContextVaultBalanceBeforeTest:testSubParserContextUnhappyDisallowedOperand() (gas: 2065668) OrderBookSubParserDescribedByMetaV1Test:testOrderBookSubParserDescribedByMetaV1Happy() (gas: 2018322) -OrderBookSubParserIERC165Test:testOrderBookSubParserIERC165(bytes4) (runs: 5116, μ: 2018691, ~: 2018691) +OrderBookSubParserIERC165Test:testOrderBookSubParserIERC165(bytes4) (runs: 5120, μ: 2018691, ~: 2018691) OrderBookSubParserPointersTest:testSubParserFunctionPointers() (gas: 2029308) OrderBookSubParserPointersTest:testSubParserOperandParsers() (gas: 2029308) OrderBookSubParserPointersTest:testSubParserParseMeta() (gas: 172448) @@ -171,70 +176,70 @@ 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: 120, μ: 971414, ~: 969392) -OrderBookTakeOrderBadStackTest:testTakeOrderBadStackOneStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 978731, ~: 976709) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO0() (gas: 241092) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO1() (gas: 405265) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO10(uint256) (runs: 120, μ: 644132, ~: 608769) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO2() (gas: 418991) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO3() (gas: 563700) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO4() (gas: 583211) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO5() (gas: 583210) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO6() (gas: 569415) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO7(uint256) (runs: 120, μ: 828013, ~: 828324) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO8(uint256) (runs: 120, μ: 986808, ~: 987119) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO9(uint256) (runs: 120, μ: 727911, ~: 663874) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert0() (gas: 233005) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert1() (gas: 391201) -OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert2() (gas: 377476) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrders(uint256,uint256) (runs: 120, μ: 414435, ~: 425042) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrdersMultipleOwners(uint256,uint256,uint256) (runs: 120, μ: 472150, ~: 483089) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleAnyDeposit(uint256,uint256) (runs: 120, μ: 261126, ~: 261943) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumInput(uint256,uint256) (runs: 120, μ: 242333, ~: 243577) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumOutput(uint256) (runs: 120, μ: 241942, ~: 241905) -OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderUnlimitedMax(uint256) (runs: 120, μ: 238883, ~: 238709) -OrderBookTakeOrderMaximumInputTest:testTakeOrderNoopZeroMaxTakerInput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,uint256[],bytes)) (runs: 120, μ: 178517, ~: 174756) -OrderBookTakeOrderNoopTest:testTakeOrderNoopNonLiveOrderOne((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)) (runs: 120, μ: 433111, ~: 412866) -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: 120, μ: 849949, ~: 841638) +OrderBookTakeOrderBadStackTest:testTakeOrderBadStackEmptyStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 966848, ~: 943156) +OrderBookTakeOrderBadStackTest:testTakeOrderBadStackOneStack(address,address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 974164, ~: 950469) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO0() (gas: 240999) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO1() (gas: 405079) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO10(uint256) (runs: 124, μ: 644196, ~: 608676) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO2() (gas: 418805) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO3() (gas: 563421) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO4() (gas: 582932) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO5() (gas: 582931) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO6() (gas: 569136) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO7(uint256) (runs: 124, μ: 827618, ~: 827754) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO8(uint256) (runs: 124, μ: 986320, ~: 986456) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderHandleIO9(uint256) (runs: 124, μ: 733459, ~: 663781) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert0() (gas: 232912) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert1() (gas: 391015) +OrderBookTakeOrderHandleIORevertTest:testTakeOrderNoHandleIORevert2() (gas: 377290) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrders(uint256,uint256) (runs: 124, μ: 412947, ~: 424856) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputMultipleOrdersMultipleOwners(uint256,uint256,uint256) (runs: 124, μ: 470231, ~: 482903) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleAnyDeposit(uint256,uint256) (runs: 124, μ: 261061, ~: 261850) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumInput(uint256,uint256) (runs: 124, μ: 243504, ~: 243484) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderLessThanMaximumOutput(uint256) (runs: 124, μ: 241854, ~: 241812) +OrderBookTakeOrderMaximumInputTest:testTakeOrderMaximumInputSingleOrderUnlimitedMax(uint256) (runs: 124, μ: 238801, ~: 238616) +OrderBookTakeOrderMaximumInputTest:testTakeOrderNoopZeroMaxTakerInput((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),(address,uint256[],bytes)) (runs: 124, μ: 179434, ~: 177315) +OrderBookTakeOrderNoopTest:testTakeOrderNoopNonLiveOrderOne((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,uint256[],bytes)) (runs: 124, μ: 433730, ~: 412866) +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: 124, μ: 847102, ~: 827948) OrderBookTakeOrderNoopTest:testTakeOrderNoopZeroOrders() (gas: 12427) -OrderBookTakeOrderPrecisionTest:testTakeOrderPrecisionKnownBad01() (gas: 2224106) -OrderBookTakeOrderSameTokenTest:testTakeOrderSameToken(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 30, μ: 798509, ~: 750217) -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: 29, μ: 653020, ~: 650740) -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: 30, μ: 665302, ~: 656765) -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: 30, μ: 666703, ~: 680544) -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: 30, μ: 665449, ~: 679290) +OrderBookTakeOrderPrecisionTest:testTakeOrderPrecisionKnownBad01() (gas: 2223083) +OrderBookTakeOrderSameTokenTest:testTakeOrderSameToken(address,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 34, μ: 804111, ~: 760276) +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: 34, μ: 669456, ~: 675872) +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: 33, μ: 669323, ~: 684876) +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: 34, μ: 658715, ~: 694240) +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: 34, μ: 668073, ~: 692986) OrderBookV4ArbOrderTakerContextTest:testOrderBookV4ArbOrderTakerContext() (gas: 2602528) -OrderBookV4ArbOrderTakerIERC165Test:testOrderBookV4ArbOrderTakerIERC165(bytes4) (runs: 5115, μ: 2374572, ~: 2374572) -OrderBookV4FlashBorrowerIERC165Test:testOrderBookV4FlashBorrowerIERC165(bytes4) (runs: 5116, μ: 2786827, ~: 2786827) -OrderBookV4FlashLenderFeeTest:testFlashFee(address,uint256) (runs: 5116, μ: 6536, ~: 6536) -OrderBookV4FlashLenderIERC165Test:testOrderBookV4FlashLenderIERC165(bytes4) (runs: 5116, μ: 580452, ~: 580452) -OrderBookV4FlashLenderMaxFlashLoanTest:testFlashMaxLoan(uint256) (runs: 5116, μ: 7981, ~: 7981) -OrderBookV4FlashLenderMockSuccessTest:testFlashLoanToReceiver(uint256,bytes) (runs: 5116, μ: 14786, ~: 14732) -OrderBookV4FlashLenderReentrant:testReenterAddOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 18194767, ~: 18185165) -OrderBookV4FlashLenderReentrant:testReenterCheckOrderExists(bytes32,uint256) (runs: 120, μ: 553734, ~: 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: 120, μ: 38278399, ~: 37480533) -OrderBookV4FlashLenderReentrant:testReenterDeposit(uint256,uint256,uint256) (runs: 120, μ: 654935, ~: 655599) -OrderBookV4FlashLenderReentrant:testReenterReadVaultBalances(uint256,uint256) (runs: 120, μ: 598689, ~: 599187) -OrderBookV4FlashLenderReentrant:testReenterRemoveOrder(uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 120, μ: 18206981, ~: 17683197) -OrderBookV4FlashLenderReentrant:testReenterTakeOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 120, μ: 18812960, ~: 18743878) -OrderBookV4FlashLenderReentrant:testReenterWithdraw(uint256,uint256,uint256) (runs: 120, μ: 631402, ~: 632066) -OrderBookV4FlashLenderTransferTest:testFlashLoanTransferFail(uint256,uint256,bool) (runs: 120, μ: 1345648, ~: 1347531) -OrderBookV4FlashLenderTransferTest:testFlashLoanTransferSuccess(uint256,bool) (runs: 120, μ: 1291806, ~: 1297531) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalEmptyNoop(address,uint256,uint256,uint256) (runs: 120, μ: 53343, ~: 54109) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneReadState(address,uint256,uint256,uint256) (runs: 120, μ: 115301, ~: 116671) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneStateless(address,uint256,uint256,uint256) (runs: 120, μ: 100684, ~: 102054) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256,uint256) (runs: 120, μ: 993643, ~: 994386) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSequential(address,uint256,uint256,uint256) (runs: 120, μ: 611291, ~: 612659) -OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSingle(address,uint256,uint256,uint256) (runs: 120, μ: 229045, ~: 230413) -OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalRevertInAction(address,uint256,uint256,uint256) (runs: 120, μ: 108288, ~: 109658) -OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalZeroAmountEvalNoop(address,uint256,uint256) (runs: 120, μ: 60976, ~: 60768) -OrderBookWithdrawEvalTest:testOrderWithdrawContext(address,uint256,uint256,uint256) (runs: 120, μ: 722770, ~: 721530) -OrderBookWithdrawTest:testWithdrawEmptyVault(address,address,uint256,uint256) (runs: 120, μ: 17802, ~: 17802) -OrderBookWithdrawTest:testWithdrawFailure(address,uint256,uint256,uint256) (runs: 120, μ: 1040419101, ~: 1040437714) -OrderBookWithdrawTest:testWithdrawFullVault(address,uint256,uint256,uint256) (runs: 110, μ: 40855, ~: 40836) -OrderBookWithdrawTest:testWithdrawMany((bool,address,address,uint256,uint248)[]) (runs: 120, μ: 3252472, ~: 3353023) -OrderBookWithdrawTest:testWithdrawPartialVault(address,uint256,uint256,uint256) (runs: 110, μ: 51385, ~: 51385) -OrderBookWithdrawTest:testWithdrawZero(address,address,uint256) (runs: 120, μ: 13382, ~: 13382) -RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 120, μ: 366932, ~: 361105) -RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 120, μ: 167491, ~: 155298) -RouteProcessorOrderBookV4ArbOrderTakerSenderTest:testRouteProcessorTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 120, μ: 264572, ~: 263505) \ No newline at end of file +OrderBookV4ArbOrderTakerIERC165Test:testOrderBookV4ArbOrderTakerIERC165(bytes4) (runs: 5119, μ: 2374572, ~: 2374572) +OrderBookV4FlashBorrowerIERC165Test:testOrderBookV4FlashBorrowerIERC165(bytes4) (runs: 5120, μ: 2786827, ~: 2786827) +OrderBookV4FlashLenderFeeTest:testFlashFee(address,uint256) (runs: 5120, μ: 6536, ~: 6536) +OrderBookV4FlashLenderIERC165Test:testOrderBookV4FlashLenderIERC165(bytes4) (runs: 5120, μ: 580452, ~: 580452) +OrderBookV4FlashLenderMaxFlashLoanTest:testFlashMaxLoan(uint256) (runs: 5120, μ: 7981, ~: 7981) +OrderBookV4FlashLenderMockSuccessTest:testFlashLoanToReceiver(uint256,bytes) (runs: 5120, μ: 14786, ~: 14732) +OrderBookV4FlashLenderReentrant:testReenterAddOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 18429209, ~: 18737951) +OrderBookV4FlashLenderReentrant:testReenterCheckOrderExists(bytes32,uint256) (runs: 124, μ: 553900, ~: 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: 124, μ: 37910299, ~: 37217229) +OrderBookV4FlashLenderReentrant:testReenterDeposit(uint256,uint256,uint256) (runs: 124, μ: 654475, ~: 655599) +OrderBookV4FlashLenderReentrant:testReenterReadVaultBalances(uint256,uint256) (runs: 124, μ: 599026, ~: 599187) +OrderBookV4FlashLenderReentrant:testReenterRemoveOrder(uint256,(address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32)) (runs: 124, μ: 18132064, ~: 17587711) +OrderBookV4FlashLenderReentrant:testReenterTakeOrder(uint256,((address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32,bytes32,bytes)) (runs: 124, μ: 19052515, ~: 19326287) +OrderBookV4FlashLenderReentrant:testReenterWithdraw(uint256,uint256,uint256) (runs: 124, μ: 630942, ~: 632066) +OrderBookV4FlashLenderTransferTest:testFlashLoanTransferFail(uint256,uint256,bool) (runs: 124, μ: 1345637, ~: 1347531) +OrderBookV4FlashLenderTransferTest:testFlashLoanTransferSuccess(uint256,bool) (runs: 124, μ: 1291779, ~: 1297531) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalEmptyNoop(address,uint256,uint256,uint256) (runs: 124, μ: 53303, ~: 54109) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneReadState(address,uint256,uint256,uint256) (runs: 124, μ: 115206, ~: 116671) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalOneStateless(address,uint256,uint256,uint256) (runs: 124, μ: 100589, ~: 102054) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateDifferentOwnersNamespaced(address,address,uint256,uint256,uint256) (runs: 124, μ: 993337, ~: 994386) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSequential(address,uint256,uint256,uint256) (runs: 124, μ: 611196, ~: 612659) +OrderBookWithdrawEvalTest:testOrderBookWithdrawEvalWriteStateSingle(address,uint256,uint256,uint256) (runs: 124, μ: 228950, ~: 230413) +OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalRevertInAction(address,uint256,uint256,uint256) (runs: 124, μ: 108192, ~: 109658) +OrderBookWithdrawEvalTest:testOrderBookWithdrawalEvalZeroAmountEvalNoop(address,uint256,uint256) (runs: 124, μ: 60997, ~: 60768) +OrderBookWithdrawEvalTest:testOrderWithdrawContext(address,uint256,uint256,uint256) (runs: 124, μ: 722980, ~: 721418) +OrderBookWithdrawTest:testWithdrawEmptyVault(address,address,uint256,uint256) (runs: 123, μ: 17802, ~: 17802) +OrderBookWithdrawTest:testWithdrawFailure(address,uint256,uint256,uint256) (runs: 124, μ: 1040419072, ~: 1040437714) +OrderBookWithdrawTest:testWithdrawFullVault(address,uint256,uint256,uint256) (runs: 112, μ: 40849, ~: 40829) +OrderBookWithdrawTest:testWithdrawMany((bool,address,address,uint256,uint248)[]) (runs: 124, μ: 3260897, ~: 3383353) +OrderBookWithdrawTest:testWithdrawPartialVault(address,uint256,uint256,uint256) (runs: 112, μ: 51385, ~: 51385) +OrderBookWithdrawTest:testWithdrawZero(address,address,uint256) (runs: 124, μ: 13382, ~: 13382) +RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,uint256[],uint256[]) (runs: 124, μ: 366920, ~: 361105) +RouteProcessorOrderBookV4ArbOrderTakerExpressionTest:testRouteProcessorTakeOrdersWrongExpression((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256,(address,address,bytes)) (runs: 124, μ: 167756, ~: 157267) +RouteProcessorOrderBookV4ArbOrderTakerSenderTest:testRouteProcessorTakeOrdersSender((address,(address,address,bytes),(address,uint8,uint256)[],(address,uint8,uint256)[],bytes32),uint256,uint256) (runs: 124, μ: 265201, ~: 262673) \ No newline at end of file diff --git a/crates/common/src/add_order.rs b/crates/common/src/add_order.rs index c373c0ea3..4289ed53c 100644 --- a/crates/common/src/add_order.rs +++ b/crates/common/src/add_order.rs @@ -484,6 +484,8 @@ price: 2e18; let token3_arc = Arc::new(token3); let known_vault_id = U256::from(1); let order = Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: "".to_string(), inputs: vec![ OrderIO { token: token1_arc.clone(), @@ -589,6 +591,8 @@ _ _: 0 0; let token2_arc = Arc::new(token2); let token3_arc = Arc::new(token3); let order = Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: "".to_string(), inputs: vec![ OrderIO { token: token1_arc.clone(), @@ -730,6 +734,8 @@ _ _: 0 0; let token3_arc = Arc::new(token3); let known_vault_id = U256::from(1); let order = Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: "".to_string(), inputs: vec![ OrderIO { token: token1_arc.clone(), diff --git a/crates/settings/src/deployment.rs b/crates/settings/src/deployment.rs index 794b79fc9..ce3f6af01 100644 --- a/crates/settings/src/deployment.rs +++ b/crates/settings/src/deployment.rs @@ -65,6 +65,8 @@ impl DeploymentConfigSource { mod tests { use super::*; use crate::test::*; + use std::sync::RwLock; + use strict_yaml_rust::StrictYaml; #[test] fn test_try_into_deployment_success() { @@ -78,6 +80,8 @@ mod tests { blocks: None, }; let order = Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: String::new(), inputs: vec![], outputs: vec![], network: mock_network(), @@ -107,6 +111,8 @@ mod tests { blocks: None, }; let order = Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: String::new(), inputs: vec![], outputs: vec![], network: mock_network(), diff --git a/crates/settings/src/gui.rs b/crates/settings/src/gui.rs index 1b1a0a1dd..219d7ff66 100644 --- a/crates/settings/src/gui.rs +++ b/crates/settings/src/gui.rs @@ -226,12 +226,15 @@ impl_all_wasm_traits!(Gui); #[cfg(test)] mod tests { + use std::sync::RwLock; + use super::*; use crate::{ test::{mock_deployer, mock_network, mock_token}, Order, Scenario, }; use alloy::primitives::Address; + use strict_yaml_rust::StrictYaml; #[test] fn test_gui_creation_success() { @@ -308,6 +311,8 @@ mod tests { blocks: None, }; let order = Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: String::new(), inputs: vec![], outputs: vec![], network: mock_network(), diff --git a/crates/settings/src/order.rs b/crates/settings/src/order.rs index a7db0f5f8..c72a32d9f 100644 --- a/crates/settings/src/order.rs +++ b/crates/settings/src/order.rs @@ -1,9 +1,18 @@ use crate::*; use alloy::primitives::U256; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, sync::Arc}; +use std::{ + collections::HashMap, + str::FromStr, + sync::{Arc, RwLock}, +}; +use strict_yaml_rust::StrictYaml; use thiserror::Error; use typeshare::typeshare; +use yaml::{ + default_document, optional_string, require_hash, require_string, require_vec, YamlError, + YamlParsableHash, +}; #[cfg(target_family = "wasm")] use rain_orderbook_bindings::{impl_all_wasm_traits, wasm_traits::prelude::*}; @@ -27,10 +36,13 @@ pub struct OrderIO { impl_all_wasm_traits!(OrderIO); #[typeshare] -#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)] +#[derive(Debug, Serialize, Deserialize, Clone)] #[cfg_attr(target_family = "wasm", derive(Tsify))] #[serde(rename_all = "kebab-case")] pub struct Order { + #[serde(skip, default = "default_document")] + pub document: Arc>, + pub key: String, #[typeshare(typescript(type = "OrderIO[]"))] #[cfg_attr(target_family = "wasm", tsify(type = "Vault[]"))] pub inputs: Vec, @@ -47,6 +59,189 @@ pub struct Order { #[cfg(target_family = "wasm")] impl_all_wasm_traits!(Order); +impl Order { + pub fn validate_vault_id(value: &str) -> Result { + U256::from_str(value).map_err(ParseOrderConfigSourceError::VaultParseError) + } +} + +impl YamlParsableHash for Order { + fn parse_all_from_yaml( + document: Arc>, + ) -> Result, YamlError> { + let document_read = document.read().map_err(|_| YamlError::ReadLockError)?; + let orders_hash = require_hash( + &document_read, + Some("orders"), + Some("missing field: orders".to_string()), + )?; + + orders_hash + .into_iter() + .map(|(key_yaml, order_yaml)| { + let order_key = key_yaml.as_str().unwrap_or_default().to_string(); + + let mut network: Option> = None; + + let deployer = match optional_string(order_yaml, "deployer") { + Some(deployer_name) => { + let deployer = + Arc::new(Deployer::parse_from_yaml(document.clone(), &deployer_name)?); + if let Some(n) = &network { + if deployer.network != *n { + return Err(YamlError::ParseOrderConfigSourceError( + ParseOrderConfigSourceError::NetworkNotMatch, + )); + } + } else { + network = Some(deployer.network.clone()); + } + Some(deployer) + } + None => None, + }; + + let orderbook = match optional_string(order_yaml, "orderbook") { + Some(orderbook_name) => { + let orderbook = Arc::new(Orderbook::parse_from_yaml( + document.clone(), + &orderbook_name, + )?); + if let Some(n) = &network { + if orderbook.network != *n { + return Err(YamlError::ParseOrderConfigSourceError( + ParseOrderConfigSourceError::NetworkNotMatch, + )); + } + } else { + network = Some(orderbook.network.clone()); + } + Some(orderbook) + } + None => None, + }; + + let inputs = require_vec( + order_yaml, + "inputs", + Some(format!("inputs list missing in order: {order_key}")), + )? + .iter() + .enumerate() + .map(|(i, input)| { + let token_name = require_string( + input, + Some("token"), + Some(format!( + "token string missing in input index: {i} in order: {order_key}" + )), + )?; + let token = Token::parse_from_yaml(document.clone(), &token_name)?; + + if let Some(n) = &network { + if token.network != *n { + return Err(YamlError::ParseOrderConfigSourceError( + ParseOrderConfigSourceError::NetworkNotMatch, + )); + } + } else { + network = Some(token.network.clone()); + } + + let vault_id = match optional_string(input, "vault-id") { + Some(id) => Some(Order::validate_vault_id(&id)?), + None => None, + }; + + Ok(OrderIO { + token: Arc::new(token), + vault_id, + }) + }) + .collect::, YamlError>>()?; + + let outputs = require_vec( + order_yaml, + "outputs", + Some(format!("outputs list missing in order: {order_key}")), + )? + .iter() + .enumerate() + .map(|(i, output)| { + let token_name = require_string( + output, + Some("token"), + Some(format!( + "token string missing in output index: {i} in order: {order_key}" + )), + )?; + let token = Token::parse_from_yaml(document.clone(), &token_name)?; + + if let Some(n) = &network { + if token.network != *n { + return Err(YamlError::ParseOrderConfigSourceError( + ParseOrderConfigSourceError::NetworkNotMatch, + )); + } + } else { + network = Some(token.network.clone()); + } + + let vault_id = match optional_string(output, "vault-id") { + Some(id) => Some(Order::validate_vault_id(&id)?), + None => None, + }; + + Ok(OrderIO { + token: Arc::new(token), + vault_id, + }) + }) + .collect::, YamlError>>()?; + + let order = Order { + document: document.clone(), + key: order_key.clone(), + inputs, + outputs, + network: network.ok_or(ParseOrderConfigSourceError::NetworkNotFoundError( + String::new(), + ))?, + deployer, + orderbook, + }; + + Ok((order_key, order)) + }) + .collect() + } +} + +impl Default for Order { + fn default() -> Self { + Self { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: String::new(), + inputs: vec![], + outputs: vec![], + network: Arc::new(Network::default()), + deployer: None, + orderbook: None, + } + } +} + +impl PartialEq for Order { + fn eq(&self, other: &Self) -> bool { + self.key == other.key + && self.inputs == other.inputs + && self.outputs == other.outputs + && self.network == other.network + && self.deployer == other.deployer + && self.orderbook == other.orderbook + } +} + #[derive(Error, Debug, PartialEq)] pub enum ParseOrderConfigSourceError { #[error("Failed to parse deployer")] @@ -181,6 +376,8 @@ impl OrderConfigSource { .collect::, _>>()?; Ok(Order { + document: Arc::new(RwLock::new(StrictYaml::String("".to_string()))), + key: String::new(), inputs, outputs, network: network.ok_or(ParseOrderConfigSourceError::NetworkNotFoundError( @@ -194,6 +391,8 @@ impl OrderConfigSource { #[cfg(test)] mod tests { + use yaml::tests::get_document; + use super::*; use crate::test::*; @@ -327,4 +526,96 @@ mod tests { Err(ParseOrderConfigSourceError::TokenParseError(_)) )); } + + #[test] + fn test_parse_orders_from_yaml() { + let yaml = r#" +test: test +"#; + let error = Order::parse_all_from_yaml(get_document(yaml)).unwrap_err(); + assert_eq!( + error, + YamlError::ParseError("missing field: orders".to_string()) + ); + + let yaml = r#" +orders: + order1: +"#; + let error = Order::parse_all_from_yaml(get_document(yaml)).unwrap_err(); + assert_eq!( + error, + YamlError::ParseError("inputs list missing in order: order1".to_string()) + ); + + let yaml = r#" +orders: + order1: + inputs: + - test: test +"#; + let error = Order::parse_all_from_yaml(get_document(yaml)).unwrap_err(); + assert_eq!( + error, + YamlError::ParseError( + "token string missing in input index: 0 in order: order1".to_string() + ) + ); + + let yaml = r#" +orders: + order1: + inputs: + - token: eth +"#; + let error = Order::parse_all_from_yaml(get_document(yaml)).unwrap_err(); + assert_eq!( + error, + YamlError::ParseError("missing field: tokens".to_string()) + ); + + let yaml = r#" +networks: + mainnet: + rpc: "https://mainnet.infura.io" + chain-id: "1" +tokens: + eth: + network: mainnet + address: 0x1234567890123456789012345678901234567890 +orders: + order1: + inputs: + - token: eth +"#; + let error = Order::parse_all_from_yaml(get_document(yaml)).unwrap_err(); + assert_eq!( + error, + YamlError::ParseError("outputs list missing in order: order1".to_string()) + ); + + let yaml = r#" +networks: + mainnet: + rpc: "https://mainnet.infura.io" + chain-id: "1" +tokens: + eth: + network: mainnet + address: 0x1234567890123456789012345678901234567890 +orders: + order1: + inputs: + - token: eth + outputs: + - test: test +"#; + let error = Order::parse_all_from_yaml(get_document(yaml)).unwrap_err(); + assert_eq!( + error, + YamlError::ParseError( + "token string missing in output index: 0 in order: order1".to_string() + ) + ); + } } diff --git a/crates/settings/src/yaml/dotrain.rs b/crates/settings/src/yaml/dotrain.rs index d09c1f2ee..8129b057f 100644 --- a/crates/settings/src/yaml/dotrain.rs +++ b/crates/settings/src/yaml/dotrain.rs @@ -1,4 +1,5 @@ use super::*; +use crate::Order; use std::sync::{Arc, RwLock}; #[derive(Debug, Clone)] @@ -7,7 +8,7 @@ pub struct DotrainYaml { } impl YamlParsable for DotrainYaml { - fn new(source: String, _validate: bool) -> Result { + fn new(source: String, validate: bool) -> Result { let docs = StrictYamlLoader::load_from_str(&source)?; if docs.is_empty() { return Err(YamlError::EmptyFile); @@ -15,8 +16,79 @@ impl YamlParsable for DotrainYaml { let doc = docs[0].clone(); let document = Arc::new(RwLock::new(doc)); + if validate { + Order::parse_all_from_yaml(document.clone())?; + } + Ok(DotrainYaml { document }) } } -impl DotrainYaml {} +impl DotrainYaml { + pub fn get_order_keys(&self) -> Result, YamlError> { + let orders = Order::parse_all_from_yaml(self.document.clone())?; + Ok(orders.keys().cloned().collect()) + } + pub fn get_order(&self, key: &str) -> Result { + Order::parse_from_yaml(self.document.clone(), key) + } +} + +#[cfg(test)] +mod tests { + use alloy::primitives::U256; + use orderbook::OrderbookYaml; + + use super::*; + + const FULL_YAML: &str = r#" + networks: + mainnet: + rpc: https://mainnet.infura.io + chain-id: 1 + tokens: + token1: + network: mainnet + address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 + decimals: 18 + label: Wrapped Ether + symbol: WETH + token2: + network: mainnet + address: 0x0000000000000000000000000000000000000002 + decimals: 6 + label: USD Coin + symbol: USDC + orders: + order1: + inputs: + - token: token1 + vault-id: 1 + outputs: + - token: token2 + vault-id: 2 + "#; + + #[test] + fn test_full_yaml() { + let ob_yaml = OrderbookYaml::new(FULL_YAML.to_string(), false).unwrap(); + let dotrain_yaml = DotrainYaml::new(FULL_YAML.to_string(), false).unwrap(); + + assert_eq!(dotrain_yaml.get_order_keys().unwrap().len(), 1); + let order = dotrain_yaml.get_order("order1").unwrap(); + assert_eq!(order.inputs.len(), 1); + let input = order.inputs.first().unwrap(); + assert_eq!( + *input.token.clone().as_ref(), + ob_yaml.get_token("token1").unwrap() + ); + assert_eq!(input.vault_id, Some(U256::from(1))); + let output = order.outputs.first().unwrap(); + assert_eq!(*output.token.as_ref(), ob_yaml.get_token("token2").unwrap()); + assert_eq!(output.vault_id, Some(U256::from(2))); + assert_eq!( + *order.network.as_ref(), + ob_yaml.get_network("mainnet").unwrap() + ); + } +} diff --git a/crates/settings/src/yaml/mod.rs b/crates/settings/src/yaml/mod.rs index 144a06a70..c7d788618 100644 --- a/crates/settings/src/yaml/mod.rs +++ b/crates/settings/src/yaml/mod.rs @@ -2,9 +2,10 @@ pub mod dotrain; pub mod orderbook; use crate::{ - ParseDeployerConfigSourceError, ParseNetworkConfigSourceError, ParseOrderbookConfigSourceError, - ParseTokenConfigSourceError, + ParseDeployerConfigSourceError, ParseNetworkConfigSourceError, ParseOrderConfigSourceError, + ParseOrderbookConfigSourceError, ParseTokenConfigSourceError, }; +use alloy::primitives::ruint::ParseError as RuintParseError; use std::collections::HashMap; use std::sync::{Arc, RwLock}; use std::sync::{PoisonError, RwLockReadGuard, RwLockWriteGuard}; @@ -65,6 +66,8 @@ pub enum YamlError { RwLockWriteGuardError(#[from] PoisonError>), #[error(transparent)] UrlParseError(#[from] UrlParseError), + #[error(transparent)] + RuintParseError(#[from] RuintParseError), #[error("Yaml file is empty")] EmptyFile, #[error("Yaml parse error: {0}")] @@ -89,6 +92,8 @@ pub enum YamlError { ParseOrderbookConfigSourceError(#[from] ParseOrderbookConfigSourceError), #[error(transparent)] ParseDeployerConfigSourceError(#[from] ParseDeployerConfigSourceError), + #[error(transparent)] + ParseOrderConfigSourceError(#[from] ParseOrderConfigSourceError), } impl PartialEq for YamlError { fn eq(&self, other: &Self) -> bool { @@ -185,6 +190,10 @@ pub fn optional_vec<'a>(value: &'a StrictYaml, field: &str) -> Option<&'a Array> value[field].as_vec() } +pub fn default_document() -> Arc> { + Arc::new(RwLock::new(StrictYaml::String("".to_string()))) +} + #[cfg(test)] pub mod tests { use super::*; diff --git a/packages/orderbook/test/js_api/gui.test.ts b/packages/orderbook/test/js_api/gui.test.ts index e59614544..b93f496f9 100644 --- a/packages/orderbook/test/js_api/gui.test.ts +++ b/packages/orderbook/test/js_api/gui.test.ts @@ -592,7 +592,7 @@ describe('Rain Orderbook JS API Package Bindgen Tests - Gui', async function () describe('state management tests', async () => { let serializedState = - 'H4sIAAAAAAAA_3WNQQrCQAxFWxXRW7gWlGQ6k0l3HsErTDoZKUIF7cLjK5hxIfg3L_kJ_5-aj2IKAT2heI5DiDkUIonYvV1mUQZMQCUF7gmzZ6WcncMiiTtxoLqwnK1RximP0-WArRnQbmw63_Wh8w739fJE1_lAkXtIMmQt__bfcNdULY0IUAvXxvl21Qm_nytjgCO9AAAqf6L9AAAA'; + 'H4sIAAAAAAAA_3WPTQoCMQyFZ1REb-FaUJq26TQ7j-AV0k4qg1BBZ-HxFUxdCL7Nlz_eI6fuI7DekQOkDHnIgdlxZBY_SikpcLFiLQsigCOIPpkEBYjIx1FCxLxQn60yTXWc6uUAvQ5Mv9HqfJeHzDvYt80TrPMYhkiGU34n_ut_zW3XtGxvGNMC18r5dpUK38uVEs0xvAARbQwj_QAAAA=='; let gui: DotrainOrderGui; beforeAll(async () => { mockServer diff --git a/packages/ui-components/src/__tests__/InputToken.test.ts b/packages/ui-components/src/__tests__/InputToken.test.ts new file mode 100644 index 000000000..c1e808027 --- /dev/null +++ b/packages/ui-components/src/__tests__/InputToken.test.ts @@ -0,0 +1,39 @@ +import { render, fireEvent } from '@testing-library/svelte'; +import InputToken from '../lib/components/input/InputToken.svelte'; + +describe('InputToken', () => { + it('renders with initial values', () => { + const address = '0xc0D477556c25C9d67E1f57245C7453DA776B51cf'; + const decimals = 10; + const { getByTestId } = render(InputToken, { props: { address, decimals } }); + + const input = getByTestId('token-address').querySelector('input'); + expect(input?.value).toBe('0xc0D477556c25C9d67E1f57245C7453DA776B51cf'); + const decimalsInput = getByTestId('token-decimals-input').querySelector('input'); + expect(decimalsInput?.value).toBe('10'); + }); + + it('shows error for invalid address', async () => { + const address = 'abc'; + const decimals = 0; + const { getByTestId, getByText } = render(InputToken, { props: { address, decimals } }); + + const addressInput = getByTestId('token-address').querySelector('input') as HTMLInputElement; + await fireEvent.input(addressInput, { target: { value: 'invalidAddress' } }); + + expect(getByText('Invalid Address')).toBeInTheDocument(); + }); + + it('does not show error for valid address', async () => { + const address = ''; + const decimals = 0; + const { getByTestId, queryByText } = render(InputToken, { props: { address, decimals } }); + + const addressInput = getByTestId('token-address').querySelector('input') as HTMLInputElement; + await fireEvent.input(addressInput, { + target: { value: '0xc0D477556c25C9d67E1f57245C7453DA776B51cf' } + }); + + expect(queryByText('Invalid Address')).toBeNull(); + }); +}); diff --git a/packages/ui-components/src/additional-svelte-typings.d.ts b/packages/ui-components/src/additional-svelte-typings.d.ts new file mode 100644 index 000000000..cc18f8751 --- /dev/null +++ b/packages/ui-components/src/additional-svelte-typings.d.ts @@ -0,0 +1,7 @@ +declare namespace svelteHTML { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + interface HTMLAttributes { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + 'on:complete'?: (event: any) => any; + } +} diff --git a/packages/ui-components/src/lib/components/input/InputToken.svelte b/packages/ui-components/src/lib/components/input/InputToken.svelte new file mode 100644 index 000000000..935674c55 --- /dev/null +++ b/packages/ui-components/src/lib/components/input/InputToken.svelte @@ -0,0 +1,60 @@ + + +
+
+
+ +
+ + {#if !isAddressValid && address.length > 0} + Invalid Address + {/if} + + Token Address +
+
+ + Decimals +
+
diff --git a/packages/ui-components/src/lib/index.ts b/packages/ui-components/src/lib/index.ts index 499585443..01a33a489 100644 --- a/packages/ui-components/src/lib/index.ts +++ b/packages/ui-components/src/lib/index.ts @@ -56,6 +56,8 @@ export { default as TokenOutput } from './components/deployment/wizard/TokenOutp export { default as SelectToken } from './components/deployment/SelectToken.svelte'; export { default as TokenInputButtons } from './components/deployment/wizard/TokenInputButtons.svelte'; export { default as TokenOutputButtons } from './components/deployment/wizard/TokenOutputButtons.svelte'; +export { default as InputToken } from './components/input/InputToken.svelte'; + //Types export type { AppStoresInterface } from './types/appStores.ts'; export type { ConfigSource, OrderbookConfigSource, OrderbookRef } from './typeshare/config'; diff --git a/packages/webapp/src/routes/deployment/+page.svelte b/packages/webapp/src/routes/deployment/+page.svelte index 3a9de6354..71326c693 100644 --- a/packages/webapp/src/routes/deployment/+page.svelte +++ b/packages/webapp/src/routes/deployment/+page.svelte @@ -15,6 +15,7 @@ type DepositAndAddOrderCalldataResult, type GuiDeposit, type GuiFieldDefinition, + type Network, type SelectTokens, type TokenInfos, type Vault @@ -155,7 +156,7 @@ await window.ethereum?.request({ method: 'eth_requestAccounts' }); const walletClient = createWalletClient({ chain: getChainById( - gui.getCurrentDeployment().deployment.order.network['chain-id'] as number + (gui.getCurrentDeployment().deployment.order.network as Network)['chain-id'] as number ), // @ts-expect-error window.ethereum is not typed transport: custom(window.ethereum!) diff --git a/src/concrete/ob/OrderBook.sol b/src/concrete/ob/OrderBook.sol index a8c7ef6d9..44baa77a1 100644 --- a/src/concrete/ob/OrderBook.sol +++ b/src/concrete/ob/OrderBook.sol @@ -786,14 +786,18 @@ contract OrderBook is IOrderBookV4, IMetaV1_2, ReentrancyGuard, Multicall, Order new uint256[](0) ); - // This is redundant with the array index checks implied by solidity - // but it's a much clearer error message. + // This is a much clearer error message and overall is more efficient + // than solidity generic index out of bounds errors. if (calculateOrderStack.length < CALCULATE_ORDER_MIN_OUTPUTS) { revert UnsupportedCalculateOutputs(calculateOrderStack.length); } - Output18Amount orderOutputMax18 = Output18Amount.wrap(calculateOrderStack[1]); - uint256 orderIORatio = calculateOrderStack[0]; + uint256 orderIORatio; + Output18Amount orderOutputMax18; + assembly ("memory-safe") { + orderIORatio := mload(add(calculateOrderStack, 0x20)) + orderOutputMax18 := mload(add(calculateOrderStack, 0x40)) + } { // The order owner can't send more than the smaller of their vault @@ -954,36 +958,41 @@ contract OrderBook is IOrderBookV4, IMetaV1_2, ReentrancyGuard, Multicall, Order OrderIOCalculationV2 memory aliceOrderIOCalculation, OrderIOCalculationV2 memory bobOrderIOCalculation ) internal pure returns (uint256 aliceInput, uint256 aliceOutput) { + // Alice's input is her output * her IO ratio. // Always round IO calculations up so that the counterparty pays more. - // This is the max input that bob can afford, given his own IO ratio - // and maximum spend/output. - Input18Amount bobInputMax18 = Input18Amount.wrap( - Output18Amount.unwrap(bobOrderIOCalculation.outputMax).fixedPointMul( - bobOrderIOCalculation.IORatio, Math.Rounding.Up + Input18Amount aliceInputMax18 = Input18Amount.wrap( + Output18Amount.unwrap(aliceOrderIOCalculation.outputMax).fixedPointMul( + aliceOrderIOCalculation.IORatio, Math.Rounding.Up ) ); Output18Amount aliceOutputMax18 = aliceOrderIOCalculation.outputMax; - // Alice's doesn't need to provide more output than bob's max input. - if (Output18Amount.unwrap(aliceOutputMax18) > Input18Amount.unwrap(bobInputMax18)) { - aliceOutputMax18 = Output18Amount.wrap(Input18Amount.unwrap(bobInputMax18)); + + // If Alice's input is greater than Bob's max output, Alice's input is + // capped at Bob's max output. + if (Input18Amount.unwrap(aliceInputMax18) > Output18Amount.unwrap(bobOrderIOCalculation.outputMax)) { + aliceInputMax18 = Input18Amount.wrap(Output18Amount.unwrap(bobOrderIOCalculation.outputMax)); + + // Alice's output is capped at her input / her IO ratio. + // Round down to benefit Alice. + aliceOutputMax18 = Output18Amount.wrap( + Input18Amount.unwrap(aliceInputMax18).fixedPointDiv(aliceOrderIOCalculation.IORatio, Math.Rounding.Down) + ); } + // Alice's final output is the scaled version of the 18 decimal output, // rounded down to benefit Alice. aliceOutput = Output18Amount.unwrap(aliceOutputMax18).scaleN( aliceOrderIOCalculation.order.validOutputs[aliceOrderIOCalculation.outputIOIndex].decimals, 0 ); - // Alice's input is her bob-capped output * her IO ratio, rounded up. - Input18Amount aliceInput18 = Input18Amount.wrap( - Output18Amount.unwrap(aliceOutputMax18).fixedPointMul(aliceOrderIOCalculation.IORatio, Math.Rounding.Up) - ); - aliceInput = + // Alice's final input is the scaled version of the 18 decimal input, + // rounded up to benefit Alice. // Use bob's output decimals as alice's input decimals. // // This is only safe if we have previously checked that the decimals // match for alice and bob per token, otherwise bob could manipulate // alice's intent. - Input18Amount.unwrap(aliceInput18).scaleN( + aliceInput = Input18Amount.unwrap(aliceInputMax18).scaleN( bobOrderIOCalculation.order.validOutputs[bobOrderIOCalculation.outputIOIndex].decimals, FLAG_ROUND_UP ); } diff --git a/tauri-app/src/lib/components/InputToken.svelte b/tauri-app/src/lib/components/InputToken.svelte deleted file mode 100644 index b5d4f2934..000000000 --- a/tauri-app/src/lib/components/InputToken.svelte +++ /dev/null @@ -1,60 +0,0 @@ - - -
-
-
- -
- - {#if !isAddressValid && address.length > 0} - Invalid Address - {/if} - - Token Address -
-
- - Decimals -
-
diff --git a/tauri-app/src/lib/components/ModalVaultDepositGeneric.svelte b/tauri-app/src/lib/components/ModalVaultDepositGeneric.svelte index 277fa44ae..5c83e956f 100644 --- a/tauri-app/src/lib/components/ModalVaultDepositGeneric.svelte +++ b/tauri-app/src/lib/components/ModalVaultDepositGeneric.svelte @@ -6,7 +6,7 @@ vaultDepositApproveCalldata, vaultDepositCalldata, } from '$lib/services/vault'; - import InputToken from '$lib/components/InputToken.svelte'; + import { InputToken } from '@rainlanguage/ui-components'; import InputVaultId from '$lib/components/InputVaultId.svelte'; import { orderbookAddress } from '$lib/stores/settings'; import { checkAllowance, ethersExecute } from '$lib/services/ethersTx'; diff --git a/tauri-app/src/tests/pickConfig.test.ts b/tauri-app/src/tests/pickConfig.test.ts index 2e4b36044..96532bf24 100644 --- a/tauri-app/src/tests/pickConfig.test.ts +++ b/tauri-app/src/tests/pickConfig.test.ts @@ -48,6 +48,7 @@ export const config: Config = { tokens: {}, orders: { buy: { + key: 'buy', inputs: [], outputs: [], network: { @@ -57,6 +58,7 @@ export const config: Config = { }, }, sell: { + key: 'sell', inputs: [], outputs: [], network: { @@ -124,6 +126,7 @@ export const config: Config = { }, }, order: { + key: 'sell', inputs: [], outputs: [], network: { @@ -148,6 +151,7 @@ export const config: Config = { }, }, order: { + key: 'buy', inputs: [], outputs: [], network: { diff --git a/test/concrete/ob/OrderBook.clear.mock.t.sol b/test/concrete/ob/OrderBook.clear.mock.t.sol index e7cee4a81..be2e982b8 100644 --- a/test/concrete/ob/OrderBook.clear.mock.t.sol +++ b/test/concrete/ob/OrderBook.clear.mock.t.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 thedavidmeister pragma solidity =0.8.25; -import {Test} from "forge-std/Test.sol"; +import {Test, stdError} from "forge-std/Test.sol"; import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; import {OrderBookExternalMockTest} from "test/util/abstract/OrderBookExternalMockTest.sol"; @@ -18,26 +18,32 @@ import { } from "rain.orderbook.interface/interface/IOrderBookV4.sol"; import {LibTestAddOrder} from "test/util/lib/LibTestAddOrder.sol"; import {NotOrderOwner} from "src/concrete/ob/OrderBook.sol"; +import {LibNamespace} from "rain.interpreter.interface/lib/ns/LibNamespace.sol"; +import {StateNamespace} from "rain.interpreter.interface/interface/IInterpreterV3.sol"; +import {LibFixedPointDecimalArithmeticOpenZeppelin} from + "rain.math.fixedpoint/lib/LibFixedPointDecimalArithmeticOpenZeppelin.sol"; +import {Math} from "openzeppelin-contracts/contracts/utils/math/Math.sol"; /// @title OrderBookClearTest /// Tests clearing an order. contract OrderBookClearTest is OrderBookExternalMockTest { - /// forge-config: default.fuzz.runs = 100 - function testClearSimple( - address alice, - OrderConfigV3 memory aliceConfig, - address bob, - OrderConfigV3 memory bobConfig, - bytes memory expression, - address bountyBot, - uint256 aliceBountyVaultId, - uint256 bobBountyVaultId - ) public { - // Different accounts - vm.assume(alice != bob); - vm.assume(alice != bountyBot); - vm.assume(bob != bountyBot); - vm.assume(aliceBountyVaultId != bobBountyVaultId); + using LibFixedPointDecimalArithmeticOpenZeppelin for uint256; + using Math for uint256; + + /// Make a deposit to the OB mocking the internal transferFrom call. + function _depositInternal(address depositor, address token, uint256 vaultId, uint256 amount) internal { + vm.prank(depositor); + vm.mockCall( + token, + abi.encodeWithSelector(IERC20.transferFrom.selector, depositor, address(iOrderbook), amount), + abi.encode(true) + ); + iOrderbook.deposit2(address(token), vaultId, amount, new TaskV1[](0)); + + assertEq(iOrderbook.vaultBalance(depositor, token, vaultId), amount); + } + + function conformBasicConfig(OrderConfigV3 memory aliceConfig, OrderConfigV3 memory bobConfig) internal view { vm.assume(aliceConfig.validInputs.length > 0); vm.assume(aliceConfig.validOutputs.length > 0); vm.assume(bobConfig.validInputs.length > 0); @@ -62,93 +68,457 @@ contract OrderBookClearTest is OrderBookExternalMockTest { aliceConfig.meta = ""; bobConfig.meta = ""; + } + + struct CheckClear { + address alice; + OrderConfigV3 aliceConfig; + address bob; + OrderConfigV3 bobConfig; + address bountyBot; + uint256 aliceBountyVaultId; + uint256 bobBountyVaultId; + uint256 aliceAmount; + uint256 bobAmount; + bytes expression; + uint256[] orderStackAlice; + uint256[] orderStackBob; + uint256 expectedAliceOutput; + uint256 expectedBobOutput; + uint256 expectedAliceInput; + uint256 expectedBobInput; + bytes expectedError; + } + + function checkClear(CheckClear memory clear) internal { + vm.assume(clear.alice != clear.bob); + vm.assume(clear.alice != clear.bountyBot); + vm.assume(clear.bob != clear.bountyBot); + vm.assume(clear.aliceBountyVaultId != clear.bobBountyVaultId); - uint256 amount = 2e18; + conformBasicConfig(clear.aliceConfig, clear.bobConfig); + vm.assume(keccak256(clear.aliceConfig.evaluable.bytecode) != keccak256(clear.bobConfig.evaluable.bytecode)); - _depositInternal(alice, aliceConfig.validOutputs[0].token, aliceConfig.validOutputs[0].vaultId, amount); - _depositInternal(bob, bobConfig.validOutputs[0].token, bobConfig.validOutputs[0].vaultId, amount); + _depositInternal( + clear.alice, + clear.aliceConfig.validOutputs[0].token, + clear.aliceConfig.validOutputs[0].vaultId, + clear.aliceAmount + ); + _depositInternal( + clear.bob, clear.bobConfig.validOutputs[0].token, clear.bobConfig.validOutputs[0].vaultId, clear.bobAmount + ); assertEq( - iOrderbook.vaultBalance(alice, aliceConfig.validInputs[0].token, aliceConfig.validInputs[0].vaultId), 0 + iOrderbook.vaultBalance( + clear.alice, clear.aliceConfig.validInputs[0].token, clear.aliceConfig.validInputs[0].vaultId + ), + 0 ); assertEq( - iOrderbook.vaultBalance(alice, aliceConfig.validOutputs[0].token, aliceConfig.validOutputs[0].vaultId), - amount + iOrderbook.vaultBalance( + clear.alice, clear.aliceConfig.validOutputs[0].token, clear.aliceConfig.validOutputs[0].vaultId + ), + clear.aliceAmount ); - assertEq(iOrderbook.vaultBalance(bob, bobConfig.validInputs[0].token, bobConfig.validInputs[0].vaultId), 0); assertEq( - iOrderbook.vaultBalance(bob, bobConfig.validOutputs[0].token, bobConfig.validOutputs[0].vaultId), amount + iOrderbook.vaultBalance( + clear.bob, clear.bobConfig.validInputs[0].token, clear.bobConfig.validInputs[0].vaultId + ), + 0 + ); + assertEq( + iOrderbook.vaultBalance( + clear.bob, clear.bobConfig.validOutputs[0].token, clear.bobConfig.validOutputs[0].vaultId + ), + clear.bobAmount ); - assertEq(iOrderbook.vaultBalance(bountyBot, address(iToken0), aliceBountyVaultId), 0); - assertEq(iOrderbook.vaultBalance(bountyBot, address(iToken1), bobBountyVaultId), 0); + assertEq(iOrderbook.vaultBalance(clear.bountyBot, address(iToken0), clear.aliceBountyVaultId), 0); + assertEq(iOrderbook.vaultBalance(clear.bountyBot, address(iToken1), clear.bobBountyVaultId), 0); { - (OrderV3 memory aliceOrder, bytes32 aliceOrderHash) = addOrderWithChecks(alice, aliceConfig, expression); - assertTrue(iOrderbook.orderExists(aliceOrderHash)); + { + bytes memory call = abi.encodeWithSelector( + IInterpreterV3.eval3.selector, + clear.aliceConfig.evaluable.store, + LibNamespace.qualifyNamespace( + StateNamespace.wrap(uint256(uint160(clear.alice))), address(iOrderbook) + ) + ); + + vm.mockCall(address(iInterpreter), call, abi.encode(clear.orderStackAlice, new uint256[](0))); - (OrderV3 memory bobOrder, bytes32 bobOrderHash) = addOrderWithChecks(bob, bobConfig, expression); - assertTrue(iOrderbook.orderExists(bobOrderHash)); + call = abi.encodeWithSelector( + IInterpreterV3.eval3.selector, + clear.bobConfig.evaluable.store, + LibNamespace.qualifyNamespace(StateNamespace.wrap(uint256(uint160(clear.bob))), address(iOrderbook)) + ); + + vm.mockCall(address(iInterpreter), call, abi.encode(clear.orderStackBob, new uint256[](0))); + } + + OrderV3 memory aliceOrder; + OrderV3 memory bobOrder; + { + (aliceOrder,) = addOrderWithChecks(clear.alice, clear.aliceConfig, clear.expression); + (bobOrder,) = addOrderWithChecks(clear.bob, clear.bobConfig, clear.expression); + } ClearConfig memory configClear = ClearConfig({ aliceInputIOIndex: 0, aliceOutputIOIndex: 0, bobInputIOIndex: 0, bobOutputIOIndex: 0, - aliceBountyVaultId: aliceBountyVaultId, - bobBountyVaultId: bobBountyVaultId + aliceBountyVaultId: clear.aliceBountyVaultId, + bobBountyVaultId: clear.bobBountyVaultId }); - { - // Mock the interpreter.eval that is used inside clear().calculateOrderIO() - // Produce the stack output for OB - uint256[] memory orderStackBob = new uint256[](2); - orderStackBob[0] = 99e16; // orderIORatio - orderStackBob[1] = 5e17; // orderOutputMax - vm.mockCall( - address(iInterpreter), - abi.encodeWithSelector(IInterpreterV3.eval3.selector), - abi.encode(orderStackBob, new uint256[](0)) - ); + vm.prank(clear.bountyBot); + if (clear.expectedError.length > 0) { + vm.expectRevert(clear.expectedError); } - - vm.prank(bountyBot); iOrderbook.clear2(aliceOrder, bobOrder, configClear, new SignedContextV1[](0), new SignedContextV1[](0)); } assertEq( - iOrderbook.vaultBalance(alice, aliceConfig.validInputs[0].token, aliceConfig.validInputs[0].vaultId), - 0.49005e18 + iOrderbook.vaultBalance( + clear.alice, clear.aliceConfig.validOutputs[0].token, clear.aliceConfig.validOutputs[0].vaultId + ), + clear.aliceAmount - clear.expectedAliceOutput, + "Alice output vault" ); assertEq( - iOrderbook.vaultBalance(alice, aliceConfig.validOutputs[0].token, aliceConfig.validOutputs[0].vaultId), - 1.505e18 + iOrderbook.vaultBalance( + clear.alice, clear.aliceConfig.validInputs[0].token, clear.aliceConfig.validInputs[0].vaultId + ), + clear.expectedAliceInput, + "Alice input vault" ); assertEq( - iOrderbook.vaultBalance(bob, bobConfig.validInputs[0].token, bobConfig.validInputs[0].vaultId), 0.49005e18 + iOrderbook.vaultBalance( + clear.bob, clear.bobConfig.validOutputs[0].token, clear.bobConfig.validOutputs[0].vaultId + ), + clear.bobAmount - clear.expectedBobOutput, + "Bob output vault" ); assertEq( - iOrderbook.vaultBalance(bob, bobConfig.validOutputs[0].token, bobConfig.validOutputs[0].vaultId), 1.505e18 + iOrderbook.vaultBalance( + clear.bob, clear.bobConfig.validInputs[0].token, clear.bobConfig.validInputs[0].vaultId + ), + clear.expectedBobInput, + // clear.expectedBobOutput.fixedPointMul(clear.orderStackBob[0], Math.Rounding.Up), + "Bob input vault" ); - assertEq(iOrderbook.vaultBalance(bountyBot, address(iToken0), aliceBountyVaultId), 0); - assertEq(iOrderbook.vaultBalance(bountyBot, address(iToken1), aliceBountyVaultId), 0.00495e18); - assertEq(iOrderbook.vaultBalance(bountyBot, address(iToken1), bobBountyVaultId), 0); - assertEq(iOrderbook.vaultBalance(bountyBot, address(iToken0), bobBountyVaultId), 0.00495e18); + assertEq( + iOrderbook.vaultBalance(clear.bountyBot, clear.aliceConfig.validOutputs[0].token, clear.aliceBountyVaultId), + clear.expectedAliceOutput - clear.expectedBobInput, + "Alice bounty" + ); + assertEq( + iOrderbook.vaultBalance(clear.bountyBot, clear.aliceConfig.validInputs[0].token, clear.aliceBountyVaultId), + 0, + "Alice bounty input" + ); + assertEq( + iOrderbook.vaultBalance(clear.bountyBot, clear.bobConfig.validOutputs[0].token, clear.bobBountyVaultId), + clear.expectedBobOutput - clear.expectedAliceInput, + "Bob bounty" + ); + assertEq( + iOrderbook.vaultBalance(clear.bountyBot, clear.bobConfig.validInputs[0].token, clear.bobBountyVaultId), + 0, + "Bob bounty input" + ); } - /// Make a deposit to the OB mocking the internal transferFrom call. - function _depositInternal(address depositor, address token, uint256 vaultId, uint256 amount) internal { - vm.prank(depositor); - vm.mockCall( - token, - abi.encodeWithSelector(IERC20.transferFrom.selector, depositor, address(iOrderbook), amount), - abi.encode(true) + /// forge-config: default.fuzz.runs = 100 + function testClearSimple( + address alice, + OrderConfigV3 memory aliceConfig, + address bob, + OrderConfigV3 memory bobConfig, + bytes memory expression, + address bountyBot, + uint256 aliceBountyVaultId, + uint256 bobBountyVaultId + ) external { + uint256 aliceAmount = 2e18; + uint256 bobAmount = 2e18; + + // Mock the interpreter.eval that is used inside clear().calculateOrderIO() + // Produce the stack output for OB + uint256[] memory orderStackAlice = new uint256[](2); + orderStackAlice[0] = 0.99e18; // orderIORatio + orderStackAlice[1] = 0.5e18; // orderOutputMax + + checkClear( + CheckClear( + alice, + aliceConfig, + bob, + bobConfig, + bountyBot, + aliceBountyVaultId, + bobBountyVaultId, + aliceAmount, + bobAmount, + expression, + orderStackAlice, + orderStackAlice, + 0.5e18, + 0.5e18, + 0.495e18, + 0.495e18, + "" + ) ); - iOrderbook.deposit2(address(token), vaultId, amount, new TaskV1[](0)); + } - assertEq(iOrderbook.vaultBalance(depositor, token, vaultId), amount); + /// forge-config: default.fuzz.runs = 100 + function testClearFuzzIoRatio( + address alice, + OrderConfigV3 memory aliceConfig, + address bob, + OrderConfigV3 memory bobConfig, + bytes memory expression, + address bountyBot, + uint256 aliceBountyVaultId, + uint256 bobBountyVaultId, + uint256 aliceIORatio, + uint256 bobIORatio + ) external { + // 0 tested separately. + aliceIORatio = bound(aliceIORatio, 1, 1e18); + bobIORatio = bound(bobIORatio, 1e18, uint256(1e18).fixedPointDiv(aliceIORatio, Math.Rounding.Down)); + + // Mock the interpreter.eval that is used inside clear().calculateOrderIO() + // Produce the stack output for OB + uint256[] memory orderStackAlice = new uint256[](2); + orderStackAlice[0] = aliceIORatio; // orderIORatio + orderStackAlice[1] = 1e18; // orderOutputMax + + uint256[] memory orderStackBob = new uint256[](2); + orderStackBob[0] = bobIORatio; // orderIORatio + orderStackBob[1] = 1e18; // orderOutputMax + + checkClear( + CheckClear( + alice, + aliceConfig, + bob, + bobConfig, + bountyBot, + aliceBountyVaultId, + bobBountyVaultId, + 1e18, + 1e18, + expression, + orderStackAlice, + orderStackBob, + 1e18, + // Alice is outputting 1 so bob will output enough to match this + // according to his own IO ratio. + uint256(1e18).fixedPointDiv(bobIORatio, Math.Rounding.Down).min(1e18), + // Expected input for Alice is aliceOutput * aliceIORatio + uint256(1e18).fixedPointMul(aliceIORatio, Math.Rounding.Up), + // Expected input for Bob is Alice's output in entirety, because + // alice IO * bob IO <= 1 and Bob is the larger ratio. + // As Bob's ratio is >= 1 he will have his input shrunk to match + // Alice's output. This means in this case Bob's input will be + // 1 always, as it either = 1 anyway or matches Alice's 1. + uint256(1e18), + "" + ) + ); + } + + /// forge-config: default.fuzz.runs = 100 + function testClearFuzzIoRatioError( + address alice, + OrderConfigV3 memory aliceConfig, + address bob, + OrderConfigV3 memory bobConfig, + bytes memory expression, + address bountyBot, + uint256 aliceBountyVaultId, + uint256 bobBountyVaultId, + uint256 aliceIORatio, + uint256 bobIORatio + ) external { + aliceIORatio = bound(aliceIORatio, 1e18 + 1, 1.1e18); + bobIORatio = bound(bobIORatio, 1e18 + 1, 1.1e18); + + // Mock the interpreter.eval that is used inside clear().calculateOrderIO() + // Produce the stack output for OB + uint256[] memory orderStackAlice = new uint256[](2); + orderStackAlice[0] = aliceIORatio; // orderIORatio + orderStackAlice[1] = 1e18; // orderOutputMax + + uint256[] memory orderStackBob = new uint256[](2); + orderStackBob[0] = bobIORatio; // orderIORatio + orderStackBob[1] = 1e18; // orderOutputMax + + checkClear( + CheckClear( + alice, + aliceConfig, + bob, + bobConfig, + bountyBot, + aliceBountyVaultId, + bobBountyVaultId, + 1e18, + 1e18, + expression, + orderStackAlice, + orderStackBob, + 0, + 0, + 0, + 0, + stdError.arithmeticError + ) + ); + } + + /// forge-config: default.fuzz.runs = 100 + function testClear2ZeroRatioAliceOnly( + address alice, + OrderConfigV3 memory aliceConfig, + address bob, + OrderConfigV3 memory bobConfig, + bytes memory expression, + address bountyBot, + uint256 aliceBountyVaultId, + uint256 bobBountyVaultId + ) external { + uint256 aliceAmount = 2e18; + uint256 bobAmount = 3e18; + + uint256[] memory orderStackAlice = new uint256[](2); + orderStackAlice[0] = 0; // Zero orderIORatio + orderStackAlice[1] = 0.5e18; // orderOutputMax + + uint256[] memory orderStackBob = new uint256[](2); + orderStackBob[0] = 1e18; // Nonzero orderIORatio + orderStackBob[1] = 0.5e18; // orderOutputMax + + checkClear( + CheckClear( + alice, + aliceConfig, + bob, + bobConfig, + bountyBot, + aliceBountyVaultId, + bobBountyVaultId, + aliceAmount, + bobAmount, + expression, + orderStackAlice, + orderStackBob, + 0.5e18, + 0.5e18, + 0, + 0.5e18, + "" + ) + ); + } + + /// forge-config: default.fuzz.runs = 100 + function testClear2ZeroRatioBobOnly( + address alice, + OrderConfigV3 memory aliceConfig, + address bob, + OrderConfigV3 memory bobConfig, + bytes memory expression, + address bountyBot, + uint256 aliceBountyVaultId, + uint256 bobBountyVaultId + ) external { + uint256 aliceAmount = 2e18; + uint256 bobAmount = 3e18; + + uint256[] memory orderStackAlice = new uint256[](2); + orderStackAlice[0] = 1e18; // Zero orderIORatio + orderStackAlice[1] = 0.5e18; // orderOutputMax + + uint256[] memory orderStackBob = new uint256[](2); + orderStackBob[0] = 0; // Nonzero orderIORatio + orderStackBob[1] = 0.5e18; // orderOutputMax + + checkClear( + CheckClear( + alice, + aliceConfig, + bob, + bobConfig, + bountyBot, + aliceBountyVaultId, + bobBountyVaultId, + aliceAmount, + bobAmount, + expression, + orderStackAlice, + orderStackBob, + 0.5e18, + 0.5e18, + 0.5e18, + 0, + "" + ) + ); + } + + /// forge-config: default.fuzz.runs = 100 + function testClear2ZeroRatioAliceAndBob( + address alice, + OrderConfigV3 memory aliceConfig, + address bob, + OrderConfigV3 memory bobConfig, + bytes memory expression, + address bountyBot, + uint256 aliceBountyVaultId, + uint256 bobBountyVaultId + ) external { + uint256 aliceAmount = 2e18; + uint256 bobAmount = 3e18; + + // Mock the interpreter.eval for Alice and Bob orders with zero ratio + uint256[] memory orderStackAlice = new uint256[](2); + orderStackAlice[0] = 0; // Zero orderIORatio + orderStackAlice[1] = 5e17; // orderOutputMax + + uint256[] memory orderStackBob = new uint256[](2); + + orderStackBob[0] = 0; // Zero orderIORatio + orderStackBob[1] = 5e17; // orderOutputMax + + checkClear( + CheckClear( + alice, + aliceConfig, + bob, + bobConfig, + bountyBot, + aliceBountyVaultId, + bobBountyVaultId, + aliceAmount, + bobAmount, + expression, + orderStackAlice, + orderStackBob, + 0.5e18, + 0.5e18, + 0, + 0, + "" + ) + ); } }