{"id":28470539,"url":"https://github.com/magicblock-labs/real-time-pricing-oracle","last_synced_at":"2025-07-01T17:30:53.852Z","repository":{"id":272254951,"uuid":"915222988","full_name":"magicblock-labs/real-time-pricing-oracle","owner":"magicblock-labs","description":"Low latency pricing oracle for ephemeral rollups","archived":false,"fork":false,"pushed_at":"2025-06-22T00:39:31.000Z","size":274,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-22T01:30:59.690Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magicblock-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-11T09:35:29.000Z","updated_at":"2025-06-22T00:39:35.000Z","dependencies_parsed_at":"2025-01-13T09:36:13.845Z","dependency_job_id":"e974fcc1-c28c-4ed2-9caf-5325f76cb46f","html_url":"https://github.com/magicblock-labs/real-time-pricing-oracle","commit_stats":null,"previous_names":["magicblock-labs/ephemeral-pricing-oracle","magicblock-labs/real-time-pricing-oracle"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/magicblock-labs/real-time-pricing-oracle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2Freal-time-pricing-oracle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2Freal-time-pricing-oracle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2Freal-time-pricing-oracle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2Freal-time-pricing-oracle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magicblock-labs","download_url":"https://codeload.github.com/magicblock-labs/real-time-pricing-oracle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magicblock-labs%2Freal-time-pricing-oracle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263007050,"owners_count":23398753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-07T09:31:00.548Z","updated_at":"2025-07-01T17:30:53.834Z","avatar_url":"https://github.com/magicblock-labs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real-time Pricing Oracle\n\nThis repository contains a Solana program designed to inject price feeds into ephemeral rollups. It includes a chain pusher that subscribes to and posts price updates on-chain, as well as an example of how to consume price data in a Solana program.\n\nCurrently supports:\n- [Pyth Lazer](https://docs.pyth.network/lazer)\n- [Stork price feeds](https://www.stork.network/)\n\n\n## Overview\n\nThe project is structured as follows:\n\n- Solana Program: A program that allow to create and update price feeds in the ephemeral rollups.\n- Chain Pusher: A component that subscribes to price updates from a price feed and posts these updates on-chain.\n- Example Consumer: An example demonstrating how to consume and utilize the price data within a Solana program.\n\n## Running the chain pusher\n\n```bash\ncargo run -- --auth_header \"Bearer \u003cyour_auth_token\u003e\" --ws_url \"ws_url\" --cluster \"https://devnet.magicblock.app\"\n```\n\n## Consuming Price Data in a Solana Program\n\n\n1. Add pyth sdk\n\n```bash\ncargo add pyth_solana_receiver_sdk\n```\n\n2. Define the instruction context, passing the account as AccountInfo\n\n```rust\n#[derive(Accounts)]\npub struct Sample\u003c'info\u003e {\n    #[account(mut)]\n    pub payer: Signer\u003c'info\u003e,\n    /// CHECK: the correct price feed\n    pub price_update: AccountInfo\u003c'info\u003e,\n}\n```\n\n3. Deserialize and use the price data\n\n```rust\n    pub fn sample(ctx: Context\u003cSample\u003e) -\u003e Result\u003c()\u003e {\n        // Deserialize the price feed\n        let price_update = PriceUpdateV2::try_deserialize_unchecked\n            (\u0026mut (*ctx.accounts.price_update.data.borrow()).as_ref(),\n            ).map_err(Into::\u003cError\u003e::into)?;\n\n        // get_price_no_older_than will fail if the price update is more than 30 seconds old\n        let maximum_age: u64 = 60;\n\n        // Get the price feed id\n        let feed_id: [u8; 32] = ctx.accounts.price_update.key().to_bytes();\n\n        msg!(\"The price update is: {}\", price_update.price_message.price);\n        let price = price_update.get_price_no_older_than(\u0026Clock::get()?, maximum_age, \u0026feed_id)?;\n\n        // Sample output:\n        // The price is (7160106530699 ± 5129162301) * 10^-8\n        msg!(\"The price is ({} ± {}) * 10^{}\", price.price, price.conf, price.exponent);\n        msg!(\"The price is: {}\", price.price as f64 * 10_f64.powi(price.exponent));\n\n        Ok(())\n    }\n```\n\n- [programs/ephemeral-oracle/programs/ephemeral-oracle/src/lib.rs](programs/ephemeral-oracle/programs/ephemeral-oracle/src/lib.rs)\n\n## Example Price Feeds\n\n| Asset Pair | Feed Provider | Address                                          |\n|------------|---------------|--------------------------------------------------|\n| SOL/USD    | Pyth Lazer    | [ENYwebBThHzmzwPLAQvCucUTsjyfBSZdD9ViXksS4jPu](https://explorer.solana.com/address/ENYwebBThHzmzwPLAQvCucUTsjyfBSZdD9ViXksS4jPu?cluster=custom\u0026customUrl=https%3A%2F%2Fdevnet.magicblock.app) |\n| BTC/USD    | Pyth Lazer    | [71wtTRDY8Gxgw56bXFt2oc6qeAbTxzStdNiC425Z51sr](https://explorer.solana.com/address/71wtTRDY8Gxgw56bXFt2oc6qeAbTxzStdNiC425Z51sr?cluster=custom\u0026customUrl=https%3A%2F%2Fdevnet.magicblock.app) |\n| ETH/USD    | Pyth Lazer    | [5vaYr1hpv8yrSpu8w3K95x22byYxUJCCNCSYJtqVWPvG](https://explorer.solana.com/address/5vaYr1hpv8yrSpu8w3K95x22byYxUJCCNCSYJtqVWPvG?cluster=custom\u0026customUrl=https%3A%2F%2Fdevnet.magicblock.app) |\n| USDC/USD   | Pyth Lazer    | [Ekug3x6hs37Mf4XKCDptvRVCSCjJCAD7LKmKQXBAa541](https://explorer.solana.com/address/Ekug3x6hs37Mf4XKCDptvRVCSCjJCAD7LKmKQXBAa541?cluster=custom\u0026customUrl=https%3A%2F%2Fdevnet.magicblock.app) |\n\n## Demo\n\nhttps://realtime-price-tracker.vercel.app/\n\n### Subcribe to a price feed\n\nConnect:\n\n```bash\nwscat -c \"wss://devnet.magicblock.app\"\n```\n\nSubscribe:\n\n```bash\n{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"accountSubscribe\",\"params\":[\"ENYwebBThHzmzwPLAQvCucUTsjyfBSZdD9ViXksS4jPu\",{\"encoding\":\"jsonParsed\",\"commitment\":\"confirmed\"}]}\n```\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicblock-labs%2Freal-time-pricing-oracle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagicblock-labs%2Freal-time-pricing-oracle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagicblock-labs%2Freal-time-pricing-oracle/lists"}