Skip to content

Commit

Permalink
feedback on helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
andreivladbrg authored and smol-ninja committed Oct 15, 2024
1 parent 8de394b commit 8b50da8
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/libraries/Helpers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 8b50da8

Please sign in to comment.