API reference v1.0
Introduction
periphery
tokenomics
DataStorageOperator

DataStorageOperator

DataStorageOperator

Modifiers

onlyPool

Variables

struct DataStorage.Timepoint[65536] timepoints

struct AdaptiveFee.Configuration feeConfig

Functions

constructor

constructor(address) public

NameTypeDescription
_pooladdress

initialize

onlyPool

initialize(uint32,int24) external

Initialize the dataStorage array by writing the first slot. Called once for the lifecycle of the timepoints array

NameTypeDescription
timeuint32The time of the dataStorage initialization, via block.timestamp truncated to uint32
tickint24Initial tick

changeFeeConfiguration

changeFeeConfiguration(struct AdaptiveFee.Configuration) external

Changes fee configuration for the pool

NameTypeDescription
_feeConfigstruct AdaptiveFee.Configuration

getSingleTimepoint

onlyPool

getSingleTimepoint(uint32,uint32,int24,uint16,uint128) view external

NameTypeDescription
timeuint32The current block timestamp
secondsAgouint32The amount of time to look back, in seconds, at which point to return an timepoint
tickint24The current tick
indexuint16The index of the timepoint that was most recently written to the timepoints array
liquidityuint128The current in-range pool liquidity

Returns:

NameTypeDescription
tickCumulativeint56
secondsPerLiquidityCumulativeuint160
volatilityCumulativeuint112
volumePerAvgLiquidityuint256

getTimepoints

onlyPool

getTimepoints(uint32,uint32[],int24,uint16,uint128) view external

Returns the accumulator values as of each time seconds ago from the given time in the array of `secondsAgos`

NameTypeDescription
timeuint32The current block.timestamp
secondsAgosuint32[]Each amount of time to look back, in seconds, at which point to return an timepoint
tickint24The current tick
indexuint16The index of the timepoint that was most recently written to the timepoints array
liquidityuint128The current in-range pool liquidity

Returns:

NameTypeDescription
tickCumulativesint56[]
secondsPerLiquidityCumulativesuint160[]
volatilityCumulativesuint112[]
volumePerAvgLiquiditysuint256[]

getAverages

onlyPool

getAverages(uint32,int24,uint16,uint128) view external

Returns average volatility in the range from time-WINDOW to time

NameTypeDescription
timeuint32The current block.timestamp
tickint24The current tick
indexuint16The index of the timepoint that was most recently written to the timepoints array
liquidityuint128The current in-range pool liquidity

Returns:

NameTypeDescription
TWVolatilityAverageuint112
TWVolumePerLiqAverageuint256

write

onlyPool

write(uint16,uint32,int24,uint128,uint128) external

Writes an dataStorage timepoint to the array

NameTypeDescription
indexuint16The index of the timepoint that was most recently written to the timepoints array
blockTimestampuint32The timestamp of the new timepoint
tickint24The active tick at the time of the new timepoint
liquidityuint128The total in-range liquidity at the time of the new timepoint
volumePerLiquidityuint128The gmean(volumes)/liquidity at the time of the new timepoint

Returns:

NameTypeDescription
indexUpdateduint16

calculateVolumePerLiquidity

calculateVolumePerLiquidity(uint128,int256,int256) pure external

Calculates gmean(volume/liquidity) for block

NameTypeDescription
liquidityuint128The current in-range pool liquidity
amount0int256Total amount of swapped token0
amount1int256Total amount of swapped token1

Returns:

NameTypeDescription
volumePerLiquidityuint128

window

window() pure external

Returns:

NameTypeDescription
[0]uint32

getFee

onlyPool

getFee(uint32,int24,uint16,uint128) view external

Calculates fee based on combination of sigmoids

NameTypeDescription
_timeuint32
_tickint24
_indexuint16
_liquidityuint128

Returns:

NameTypeDescription
feeuint16