convert_raw_price_to_usd

Documentation for eth_defi.gmx.utils.convert_raw_price_to_usd function.

convert_raw_price_to_usd(raw_price, token_decimals)

Convert GMX raw price to human-readable USD.

GMX stores prices in 30-decimal PRECISION format. The conversion formula is:

price_usd = raw_price / 10^(30 - token_decimals)

Examples:
  • BTC (8 decimals): raw / 10^22

  • ETH (18 decimals): raw / 10^12

  • USDC (6 decimals): raw / 10^24

Parameters
  • raw_price (int | float) – Raw price value from GMX (30-decimal format)

  • token_decimals (int) – Number of decimals for the token (e.g., 8 for BTC, 18 for ETH)

Returns

Price in USD

Return type

float