Skip to content

Instantly share code, notes, and snippets.

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({
import { OracleQuote } from './src/classes/oracleQuote.js';
// Your hex string
const hexData = '0100100000005000000070005100000047c0a7750a1809cab7d20a63c56f4c337d4d3cbef811abc27c2d0733c9698664d0dc7526e113052843ca295575fda8375bb8c013e1e8f8522cd96acd94f8280a887d70946cbfbd9ff02d81dff0a80f74c8f6c1fc7c456fbde36784ebec8020fb5e5340cd96123980828ce60bb40ad16d805ec03b003fec50a6922a014e495a0136a820f6fe617053e0b9886e39b583fc5d904553964623d02d3e924c07670f300000e2c7cea8990d0000000000000000010a6cf36b16000000000053424f44';
// Convert hex to Buffer
const buffer = Buffer.from(hexData, 'hex');
try {
// Decode the instruction data
import { wrap as wrapFetch } from "@faremeter/fetch";
import { Keypair, PublicKey, Connection } from "@solana/web3.js";
import { createLocalWallet } from "@faremeter/wallet-solana";
import { exact } from "@faremeter/payment-solana";
import * as fs from "fs";
(async function main() {
const keypair = Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(fs.readFileSync(process.env.SOL_KEY_PATH!, "utf-8"))),
);