From 8b50da83b825d463f836f8e08a13be568957c721 Mon Sep 17 00:00:00 2001 From: andreivladbrg Date: Tue, 15 Oct 2024 17:37:50 +0300 Subject: [PATCH] feedback on helpers --- src/libraries/Helpers.sol | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/libraries/Helpers.sol b/src/libraries/Helpers.sol index 7d013024..22a3c9f3 100644 --- a/src/libraries/Helpers.sol +++ b/src/libraries/Helpers.sol @@ -50,12 +50,9 @@ library Helpers { (brokerFeeAmount, depositAmount) = calculateAmountsFromFee(totalAmount, broker.fee); } - /// @notice Descales the provided `amount` to be denoted in the token's decimals. - /// @dev The following logic is used to denormalize the amount: - /// - If the token has exactly 18 decimals, the amount is returned as is. - /// - if the token has fewer than 18 decimals, the amount is divided by $10^(18 - tokenDecimals)$. + /// @notice Descales the provided `amount` from 18 decimals fixed-point number to token's decimals number. function descaleAmount(uint256 amount, uint8 decimals) internal pure returns (uint256) { - if (decimals > 18) { + if (decimals == 18) { return amount; } @@ -65,12 +62,9 @@ library Helpers { } } - /// @notice Scales the provided `amount` to be denoted in 18 decimals. - /// @dev The following logic is used to normalize the amount: - /// - If the token has exactly 18 decimals, the amount is returned as is. - /// - If the token has fewer than 18 decimals, the amount is multiplied by $10^(18 - tokenDecimals)$. + /// @notice Scales the provided `amount` from 18 decimals fixed-point number to token's decimals number. function scaleAmount(uint256 amount, uint8 decimals) internal pure returns (uint256) { - if (decimals > 18) { + if (decimals == 18) { return amount; }