Overview
The Price Oracle Tool is a backend service in GalaSwap that calculates the USD prices of tokens in liquidity pools. These prices are used throughout the platform to display up-to-date token values and metrics, such as:
- Token prices on the GalaSwap frontend
- Total Value Locked (TVL)
- Trade volumes on the Explore page
⚠️ Note: The Price Tool is not used to determine the exact amounts of tokens swapped in transactions. It only provides price references used for display purposes.
How the Price Tool Works
Step 1: Determining the Price of GALA
The process begins by calculating the price of GALA, using three USDC-GALA liquidity pools:
- 1% fee pool
- 0.3% fee pool
- 0.05% fee pool
Each pool reports a price, which reflects the ratio of GALA to USDC. The backend queries all three pools and selects the price from the pool with the highest liquidity, as this is considered the most reliable source.
Step 2: Determining the Price of Other Tokens (e.g. FILM)
For any non-GALA token, such as FILM, the Price Tool evaluates up to six liquidity pools:
- 3 USDC pairs (e.g. FILM-USDC)
- 3 GALA pairs (e.g. FILM-GALA)
If the token has a USDC pair:
The price is calculated just like it is for GALA, based on the ratio of tokens in the pool.
If the token has a GALA pair:
The system first calculates the token’s value in GALA, then converts that value to USD using the GALA price calculated in Step 1.
This means there are potentially 12 price paths for each non-GALA token:
- 3 direct USDC pools
- 3 GALA pools × 3 possible GALA-USDC conversions