Formula
NostraSwap imposes a LimitPriceImpactPerSecond on the oracle price to protect against manipulations. Upon initialization, the oracle price is set to be the market price:
For each trade, the oracle price is updated through the following rule:
Where
is the stored oracle price in the contract is the new oracle price is the market price is time in seconds since the oracle price was last updated is a hyperparameter initially set to be 0.019% (around 0.25% per block) but can be updated by the factory owner to suit the volatility of different assets.
As opposed to TWAP, this method of calculating oracle price from market price can both provide price security and price freshness.
Last updated
Was this helpful?