Solidity API
UtilitiesLib
Library for utility functions
This library provides utility functions for common operations.
convertDecimals
function convertDecimals(uint256 value, uint8 fromDecimals, uint8 toDecimals) internal pure returns (uint256 convertedValue)
Converts a value from one decimal precision to another
Parameters
Name | Type | Description |
---|---|---|
value | uint256 | The value to convert |
fromDecimals | uint8 | The number of decimals in the source value |
toDecimals | uint8 | The number of decimals to convert to |
Return Values
Name | Type | Description |
---|---|---|
convertedValue | uint256 | The value converted to the target decimals |
convertEncryptedDecimals
function convertEncryptedDecimals(euint128 encryptedValue, uint8 fromDecimals, uint8 toDecimals) internal returns (euint128 convertedEncryptedValue)
Converts an encrypted value from one decimal precision to another
Parameters
Name | Type | Description |
---|---|---|
encryptedValue | euint128 | The encrypted value to convert |
fromDecimals | uint8 | The number of decimals in the source value |
toDecimals | uint8 | The number of decimals to convert to |
Return Values
Name | Type | Description |
---|---|---|
convertedEncryptedValue | euint128 | The encrypted value converted to the target decimals |