How it work?

The price feeds come from multiple sources such as off-chain CEX'ed (Binance, OKX, Coinbase & Kraken, etc.), on-chain DEX'es (Uniswap, Curve, etc.) and aggregators (CoinmarketCap, Coingecko). Currently, we've got more than 20+ sources integrated. The data is aggregated in independent nodes operated by data providers using various methodologies (eg. median, TWAP, LWAP) and safety measures like outliers detection. The cleaned and processed data is then signed by node operators underwriting the quality. The feeds are broadcast directly to Bracle Network Validator Node, which could be easily spun off on demand. The data could be pushed on-chain either by a dedicated relayer operating under predefined conditions (ie. heartbeat or price deviation), by a bot (ie. performing liquidations), or even by end users interacting with the protocol. Inside the on-chain protocol, the data is unpacked and verified cryptographically checking both the origin and timestamps.

Data Format

At a top level, transferring data to a Blockchain VM environment requires packing an extra payload to a user's transaction and processing the message on-chain.

Data packing (off-chain data encoding)

  1. Relevant data needs to be fetched from the decentralized cache layer, powered by Bracle Network light cache nodes

  2. Data is packed into a message according to the following structure

  1. The package is appended to the original transaction message, signed and submitted to the network

All of the steps are executed automatically by ContractProxy and transparent to the end-user

Data unpacking (on-chain data verification)

  1. The appended data packages are extracted from the msg.data

  2. For each data package we:

    1. Verify if the signature was created by a trusted provider

    2. Validate the timestamp, checking if the information is not obsolete

  3. Then, for each requested data feed we:

    1. Calculate the number of received unique signers

    2. Extract value for each unique signer

    3. Calculate the aggregated value (median by default)

This logic is executed in the on-chain environment and we optimised the execution using a low-level assembly code to reduce gas consumption to the absolute minimum

On-chain aggregation

To increase the security of the Bracle oracle system, we've created the on-chain aggregation mechanism. This mechanism adds an additional requirement of passing at least X signatures from different authorised data providers for a given data feed. The values of different providers are then aggregated before returning to a consumer contract (by default, we use median value calculation for aggregation). This way, even if some small subset of providers corrupt (e.g. 2 of 10), it should not significantly affect the aggregated value.

Last updated