# Oracle Risk Assessment: RedStone ![prisma_20240208_redstone-oracle (2)](https://hackmd.io/_uploads/r1rzYhziT.png) **A comprehensive review to determine the Oracle provider's suitability for onboarding to Prisma** ### Useful Links - Website: [redstone.finance](https://redstone.finance/) | [Warp (Arweave SDK)](https://warp.cc/) - Documentation: [RedStone Docs](https://docs.redstone.finance/) | [API Docs](https://api.docs.redstone.finance) | [GitHub](https://github.com/redstone-finance) - Social: [Blog](https://blog.redstone.finance/) | [Medium](https://medium.com/@RedStone_Finance) | [Twitter](https://twitter.com/redstone_defi) - Contracts: [EVM Connector](https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/evm-connector) - Dashboards: [Dune Dashboard](https://dune.com/hatskier/redstone) <!-- ## Important contracts and addresses [Available Redstone Providers](https://api.docs.redstone.finance/definitions/provider) - Arweave blockchain: - redstone (redst0ne.ar): [I-5rWUehEv-MjdK9gFw09RxfSLQX9DIHxG614Wf8qo0](https://viewblock.io/arweave/address/I-5rWUehEv-MjdK9gFw09RxfSLQX9DIHxG614Wf8qo0) - redstone-rapid: [zYqPZuALSPa_f5Agvf8g2JHv94cqMn9aBtnH7GFHbuA](https://viewblock.io/arweave/address/zYqPZuALSPa_f5Agvf8g2JHv94cqMn9aBtnH7GFHbuA) - redstone-stocks: [Yba8IVc_01bFxutKNJAZ7CmTD5AVi2GcWXf1NajPAsc](https://viewblock.io/arweave/address/Yba8IVc_01bFxutKNJAZ7CmTD5AVi2GcWXf1NajPAsc) **Oracles SmartWeave contracts** #### EVM Connectors contracts **1. Core Contracts** - CalldataExtractor.sol - ProxyConnector.sol - RedstoneConsumerBase.sol - RedstoneConsumerNumericBase.sol **1. Core Contracts** - CalldataExtractor.sol - ProxyConnector.sol - RedstoneConsumerBase.sol - RedstoneConsumerNumericBase.sol --> ## Introduction RedStone is an Oracle provider that offers a multitude of data feeds that are available to DeFi protocols across over 30 chains. It currently supports over 1000 assets and aggregates a wide range of data sources, including CEXs, DEXs, and broad market aggregators. The alpha version of the product launched in [January 2022](https://blog.redstone.finance/2022/01/10/introducing-redstone/) to improve inefficiencies in existing oracles, addressing affordable storage, on-demand fetching, and flexible data streams that give custom support for underserved areas of DeFi. RedStone has emphasized supporting Liquid Staking Derivative (LSD) assets with price feed data, allowing them to gain adoption through DeFi integrations. Their [LSTfi Report](https://blog.redstone.finance/2023/11/06/lstfi-report-the-ultimate-q4-2023-market-overview/) makes a note of the $22.4B market for LSDs, the largest DeFi category by TVL. In 2023, RedStone created price feeds for a number of early-stage LSD protocols, including Swell swETH, Stader ETHx, Stakewise osETH, and EtherFi eETH. This has led to integrations with DeFi protocols such as [Sommelier](https://twitter.com/redstone_defi/status/1692574274605793339) and [Gravita](https://x.com/redstone_defi/status/1701913677031727333?s=20). This review evaluates RedStone's architecture and performance as an Oracle provider. We aim to deliver a comprehensive and objective assessment of its suitability to secure user value for the critical application of liquidations processing in DeFi lending markets. Specifically, we aim to form a recommendation about if and how RedStone can be integrated with Prisma to onboard additional collateral types. <!-- RedStone's service offerings, tailored to meet diverse needs within the DeFi space, include the following: The Core model provides dynamic data injection into user transactions, ensuring maximum gas efficiency and an optimal user experience. The Classic model pushes data into on-chain storage via a relayer. It is ideal for protocols that adhere to the traditional Oracle model and require complete control over their data sources and update conditions. Finally, the X model is designed for advanced protocols such as perpetuals, options, and derivatives, eliminating front-running risks by providing immediate post-interaction price feeds. ~~RedStone has supported DeltaPrime since March 2022 and live on mainnets since January 2023. Multiple security experts have audited the code. ~~~~In our review, we will evaluate RedStone's worthiness as an Oracle provider using our internal framework, ensuring a comprehensive and objective assessment of its capabilities and effectiveness in the evolving blockchain ecosystem.~~ ==@Marin: First two paragraphs are good, but in third we need to place in first plan on which blockchain was protocol developed (Arweave, protocol participated in Open Web Foundry incubation program) and point on unique infrastructure components. I will put a few points below that are imo very important when we compare Redstone with other Oracle solutions.== - Redstone Oracle protocol is built on top of the Arweave layer1 chain, as Open Web Foundry incubation program participant - Pre-Seed Funding of $525,000 led by Maven 11 - The Redstone team developed a dedicated Redstone Contracts SDK based on SmartWeave code but rewrote it from scratch because Arweave native smart contracts caused significant performance and reliability issues. RedStone SDK for Arweave smart contracts development is [Warp](https://warp.cc/). - Chainlink websites - market.link and reputation. The link was moved to Dune Analytics because of a problem with storage (too expensive). Redstone Oracle uses Arweave permanent storage for hosting the Archive node (for historical data), and at the moment of writing, 1 GB storage costs $8.5 (one-time payment) - [calculator](https://ar-fees.arweave.dev/). - Streamr Network is a decentralized cache layer combined with Redstone light cache nodes (direct OSS gateways on the scheme). Data is broadcasted on both Streamr Network and by Redstone nodes, and that data is pushed on-chain only if a demand exists for that. In that way, Redstone decreases costs from on-chain interaction (gas fees). --> <!-- ## Oracle Framework ==@temp Oracle Framework: https://hackmd.io/aVxX3IacQ6mJRnJBEoNmHg== Our framework will cover the following scope and sections: * **1. Oracle System Design and Operation**: This section assesses the architectural design of RedStone, including how it operates and its underlying technology. It focuses on how effectively the system meets the needs of dApps and smart contracts. * **2. Data Feeders and Decentralization**: We evaluate the sources of RedStone's data feeds and the extent of decentralization in its data provisioning. This includes looking at the number and diversity of data feeders. * **3. Security**: This part examines the security measures RedStone has in place, including data protection, resistance to attacks, and overall system integrity. * **4. Data Delivery**: Here, we look at how RedStone delivers data to its clients, focusing on speed, reliability, and the methods used for data transmission. * **5. Data Aggregation and Accuracy**: This section is dedicated to analyzing how RedStone aggregates data from different sources, and the accuracy of the data provide * **6. Dispute Resolution and Trustworthines**s: We assess the mechanisms in place for resolving disputes and errors in data feeds, as well as the overall trustworthiness of the system. * **7. Scalability and performance**: This part evaluates RedStone's ability to scale and perform under varying loads and in different blockchain environments. * **8. Economic Model and Cost Efficiency**: Here, we review RedStone's economic model, focusing on its cost-effectiveness for users and overall efficiency. * **9. Usability and Integration**: This section examines how user-friendly RedStone is and how easily it can be integrated with various platforms and applications. * **10. Community Trust and Adoption**: We assess the trust and adoption RedStone has garnered within the blockchain and DeFi community. * **11. Regulatory Compliance and Transparency**: This section looks at how RedStone complies with regulatory requirements and its transparency in operations and governance. --> ## Section 1: Oracle System Design Overview This section provides an overview of RedStone's design and the motivation for those design decisions. It highlights how this provider differs from other Oracle networks and provides an overview of the system components and the data flow process. Finally, it expands on the product offerings relevant to prospective DeFi integrators. - **1.1 Design Goals** - **1.2 Infrastructure Components** - **1.3 Data Flow Process** - **1.4 Integration Options** ### 1.1 Design Goals RedStone aims to improve a range of inefficiencies and constraints of existing Oracle architectures. The main issues that RedStone attempts to address are: - **Affordable Storage:** Historical data is stored on the [Arweave](https://www.arweave.org/) data storage chain, which is designed to store large amounts of data at low cost. - **On-Demand Fetching:** Instead of the Oracle nodes regularly pushing data on-chain, it is broadcasted to the [Streamr network](https://streamr.network/) and/or open source gateways that sign the data, allowing any relayer to push data on-chain. - **Flexible Data Streams:** A modular design allows applications consuming data to customize data delivery to fit their needs. In response to these challenges, RedStone built their oracle solution with modular design to allow greater autonomy and simple Integration. RedStone aims to improve user autonomy and data transmission efficiency, avoiding the need for data providers to continuous post data on-chain. ### 1.2 Infrastructure Components The protocol can be dissected into multiple components. The Redstone Oracle system components include: **Data Sources** Redstone [data sources](https://app.redstone.finance/#/app/sources) include CEXs (e.g., Binance, Coinbase), DEXs (e.g., Uniswap, Curve), and broad market aggregators (e.g., Coingecko, Kaiko). Over 50 data sources are integrated with specific data sources curated to suit individual price feeds. **Redstone Oracle nodes** A set of Oracle nodes perform off-chain data source aggregation, data processing, and signing to a Distributed Data Layer (DDL). Aggregation methodology is configurable, e.g., by median of values, volume-weighted average price (VWAP), or liquidity-weighted average price (LWAP), although RedStone passes the median value by default. The Oracle nodes can theoretically be independent operators, although currently on mainnet, RedStone operates [all 5 Oracle Nodes](https://app.redstone.finance/#/app/data-services/redstone-primary-prod). **Data-Cache Layer** This data availability layer ensures that signed data is packed as meta-transactions without requiring regular price updates to be pushed on-chain. This is handled through an integration with [Streamr Network](https://streamr.network/) and Gateways that are currently operated by the RedStone team but can theoretically be spun up permissionlessly via the open source [cache-service](https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/cache-service). **Data Storage** Because the data cache layer stores data for a short time, a decentralized storage provider is needed to preserve archived data. [Arweave](https://www.arweave.org/) is a blockchain specialized in data storage. Historical price feed data is archived to ensure data provider accountability. **Relayers** Relayers push data on-chain under predefined conditions, such as by a heartbeat or price deviation threshold. The relayer can be configurable per price feed, although on mainnet, RedStone operates whitelisted relayers. The overall architecture is shown below: ![upload_82635c322ba3fc2f0c325831236c48f8](https://hackmd.io/_uploads/SkLo0pWo6.jpg) Source: [RedStone Docs](https://docs.redstone.finance/docs/smart-contract-devs/how-it-works) <!-- A significant aspect of Redstone's approach is utilizing the decentralized Streamr Network, which is pivotal in delivering signed Oracle data directly to end-users. This decentralizes the data distribution and ensures timely and reliable data delivery. Moreover, Redstone capitalizes on the Arweave blockchain's capabilities for cost-effective and permanent storage, which is instrumental in archiving Oracle data and upholding the accountability of data providers. --> ### 1.3 Data Flow Process 1. RedStone supports over 1000 price feeds from over 50 data providers (CEXs, DEXs, Oracles, and Market Data Aggregators). 2. A set of Oracle nodes query multiple API/RPCs and aggregate data using various methodologies like median, TWAP, LWAP, VWAP, etc., and perform security checks with outlier detection. 3. Processed data is then signed by node operators and delivered to the Data Distribution Layer (DDL). Signed data is passed to the decentralized [Streamr network](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/cache-service/src/broadcasters/streamr-broadcaster.ts) and [Redstone light cache nodes](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/cache-service/src/broadcasters/mongo-broadcaster.ts) packed in a message containing various metadata such as timestamp, number of signers, and value per signer. 5. At the time of broadcasting, data feeds represent live data, but with each new broadcast, previous data is archived on [Arweave](https://arweave.org/), a permanent storage network. 6. Live and historical data can be pushed on-chain from the DDL by a dedicated Relayer with a predefined set of conditions (e.g., update frequency, price deviation). This is currently managed by the RedStone team on mainnet, although it is configurable per price feed and can theoretically be managed by liquidation bots or end users. 7. When an application requires the updated value, the RedStone smart contract extracts the signed data with a timestamp, verifies it, and passes it to the target contract. ### 1.4 Integration Options Per the diagram below, data cached in the DDL can be delivered on-chain using one of three models, depending on the user's needs. The three models are called Classic, Core, and X. ![image](https://hackmd.io/_uploads/rympC6ZoT.png) Source: [Redstone Docs- Architecture](https://raw.githubusercontent.com/redstone-finance/redstone-docs/main/static/img/redstone-architecture-simple.png) #### **Core Oracle Model (Pull)** The Core Oracle Model also called the "on-demand fetching model," involves automatically injecting data into user transactions to improve gas efficiency and UX. This model is the most mature method to consume RedStone data that currently secures the most value, according to the RedStone [docs](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-core). <!-- Process of integrating RedStone Oracle Core Model into Smart Contract: **1. Installation (evm connecto from NPM or Yarn)** ``` npm install @redstone-finance/evm-connector ``` ``` yarn add @redstone-finance/evm-connector ``` **2. Smart Contract modification** Import the relevant base contract into the consumer Solidity contract and pass the data feed id converted to bytes32: ``` import "@redstone-finance/evm-connector/contracts/data-services/MainDemoConsumerBase.sol"; Contract YourContractName is MainDemoConsumerBase { ... } ``` ``` bytes32[] memory dataFeedIds = new bytes32[](2); dataFeedIds[0] = bytes32("ETH"); dataFeedIds[1] = bytes32("BTC"); uint256[] memory values = getOracleNumericValuesFromTxMsg(dataFeedIds); uint256 ethPrice = values[0]; uint256 btcPrice = values[1]; ``` Users can override the following functions (customized): - ***isTimestampValid(uint256 receivedTimestamp) returns (bool)*** - custom logic of timestamp validation can be set on shorter delay period (accept most recent price fees) or extend period (on networks with longer block period to avoid rejecting too many txs) - ***aggregateValues(uint256[] memory values) returns (uint256)*** - custom logic of aggregating value from different data providers. This function is median by default, but the user can request that providers be strictly equal while dealing with discrete numbers. - ***getAuthorisedSignerIndex(address _signerAddress) returns (uint256)*** - this function enables whitelist additional signers or remove corrupted ones. - ***getUniqueSignersThreshold() returns (unt256)*** - enable user to modify number of require signers (threshold). There exists a trade-off between security and gas fee cost (more signers means higher security but also higher gas cost) **3. JavaScript Code Modification - Code Object Wrapping** First, we need to import the wrapper code to the project: ``` const { WrapperBuilder } = require("@redstone-finance/evm-connector"); ``` Then, we must wrap the ethers contract, pointing to the selected [RedStone data service id](https://app.redstone.finance/#/app/data-services). It optionally specifies a number of unique signers, data feed identifiers, and URLs for the Redstone Cache Nodes. ``` const yourEthersContract = new ethers.Contract(address, abi, provider); const wrappedContract = WrapperBuilder.wrap(contract).usingDataService( { dataFeeds: ["ETH", "BTC"], }, ); ``` Then, it's possible to access any of the contract methods, like interacting with the ethers-js code: ``` wrappedContract.executeYourMethod(); ``` **4. Testing** For using a wrapper for testing purposes, the Redstone team recommends using a mocking wrapper to set Oracle values and simulate various scenarios. Below is an example of set up mock wrapper using Hardhat: ``` const { SimpleNumericMockWrapper } = require("@redstone-finance/evm-connector/dist/src/wrappers/SimpleMockNumericWrapper"); const wrappedContract = WrapperBuilder.wrap(yourContract).usingSimpleNumericMock({ mockSignersCount: 10, dataPoints: [ { dataFeedId: "ETH", value: 1000 } ], }); await wrappedContract.yourMethod(); ``` <!-- ![Redstone_API_1_50](https://hackmd.io/_uploads/SkZEKiXt6.png) (source: [Redstone Architecture - Simple Flow](https://raw.githubusercontent.com/redstone-finance/redstone-docs/main/static/img/redstone-architecture-simple.png)) --> #### **Classic Oracle Model (Push)** The Redstone Classic model uses a more traditional Oracle design where data is regularly pushed on-chain based on predefined conditions. This may be suitable for protocols that: 1) Don't need to be updated frequently 2) Do not want to modify the codebase, which is required for Core model functionality 3) Run on a chain with low gas fees RedStone Classic is built on top of the Redstone Core model and consists of two main parts: the off-chain relayer and on-chain smart contracts. **Relayer** The [off-chain Relayer](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic#relayer) is responsible for pushing data on-chain in a customized way using [environment variables](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic#environment-variables). The Relayers can theoretically be operated permissionlessly because data is validated on-chain using conditions defined by the protocol stakeholders. In practice, the RedStone team currently manages whitelisted Relayer addresses on mainnet. The layers are designed to work in parallel to avoid a single point of failure. There are two Relayer trigger conditions: a `time` condition (`UPDATE_PRICE_INTERVAL`) and a `value-deviation` condition (`MIN_DEVIATION_PERCENTAGE`). The Relayer update conditions can be found in the Redstone [GitHub](https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/on-chain-relayer/src/core/update-conditions). **PriceFeedsAdapter Contract** The [on-chain Relayer](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic#contracts) stores prices that go through a familiar interface like the [Chainlink Aggregator](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/src/v0.7/interfaces/AggregatorV3Interface.sol)). The on-chain relayer is based on RedstoneAdapterBase.sol contract, used to push RedStone data to blockchain storage repeatedly. Some of the contract's main features are: - Values for data feeds can be updated using the `updateDataFeedsValues` function. - All data feeds must be updated within a single call; partial updates are not allowed (batch updating). - The minimum interval between updates is configurable. - If the protocol wants to be fully compatible with Chainlink Price Feed, additional [PriceFeed contracts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/contracts/price-feeds/PriceFeedBase.sol) need to be deployed. The scheme below shows the data flow for the implementation of the RedStone Classic (Push) Oracle system: ![image](https://hackmd.io/_uploads/Bkkyy0Zja.png) Source: [Redstone Finance documentation - Classic Model](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic) #### **RedStone X** This model was popularised by perpetual protocols such as [GMX](https://gmx.io/#/) to prevent front-running. The user initiates a transaction before knowing the price, mitigating attempts to arbitrage the Oracle. The cost can then be pushed as soon as the next block is undertaken by anyone acting as the Resolver. While the Resolver role is permissionless, RedStone's integration requires a Keeper service that receives requests when the `NewOracleDataRequest` event is triggered, which relays signed data from the Data Distribution Layer. ![image](https://hackmd.io/_uploads/S1MgJRbi6.png) Source: [RedStone Documentation - RedstoneX Oracle model](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-x) <!-- ### 1.5 Economic Model and Cost Efficiency RedStone Oracle is built with economic efficiency in mind. RedStone works with the Arweave blockchain, a highly reliable and low-cost decentralized storage infrastructure, having joined its Open Web Foundry incubation program. Arweave chain's "permanent storage" solution represents an innovation in the decentralized data storage sector because it allows users and developers to store data forever with a one-time payment. On the [Arweave Fees](https://ar-fees.arweave.dev/) website, users can use the "Storage Fee Calculator" to check the current price of permanent storage: ![Arweave fees calculator website](https://hackmd.io/_uploads/SyihxBnFT.png) Source: [Storage Fee Calculator](https://ar-fees.arweave.dev/) Arweave utilizes a unique blockchain-like technology called [Blockweave](https://www.devx.com/terms/blockweave/). Unlike traditional blockchains, where each block contains a reference to the previous block, in Blockweave, each block is linked to both the previous and recall blocks, improving scalability and efficiency. When the RedStone team started building an Oracle solution, the team faced significant performance and reliability issues with Arweave's native smart contracts, SmartWeave. RedStone team created the Warp Contracts SDK, based on SmartWeaves, so [Warp SDK](https://warp.cc/) is optimized for developing a cross-chain oracle protocol. --> ## Section 2: Decentralization and Security This section will dissect the components of the oracle provider's architecture to elucidate any trust assumptions and/or security considerations. The sub-sections start with the data source and progress through each component in the system. The section concludes with an overview of security audits. - **2.1 Data Sources** - **2.2 Oracle Nodes** - **2.3 Data-Cache Layer** - **2.4. Permanent Storage** - **2.5 EVM Connectors** - **2.6 On-chain Relayer** - **2.7 Smart Contract Audits** ### 2.1 Data Sources RedStone collects information from both on-chain and off-chain sources via API and RPC queries. That includes DEXs (Curve pools, Uniswap pools, Balancer pools, etc.), CEXs (Binance, Bitget, Coinbase, OKX, Kraken, etc.), Oracle providers (Chainlink, Band protocol, DIA), Social Graph (Lens) and aggregators (CoinmarketCap, Coingecko, Kaiko. etc.). RedStone has integrated 162 data sources at the time of writing. All available data sources are displayed on the RedStone dashboard with reliability metrics like "Incorrect Price," "Fetching Failed," "Success Rate," and "Stability Reports": ![image](https://hackmd.io/_uploads/Bko-1Rbsa.png) Source: [Redstone App - sources](https://app.redstone.finance/#/app/sources) For example, a report about the Binance data source shows dates and call counts of failed and incorrect data: ![image](https://hackmd.io/_uploads/Byjzy0Zoa.png) Source: [Redstone-app - Binance report](https://app.redstone.finance/#/app/source/binance) <!-- Also, need to mention an additional incentive mechanism for all participants in the Redstone ecosystem - [Profit Sharing Tokens](https://arweave.medium.com/profit-sharing-tokens-a-new-incentivization-mechanism-for-an-open-web-1f2532411d6e) on Arweave. SmartWeaves and Arweave native smart contracts enable developers to monetize their apps and profit from real-world usage with this mechanism. ==@marin: I need to check who can get PST. Do they have some requirements? --> ### 2.2 Oracle Nodes The RedStone nodes play a crucial role in the protocol. RedStone nodes operate based on predefined configurations set by the RedStone team or as independent Oracle nodes with higher customization levels regarding data sources and types. Nodes perform the following tasks: 1. **Data Fetching**: Multiple Oracle nodes fetch data from various external APIs. 2. **Data Processing and Aggregation**: The data is aggregated (typically using a median aggregator) and attested with a cryptographic signature after fetching. 3. **Transmission to DDL**: The signed data is then sent to the Distributed Data Layer (DDL), making it available to end users. Users should be aware that although the [docs](https://docs.redstone.finance/docs/data-providers/running-oracle-node) assist anyone in spinning up their own RedStone node from source code, the only nodes currently securing the network are operated by the RedStone team. RedStone is taking steps to onboard Data Providers in the coming months, reviewing a shortlist of ~15 node operators. Eventually, a crypto-economic security model will involve a native token with staking/slashing, although this upgrade has no clear timeline. <!-- There are 2 options for loading the Manifest in the redstone-node: 1. Loading from JSON file (preferred for local runs and experiments) 2. Loading from SmartWeave contracts --> Data providers can be checked in the RedStone web app under "Data services." This shows what assets are supported (the total number of assets), accessible data sources for a specific asset, the number of nodes, and the time interval between updates. ![image](https://hackmd.io/_uploads/ByyV1RWo6.png) Source: [Redstone WebApp](https://app.redstone.finance/#/app/data-services/redstone-avalanche-prod) #### Off-Chain Aggregation Off-chain data aggregation is an initial aggregation performed by independent node providers. These nodes first collect data from data providers and then aggregate collected data using methodologies like median, Time-Weighted Average Price (TWAP), Last Weighted Average Price (LWAP), or any other custom calculation (i.e., using slippage instead of volume for wstETH price feed). After aggregation and processing, the node operators sign the data, underwriting its quality and integrity. The methodology of the off-chain aggregation employed by the Data Provider is significant to the reliability of the data feed. While the methodology is configurable per data feed, RedStone has a preference to use the median of aggregated quotes, which it uses as the base for its LSD price feeds. The team considers this a conservative approach that favors manipulation resistance (by discarding outliers), over price accuracy, which while attainable from more sophisticated weighting strategies (e.g. VWAP), may become vulnerable to manipulation in some cases. See below an example of RedStone Oracles collecting data from 6 sources and producing a medianized price at each timestamp. ![image](https://hackmd.io/_uploads/B1LBJAZsa.png) Source: [RedStone Blog - Data Aggregation](https://blog.redstone.finance/2022/08/17/what-you-must-know-about-data-agregation-and-its-role-in-blockchain-oracles/) The median strategy requires monitoring to ensure the viability of each data source involved in the aggregation. It may become necessary to exclude or introduce data sources as volumes and liquidity shift, especially with emerging assets, which are a focus for RedStone. For this, RedStone conducts internal real-time monitoring of DEX data sources to check if slippage exceeds safe levels. If triggered, the affected data source will be automatically disconnected from the aggregation until liquidity increases. They are also able to medianize data across multiple blocks to increase the economic costs of price manipulation by extending the window where the price could be arbitraged. The Redstone Oracle node's operational parameters are defined by a Manifest, which includes data sources, update intervals, and validation checks, ensuring accurate and timely data delivery to blockchain networks. The Manifest is a public JSON file defining the provider's obligation regarding the data they provide. In the official RedStone GitHub, it is possible to check various types of Manifests and providers. Data Service Manifests like [main.json](https://github.com/redstone-finance/redstone-node/blob/main/manifests/main.json) and primary.json ([rapid.json](https://github.com/redstone-finance/redstone-node/blob/main/manifests/rapid.json)) are essential for providing aggregated price data from multiple sources and crucial for oracle reliability and accuracy. ### 2.3 Data-Cache Layer The Data-Cache Layer has two broadcasting channels: Streamr Network and custom Gateway network(s). Currently, only the RedStone team has implemented direct Gateways. However, the [Gateway](https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/cache-service) is open source, and over time, there are intended to be more diverse broadcasting channels operated by independent operators. [The Streamr Network](https://streamr.network/) is a decentralized platform designed explicitly for real-time data exchange. It operates as a peer-to-peer network, allowing direct data transmission from producers to consumers without central authority involvement. ![image](https://hackmd.io/_uploads/HJSUyC-jT.png) Source: [DeveloperDAO blog](https://blog.developerdao.com/getting-started-with-streamr) RedStone nodes include a price requester module that fetches signed data from the Streamr Network. This data is then attached to meta-transactions before being submitted on-chain. When a transaction is executed on-chain, it can access the linked data. This process eliminates the need to regularly push data to the blockchain, making it more efficient and cost-effective. Initially, Streamr Nodes were used by RedStone as an additional data broadcasting channel to ensure liveness of the data-cache layer. It does come with trade-offs, namely that a distributed network like Streamr takes longer to propogate than RedStone operated Gateways. Therefore, it is used as a backup, in case RedStone's own Gateways have failed for any reason. The data-cache layer packs the transaction with signed data from various Oracle nodes. The package can be fetched through direct injection of a user transaction (Core model) or by a Relayer (Classic model) and unpacked on-chain. The data-cache layer packs the transaction with the following format: ![image](https://hackmd.io/_uploads/Hyuv1RbjT.png) Source: [RedStone Docs](https://docs.redstone.finance/docs/smart-contract-devs/how-it-works) <!-- ![Streamr-work-flow process](https://hackmd.io/_uploads/rkk_QBb9p.png) Source: [Disk91 - IoT Blog](https://www.disk91.com/2022/technology/blockchain/streamr-network-a-web3-topic-based-publish-subscribe-system/) --> <!-- Redstone's use of the Streamr Network as part of its oracle infrastructure involves several key aspects: **Cost-Efficiency and Scalability**: The partnership between RedStone and Streamr creates a more cost-effective and flexible model for Oracle services. This approach allows builders to fetch data to over 30 chains without incurring high gas fees. RedStone's unique architecture stores data off-chain and validates it on-chain when a transaction is triggered, leading to minimal costs and enabling new data feeds in the blockchain ecosystem. **Storage Layer and Data Compression**: RedStone has built a temporary storage layer of Streamr Nodes data, providing easy access to recent, verified data. Additionally, they have implemented data compression before broadcasting signed data packages to the Streamr Network, which has resulted in reduced packet size and more efficient data flow. **Data Archiving on Arweave Chain**: RedStone is developing solutions to archive data from Streamr Nodes on the Arweave chain. This would allow using historical data in DeFi protocols and improve data provider accountability. --> ### 2.4 Permanent Storage RedStone uses a permanent storage solution as part of its Data Distribution Layer to preserve all historical data and help ensure accountability of the Data Providers. While primarily used for storage, it can also be useful in certain applications that require historical data. [Arweave](https://www.arweave.org/) is a blockchain that offers scalable and performant solutions for immutable and permanent data storage. The core of this functionality is SmartWeave, an Arweave native smart contracts SDK. SmartWeave facilitates the creation of smart contracts on Arweave, allowing for the development of decentralized applications that require immutable data storage. It enables transactions to include an initial state and associated business logic, which defines the rules for updating the state. Subsequent transactions can then reference this initial transaction, proposing new state updates based on the current state and the predefined rules. The approach of SmartWeave leverages lazy evaluation, where the execution of contract logic is deferred until the data is requested. This method shifts the computational load from the network to the clients or users of the smart contracts, enabling more efficient use of network resources. However, this approach often necessitates a centralized caching layer to ensure efficient access to the contract's current state while preserving the decentralized, immutable nature of the data stored on Arweave. [Warp Contracts](https://warp.cc/) is an implementation of the SmartWeave smart contracts protocol, designed to enhance the functionality and efficiency of smart contracts on Arweave. By optimizing the execution and state management of SmartWeave contracts, Warp Contracts aims to reduce the reliance on centralized caching mechanisms, thereby decentralizing the computational load and improving the scalability of applications built on Arweave. <!-- ![Arweave Mining nodes](https://hackmd.io/_uploads/BkH1Djb96.jpg) --> ### 2.5 EVM Connectors The Redstone team's EVM-Connector module implements an alternative design for providing data to smart contracts. Instead of constantly pushing Oracle data on-chain (in EVM storage), information is brought on-chain only when needed—"on-demand fetching." Between "on-demand fetching" events, data is available in the protocol Data-Cache Layer (also called [Flash Storage](https://permaweb.news/redstone-ama/)). Transferring data on-chain requires packing an extra payload off-chain to a user's transaction and processing the message on-chain. The process is described in the scheme below: ![image](https://hackmd.io/_uploads/BkGFyA-ia.png) Source: [Redstone Github](https://github.com/redstone-finance/redstone-evm-connector) ***Data packing (off-chain data encoding)*** - all three steps are executed automatically and transparently by the ContractWrapper: 1. Streamr network and RedStone cache layer (as a backup source) fetch relevant data from Oracle nodes 2. Data is packed into a message according to the [specified structure](https://github.com/redstone-finance/redstone-evm-connector?tab=readme-ov-file#data-packing-off-chain-data-encoding) 3. The package is appended to the original transaction message, signed, and submitted to the network ***Data unpacking (on-chain data verification)*** - all four steps below are executed on-chain by using a low-level assembly code (significant gas cost reduction): 1. The appended data package is extracted from the msg.data 2. The data signature is verified by checking if the signer is one of the approved providers 3. The timestamp is also verified, checking if the information is not obsolete 4. The value that matches a given symbol is extracted from the data package On-chain aggregation and verification occur when this data is brought onto the blockchain, ensuring its validity and preparing it for use by smart contracts and end-users. This mechanism also requires signing a threshold signature from authorized data providers for a given data feed. ![image](https://hackmd.io/_uploads/S1_5y0WoT.png) Source: [RedstoneConsumerBase.sol - Github](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/evm-connector/contracts/core/RedstoneConsumerBase.sol) ### 2.6 On-chain Relayer <!-- The [On-Chain Relayer](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic#relayer) is designed to update on-chain data securely and efficiently. It primarily interacts with blockchain smart contracts to deliver updated data points. --> In the Classic Model, a crucial part of the data delivery is pushing the prices on-chain. According to the RedStone team, they have 4 cascading fallback layers to ensure the continuity of service: - Main Relayers (using multiple redundant RPCs and monitoring current gas level), - Fallback Relayers (similar nodes in a different geo-location), - Gelato automation (using Gelato infrastructure), - Manual Relayers (leveraging the fact that anyone can trustlessly bring signed data packages on chain). In theory, the Relayers service can operate permissionlessly to validate the on-chain requirements set by the protocol stakeholders. In practice, the RedStone team whitelists trusted addresses to perform this function. Additionally, Relayers are designed to function in parallel, and it is advisable to run multiple independent instances to reduce the risks associated with single points of failure and censorship. The Relayer service works in a customizable way based on environment variables from the table below: ![image](https://hackmd.io/_uploads/HkisJ0Wsa.png) Source: [Redstone documentation - env variables](https://docs.redstone.finance/docs/smart-contract-devs/get-started/redstone-classic#environment-variables) #### Relayer Operation - The Relayer is initially set up with installed dependencies, compiled and deployed contracts, and in place has an [env variable configuration](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/.env.example). - The Relayer fetches data packages from the Data Distribution Layer. Scripts like [fetch-data-packages.ts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/src/core/fetch-data-packages.ts) manage this, ensuring data is up-to-date and relevant. - The Relayer performs an update condition and checks before updating on-chain prices. The Relayer checks two conditions: Time-Based Checks ([time-condition.ts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/src/core/update-conditions/time-condition.ts)) and Value Deviation Checks ([check-value-deviation-condition.ts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/src/core/update-conditions/check-value-deviation-condition.ts) and [value-deviation-condition.ts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/src/core/update-conditions/value-deviation-condition.ts)) - The [TxDeliveryManSingleton.ts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/src/core/TxDeliveryManSingleton.ts) script manages the delivery of transactions to the blockchain, ensuring efficient use of resources and gas optimization. - The Relayer operates continuously, as is evident from scripts like [run-relayer.ts](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/src/run-relayer.ts), which manages iterative operations to keep the on-chain data up-to-date. The image below is an example of the Manifest for Ethereum ETHx/ETH Relayer, showing the `updatetriggers` conditions: ![image](https://hackmd.io/_uploads/S1hp1C-jp.png) Source: [Github - Relayer Manifests](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/ethereumEthxeth.json) ### 2.7 Smart Contract Audits |Report | [ABDK Cons - 22nd, November 2022](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/d11790b4f7b5a4a73c74f40d5dab9cee79e7ae4d/packages/evm-connector/audits/abdk-redstone-audit-evm-connector-nov-2022.pdf) | [ABDK Cons- 31st, March 2023](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/8ef89a92cba2ca0c9a36970ab2cc8ddbf99c04f5/packages/eth-contracts/audits/abdk-redstone-eth-contracts-audit-march-2023.pdf) | [AuditOne - 7th, June 2023](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/d11790b4f7b5a4a73c74f40d5dab9cee79e7ae4d/packages/on-chain-relayer/audits/auditone-redstone-adapter-contracts-audit-june-2023.pdf) | [ABDK Consulting - 16st, June 2023](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/d11790b4f7b5a4a73c74f40d5dab9cee79e7ae4d/packages/on-chain-relayer/audits/abdk-redstone-adapter-contracts-audit-june-2023.pdf) | |---| --- | --- | --- | --- | |**Findings**| Auditor found 3 major, ten moderate, and 28 minor issues | Auditor found 2 critical, one major, one moderate and 15 minor issues | Auditor found three medium, three low and seven quality assurance issues (no high issues) | Auditor found two major, six moderate and 18 minor issues | |**Scope**| Redstone evm-connector | Redstone eth-contracts | Redstone on-chain-relayer - Phase I | Redstone on-chain-relayer - Phase II | || CalldataExtractor.sol | LockingRegistry.sol | RedstoneAdapterBase.sol | CallDataExtractor.sol | || ProxyConnector.sol | RedstoneToken.sol | PriceFeedsAdapterBase.sol | PriceFeedBase.sol | || RedstoneConstants.sol | VestingWallet.sol | PriceFeedBase.sol | PriceFeedsAdapterBase.sol | || RedstoneConsumerBase.sol | | PriceFeedsAdapterWithoutRounds.sol | PriceFeedWithRounds.sol | || RedstoneConsumerBytesBase.sol | | | PriceFeedWithoutRounds.sol | || RedstoneConsumerNumericBase.sol | | | PriceFeedsAdapterWithRounds.sol | || RedstoneDefaultsLib.sol | | | PriceFeedsAdapterWithoutRounds.sol | || | | | RedstoneAdapterBase.sol | || | | | SinglePriceFeedAdaper.sol | <!-- ## Section 5: Redstone Products - [Custom URL](https://docs.redstone.finance/docs/smart-contract-devs/custom-urls) - Custom URL Oracles are shut down ![Custom URL - shut down](https://hackmd.io/_uploads/rJAURdnYT.png) - NFT Data Feeds - NFT data feeds at the moment dont exist - Randomness --> <!-- ## Redstone's Modular Design: Flexibility and Scalability Sources for section: [Link1](https://medium.com/@adnantaher911/redstones-modular-design-a-key-to-flexibility-and-scalability-41b382173a98), Link2 ==@marin: do we need this? Or can I explain that in the section below?== --> ## Section 3: Adoption This section will review the level of DeFi adoption achieved by RedStone to date, with particular focus on its support for liquid staking derivatives. The section is divided into 3 sub-sections that review the unique LSD price feeds available, adoption of RedStone compared with other Oracle providers, and specific DeFi integrations. - **3.1: LSD Price Feed Support** - **3.2 Oracles Comparison** - **3.3 DeFi Integrations** ### 3.1: LSD Price Feed Support Below is an overview of the ETH Liquid Staking Derivatives with a RedStone Oracle price feed. For a complete list of the RedStone data feeds, see the [Price Feed docs](https://docs.redstone.finance/docs/smart-contract-devs/price-feeds). **Swell swETH** [PriceFeedSwellSwetheth.sol](https://etherscan.io/address/0x37963f10245e7c3a10c0e9d43a6e617b4bc8440a#code) [Announcement](https://blog.redstone.finance/2023/06/22/case-study-redstone-oracles-provides-sweth-feed-for-swell-network/) Manifest: [swell.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/swell.json) The swETH feed ingests data from the following sources: 1) Balancer: SwETH/Boosted Aave V3 WETH (0x02d928e68d8f10c0358566152677db51e1e2dc8c) 2) Uniswap V3: UniV3 ETH/swETH pool (0x30ea22c879628514f1494d4bbfef79d21a6b49a2) 3) Maverick: Maverick ETH-swETH pool (0x0ce176e1b11a8f88a4ba2535de80e81f88592bad) RedStone implemented a liquidity monitoring service to rearrange pools in case of liquidity migration. **StakeWise osETH** [MergedAdapterWithoutRoundsOsethethV1.sol](https://etherscan.io/address/0x6e63484daacd224c447b7e2913eaaf659c7bb8b7#code) [MergedAdapterWithoutRoundsOsethethV2.sol](https://etherscan.io/address/0xbf7d92afdf01c8370e0b164338fdef105a7c8dbb#code) [Announcement](https://blog.redstone.finance/2024/01/05/case-study-stakewise-integrates-redstone-oracles-to-bring-oseth-to-defi/) Manifest: [ethereumStakewiseOsetheth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/ethereumStakewiseOsetheth.json) The osETH feed ingests data from the following sources: 1) Balancer: osETH-WETH 2) Uniswap V3: osETH-USDC 3) Curve: osETH-rETH RedStone implemented a liquidity monitoring service to rearrange pools in case of liquidity migration. **Stader ETHx** [PriceFeedStaderEthxEthxWithRounds.sol](https://etherscan.io/address/0x5a74cef7f818f556732a61c7aa6bad1502f2e9fa#code) [PriceFeedsAdapterStaderEthxWithRounds.sol](https://etherscan.io/address/0x41fded6845d19c7236d2c3fb53fe5bcd503542ad#code) [Announcement](https://twitter.com/redstone_defi/status/1702698921984962623?s=20) Manifest: [ethereumEthxeth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/ethereumEthxeth.json) The osETH feed ingests data from the following sources: 1) Balancer 2) Curve Finance 3) PancakeSwap 4) Wombat Exchange **Etherfi weETH** [MergedAdapterWithRoundsWeethV1.sol](https://etherscan.io/address/0x0c2c7ded01ccdfab16f04aff82af766b23d6be0a#code) [Announcement](https://twitter.com/redstone_defi/status/1737503311941812232?s=20) Manifest: [ethereumEtherfiWeeth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/ethereumEtherfiWeeth.json) and [ethereumEtherfiWeetheth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/ethereumEtherfiWeetheth.json) The osETH feed ingests data from the following sources: 1) Balancer 2) Curve Finance 3) Maverick ### 3.2 Oracles Comparison According to data from [DefiLlama](https://defillama.com/oracles) in late January, RedStone is a minor player in the price feed oracle market, ranking 13 in terms of Total Value Secured (TVS). The TVS calculation includes the value of tokens borrowed in lending applications. While DeFiLlama conveniently displays data about oracle provider usage in DeFi, it should be noted that it does not present a complete picture of all RedStone integrations, as DeFiLlama requires an oracle provider to secure 50% of the protocol TVL to be listed as an integration. In reality, the majority of the protocols have their TVL accumulated in one or two markets i.e. ETH or stETH. For example, in Gravita, RedStone feeds are used for weETH, swETH, osETH, ETHx ([~36% of the market](https://github.com/DefiLlama/defillama-server/pull/5430)) and Chainlink feeds for WETH, wstETH, and rETH, although the full TVL is assigned only to Chainlink. ![image](https://hackmd.io/_uploads/rk9kgAbsp.png) Source: [DefiLlama Oracles](https://defillama.com/oracles) | Date: 1/26/2024 Compared with the most prominent Oracle providers, RedStone appears to have been a historically minor market participant with a shorter history of securing value. The industry leader, Chainlink, has a history of securing value in DeFi since May 2019, while RedStone began securing value in January 2023. ![image](https://hackmd.io/_uploads/r12xgAWsa.png) Source: [DefiLlama Oracles](https://defillama.com/oracles) | Date: 1/26/2024 ### 3.3 DeFi Integrations This section will first review the DeFi integrations shown on DeFiLlama, which require RedStone to secure >50% of the protocol TVL to be listed. Afterwards we will cover additional protocol integrations where RedStone secures some assets making up a minority of protocol TVL. Finally, we will make mention of upcoming integrations. #### DeFiLlama Oracle Dashboard Upon review of [DefiLlama data](https://defillama.com/oracles), which shares the integrations in which RedStone dominates, RedStone provides price feed data to 14 protocols. The Total Value Secured (TVS) by RedStone services is ~$102.5 million as of mid-January 2024. When looking at a breakdown of the protocols using RedStone, we observe that a number of the protocols are deprecated for a variety of reasons or otherwise have negligible TVL. Four of the 14 protocols are active with a TVL that is reasonably substantial (>$10m). ![image](https://hackmd.io/_uploads/S1Jzl0bsa.png) Source: [DefiLlama Oracles](https://defillama.com/oracles/RedStone) **CIAN** [Integration Announcement](https://blog.redstone.finance/2023/07/12/case-study-cian-integrates-redstone-oracles-to-revolutionize-algorithmic-strategic-vaults-and-decentralized-automation-tools/) - July 12, 2023 CIAN is an automation platform that can be used to create delta-neutral strategies, with particular emphasis on LSDs, liquid restaking tokens, and Real-World assets. Strategies involve leveraged exposure to yield-bearing assets with built-in liquidation protection. It has deployed on Ethereum, Avalanche, Polygon, Optimism, Arbitrum, and BSC. CIAN integrated RedStone price feeds to monitor user collateral ratios and provide liquidation protection. RedStone's Core Model was chosen as a low-latency and efficient solution since gas fees are only charged when data is needed. **Angle** [Integration Announcement](https://blog.redstone.finance/2023/08/10/redstones-seamless-integration-with-angle-the-rise-of-real-world-assets-rwas-in-defi/) - August 10, 2023 Angle is an over-collateralized stablecoin protocol with a unique strategy of rehypothecating stablecoin collateral into various third-party applications to improve capital efficiency. The protocol experienced a crisis in March 2023 when the Euler lending protocol, containing many Angle protocol funds, was hacked. A migration to Angle V2 occurred several months later, in August 2023. Angle integrated a RedStone price feed for a short-term Euro treasury bond tokenized by Backed (bC3M) which allows users, through the transmuter module, to mint and burn its native stablecoin agEUR from bC3M at the oracle price. As of January 26, bC3M makes up €8m in collateral with €6.236m agEUR minted against it (26.8% of the 23.25m outstanding agEUR). There is a [second oracle](https://etherscan.io/address/0x83Ec02059F686E747392A22ddfED7833bA0d7cE3) managed by Backed which is required to be within reasonable bounds of the Redstone price. Otherwise, transactions will revert. ![image](https://hackmd.io/_uploads/rykmlC-sa.png) Source: [Angle Analytics](https://analytics.angle.money/ageur) **DeltaPrime** [Integration Announcement 1](https://blog.redstone.finance/2022/11/29/deltaprime-x-redstone-novel-defi-needs-novel-oracles/) - November 29, 2022 [Integration Announcement 2](https://blog.redstone.finance/2023/06/19/case-study-deltaprime-x-redstone-oracles-months-of-successful-cooperation/) - June 19, 2023 DeltaPrime is a lending protocol that allows up to 5x leverage by creating personal brokerage smart contract accounts. The protocol is native to Avalanche and has also been deployed on Arbitrum. It offers various collateral types, including crypto blue-chips, stablecoins, staking derivatives, and governance tokens. DeltaPrime integrated RedStone price feeds as its exclusive oracle provider because it was the only provider allowing feeds for derivative tokens and offered a low-latency solution. It combined the Core Model to process liquidations, which only pushes data on-chain when needed. The Integration involves support for ~40 tokens with a 10s latency guarantee. **Yield Yak** [Integration Announcement](https://blog.redstone.finance/2023/05/12/redstone-x-yield-yak-a-new-era-of-defi-with-real-time-token-valuations/) - May 12, 2023 Yield Yak is a yield aggregator that accepts a deposit token that it deploys to various yield-earning strategies. The protocol is native to Avalanche and has also been deployed on Arbitrum. The Integration with Yield Yak is through DeltaPrime to allow leverage on autocompounding Yield Yak deposits. Users can gain access to leverage through the DeltaPrime [leverage farms](https://app.deltaprime.io/#/prime-account/farms), including the AVAX strategy on AAVE, GLP strategy on GMX, AVAX-USDC on Pangolin, AVAX-ETH from Pangolin, AVAX-USDC from TraderJoe, or AVAX-ETH from TraderJoe. RedStone calculates the collateral ratio of the leveraged farm position and processes liquidation when necessary. **Conclusion** Most of the primary RedStone integrations involve leveraged yield and trading strategies, emphasizing Avalanche-based applications. In some cases, RedStone is employed as a liquidation protection mechanism (CIAN), and in others, it is used to process timely liquidation (DeltaPrime/Yield Yak). One protocol uses RedStone to mint and redeem a stablecoin (Angle) as one of several Oracle providers used within the protocol. Angle is also the most notable protocol that uses RedStone price data on the Ethereum mainnet. #### Additional RedStone Integrations The following list includes minor integrations that are not credited in DeFiLlama's curated oracle integrations list because RedStone does not secure >50% of the protocol TVL. Many of the integrations revolve around RedStone's support for emerging LSD assets, other assets that have limited price feeds available, and combined with other oracle providers for improved resiliency. 1. [Sommelier](https://defillama.com/protocol/sommelier) utilizes RedStone’s weETH, ETHx, and swETH feeds for in its yield strategies. 2. [Enzyme](https://defillama.com/protocol/enzyme-finance) utilizes RedStone's swETH and ETHx feeds for its yield strategies. 3. [Gravita](https://defillama.com/protocol/gravita-protocol) utilizes RedStone's swETH, weETH, and osETH feeds to secure collateral for its GRAI stablecoin. 4. [Mento](https://defillama.com/protocol/mento) uses RedStone as the main Oracle in the [SortedOracles](https://twitter.com/MentoLabs/status/1747559367350661518) module. 5. [Silo](https://defillama.com/protocol/silo-finance) utilizes RedStone's weETH feed for the [weETH, ETH, XAI Market](https://app.silo.finance/silo/0xCD7ae3373F7e76A817238261b8303FA17D2AF585) to secure collateral and will soon use the agEUR feed on Arbitrum. 6. [Term Finance](https://defillama.com/protocol/termfinance) utilizes [RedStone's weETH feed](https://twitter.com/redstone_defi/status/1748012557095620702) to secure it as collateral on its lending platform. 7. [Gearbox](https://defillama.com/protocol/gearbox) uses a multitude of [RedStone pricefeeds](https://github.com/Gearbox-protocol/oracles-v3/blob/c6e4bd0a42331daeec599f3d8a688fab79f9879a/contracts/oracles/updatable/RedstonePriceFeed.sol) in addition to other oracle providers to secure collateral assets. 8. [Venus](https://defillama.com/protocol/venus) incorporates RedStone feeds in its "[Resilient Price Oracle](https://docs-v4.venus.io/risk/resilient-price-oracle)" design that uses Chainlink, RedStone, Pyth, TWAP, and Binance Oracle in a series of fallback mechanisms for securing collateral. 9. [Abracadabra](https://defillama.com/protocol/abracadabra) uses RedStone feeds in its Kava markets (MIM/USDT Curve LP and Tether USDT-LP cauldrons) to secure collateral. 10. A [Morpho Blue vault](https://app.morpho.org/vault?vault=0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0) launched by Re7 uses RedStone's LST feeds to secure the underlying collateral assets. #### Upcoming RedStone Integrations The RedStone team has shared information about upcoming integrations, planned as of February 1, 2024. 1. [LayerBank](https://defillama.com/protocol/layerbank)- In the first week of February they plan to switch from their own Oracles to RedStone as the only Oracle provider. 2. [ZeroLend](https://defillama.com/protocol/zerolend)- In the first week of February they plan to switch to RedStone as the only Oracle provider on Manta. 3. [Shoebill](https://defillama.com/protocol/shoebill-finance)- In the first week of February they plan to switch to RedStone as the only Oracle provider on Manta. 4. [Radiant](https://defillama.com/protocol/radiant)- They will use RedStone feeds for LSTs and other assets in their upcoming v3 launch. 5. Fluid (by [Instadapp](https://defillama.com/protocol/instadapp))- A new lending primitive by Instadapp similar to Morpho Blue. They’ll launch open access in February that plans to utilize RedStone feeds. 6. [Pendle](https://defillama.com/protocol/pendle)- They plan to launch the wstETH market on Mantle L2 with the [RedStone feed](https://explorer.mantle.xyz/address/0xE8d850331faAbb277a24C09d91aabb68fb808748/contracts?contract-tab=read-proxy#address-tabs) and evaluate an expanded cooperation. 7. [Spark](https://defillama.com/protocol/spark)- They’re working 10 add RedStone to their oracles interface in Q1. 8. [Synthetix](https://defillama.com/protocol/synthetix)- They’re finanlizing addition of RedStone to their [ERC-7412](https://erc7412.vercel.app/) Oracle module, which should be ready in February. 9. [Seamless](https://defillama.com/protocol/seamless-protocol)- They’ll use RedStone for the upcoming markets i.e. tBTC. 10. [Curvance](https://twitter.com/curvance) (pre-launch)- They’ll use RedStone in the [Oracle module](https://docs.curvance.com/cve/summary/protocol-overview/money-market/oracles). 11. [Conic](https://defillama.com/protocol/conic-finance) V2- The team intends to use RedStone in their upcoming V2 release. 12. [eBTC](https://twitter.com/eBTCprotocol) (pre-launch, by [BadgerDAO](https://defillama.com/protocol/badger-dao))- They’ll use RedStone’s stETH feed in addition to Chainlink’s. 13. [Liquity](https://defillama.com/protocol/liquity)- They shortlisted RedStone together with Chainlink for their multi-oracle V2 setup. 14. [Lybra](https://defillama.com/protocol/lybra-finance)- RedStone’s ETHx price feed passed Halborn’s audit, currently in discussion of integration. <!-- Redstone implementation table: | Protocol | Integration materialized | Protocol Category / Integration Type / | | | | --- | --- | --- | --- | --- | | CIAN | | Core model implementation, CIAN is a yield aggregator focused on LSDs/LSTs | | | | Angle | | [Snapshot Proposal](https://snapshot.org/#/anglegovernance.eth/proposal/0xe28409f40125f1ed44dfdf5071c2f0baa90844c6926e214eca3b3f0f61bf5e84) - create Price Feed for agEUR on Arbitrum | [arbitrumAngleAgeur.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/arbitrumAngleAgeur.json), [angle.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/angle.json) | [Integrated contract - Etherscan]([https:/](https://etherscan.io/address/0xe84823246a76820203f2b4bb8d9bc0e3df45bd77#code)/) | | Delta Prime | from March 2022 to January 2023 | | | | | Yield Yak Agg | | | | | | Premia V3 | | [PREMIA](https://app.redstone.finance/#/app/token/PREMIA) and [PREMIA-TWAP-60 Price Feeds](https://app.redstone.finance/#/app/token/PREMIA-TWAP-60) | [arbitrumPremia.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/arbitrumPremia.json) | | | Yield Yak Staked AVAX | | | | | <!-- | Abracadabra | | | [abracadabraKavaBtc.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/abracadabraKavaBtc.json), [abracadabraKavaEth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/abracadabraKavaEth.json), [abracadabraKavaUsdt.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/abracadabraKavaUsdt.json) | | | Vesta Finance | | | | | | Voltz | | | | | | Raft | | Exploited | | | | Float | | Tokenized | | | | Loanshark Core | | | | | | LaDAO Xocolati | | | | | | Arcanum protocol| | Decentralized ETF protocol, in their docs use description of Redstone mechanism but call that Arcanum Oracle (white label?) | | | | Stader | | | [staderEthx.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/staderEthx.json), [ethereumEthxeth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/ethereumEthxeth.json) | | | Swell | | | [swell.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/arbitrumSwellSweth.json, https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/swell.json) | | | | | | | | | | | | | | | Mantle | | | | | | Manta Pacific L2 | Middle January, 2024. | [Push oracle for Manta Pacific](https://blog.redstone.finance/2024/01/19/redstone-becomes-official-push-oracle-for-manta-pacific-l2/, https://app.redstone.finance/#/app/token/MANTA) , https://app.redstone.finance/#/app/token/MANTA - Pull and Push models (8 CEX sources) | | https://pacific-explorer.manta.network/address/0x2e441aDC345dAeB11Ff9c2caE7eFD461E5525850 | | Stakewise | | | | | | TON | | [Push Oracle Model](https://github.com/redstone-finance/redstone-oracles-monorepo/tree/main/packages/ton-connector/contracts#-ton-redstone-payload-packing) (from byte-array to tree-like), [Feed for $MANTA token] (https://blog.redstone.finance/2024/01/11/redstone-oracles-enabling-defi-on-ton-blockchain/(?)) - Pull and Push models (8 CEX sources) | | [Integrated Contract](https://testnet.tonviewer.com/EQCMxfukwpP3BI_6Pn3lmOXgxlp3dPabVGOM0UvJCjsDhkdD) | | Canto | 18-08-2023 | | [cadenceCantoAtom.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/cadenceCantoAtom.json), [cadenceCantoCanto.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/cadenceCantoCanto.json), [cadenceCantoEth.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/cadenceCantoEth.json), [cadenceCantoUsdc.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/cadenceCantoUsdc.json), [cadenceCantoUsdt.json](https://github.com/redstone-finance/redstone-oracles-monorepo/blob/main/packages/on-chain-relayer/relayer-manifests/cadenceCantoUsdt.json) | [Integrated contract](https://evm.explorer.canto.io/address/0xf16dA7ABcac966B3ba9c1DFa17D8A9626237bcf8) - testnet | --> <!-- | Blockchain Oracle provider | Protocols Secured | TVS | | --- | --- | --- | | Chainlink | 346 | $19.116b | | | | Staking (Community Members and NOs) | | | Redstone | 14 | $107.8m | | | | NO | | | Pyth | 141 | $1.97b | | | | | | | Band Protocol | 21 | $42.15m | | | | | | | DIA DAO | 22 | $29.13m | | | | | | | SupraOracle | 6 | $96.88m | | | | NO | | | API3 | 8 | $17.84m | | | | | | --> ## Section 4: Regulatory Compliance and Transparency This section reviews any relevant regulatory considerations regarding Oracle services generally and contractual obligations specifically offered by RedStone. Finally, it reviews plans for an arbitration process that aims to ensure data integrity and user assurances. - 4.1 International Policy Recommendations - 4.2 Contractual Obligations - 4.3 On-chain Arbitration ### 4.1 International Policy Recommendations ### **Financial Stability Board** In their seminal research paper, "The Financial Stability Risks of Decentralised Finance," the Financial Stability Board (FSB) sheds light on the pivotal role of oracles in the DeFi ecosystem. According to the FSB, an oracle is *"a service that enables smart contracts to access, in real-time, relevant external or off-chain data using queries typically through crypto-asset exchange application programming interfaces and which provides inputs to smart contracts"*. The oracles' fundamental role in DeFi is recognized by reference to their function, i.e., smart contracts to access external ("off-chain"), real-world data. While oracles are indispensable, they also introduce a layer of risk, referred to in the paper as "oracle risk." This risk arises when an oracle fails to function as expected or is compromised. The implications of such failures can be far-reaching. For instance, erroneous data inputs from an oracle can trigger adverse actions in a DeFi protocol, like unwarranted liquidations, leading to cascading effects across interconnected protocols. In the next place, oracles are seen as market manipulation targets. This vulnerability is particularly acute when a dominant protocol heavily relies on a single oracle or when multiple protocols depend on the same oracle source. An oracle's failure or manipulation could catalyze a systemic shock within the DeFi ecosystem in such scenarios. Although the FSB's analysis acknowledges oracle risk, it stops short of proposing specific regulations for oracle activities. **International Organization of Securities Commissions** Another international standard-setting body, the International Organization of Securities Commissions (IOSCO), wields significant influence over policy recommendations in the DeFi sector. IOSCO has provided guidelines suggesting that national regulators thoroughly assess the operational and technological risks associated with DeFi products and services. One of the key recommendations is that regulators should require the Responsible Person(s) of DeFi products that rely on oracles to actively identify, manage, and mitigate the risks posed by such technologies. In some regions, regulators may opt for more stringent measures, including stricter oversight and compliance requirements for DeFi entities using oracles. Interestingly, while IOSCO emphasizes the need to identify and address material risks, including those associated with oracles, it does not explicitly mandate introducing a regulatory regime specifically for oracles. This suggests a measured approach, focusing on understanding and managing the risks rather than imposing prescriptive regulatory frameworks. **MiCA** Recital 93 of MiCA offers a crucial distinction between Crypto-Asset Service Providers (CASPs) engaged in transfer services as a regulated activity and other entities like validators, nodes, or miners involved in confirming transactions and updating the state of the underlying distributed ledger. Oracles are primarily recognized as suppliers of external data, such as asset prices, and do not participate in confirming transactions on the blockchain. Their role does not extend to updating the blockchain state; instead, they are commissioned to deliver specific external information. In essence, oracles act as third-party services enabling smart contracts to access necessary data, whether on-chain or off-chain, which then becomes an input for the smart contract's functionality (*"Systemic Implications and Policy Options by ESRB Task Force"*). MiCA exempts parties with core technical functions, such as nodes and validators, from its regulatory scope. The exemption provides a basis to assert that oracles, given their clearly defined role as external data suppliers, do not fall within the ambit of MiCA regulation. This interpretation aligns with MiCA's focus on regulating activities more directly involved in asset transfer and management rather than entities that provide ancillary services to the DeFi ecosystem. ### 4.2 Contractual Obligations ### **A) Client Relations** By entering into a Services Agreement with clients, RedStone commits to integrating various Oracle systems and establishing a contractual framework defining the scope and quality of the services provided. RedStone is contractually obligated to perform its services with great diligence and professionalism. The Agreement grants RedStone the right to engage third parties or contractors to assist in providing services. A pivotal aspect of RedStone's contractual obligations is the assurance of a specified Service Level Agreement. SLA defines the expected performance performance and reliability levels of the Oracle feeds or services provided. **B) Business Relations** When onboarding Data Providers, RedStone considers only those entities with whom they have maintained a relationship for at least six months. Providers with narrow specialization in data delivery, aligning with their commitment to quality and reliability, are prioritized. These Data Providers must deliver price feeds per the terms of the contract concluded between the RedStone Association (domiciled in Switzerland) and their respective entity(ies). In return for their services, Data Providers receive RedStone tokens, which are accounted for and distributed monthly, contingent upon adherence to the contract's stipulations. The primary responsibility of Data Providers is to deploy and consistently maintain Data Provision nodes. They retain the right to terminate the service provision. However, this decision must be communicated with at least a two-month notice period, providing sufficient time for RedStone to make necessary adjustments. If Data Providers fail to deliver the agreed-upon service, they are obligated to reimburse the affected party. The compensation is calculated based on the extent of the damage incurred due to the service lapse. It is important to note that the summary of the rights and obligations of Data Providers is based on specific details provided by RedStone. Due to confidentiality reasons, the actual contract has not been reviewed in this context. ### 4.3 On-chain Arbitration ### RedStone's roadmap involves plans to address the need to resolve disputes related to data accuracy through a novel approach: on-chain arbitration on ARgue. This decentralized dispute resolution protocol will allow users to claim refunds in the event of the submission of faulty data, with disputes being adjudicated by decentralized juries. The dispute process within ARgue is multi-staged, involving several vital actors and a systematic approach. ![image](https://hackmd.io/_uploads/Hyh4eCbja.png) Source: [ARgue Architecture](https://https://github.com/redstone-finance/redstone-node/blob/main/docs/DISPUTE_RESOLUTION.md) **Pre-Dispute Phase:** Data providers post collateral as RedStone tokens to signal their commitment to data quality. The collateral amount affects the dispute opening fee and the potential reward for challengers. **Opening a Dispute:** Any party can initiate a dispute by depositing a stake proportional to the provider's collateral, with a minimum value to deter spam. **Voting Process:** Jurors stake tokens to vote for or against the dispute within a limited period, influenced by their voting capacity. **Verdict and Appeal:** A verdict is reached when a quorum is met. Parties dissatisfied with the verdict can appeal by doubling the challenge fee, leading to a new voting round with a higher quorum requirement. **Settlement:** The final verdict triggers the distribution of rewards, funded by the losing side's stake. Jurors voting with the majority gain a portion of the opposing side's stake and enhance their voting capacity. RedStone plans to implement a random-based selection process for jurors to ensure fairness and prevent front-running in high-stake disputes. No on-chain arbitration has been conducted, primarily because the RedStone token is not yet live. The final version of the arbitration protocol will undergo thorough consultation and auditing before deployment. Therefore, the implementation details may be subject to change. ## Recommendation After reviewing the RedStone protocol design, implementation, development roadmap, historical adoption, and user assurances, we propose a solution involving a compromise that limits the risk to the mkUSD peg while enabling growth potential by onboarding newly emerging LSD protocols. We recommend exercising caution in onboarding additional oracle providers directly to Prisma and to take a multi-step approach that begins by creating markets on third-party lending protocols that leverage RedStone price feeds. After a period of time monitoring Oracle performance, data can be used for evaluating RedStone and potentially onboard it as an Oracle provider directly to Prisma. We have been in talks with Morpho Blue to create a lending market aggregator for Prisma that pairs long-tail ETH LSDs against mkUSD, based entirely on RedStone price feeds. These LSD assets likely do not qualify for onboarding to Prisma directly because of, for example, their short history and lower liquidity. They may, however, benefit from inclusion in a lending market that supports their adoption, which also provides a pathway for well-performing assets to eventually be onboarded directly to Prisma. RedStone already has price feeds available for these emerging assets and has signaled a priority to emphasize support for the LSD market. Example pairings below: ![image](https://hackmd.io/_uploads/SkTre0Wia.png) Support for these assets involves greater risk and diligence to prevent market manipulation, given that they generally have considerably lower liquidity and limited trading venues than mainstream competitors. Third-party lending platforms such as Morpho may be better equipped to manage market demand for additional risk with a dynamic interest rate model. This solution also allows Prisma to observe the performance of RedStone over time and revisit the possibility of onboarding RedStone directly to Prisma in the future. There are essential upgrades in development, including a crypto-economic arbitration model involving a native RedStone token and the onboarding of independent node operators. RedStone is designed modularly with a pathway to become a genuinely decentralized oracle provider, although developments should be monitored as RedStone secures Prisma's third-party lending markets. Building a substantial history connecting value for Prisma and observing TVLs grow over time will be essential in establishing trust that RedStone can be onboarded as an oracle provider directly for Prisma vaults. <!-- ___ ## Resources: - https://docs.redstone.finance/docs/introduction - https://blog.redstone.finance/ - [Unlocking DeFi Potential: A Comprehensive Guide to RedStone Oracles](https://mirror.xyz/0x94ecbf66A6A6C5DE264120cF5DD7E35F21d4c70c/vu4LQfP2yyO6L1_aaJ_yZqe_6qyQOpjuOx-GvHbTW5Y) - [Redstone Oracle: Mapping DeFi's Constellations of Innovation!](https://mirror.xyz/0x94ecbf66A6A6C5DE264120cF5DD7E35F21d4c70c/dyyaTOCt8piQSzxFjkDlQbQoEHeoTRuK3SbHLDY_CmE) - https://devpost.com/software/redstone-oracles-on-near-and-1k-available-synths-on-near - https://governance.aave.com/t/redstone-oracles-to-launch-gho-price-feed/13670 - https://api.docs.redstone.finance/ - https://app.redstone.finance/#/app/data-services - https://docs.redstone.finance/docs/smart-contract-devs/custom-urls - https://cryptoslate.com/demystifying-blockchain-oracles-part-1/ - https://cryptoslate.com/demystifying-blockchain-oracles-part-2/ - https://cryptoslate.com/demystifying-blockchain-oracles-part-3/ - https://lochanachamikaraphillip.medium.com/redstone-oracle-3b53232072ca - https://www.alphalab.capital/decentralised-oracle-market-landscape/ - https://20755222.fs1.hubspotusercontent-na1.net/hubfs/20755222/guides/the-ultimate-guide-to-blockchain-oracle-security.pdf - [Case Study: StakeWise Integrates RedStone Oracles to Bring $osETH to DeFi](https://blog.redstone.finance/2024/01/05/case-study-stakewise-integrates-redstone-oracles-to-bring-oseth-to-defi/) - https://chaoslabs.xyz/posts/role-of-oracle-security-in-defi-derivatives-with-gmx-and-chainlink - https://blockchainoraclesummit.io/ - https://medium.com/@nfett/on-oracle-extractable-value-f6c7a0d64af5 - https://medium.com/@frontx25/using-redstone-oracle-in-your-dapps-core-model-96f9229a6791 - https://github.com/gelatodigital/gelato-raas-redstone-deployment?tab=readme-ov-file - https://zenofchain.gitbook.io/redstone-quick-guide/guide ==collecting RSG points, I assume farming token== - https://price-oracle.notion.site/Oracle-Manipulation-101-cbcea67b7796496995437907d3b1b4ba - [Silo Finance - Oracle Rating System (for Silo markets) and set of oracles Silo use](https://silopedia.silo.finance/risks/oracles) - https://chaoslabs.xyz/posts/chaos-labs-uniswap-v3-twap-market-risk - [Dispute Models in Blockchain Oracles](https://blockchain-academy.hs-mittweida.de/courses/blockchain-introduction-technical-beginner-to-intermediate/lessons/lesson-24-blockchain-oracles/topic/dispute-models-in-blockchain-oracles/) - [Computation metric](https://blog.chain.link/computation-complexity-metrics/) - https://medium.com/@yoakin460/redstone-a-decentralized-oracle-solution-for-blockchain-c98b4c0ad7fa - [Redstone Finance - About Data Aggregation and its role in blockchain oracles](https://medium.com/@RedStone_Finance/what-you-must-know-about-data-agregation-and-its-role-in-blockchain-oracles-d0c1b43e685e) -->