Expand description
Oracle decimal conversion utilities.
Different oracle providers use different decimal precisions:
- Chainlink: 8 decimals for most feeds, 18 for some
- Pyth: Variable precision (exponent-based)
- RedStone: 8 decimals
- Band Protocol: 18 decimals
This module provides utilities for normalizing and converting between different oracle decimal formats.
Enums§
- Oracle
Decimals - Standard oracle decimal formats.
Functions§
- calculate_
value - Calculate the value of tokens in a quote currency.
- calculate_
value_ i128 - Calculate value and return as i128 for large results.
- convert_
decimals - Convert a price between two different decimal precisions.
- convert_
decimals_ i128 - Convert a price between decimal precisions, returning i128.
- denormalize_
oracle_ price - Convert a Decimal to a raw oracle integer value.
- denormalize_
oracle_ price_ i128 - Convert a Decimal to a raw oracle i128 value.
- normalize_
oracle_ price - Normalize a raw oracle value to a Decimal.
- normalize_
oracle_ price_ i128 - Normalize a large raw oracle value to a Decimal.
- normalize_
pyth_ price - Normalize a Pyth-style price with exponent.
- scale_
token_ amount - Scale a token amount between different decimal precisions.
- scale_
token_ amount_ i128 - Scale a token amount using i128 for large values.