diff --git a/script/optimized-deployer-meta b/script/optimized-deployer-meta index c1d7061a..38f5dd50 100644 --- a/script/optimized-deployer-meta +++ b/script/optimized-deployer-meta @@ -1,5 +1,5 @@ { "constant_product_hash": "0xe174de1f7ab5f7c871f23787d956a8d1b4ebbb3b195eb2d6af27fb3a8c9e812e", "factory_hash": "0x87b0f73fafcf4bb41e013c8423dc679f6885527007d6c3f1e1834a670cbaadc5", - "stable_hash": "0x37118cc4f3b41471e6e52968fd506b80bbb1395764db8498cb3f4c4cfb8ab35c" + "stable_hash": "0x3ae886aee24fa2cc0144d24306033a7ed47e91bc0f962e4bffcef5922ae175f5" } \ No newline at end of file diff --git a/src/ReservoirDeployer.sol b/src/ReservoirDeployer.sol index c9fd2006..7c016a13 100644 --- a/src/ReservoirDeployer.sol +++ b/src/ReservoirDeployer.sol @@ -17,6 +17,8 @@ contract ReservoirDeployer { error DeployFactoryFailed(); error ConstantProductHash(); error StableHash(); + error Threshold(); + error NotOwner(); // Steps. uint256 public constant TERMINAL_STEP = 3; @@ -26,7 +28,7 @@ contract ReservoirDeployer { bytes32 public constant FACTORY_HASH = bytes32(0x87b0f73fafcf4bb41e013c8423dc679f6885527007d6c3f1e1834a670cbaadc5); bytes32 public constant CONSTANT_PRODUCT_HASH = bytes32(0xe174de1f7ab5f7c871f23787d956a8d1b4ebbb3b195eb2d6af27fb3a8c9e812e); - bytes32 public constant STABLE_HASH = bytes32(0x37118cc4f3b41471e6e52968fd506b80bbb1395764db8498cb3f4c4cfb8ab35c); + bytes32 public constant STABLE_HASH = bytes32(0x3ae886aee24fa2cc0144d24306033a7ed47e91bc0f962e4bffcef5922ae175f5); // Deployment addresses. GenericFactory public factory; @@ -129,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; } @@ -141,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/libraries/StableOracleMath.sol b/src/libraries/StableOracleMath.sol index 45164356..52a74b0e 100644 --- a/src/libraries/StableOracleMath.sol +++ b/src/libraries/StableOracleMath.sol @@ -61,9 +61,9 @@ library StableOracleMath { // dy = a.x.y.2 + a.x^2 - b.x uint256 derivativeY = axy2 + ((a * reserve0).mulWad(reserve0)) - (b.mulWad(reserve0)); -// if (derivativeY == 0 || derivativeX == 0) { -// return 1e18; -// } + if (derivativeY == 0 || derivativeX == 0) { + return 1e18; + } // The rounding direction is irrelevant as we're about to introduce a much larger error when converting to log // space. We use `divWadUp` as it prevents the result from being zero, which would make the logarithm revert. A diff --git a/test/unit/GenericFactory.t.sol b/test/unit/GenericFactory.t.sol index 05a1563f..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.DeployFailed.selector"); + 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.ZeroAddress.selector); + 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.IdenticalAddresses.selector"); + 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("PairExists()"); + 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 dcc4a16c..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(_timelock.Unauthorized.selector); + 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(_timelock.Unauthorizedselector); + 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(_timelock.Unauthorized.selector); + 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 f60efc94..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.DeployFailed.selector"); + 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.DeployFailed.selector"); + vm.expectRevert(GenericFactory.DeployFailed.selector); _createPair(address(_tokenC), address(_tokenD), 1); }