From b3b8f3ec28835856e6dd93ebbe7cf38b8364179d Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Fri, 23 Feb 2024 20:39:11 -0600 Subject: [PATCH 1/2] Replaced remaining instances of 1e18 with `ONE` --- .../src/deployers/HyperdriveDeployerCoordinator.sol | 9 +++++---- contracts/src/internal/HyperdriveLong.sol | 6 +++--- contracts/src/internal/HyperdriveShort.sol | 4 ++-- contracts/src/libraries/FixedPointMath.sol | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/contracts/src/deployers/HyperdriveDeployerCoordinator.sol b/contracts/src/deployers/HyperdriveDeployerCoordinator.sol index e0c055deb..242426a23 100644 --- a/contracts/src/deployers/HyperdriveDeployerCoordinator.sol +++ b/contracts/src/deployers/HyperdriveDeployerCoordinator.sol @@ -5,6 +5,7 @@ import { IHyperdrive } from "../interfaces/IHyperdrive.sol"; import { IHyperdriveCoreDeployer } from "../interfaces/IHyperdriveCoreDeployer.sol"; import { IHyperdriveDeployerCoordinator } from "../interfaces/IHyperdriveDeployerCoordinator.sol"; import { IHyperdriveTargetDeployer } from "../interfaces/IHyperdriveTargetDeployer.sol"; +import { ONE } from "../libraries/FixedPointMath.sol"; /// @author DELV /// @title HyperdriveDeployerCoordinator @@ -342,10 +343,10 @@ abstract contract HyperdriveDeployerCoordinator is // Ensure that the fees don't exceed 100%. if ( - _deployConfig.fees.curve > 1e18 || - _deployConfig.fees.flat > 1e18 || - _deployConfig.fees.governanceLP > 1e18 || - _deployConfig.fees.governanceZombie > 1e18 + _deployConfig.fees.curve > ONE || + _deployConfig.fees.flat > ONE || + _deployConfig.fees.governanceLP > ONE || + _deployConfig.fees.governanceZombie > ONE ) { revert IHyperdriveDeployerCoordinator.InvalidFeeAmounts(); } diff --git a/contracts/src/internal/HyperdriveLong.sol b/contracts/src/internal/HyperdriveLong.sol index 749d75ecf..dc588a260 100644 --- a/contracts/src/internal/HyperdriveLong.sol +++ b/contracts/src/internal/HyperdriveLong.sol @@ -5,7 +5,7 @@ import { IHyperdrive } from "../interfaces/IHyperdrive.sol"; import { IHyperdriveEvents } from "../interfaces/IHyperdriveEvents.sol"; import { AssetId } from "../libraries/AssetId.sol"; import { Errors } from "../libraries/Errors.sol"; -import { FixedPointMath } from "../libraries/FixedPointMath.sol"; +import { FixedPointMath, ONE } from "../libraries/FixedPointMath.sol"; import { HyperdriveMath } from "../libraries/HyperdriveMath.sol"; import { SafeCast } from "../libraries/SafeCast.sol"; import { HyperdriveLP } from "./HyperdriveLP.sol"; @@ -256,7 +256,7 @@ abstract contract HyperdriveLong is IHyperdriveEvents, HyperdriveLP { ) .updateWeightedAverage( uint256(longsOutstanding_), - _maturityTime * 1e18, // scale up to fixed point scale + _maturityTime * ONE, // scale up to fixed point scale _bondReservesDelta, true ) @@ -346,7 +346,7 @@ abstract contract HyperdriveLong is IHyperdriveEvents, HyperdriveLP { ) .updateWeightedAverage( longsOutstanding, - _maturityTime * 1e18, // scale up to fixed point scale + _maturityTime * ONE, // scale up to fixed point scale _bondAmount, false ) diff --git a/contracts/src/internal/HyperdriveShort.sol b/contracts/src/internal/HyperdriveShort.sol index ea708ed86..3f0a650a7 100644 --- a/contracts/src/internal/HyperdriveShort.sol +++ b/contracts/src/internal/HyperdriveShort.sol @@ -302,7 +302,7 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP { ) .updateWeightedAverage( _marketState.shortsOutstanding, - _maturityTime * 1e18, // scale up to fixed point scale + _maturityTime * ONE, // scale up to fixed point scale _bondAmount, true ) @@ -360,7 +360,7 @@ abstract contract HyperdriveShort is IHyperdriveEvents, HyperdriveLP { ) .updateWeightedAverage( shortsOutstanding_, - _maturityTime * 1e18, // scale up to fixed point scale + _maturityTime * ONE, // scale up to fixed point scale _bondAmount, false ) diff --git a/contracts/src/libraries/FixedPointMath.sol b/contracts/src/libraries/FixedPointMath.sol index 7ccb85914..25c695e82 100644 --- a/contracts/src/libraries/FixedPointMath.sol +++ b/contracts/src/libraries/FixedPointMath.sol @@ -50,7 +50,7 @@ library FixedPointMath { /// @param b Fixed point number in 1e18 format. /// @return Result of a / b rounded down. function divDown(uint256 a, uint256 b) internal pure returns (uint256) { - return (mulDivDown(a, 1e18, b)); // Equivalent to (a * 1e18) / b rounded down. + return (mulDivDown(a, ONE, b)); // Equivalent to (a * 1e18) / b rounded down. } /// @param x Fixed point number in 1e18 format. @@ -84,14 +84,14 @@ library FixedPointMath { /// @param b Fixed point number in 1e18 format. /// @return The result of a * b rounded up. function mulUp(uint256 a, uint256 b) internal pure returns (uint256) { - return (mulDivUp(a, b, 1e18)); + return (mulDivUp(a, b, ONE)); } /// @param a Fixed point number in 1e18 format. /// @param b Fixed point number in 1e18 format. /// @return The result of a / b rounded up. function divUp(uint256 a, uint256 b) internal pure returns (uint256) { - return (mulDivUp(a, 1e18, b)); + return (mulDivUp(a, ONE, b)); } /// @dev Exponentiation (x^y) with unsigned 18 decimal fixed point base and exponent. From e7fb77f4528119dc7aaf996a8c5e4ff0167923f4 Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Sat, 24 Feb 2024 02:07:16 -0600 Subject: [PATCH 2/2] Updated missing `ONE` --- contracts/src/libraries/FixedPointMath.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/src/libraries/FixedPointMath.sol b/contracts/src/libraries/FixedPointMath.sol index 25c695e82..f919ac3ee 100644 --- a/contracts/src/libraries/FixedPointMath.sol +++ b/contracts/src/libraries/FixedPointMath.sol @@ -43,7 +43,7 @@ library FixedPointMath { /// @param b Fixed point number in 1e18 format. /// @return Result of a * b rounded down. function mulDown(uint256 a, uint256 b) internal pure returns (uint256) { - return (mulDivDown(a, b, 1e18)); + return (mulDivDown(a, b, ONE)); } /// @param a Fixed point number in 1e18 format.