🔮Oracles and Price Feeds
Adrena uses of oracles
Perpetuals exchanges on chain rely on external information, namely price feeds from oracles. These are used for determining the price of the assets supported by the platform in the liquidity pool, for trading, and for collateral deposits.
As a perpetual exchange based on oracle prices, Adrena requires reliable and up to date price feeds to enable user activity.
Adrena uses Pyth Network’s price feeds.
Challenges
Prices feeds have two important qualities:
being up to date, reflecting the latest market valuation of the asset
being accurate, reflecting the correct market valuation of the asset
The up to date part is enforced at two levels:
Pyth framework and price feed built-in verification related to
valid_slot
Adrena’s oracles configuration
OracleParams.max_price_age_sec
currently set to 3 seconds
The accuracy part is more challenging as there is no “real price”, but only an approximation based on the aggregation of supply and demand over a multitude of venues.
Pyth distillates this information to us through their feed, which comes with the confidence interval, which reflects the price's accuracy, or spread.
Existing parades
To address this, multiple choices (by order of desirability) :
always use the best price from the platform PoV by subtracting/adding the confidence to the mid price returned by the oracle (a.k.a. worse price, from user PoV)
PRO: protects liquidity providers, without which there is no trading possible, generates more fees as the confidence does not inform the direction
CON: traders bear the load
This is what Adrena implements ^
halt trading when volatility reach X (confidence interval higher than X)
PRO: impossible to game
CON: not very enticing UX, nor good for fees, high volatility period are period during which people want to take trades
use EMA price from the price feed
PRO: partially protects against high volatility period price
CON: lags behind the real price, bad UX for traders and also create new arbitrage risks as the real price is sometime very far from the EMA price.
use the worse price between EMA and worse price
PRO: beyond safe, this is a hidden fee from the platform on it's users
CON: users gets the ultimate worse price possible even when the oracle confidence is low
Additionally some platforms sprinkle some of this on top of the above:
add a virtual spread of X bps on everything, basically a hidden fee
PRO: it generates additional revenues, creates a buffer to prevent arbs
CON: this does not protect against very high volatility periods
At adre
Last updated