This commit is contained in:
Hardhat Chad
2025-10-05 12:45:36 -07:00
parent 4deabfd01b
commit c327029d2c
2 changed files with 60 additions and 3 deletions

View File

@@ -308,6 +308,26 @@ pub fn reset(
}
}
// let [signer_info, board_info, rent_payer_info, round_info, treasury_info, system_program] =
pub fn close(signer: Pubkey, round_id: u64, rent_payer: Pubkey) -> Instruction {
let board_address = board_pda().0;
let treasury_address = TREASURY_ADDRESS;
let round_address = round_pda(round_id).0;
Instruction {
program_id: crate::ID,
accounts: vec![
AccountMeta::new(signer, true),
AccountMeta::new(board_address, false),
AccountMeta::new(rent_payer, false),
AccountMeta::new(round_address, false),
AccountMeta::new(treasury_address, false),
AccountMeta::new_readonly(system_program::ID, false),
],
data: Close {}.to_bytes(),
}
}
// let [signer_info, automation_info, board_info, miner_info, round_info, treasury_info, system_program] =
pub fn checkpoint(signer: Pubkey, authority: Pubkey, round_id: u64) -> Instruction {

View File

@@ -98,6 +98,9 @@ async fn main() {
"checkpoint_all" => {
checkpoint_all(&rpc, &payer).await.unwrap();
}
"close_all" => {
close_all(&rpc, &payer).await.unwrap();
}
"claim_seeker" => {
claim_seeker(&rpc, &payer).await.unwrap();
}
@@ -218,8 +221,8 @@ async fn bury(
let amount_u64 = ui_amount_to_amount(amount_f64, TOKEN_DECIMALS);
let wrap_ix = ore_api::sdk::wrap(payer.pubkey());
let bury_ix = ore_api::sdk::bury(payer.pubkey(), amount_u64);
// submit_transaction(rpc, payer, &[wrap_ix, bury_ix]).await?;
simulate_transaction(rpc, payer, &[wrap_ix, bury_ix]).await;
submit_transaction(rpc, payer, &[wrap_ix, bury_ix]).await?;
// simulate_transaction(rpc, payer, &[wrap_ix, bury_ix]).await;
Ok(())
}
@@ -360,7 +363,7 @@ async fn checkpoint_all(
}
}
// Submit the instructions in batches.
// Batch and submit the instructions.
while !ixs.is_empty() {
let batch = ixs
.drain(..std::cmp::min(10, ixs.len()))
@@ -371,6 +374,35 @@ async fn checkpoint_all(
Ok(())
}
async fn close_all(
rpc: &RpcClient,
payer: &solana_sdk::signer::keypair::Keypair,
) -> Result<(), anyhow::Error> {
let rounds = get_rounds(rpc).await?;
let mut ixs = vec![];
let clock = get_clock(rpc).await?;
for (_i, (_address, round)) in rounds.iter().enumerate() {
if clock.slot >= round.expires_at {
ixs.push(ore_api::sdk::close(
payer.pubkey(),
round.id,
round.rent_payer,
));
}
}
// Batch and submit the instructions.
while !ixs.is_empty() {
let batch = ixs
.drain(..std::cmp::min(12, ixs.len()))
.collect::<Vec<Instruction>>();
// simulate_transaction(rpc, payer, &batch).await;
submit_transaction(rpc, payer, &batch).await?;
}
Ok(())
}
async fn log_meteora_pool(rpc: &RpcClient) -> Result<(), anyhow::Error> {
let address = pubkey!("GgaDTFbqdgjoZz3FP7zrtofGwnRS4E6MCzmmD5Ni1Mxj");
let pool = get_meteora_pool(rpc, address).await?;
@@ -630,6 +662,11 @@ async fn get_stake(rpc: &RpcClient, authority: Pubkey) -> Result<Stake, anyhow::
Ok(*stake)
}
async fn get_rounds(rpc: &RpcClient) -> Result<Vec<(Pubkey, Round)>, anyhow::Error> {
let rounds = get_program_accounts::<Round>(rpc, ore_api::ID, vec![]).await?;
Ok(rounds)
}
#[allow(dead_code)]
async fn get_miners(rpc: &RpcClient) -> Result<Vec<(Pubkey, Miner)>, anyhow::Error> {
let miners = get_program_accounts::<Miner>(rpc, ore_api::ID, vec![]).await?;