Skip to content

Commit

Permalink
add migrate farming rate to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsource147 committed Dec 6, 2023
1 parent 158e098 commit 86ad109
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions cli/farming-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ pub enum CliCommand {
},

CheckFunderAllPool {},
MigrateFarmingRate {},
}

#[derive(Parser, Debug)]
Expand Down
30 changes: 30 additions & 0 deletions cli/farming-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ fn main() -> Result<()> {
CliCommand::CheckFunderAllPool {} => {
check_funder_all_pool(&program)?;
}
CliCommand::MigrateFarmingRate {} => {
migrate_farming_rate(&program)?;
}
}

Ok(())
Expand Down Expand Up @@ -448,3 +451,30 @@ fn check_funder_all_pool(program: &Program) -> Result<()> {
}
Ok(())
}

fn migrate_farming_rate(program: &Program) -> Result<()> {
let pools: Vec<(Pubkey, Pool)> = program.accounts::<Pool>(vec![]).unwrap();

println!("len pool {}", pools.len());

for pool in pools.iter() {
let pool_state = pool.1.clone();
let mut should_migrate = false;
if pool_state.reward_a_rate_u128 == 0 && pool_state._reward_a_rate != 0 {
should_migrate = true;
}
if pool_state.reward_b_rate_u128 == 0 && pool_state._reward_b_rate != 0 {
should_migrate = true;
}

if should_migrate {
let builder = program
.request()
.accounts(farming::accounts::MigrateFarmingRate { pool: pool.0 })
.args(farming::instruction::MigrateFarmingRate {});
let signature = builder.send()?;
println!("Migrate pool {} signature {:?}", pool.0, signature);
}
}
Ok(())
}

0 comments on commit 86ad109

Please sign in to comment.