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:
OP=MP=reserve1reserve0
For each trade, the oracle price is updated through the following rule:
OP′={min(OP∗(1+lpips)t,MP),max(OP∗(1−lpips)t,MP),if OP≤MPotherwise
Where
OPis the stored oracle price in the contract OP′is the new oracle price MPis the market price t is time in seconds since the oracle price was last updated LPIPSis 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