diff --git a/foundry.toml b/foundry.toml index 41b1a41a..e3c735ed 100644 --- a/foundry.toml +++ b/foundry.toml @@ -2,7 +2,7 @@ solc = "0.8.28" evm_version = "cancun" via_ir = true -bytecode_hash = "none" +bytecode_hash = "ipfs" optimizer_runs = 1_000_000 gas_limit = "18446744073709551615" libs = ['lib'] diff --git a/script/optimized-deployer-meta b/script/optimized-deployer-meta index f5f188ac..d6918db7 100644 --- a/script/optimized-deployer-meta +++ b/script/optimized-deployer-meta @@ -1,5 +1,5 @@ { - "constant_product_hash": "0xddd075b1901512190892da217db5c4d266a6831226e14669e690aeb663dd9cf3", - "factory_hash": "0x87b0f73fafcf4bb41e013c8423dc679f6885527007d6c3f1e1834a670cbaadc5", - "stable_hash": "0xa52a6e20c3811c44bda8bc9f7988dd62da3c611711900f85d465b64bf97066af" + "constant_product_hash": "0x174b1bf04c1051e9d50d64a3c3b35666a4473b5994955635039d64ef9da69e97", + "factory_hash": "0x03107ee57e3054504c8ec584092f9d955bec0cbd1225fa1a8fb090a2084335aa", + "stable_hash": "0xc94b58df187b1b9b93b67504d44fbe2d8083ccfa39b23bd724037901d6c6dbf9" } \ No newline at end of file diff --git a/script/unoptimized-deployer-meta b/script/unoptimized-deployer-meta index a04d4dbf..8aaf8df6 100644 --- a/script/unoptimized-deployer-meta +++ b/script/unoptimized-deployer-meta @@ -1,5 +1,5 @@ { - "constant_product_hash": "0x903212fc8445706a81c9527fb7fdbb940f030132904209befdddbc617d8bbc47", - "factory_hash": "0x09a9ce1ed77c95be4842dddd771939e048b8bfe2837863be3a2766b1c13ea5a2", - "stable_hash": "0x54471d136002bf755956dcaefd3f0450ba1596532ca57cc84f6c9d774002f4d3" + "constant_product_hash": "0x4cca74e4aab53779dc7f4f91ab12a3460cc34bae518a286b4ecd7fd16c0f193c", + "factory_hash": "0xc5e6cd61c86f3ff115d416548099141eb8fa9ede05aebf8f748e14f0b2cecfb4", + "stable_hash": "0x17c57223683f732b0c73ae6a258077c8a1053ebfecb97f8f60518a75f75a6253" } \ No newline at end of file diff --git a/src/ReservoirDeployer.sol b/src/ReservoirDeployer.sol index c92b211a..54b9c85b 100644 --- a/src/ReservoirDeployer.sol +++ b/src/ReservoirDeployer.sol @@ -25,10 +25,10 @@ contract ReservoirDeployer { uint256 public step = 0; // Bytecode hashes. - bytes32 public constant FACTORY_HASH = bytes32(0x87b0f73fafcf4bb41e013c8423dc679f6885527007d6c3f1e1834a670cbaadc5); + bytes32 public constant FACTORY_HASH = bytes32(0x03107ee57e3054504c8ec584092f9d955bec0cbd1225fa1a8fb090a2084335aa); bytes32 public constant CONSTANT_PRODUCT_HASH = - bytes32(0xddd075b1901512190892da217db5c4d266a6831226e14669e690aeb663dd9cf3); - bytes32 public constant STABLE_HASH = bytes32(0xa52a6e20c3811c44bda8bc9f7988dd62da3c611711900f85d465b64bf97066af); + bytes32(0x174b1bf04c1051e9d50d64a3c3b35666a4473b5994955635039d64ef9da69e97); + bytes32 public constant STABLE_HASH = bytes32(0xc94b58df187b1b9b93b67504d44fbe2d8083ccfa39b23bd724037901d6c6dbf9); // Deployment addresses. GenericFactory public factory; diff --git a/src/curve/stable/StablePair.sol b/src/curve/stable/StablePair.sol index 5477dfeb..f66f8551 100644 --- a/src/curve/stable/StablePair.sol +++ b/src/curve/stable/StablePair.sol @@ -42,7 +42,10 @@ contract StablePair is ReservoirPair { constructor(IERC20 aToken0, IERC20 aToken1) ReservoirPair(aToken0, aToken1, PAIR_SWAP_FEE_NAME) { uint64 lImpreciseA = factory.read(AMPLIFICATION_COEFFICIENT_NAME).toUint64(); - require(lImpreciseA >= StableMath.MIN_A && lImpreciseA <= StableMath.MAX_A, InvalidA()); + unchecked { + // StableMath.MIN_A <= lImpreciseA <= StableMath.MAX_A + require(lImpreciseA - StableMath.MIN_A <= StableMath.MAX_A - StableMath.MIN_A, InvalidA()); + } ampData.initialA = lImpreciseA * uint64(StableMath.A_PRECISION); ampData.futureA = ampData.initialA; @@ -51,8 +54,10 @@ contract StablePair is ReservoirPair { } function rampA(uint64 aFutureARaw, uint64 aFutureATime) external onlyFactory { - require(aFutureARaw >= StableMath.MIN_A && aFutureARaw <= StableMath.MAX_A, InvalidA()); - + unchecked { + // StableMath.MIN_A <= aFutureRaw <= StableMath.MAX_A + require(aFutureARaw - StableMath.MIN_A <= StableMath.MAX_A - StableMath.MIN_A, InvalidA()); + } uint64 lFutureAPrecise = aFutureARaw * uint64(StableMath.A_PRECISION); uint256 duration = aFutureATime - block.timestamp; diff --git a/src/libraries/StableMath.sol b/src/libraries/StableMath.sol index ea633938..c165939e 100644 --- a/src/libraries/StableMath.sol +++ b/src/libraries/StableMath.sol @@ -26,6 +26,9 @@ library StableMath { /// @dev Maximum fee, which is 100%. uint256 private constant ONE_HUNDRED_PERCENT = 1_000_000; + error SM_COMPUTE_DID_NOT_CONVERGE(); + error SM_GETY_DID_NOT_CONVERGE(); + /// @notice Calculates the amount of output tokens for an exact in trade /// @param amountIn input amount, assumed to be type(uint104).max or less /// @param reserve0 reserves of token0, assumed to be type(uint104).max or less @@ -135,7 +138,7 @@ library StableMath { } } - revert("SM: COMPUTE_DID_NOT_CONVERGE"); + revert SM_COMPUTE_DID_NOT_CONVERGE(); } /// @notice Calculate the new balance of one token given the balance of the other token @@ -163,6 +166,6 @@ library StableMath { return y; } } - revert("SM: GETY_DID_NOT_CONVERGE"); + revert SM_GETY_DID_NOT_CONVERGE(); } }