How it work?
Last updated
Last updated
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.
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.
Relevant data needs to be fetched from the decentralized cache layer, powered by Bracle Network light cache nodes
Data is packed into a message according to the following structure
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
The appended data packages are extracted from the msg.data
For each data package we:
Verify if the signature was created by a trusted provider
Validate the timestamp, checking if the information is not obsolete
Then, for each requested data feed we:
Calculate the number of received unique signers
Extract value for each unique signer
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
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.