Token Oracles

How the token oracles work

The asset prices that help determine the target balances, and the total and individual token values for the Index are obtained via a combination of Chainlink oracles and the GMX Reader contract. These contract calls happen inside getPrice() on each token’s Oracle contract.

At deployment, the Oracle contract stores addresses for use in the getPrice() call (the token’s GMX market address, the GMX dataStore, and the GMX reader), and wraps the token’s Chainlink oracle address and USDC’s Chainlink oracle address in the AggregatorV3Interface type. It also stores the keccak256 hash of a public constant MAX_PNL_FACTOR_FOR_TRADERS that the GMX reader's function getMarketTokenPrice() uses.


function getPrice() external view returns (uint256, uint256)

Retrieves the current price of the GM token each specific oracle belongs to. The function retrieves marketProps from the GMX reader by calling the getMarket() function. The contract then calls latestRoundData() to retrieve the latest Chainlink oracle prices for the GM token and USDC. After decimal conversions, getMarketTokenPrice() is called with the necessary variables to retrieve the token's current price. After a type conversion and another decimal conversion, the final price is returned by the function.

For more info on getMarket() and getMarketTokenPrice(), please see the GMX documentation.





The price of the GM token, determined by the GMX reader contract

Last updated