Ordiswap Oracle

Ordiswap's synthetic oracle introduces a groundbreaking approach to pricing pools within the ecosystem. In our innovative design, all Ordiswap pools double as oracles, providing seamless access to historical price and liquidity data, thereby unlocking a myriad of on-chain use cases.

Our synthetic oracle employs an array of observations to store historical data. Initially, each pool monitors a single observation, dynamically updating it with the progression of blocks. While this approach imposes a constraint on how far back users can retrieve data, any interested party can extend this horizon by bearing the transaction fees. This expansion allows for an increased number of tracked observations, capped at a maximum of 65535, resulting in an extended data availability period of approximately 9 days or more.

By storing price and liquidity history directly within the pool contract, Ordiswap substantially mitigates the risk of logical errors in calling contracts. This design choice also streamlines integration efforts by eliminating the necessity to manage historical values externally. Furthermore, our synthetic oracle boasts a substantial maximum length, creating a formidable barrier against price manipulation attempts, as calling contracts can effortlessly compute a time-weighted average over any specified range within or encompassing the oracle array length.


Ordiswap leverages a sophisticated oracle mechanism based on Uniswap's observation structure to maintain robust pricing off-chain, ensuring the integrity of our Automated Market Maker (AMM). The oracle relies on the following components:

  1. Observation Structure: The observation structure consists of essential parameters:

    • blockTimestamp: Records the block timestamp of the observation.

    • tickCumulative: Represents the tick accumulator, i.e., the product of tick and the time elapsed since the pool's initiation.

    • secondsPerLiquidityCumulativeX128: Indicates the seconds per liquidity, i.e., seconds elapsed divided by the maximum of 1 or liquidity, since the pool's initiation.

    • initialized: A boolean flag determining whether the observation is initialized.

  2. Data Retrieval: Observations can be retrieved using the observations method off-chain, on pools.

    solidityCopy codefunction observe(uint32[] calldata secondsAgos)
        external
        view
        returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);

    Each invocation of observe requires the caller to provide an array of time intervals denoting the periods to retrieve observations. The function then returns the corresponding tick cumulatives and seconds per liquidity cumulatives.

  3. Interpolation and Counterfactual Observations: Ordiswap implements counterfactual observations when the provided times in observe don't precisely align with a block where an observation was written. This eliminates the need for manual interpolation, enhancing the efficiency and accuracy of the oracle.

  4. Update Frequency: Given that the oracle is updated at most once per block, calling observe with a secondsAgo value of 0 ensures retrieval of the most recently written observation. However, this observation can only be as recent as the beginning of the current block or older.

By meticulously utilizing Uniswap's observation structure and the observe function, Ordiswap's off-chain oracle implementation guarantees reliable and up-to-date pricing data for our AMM, providing a secure foundation for users and contributors alike.

Last updated