Parameters

coefficient: the k value of the “x*y” formula, set by the market creator

reserve0: the initial value of the USD virtual liquidity, set by the market creator

reserve: the latest value of the USD virtual liquidity

decayPerSecond: exponential TWAP decay for markPrice, with 99.8% as default value

timeElapsed: the seconds elapsed since the last time when poke function is triggered

maxPokeElapsed: the max time cap for the timeElapsed, with default value as 1 hour(3600 seconds)

markPrice: exponential TWAP of spot price. It is used to calculate unrealized PNL and determine liquidations on the position.

markPrice = previousMarkPrice * decay + spotPrice * (1 - decay), where

decay = decayPerSecond ^ timeElapsed

indexPrice: price from external exchanges, provided by a Chainlink oracle

spotPrice: AMM price + shift, where AMM price = (coefficient / reserve) / reserve

fundingAdjustThreshold: if the difference of markPrice and indexPrice is above this threshold, funding will be adjusted. With default value as 0.5%.

shift: funding adjustment

markIndexDiff = abs(markPrice - indexPrice) / indexPrice

if markIndexDiff > fundingAdjustThreshold:

shift = previousShift + timeElapsed * markIndexDiff / secondsInADay

else:

shift = previousShift

strikePrice: the price at which the leverage position is worth 0

strikePrice of long position = markPrice + markPrice / leverage

strikePrice of short position = markPrice - markPrice / leverage

safeThreshold: buffer for liquidation, with default value as 93%

Long positions get liquidated when strikePrice / markPrice <= safeThreshold

Short positions get liquidated when markPrice / strikePrice >= safeThreshold

spotMarkThreshold: (spotPrice / markPrice) or (markPrice / spotPrice) must not exceed this value for a trade to be executed. Default value is 105%. This is a protection against price manipulation.

liquidationPerSec: the maximum amount of opposite trade the protocol will do per second to offset the liquidations. This is useful to prevent the flash crash of the price during big liquidation events.

liquidityChangePerSec: the maximum liquidity change per second, with default value as 0.5% per day cap

smallDecayTwapOI:exponential TWAP open interest for a shorter period

largeDecayTwapOI:exponential TWAP open interest for a longer period

smallOIDecayPerSecond: a faster exponential TWAP decay value to calculate smallDecayTwapOI, with default value as 99.999%

largeOIDecayPerSecond: a slower exponential TWAP decay value to calculate largeDecayTwapOI, with default value as 99.9999%

volumeChangeThreshold: If the difference between dailyVolume and prevDailyVolume is larger than this value, liquidity will be dynamically updated. Default value is 120%.

OIChangeThreshold: if (smallDecayTwapOI / largeDecayTwapOI) or (smallDecayTwapOI / largeDecayTwapOI) exceeds this value, the liquidity will be dynamically adjusted

isLiquidityDynamicByOI: boolean flag to turn on/off the liquidity adjustment based on open interest movement

isLiquidityDynamicByVolume: boolean flag to turn on/off the liquidity adjustment based on trading value trend

Last updated