This guide explains how pricing works in OraclePool and how to track price changes. The key insight is that the execution price is not simply the oracle price — it's computed from both oracle data AND pool reserves.
The Pricing Model
OraclePool uses a Concentrated Liquidity Constant Product (CLCP) model. The price is determined by two components:
Oracle Data (Set by Operator)
The oracle operator sets these parameters:
Parameter
Description
Format
price (P)
Center/reference price of tokenX in tokenY
1e24 precision
alpha
Concentration factor
BPS (10000 = 1.0)
feeHbps
Trading fee
Hundred basis points (1e6 = 100%)
expiry
When the data expires
Unix timestamp
The alpha parameter defines the price range: [P/alpha, P*alpha]
For example, with alpha = 10100 (1.01 in BPS):
If oracle price P = 1.0, the actual price can range from ~0.99 to ~1.01
Pool Reserves
The reserves (reserveX, reserveY) determine where within the price range the actual price sits.
The CLCP formula computes "virtual reserves" from real reserves + oracle params, then applies constant product pricing. As trades occur, reserves change, moving the price within the allowed range.
Oracle price alone is NOT the execution price. The oracle sets the "center" and boundaries; reserves determine the actual position within those boundaries. To compute the true execution price you need BOTH oracle data AND reserves.
Reading Oracle Data
Computing the Oracle Key
Oracle data is stored by a key derived from the token pair:
Order matters! tokenX must come first when computing the key.
Getting the Data
Example usage:
Getting the Current Price
The ClcpOracle contract provides a function to compute the actual price:
1
How getCurrentPrice works — step 1
Reads the oracle data (price P, alpha).
2
How getCurrentPrice works — step 2
Uses the provided reserves.
3
How getCurrentPrice works — step 3
Computes the actual price using the CLCP formula.
4
How getCurrentPrice works — step 4
Returns price with 1e24 precision.
Example:
Price Format and Decimal Adjustment
The price returned is with 1e24 precision and represents the price of tokenX in terms of tokenY.
To get a human-readable price, adjust for token decimals:
Example — tokenX has 18 decimals and tokenY (USDC) has 6 decimals:
Another example — tokenX has 6 decimals and tokenY has 18 decimals:
Tracking Price Changes
Price can change from two sources:
Reserve Changes (Events Available)
Reserves change on:
Swaps: Swap event
Reallocation: Allocated event
Watch these events to detect reserve-driven price moves.
Oracle Data Changes (No Events)
The oracle's setData() function does NOT emit events. To track oracle changes you must either watch transactions calling setData() on the oracle contract or periodically poll getData(key).
TypeScript Example
Python Example
Key Takeaways
1
Price is a function of oracle data and reserves
You need both to get the actual price.
2
Oracle data has no events
You must poll getData(key) or watch transactions that call setData().
3
Reserve changes have events
Watch Swap and Allocated events for reserve-driven price changes.
4
Price precision is 1e24
Use humanPrice = priceE24 / 1e24 * 10^(decimalsX - decimalsY)