
Decimal Precision & Formatting
Key Fields Returned by getAssetInfo
getAssetInfoField
Type
Description
How Scaling Works
Solidity Example: Converting to Human-Readable
// Offchain or simple onchain (assuming fixed -18 decimals)
uint256 humanPrice = uint256(info.price) / 10**18;
// For variable decimals (advanced — use a library)
function toHuman(int256 _price, int8 _decimal) public pure returns (uint256) {
require(_decimal < 0, "Positive decimals not supported");
uint8 decimals = uint8(-_decimal);
return uint256(_price) / (10 ** decimals);
}Best Practices
Last updated
Was this helpful?

