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
running 1 test | |
Initializing state | |
Connecting to RPC: https://switchboard.rpcpool.com/5f7ec120-9628-40c4-997f-0cdb4135e059 | |
Connected to RPC | |
Loaded payer | |
Markets: 19 | |
====== Market Details ====== | |
Lifinity market ID: W5s3YFGHyMnWqYxkdfimB6AgMPiofDm5S5ndjqdvPuy |
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
-- ========== v1: May 2021 - Dec 2022 ========== | |
WITH | |
-- v1a: May 2021 - Oct 2021 | |
v1a AS ( | |
WITH tx_signers AS ( | |
SELECT DISTINCT tx_id, address AS signer | |
FROM solana.account_activity | |
WHERE signed = TRUE | |
AND block_time BETWEEN TIMESTAMP '2021-05-01' AND TIMESTAMP '2021-10-31' |
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
-- v1: May 2021 - Dec 2022 | |
WITH | |
tx_signers_v1 AS ( | |
SELECT DISTINCT tx_id, address AS signer | |
FROM solana.account_activity | |
WHERE signed = TRUE AND block_time BETWEEN TIMESTAMP '2021-05-01' AND TIMESTAMP '2022-12-31' | |
), | |
combined_keys_v1 AS ( | |
SELECT DISTINCT t.signer, aa.address AS key | |
FROM solana.account_activity aa |
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 anchor_lang::{AnchorDeserialize, prelude::AccountInfo}; | |
use anyhow::{anyhow, Result}; | |
use anyhow_ext::Context; | |
use idl::*; | |
use rust_decimal::Decimal; | |
use sanctum_lst_list::{ | |
PoolInfo::{SPool, SanctumSpl, SanctumSplMulti, Spl}, | |
SanctumLst, SanctumLstList, SplPoolAccounts, | |
}; |
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
WITH signer_lookup AS ( | |
SELECT | |
tx_id, | |
MAX(CASE WHEN signed THEN address END) AS signer | |
FROM account_activity | |
GROUP BY tx_id | |
) | |
SELECT | |
a.*, |
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::{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 anyhow::Error as AnyhowError; | |
use crate::{ | |
protos::{oracle_job::*, OracleJob}, |
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
WITH combined_keys AS ( | |
-- Feed v3 via account_activity (2024+) | |
SELECT DISTINCT t.signer, aa.address AS key | |
FROM solana.transactions t, solana.account_activity aa | |
WHERE t.block_date >= TIMESTAMP '2024-06-01' | |
AND aa.block_time >= TIMESTAMP '2024-06-01' | |
AND aa.tx_id = t.id | |
UNION ALL |
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
WITH account_list AS ( | |
SELECT | |
* | |
FROM (VALUES | |
('4TBA2upbfULV5ryM8LxSqreztonu5xLYxN6qBEzHXR5f'), | |
('GZcUY6egnYuXHGWPukTo8iKEZiv5CVKXutcphRuKryNE'), | |
('9cizJpitym7CGL2QauvgG4BtTvSeADvppUpwGTPRc6De'), | |
('GpNuWCghujQQNyyX1qv2p2r7WpX2hD6UyPnN8rRDGLs'), | |
('7TZABdVVzqtGwgtqHM6VS8E34LtFq4dogNvTWEH9QaaM'), | |
('5tMcLP49P7CHKEM4KWAiSDNpEh5UFcCLsMVXi74YRg5C'), |
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
WITH instruction_accounts AS ( | |
SELECT DISTINCT | |
i.tx_id, | |
i.tx_signer, | |
account | |
FROM | |
solana.instruction_calls i | |
CROSS JOIN UNNEST(i.account_arguments) AS t(account) | |
WHERE | |
i.tx_signer != account |
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
pub async fn calc_from_calculator( | |
client: &RpcClient, | |
mut calc: KnownLstSolValCalc, | |
) -> Result<Decimal> { | |
let accounts = calc.get_accounts_to_update(); | |
let account_datas: Vec<Account> = client | |
.get_multiple_accounts(&accounts.clone()) | |
.await | |
.map_err(|_| anyhow!("Failed to get accounts"))? | |
.into_iter() |
NewerOlder