check_price_sanity

Documentation for eth_defi.gmx.price_sanity.check_price_sanity function.

check_price_sanity(oracle_price, ticker_price, token_address, token_decimals, config)

Compare oracle and ticker prices and determine action.

This function compares prices from two independent sources (oracle and ticker) and calculates the deviation. If the deviation exceeds the configured threshold, it takes the specified action (log warning, use oracle, or raise exception).

The deviation is calculated as:

Parameters
  • oracle_price (dict) – Oracle price data from OraclePrices.get_recent_prices()

  • ticker_price (dict) – Ticker price data from GMXAPI.get_tickers()

  • token_address (str) – Token address being checked

  • token_decimals (int) – Number of decimals for the token

  • config (eth_defi.gmx.price_sanity.PriceSanityCheckConfig) – Configuration for the sanity check

Returns

PriceSanityCheckResult with comparison details and action taken

Return type

eth_defi.gmx.price_sanity.PriceSanityCheckResult