Oracle

Oracles on Yowie Finance

All Yowie Finance pools serve as oracles, providing access to historical price and liquidity data, which opens up various on-chain use cases.

Historical data is organized as an array of observations. Initially, each pool tracks only a single observation, replacing it as new blocks are added. This limitation restricts users’ access to historical data. However, any participant willing to cover the transaction fees can increase the number of tracked observations (up to a maximum of 65,535), thereby extending the availability of data to approximately nine days or more.

By storing price and liquidity history directly within the pool contract, the risk of logical errors from the calling contract is significantly minimized, and integration costs are reduced since there’s no need to maintain separate historical records. Moreover, the extensive maximum length of the oracle makes it much harder to manipulate prices, allowing the calling contract to easily construct a time-weighted average over any chosen range, whether it fits within or fully spans the length of the oracle array.

Observations

Observations take the following form:

struct Observation {
    // the block timestamp of the observation
    uint32 blockTimestamp;
    // the tick accumulator, i.e. tick * time elapsed since the pool was first initialized
    int56 tickCumulative;
    // the seconds per liquidity, i.e. seconds elapsed / max(1, liquidity) since the pool was first initialized
    uint160 secondsPerLiquidityCumulativeX128;
    // whether or not the observation is initialized
    bool initialized;
}