bp-ventures / lightecho-stellar-oracle

A Stellar Soroban Oracle contract implemented by BP Ventures
MIT License
4 stars 0 forks source link

add a readme about this project (update as required) #6

Closed antb123 closed 1 year ago

antb123 commented 1 year ago

BPV - Blockchain Oracle

BACKGROUND

Price Oracles serve as an essential element in the next-generation Stellar Soroban smart contract system, which leverages the Rust programming language. They are widely applied in lending schemes that incorporate approaches like overcollateralized loans. Decentralized systems require a secure and reliable way to access external data, especially when it comes to financial data that impacts decision-making within the applications (1). Since blockchain networks are typically isolated from the outside world, price oracles act as a bridge between off-chain data and on-chain applications, ensuring accurate and trustworthy information for users and developers.

Major oracle disruptions could endanger billions of dollars stored in Soroban-based agreements. Recognizing the focused risks is crucial, as the ever-expanding assortment of projects within the system typically hinges on a few price oracles. A breakdown in even one of these oracles might trigger a catastrophic ripple effect throughout the entire ecosystem. As a result, the seamless integration of dependable and secure price oracles is crucial for the success of Stellar Soroban.

We previously developed LightEcho.io, an aggregator that compiles pricing data from various sources, including Decentralized Exchanges (DEXs), Centralized Exchanges (CEXs), Instant Exchanges (ICE), and Peer-to-Peer (P2P) exchanges. It collects data from over 50 sources. This platform showcases Stellar pricing information.

For this project, we aim to create two distinct types of oracle contracts within the Stellar Soroban ecosystem: 1) An embedded oracle, in which all prices are stored inside the contract data on-chain, and the prices can be obtained at any time by invoking the contract function directly from another contract. 2) A callback-based oracle, in which a price is requested alongside a contract ID for receiving the price later, then a backend aggregator (off-chain) detects the request via getEvents, and invokes the receiver contract, passing the price as a parameter to the function being invoked.

The sources of the prices that are fed into those contracts will be decentralized, meaning there will be multiple sources, each one controlled by a different trusted market data providing, company or exchange. It's on the consumer (of the contracts) to decide which price source to rely on when retrieving a price.

In developing an effective pricing mechanism, we have carefully considered several stages in our journey. For on-chain data, our strategy involves gathering data from Stellar Classic (such as the XLM-USDC price). This will be accomplished through an RPC call that computes the current price based on the Liquidity Pool within Stellar Classic. Additionally, we plan to explore the potential of extracting data from Uniswap, further diversifying our data sources and enhancing accuracy.

For the centralized pricing systems we will both investigate using the pricing model from CME(6) and use a hybrid model taking the best of Maker Dao and Cornell University's "Town Crier" model(2).

Our design goals for this project encompass the following key aspects:

By addressing these design goals, we strive to create a comprehensive, reliable, and user-friendly system on Stellar that caters to the diverse needs of the smart contract and trading ecosystem.

PILOT:

Embedded Oracle For our pilot we have taken the developer discussion from Alex and Orbitens (3) and we believe have made it more flexible. While incorporating data structures used in traditional finance (4). You can see the current pilot implementation in the Github repository located here

An overview of our modifications to the structure proposed by Alex and Orbitens (3):

Please feel free to ask questions and provide feedback via the Discussions page located at: https://github.com/bp-ventures/lightecho-soroban-oracle

.

REFERENCE:

1 Ethereum Oracles https://ethereum.org/en/developers/docs/oracles/

2 The Oracle Problem: Unlocking the Potential of Blockchain By Jennifer Yen, Upenn https://www.cis.upenn.edu/~fbrett/assets/theses/jennifer_yen.pdf

3 Script3 and Orbitlens discussion https://groups.google.com/g/stellar-dev/c/KV2XaQzcPPQ

4 FIX 4.3 Market Data https://www.onixs.biz/fix-dictionary/4.3/app_g.html

5 Chainlink whitepaper https://research.chain.link/whitepaper-v1.pdf

6 CME BRTI calculation https://www.cmegroup.com/education/bitcoin/infographic-cme-cf-brr-and-brti.html

7 OpenZeppelin Oracle discussion https://blog.openzeppelin.com/secure-smart-contract-guidelines-the-dangers-of-price-oracles/

8 OpenZepplin Oracle Security https://github.com/OpenZeppelin/workshops/blob/master/16-dangers-price-oracles-smart-contracts/slides.pdf

9 Uniswap Oracles (TWAP) https://docs.uniswap.org/contracts/v2/concepts/core-concepts/oracles

10 Bitcoin currency code: XBT vs BTC https://support.kraken.com/hc/en-us/articles/360001206766-Bitcoin-currency-code-XBT-vs-BTC

yuriescl commented 1 year ago

Done