Skip to content

Instantly share code, notes, and snippets.

import * as sb from "@switchboard-xyz/on-demand";
import {
Connection,
Transaction,
sendAndConfirmTransaction,
Keypair,
PublicKey,
} from "@solana/web3.js";
import { TX_CONFIG } from "./utils";
@mgild
mgild / x.rs
Last active August 14, 2025 18:50
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()),
#!/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 = {
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,
};
version: '3.8'
services:
crossbar:
image: switchboardlabs/crossbar:latest
depends_on:
- ipfs
ports:
- "8080:8080"
environment:
[
{
"feedHash": "0xff97ea4aa5f7b1e6d3c45bccc5e17e9e1eeebfa7816898d4e2e9e3ac449419d9",
"results": [
"0.0000171609694196136122180671"
],
"receipts": [
{
"children": [
{
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;
#!/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"
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;
mod idl;
use std::{
collections::HashMap,
sync::{atomic::AtomicU64, Arc},
};
use anyhow::{anyhow, Result};
use anyhow_ext::Context;
use idl::*;
use rust_decimal::Decimal;