Price Oracle Service

Introduction

The purpose of the price oracle micro service (POMS) is to consistently and accurately monitor prices of various crypto assets. The POMS is additionally responsible for providing continuous access to that data to various parts of the protocol.

Architecture

The POMS will utilize a combination of on chain, as well as traditional web2 API points to collate pricing data for given assets. The POMS will utilize a "safety mechanism" to identify and weed out any abhorrent pricing data. Once the data passes through the safety mechanism, it will be made available for use throughout the protocol.

  • General stack

    • Python 3 with Poetry environment management

    • FastAPI for creating the server

    • <TODO: Library for using pub-sub>

    • Web sockets

    • REST

    • Swagger (for documentation)

    • Docker

    • Kubernettes

  • On chain data

    • The POMS will establish a web socket with the NODE service. This connection will relay up to date pricing data from the chainlink oracle smart contracts.

    • The pricing data will be updated every time the node registers an event.

    • The pricing data will be fed into a safety mechanism for comparison against additional (see below)

  • Off chain data

    • The POMS will establish web socket connections with a minimum of two third party pricing api's.

    • The third party apis must obtain their data from different sources

    • Once an updated asset price is passed to the POMS, that new data will be fed into a safety mechanism for comparison against additional pricing data.

  • Safety mechanism

    • The purpose of the safety mechanism is to identify any one source that is > n% different than the other two sources. This will identify any "rogue" pricing data and disallow it from being sent to the decision making centers of the protocol.

    • The mechanism will store last prices from each of the data sources

      • This storage will be small, likely only ~60 minutes worth

    • Upon receipt of updated pricing data, it will be checked against the last pricing data available for that particular source.

    • The data will then be compared with the last data available for the other sources.

    • If the pricing data is found to be outside acceptable bounds of tolerance, that data will be discarded.

      • If this occurs, the "secondary" data will be made available to the protocol.

    • Preference will be given to data derived on chain.

    • An unpredictable rotation will be utilized in order to prevent potential attackers from being able to identify and manipulate our data source.

  • Gateway

    • The micro service will expose a combination of pub-sub instances, websockets and standard/traditional REST API interface to expose data as needed.

Integration within the product ecosystem

The POMS will contain a module that exposes the following data retrieval points

  • PUB-SUB

    • For use with the other microservices running within the protocol

  • Websocket

    • For use as an alternate to pub sub

    • May be made available to the frontend.

  • Traditional REST API interface

    • For use by the frontend

    • Used to request data on a specific asset

    • Used to setup continuous feeds (used above)

Last updated