Skip to main content

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

NameTypeDescription
valueuint256The value to convert
fromDecimalsuint8The number of decimals in the source value
toDecimalsuint8The number of decimals to convert to

Return Values

NameTypeDescription
convertedValueuint256The 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

NameTypeDescription
encryptedValueeuint128The encrypted value to convert
fromDecimalsuint8The number of decimals in the source value
toDecimalsuint8The number of decimals to convert to

Return Values

NameTypeDescription
convertedEncryptedValueeuint128The encrypted value converted to the target decimals