Skip to main content

TwapTask

Takes a twap over a set period for a certain aggregator. Aggregators have an optional history buffer account storing the last N accepted results. The TwapTask will iterate over an aggregators history buffer and calculate the time weighted average of the samples within a given time period.

Input: None

Returns: The time weighted average of an aggregator over a given time period.

Example: The 1hr Twap of the SOL/USD Aggregator, requiring at least 60 samples.

{
"twapTask": {
"aggregatorPubkey": "GvDMxPzN1sCj7L26YDK2HnMRXEQmQ2aemov8YBtPS7vR",
"period": 3600,
"minSamples": 60,
"weightByPropagationTime": true
}
}


Fields

NameTypeDescription
 aggregatorPubkey

string

The target aggregator for the TWAP.

 endingUnixTimestamp

int32

Ending unix timestamp to collect values up to

 endingUnixTimestampTask

Execute the task to get the ending unix timestamp

 minSamples

uint32

Minimum number of samples in the history to calculate a valid result

 period

int32

Period, in seconds, the twap should account for

 weightByPropagationTime

bool

Weight samples by their propagation time