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 bun | |
| /** | |
| * Monad Mainnet - Switchboard Feed Update Utility | |
| * | |
| * This script fetches oracle data from Switchboard's Crossbar service and submits | |
| * feed updates to the Switchboard contract on Monad Mainnet. It can also query | |
| * the current state of feeds on-chain. | |
| * | |
| * Prerequisites: | |
| * - Bun runtime: https://bun.sh |
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
| # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | |
| # Logs | |
| logs | |
| _.log | |
| npm-debug.log_ | |
| yarn-debug.log* | |
| yarn-error.log* | |
| lerna-debug.log* |
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 { ethers, BigNumberish } from 'ethers'; | |
| import * as dotenv from 'dotenv'; | |
| import { CrossbarClient } from '@switchboard-xyz/common'; | |
| // Load environment variables | |
| dotenv.config(); | |
| // Contract ABI for the randomness-related functions | |
| const RANDOMNESS_ABI = [ | |
| // requestRandomness IS TO BE CALLED WHEN CREATING A NEW RANDOMNESS REQUEST - FROM INSIDE YOUR CONTRACT |
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
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity ^0.8.17; | |
| /// DEPLOYED AT https://sepolia.arbiscan.io/address/0x237485729745b2ba588d1414e40e1faf126fc604 | |
| /// My additions: | |
| /// I added the Switchboard Devnet Queue - which hits the cluster of oracles for test networks. This is the only queue enabled on Testnets. | |
| /// Thanks for your patience with this. It will be made clearer in the documentation. | |
| import {Structs} from ""; | |
| import {ISwitchboard} from "" |
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 { PublicKey, Keypair } from "@solana/web3.js"; | |
| import { CrossbarClient } from "@switchboard-xyz/common"; | |
| import { PullFeed, asV0Tx, getDefaultQueue } from "@switchboard-xyz/on-demand"; | |
| import { config as dotenv } from "dotenv"; | |
| import base58 from "bs58"; | |
| import perf from "perf_hooks"; | |
| // load environment variables | |
| dotenv(); |
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 { PublicKey, Keypair } from "@solana/web3.js"; | |
| import { CrossbarClient } from "@switchboard-xyz/common"; | |
| import { PullFeed, asV0Tx, getDefaultQueue } from "@switchboard-xyz/on-demand"; | |
| import { config as dotenv } from "dotenv"; | |
| import base58 from "bs58"; | |
| import perf from "perf_hooks"; | |
| // load environment variables | |
| dotenv(); |
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 necessary modules | |
| import { GatewayCache } from "./src/chains/evm/GatewayCache"; | |
| import { getIPFSClient } from "./src/ipfs"; | |
| import type { FeedHashDefinition } from "./src/util"; | |
| import { getDevnetQueue } from "./src/util"; | |
| import { OracleJob } from "@switchboard-xyz/common"; | |
| import { Gateway } from "@switchboard-xyz/on-demand"; | |
| import axios from "axios"; | |
| import * as fs from "fs"; |
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
| //SPDX-License-Identifier: UNLICENSED | |
| pragma solidity >=0.8.0 <0.9.0; | |
| import {Structs} from "./structs/Structs.sol"; | |
| import {FeedLib} from "./feed/FeedLib.sol"; | |
| import {FeedStorage} from "./feed/FeedStorage.sol"; | |
| import {QueueLib} from "./queue/QueueLib.sol"; | |
| import {QueueStorage} from "./queue/QueueStorage.sol"; | |
| import {AggregatorLib} from "./aggregator/AggregatorLib.sol"; | |
| import {AggregatorStorage} from "./aggregator/AggregatorStorage.sol"; |
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 { | |
| getFeedUpdateData, | |
| getDefaultDevnetQueue, | |
| OracleJob, | |
| } from "@switchboard-xyz/on-demand"; // use @switchboard-xyz/[email protected] | |
| import { ethers } from "ethers"; // use ethers@^6.12.1 | |
| async function getTimeBTC() { | |
| return getFeedUpdateData( | |
| { |
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
| // SPDX-License-Identifier: UNLICENSED | |
| // This is an interface for interacting with the Receiver contract from Switchboard's Pull Model | |
| pragma solidity ^0.8.9; | |
| // Struct representing a result for a feed and interval | |
| struct Result { | |
| int256 value; // The value of the feed result | |
| uint256 timestamp; // The timestamp of the result | |
| uint256 updatedAt; // The timestamp when the result was last updated |
NewerOlder