(
client: &Client,
price_feed_pubkey: Pubkey,
cluster: Cluster,
thread_id: &str,
)
| 58 | } |
| 59 | |
| 60 | fn create_feed( |
| 61 | client: &Client, |
| 62 | price_feed_pubkey: Pubkey, |
| 63 | cluster: Cluster, |
| 64 | thread_id: &str, |
| 65 | ) -> ClientResult<()> { |
| 66 | let lookback_window: i64 = 7203; // seconds |
| 67 | let stat_pubkey = |
| 68 | pyth_stats::state::Stat::pubkey(price_feed_pubkey, client.payer_pubkey(), lookback_window); |
| 69 | let stat_thread_pubkey = |
| 70 | clockwork_client::thread::state::Thread::pubkey(client.payer_pubkey(), thread_id.into()); |
| 71 | let avg_buffer_pubkey = pyth_stats::state::AvgBuffer::pubkey(stat_pubkey); |
| 72 | let price_buffer_pubkey = pyth_stats::state::PriceBuffer::pubkey(stat_pubkey); |
| 73 | let time_series_pubkey = pyth_stats::state::TimeSeries::pubkey(stat_pubkey); |
| 74 | |
| 75 | print_explorer_link(stat_pubkey, "stat account".into(), cluster)?; |
| 76 | print_explorer_link(stat_thread_pubkey, "stat_thread".into(), cluster)?; |
| 77 | |
| 78 | // airdrop thread |
| 79 | #[cfg(not(feature = "mainnet"))] |
| 80 | client.airdrop( |
| 81 | &stat_thread_pubkey, |
| 82 | 2 * solana_sdk::native_token::LAMPORTS_PER_SOL, |
| 83 | )?; |
| 84 | |
| 85 | let initialize_ix = Instruction { |
| 86 | program_id: pyth_stats::ID, |
| 87 | accounts: vec![ |
| 88 | AccountMeta::new(avg_buffer_pubkey, false), |
| 89 | AccountMeta::new(price_buffer_pubkey, false), |
| 90 | AccountMeta::new_readonly(price_feed_pubkey, false), |
| 91 | AccountMeta::new(client.payer_pubkey(), true), |
| 92 | AccountMeta::new(stat_pubkey, false), |
| 93 | AccountMeta::new_readonly(system_program::ID, false), |
| 94 | AccountMeta::new(time_series_pubkey, false), |
| 95 | ], |
| 96 | data: pyth_stats::instruction::Initialize { lookback_window }.data(), |
| 97 | }; |
| 98 | |
| 99 | let create_thread_ix = thread_create( |
| 100 | client.payer_pubkey(), |
| 101 | thread_id.into(), |
| 102 | Instruction { |
| 103 | program_id: pyth_stats::ID, |
| 104 | accounts: vec![ |
| 105 | AccountMeta::new(avg_buffer_pubkey, false), |
| 106 | AccountMeta::new(price_buffer_pubkey, false), |
| 107 | AccountMeta::new_readonly(price_feed_pubkey, false), |
| 108 | AccountMeta::new(stat_pubkey, false), |
| 109 | AccountMeta::new(stat_thread_pubkey, true), |
| 110 | AccountMeta::new(time_series_pubkey, false), |
| 111 | ], |
| 112 | data: pyth_stats::instruction::Calc {}.data(), |
| 113 | } |
| 114 | .into(), |
| 115 | client.payer_pubkey(), |
| 116 | stat_thread_pubkey, |
| 117 | Trigger::Cron { |
no test coverage detected