From add6b0271984e02ae74736c918632671c2b5e2c5 Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Fri, 23 Feb 2024 22:37:37 -0600 Subject: [PATCH] Removed unnecessary types --- contracts/src/internal/HyperdriveBase.sol | 3 +-- contracts/src/internal/HyperdriveLP.sol | 5 ++--- contracts/src/internal/HyperdriveLong.sol | 2 +- contracts/src/libraries/AssetId.sol | 10 ++++------ contracts/src/libraries/LPMath.sol | 4 ++-- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/contracts/src/internal/HyperdriveBase.sol b/contracts/src/internal/HyperdriveBase.sol index cd5de9e64..482702200 100644 --- a/contracts/src/internal/HyperdriveBase.sol +++ b/contracts/src/internal/HyperdriveBase.sol @@ -285,8 +285,7 @@ abstract contract HyperdriveBase is IHyperdriveEvents, HyperdriveStorage { // The global long exposure is the sum of the non-netted longs in each // checkpoint. To update this value, we subtract the current value // (`_before.max(0)`) and add the new value (`_after.max(0)`). - int128 delta = (int256(_after.max(0)) - int256(_before.max(0))) - .toInt128(); + int128 delta = (_after.max(0) - _before.max(0)).toInt128(); if (delta > 0) { _marketState.longExposure += uint128(delta); } else if (delta < 0) { diff --git a/contracts/src/internal/HyperdriveLP.sol b/contracts/src/internal/HyperdriveLP.sol index 2861c6227..61fc0a25d 100644 --- a/contracts/src/internal/HyperdriveLP.sol +++ b/contracts/src/internal/HyperdriveLP.sol @@ -410,10 +410,9 @@ abstract contract HyperdriveLP is // NOTE: Round down to underestimate the share proceeds. // // The LP gets the pro-rata amount of the collected proceeds. - uint128 proceeds_ = _withdrawPool.proceeds; uint256 shareProceeds = withdrawalSharesRedeemed.mulDivDown( - uint128(proceeds_), - uint128(readyToWithdraw_) + _withdrawPool.proceeds, + readyToWithdraw_ ); // Apply the update to the withdrawal pool. diff --git a/contracts/src/internal/HyperdriveLong.sol b/contracts/src/internal/HyperdriveLong.sol index dc588a260..ab6386972 100644 --- a/contracts/src/internal/HyperdriveLong.sol +++ b/contracts/src/internal/HyperdriveLong.sol @@ -255,7 +255,7 @@ abstract contract HyperdriveLong is IHyperdriveEvents, HyperdriveLP { _marketState.longAverageMaturityTime ) .updateWeightedAverage( - uint256(longsOutstanding_), + longsOutstanding_, _maturityTime * ONE, // scale up to fixed point scale _bondReservesDelta, true diff --git a/contracts/src/libraries/AssetId.sol b/contracts/src/libraries/AssetId.sol index c8bf3d980..5aa4346ec 100644 --- a/contracts/src/libraries/AssetId.sol +++ b/contracts/src/libraries/AssetId.sol @@ -78,7 +78,7 @@ library AssetId { } else if (prefix == AssetIdPrefix.Short) { _name = string(abi.encodePacked("Hyperdrive Short: ", _timestamp)); } else if (prefix == AssetIdPrefix.WithdrawalShare) { - _name = string(abi.encodePacked("Hyperdrive Withdrawal Share")); + _name = "Hyperdrive Withdrawal Share"; } } @@ -97,7 +97,7 @@ library AssetId { } else if (prefix == AssetIdPrefix.Short) { _name = string(abi.encodePacked("HYPERDRIVE-SHORT:", _timestamp)); } else if (prefix == AssetIdPrefix.WithdrawalShare) { - _name = string(abi.encodePacked("HYPERDRIVE-WS")); + _name = "HYPERDRIVE-WS"; } } @@ -115,14 +115,12 @@ library AssetId { // Loop through the integer and add each digit to the raw result, // starting at the end of the string and working towards the beginning. - rawResult[maxStringLength - 1] = bytes1( - uint8(uint256((_num % 10) + 48)) - ); + rawResult[maxStringLength - 1] = bytes1(uint8((_num % 10) + 48)); _num /= 10; uint256 digits = 1; while (_num != 0) { rawResult[maxStringLength - digits - 1] = bytes1( - uint8(uint256((_num % 10) + 48)) + uint8((_num % 10) + 48) ); _num /= 10; digits++; diff --git a/contracts/src/libraries/LPMath.sol b/contracts/src/libraries/LPMath.sol index fdf88ee48..dbb61653a 100644 --- a/contracts/src/libraries/LPMath.sol +++ b/contracts/src/libraries/LPMath.sol @@ -77,7 +77,7 @@ library LPMath { // NOTE: Rounding down to avoid introducing dust into the // computation. shareAdjustment = int256( - uint256(shareReserves).mulDivDown( + shareReserves.mulDivDown( uint256(_shareAdjustment), _shareReserves ) @@ -86,7 +86,7 @@ library LPMath { // NOTE: Rounding down to avoid introducing dust into the // computation. shareAdjustment = -int256( - uint256(shareReserves).mulDivDown( + shareReserves.mulDivDown( uint256(-_shareAdjustment), _shareReserves )