Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Transfer SWITCH tokens from operator to signer wallet
#
# Usage: ./setup-oracle-env.sh [--simulate] <operator> <signer>
set -e
SIMULATE=false
if [[ "$1" == "--simulate" ]]; then
SIMULATE=true
#!/usr/bin/env npx tsx
/**
* Sui Feed Crank Script
*
* Fetches oracle responses and submits a feed update transaction.
*
* Usage:
* npx tsx scripts/sui-feed-crank.ts <feed_id> [options]
*
* Arguments:
use std::str::FromStr;
use anyhow_ext::{anyhow, Result};
use fusionamm_client::FusionPool;
use fusionamm_core::sqrt_price_to_price;
use rust_decimal::Decimal;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
/// DefiTuna program ID: tuna4uSQZncNeeiAMKbstuxA9CUkHH6HmC64wgmnogD
@mgild
mgild / idl.json
Last active November 24, 2025 17:51
{
"version": "0.1.0",
"name": "quote_program",
"instructions": [
{
"name": "VerifiedUpdate",
"accounts": [
{
"name": "queueAccount",
"isMut": false,
#[assert_size(3200)]
#[account(zero_copy)]
pub struct PullFeedAccountData {
/// The oracle submissions for this feed.
pub submissions: [OracleSubmission; 32],
/// The public key of the authority that can update the feed hash that
/// this account will use for registering updates.
pub authority: Pubkey,
/// The public key of the queue which oracles must be bound to in order to
/// submit data to this feed.
use std::{
collections::HashMap,
str::FromStr,
sync::{atomic::AtomicU64, Arc},
};
use anyhow::Context;
use anyhow_ext::{anyhow, Result};
use async_recursion::async_recursion;
use borsh::de::BorshDeserialize;
use std::time::{SystemTime, UNIX_EPOCH};
use anyhow::{anyhow, Context};
use num_traits::FromPrimitive;
use rust_decimal::Decimal;
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::pubkey::Pubkey;
use crate::{
oracle_job::ExponentPtLinearPricingTask, protos::OracleJob, TaskInterface, TaskInterfaceAsync,
use crate::{exchange_config::get_allowed_quotes, exchanges::connection_state::ConnectionState, pair::Pair, traits::TickerStream, types::{Source, Ticker}};
use anyhow::{anyhow, Result};
use dashmap::DashMap;
use futures::Stream;
use futures::{SinkExt, StreamExt};
use once_cell::sync::Lazy;
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
use std::pin::Pin;
use std::sync::atomic::{AtomicBool, Ordering};

Technical Interview Question: Counting Squares from Points

Prompt

You are given a vector of points in 2D space, represented as Vec<(i32, i32)>. Write a function that returns the number of distinct squares that can be formed using these points as vertices.

A square is defined as a quadrilateral with four equal sides and four right angles.


import { CrossbarClient, OracleJob } from "@switchboard-xyz/common";
/**
* Creates an Oracle Job definition for hyloUSD
* HyloTask converts 1 hyUSD to jitoSOL
* hyUSD is a stablecoin with NAV pegged to $1.00 USD
* @returns OracleJob configured to fetch hyUSD to jitoSOL conversion rate
*/
function getHyloUSDJob(): OracleJob {
const job = OracleJob.fromObject({