This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as sb from "@switchboard-xyz/on-demand"; | |
import { | |
Connection, | |
Transaction, | |
sendAndConfirmTransaction, | |
Keypair, | |
PublicKey, | |
} from "@solana/web3.js"; | |
import { TX_CONFIG } from "./utils"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use sb_on_demand_schemas::{FeedRequestV2}; | |
/// Creates the exact BTC v2 feed structure for testing | |
pub fn create_btc_v2_feed() -> Result<OracleFeed> { | |
use protos::oracle_job::oracle_job::{Task, HttpTask, JsonParseTask, http_task, json_parse_task}; | |
// Create HTTP task | |
let http_task = Task { | |
task: Some(protos::oracle_job::oracle_job::task::Task::HttpTask(HttpTask { | |
url: Some("https://www.binance.com/api/v3/ticker/price?symbol=BTCUSDT".to_string()), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ts-node | |
import { normalizeOracleFeed, serializeOracleFeed } from './lib/utils/oracle-feed.js'; | |
import { FeedHash } from './lib/FeedHash.js'; | |
async function createBtcFeedDemo() { | |
console.log('🚀 Creating BTC v2 Oracle Feed...\n'); | |
// Create the exact feed structure as provided | |
const feedDefinition = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use anyhow::{anyhow, Context}; | |
use rust_decimal::Decimal; | |
use solana_sdk::{pubkey, pubkey::Pubkey}; | |
use spl_token_2022::{ | |
extension::{ | |
interest_bearing_mint::InterestBearingConfig, BaseStateWithExtensions, | |
StateWithExtensionsOwned, | |
}, | |
state::Mint as Mint2022, | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
crossbar: | |
image: switchboardlabs/crossbar:latest | |
depends_on: | |
- ipfs | |
ports: | |
- "8080:8080" | |
environment: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"feedHash": "0xff97ea4aa5f7b1e6d3c45bccc5e17e9e1eeebfa7816898d4e2e9e3ac449419d9", | |
"results": [ | |
"0.0000171609694196136122180671" | |
], | |
"receipts": [ | |
{ | |
"children": [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{env, str::FromStr, sync::Arc, time::Duration}; | |
use anyhow_ext::{anyhow, Context, Error as AnyhowError, Result}; | |
use cached::{ | |
proc_macro::{cached, once}, | |
SizedCache, | |
}; | |
use fancy_regex::Regex; | |
use futures::future::join_all; | |
use num_traits::FromPrimitive; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Chainlink Data Streams API Request Script | |
# Usage: ./chainlink_request.sh | |
# Configuration | |
API_KEY=${API_KEY:-"your_api_key_here"} | |
API_SECRET="${API_SECRET:-"your_api_secret_here"} | |
BASE_URL="https://api.testnet-dataengine.chain.link" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::time::{Instant}; | |
use databento::{ | |
dbn::{PitSymbolMap, SType, Schema, TradeMsg}, | |
live::Subscription, | |
LiveClient, | |
}; | |
use regex::Regex; | |
use std::time::{Duration, SystemTime, UNIX_EPOCH}; | |
use chrono; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mod idl; | |
use std::{ | |
collections::HashMap, | |
sync::{atomic::AtomicU64, Arc}, | |
}; | |
use anyhow::{anyhow, Result}; | |
use anyhow_ext::Context; | |
use idl::*; | |
use rust_decimal::Decimal; |
NewerOlder