diff --git a/.gas-snapshot b/.gas-snapshot index 6c4f2fe8..57939655 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,28 +1,28 @@ -AssetManagedPairTest:testAdjustManagement(uint256,uint256) (runs: 256, μ: 315370, ~: 315670) -AssetManagedPairTest:testAdjustManagement_AdjustAfterLoss(uint256) (runs: 256, μ: 539195, ~: 543614) -AssetManagedPairTest:testAdjustManagement_DecreaseManagement(uint256,uint256) (runs: 256, μ: 508029, ~: 508841) +AssetManagedPairTest:testAdjustManagement(uint256,uint256) (runs: 256, μ: 315400, ~: 315670) +AssetManagedPairTest:testAdjustManagement_AdjustAfterLoss(uint256) (runs: 256, μ: 538969, ~: 543614) +AssetManagedPairTest:testAdjustManagement_DecreaseManagement(uint256,uint256) (runs: 256, μ: 508066, ~: 508841) AssetManagedPairTest:testAdjustManagement_GreaterThanUint104() (gas: 124232) AssetManagedPairTest:testAdjustManagement_Int256Min() (gas: 124764) -AssetManagedPairTest:testAdjustManagement_KStillHolds(uint256) (runs: 256, μ: 632517, ~: 632195) +AssetManagedPairTest:testAdjustManagement_KStillHolds(uint256) (runs: 256, μ: 632527, ~: 632195) AssetManagedPairTest:testAdjustManagement_Uint104() (gas: 745418) AssetManagedPairTest:testBurn_AfterAlmostTotalLoss() (gas: 633477) -AssetManagedPairTest:testBurn_AfterLoss(uint256,uint256) (runs: 256, μ: 712836, ~: 705238) -AssetManagedPairTest:testMint_AfterLoss(uint256,uint256) (runs: 256, μ: 613406, ~: 624365) +AssetManagedPairTest:testBurn_AfterLoss(uint256,uint256) (runs: 256, μ: 714141, ~: 712027) +AssetManagedPairTest:testMint_AfterLoss(uint256,uint256) (runs: 256, μ: 614530, ~: 624495) AssetManagedPairTest:testSetManager() (gas: 131642) -AssetManagedPairTest:testSetManager_CannotMigrateWithManaged(uint256,uint256) (runs: 256, μ: 412032, ~: 412332) +AssetManagedPairTest:testSetManager_CannotMigrateWithManaged(uint256,uint256) (runs: 256, μ: 412062, ~: 412332) AssetManagedPairTest:testSkimExcessManaged() (gas: 406472) AssetManagedPairTest:testSkimExcessManaged_InvalidToken() (gas: 68737) AssetManagedPairTest:testSkimExcessManaged_NoExcess() (gas: 308150) -AssetManagedPairTest:testSwap_AfterLoss(uint256) (runs: 256, μ: 811803, ~: 816273) -AssetManagedPairTest:testSync(uint256,uint256,uint256,uint256) (runs: 256, μ: 520770, ~: 530158) -AssetManagedPairTest:testSyncManaged_ConstantProduct(uint256,uint256) (runs: 256, μ: 347080, ~: 355420) -AssetManagedPairTest:testSyncManaged_Stable(uint256,uint256) (runs: 256, μ: 385005, ~: 379768) +AssetManagedPairTest:testSwap_AfterLoss(uint256) (runs: 256, μ: 811658, ~: 816273) +AssetManagedPairTest:testSync(uint256,uint256,uint256,uint256) (runs: 256, μ: 518737, ~: 530121) +AssetManagedPairTest:testSyncManaged_ConstantProduct(uint256,uint256) (runs: 256, μ: 347969, ~: 355451) +AssetManagedPairTest:testSyncManaged_Stable(uint256,uint256) (runs: 256, μ: 385860, ~: 380008) BufferTest:testAdd_IndexGreaterThanBufferSize(uint16,uint16) (runs: 256, μ: 6788, ~: 6755) BufferTest:testNext_AtLimit() (gas: 3343) BufferTest:testNext_GreaterThanBufferSize(uint16) (runs: 256, μ: 7375, ~: 7333) BufferTest:testPrev_AtLimit() (gas: 3321) BufferTest:testSub_IndexGreaterThanBufferSize(uint16,uint16) (runs: 256, μ: 6844, ~: 6811) -ConstantProductMathTest:testCalcLogPrice_ReturnsOneWeiWhenPriceDiffGreaterThan1e18(uint256,uint256) (runs: 256, μ: 10746, ~: 10722) +ConstantProductMathTest:testCalcLogPrice_ReturnsOneWeiWhenPriceDiffGreaterThan1e18(uint256,uint256) (runs: 256, μ: 10742, ~: 10722) ConstantProductMathTest:testConstantProductOracleMath() (gas: 34880) ConstantProductPairGas:testGasBurn() (gas: 93601) ConstantProductPairGas:testGasMint() (gas: 101264) @@ -41,10 +41,10 @@ ConstantProductPairTest:testOracle_ClampedPrice_AtLimit() (gas: 147983) ConstantProductPairTest:testOracle_ClampedPrice_NoDiffWithinLimit() (gas: 148995) ConstantProductPairTest:testOracle_ClampedPrice_OverLimit() (gas: 150131) ConstantProductPairTest:testOracle_CorrectPrice(uint32) (runs: 256, μ: 4777873, ~: 4777873) -ConstantProductPairTest:testOracle_CorrectPriceDiffDecimals(uint32) (runs: 256, μ: 4700061, ~: 4700067) +ConstantProductPairTest:testOracle_CorrectPriceDiffDecimals(uint32) (runs: 256, μ: 4700062, ~: 4700067) ConstantProductPairTest:testOracle_SimplePrices(uint32) (runs: 256, μ: 4743033, ~: 4743033) ConstantProductPairTest:testSwap() (gas: 113322) -ConstantProductPairTest:testSwap_ExactOut(uint256) (runs: 256, μ: 110423, ~: 100405) +ConstantProductPairTest:testSwap_ExactOut(uint256) (runs: 256, μ: 110909, ~: 120249) ConstantProductPairTest:testSwap_ExactOutExceedReserves() (gas: 28772) ConstantProductPairTest:testSwap_ExactOut_NewReservesExceedUint104() (gas: 78855) ConstantProductPairTest:testSwap_ExtremeAmounts() (gas: 4647340) @@ -52,11 +52,11 @@ ConstantProductPairTest:testSwap_MinInt256() (gas: 15306) ConstantProductPairTest:testSwap_Reenter() (gas: 78501) FixedPointMathLibTest:testFullMulDiv(uint256,uint256,uint256) (runs: 256, μ: 9691, ~: 9580) FixedPointMathLibTest:testMulDiv(uint256,uint256,uint256) (runs: 256, μ: 9274, ~: 9312) -FlashSwapTest:testSwap_FlashSwap_ExactIn(uint256) (runs: 256, μ: 283557, ~: 239367) -FlashSwapTest:testSwap_FlashSwap_ExactOut(uint256) (runs: 256, μ: 258913, ~: 240186) -FlashSwapTest:testSwap_FlashSwap_NoPay(uint256) (runs: 256, μ: 174996, ~: 176637) +FlashSwapTest:testSwap_FlashSwap_ExactIn(uint256) (runs: 256, μ: 281389, ~: 239367) +FlashSwapTest:testSwap_FlashSwap_ExactOut(uint256) (runs: 256, μ: 258912, ~: 240186) +FlashSwapTest:testSwap_FlashSwap_NoPay(uint256) (runs: 256, μ: 175044, ~: 176637) GenericFactoryGasTest:testCreateConstantProductPair() (gas: 4411143) -GenericFactoryGasTest:testCreateFactory() (gas: 890382) +GenericFactoryGasTest:testCreateFactory() (gas: 847078) GenericFactoryGasTest:testCreateStablePair() (gas: 5212488) GenericFactoryTest:testAddCurve() (gas: 119232) GenericFactoryTest:testAddCurve_OnlyOwner() (gas: 14164) @@ -64,29 +64,29 @@ GenericFactoryTest:testAllPairs() (gas: 9609681) GenericFactoryTest:testCreatePair_AllCurves(uint256) (runs: 256, μ: 4870305, ~: 5220834) GenericFactoryTest:testCreatePair_Create2AddressCorrect() (gas: 9680198) GenericFactoryTest:testCreatePair_CurveDoesNotExist(uint256) (runs: 256, μ: 21248, ~: 21244) -GenericFactoryTest:testCreatePair_IdenticalAddress(uint256) (runs: 256, μ: 14891, ~: 14850) -GenericFactoryTest:testCreatePair_MoreThan18Decimals(uint256) (runs: 256, μ: 156205, ~: 159334) -GenericFactoryTest:testCreatePair_PairAlreadyExists(uint256) (runs: 256, μ: 19140, ~: 19099) -GenericFactoryTest:testCreatePair_ZeroAddress(uint256) (runs: 256, μ: 15037, ~: 14996) +GenericFactoryTest:testCreatePair_IdenticalAddress(uint256) (runs: 256, μ: 14762, ~: 14721) +GenericFactoryTest:testCreatePair_MoreThan18Decimals(uint256) (runs: 256, μ: 156106, ~: 159235) +GenericFactoryTest:testCreatePair_PairAlreadyExists(uint256) (runs: 256, μ: 19045, ~: 19004) +GenericFactoryTest:testCreatePair_ZeroAddress(uint256) (runs: 256, μ: 14908, ~: 14867) GenericFactoryTest:testGetBytecode_CorrectConstructorData() (gas: 112679) GenericFactoryTest:testGetPair() (gas: 20918) OracleWriterTest:testMaxChangeRate_Default() (gas: 68110) OracleWriterTest:testOracle_MintWrongPriceThenConverge() (gas: 247897806) OracleWriterTest:testOracle_NoWriteInSameTimestamp() (gas: 488841) -OracleWriterTest:testOracle_OverflowAccPrice(uint32) (runs: 256, μ: 376778, ~: 376684) -OracleWriterTest:testOracle_SamePriceDiffLiq(uint32) (runs: 256, μ: 10158278, ~: 10158292) -OracleWriterTest:testOracle_SamePriceSameLiq(uint32) (runs: 256, μ: 10154890, ~: 10154904) +OracleWriterTest:testOracle_OverflowAccPrice(uint32) (runs: 256, μ: 376761, ~: 376684) +OracleWriterTest:testOracle_SamePriceDiffLiq(uint32) (runs: 256, μ: 10158279, ~: 10158292) +OracleWriterTest:testOracle_SamePriceSameLiq(uint32) (runs: 256, μ: 10154891, ~: 10154904) OracleWriterTest:testOracle_SameReservesDiffPrice(uint32) (runs: 256, μ: 10146791, ~: 10146779) OracleWriterTest:testOracle_WrapsAroundAfterFull() (gas: 4217529379) OracleWriterTest:testSetClampParams_OnlyFactory() (gas: 91155) -OracleWriterTest:testSetClampParams_TooHigh(uint256) (runs: 256, μ: 76548, ~: 76652) +OracleWriterTest:testSetClampParams_TooHigh(uint256) (runs: 256, μ: 76542, ~: 76652) OracleWriterTest:testSetClampParams_TooLow() (gas: 69054) OracleWriterTest:testUpdateOracle_AccumulateOldPricesNotNew() (gas: 221072) OracleWriterTest:testUpdateOracle_DecreasePrice_ExceedBothMaxChangeRateAndMaxChangePerTrade() (gas: 357498) OracleWriterTest:testUpdateOracle_DecreasePrice_ExceedMaxChangePerTrade() (gas: 305783) OracleWriterTest:testUpdateOracle_DecreasePrice_ExceedMaxChangeRate() (gas: 306501) OracleWriterTest:testUpdateOracle_DecreasePrice_LongElapsedTime() (gas: 299742) -OracleWriterTest:testUpdateOracle_LatestTimestampWritten(uint256) (runs: 256, μ: 290892, ~: 291226) +OracleWriterTest:testUpdateOracle_LatestTimestampWritten(uint256) (runs: 256, μ: 290872, ~: 291226) OracleWriterTest:testUpdateOracle_MintThenSwapSameBlock() (gas: 314930) OracleWriterTest:testUpdateOracle_MultipleSwapsSameBlock() (gas: 410086) OracleWriterTest:testWriteObservations() (gas: 431094) @@ -96,10 +96,10 @@ PairTest:testEmitEventOnCreation() (gas: 9601363) PairTest:testNonPayable() (gas: 79592) PairTest:testRecoverToken() (gas: 200069) PairTest:testSetPlatformFeeForPair() (gas: 111080) -PairTest:testSetPlatformFeeForPair_BreachMaximum(uint256) (runs: 256, μ: 110825, ~: 110445) +PairTest:testSetPlatformFeeForPair_BreachMaximum(uint256) (runs: 256, μ: 110818, ~: 110445) PairTest:testSetPlatformFeeForPair_Reset() (gas: 118525) PairTest:testSetSwapFeeForPair() (gas: 112048) -PairTest:testSetSwapFeeForPair_BreachMaximum(uint256) (runs: 256, μ: 111034, ~: 110691) +PairTest:testSetSwapFeeForPair_BreachMaximum(uint256) (runs: 256, μ: 111023, ~: 110691) PairTest:testSetSwapFeeForPair_Reset() (gas: 125017) PairTest:testSwapFee_UseDefault() (gas: 19026) PairTest:testUpdateDefaultFees() (gas: 166371) @@ -117,17 +117,17 @@ ReservoirPairTest:testCheckedTransfer_RevertWhenTransferReverts() (gas: 433392) ReservoirPairTest:testPlatformFee_Disable() (gas: 1019616) ReservoirPairTest:testPlatformFee_DisableReenable() (gas: 1435332) ReservoirPairTest:testReentrancyGuard_LargeTimestamp() (gas: 197899) -ReservoirPairTest:testSkim(uint256,uint256) (runs: 256, μ: 257047, ~: 256997) +ReservoirPairTest:testSkim(uint256,uint256) (runs: 256, μ: 257053, ~: 256997) ReservoirPairTest:testSync() (gas: 192471) -ReservoirTimelockTest:testRampA(uint32) (runs: 256, μ: 36152, ~: 36152) -ReservoirTimelockTest:testRampA_NotAdmin() (gas: 17972) -ReservoirTimelockTest:testSetCustomPlatformFee(uint256) (runs: 256, μ: 134496, ~: 135161) -ReservoirTimelockTest:testSetCustomPlatformFee_NotAdmin() (gas: 81368) -ReservoirTimelockTest:testSetCustomSwapFee(uint256) (runs: 256, μ: 136564, ~: 137194) -ReservoirTimelockTest:testSetCustomSwapFee_NotAdmin() (gas: 81676) -StableMathTest:testComputeLiquidityFromAdjustedBalances_ConvergeEvenWithVeryUnbalancedValues(uint256,uint256,uint256) (runs: 256, μ: 14117, ~: 12439) -StableMathTest:testGetAmountIn(uint256,uint256,uint256) (runs: 256, μ: 22172, ~: 21987) -StableMathTest:testGetAmountOut(uint256,uint256,uint256) (runs: 256, μ: 26127, ~: 25722) +ReservoirTimelockTest:testRampA(uint32) (runs: 256, μ: 36132, ~: 36132) +ReservoirTimelockTest:testRampA_NotAdmin() (gas: 17852) +ReservoirTimelockTest:testSetCustomPlatformFee(uint256) (runs: 256, μ: 134458, ~: 135105) +ReservoirTimelockTest:testSetCustomPlatformFee_NotAdmin() (gas: 81112) +ReservoirTimelockTest:testSetCustomSwapFee(uint256) (runs: 256, μ: 136532, ~: 137142) +ReservoirTimelockTest:testSetCustomSwapFee_NotAdmin() (gas: 81406) +StableMathTest:testComputeLiquidityFromAdjustedBalances_ConvergeEvenWithVeryUnbalancedValues(uint256,uint256,uint256) (runs: 256, μ: 13985, ~: 12424) +StableMathTest:testGetAmountIn(uint256,uint256,uint256) (runs: 256, μ: 22131, ~: 21987) +StableMathTest:testGetAmountOut(uint256,uint256,uint256) (runs: 256, μ: 26076, ~: 25762) StableMathTest:testMinALessThanMaxA() (gas: 3381) StablePairGas:testGasBurn() (gas: 102875) StablePairGas:testGasMint() (gas: 124790) @@ -138,28 +138,28 @@ StablePairGas:testGasSwap_UpdateOracleClamped() (gas: 102230) StablePairTest:testAttackWhileRampingDown_LongInterval() (gas: 202899) StablePairTest:testAttackWhileRampingDown_ShortInterval() (gas: 204209) StablePairTest:testBurn() (gas: 144841) -StablePairTest:testBurn_DiffDecimalPlaces(uint256) (runs: 256, μ: 5491448, ~: 5491299) +StablePairTest:testBurn_DiffDecimalPlaces(uint256) (runs: 256, μ: 5491420, ~: 5491299) StablePairTest:testBurn_LastInvariantUseReserveInsteadOfBalance() (gas: 263676) StablePairTest:testBurn_Reenter() (gas: 48719) StablePairTest:testBurn_SucceedEvenIfMintFeeReverts() (gas: 143703) -StablePairTest:testBurn_WhenRampingA(uint256,uint32) (runs: 256, μ: 332415, ~: 332430) +StablePairTest:testBurn_WhenRampingA(uint256,uint32) (runs: 256, μ: 332413, ~: 332430) StablePairTest:testBurn_Zero() (gas: 81490) -StablePairTest:testFactoryAmpTooHigh() (gas: 271186) -StablePairTest:testFactoryAmpTooLow() (gas: 266776) +StablePairTest:testFactoryAmpTooHigh() (gas: 271071) +StablePairTest:testFactoryAmpTooLow() (gas: 266661) StablePairTest:testGetCurrentA() (gas: 32277) StablePairTest:testMint() (gas: 117916) StablePairTest:testMintFee_CallableBySelf() (gas: 16698) -StablePairTest:testMintFee_DiffPlatformFees(uint256) (runs: 256, μ: 6911987, ~: 6913235) +StablePairTest:testMintFee_DiffPlatformFees(uint256) (runs: 256, μ: 6911981, ~: 6913235) StablePairTest:testMintFee_NotCallableByOthers() (gas: 8541) -StablePairTest:testMintFee_WhenRampingA_PoolBalanced(uint256) (runs: 256, μ: 6980785, ~: 6980823) -StablePairTest:testMintFee_WhenRampingA_PoolUnbalanced(uint256) (runs: 256, μ: 6396059, ~: 6395907) +StablePairTest:testMintFee_WhenRampingA_PoolBalanced(uint256) (runs: 256, μ: 6980778, ~: 6980823) +StablePairTest:testMintFee_WhenRampingA_PoolUnbalanced(uint256) (runs: 256, μ: 6396046, ~: 6395907) StablePairTest:testMint_CalculationOverflowInStableMath() (gas: 5318816) StablePairTest:testMint_NonOptimalProportion() (gas: 172605) StablePairTest:testMint_NonOptimalProportion_ThenBurn() (gas: 354840) StablePairTest:testMint_OnlyTransferOneToken() (gas: 5257255) StablePairTest:testMint_PlatformFeeOff() (gas: 120979) StablePairTest:testMint_Reenter() (gas: 48141) -StablePairTest:testMint_WhenRampingA(uint256,uint32) (runs: 256, μ: 356877, ~: 356887) +StablePairTest:testMint_WhenRampingA(uint256,uint32) (runs: 256, μ: 356874, ~: 356887) StablePairTest:testOracle_ClampedPrice_NoDiffWithinLimit() (gas: 164912) StablePairTest:testOracle_CorrectPrice(uint32) (runs: 256, μ: 5618924, ~: 5618924) StablePairTest:testOracle_SimplePrices(uint32) (runs: 256, μ: 5624665, ~: 5624665) @@ -173,25 +173,25 @@ StablePairTest:testRampA_MaxSpeed_Halve() (gas: 29006) StablePairTest:testRampA_OnlyFactory() (gas: 8715) StablePairTest:testRampA_SetAtMaximum() (gas: 27421) StablePairTest:testRampA_SetAtMinimum() (gas: 26938) -StablePairTest:testRampA_SwappingDuringRampingDown(uint256,uint256,uint256,uint256) (runs: 256, μ: 575084, ~: 457676) -StablePairTest:testRampA_SwappingDuringRampingUp(uint256,uint256,uint256,uint256) (runs: 256, μ: 574515, ~: 458549) +StablePairTest:testRampA_SwappingDuringRampingDown(uint256,uint256,uint256,uint256) (runs: 256, μ: 576232, ~: 459071) +StablePairTest:testRampA_SwappingDuringRampingUp(uint256,uint256,uint256,uint256) (runs: 256, μ: 575664, ~: 458802) StablePairTest:testStopRampA() (gas: 34839) -StablePairTest:testStopRampA_Early(uint256,uint32) (runs: 256, μ: 43066, ~: 43162) -StablePairTest:testStopRampA_Late(uint256) (runs: 256, μ: 42507, ~: 42590) +StablePairTest:testStopRampA_Early(uint256,uint32) (runs: 256, μ: 43076, ~: 43162) +StablePairTest:testStopRampA_Late(uint256) (runs: 256, μ: 42508, ~: 42590) StablePairTest:testStopRampA_OnlyFactory() (gas: 9181) StablePairTest:testSwap() (gas: 119527) StablePairTest:testSwap_BetterPerformanceThanConstantProduct() (gas: 187191) -StablePairTest:testSwap_DiffAs(uint256,uint256,uint256,uint256) (runs: 256, μ: 5554183, ~: 5555271) -StablePairTest:testSwap_DiffSwapFees(uint256) (runs: 256, μ: 5531184, ~: 5532106) +StablePairTest:testSwap_DiffAs(uint256,uint256,uint256,uint256) (runs: 256, μ: 5554278, ~: 5555287) +StablePairTest:testSwap_DiffSwapFees(uint256) (runs: 256, μ: 5531346, ~: 5532106) StablePairTest:testSwap_ExactInExceedUint104() (gas: 74746) StablePairTest:testSwap_ExactOutExceedReserves() (gas: 29861) -StablePairTest:testSwap_IncreasingSwapFees(uint256,uint256,uint256) (runs: 256, μ: 389359, ~: 389504) +StablePairTest:testSwap_IncreasingSwapFees(uint256,uint256,uint256) (runs: 256, μ: 389336, ~: 389504) StablePairTest:testSwap_MinInt256() (gas: 19284) StablePairTest:testSwap_Reenter() (gas: 87163) -StablePairTest:testSwap_Token0ExactOut(uint256) (runs: 256, μ: 151280, ~: 137530) -StablePairTest:testSwap_Token1ExactOut(uint256) (runs: 256, μ: 151468, ~: 137667) -StablePairTest:testSwap_VeryLargeLiquidity(uint256) (runs: 256, μ: 5481980, ~: 5480098) -StablePairTest:testSwap_VerySmallLiquidity(uint256,uint256,uint256) (runs: 256, μ: 5520147, ~: 5498945) +StablePairTest:testSwap_Token0ExactOut(uint256) (runs: 256, μ: 152002, ~: 137530) +StablePairTest:testSwap_Token1ExactOut(uint256) (runs: 256, μ: 152191, ~: 137667) +StablePairTest:testSwap_VeryLargeLiquidity(uint256) (runs: 256, μ: 5481880, ~: 5480098) +StablePairTest:testSwap_VerySmallLiquidity(uint256,uint256,uint256) (runs: 256, μ: 5520407, ~: 5498975) StablePairTest:testSwap_ZeroInput() (gas: 12788) StdMathTest:testPercentDelta() (gas: 3351) StdMathTest:testPercentDelta_MinusOne() (gas: 3197) diff --git a/script/optimized-deployer-meta b/script/optimized-deployer-meta index 758d2410..38f5dd50 100644 --- a/script/optimized-deployer-meta +++ b/script/optimized-deployer-meta @@ -1,5 +1,5 @@ { "constant_product_hash": "0xe174de1f7ab5f7c871f23787d956a8d1b4ebbb3b195eb2d6af27fb3a8c9e812e", - "factory_hash": "0x23864280088f6f71abfba47086784b3c758d1df19a55957e25f1f4bd9336792e", + "factory_hash": "0x87b0f73fafcf4bb41e013c8423dc679f6885527007d6c3f1e1834a670cbaadc5", "stable_hash": "0x3ae886aee24fa2cc0144d24306033a7ed47e91bc0f962e4bffcef5922ae175f5" } \ No newline at end of file diff --git a/script/unoptimized-deployer-meta b/script/unoptimized-deployer-meta index f62f72de..c7487494 100644 --- a/script/unoptimized-deployer-meta +++ b/script/unoptimized-deployer-meta @@ -1,5 +1,5 @@ { "constant_product_hash": "0x89ba88e63d531f6343d8f30d0baf35d10eb900e4e9e5cf64e857a17d63c27863", - "factory_hash": "0x4106b8ba3fea1679610d16c7270d5d7e41404bbf3aed56e9c5f042e8eb827f8b", + "factory_hash": "0x09a9ce1ed77c95be4842dddd771939e048b8bfe2837863be3a2766b1c13ea5a2", "stable_hash": "0x2556755e769639b4fbeff548907a3a675f94209a24a97c7fca31eedb76567c2f" } \ No newline at end of file diff --git a/src/GenericFactory.sol b/src/GenericFactory.sol index 40be7b14..1647b7a8 100644 --- a/src/GenericFactory.sol +++ b/src/GenericFactory.sol @@ -15,6 +15,11 @@ uint256 constant MAX_SSTORE_SIZE = 0x6000 - 1; contract GenericFactory is IGenericFactory, Owned(msg.sender) { using Bytes32Lib for address; + error IdenticalAddresses(); + error ZeroAddress(); + error PairExists(); + error DeployFailed(); + /*////////////////////////////////////////////////////////////////////////// CONFIG //////////////////////////////////////////////////////////////////////////*/ @@ -139,9 +144,9 @@ contract GenericFactory is IGenericFactory, Owned(msg.sender) { } function createPair(IERC20 aTokenA, IERC20 aTokenB, uint256 aCurveId) external returns (address rPair) { - require(aTokenA != aTokenB, "FACTORY: IDENTICAL_ADDRESSES"); - require(address(aTokenA) != address(0), "FACTORY: ZERO_ADDRESS"); - require(getPair[aTokenA][aTokenB][aCurveId] == address(0), "FACTORY: PAIR_EXISTS"); + require(aTokenA != aTokenB, IdenticalAddresses()); + require(address(aTokenA) != address(0), ZeroAddress()); + require(getPair[aTokenA][aTokenB][aCurveId] == address(0), PairExists()); (IERC20 lToken0, IERC20 lToken1) = _sortAddresses(aTokenA, aTokenB); @@ -159,7 +164,7 @@ contract GenericFactory is IGenericFactory, Owned(msg.sender) { 0 // salt ) } - require(rPair != address(0), "FACTORY: DEPLOY_FAILED"); + require(rPair != address(0), DeployFailed()); // Double-map the newly created pair for reverse lookup. getPair[lToken0][lToken1][aCurveId] = rPair; diff --git a/src/ReservoirDeployer.sol b/src/ReservoirDeployer.sol index 22a991c9..7c016a13 100644 --- a/src/ReservoirDeployer.sol +++ b/src/ReservoirDeployer.sol @@ -11,12 +11,21 @@ import { GenericFactory } from "src/GenericFactory.sol"; contract ReservoirDeployer { using FactoryStoreLib for GenericFactory; + error GuardianAddressZero(); + error OutOfOrder(); + error FactoryHash(); + error DeployFactoryFailed(); + error ConstantProductHash(); + error StableHash(); + error Threshold(); + error NotOwner(); + // Steps. uint256 public constant TERMINAL_STEP = 3; uint256 public step = 0; // Bytecode hashes. - bytes32 public constant FACTORY_HASH = bytes32(0x23864280088f6f71abfba47086784b3c758d1df19a55957e25f1f4bd9336792e); + bytes32 public constant FACTORY_HASH = bytes32(0x87b0f73fafcf4bb41e013c8423dc679f6885527007d6c3f1e1834a670cbaadc5); bytes32 public constant CONSTANT_PRODUCT_HASH = bytes32(0xe174de1f7ab5f7c871f23787d956a8d1b4ebbb3b195eb2d6af27fb3a8c9e812e); bytes32 public constant STABLE_HASH = bytes32(0x3ae886aee24fa2cc0144d24306033a7ed47e91bc0f962e4bffcef5922ae175f5); @@ -25,10 +34,7 @@ contract ReservoirDeployer { GenericFactory public factory; constructor(address aGuardian1, address aGuardian2, address aGuardian3) { - require( - aGuardian1 != address(0) && aGuardian2 != address(0) && aGuardian3 != address(0), - "DEPLOYER: GUARDIAN_ADDRESS_ZERO" - ); + require(aGuardian1 != address(0) && aGuardian2 != address(0) && aGuardian3 != address(0), GuardianAddressZero()); guardian1 = aGuardian1; guardian2 = aGuardian2; guardian3 = aGuardian3; @@ -43,8 +49,8 @@ contract ReservoirDeployer { //////////////////////////////////////////////////////////////////////////*/ function deployFactory(bytes memory aFactoryBytecode) external returns (GenericFactory) { - require(step == 0, "FAC_STEP: OUT_OF_ORDER"); - require(keccak256(aFactoryBytecode) == FACTORY_HASH, "DEPLOYER: FACTORY_HASH"); + require(step == 0, OutOfOrder()); + require(keccak256(aFactoryBytecode) == FACTORY_HASH, FactoryHash()); // Manual deployment from validated bytecode. address lFactoryAddress; @@ -56,7 +62,7 @@ contract ReservoirDeployer { mload(aFactoryBytecode) // size ) } - require(lFactoryAddress != address(0), "FAC_STEP: DEPLOYMENT_FAILED"); + require(lFactoryAddress != address(0), DeployFactoryFailed()); // Write the factory address so we can start configuring it. factory = GenericFactory(lFactoryAddress); @@ -75,8 +81,8 @@ contract ReservoirDeployer { } function deployConstantProduct(bytes memory aConstantProductBytecode) external { - require(step == 1, "CP_STEP: OUT_OF_ORDER"); - require(keccak256(aConstantProductBytecode) == CONSTANT_PRODUCT_HASH, "DEPLOYER: CP_HASH"); + require(step == 1, OutOfOrder()); + require(keccak256(aConstantProductBytecode) == CONSTANT_PRODUCT_HASH, ConstantProductHash()); // Add curve & curve specific parameters. factory.addCurve(aConstantProductBytecode); @@ -87,8 +93,8 @@ contract ReservoirDeployer { } function deployStable(bytes memory aStableBytecode) external { - require(step == 2, "SP_STEP: OUT_OF_ORDER"); - require(keccak256(aStableBytecode) == STABLE_HASH, "DEPLOYER: STABLE_HASH"); + require(step == 2, OutOfOrder()); + require(keccak256(aStableBytecode) == STABLE_HASH, StableHash()); // Add curve & curve specific parameters. factory.addCurve(aStableBytecode); @@ -125,7 +131,7 @@ contract ReservoirDeployer { uint256 lGuardian3Support = proposals[guardian3][msg.sender]; uint256 lSupport = lGuardian1Support + lGuardian2Support + lGuardian3Support; - require(lSupport >= GUARDIAN_THRESHOLD, "DEPLOYER: THRESHOLD"); + require(lSupport >= GUARDIAN_THRESHOLD, Threshold()); owner = msg.sender; } @@ -137,7 +143,7 @@ contract ReservoirDeployer { address public owner = address(0); modifier onlyOwner() { - require(msg.sender == owner, "DEPLOYER: NOT_OWNER"); + require(msg.sender == owner, NotOwner()); _; } diff --git a/src/ReservoirTimelock.sol b/src/ReservoirTimelock.sol index 08e84bbf..b1a9f8af 100644 --- a/src/ReservoirTimelock.sol +++ b/src/ReservoirTimelock.sol @@ -8,8 +8,10 @@ import { ReservoirPair } from "src/ReservoirPair.sol"; import { StablePair } from "src/curve/stable/StablePair.sol"; contract ReservoirTimelock is CompTimelock(msg.sender, 7 days) { + error Unauthorized(); + modifier onlyAdmin() { - require(msg.sender == admin, "RT: ADMIN"); + require(msg.sender == admin, Unauthorized()); _; } diff --git a/test/unit/GenericFactory.t.sol b/test/unit/GenericFactory.t.sol index cd6c485e..15af9a1a 100644 --- a/test/unit/GenericFactory.t.sol +++ b/test/unit/GenericFactory.t.sol @@ -24,7 +24,7 @@ contract GenericFactoryTest is BaseTest { uint256 lCurveId = bound(aCurveId, 0, 1); // act & assert - vm.expectRevert("FACTORY: DEPLOY_FAILED"); + vm.expectRevert(GenericFactory.DeployFailed.selector); _createPair(address(_tokenE), address(_tokenA), lCurveId); } @@ -33,7 +33,7 @@ contract GenericFactoryTest is BaseTest { uint256 lCurveId = bound(aCurveId, 0, 1); // act & assert - vm.expectRevert("FACTORY: ZERO_ADDRESS"); + vm.expectRevert(GenericFactory.ZeroAddress.selector); _createPair(address(0), address(_tokenA), lCurveId); } @@ -51,7 +51,7 @@ contract GenericFactoryTest is BaseTest { uint256 lCurveId = bound(aCurveId, 0, 1); // act & assert - vm.expectRevert("FACTORY: IDENTICAL_ADDRESSES"); + vm.expectRevert(GenericFactory.IdenticalAddresses.selector); _createPair(address(_tokenD), address(_tokenD), lCurveId); } @@ -60,7 +60,7 @@ contract GenericFactoryTest is BaseTest { uint256 lCurveId = bound(aCurveId, 0, 1); // act & assert - vm.expectRevert("FACTORY: PAIR_EXISTS"); + vm.expectRevert(GenericFactory.PairExists.selector); _createPair(address(_tokenA), address(_tokenB), lCurveId); } diff --git a/test/unit/ReservoirTimelock.t.sol b/test/unit/ReservoirTimelock.t.sol index bab5cb7a..c6772d14 100644 --- a/test/unit/ReservoirTimelock.t.sol +++ b/test/unit/ReservoirTimelock.t.sol @@ -41,7 +41,7 @@ contract ReservoirTimelockTest is BaseTest { function testSetCustomSwapFee_NotAdmin() external allPairs { // act & assert vm.prank(_alice); - vm.expectRevert("RT: ADMIN"); + vm.expectRevert(ReservoirTimelock.Unauthorized.selector); _timelock.setCustomSwapFee(_factory, address(_pair), 500); } @@ -60,7 +60,7 @@ contract ReservoirTimelockTest is BaseTest { function testSetCustomPlatformFee_NotAdmin() external allPairs { // act & assert vm.prank(_alice); - vm.expectRevert("RT: ADMIN"); + vm.expectRevert(ReservoirTimelock.Unauthorized.selector); _timelock.setCustomPlatformFee(_factory, address(_pair), 500); } @@ -82,7 +82,7 @@ contract ReservoirTimelockTest is BaseTest { function testRampA_NotAdmin() external { // act & assert vm.prank(_alice); - vm.expectRevert("RT: ADMIN"); + vm.expectRevert(ReservoirTimelock.Unauthorized.selector); _timelock.rampA(_factory, address(_stablePair), 500, 500); } } diff --git a/test/unit/StablePair.t.sol b/test/unit/StablePair.t.sol index 23adabb8..e0ba6cd9 100644 --- a/test/unit/StablePair.t.sol +++ b/test/unit/StablePair.t.sol @@ -54,7 +54,7 @@ contract StablePairTest is BaseTest { _factory.write("SP::amplificationCoefficient", StableMath.MIN_A - 1); // act & assert - vm.expectRevert("FACTORY: DEPLOY_FAILED"); + vm.expectRevert(GenericFactory.DeployFailed.selector); _createPair(address(_tokenC), address(_tokenD), 1); } @@ -63,7 +63,7 @@ contract StablePairTest is BaseTest { _factory.write("SP::amplificationCoefficient", StableMath.MAX_A + 1); // act & assert - vm.expectRevert("FACTORY: DEPLOY_FAILED"); + vm.expectRevert(GenericFactory.DeployFailed.selector); _createPair(address(_tokenC), address(_tokenD), 1); }