From 028f07a628b9c4166ce396600c6542a136d642d4 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Mon, 6 Jan 2025 20:30:56 +0000 Subject: [PATCH 01/19] checkpoint --- staking/Cargo.lock | 11 ++++++----- staking/cli/Cargo.toml | 1 + staking/cli/src/instructions.rs | 2 +- staking/cli/src/main.rs | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/staking/Cargo.lock b/staking/Cargo.lock index 97cef11a..0851e13a 100644 --- a/staking/Cargo.lock +++ b/staking/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -5294,6 +5294,7 @@ dependencies = [ "solana-client", "solana-remote-wallet", "solana-sdk", + "tokio", "uriparse", "wormhole-core-bridge-solana", "wormhole-solana", @@ -5527,9 +5528,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -6216,7 +6217,7 @@ dependencies = [ [[package]] name = "wormhole-core" version = "0.1.0" -source = "git+https://github.com/guibescos/wormhole?branch=reisen/sdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" +source = "git+https://github.com/guibescos/wormhole?branch=reisen%2Fsdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" dependencies = [ "borsh 0.9.3", "bstr 0.2.17", @@ -6268,7 +6269,7 @@ checksum = "045a3cc929189ffc0df110e4dc04421ed3226543f47a302088e6175b97b7d75f" [[package]] name = "wormhole-solana" version = "0.1.0" -source = "git+https://github.com/guibescos/wormhole?branch=reisen/sdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" +source = "git+https://github.com/guibescos/wormhole?branch=reisen%2Fsdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" dependencies = [ "borsh 0.9.3", "bstr 0.2.17", diff --git a/staking/cli/Cargo.toml b/staking/cli/Cargo.toml index 9a3e3cf8..4f5c80eb 100644 --- a/staking/cli/Cargo.toml +++ b/staking/cli/Cargo.toml @@ -27,3 +27,4 @@ uriparse = "0.6.4" solana-remote-wallet = "1.18.16" solana-account-decoder = "1.18.16" chrono = "0.4.38" +tokio = "1.42.0" diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 34a4c51e..e9eec010 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -48,7 +48,7 @@ use { serde_wormhole::RawMessage, solana_account_decoder::UiAccountEncoding, solana_client::{ - rpc_client::RpcClient, + nonblocking::rpc_client::RpcClient, rpc_config::{ RpcAccountInfoConfig, RpcProgramAccountsConfig, diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index df3a6ba0..c362e79e 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -21,12 +21,12 @@ use { update_reward_program_authority, update_y, }, - solana_client::rpc_client::RpcClient, + solana_client::nonblocking::rpc_client::RpcClient, solana_sdk::commitment_config::CommitmentConfig, }; - -fn main() { +#[tokio::main] +async fn main() { let Cli { keypair, rpc_url, From d36d40d285deb4262057efb6cdaec7a47c78a30d Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Mon, 6 Jan 2025 20:48:36 +0000 Subject: [PATCH 02/19] make the cli async: --- staking/cli/src/instructions.rs | 176 +++++++++++++++++++++----------- staking/cli/src/main.rs | 63 +++++++----- 2 files changed, 153 insertions(+), 86 deletions(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index e9eec010..5da999e3 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -119,13 +119,14 @@ use { }, }; -pub fn init_publisher_caps(rpc_client: &RpcClient, payer: &dyn Signer) -> Pubkey { +pub async fn init_publisher_caps(rpc_client: &RpcClient, payer: &dyn Signer) -> Pubkey { let publisher_caps = Keypair::new(); let create_account_ix = create_account( &payer.pubkey(), &publisher_caps.pubkey(), rpc_client .get_minimum_balance_for_rent_exemption(PublisherCaps::LEN) + .await .unwrap(), PublisherCaps::LEN.try_into().unwrap(), &publisher_caps::ID, @@ -153,11 +154,12 @@ pub fn init_publisher_caps(rpc_client: &RpcClient, payer: &dyn Signer) -> Pubkey ], &[payer, &publisher_caps], ) + .await .unwrap(); publisher_caps.pubkey() } -pub fn write_publisher_caps( +pub async fn write_publisher_caps( rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubkey, @@ -180,10 +182,16 @@ pub fn write_publisher_caps( data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[payer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[payer]) + .await + .unwrap(); } -pub fn close_publisher_caps(rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubkey) { +pub async fn close_publisher_caps( + rpc_client: &RpcClient, + payer: &dyn Signer, + publisher_caps: Pubkey, +) { let accounts = publisher_caps::accounts::ClosePublisherCaps { write_authority: payer.pubkey(), publisher_caps, @@ -197,11 +205,12 @@ pub fn close_publisher_caps(rpc_client: &RpcClient, payer: &dyn Signer, publishe data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[payer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[payer]) + .await + .unwrap(); } - -pub fn verify_publisher_caps( +pub async fn verify_publisher_caps( rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubkey, @@ -232,6 +241,7 @@ pub fn verify_publisher_caps( ], &[payer], ) + .await .unwrap(); } @@ -246,7 +256,7 @@ pub fn deserialize_accumulator_update_data( } } -pub fn process_transaction( +pub async fn process_transaction( rpc_client: &RpcClient, instructions: &[Instruction], signers: &[&dyn Signer], @@ -256,6 +266,7 @@ pub fn process_transaction( signers, rpc_client .get_latest_blockhash_with_commitment(CommitmentConfig::finalized()) + .await .unwrap() .0, ); @@ -267,7 +278,8 @@ pub fn process_transaction( skip_preflight: true, ..Default::default() }, - ); + ) + .await; match transaction_signature_res { Ok(signature) => { println!("Transaction successful : {signature:?}"); @@ -280,7 +292,7 @@ pub fn process_transaction( } } -pub fn process_write_encoded_vaa( +pub async fn process_write_encoded_vaa( rpc_client: &RpcClient, vaa: &[u8], wormhole: Pubkey, @@ -313,6 +325,7 @@ pub fn process_write_encoded_vaa( &[create_encoded_vaa, init_encoded_vaa_instruction], &[payer, &encoded_vaa_keypair], ) + .await .unwrap(); for i in (0..vaa.len()).step_by(1000) { @@ -325,7 +338,8 @@ pub fn process_write_encoded_vaa( &wormhole, i, chunk, - ); + ) + .await; } let (header, _): (Header, Body<&RawMessage>) = serde_wormhole::from_slice(vaa).unwrap(); @@ -355,13 +369,14 @@ pub fn process_write_encoded_vaa( ], &[payer], ) + .await .unwrap(); encoded_vaa_keypair.pubkey() } -pub fn write_encoded_vaa( +pub async fn write_encoded_vaa( rpc_client: &RpcClient, payer: &dyn Signer, encoded_vaa: &Pubkey, @@ -392,10 +407,11 @@ pub fn write_encoded_vaa( &[write_encoded_vaa_accounts_instruction], &[payer], ) + .await .unwrap(); } -pub fn close_encoded_vaa( +pub async fn close_encoded_vaa( rpc_client: &RpcClient, payer: &dyn Signer, encoded_vaa: Pubkey, @@ -413,10 +429,12 @@ pub fn close_encoded_vaa( data: wormhole_core_bridge_solana::instruction::CloseEncodedVaa {}.data(), }; - process_transaction(rpc_client, &[close_encoded_vaa_instruction], &[payer]).unwrap(); + process_transaction(rpc_client, &[close_encoded_vaa_instruction], &[payer]) + .await + .unwrap(); } -pub fn initialize_reward_custody(rpc_client: &RpcClient, payer: &dyn Signer) { +pub async fn initialize_reward_custody(rpc_client: &RpcClient, payer: &dyn Signer) { let pool_config = get_pool_config_address(); let PoolConfig { @@ -424,6 +442,7 @@ pub fn initialize_reward_custody(rpc_client: &RpcClient, payer: &dyn Signer) { } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) @@ -436,10 +455,12 @@ pub fn initialize_reward_custody(rpc_client: &RpcClient, payer: &dyn Signer) { &spl_token::ID, ); - process_transaction(rpc_client, &[create_ata_ix], &[payer]).unwrap(); + process_transaction(rpc_client, &[create_ata_ix], &[payer]) + .await + .unwrap(); } -pub fn advance(rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubkey) { +pub async fn advance(rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubkey) { let pool_config = get_pool_config_address(); let PoolConfig { @@ -449,6 +470,7 @@ pub fn advance(rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubke } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) @@ -480,10 +502,11 @@ pub fn advance(rpc_client: &RpcClient, payer: &dyn Signer, publisher_caps: Pubke ], &[payer], ) + .await .unwrap(); } -pub fn initialize_pool( +pub async fn initialize_pool( rpc_client: &RpcClient, payer: &dyn Signer, pool_data_keypair: &Keypair, @@ -496,6 +519,7 @@ pub fn initialize_pool( let rent = rpc_client .get_minimum_balance_for_rent_exemption(pool_data_space.try_into().unwrap()) + .await .unwrap(); let create_pool_data_acc_ix = create_account( @@ -534,21 +558,22 @@ pub fn initialize_pool( &[create_pool_data_acc_ix, initialize_pool_ix], &[payer, pool_data_keypair], ) + .await .unwrap(); } -pub fn get_current_time(rpc_client: &RpcClient) -> i64 { - let slot = rpc_client.get_slot().unwrap(); - rpc_client.get_block_time(slot).unwrap() +pub async fn get_current_time(rpc_client: &RpcClient) -> i64 { + let slot = rpc_client.get_slot().await.unwrap(); + rpc_client.get_block_time(slot).await.unwrap() } -pub fn get_current_epoch(rpc_client: &RpcClient) -> u64 { - let slot = rpc_client.get_slot().unwrap(); - let blocktime = rpc_client.get_block_time(slot).unwrap(); +pub async fn get_current_epoch(rpc_client: &RpcClient) -> u64 { + let slot = rpc_client.get_slot().await.unwrap(); + let blocktime = rpc_client.get_block_time(slot).await.unwrap(); blocktime as u64 / EPOCH_DURATION } -pub fn fetch_publisher_caps_and_advance( +pub async fn fetch_publisher_caps_and_advance( rpc_client: &RpcClient, payer: &dyn Signer, wormhole: Pubkey, @@ -562,18 +587,22 @@ pub fn fetch_publisher_caps_and_advance( } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) .unwrap(); let pool_data = PoolData::try_deserialize( - &mut rpc_client.get_account_data(&pool_data_address).unwrap()[..8 + size_of::()] + &mut rpc_client + .get_account_data(&pool_data_address) + .await + .unwrap()[..8 + size_of::()] .as_ref(), ) .unwrap(); - if pool_data.last_updated_epoch == get_current_epoch(rpc_client) { + if pool_data.last_updated_epoch == get_current_epoch(rpc_client).await { println!("Pool data is already updated"); return; } @@ -597,12 +626,9 @@ pub fn fetch_publisher_caps_and_advance( let (vaa, merkle_proofs) = deserialize_accumulator_update_data(message); + let encoded_vaa = process_write_encoded_vaa(rpc_client, vaa.as_slice(), wormhole, payer).await; - let encoded_vaa = process_write_encoded_vaa(rpc_client, vaa.as_slice(), wormhole, payer); - - - let publisher_caps = init_publisher_caps(rpc_client, payer); - + let publisher_caps = init_publisher_caps(rpc_client, payer).await; let publisher_caps_message_bytes = Vec::::from(merkle_proofs.first().unwrap().message.clone()); @@ -612,7 +638,7 @@ pub fn fetch_publisher_caps_and_advance( let chunk = &publisher_caps_message_bytes[i..min(i + 1000, publisher_caps_message_bytes.len())]; - write_publisher_caps(rpc_client, payer, publisher_caps, i, chunk); + write_publisher_caps(rpc_client, payer, publisher_caps, i, chunk).await; } verify_publisher_caps( @@ -621,25 +647,30 @@ pub fn fetch_publisher_caps_and_advance( publisher_caps, encoded_vaa, merkle_proofs, - ); - + ) + .await; println!( "Initialized publisher caps with pubkey : {:?}", publisher_caps ); - advance(rpc_client, payer, publisher_caps); - close_publisher_caps(rpc_client, payer, publisher_caps); - close_encoded_vaa(rpc_client, payer, encoded_vaa, &wormhole); + advance(rpc_client, payer, publisher_caps).await; + close_publisher_caps(rpc_client, payer, publisher_caps).await; + close_encoded_vaa(rpc_client, payer, encoded_vaa, &wormhole).await; } -pub fn update_delegation_fee(rpc_client: &RpcClient, payer: &dyn Signer, delegation_fee: u64) { +pub async fn update_delegation_fee( + rpc_client: &RpcClient, + payer: &dyn Signer, + delegation_fee: u64, +) { let pool_config = get_pool_config_address(); let PoolConfig { pool_data, .. } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) @@ -660,10 +691,12 @@ pub fn update_delegation_fee(rpc_client: &RpcClient, payer: &dyn Signer, delegat data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[payer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[payer]) + .await + .unwrap(); } -pub fn set_publisher_stake_account( +pub async fn set_publisher_stake_account( rpc_client: &RpcClient, signer: &dyn Signer, publisher: &Pubkey, @@ -674,6 +707,7 @@ pub fn set_publisher_stake_account( let PoolConfig { pool_data, .. } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) @@ -696,10 +730,12 @@ pub fn set_publisher_stake_account( data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[signer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[signer]) + .await + .unwrap(); } -pub fn create_slash_event( +pub async fn create_slash_event( rpc_client: &RpcClient, signer: &dyn Signer, publisher: &Pubkey, @@ -714,13 +750,17 @@ pub fn create_slash_event( } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) .unwrap(); let pool_data = PoolData::try_deserialize( - &mut rpc_client.get_account_data(&pool_data_address).unwrap()[..8 + size_of::()] + &mut rpc_client + .get_account_data(&pool_data_address) + .await + .unwrap()[..8 + size_of::()] .as_ref(), ) .unwrap(); @@ -747,10 +787,12 @@ pub fn create_slash_event( data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[signer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[signer]) + .await + .unwrap(); } -pub fn update_reward_program_authority( +pub async fn update_reward_program_authority( rpc_client: &RpcClient, signer: &dyn Signer, new_reward_program_authority: &Pubkey, @@ -773,10 +815,12 @@ pub fn update_reward_program_authority( data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[signer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[signer]) + .await + .unwrap(); } -pub fn slash( +pub async fn slash( rpc_client: &RpcClient, signer: &dyn Signer, publisher: &Pubkey, @@ -790,6 +834,7 @@ pub fn slash( } = PoolConfig::try_deserialize( &mut rpc_client .get_account_data(&pool_config) + .await .unwrap() .as_slice(), ) @@ -800,7 +845,7 @@ pub fn slash( next_slash_event_index, .. } = { - let delegation_record_account_data = rpc_client.get_account_data(&delegation_record); + let delegation_record_account_data = rpc_client.get_account_data(&delegation_record).await; if let Ok(data) = delegation_record_account_data { DelegationRecord::try_deserialize(&mut data.as_slice()).unwrap() } else { @@ -847,10 +892,12 @@ pub fn slash( data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[signer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[signer]) + .await + .unwrap(); } -pub fn update_y(rpc_client: &RpcClient, signer: &dyn Signer, y: u64) { +pub async fn update_y(rpc_client: &RpcClient, signer: &dyn Signer, y: u64) { let pool_config = get_pool_config_address(); let accounts = integrity_pool::accounts::UpdateY { @@ -867,11 +914,13 @@ pub fn update_y(rpc_client: &RpcClient, signer: &dyn Signer, y: u64) { data: instruction_data.data(), }; - process_transaction(rpc_client, &[instruction], &[signer]).unwrap(); + process_transaction(rpc_client, &[instruction], &[signer]) + .await + .unwrap(); } -pub fn close_all_publisher_caps(rpc_client: &RpcClient, signer: &dyn Signer) { - rpc_client +pub async fn close_all_publisher_caps(rpc_client: &RpcClient, signer: &dyn Signer) { + let accounts = rpc_client .get_program_accounts_with_config( &publisher_caps::ID, RpcProgramAccountsConfig { @@ -888,12 +937,15 @@ pub fn close_all_publisher_caps(rpc_client: &RpcClient, signer: &dyn Signer) { with_context: None, }, ) - .unwrap() - .into_iter() - .for_each(|(pubkey, _account)| close_publisher_caps(rpc_client, signer, pubkey)); + .await + .unwrap(); + + for (pubkey, _account) in accounts { + close_publisher_caps(rpc_client, signer, pubkey).await; + } } -pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { +pub async fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { let data: Vec<(Pubkey, DynamicPositionArrayAccount, Pubkey, Pubkey, Pubkey)> = rpc_client .get_program_accounts_with_config( &staking::ID, @@ -911,6 +963,7 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { with_context: None, }, ) + .await .unwrap() .into_iter() .map(|(pubkey, account)| { @@ -945,6 +998,7 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { with_context: None, }, ) + .await .unwrap() .into_iter() .map(|(pubkey, account)| { @@ -958,11 +1012,12 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { let config = GlobalConfig::try_deserialize( &mut rpc_client .get_account_data(&get_config_address()) + .await .unwrap() .as_slice(), ) .unwrap(); - let current_time = get_current_time(rpc_client); + let current_time = get_current_time(rpc_client).await; let metadata_account_data_locked: HashMap = metadata_accounts_data .iter() @@ -1005,6 +1060,7 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { for chunk in locked_token_accounts_pubkeys.chunks(100) { rpc_client .get_multiple_accounts(chunk) + .await .unwrap() .into_iter() .enumerate() @@ -1046,7 +1102,7 @@ pub fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { ) .collect::>(); - let current_epoch = get_current_epoch(rpc_client); + let current_epoch = get_current_epoch(rpc_client).await; let data = data .into_iter() .map( diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index c362e79e..8323beca 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -48,58 +48,69 @@ async fn main() { reward_program_authority, y, slash_custody, - ); + ) + .await; } Action::Advance { hermes_url, wormhole, } => { - fetch_publisher_caps_and_advance(&rpc_client, keypair.as_ref(), wormhole, hermes_url); + fetch_publisher_caps_and_advance(&rpc_client, keypair.as_ref(), wormhole, hermes_url) + .await; } Action::InitializePoolRewardCustody {} => { - initialize_reward_custody(&rpc_client, keypair.as_ref()); + initialize_reward_custody(&rpc_client, keypair.as_ref()).await; } Action::UpdateDelegationFee { delegation_fee } => { - update_delegation_fee(&rpc_client, keypair.as_ref(), delegation_fee) + update_delegation_fee(&rpc_client, keypair.as_ref(), delegation_fee).await } Action::SetPublisherStakeAccount { publisher, stake_account_positions, - } => set_publisher_stake_account( - &rpc_client, - keypair.as_ref(), - &publisher, - &stake_account_positions, - ), + } => { + set_publisher_stake_account( + &rpc_client, + keypair.as_ref(), + &publisher, + &stake_account_positions, + ) + .await + } Action::CreateSlashEvent { publisher, slash_ratio, - } => create_slash_event(&rpc_client, keypair.as_ref(), &publisher, slash_ratio), + } => create_slash_event(&rpc_client, keypair.as_ref(), &publisher, slash_ratio).await, Action::UpdateRewardProgramAuthority { new_reward_program_authority, - } => update_reward_program_authority( - &rpc_client, - keypair.as_ref(), - &new_reward_program_authority, - ), + } => { + update_reward_program_authority( + &rpc_client, + keypair.as_ref(), + &new_reward_program_authority, + ) + .await + } Action::Slash { publisher, stake_account_positions, - } => slash( - &rpc_client, - keypair.as_ref(), - &publisher, - &stake_account_positions, - ), - Action::UpdateY { y } => update_y(&rpc_client, keypair.as_ref(), y), + } => { + slash( + &rpc_client, + keypair.as_ref(), + &publisher, + &stake_account_positions, + ) + .await + } + Action::UpdateY { y } => update_y(&rpc_client, keypair.as_ref(), y).await, Action::ClosePublisherCaps { publisher_caps } => { - close_publisher_caps(&rpc_client, keypair.as_ref(), publisher_caps) + close_publisher_caps(&rpc_client, keypair.as_ref(), publisher_caps).await } Action::SaveStakeAccountsSnapshot {} => { - save_stake_accounts_snapshot(&rpc_client); + save_stake_accounts_snapshot(&rpc_client).await; } Action::CloseAllPublisherCaps {} => { - close_all_publisher_caps(&rpc_client, keypair.as_ref()); + close_all_publisher_caps(&rpc_client, keypair.as_ref()).await; } } } From 675322c60eed9d3b3d4c550058deaefd14aecd22 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Mon, 6 Jan 2025 20:58:41 +0000 Subject: [PATCH 03/19] no-verify --- staking/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/staking/Cargo.lock b/staking/Cargo.lock index 0851e13a..7417332e 100644 --- a/staking/Cargo.lock +++ b/staking/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 4 +version = 3 [[package]] name = "Inflector" From 5a27e89c212c75ebc7d7afddd27b5ae3ae8360ca Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 13:59:09 +0000 Subject: [PATCH 04/19] go --- staking/Cargo.lock | 4 ++-- staking/rust-toolchain | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 staking/rust-toolchain diff --git a/staking/Cargo.lock b/staking/Cargo.lock index 7417332e..daf9f740 100644 --- a/staking/Cargo.lock +++ b/staking/Cargo.lock @@ -6217,7 +6217,7 @@ dependencies = [ [[package]] name = "wormhole-core" version = "0.1.0" -source = "git+https://github.com/guibescos/wormhole?branch=reisen%2Fsdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" +source = "git+https://github.com/guibescos/wormhole?branch=reisen/sdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" dependencies = [ "borsh 0.9.3", "bstr 0.2.17", @@ -6269,7 +6269,7 @@ checksum = "045a3cc929189ffc0df110e4dc04421ed3226543f47a302088e6175b97b7d75f" [[package]] name = "wormhole-solana" version = "0.1.0" -source = "git+https://github.com/guibescos/wormhole?branch=reisen%2Fsdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" +source = "git+https://github.com/guibescos/wormhole?branch=reisen/sdk-solana#b0da20525fe68408ed2c8b331eb5f63101381936" dependencies = [ "borsh 0.9.3", "bstr 0.2.17", diff --git a/staking/rust-toolchain b/staking/rust-toolchain new file mode 100644 index 00000000..7897a24d --- /dev/null +++ b/staking/rust-toolchain @@ -0,0 +1,2 @@ +[toolchain] +channel = "1.75.0" From 9bf681d5f85e4c2627051a24f8b87dc7ccecfc7c Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 16:01:58 +0000 Subject: [PATCH 05/19] checkpoint --- staking/cli/src/cli.rs | 6 + staking/cli/src/instructions.rs | 264 ++++++++++++++++++++++++++++++++ staking/cli/src/main.rs | 4 + 3 files changed, 274 insertions(+) diff --git a/staking/cli/src/cli.rs b/staking/cli/src/cli.rs index 48600fc0..2de1e233 100644 --- a/staking/cli/src/cli.rs +++ b/staking/cli/src/cli.rs @@ -111,6 +111,12 @@ pub enum Action { }, SaveStakeAccountsSnapshot {}, CloseAllPublisherCaps {}, + ClaimRewards { + #[clap(long, help = "Minimum staked tokens")] + min_staked: u64, + #[clap(long, help = "Minimum reward tokens per publisher")] + min_reward: u64, + }, } pub enum SignerSource { diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 5da999e3..00590675 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1191,3 +1191,267 @@ pub async fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { .unwrap(); } } + +pub async fn advance_delegation_record<'a>( + rpc_client: &RpcClient, + signer: &dyn Signer, + positions: &DynamicPositionArray<'a>, + min_reward: u64, + current_epoch: u64, + pool_data: &PoolData, + pool_data_address: &Pubkey, + pyth_token_mint: &Pubkey, + pool_config: &Pubkey, + index: usize, +) -> bool { + let positions_pubkey = positions.acc_info.key; + + // First collect all potential instruction data + let potential_instructions: Vec<_> = pool_data + .publishers + .iter() + .enumerate() + .filter_map(|(publisher_index, publisher)| { + if *publisher == Pubkey::default() { + return None; + } + + let publisher_exposure = { + let mut publisher_exposure = 0; + for i in 0..positions.get_position_capacity() { + if let Some(position) = positions.read_position(i).unwrap() { + if (position.target_with_parameters + == TargetWithParameters::IntegrityPool { + publisher: *publisher, + }) + { + publisher_exposure += position.amount; + } + } + } + publisher_exposure + }; + + if publisher_exposure == 0 { + return None; + } + + let publisher_stake_account_positions = + if pool_data.publisher_stake_accounts[publisher_index] == Pubkey::default() { + None + } else { + Some(pool_data.publisher_stake_accounts[publisher_index]) + }; + + let publisher_stake_account_custody = + publisher_stake_account_positions.map(get_stake_account_custody_address); + + Some(( + *publisher, + publisher_stake_account_positions, + publisher_stake_account_custody, + )) + }) + .collect(); + + println!( + "Position {:?} with index {} has {} potential instructions", + positions_pubkey, + index, + potential_instructions.len() + ); + + // Fetch all delegation records concurrently + let delegation_records = join_all(potential_instructions.iter().map(|(publisher, _, _)| { + let delegation_record_pubkey = get_delegation_record_address(*publisher, *positions_pubkey); + fetch_delegation_record(rpc_client, delegation_record_pubkey) + })) + .await; + + // Process results and create instructions + let mut instructions = Vec::new(); + for ( + (publisher, publisher_stake_account_positions, publisher_stake_account_custody), + delegation_record, + ) in potential_instructions.into_iter().zip(delegation_records) + { + // Skip if we couldn't fetch the record or if it's already processed for current epoch + match delegation_record { + Ok(delegation_record) => { + if delegation_record.last_epoch == current_epoch { + continue; + } + } + Err(_) => { + continue; + } + } + + let accounts = integrity_pool::accounts::AdvanceDelegationRecord { + delegation_record: get_delegation_record_address(publisher, *positions_pubkey), + payer: signer.pubkey(), + pool_config: *pool_config, + pool_data: *pool_data_address, + pool_reward_custody: get_pool_reward_custody_address(*pyth_token_mint), + publisher, + publisher_stake_account_positions, + publisher_stake_account_custody, + stake_account_positions: *positions_pubkey, + stake_account_custody: get_stake_account_custody_address(*positions_pubkey), + system_program: system_program::ID, + token_program: spl_token::ID, + }; + + let data = integrity_pool::instruction::AdvanceDelegationRecord {}; + + instructions.push(Instruction { + program_id: integrity_pool::ID, + accounts: accounts.to_account_metas(None), + data: data.data(), + }); + } + + // Process instructions in chunks of 5 + if !instructions.is_empty() { + println!( + "Advancing delegation record for pubkey: {:?}, number of instructions: {}", + positions_pubkey.to_string(), + instructions.len(), + ); + + for chunk in instructions.chunks(5) { + process_transaction(rpc_client, chunk, &[signer]) + .await + .unwrap(); + } + return true; // Instructions were processed + } + false // No instructions were processed +} + +pub async fn claim_rewards( + rpc_client: &RpcClient, + signer: &dyn Signer, + min_staked: u64, + min_reward: u64, +) { + let mut data: Vec = rpc_client + .get_program_accounts_with_config( + &staking::ID, + RpcProgramAccountsConfig { + filters: Some(vec![RpcFilterType::Memcmp(Memcmp::new( + 0, + MemcmpEncodedBytes::Bytes(PositionData::discriminator().to_vec()), + ))]), + account_config: RpcAccountInfoConfig { + encoding: Some(UiAccountEncoding::Base64Zstd), + data_slice: None, + commitment: None, + min_context_slot: None, + }, + with_context: None, + }, + ) + .await + .unwrap() + .into_iter() + .map(|(pubkey, account)| DynamicPositionArrayAccount { + key: pubkey, + lamports: account.lamports, + data: account.data.clone(), + }) + .collect::>(); + + let current_epoch = get_current_epoch(rpc_client).await; + + let mut data: Vec<(u64, DynamicPositionArray)> = data + .iter_mut() + .filter_map(|positions| { + let acc = positions.to_dynamic_position_array(); + let exposure = acc + .get_target_exposure(&Target::IntegrityPool, current_epoch) + .unwrap(); + if exposure >= min_staked { + Some((exposure, acc)) + } else { + None + } + }) + .collect(); + + data.sort_by_key(|(exposure, _)| *exposure); + data.reverse(); + + + let pool_config = get_pool_config_address(); + + let PoolConfig { + pool_data: pool_data_address, + pyth_token_mint, + .. + } = PoolConfig::try_deserialize( + &mut rpc_client + .get_account_data(&pool_config) + .await + .unwrap() + .as_slice(), + ) + .unwrap(); + + let pool_data = PoolData::try_deserialize( + &mut &rpc_client + .get_account_data(&pool_data_address) + .await + .unwrap() + .as_slice()[..8 + size_of::()], + ) + .unwrap(); + + println!("Processing {} accounts", data.len()); + // Initialize results vector with true to process all indexes in first round + let mut active_positions = vec![true; data.len()]; + + loop { + let futures = data + .iter() + .enumerate() + .filter(|(i, _)| active_positions[*i]) + .map(|(i, (_, positions))| { + advance_delegation_record( + rpc_client, + signer, + positions, + min_reward, + current_epoch, + &pool_data, + &pool_data_address, + &pyth_token_mint, + &pool_config, + i, + ) + }) + .collect::>(); + + let futures = tokio_stream::iter(futures); + let results = futures.buffered(20).collect::>().await; + + println!("Finished processing {} accounts", results.len()); + // Update active_positions based on results + let mut result_index = 0; + for i in 0..active_positions.len() { + if active_positions[i] { + active_positions[i] = results[result_index]; + result_index += 1; + } + } + + // If no delegations were advanced, we're done + if !results.iter().any(|&active| active) { + break; + } + + + println!("We will retry after 10 seconds!"); + tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; + } +} \ No newline at end of file diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index 8323beca..f0925c45 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -112,5 +112,9 @@ async fn main() { Action::CloseAllPublisherCaps {} => { close_all_publisher_caps(&rpc_client, keypair.as_ref()).await; } + Action::ClaimRewards { + min_staked, + min_reward, + } => claim_rewards(&rpc_client, keypair.as_ref(), min_staked, min_reward).await; } } From 98434e46a0279a0a106dfc54b08d41329e6c0e99 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 17:31:39 +0000 Subject: [PATCH 06/19] checkpoint --- staking/Cargo.lock | 42 +++++++++++++++++---------------- staking/cli/Cargo.toml | 2 ++ staking/cli/src/instructions.rs | 27 ++++++++++++++++++++- staking/cli/src/main.rs | 3 ++- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/staking/Cargo.lock b/staking/Cargo.lock index daf9f740..d4d30632 100644 --- a/staking/Cargo.lock +++ b/staking/Cargo.lock @@ -1643,9 +1643,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1658,9 +1658,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1668,15 +1668,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1685,15 +1685,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -1702,21 +1702,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -5281,6 +5281,7 @@ dependencies = [ "byteorder", "chrono", "clap 3.2.25", + "futures", "integration-tests", "integrity-pool", "publisher-caps", @@ -5295,6 +5296,7 @@ dependencies = [ "solana-remote-wallet", "solana-sdk", "tokio", + "tokio-stream", "uriparse", "wormhole-core-bridge-solana", "wormhole-solana", @@ -5577,9 +5579,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" dependencies = [ "futures-core", "pin-project-lite", diff --git a/staking/cli/Cargo.toml b/staking/cli/Cargo.toml index 4f5c80eb..6ef93f21 100644 --- a/staking/cli/Cargo.toml +++ b/staking/cli/Cargo.toml @@ -27,4 +27,6 @@ uriparse = "0.6.4" solana-remote-wallet = "1.18.16" solana-account-decoder = "1.18.16" chrono = "0.4.38" +futures = "0.3.31" tokio = "1.42.0" +tokio-stream = "0.1.17" diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 00590675..95d71e07 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -13,6 +13,10 @@ use { }, }, base64::Engine, + futures::{ + future::join_all, + StreamExt, + }, integration_tests::{ integrity_pool::pda::{ get_delegation_record_address, @@ -86,9 +90,12 @@ use { global_config::GlobalConfig, max_voter_weight_record::MAX_VOTER_WEIGHT, positions::{ + DynamicPositionArray, DynamicPositionArrayAccount, PositionData, PositionState, + Target, + TargetWithParameters, }, stake_account::StakeAccountMetadataV2, }, @@ -1192,6 +1199,24 @@ pub async fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { } } +pub struct FetchError {} + +pub async fn fetch_delegation_record( + rpc_client: &RpcClient, + key: Pubkey, +) -> Result { + let delegation_record = DelegationRecord::try_deserialize( + &mut (rpc_client + .get_account_data(&key) + .await + .map_err(|_| FetchError {})? + .as_slice()), + ) + .map_err(|_| FetchError {})?; + + Ok(delegation_record) +} + pub async fn advance_delegation_record<'a>( rpc_client: &RpcClient, signer: &dyn Signer, @@ -1454,4 +1479,4 @@ pub async fn claim_rewards( println!("We will retry after 10 seconds!"); tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; } -} \ No newline at end of file +} diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index f0925c45..5dcb67d4 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -8,6 +8,7 @@ use { Cli, }, instructions::{ + claim_rewards, close_all_publisher_caps, close_publisher_caps, create_slash_event, @@ -115,6 +116,6 @@ async fn main() { Action::ClaimRewards { min_staked, min_reward, - } => claim_rewards(&rpc_client, keypair.as_ref(), min_staked, min_reward).await; + } => claim_rewards(&rpc_client, keypair.as_ref(), min_staked, min_reward).await, } } From 5e29f31216e85e0a41c583560140d8656c628f7d Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 17:37:15 +0000 Subject: [PATCH 07/19] checkpoint --- staking/cli/src/cli.rs | 2 -- staking/cli/src/instructions.rs | 62 ++++++++++++++++++--------------- staking/cli/src/main.rs | 7 ++-- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/staking/cli/src/cli.rs b/staking/cli/src/cli.rs index 2de1e233..aea0a2bc 100644 --- a/staking/cli/src/cli.rs +++ b/staking/cli/src/cli.rs @@ -114,8 +114,6 @@ pub enum Action { ClaimRewards { #[clap(long, help = "Minimum staked tokens")] min_staked: u64, - #[clap(long, help = "Minimum reward tokens per publisher")] - min_reward: u64, }, } diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 95d71e07..3d0b2545 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1221,7 +1221,6 @@ pub async fn advance_delegation_record<'a>( rpc_client: &RpcClient, signer: &dyn Signer, positions: &DynamicPositionArray<'a>, - min_reward: u64, current_epoch: u64, pool_data: &PoolData, pool_data_address: &Pubkey, @@ -1354,13 +1353,8 @@ pub async fn advance_delegation_record<'a>( false // No instructions were processed } -pub async fn claim_rewards( - rpc_client: &RpcClient, - signer: &dyn Signer, - min_staked: u64, - min_reward: u64, -) { - let mut data: Vec = rpc_client +pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_staked: u64) { + let mut position_accounts: Vec = rpc_client .get_program_accounts_with_config( &staking::ID, RpcProgramAccountsConfig { @@ -1389,23 +1383,33 @@ pub async fn claim_rewards( let current_epoch = get_current_epoch(rpc_client).await; - let mut data: Vec<(u64, DynamicPositionArray)> = data - .iter_mut() - .filter_map(|positions| { - let acc = positions.to_dynamic_position_array(); - let exposure = acc - .get_target_exposure(&Target::IntegrityPool, current_epoch) - .unwrap(); - if exposure >= min_staked { - Some((exposure, acc)) - } else { - None - } - }) - .collect(); + let mut position_accounts_with_sufficient_amount_staked: Vec<(u64, DynamicPositionArray)> = + position_accounts + .iter_mut() + .filter_map(|positions| { + let positions = positions.to_dynamic_position_array(); + let exposure = { + let mut exposure = 0; + for i in 0..positions.get_position_capacity() { + if let Some(position) = positions.read_position(i).unwrap() { + if position.target_with_parameters.get_target() == Target::IntegrityPool + { + exposure += position.amount; + } + } + } + exposure + }; + if exposure >= min_staked { + Some((exposure, positions)) + } else { + None + } + }) + .collect(); - data.sort_by_key(|(exposure, _)| *exposure); - data.reverse(); + position_accounts_with_sufficient_amount_staked.sort_by_key(|(exposure, _)| *exposure); + position_accounts_with_sufficient_amount_staked.reverse(); let pool_config = get_pool_config_address(); @@ -1432,12 +1436,15 @@ pub async fn claim_rewards( ) .unwrap(); - println!("Processing {} accounts", data.len()); + println!( + "Processing {} accounts", + position_accounts_with_sufficient_amount_staked.len() + ); // Initialize results vector with true to process all indexes in first round - let mut active_positions = vec![true; data.len()]; + let mut active_positions = vec![true; position_accounts_with_sufficient_amount_staked.len()]; loop { - let futures = data + let futures = position_accounts_with_sufficient_amount_staked .iter() .enumerate() .filter(|(i, _)| active_positions[*i]) @@ -1446,7 +1453,6 @@ pub async fn claim_rewards( rpc_client, signer, positions, - min_reward, current_epoch, &pool_data, &pool_data_address, diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index 5dcb67d4..9e1736b3 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -113,9 +113,8 @@ async fn main() { Action::CloseAllPublisherCaps {} => { close_all_publisher_caps(&rpc_client, keypair.as_ref()).await; } - Action::ClaimRewards { - min_staked, - min_reward, - } => claim_rewards(&rpc_client, keypair.as_ref(), min_staked, min_reward).await, + Action::ClaimRewards { min_staked } => { + claim_rewards(&rpc_client, keypair.as_ref(), min_staked).await + } } } From 98fce5c542f694382dd8f7ad97149dbbab502343 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 17:46:29 +0000 Subject: [PATCH 08/19] checkpoint --- staking/cli/src/instructions.rs | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 3d0b2545..1782fa8f 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1217,7 +1217,7 @@ pub async fn fetch_delegation_record( Ok(delegation_record) } -pub async fn advance_delegation_record<'a>( +pub async fn advance_delegation_records<'a>( rpc_client: &RpcClient, signer: &dyn Signer, positions: &DynamicPositionArray<'a>, @@ -1412,7 +1412,7 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak position_accounts_with_sufficient_amount_staked.reverse(); - let pool_config = get_pool_config_address(); + let pool_config_address = get_pool_config_address(); let PoolConfig { pool_data: pool_data_address, @@ -1420,7 +1420,7 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak .. } = PoolConfig::try_deserialize( &mut rpc_client - .get_account_data(&pool_config) + .get_account_data(&pool_config_address) .await .unwrap() .as_slice(), @@ -1437,19 +1437,21 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak .unwrap(); println!( - "Processing {} accounts", + "Processing {} stake accounts...", position_accounts_with_sufficient_amount_staked.len() ); - // Initialize results vector with true to process all indexes in first round - let mut active_positions = vec![true; position_accounts_with_sufficient_amount_staked.len()]; + + // This vector is used to keep track of which stake accounts have all rewards claimed + let mut has_claimed_all_rewards = + vec![false; position_accounts_with_sufficient_amount_staked.len()]; loop { let futures = position_accounts_with_sufficient_amount_staked .iter() .enumerate() - .filter(|(i, _)| active_positions[*i]) + .filter(|(i, _)| has_claimed_all_rewards[*i]) .map(|(i, (_, positions))| { - advance_delegation_record( + advance_delegation_records( rpc_client, signer, positions, @@ -1457,28 +1459,30 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak &pool_data, &pool_data_address, &pyth_token_mint, - &pool_config, + &pool_config_address, i, ) }) .collect::>(); - let futures = tokio_stream::iter(futures); - let results = futures.buffered(20).collect::>().await; + // Process at most 20 stake accounts concurrently + let succesful_claims = tokio_stream::iter(futures) + .buffered(20) + .collect::>() + .await; - println!("Finished processing {} accounts", results.len()); - // Update active_positions based on results - let mut result_index = 0; - for i in 0..active_positions.len() { - if active_positions[i] { - active_positions[i] = results[result_index]; - result_index += 1; - } - } - - // If no delegations were advanced, we're done - if !results.iter().any(|&active| active) { + // If all stake account have all rewards claimed, we're done + if succesful_claims.iter().all(|&claimed| claimed) { break; + }; + + // Update has_all_rewards_claimed based on results + let mut succesful_claim_index = 0; + for i in 0..has_claimed_all_rewards.len() { + if has_claimed_all_rewards[i] { + has_claimed_all_rewards[i] = succesful_claims[succesful_claim_index]; + succesful_claim_index += 1; + } } From 50cb653203733452d1a92c951f39e953a12e2661 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 17:51:47 +0000 Subject: [PATCH 09/19] checkpoint --- staking/cli/src/instructions.rs | 58 ++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 1782fa8f..b34e9ba5 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1228,10 +1228,10 @@ pub async fn advance_delegation_records<'a>( pool_config: &Pubkey, index: usize, ) -> bool { - let positions_pubkey = positions.acc_info.key; + let positions_address = positions.acc_info.key; - // First collect all potential instruction data - let potential_instructions: Vec<_> = pool_data + // Find all publishers the stake account has exposure to + let position_account_delegates: Vec<_> = pool_data .publishers .iter() .enumerate() @@ -1278,26 +1278,23 @@ pub async fn advance_delegation_records<'a>( }) .collect(); - println!( - "Position {:?} with index {} has {} potential instructions", - positions_pubkey, - index, - potential_instructions.len() - ); - // Fetch all delegation records concurrently - let delegation_records = join_all(potential_instructions.iter().map(|(publisher, _, _)| { - let delegation_record_pubkey = get_delegation_record_address(*publisher, *positions_pubkey); - fetch_delegation_record(rpc_client, delegation_record_pubkey) - })) - .await; + let delegation_records = + join_all(position_account_delegates.iter().map(|(publisher, _, _)| { + let delegation_record_pubkey = + get_delegation_record_address(*publisher, *positions_address); + fetch_delegation_record(rpc_client, delegation_record_pubkey) + })) + .await; // Process results and create instructions let mut instructions = Vec::new(); for ( (publisher, publisher_stake_account_positions, publisher_stake_account_custody), delegation_record, - ) in potential_instructions.into_iter().zip(delegation_records) + ) in position_account_delegates + .into_iter() + .zip(delegation_records) { // Skip if we couldn't fetch the record or if it's already processed for current epoch match delegation_record { @@ -1312,7 +1309,7 @@ pub async fn advance_delegation_records<'a>( } let accounts = integrity_pool::accounts::AdvanceDelegationRecord { - delegation_record: get_delegation_record_address(publisher, *positions_pubkey), + delegation_record: get_delegation_record_address(publisher, *positions_address), payer: signer.pubkey(), pool_config: *pool_config, pool_data: *pool_data_address, @@ -1320,8 +1317,8 @@ pub async fn advance_delegation_records<'a>( publisher, publisher_stake_account_positions, publisher_stake_account_custody, - stake_account_positions: *positions_pubkey, - stake_account_custody: get_stake_account_custody_address(*positions_pubkey), + stake_account_positions: *positions_address, + stake_account_custody: get_stake_account_custody_address(*positions_address), system_program: system_program::ID, token_program: spl_token::ID, }; @@ -1339,7 +1336,7 @@ pub async fn advance_delegation_records<'a>( if !instructions.is_empty() { println!( "Advancing delegation record for pubkey: {:?}, number of instructions: {}", - positions_pubkey.to_string(), + positions_address.to_string(), instructions.len(), ); @@ -1478,15 +1475,22 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak // Update has_all_rewards_claimed based on results let mut succesful_claim_index = 0; - for i in 0..has_claimed_all_rewards.len() { - if has_claimed_all_rewards[i] { - has_claimed_all_rewards[i] = succesful_claims[succesful_claim_index]; + has_claimed_all_rewards + .iter_mut() + .filter(|claimed| !**claimed) + .for_each(|claimed| { + *claimed = succesful_claims[succesful_claim_index]; succesful_claim_index += 1; - } - } - + }); - println!("We will retry after 10 seconds!"); + let remaining_accounts = has_claimed_all_rewards + .iter() + .filter(|claimed| !**claimed) + .count(); + println!( + "We will retry after 10 seconds! {} accounts remaining", + remaining_accounts + ); tokio::time::sleep(tokio::time::Duration::from_secs(10)).await; } } From f846f40934bcb44abbd6c99fb5ab451c93566236 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 17:59:45 +0000 Subject: [PATCH 10/19] more cleanup --- staking/cli/src/instructions.rs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index b34e9ba5..00f06814 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1199,22 +1199,21 @@ pub async fn save_stake_accounts_snapshot(rpc_client: &RpcClient) { } } -pub struct FetchError {} pub async fn fetch_delegation_record( rpc_client: &RpcClient, - key: Pubkey, -) -> Result { - let delegation_record = DelegationRecord::try_deserialize( + positions_address: &Pubkey, + publisher: &Pubkey, +) -> Option { + let delegation_record_key = get_delegation_record_address(*publisher, *positions_address); + DelegationRecord::try_deserialize( &mut (rpc_client - .get_account_data(&key) + .get_account_data(&delegation_record_key) .await - .map_err(|_| FetchError {})? + .unwrap() .as_slice()), ) - .map_err(|_| FetchError {})?; - - Ok(delegation_record) + .ok() } pub async fn advance_delegation_records<'a>( @@ -1281,9 +1280,7 @@ pub async fn advance_delegation_records<'a>( // Fetch all delegation records concurrently let delegation_records = join_all(position_account_delegates.iter().map(|(publisher, _, _)| { - let delegation_record_pubkey = - get_delegation_record_address(*publisher, *positions_address); - fetch_delegation_record(rpc_client, delegation_record_pubkey) + fetch_delegation_record(rpc_client, positions_address, publisher) })) .await; @@ -1297,15 +1294,12 @@ pub async fn advance_delegation_records<'a>( .zip(delegation_records) { // Skip if we couldn't fetch the record or if it's already processed for current epoch - match delegation_record { - Ok(delegation_record) => { - if delegation_record.last_epoch == current_epoch { - continue; - } - } - Err(_) => { + if let Some(delegation_record) = delegation_record { + if delegation_record.last_epoch == current_epoch { continue; } + } else { + continue; } let accounts = integrity_pool::accounts::AdvanceDelegationRecord { From aabb07a5881888742358c7a55e5fe5aec78a1c5a Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 18:02:22 +0000 Subject: [PATCH 11/19] finished cleanup --- staking/cli/src/instructions.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 00f06814..d3e149f1 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1335,13 +1335,16 @@ pub async fn advance_delegation_records<'a>( ); for chunk in instructions.chunks(5) { - process_transaction(rpc_client, chunk, &[signer]) + if process_transaction(rpc_client, chunk, &[signer]) .await - .unwrap(); + .is_err() + { + return false; // Return false if any transaction fails, this account is still + // pending + } } - return true; // Instructions were processed } - false // No instructions were processed + true // No instruction were needed, this stake account is already done } pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_staked: u64) { From 19bd8d76dc557a7f81cfa75fdedf986bd2bf36cb Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 19:19:40 +0000 Subject: [PATCH 12/19] checkpoint --- staking/Cargo.lock | 140 ++++++++++++++++---------------- staking/cli/src/instructions.rs | 37 +++++---- 2 files changed, 90 insertions(+), 87 deletions(-) diff --git a/staking/Cargo.lock b/staking/Cargo.lock index d4d30632..d876903e 100644 --- a/staking/Cargo.lock +++ b/staking/Cargo.lock @@ -339,9 +339,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "ark-bn254" @@ -565,7 +565,7 @@ checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -665,9 +665,9 @@ dependencies = [ [[package]] name = "blake3" -version = "1.5.1" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30cca6d3674597c30ddf2c587bf8d9d65c9a84d2326d941cc79c9842dfe0ef52" +checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" dependencies = [ "arrayref", "arrayvec", @@ -768,7 +768,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", "syn_derive", ] @@ -892,22 +892,22 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc8b54b395f2fcfbb3d90c47b01c7f444d94d05bdeb775811dec868ac3bbc26" +checksum = "3fa76293b4f7bb636ab88fd78228235b5248b4d05cc589aed610f954af5d7c7a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -1248,7 +1248,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -1259,7 +1259,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -1412,7 +1412,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -1435,7 +1435,7 @@ checksum = "a6cbae11b3de8fce2a456e8ea3dada226b35fe791f0dc1d360c0941f0bb681f3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -1523,7 +1523,7 @@ checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -1697,7 +1697,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -2217,10 +2217,11 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -2641,7 +2642,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -2733,7 +2734,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -2745,7 +2746,7 @@ dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -2807,7 +2808,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -3049,9 +3050,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -3135,7 +3136,7 @@ checksum = "9e2e25ee72f5b24d773cae88422baddefff7714f97aab68d96fe2b6fc4a28fb2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -3625,7 +3626,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -3651,7 +3652,7 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -3695,9 +3696,9 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" -version = "1.0.209" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" dependencies = [ "serde_derive", ] @@ -3713,13 +3714,13 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.217" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -3730,14 +3731,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "itoa", "memchr", @@ -3785,7 +3786,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -4195,7 +4196,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -4589,7 +4590,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -4894,7 +4895,7 @@ checksum = "07fd7858fc4ff8fb0e34090e41d7eb06a823e1057945c26d480bfc21d2338a93" dependencies = [ "quote", "spl-discriminator-syn 0.1.2", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -4905,7 +4906,7 @@ checksum = "d9e8418ea6269dcfb01c712f0444d2c75542c04448b480e87de59d2865edc750" dependencies = [ "quote", "spl-discriminator-syn 0.2.0", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -4917,7 +4918,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.8", - "syn 2.0.77", + "syn 2.0.95", "thiserror", ] @@ -4930,7 +4931,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.8", - "syn 2.0.77", + "syn 2.0.95", "thiserror", ] @@ -5053,7 +5054,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.8", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -5065,7 +5066,7 @@ dependencies = [ "proc-macro2", "quote", "sha2 0.10.8", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -5346,9 +5347,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "46f71c0377baf4ef1cc3e3402ded576dccc315800fbc62dfc7fe04b009773b4a" dependencies = [ "proc-macro2", "quote", @@ -5364,7 +5365,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -5445,22 +5446,22 @@ checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -5554,7 +5555,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -5696,7 +5697,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -5910,9 +5911,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396" dependencies = [ "cfg-if", "once_cell", @@ -5921,16 +5922,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79" dependencies = [ "bumpalo", "log", - "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", "wasm-bindgen-shared", ] @@ -5948,9 +5948,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -5958,22 +5958,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "web-sys" @@ -6380,7 +6380,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] @@ -6400,7 +6400,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.95", ] [[package]] diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index d3e149f1..818b22b4 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1206,16 +1206,22 @@ pub async fn fetch_delegation_record( publisher: &Pubkey, ) -> Option { let delegation_record_key = get_delegation_record_address(*publisher, *positions_address); - DelegationRecord::try_deserialize( - &mut (rpc_client - .get_account_data(&delegation_record_key) - .await - .unwrap() - .as_slice()), - ) - .ok() + + let response = rpc_client.get_account_data(&delegation_record_key).await; + + match response { + Ok(data) => Some(DelegationRecord::try_deserialize(&mut data.as_slice()).unwrap()), + Err(err) => { + if err.to_string().contains("AccountNotFound") { + None + } else { + panic!("Error fetching delegation record: {:?}", err); + } + } + } } + pub async fn advance_delegation_records<'a>( rpc_client: &RpcClient, signer: &dyn Signer, @@ -1225,7 +1231,6 @@ pub async fn advance_delegation_records<'a>( pool_data_address: &Pubkey, pyth_token_mint: &Pubkey, pool_config: &Pubkey, - index: usize, ) -> bool { let positions_address = positions.acc_info.key; @@ -1293,13 +1298,11 @@ pub async fn advance_delegation_records<'a>( .into_iter() .zip(delegation_records) { - // Skip if we couldn't fetch the record or if it's already processed for current epoch + // Skip if the delegation record is already up to date if let Some(delegation_record) = delegation_record { if delegation_record.last_epoch == current_epoch { continue; } - } else { - continue; } let accounts = integrity_pool::accounts::AdvanceDelegationRecord { @@ -1329,9 +1332,9 @@ pub async fn advance_delegation_records<'a>( // Process instructions in chunks of 5 if !instructions.is_empty() { println!( - "Advancing delegation record for pubkey: {:?}, number of instructions: {}", - positions_address.to_string(), + "Advancing {} delegation records for stake account {}", instructions.len(), + positions_address, ); for chunk in instructions.chunks(5) { @@ -1343,6 +1346,7 @@ pub async fn advance_delegation_records<'a>( // pending } } + return false; } true // No instruction were needed, this stake account is already done } @@ -1443,8 +1447,8 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak let futures = position_accounts_with_sufficient_amount_staked .iter() .enumerate() - .filter(|(i, _)| has_claimed_all_rewards[*i]) - .map(|(i, (_, positions))| { + .filter(|(i, _)| !has_claimed_all_rewards[*i]) + .map(|(_, (_, positions))| { advance_delegation_records( rpc_client, signer, @@ -1454,7 +1458,6 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak &pool_data_address, &pyth_token_mint, &pool_config_address, - i, ) }) .collect::>(); From a33c3a02e603fd54bd6464d2d3b2a0f15c7d18ed Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 19:29:56 +0000 Subject: [PATCH 13/19] clean --- staking/cli/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index 9e1736b3..40b94dd5 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -50,14 +50,14 @@ async fn main() { y, slash_custody, ) - .await; + .await } Action::Advance { hermes_url, wormhole, } => { fetch_publisher_caps_and_advance(&rpc_client, keypair.as_ref(), wormhole, hermes_url) - .await; + .await } Action::InitializePoolRewardCustody {} => { initialize_reward_custody(&rpc_client, keypair.as_ref()).await; From bb6e5024e392ff00e0c30e444816e3181c7ef0a0 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 19:53:48 +0000 Subject: [PATCH 14/19] add warning --- staking/cli/src/main.rs | 6 + staking/target/idl/profile.json | 106 - staking/target/idl/staking.json | 3119 ------------------------ staking/target/idl/wallet_tester.json | 48 - staking/target/types/profile.ts | 112 - staking/target/types/staking.ts | 3125 ------------------------- staking/target/types/wallet_tester.ts | 54 - 7 files changed, 6 insertions(+), 6564 deletions(-) delete mode 100644 staking/target/idl/profile.json delete mode 100644 staking/target/idl/staking.json delete mode 100644 staking/target/idl/wallet_tester.json delete mode 100644 staking/target/types/profile.ts delete mode 100644 staking/target/types/staking.ts delete mode 100644 staking/target/types/wallet_tester.ts diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index 40b94dd5..54def28c 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -33,6 +33,12 @@ async fn main() { rpc_url, action, } = Cli::parse(); + + if cfg!(debug_assertions) { + panic!("These are issues with running the CLI in debug mode, and it might lead to segmentation fault, please use cargo run --release"); + } + + let rpc_client = RpcClient::new_with_commitment(rpc_url, CommitmentConfig::confirmed()); match action { diff --git a/staking/target/idl/profile.json b/staking/target/idl/profile.json deleted file mode 100644 index ac2cebf4..00000000 --- a/staking/target/idl/profile.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "address": "prfmVhiQTN5Spgoxa8uZJba35V1s7XXReqbBiqPDWeJ", - "metadata": { - "name": "profile", - "version": "1.0.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "update_identity", - "discriminator": [ - 130, - 54, - 88, - 104, - 222, - 124, - 238, - 252 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "identity_account", - "writable": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "identity", - "type": { - "defined": { - "name": "Identity" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "IdentityAccount", - "discriminator": [ - 194, - 90, - 181, - 160, - 182, - 206, - 116, - 158 - ] - } - ], - "types": [ - { - "name": "Identity", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Evm", - "fields": [ - { - "name": "pubkey", - "type": { - "option": { - "array": [ - "u8", - 20 - ] - } - } - } - ] - } - ] - } - }, - { - "name": "IdentityAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "identity", - "type": { - "defined": { - "name": "Identity" - } - } - } - ] - } - } - ] -} \ No newline at end of file diff --git a/staking/target/idl/staking.json b/staking/target/idl/staking.json deleted file mode 100644 index 4c2c4047..00000000 --- a/staking/target/idl/staking.json +++ /dev/null @@ -1,3119 +0,0 @@ -{ - "address": "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ", - "metadata": { - "name": "staking", - "version": "2.0.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "accept_split", - "docs": [ - "* A split request can only be accepted by the `pda_authority` from\n * the config account. If accepted, `amount` tokens are transferred to a new stake account\n * owned by the `recipient` and the split request is reset (by setting `amount` to 0).\n * The recipient of a transfer can't vote during the epoch of the transfer.\n *\n * The `pda_authority` must explicitly approve both the amount of tokens and recipient, and\n * these parameters must match the request (in the `split_request` account)." - ], - "discriminator": [ - 177, - 172, - 17, - 93, - 193, - 86, - 54, - 222 - ], - "accounts": [ - { - "name": "pda_authority", - "writable": true, - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "source_stake_account_positions", - "writable": true - }, - { - "name": "source_stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "source_stake_account_positions" - } - ] - } - }, - { - "name": "source_stake_account_split_request", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 108, - 105, - 116, - 95, - 114, - 101, - 113, - 117, - 101, - 115, - 116 - ] - }, - { - "kind": "account", - "path": "source_stake_account_positions" - } - ] - } - }, - { - "name": "source_stake_account_custody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "source_stake_account_positions" - } - ] - } - }, - { - "name": "source_custody_authority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "source_stake_account_positions" - } - ] - } - }, - { - "name": "new_stake_account_positions", - "writable": true - }, - { - "name": "new_stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "new_stake_account_positions" - } - ] - } - }, - { - "name": "new_stake_account_custody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "new_stake_account_positions" - } - ] - } - }, - { - "name": "new_custody_authority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "new_stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "pyth_token_mint", - "relations": [ - "config" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - }, - { - "name": "advance_clock", - "discriminator": [ - 52, - 57, - 147, - 111, - 56, - 227, - 33, - 127 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "seconds", - "type": "i64" - } - ] - }, - { - "name": "close_position", - "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 - ], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions", - "writable": true - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_custody", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "target_account", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "pool_authority", - "signer": true, - "optional": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "index", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "target_with_parameters", - "type": { - "defined": { - "name": "TargetWithParameters" - } - } - } - ] - }, - { - "name": "create_position", - "docs": [ - "Creates a position", - "Looks for the first available place in the array, fails if array is full", - "Computes risk and fails if new positions exceed risk limit" - ], - "discriminator": [ - 48, - 215, - 197, - 153, - 96, - 203, - 180, - 133 - ], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions", - "writable": true - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_custody", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "target_account", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "pool_authority", - "signer": true, - "optional": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "target_with_parameters", - "type": { - "defined": { - "name": "TargetWithParameters" - } - } - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "create_stake_account", - "docs": [ - "Trustless instruction that creates a stake account for a user", - "The main account i.e. the position accounts needs to be initialized outside of the program", - "otherwise we run into stack limits" - ], - "discriminator": [ - 105, - 24, - 131, - 19, - 201, - 250, - 157, - 73 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "stake_account_positions", - "writable": true - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_custody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "custody_authority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "pyth_token_mint", - "relations": [ - "config" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "lock", - "type": { - "defined": { - "name": "VestingSchedule" - } - } - } - ] - }, - { - "name": "create_target", - "discriminator": [ - 76, - 144, - 128, - 239, - 121, - 210, - 123, - 39 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "governance_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "target_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "create_voter_record", - "discriminator": [ - 3, - 12, - 113, - 222, - 177, - 4, - 152, - 165 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "stake_account_positions" - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "voter_record", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 101, - 114, - 95, - 119, - 101, - 105, - 103, - 104, - 116 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "export_position_type", - "discriminator": [ - 219, - 172, - 149, - 212, - 103, - 230, - 164, - 179 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "config_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "_position", - "type": { - "defined": { - "name": "Position" - } - } - } - ] - }, - { - "name": "init_config", - "discriminator": [ - 23, - 235, - 115, - 232, - 168, - 96, - 1, - 231 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "config_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "global_config", - "type": { - "defined": { - "name": "GlobalConfig" - } - } - } - ] - }, - { - "name": "join_dao_llc", - "docs": [ - "* Accept to join the DAO LLC\n * This must happen before create_position or update_voter_weight\n * The user signs a hash of the agreement and the program checks that the hash matches the\n * agreement" - ], - "discriminator": [ - 79, - 241, - 203, - 177, - 232, - 143, - 124, - 14 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions" - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "_agreement_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "merge_target_positions", - "discriminator": [ - 21, - 136, - 57, - 2, - 204, - 219, - 242, - 141 - ], - "accounts": [ - { - "name": "owner", - "docs": [ - "CHECK : This AccountInfo is safe because it's checked against stake_account_metadata" - ], - "writable": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions", - "writable": true - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "pool_authority", - "signer": true, - "optional": true - } - ], - "args": [ - { - "name": "target_with_parameters", - "type": { - "defined": { - "name": "TargetWithParameters" - } - } - } - ] - }, - { - "name": "recover_account", - "docs": [ - "Recovers a user's `stake account` ownership by transferring ownership\n * from a token account to the `owner` of that token account.\n *\n * This functionality addresses the scenario where a user mistakenly\n * created a stake account using their token account address as the owner." - ], - "discriminator": [ - 240, - 223, - 246, - 118, - 26, - 121, - 34, - 128 - ], - "accounts": [ - { - "name": "governance_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "owner", - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions", - "writable": true - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "voter_record", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 101, - 114, - 95, - 119, - 101, - 105, - 103, - 104, - 116 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "request_split", - "docs": [ - "* Any user of the staking program can request to split their account and\n * give a part of it to another user.\n * This is mostly useful to transfer unvested tokens. Each user can only have one active\n * request at a time.\n * In the first step, the user requests a split by specifying the `amount` of tokens\n * they want to give to the other user and the `recipient`'s pubkey." - ], - "discriminator": [ - 133, - 146, - 228, - 165, - 251, - 207, - 146, - 23 - ], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions" - }, - { - "name": "stake_account_metadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_split_request", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 108, - 105, - 116, - 95, - 114, - 101, - 113, - 117, - 101, - 115, - 116 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - }, - { - "name": "slash_account", - "discriminator": [ - 185, - 97, - 8, - 208, - 118, - 205, - 166, - 2 - ], - "accounts": [ - { - "name": "pool_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "publisher", - "docs": [ - "CHECK : This AccountInfo is just used to construct the target that will get slashed" - ] - }, - { - "name": "stake_account_positions", - "writable": true - }, - { - "name": "stake_account_metadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_custody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "governance_target_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "destination", - "writable": true - }, - { - "name": "custody_authority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [ - { - "name": "slash_ratio", - "type": "u64" - } - ] - }, - { - "name": "update_agreement_hash", - "discriminator": [ - 86, - 232, - 181, - 137, - 158, - 110, - 129, - 238 - ], - "accounts": [ - { - "name": "governance_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "agreement_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "update_governance_authority", - "discriminator": [ - 11, - 185, - 227, - 55, - 39, - 32, - 168, - 14 - ], - "accounts": [ - { - "name": "governance_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "new_authority", - "type": "pubkey" - } - ] - }, - { - "name": "update_max_voter_weight", - "discriminator": [ - 248, - 36, - 229, - 234, - 11, - 132, - 145, - 20 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "max_voter_record", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 97, - 120, - 95, - 118, - 111, - 116, - 101, - 114 - ] - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "update_pda_authority", - "discriminator": [ - 178, - 112, - 199, - 196, - 59, - 40, - 140, - 61 - ], - "accounts": [ - { - "name": "pda_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "new_authority", - "type": "pubkey" - } - ] - }, - { - "name": "update_pool_authority", - "discriminator": [ - 160, - 162, - 113, - 9, - 99, - 187, - 23, - 239 - ], - "accounts": [ - { - "name": "governance_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "pool_authority", - "type": "pubkey" - } - ] - }, - { - "name": "update_token_list_time", - "discriminator": [ - 38, - 217, - 99, - 222, - 253, - 253, - 31, - 83 - ], - "accounts": [ - { - "name": "governance_authority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "token_list_time", - "type": { - "option": "i64" - } - } - ] - }, - { - "name": "update_voter_weight", - "discriminator": [ - 92, - 35, - 133, - 94, - 230, - 70, - 14, - 157 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "stake_account_positions" - }, - { - "name": "stake_account_metadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_custody", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "voter_record", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 101, - 114, - 95, - 119, - 101, - 105, - 103, - 104, - 116 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "governance_target", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "action", - "type": { - "defined": { - "name": "VoterWeightAction" - } - } - } - ] - }, - { - "name": "withdraw_stake", - "discriminator": [ - 153, - 8, - 22, - 138, - 105, - 176, - 87, - 66 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "stake_account_metadata" - ] - }, - { - "name": "destination", - "writable": true - }, - { - "name": "stake_account_positions" - }, - { - "name": "stake_account_metadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "stake_account_custody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "custody_authority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "stake_account_positions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - } - ], - "accounts": [ - { - "name": "GlobalConfig", - "discriminator": [ - 149, - 8, - 156, - 202, - 160, - 252, - 176, - 217 - ] - }, - { - "name": "MaxVoterWeightRecord", - "discriminator": [ - 157, - 95, - 242, - 151, - 16, - 98, - 26, - 118 - ] - }, - { - "name": "PositionData", - "discriminator": [ - 85, - 195, - 241, - 79, - 124, - 192, - 79, - 11 - ] - }, - { - "name": "SplitRequest", - "discriminator": [ - 80, - 85, - 187, - 143, - 62, - 147, - 234, - 248 - ] - }, - { - "name": "StakeAccountMetadataV2", - "discriminator": [ - 192, - 51, - 203, - 19, - 76, - 177, - 136, - 97 - ] - }, - { - "name": "TargetMetadata", - "discriminator": [ - 157, - 23, - 139, - 117, - 181, - 44, - 197, - 130 - ] - }, - { - "name": "VoterWeightRecord", - "discriminator": [ - 46, - 249, - 155, - 75, - 153, - 248, - 116, - 9 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "TooMuchExposureToIntegrityPool", - "msg": "Too much exposure to integrity pool" - }, - { - "code": 6001, - "name": "TooMuchExposureToGovernance", - "msg": "Too much exposure to governance" - }, - { - "code": 6002, - "name": "TokensNotYetVested", - "msg": "Tokens not yet vested" - }, - { - "code": 6003, - "name": "RiskLimitExceeded", - "msg": "Risk limit exceeded" - }, - { - "code": 6004, - "name": "TooManyPositions", - "msg": "Number of position limit reached" - }, - { - "code": 6005, - "name": "PositionNotInUse", - "msg": "Position not in use" - }, - { - "code": 6006, - "name": "CreatePositionWithZero", - "msg": "New position needs to have positive balance" - }, - { - "code": 6007, - "name": "ClosePositionWithZero", - "msg": "Closing a position of 0 is not allowed" - }, - { - "code": 6008, - "name": "InvalidPosition", - "msg": "Invalid product/publisher pair" - }, - { - "code": 6009, - "name": "AmountBiggerThanPosition", - "msg": "Amount to unlock bigger than position" - }, - { - "code": 6010, - "name": "AlreadyUnlocking", - "msg": "Position already unlocking" - }, - { - "code": 6011, - "name": "ZeroEpochDuration", - "msg": "Epoch duration is 0" - }, - { - "code": 6012, - "name": "WithdrawToUnauthorizedAccount", - "msg": "Owner needs to own destination account" - }, - { - "code": 6013, - "name": "InsufficientWithdrawableBalance", - "msg": "Insufficient balance to cover the withdrawal" - }, - { - "code": 6014, - "name": "WrongTarget", - "msg": "Target in position doesn't match target in instruction data" - }, - { - "code": 6015, - "name": "GenericOverflow", - "msg": "An arithmetic operation unexpectedly overflowed" - }, - { - "code": 6016, - "name": "NegativeBalance", - "msg": "Locked balance must be positive" - }, - { - "code": 6017, - "name": "Frozen", - "msg": "Protocol is frozen" - }, - { - "code": 6018, - "name": "DebuggingOnly", - "msg": "Not allowed when not debugging" - }, - { - "code": 6019, - "name": "ProposalTooLong", - "msg": "Proposal too long" - }, - { - "code": 6020, - "name": "InvalidVotingEpoch", - "msg": "Voting epoch is either too old or hasn't started" - }, - { - "code": 6021, - "name": "ProposalNotActive", - "msg": "Voting hasn't started" - }, - { - "code": 6022, - "name": "NoRemainingAccount", - "msg": "Extra governance account required" - }, - { - "code": 6023, - "name": "Unauthorized", - "msg": "Unauthorized caller" - }, - { - "code": 6024, - "name": "AccountUpgradeFailed", - "msg": "Precondition to upgrade account violated" - }, - { - "code": 6025, - "name": "NotImplemented", - "msg": "Not implemented" - }, - { - "code": 6026, - "name": "PositionSerDe", - "msg": "Error deserializing position" - }, - { - "code": 6027, - "name": "PositionOutOfBounds", - "msg": "Position out of bounds" - }, - { - "code": 6028, - "name": "VoteDuringTransferEpoch", - "msg": "Can't vote during an account's transfer epoch" - }, - { - "code": 6029, - "name": "NotLlcMember", - "msg": "You need to be an LLC member to perform this action" - }, - { - "code": 6030, - "name": "InvalidLlcAgreement", - "msg": "Invalid LLC agreement" - }, - { - "code": 6031, - "name": "SplitZeroTokens", - "msg": "Can't split 0 tokens from an account" - }, - { - "code": 6032, - "name": "SplitTooManyTokens", - "msg": "Can't split more tokens than are in the account" - }, - { - "code": 6033, - "name": "SplitWithStake", - "msg": "Can't split a token account with staking positions. Unstake your tokens first." - }, - { - "code": 6034, - "name": "InvalidApproval", - "msg": "The approval arguments do not match the split request." - }, - { - "code": 6035, - "name": "RecoverWithStake", - "msg": "Can't recover account with staking positions. Unstake your tokens first." - }, - { - "code": 6036, - "name": "InvalidPoolAuthority", - "msg": "The pool authority hasn't been passed or doesn't match the target" - }, - { - "code": 6037, - "name": "MissingTargetAccount", - "msg": "The target account is missing" - }, - { - "code": 6038, - "name": "InvalidSlashRatio", - "msg": "The slash ratio should be between 0 and 1" - }, - { - "code": 6039, - "name": "UnexpectedTargetAccount", - "msg": "The target account is only expected when dealing with the governance target" - }, - { - "code": 6040, - "name": "Other", - "msg": "Other" - } - ], - "types": [ - { - "name": "GlobalConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "governance_authority", - "type": "pubkey" - }, - { - "name": "pyth_token_mint", - "type": "pubkey" - }, - { - "name": "pyth_governance_realm", - "type": "pubkey" - }, - { - "name": "removed_unlocking_duration", - "type": "u8" - }, - { - "name": "epoch_duration", - "type": "u64" - }, - { - "name": "freeze", - "type": "bool" - }, - { - "name": "pda_authority", - "type": "pubkey" - }, - { - "name": "governance_program", - "type": "pubkey" - }, - { - "name": "pyth_token_list_time", - "docs": [ - "Once the pyth token is listed, governance can update the config to set this value.", - "Once this value is set, vesting schedules that depend on the token list date can start", - "vesting." - ], - "type": { - "option": "i64" - } - }, - { - "name": "agreement_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "mock_clock_time", - "type": "i64" - }, - { - "name": "pool_authority", - "type": "pubkey" - } - ] - } - }, - { - "name": "MaxVoterWeightRecord", - "docs": [ - "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/max_voter_weight.rs" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "realm", - "docs": [ - "The Realm the MaxVoterWeightRecord belongs to" - ], - "type": "pubkey" - }, - { - "name": "governing_token_mint", - "docs": [ - "Governing Token Mint the MaxVoterWeightRecord is associated with", - "Note: The addin can take deposits of any tokens and is not restricted to the community or", - "council tokens only" - ], - "type": "pubkey" - }, - { - "name": "max_voter_weight", - "docs": [ - "Max voter weight", - "The max voter weight provided by the addin for the given realm and governing_token_mint" - ], - "type": "u64" - }, - { - "name": "max_voter_weight_expiry", - "docs": [ - "The slot when the max voting weight expires", - "It should be set to None if the weight never expires", - "If the max vote weight decays with time, for example for time locked based weights, then", - "the expiry must be set As a pattern Revise instruction to update the max weight should", - "be invoked before governance instruction within the same transaction and the expiry set", - "to the current slot to provide up to date weight" - ], - "type": { - "option": "u64" - } - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future versions" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } - }, - { - "name": "Position", - "docs": [ - "This represents a staking position, i.e. an amount that someone has staked to a particular", - "target. This is one of the core pieces of our staking design, and stores all", - "of the state related to a position The voting position is a position where the", - "target_with_parameters is VOTING" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "activation_epoch", - "type": "u64" - }, - { - "name": "unlocking_start", - "type": { - "option": "u64" - } - }, - { - "name": "target_with_parameters", - "type": { - "defined": { - "name": "TargetWithParameters" - } - } - } - ] - } - }, - { - "name": "PositionData", - "docs": [ - "The header of DynamicPositionArray" - ], - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "SplitRequest", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "StakeAccountMetadataV2", - "docs": [ - "This is the metadata account for each staker", - "It is derived from the positions account with seeds \"stake_metadata\" and the positions account", - "pubkey It stores some PDA bumps, the owner of the account and the vesting schedule" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "metadata_bump", - "type": "u8" - }, - { - "name": "custody_bump", - "type": "u8" - }, - { - "name": "authority_bump", - "type": "u8" - }, - { - "name": "voter_bump", - "type": "u8" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "lock", - "type": { - "defined": { - "name": "VestingSchedule" - } - } - }, - { - "name": "next_index", - "type": "u8" - }, - { - "name": "_deprecated", - "type": { - "option": "u64" - } - }, - { - "name": "signed_agreement_hash", - "type": { - "option": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - }, - { - "name": "TargetMetadata", - "docs": [ - "This represents a target that users can stake to", - "Currently we store the last time the target account was updated, the current locked balance", - "and the amount by which the locked balance will change in the next epoch" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "last_update_at", - "type": "u64" - }, - { - "name": "prev_epoch_locked", - "type": "u64" - }, - { - "name": "locked", - "type": "u64" - }, - { - "name": "delta_locked", - "type": "i64" - } - ] - } - }, - { - "name": "TargetWithParameters", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Voting" - }, - { - "name": "IntegrityPool", - "fields": [ - { - "name": "publisher", - "type": "pubkey" - } - ] - } - ] - } - }, - { - "name": "VestingSchedule", - "docs": [ - "Represents how a given initial balance vests over time", - "It is unit-less, but units must be consistent" - ], - "repr": { - "kind": "rust" - }, - "type": { - "kind": "enum", - "variants": [ - { - "name": "FullyVested" - }, - { - "name": "PeriodicVesting", - "fields": [ - { - "name": "initial_balance", - "type": "u64" - }, - { - "name": "start_date", - "type": "i64" - }, - { - "name": "period_duration", - "type": "u64" - }, - { - "name": "num_periods", - "type": "u64" - } - ] - }, - { - "name": "PeriodicVestingAfterListing", - "fields": [ - { - "name": "initial_balance", - "type": "u64" - }, - { - "name": "period_duration", - "type": "u64" - }, - { - "name": "num_periods", - "type": "u64" - } - ] - } - ] - } - }, - { - "name": "VoterWeightAction", - "docs": [ - "The governance action VoterWeight is evaluated for" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "CastVote" - }, - { - "name": "CommentProposal" - }, - { - "name": "CreateGovernance" - }, - { - "name": "CreateProposal" - }, - { - "name": "SignOffProposal" - } - ] - } - }, - { - "name": "VoterWeightRecord", - "docs": [ - "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/voter_weight.rs", - "Anchor has a macro (vote_weight_record) that is supposed to generate this struct, but it doesn't", - "work because the error's macros are not updated for anchor 0.22.0.", - "Even if it did work, the type wouldn't show up in the IDL. SPL doesn't produce an API, which", - "means that means we'd need the equivalent of this code on the client side.", - "If Anchor fixes the macro, we might consider changing it" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "realm", - "docs": [ - "VoterWeightRecord discriminator sha256(\"account:VoterWeightRecord\")[..8]", - "Note: The discriminator size must match the addin implementing program discriminator size", - "to ensure it's stored in the private space of the account data and it's unique", - "pub account_discriminator: [u8; 8],", - "The Realm the VoterWeightRecord belongs to" - ], - "type": "pubkey" - }, - { - "name": "governing_token_mint", - "docs": [ - "Governing Token Mint the VoterWeightRecord is associated with", - "Note: The addin can take deposits of any tokens and is not restricted to the community or", - "council tokens only" - ], - "type": "pubkey" - }, - { - "name": "governing_token_owner", - "docs": [ - "The owner of the governing token and voter", - "This is the actual owner (voter) and corresponds to TokenOwnerRecord.governing_token_owner" - ], - "type": "pubkey" - }, - { - "name": "voter_weight", - "docs": [ - "Voter's weight", - "The weight of the voter provided by the addin for the given realm, governing_token_mint and", - "governing_token_owner (voter)" - ], - "type": "u64" - }, - { - "name": "voter_weight_expiry", - "docs": [ - "The slot when the voting weight expires", - "It should be set to None if the weight never expires", - "If the voter weight decays with time, for example for time locked based weights, then the", - "expiry must be set As a common pattern Revise instruction to update the weight should", - "be invoked before governance instruction within the same transaction and the expiry set", - "to the current slot to provide up to date weight" - ], - "type": { - "option": "u64" - } - }, - { - "name": "weight_action", - "docs": [ - "The governance action the voter's weight pertains to", - "It allows to provided voter's weight specific to the particular action the weight is", - "evaluated for When the action is provided then the governance program asserts the", - "executing action is the same as specified by the addin" - ], - "type": { - "option": { - "defined": { - "name": "VoterWeightAction" - } - } - } - }, - { - "name": "weight_action_target", - "docs": [ - "The target the voter's weight action pertains to", - "It allows to provided voter's weight specific to the target the weight is evaluated for", - "For example when addin supplies weight to vote on a particular proposal then it must", - "specify the proposal as the action target When the target is provided then the", - "governance program asserts the target is the same as specified by the addin" - ], - "type": { - "option": "pubkey" - } - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future versions" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } - } - ] -} \ No newline at end of file diff --git a/staking/target/idl/wallet_tester.json b/staking/target/idl/wallet_tester.json deleted file mode 100644 index e8ac59df..00000000 --- a/staking/target/idl/wallet_tester.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "address": "tstPARXbQ5yxVkRU2UcZRbYphzbUEW6t5ihzpLaafgz", - "metadata": { - "name": "wallet_tester", - "version": "1.0.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "test", - "discriminator": [ - 163, - 36, - 134, - 53, - 232, - 223, - 146, - 222 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "test_receipt", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "payer" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - } - ] -} \ No newline at end of file diff --git a/staking/target/types/profile.ts b/staking/target/types/profile.ts deleted file mode 100644 index 7ccfe560..00000000 --- a/staking/target/types/profile.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/profile.json`. - */ -export type Profile = { - "address": "prfmVhiQTN5Spgoxa8uZJba35V1s7XXReqbBiqPDWeJ", - "metadata": { - "name": "profile", - "version": "1.0.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "updateIdentity", - "discriminator": [ - 130, - 54, - 88, - 104, - 222, - 124, - 238, - 252 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "identityAccount", - "writable": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "identity", - "type": { - "defined": { - "name": "identity" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "identityAccount", - "discriminator": [ - 194, - 90, - 181, - 160, - 182, - 206, - 116, - 158 - ] - } - ], - "types": [ - { - "name": "identity", - "type": { - "kind": "enum", - "variants": [ - { - "name": "evm", - "fields": [ - { - "name": "pubkey", - "type": { - "option": { - "array": [ - "u8", - 20 - ] - } - } - } - ] - } - ] - } - }, - { - "name": "identityAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "identity", - "type": { - "defined": { - "name": "identity" - } - } - } - ] - } - } - ] -}; diff --git a/staking/target/types/staking.ts b/staking/target/types/staking.ts deleted file mode 100644 index a4c70c29..00000000 --- a/staking/target/types/staking.ts +++ /dev/null @@ -1,3125 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/staking.json`. - */ -export type Staking = { - "address": "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ", - "metadata": { - "name": "staking", - "version": "2.0.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "acceptSplit", - "docs": [ - "* A split request can only be accepted by the `pda_authority` from\n * the config account. If accepted, `amount` tokens are transferred to a new stake account\n * owned by the `recipient` and the split request is reset (by setting `amount` to 0).\n * The recipient of a transfer can't vote during the epoch of the transfer.\n *\n * The `pda_authority` must explicitly approve both the amount of tokens and recipient, and\n * these parameters must match the request (in the `split_request` account)." - ], - "discriminator": [ - 177, - 172, - 17, - 93, - 193, - 86, - 54, - 222 - ], - "accounts": [ - { - "name": "pdaAuthority", - "writable": true, - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "sourceStakeAccountPositions", - "writable": true - }, - { - "name": "sourceStakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "sourceStakeAccountPositions" - } - ] - } - }, - { - "name": "sourceStakeAccountSplitRequest", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 108, - 105, - 116, - 95, - 114, - 101, - 113, - 117, - 101, - 115, - 116 - ] - }, - { - "kind": "account", - "path": "sourceStakeAccountPositions" - } - ] - } - }, - { - "name": "sourceStakeAccountCustody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "sourceStakeAccountPositions" - } - ] - } - }, - { - "name": "sourceCustodyAuthority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "sourceStakeAccountPositions" - } - ] - } - }, - { - "name": "newStakeAccountPositions", - "writable": true - }, - { - "name": "newStakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "newStakeAccountPositions" - } - ] - } - }, - { - "name": "newStakeAccountCustody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "newStakeAccountPositions" - } - ] - } - }, - { - "name": "newCustodyAuthority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "newStakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "pythTokenMint", - "relations": [ - "config" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - }, - { - "name": "advanceClock", - "discriminator": [ - 52, - 57, - 147, - 111, - 56, - 227, - 33, - 127 - ], - "accounts": [ - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "seconds", - "type": "i64" - } - ] - }, - { - "name": "closePosition", - "discriminator": [ - 123, - 134, - 81, - 0, - 49, - 68, - 98, - 98 - ], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions", - "writable": true - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountCustody", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "targetAccount", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "poolAuthority", - "signer": true, - "optional": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "index", - "type": "u8" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "targetWithParameters", - "type": { - "defined": { - "name": "targetWithParameters" - } - } - } - ] - }, - { - "name": "createPosition", - "docs": [ - "Creates a position", - "Looks for the first available place in the array, fails if array is full", - "Computes risk and fails if new positions exceed risk limit" - ], - "discriminator": [ - 48, - 215, - 197, - 153, - 96, - 203, - 180, - 133 - ], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions", - "writable": true - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountCustody", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "targetAccount", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "poolAuthority", - "signer": true, - "optional": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "targetWithParameters", - "type": { - "defined": { - "name": "targetWithParameters" - } - } - }, - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "createStakeAccount", - "docs": [ - "Trustless instruction that creates a stake account for a user", - "The main account i.e. the position accounts needs to be initialized outside of the program", - "otherwise we run into stack limits" - ], - "discriminator": [ - 105, - 24, - 131, - 19, - 201, - 250, - 157, - 73 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "stakeAccountPositions", - "writable": true - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountCustody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "custodyAuthority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "pythTokenMint", - "relations": [ - "config" - ] - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "lock", - "type": { - "defined": { - "name": "vestingSchedule" - } - } - } - ] - }, - { - "name": "createTarget", - "discriminator": [ - 76, - 144, - 128, - 239, - 121, - 210, - 123, - 39 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "governanceAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "targetAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "createVoterRecord", - "discriminator": [ - 3, - 12, - 113, - 222, - 177, - 4, - 152, - 165 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "stakeAccountPositions" - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "voterRecord", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 101, - 114, - 95, - 119, - 101, - 105, - 103, - 104, - 116 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "exportPositionType", - "discriminator": [ - 219, - 172, - 149, - 212, - 103, - 230, - 164, - 179 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "configAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "position", - "type": { - "defined": { - "name": "position" - } - } - } - ] - }, - { - "name": "initConfig", - "discriminator": [ - 23, - 235, - 115, - 232, - 168, - 96, - 1, - 231 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "configAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "globalConfig", - "type": { - "defined": { - "name": "globalConfig" - } - } - } - ] - }, - { - "name": "joinDaoLlc", - "docs": [ - "* Accept to join the DAO LLC\n * This must happen before create_position or update_voter_weight\n * The user signs a hash of the agreement and the program checks that the hash matches the\n * agreement" - ], - "discriminator": [ - 79, - 241, - 203, - 177, - 232, - 143, - 124, - 14 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions" - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "agreementHash", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "mergeTargetPositions", - "discriminator": [ - 21, - 136, - 57, - 2, - 204, - 219, - 242, - 141 - ], - "accounts": [ - { - "name": "owner", - "docs": [ - "CHECK : This AccountInfo is safe because it's checked against stake_account_metadata" - ], - "writable": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions", - "writable": true - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "poolAuthority", - "signer": true, - "optional": true - } - ], - "args": [ - { - "name": "targetWithParameters", - "type": { - "defined": { - "name": "targetWithParameters" - } - } - } - ] - }, - { - "name": "recoverAccount", - "docs": [ - "Recovers a user's `stake account` ownership by transferring ownership\n * from a token account to the `owner` of that token account.\n *\n * This functionality addresses the scenario where a user mistakenly\n * created a stake account using their token account address as the owner." - ], - "discriminator": [ - 240, - 223, - 246, - 118, - 26, - 121, - 34, - 128 - ], - "accounts": [ - { - "name": "governanceAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "owner", - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions", - "writable": true - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "voterRecord", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 101, - 114, - 95, - 119, - 101, - 105, - 103, - 104, - 116 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [] - }, - { - "name": "requestSplit", - "docs": [ - "* Any user of the staking program can request to split their account and\n * give a part of it to another user.\n * This is mostly useful to transfer unvested tokens. Each user can only have one active\n * request at a time.\n * In the first step, the user requests a split by specifying the `amount` of tokens\n * they want to give to the other user and the `recipient`'s pubkey." - ], - "discriminator": [ - 133, - 146, - 228, - 165, - 251, - 207, - 146, - 23 - ], - "accounts": [ - { - "name": "owner", - "writable": true, - "signer": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions" - }, - { - "name": "stakeAccountMetadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountSplitRequest", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 112, - 108, - 105, - 116, - 95, - 114, - 101, - 113, - 117, - 101, - 115, - 116 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - }, - { - "name": "slashAccount", - "discriminator": [ - 185, - 97, - 8, - 208, - 118, - 205, - 166, - 2 - ], - "accounts": [ - { - "name": "poolAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "publisher", - "docs": [ - "CHECK : This AccountInfo is just used to construct the target that will get slashed" - ] - }, - { - "name": "stakeAccountPositions", - "writable": true - }, - { - "name": "stakeAccountMetadata", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountCustody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "governanceTargetAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - }, - { - "name": "destination", - "writable": true - }, - { - "name": "custodyAuthority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [ - { - "name": "slashRatio", - "type": "u64" - } - ] - }, - { - "name": "updateAgreementHash", - "discriminator": [ - 86, - 232, - 181, - 137, - 158, - 110, - 129, - 238 - ], - "accounts": [ - { - "name": "governanceAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "agreementHash", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "updateGovernanceAuthority", - "discriminator": [ - 11, - 185, - 227, - 55, - 39, - 32, - 168, - 14 - ], - "accounts": [ - { - "name": "governanceAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "newAuthority", - "type": "pubkey" - } - ] - }, - { - "name": "updateMaxVoterWeight", - "discriminator": [ - 248, - 36, - 229, - 234, - 11, - 132, - 145, - 20 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "maxVoterRecord", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 97, - 120, - 95, - 118, - 111, - 116, - 101, - 114 - ] - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "updatePdaAuthority", - "discriminator": [ - 178, - 112, - 199, - 196, - 59, - 40, - 140, - 61 - ], - "accounts": [ - { - "name": "pdaAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "newAuthority", - "type": "pubkey" - } - ] - }, - { - "name": "updatePoolAuthority", - "discriminator": [ - 160, - 162, - 113, - 9, - 99, - 187, - 23, - 239 - ], - "accounts": [ - { - "name": "governanceAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "poolAuthority", - "type": "pubkey" - } - ] - }, - { - "name": "updateTokenListTime", - "discriminator": [ - 38, - 217, - 99, - 222, - 253, - 253, - 31, - 83 - ], - "accounts": [ - { - "name": "governanceAuthority", - "signer": true, - "relations": [ - "config" - ] - }, - { - "name": "config", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "tokenListTime", - "type": { - "option": "i64" - } - } - ] - }, - { - "name": "updateVoterWeight", - "discriminator": [ - 92, - 35, - 133, - 94, - 230, - 70, - 14, - 157 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "stakeAccountPositions" - }, - { - "name": "stakeAccountMetadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountCustody", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "voterRecord", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 101, - 114, - 95, - 119, - 101, - 105, - 103, - 104, - 116 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "governanceTarget", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 97, - 114, - 103, - 101, - 116 - ] - }, - { - "kind": "const", - "value": [ - 118, - 111, - 116, - 105, - 110, - 103 - ] - } - ] - } - } - ], - "args": [ - { - "name": "action", - "type": { - "defined": { - "name": "voterWeightAction" - } - } - } - ] - }, - { - "name": "withdrawStake", - "discriminator": [ - 153, - 8, - 22, - 138, - 105, - 176, - 87, - 66 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "stakeAccountMetadata" - ] - }, - { - "name": "destination", - "writable": true - }, - { - "name": "stakeAccountPositions" - }, - { - "name": "stakeAccountMetadata", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 107, - 101, - 95, - 109, - 101, - 116, - 97, - 100, - 97, - 116, - 97 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "stakeAccountCustody", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "custodyAuthority", - "docs": [ - "CHECK : This AccountInfo is safe because it's a checked PDA" - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "stakeAccountPositions" - } - ] - } - }, - { - "name": "config", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 111, - 110, - 102, - 105, - 103 - ] - } - ] - } - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - } - ], - "accounts": [ - { - "name": "globalConfig", - "discriminator": [ - 149, - 8, - 156, - 202, - 160, - 252, - 176, - 217 - ] - }, - { - "name": "maxVoterWeightRecord", - "discriminator": [ - 157, - 95, - 242, - 151, - 16, - 98, - 26, - 118 - ] - }, - { - "name": "positionData", - "discriminator": [ - 85, - 195, - 241, - 79, - 124, - 192, - 79, - 11 - ] - }, - { - "name": "splitRequest", - "discriminator": [ - 80, - 85, - 187, - 143, - 62, - 147, - 234, - 248 - ] - }, - { - "name": "stakeAccountMetadataV2", - "discriminator": [ - 192, - 51, - 203, - 19, - 76, - 177, - 136, - 97 - ] - }, - { - "name": "targetMetadata", - "discriminator": [ - 157, - 23, - 139, - 117, - 181, - 44, - 197, - 130 - ] - }, - { - "name": "voterWeightRecord", - "discriminator": [ - 46, - 249, - 155, - 75, - 153, - 248, - 116, - 9 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "tooMuchExposureToIntegrityPool", - "msg": "Too much exposure to integrity pool" - }, - { - "code": 6001, - "name": "tooMuchExposureToGovernance", - "msg": "Too much exposure to governance" - }, - { - "code": 6002, - "name": "tokensNotYetVested", - "msg": "Tokens not yet vested" - }, - { - "code": 6003, - "name": "riskLimitExceeded", - "msg": "Risk limit exceeded" - }, - { - "code": 6004, - "name": "tooManyPositions", - "msg": "Number of position limit reached" - }, - { - "code": 6005, - "name": "positionNotInUse", - "msg": "Position not in use" - }, - { - "code": 6006, - "name": "createPositionWithZero", - "msg": "New position needs to have positive balance" - }, - { - "code": 6007, - "name": "closePositionWithZero", - "msg": "Closing a position of 0 is not allowed" - }, - { - "code": 6008, - "name": "invalidPosition", - "msg": "Invalid product/publisher pair" - }, - { - "code": 6009, - "name": "amountBiggerThanPosition", - "msg": "Amount to unlock bigger than position" - }, - { - "code": 6010, - "name": "alreadyUnlocking", - "msg": "Position already unlocking" - }, - { - "code": 6011, - "name": "zeroEpochDuration", - "msg": "Epoch duration is 0" - }, - { - "code": 6012, - "name": "withdrawToUnauthorizedAccount", - "msg": "Owner needs to own destination account" - }, - { - "code": 6013, - "name": "insufficientWithdrawableBalance", - "msg": "Insufficient balance to cover the withdrawal" - }, - { - "code": 6014, - "name": "wrongTarget", - "msg": "Target in position doesn't match target in instruction data" - }, - { - "code": 6015, - "name": "genericOverflow", - "msg": "An arithmetic operation unexpectedly overflowed" - }, - { - "code": 6016, - "name": "negativeBalance", - "msg": "Locked balance must be positive" - }, - { - "code": 6017, - "name": "frozen", - "msg": "Protocol is frozen" - }, - { - "code": 6018, - "name": "debuggingOnly", - "msg": "Not allowed when not debugging" - }, - { - "code": 6019, - "name": "proposalTooLong", - "msg": "Proposal too long" - }, - { - "code": 6020, - "name": "invalidVotingEpoch", - "msg": "Voting epoch is either too old or hasn't started" - }, - { - "code": 6021, - "name": "proposalNotActive", - "msg": "Voting hasn't started" - }, - { - "code": 6022, - "name": "noRemainingAccount", - "msg": "Extra governance account required" - }, - { - "code": 6023, - "name": "unauthorized", - "msg": "Unauthorized caller" - }, - { - "code": 6024, - "name": "accountUpgradeFailed", - "msg": "Precondition to upgrade account violated" - }, - { - "code": 6025, - "name": "notImplemented", - "msg": "Not implemented" - }, - { - "code": 6026, - "name": "positionSerDe", - "msg": "Error deserializing position" - }, - { - "code": 6027, - "name": "positionOutOfBounds", - "msg": "Position out of bounds" - }, - { - "code": 6028, - "name": "voteDuringTransferEpoch", - "msg": "Can't vote during an account's transfer epoch" - }, - { - "code": 6029, - "name": "notLlcMember", - "msg": "You need to be an LLC member to perform this action" - }, - { - "code": 6030, - "name": "invalidLlcAgreement", - "msg": "Invalid LLC agreement" - }, - { - "code": 6031, - "name": "splitZeroTokens", - "msg": "Can't split 0 tokens from an account" - }, - { - "code": 6032, - "name": "splitTooManyTokens", - "msg": "Can't split more tokens than are in the account" - }, - { - "code": 6033, - "name": "splitWithStake", - "msg": "Can't split a token account with staking positions. Unstake your tokens first." - }, - { - "code": 6034, - "name": "invalidApproval", - "msg": "The approval arguments do not match the split request." - }, - { - "code": 6035, - "name": "recoverWithStake", - "msg": "Can't recover account with staking positions. Unstake your tokens first." - }, - { - "code": 6036, - "name": "invalidPoolAuthority", - "msg": "The pool authority hasn't been passed or doesn't match the target" - }, - { - "code": 6037, - "name": "missingTargetAccount", - "msg": "The target account is missing" - }, - { - "code": 6038, - "name": "invalidSlashRatio", - "msg": "The slash ratio should be between 0 and 1" - }, - { - "code": 6039, - "name": "unexpectedTargetAccount", - "msg": "The target account is only expected when dealing with the governance target" - }, - { - "code": 6040, - "name": "other", - "msg": "other" - } - ], - "types": [ - { - "name": "globalConfig", - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "governanceAuthority", - "type": "pubkey" - }, - { - "name": "pythTokenMint", - "type": "pubkey" - }, - { - "name": "pythGovernanceRealm", - "type": "pubkey" - }, - { - "name": "removedUnlockingDuration", - "type": "u8" - }, - { - "name": "epochDuration", - "type": "u64" - }, - { - "name": "freeze", - "type": "bool" - }, - { - "name": "pdaAuthority", - "type": "pubkey" - }, - { - "name": "governanceProgram", - "type": "pubkey" - }, - { - "name": "pythTokenListTime", - "docs": [ - "Once the pyth token is listed, governance can update the config to set this value.", - "Once this value is set, vesting schedules that depend on the token list date can start", - "vesting." - ], - "type": { - "option": "i64" - } - }, - { - "name": "agreementHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "mockClockTime", - "type": "i64" - }, - { - "name": "poolAuthority", - "type": "pubkey" - } - ] - } - }, - { - "name": "maxVoterWeightRecord", - "docs": [ - "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/max_voter_weight.rs" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "realm", - "docs": [ - "The Realm the MaxVoterWeightRecord belongs to" - ], - "type": "pubkey" - }, - { - "name": "governingTokenMint", - "docs": [ - "Governing Token Mint the MaxVoterWeightRecord is associated with", - "Note: The addin can take deposits of any tokens and is not restricted to the community or", - "council tokens only" - ], - "type": "pubkey" - }, - { - "name": "maxVoterWeight", - "docs": [ - "Max voter weight", - "The max voter weight provided by the addin for the given realm and governing_token_mint" - ], - "type": "u64" - }, - { - "name": "maxVoterWeightExpiry", - "docs": [ - "The slot when the max voting weight expires", - "It should be set to None if the weight never expires", - "If the max vote weight decays with time, for example for time locked based weights, then", - "the expiry must be set As a pattern Revise instruction to update the max weight should", - "be invoked before governance instruction within the same transaction and the expiry set", - "to the current slot to provide up to date weight" - ], - "type": { - "option": "u64" - } - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future versions" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } - }, - { - "name": "position", - "docs": [ - "This represents a staking position, i.e. an amount that someone has staked to a particular", - "target. This is one of the core pieces of our staking design, and stores all", - "of the state related to a position The voting position is a position where the", - "target_with_parameters is VOTING" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "activationEpoch", - "type": "u64" - }, - { - "name": "unlockingStart", - "type": { - "option": "u64" - } - }, - { - "name": "targetWithParameters", - "type": { - "defined": { - "name": "targetWithParameters" - } - } - } - ] - } - }, - { - "name": "positionData", - "docs": [ - "The header of DynamicPositionArray" - ], - "serialization": "bytemuck", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "splitRequest", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "stakeAccountMetadataV2", - "docs": [ - "This is the metadata account for each staker", - "It is derived from the positions account with seeds \"stake_metadata\" and the positions account", - "pubkey It stores some PDA bumps, the owner of the account and the vesting schedule" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "metadataBump", - "type": "u8" - }, - { - "name": "custodyBump", - "type": "u8" - }, - { - "name": "authorityBump", - "type": "u8" - }, - { - "name": "voterBump", - "type": "u8" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "lock", - "type": { - "defined": { - "name": "vestingSchedule" - } - } - }, - { - "name": "nextIndex", - "type": "u8" - }, - { - "name": "deprecated", - "type": { - "option": "u64" - } - }, - { - "name": "signedAgreementHash", - "type": { - "option": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - }, - { - "name": "targetMetadata", - "docs": [ - "This represents a target that users can stake to", - "Currently we store the last time the target account was updated, the current locked balance", - "and the amount by which the locked balance will change in the next epoch" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "bump", - "type": "u8" - }, - { - "name": "lastUpdateAt", - "type": "u64" - }, - { - "name": "prevEpochLocked", - "type": "u64" - }, - { - "name": "locked", - "type": "u64" - }, - { - "name": "deltaLocked", - "type": "i64" - } - ] - } - }, - { - "name": "targetWithParameters", - "type": { - "kind": "enum", - "variants": [ - { - "name": "voting" - }, - { - "name": "integrityPool", - "fields": [ - { - "name": "publisher", - "type": "pubkey" - } - ] - } - ] - } - }, - { - "name": "vestingSchedule", - "docs": [ - "Represents how a given initial balance vests over time", - "It is unit-less, but units must be consistent" - ], - "repr": { - "kind": "rust" - }, - "type": { - "kind": "enum", - "variants": [ - { - "name": "fullyVested" - }, - { - "name": "periodicVesting", - "fields": [ - { - "name": "initialBalance", - "type": "u64" - }, - { - "name": "startDate", - "type": "i64" - }, - { - "name": "periodDuration", - "type": "u64" - }, - { - "name": "numPeriods", - "type": "u64" - } - ] - }, - { - "name": "periodicVestingAfterListing", - "fields": [ - { - "name": "initialBalance", - "type": "u64" - }, - { - "name": "periodDuration", - "type": "u64" - }, - { - "name": "numPeriods", - "type": "u64" - } - ] - } - ] - } - }, - { - "name": "voterWeightAction", - "docs": [ - "The governance action VoterWeight is evaluated for" - ], - "type": { - "kind": "enum", - "variants": [ - { - "name": "castVote" - }, - { - "name": "commentProposal" - }, - { - "name": "createGovernance" - }, - { - "name": "createProposal" - }, - { - "name": "signOffProposal" - } - ] - } - }, - { - "name": "voterWeightRecord", - "docs": [ - "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/voter_weight.rs", - "Anchor has a macro (vote_weight_record) that is supposed to generate this struct, but it doesn't", - "work because the error's macros are not updated for anchor 0.22.0.", - "Even if it did work, the type wouldn't show up in the IDL. SPL doesn't produce an API, which", - "means that means we'd need the equivalent of this code on the client side.", - "If Anchor fixes the macro, we might consider changing it" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "realm", - "docs": [ - "VoterWeightRecord discriminator sha256(\"account:VoterWeightRecord\")[..8]", - "Note: The discriminator size must match the addin implementing program discriminator size", - "to ensure it's stored in the private space of the account data and it's unique", - "pub account_discriminator: [u8; 8],", - "The Realm the VoterWeightRecord belongs to" - ], - "type": "pubkey" - }, - { - "name": "governingTokenMint", - "docs": [ - "Governing Token Mint the VoterWeightRecord is associated with", - "Note: The addin can take deposits of any tokens and is not restricted to the community or", - "council tokens only" - ], - "type": "pubkey" - }, - { - "name": "governingTokenOwner", - "docs": [ - "The owner of the governing token and voter", - "This is the actual owner (voter) and corresponds to TokenOwnerRecord.governing_token_owner" - ], - "type": "pubkey" - }, - { - "name": "voterWeight", - "docs": [ - "Voter's weight", - "The weight of the voter provided by the addin for the given realm, governing_token_mint and", - "governing_token_owner (voter)" - ], - "type": "u64" - }, - { - "name": "voterWeightExpiry", - "docs": [ - "The slot when the voting weight expires", - "It should be set to None if the weight never expires", - "If the voter weight decays with time, for example for time locked based weights, then the", - "expiry must be set As a common pattern Revise instruction to update the weight should", - "be invoked before governance instruction within the same transaction and the expiry set", - "to the current slot to provide up to date weight" - ], - "type": { - "option": "u64" - } - }, - { - "name": "weightAction", - "docs": [ - "The governance action the voter's weight pertains to", - "It allows to provided voter's weight specific to the particular action the weight is", - "evaluated for When the action is provided then the governance program asserts the", - "executing action is the same as specified by the addin" - ], - "type": { - "option": { - "defined": { - "name": "voterWeightAction" - } - } - } - }, - { - "name": "weightActionTarget", - "docs": [ - "The target the voter's weight action pertains to", - "It allows to provided voter's weight specific to the target the weight is evaluated for", - "For example when addin supplies weight to vote on a particular proposal then it must", - "specify the proposal as the action target When the target is provided then the", - "governance program asserts the target is the same as specified by the addin" - ], - "type": { - "option": "pubkey" - } - }, - { - "name": "reserved", - "docs": [ - "Reserved space for future versions" - ], - "type": { - "array": [ - "u8", - 8 - ] - } - } - ] - } - } - ] -}; diff --git a/staking/target/types/wallet_tester.ts b/staking/target/types/wallet_tester.ts deleted file mode 100644 index 1208505b..00000000 --- a/staking/target/types/wallet_tester.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/wallet_tester.json`. - */ -export type WalletTester = { - "address": "tstPARXbQ5yxVkRU2UcZRbYphzbUEW6t5ihzpLaafgz", - "metadata": { - "name": "walletTester", - "version": "1.0.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "test", - "discriminator": [ - 163, - 36, - 134, - 53, - 232, - 223, - 146, - 222 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "testReceipt", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "payer" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - } - ] -}; From ea51b53a2361fcb7c16034b40fae6fd5caa41822 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 20:23:01 +0000 Subject: [PATCH 15/19] do it --- staking/cli/src/instructions.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index 818b22b4..e8f3ff47 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -268,7 +268,13 @@ pub async fn process_transaction( instructions: &[Instruction], signers: &[&dyn Signer], ) -> Result> { - let mut transaction = Transaction::new_with_payer(instructions, Some(&signers[0].pubkey())); + // TODO: Improve this to handle retries + let mut instructions_with_compute_budget = instructions.to_vec(); + instructions_with_compute_budget.push(ComputeBudgetInstruction::set_compute_unit_price(1)); + let mut transaction = Transaction::new_with_payer( + &instructions_with_compute_budget, + Some(&signers[0].pubkey()), + ); transaction.sign( signers, rpc_client @@ -283,6 +289,7 @@ pub async fn process_transaction( CommitmentConfig::confirmed(), RpcSendTransactionConfig { skip_preflight: true, + max_retries: Some(0), ..Default::default() }, ) @@ -1327,6 +1334,7 @@ pub async fn advance_delegation_records<'a>( accounts: accounts.to_account_metas(None), data: data.data(), }); + // TODO: Add merge positions instruction } // Process instructions in chunks of 5 @@ -1346,7 +1354,6 @@ pub async fn advance_delegation_records<'a>( // pending } } - return false; } true // No instruction were needed, this stake account is already done } From 96f4c349a6935d4c9bab5958093dd4e3057f9d87 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 20:29:15 +0000 Subject: [PATCH 16/19] cleanup main.rs --- staking/cli/src/main.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index 54def28c..1b3a1298 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -58,6 +58,7 @@ async fn main() { ) .await } + Action::Advance { hermes_url, wormhole, @@ -65,12 +66,15 @@ async fn main() { fetch_publisher_caps_and_advance(&rpc_client, keypair.as_ref(), wormhole, hermes_url) .await } + Action::InitializePoolRewardCustody {} => { - initialize_reward_custody(&rpc_client, keypair.as_ref()).await; + initialize_reward_custody(&rpc_client, keypair.as_ref()).await } + Action::UpdateDelegationFee { delegation_fee } => { update_delegation_fee(&rpc_client, keypair.as_ref(), delegation_fee).await } + Action::SetPublisherStakeAccount { publisher, stake_account_positions, @@ -83,6 +87,7 @@ async fn main() { ) .await } + Action::CreateSlashEvent { publisher, slash_ratio, @@ -97,6 +102,7 @@ async fn main() { ) .await } + Action::Slash { publisher, stake_account_positions, @@ -109,16 +115,17 @@ async fn main() { ) .await } + Action::UpdateY { y } => update_y(&rpc_client, keypair.as_ref(), y).await, Action::ClosePublisherCaps { publisher_caps } => { close_publisher_caps(&rpc_client, keypair.as_ref(), publisher_caps).await } - Action::SaveStakeAccountsSnapshot {} => { - save_stake_accounts_snapshot(&rpc_client).await; - } + Action::SaveStakeAccountsSnapshot {} => save_stake_accounts_snapshot(&rpc_client).await, + Action::CloseAllPublisherCaps {} => { - close_all_publisher_caps(&rpc_client, keypair.as_ref()).await; + close_all_publisher_caps(&rpc_client, keypair.as_ref()).await } + Action::ClaimRewards { min_staked } => { claim_rewards(&rpc_client, keypair.as_ref(), min_staked).await } From ccc9250b421262240d8ebce432a12af0715c6dc8 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 20:29:45 +0000 Subject: [PATCH 17/19] fianl cleanup: --- staking/cli/src/main.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index 1b3a1298..d11b4d66 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -58,7 +58,6 @@ async fn main() { ) .await } - Action::Advance { hermes_url, wormhole, @@ -66,15 +65,12 @@ async fn main() { fetch_publisher_caps_and_advance(&rpc_client, keypair.as_ref(), wormhole, hermes_url) .await } - Action::InitializePoolRewardCustody {} => { initialize_reward_custody(&rpc_client, keypair.as_ref()).await } - Action::UpdateDelegationFee { delegation_fee } => { update_delegation_fee(&rpc_client, keypair.as_ref(), delegation_fee).await } - Action::SetPublisherStakeAccount { publisher, stake_account_positions, @@ -87,7 +83,6 @@ async fn main() { ) .await } - Action::CreateSlashEvent { publisher, slash_ratio, @@ -102,7 +97,6 @@ async fn main() { ) .await } - Action::Slash { publisher, stake_account_positions, @@ -115,17 +109,14 @@ async fn main() { ) .await } - Action::UpdateY { y } => update_y(&rpc_client, keypair.as_ref(), y).await, Action::ClosePublisherCaps { publisher_caps } => { close_publisher_caps(&rpc_client, keypair.as_ref(), publisher_caps).await } Action::SaveStakeAccountsSnapshot {} => save_stake_accounts_snapshot(&rpc_client).await, - Action::CloseAllPublisherCaps {} => { close_all_publisher_caps(&rpc_client, keypair.as_ref()).await } - Action::ClaimRewards { min_staked } => { claim_rewards(&rpc_client, keypair.as_ref(), min_staked).await } From 4f40d79b9f70bfa320478585bb53dcd3c92fc83a Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 20:34:27 +0000 Subject: [PATCH 18/19] comments --- staking/cli/src/instructions.rs | 2 ++ staking/cli/src/main.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/staking/cli/src/instructions.rs b/staking/cli/src/instructions.rs index e8f3ff47..0cbd39dc 100644 --- a/staking/cli/src/instructions.rs +++ b/staking/cli/src/instructions.rs @@ -1393,6 +1393,8 @@ pub async fn claim_rewards(rpc_client: &RpcClient, signer: &dyn Signer, min_stak .iter_mut() .filter_map(|positions| { let positions = positions.to_dynamic_position_array(); + // We can't use `get_target_exposure` because it ignores UNLOCKED positions but they + // might have rewards let exposure = { let mut exposure = 0; for i in 0..positions.get_position_capacity() { diff --git a/staking/cli/src/main.rs b/staking/cli/src/main.rs index d11b4d66..ab0941ff 100644 --- a/staking/cli/src/main.rs +++ b/staking/cli/src/main.rs @@ -35,7 +35,7 @@ async fn main() { } = Cli::parse(); if cfg!(debug_assertions) { - panic!("These are issues with running the CLI in debug mode, and it might lead to segmentation fault, please use cargo run --release"); + panic!("There are issues with running the CLI in debug mode, and it might lead to segmentation fault, please use cargo run --release"); } From f1b649fc00a0d270f7da6e206b0d9fc7953ce5b5 Mon Sep 17 00:00:00 2001 From: Guillermo Bescos Date: Tue, 7 Jan 2025 20:35:19 +0000 Subject: [PATCH 19/19] undo this: --- staking/target/idl/profile.json | 106 + staking/target/idl/staking.json | 3119 ++++++++++++++++++++++++ staking/target/idl/wallet_tester.json | 48 + staking/target/types/profile.ts | 112 + staking/target/types/staking.ts | 3125 +++++++++++++++++++++++++ staking/target/types/wallet_tester.ts | 54 + 6 files changed, 6564 insertions(+) create mode 100644 staking/target/idl/profile.json create mode 100644 staking/target/idl/staking.json create mode 100644 staking/target/idl/wallet_tester.json create mode 100644 staking/target/types/profile.ts create mode 100644 staking/target/types/staking.ts create mode 100644 staking/target/types/wallet_tester.ts diff --git a/staking/target/idl/profile.json b/staking/target/idl/profile.json new file mode 100644 index 00000000..ac2cebf4 --- /dev/null +++ b/staking/target/idl/profile.json @@ -0,0 +1,106 @@ +{ + "address": "prfmVhiQTN5Spgoxa8uZJba35V1s7XXReqbBiqPDWeJ", + "metadata": { + "name": "profile", + "version": "1.0.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "update_identity", + "discriminator": [ + 130, + 54, + 88, + 104, + 222, + 124, + 238, + 252 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "identity_account", + "writable": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "identity", + "type": { + "defined": { + "name": "Identity" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "IdentityAccount", + "discriminator": [ + 194, + 90, + 181, + 160, + 182, + 206, + 116, + 158 + ] + } + ], + "types": [ + { + "name": "Identity", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Evm", + "fields": [ + { + "name": "pubkey", + "type": { + "option": { + "array": [ + "u8", + 20 + ] + } + } + } + ] + } + ] + } + }, + { + "name": "IdentityAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "identity", + "type": { + "defined": { + "name": "Identity" + } + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/staking/target/idl/staking.json b/staking/target/idl/staking.json new file mode 100644 index 00000000..4c2c4047 --- /dev/null +++ b/staking/target/idl/staking.json @@ -0,0 +1,3119 @@ +{ + "address": "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ", + "metadata": { + "name": "staking", + "version": "2.0.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "accept_split", + "docs": [ + "* A split request can only be accepted by the `pda_authority` from\n * the config account. If accepted, `amount` tokens are transferred to a new stake account\n * owned by the `recipient` and the split request is reset (by setting `amount` to 0).\n * The recipient of a transfer can't vote during the epoch of the transfer.\n *\n * The `pda_authority` must explicitly approve both the amount of tokens and recipient, and\n * these parameters must match the request (in the `split_request` account)." + ], + "discriminator": [ + 177, + 172, + 17, + 93, + 193, + 86, + 54, + 222 + ], + "accounts": [ + { + "name": "pda_authority", + "writable": true, + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "source_stake_account_positions", + "writable": true + }, + { + "name": "source_stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "source_stake_account_positions" + } + ] + } + }, + { + "name": "source_stake_account_split_request", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 108, + 105, + 116, + 95, + 114, + 101, + 113, + 117, + 101, + 115, + 116 + ] + }, + { + "kind": "account", + "path": "source_stake_account_positions" + } + ] + } + }, + { + "name": "source_stake_account_custody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "source_stake_account_positions" + } + ] + } + }, + { + "name": "source_custody_authority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "source_stake_account_positions" + } + ] + } + }, + { + "name": "new_stake_account_positions", + "writable": true + }, + { + "name": "new_stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "new_stake_account_positions" + } + ] + } + }, + { + "name": "new_stake_account_custody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "new_stake_account_positions" + } + ] + } + }, + { + "name": "new_custody_authority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "new_stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "pyth_token_mint", + "relations": [ + "config" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + }, + { + "name": "advance_clock", + "discriminator": [ + 52, + 57, + 147, + 111, + 56, + 227, + 33, + 127 + ], + "accounts": [ + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "seconds", + "type": "i64" + } + ] + }, + { + "name": "close_position", + "discriminator": [ + 123, + 134, + 81, + 0, + 49, + 68, + 98, + 98 + ], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions", + "writable": true + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_custody", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "target_account", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "pool_authority", + "signer": true, + "optional": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "index", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "target_with_parameters", + "type": { + "defined": { + "name": "TargetWithParameters" + } + } + } + ] + }, + { + "name": "create_position", + "docs": [ + "Creates a position", + "Looks for the first available place in the array, fails if array is full", + "Computes risk and fails if new positions exceed risk limit" + ], + "discriminator": [ + 48, + 215, + 197, + 153, + 96, + 203, + 180, + 133 + ], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions", + "writable": true + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_custody", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "target_account", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "pool_authority", + "signer": true, + "optional": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "target_with_parameters", + "type": { + "defined": { + "name": "TargetWithParameters" + } + } + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "create_stake_account", + "docs": [ + "Trustless instruction that creates a stake account for a user", + "The main account i.e. the position accounts needs to be initialized outside of the program", + "otherwise we run into stack limits" + ], + "discriminator": [ + 105, + 24, + 131, + 19, + 201, + 250, + 157, + 73 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "stake_account_positions", + "writable": true + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_custody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "custody_authority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "pyth_token_mint", + "relations": [ + "config" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "lock", + "type": { + "defined": { + "name": "VestingSchedule" + } + } + } + ] + }, + { + "name": "create_target", + "discriminator": [ + 76, + 144, + 128, + 239, + 121, + 210, + 123, + 39 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "governance_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "target_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "create_voter_record", + "discriminator": [ + 3, + 12, + 113, + 222, + 177, + 4, + 152, + 165 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "stake_account_positions" + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "voter_record", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 101, + 114, + 95, + 119, + 101, + 105, + 103, + 104, + 116 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "export_position_type", + "discriminator": [ + 219, + 172, + 149, + 212, + 103, + 230, + 164, + 179 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "config_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "_position", + "type": { + "defined": { + "name": "Position" + } + } + } + ] + }, + { + "name": "init_config", + "discriminator": [ + 23, + 235, + 115, + 232, + 168, + 96, + 1, + 231 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "config_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "global_config", + "type": { + "defined": { + "name": "GlobalConfig" + } + } + } + ] + }, + { + "name": "join_dao_llc", + "docs": [ + "* Accept to join the DAO LLC\n * This must happen before create_position or update_voter_weight\n * The user signs a hash of the agreement and the program checks that the hash matches the\n * agreement" + ], + "discriminator": [ + 79, + 241, + 203, + 177, + 232, + 143, + 124, + 14 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions" + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "_agreement_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "merge_target_positions", + "discriminator": [ + 21, + 136, + 57, + 2, + 204, + 219, + 242, + 141 + ], + "accounts": [ + { + "name": "owner", + "docs": [ + "CHECK : This AccountInfo is safe because it's checked against stake_account_metadata" + ], + "writable": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions", + "writable": true + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "pool_authority", + "signer": true, + "optional": true + } + ], + "args": [ + { + "name": "target_with_parameters", + "type": { + "defined": { + "name": "TargetWithParameters" + } + } + } + ] + }, + { + "name": "recover_account", + "docs": [ + "Recovers a user's `stake account` ownership by transferring ownership\n * from a token account to the `owner` of that token account.\n *\n * This functionality addresses the scenario where a user mistakenly\n * created a stake account using their token account address as the owner." + ], + "discriminator": [ + 240, + 223, + 246, + 118, + 26, + 121, + 34, + 128 + ], + "accounts": [ + { + "name": "governance_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "owner", + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions", + "writable": true + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "voter_record", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 101, + 114, + 95, + 119, + 101, + 105, + 103, + 104, + 116 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "request_split", + "docs": [ + "* Any user of the staking program can request to split their account and\n * give a part of it to another user.\n * This is mostly useful to transfer unvested tokens. Each user can only have one active\n * request at a time.\n * In the first step, the user requests a split by specifying the `amount` of tokens\n * they want to give to the other user and the `recipient`'s pubkey." + ], + "discriminator": [ + 133, + 146, + 228, + 165, + 251, + 207, + 146, + 23 + ], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions" + }, + { + "name": "stake_account_metadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_split_request", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 108, + 105, + 116, + 95, + 114, + 101, + 113, + 117, + 101, + 115, + 116 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + }, + { + "name": "slash_account", + "discriminator": [ + 185, + 97, + 8, + 208, + 118, + 205, + 166, + 2 + ], + "accounts": [ + { + "name": "pool_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "publisher", + "docs": [ + "CHECK : This AccountInfo is just used to construct the target that will get slashed" + ] + }, + { + "name": "stake_account_positions", + "writable": true + }, + { + "name": "stake_account_metadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_custody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "governance_target_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "destination", + "writable": true + }, + { + "name": "custody_authority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "slash_ratio", + "type": "u64" + } + ] + }, + { + "name": "update_agreement_hash", + "discriminator": [ + 86, + 232, + 181, + 137, + 158, + 110, + 129, + 238 + ], + "accounts": [ + { + "name": "governance_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "agreement_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "update_governance_authority", + "discriminator": [ + 11, + 185, + 227, + 55, + 39, + 32, + 168, + 14 + ], + "accounts": [ + { + "name": "governance_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "new_authority", + "type": "pubkey" + } + ] + }, + { + "name": "update_max_voter_weight", + "discriminator": [ + 248, + 36, + 229, + 234, + 11, + 132, + 145, + 20 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "max_voter_record", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 97, + 120, + 95, + 118, + 111, + 116, + 101, + 114 + ] + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "update_pda_authority", + "discriminator": [ + 178, + 112, + 199, + 196, + 59, + 40, + 140, + 61 + ], + "accounts": [ + { + "name": "pda_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "new_authority", + "type": "pubkey" + } + ] + }, + { + "name": "update_pool_authority", + "discriminator": [ + 160, + 162, + 113, + 9, + 99, + 187, + 23, + 239 + ], + "accounts": [ + { + "name": "governance_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "pool_authority", + "type": "pubkey" + } + ] + }, + { + "name": "update_token_list_time", + "discriminator": [ + 38, + 217, + 99, + 222, + 253, + 253, + 31, + 83 + ], + "accounts": [ + { + "name": "governance_authority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "token_list_time", + "type": { + "option": "i64" + } + } + ] + }, + { + "name": "update_voter_weight", + "discriminator": [ + 92, + 35, + 133, + 94, + 230, + 70, + 14, + 157 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "stake_account_positions" + }, + { + "name": "stake_account_metadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_custody", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "voter_record", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 101, + 114, + 95, + 119, + 101, + 105, + 103, + 104, + 116 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "governance_target", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "action", + "type": { + "defined": { + "name": "VoterWeightAction" + } + } + } + ] + }, + { + "name": "withdraw_stake", + "discriminator": [ + 153, + 8, + 22, + 138, + 105, + 176, + 87, + 66 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "stake_account_metadata" + ] + }, + { + "name": "destination", + "writable": true + }, + { + "name": "stake_account_positions" + }, + { + "name": "stake_account_metadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "stake_account_custody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "custody_authority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "stake_account_positions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "GlobalConfig", + "discriminator": [ + 149, + 8, + 156, + 202, + 160, + 252, + 176, + 217 + ] + }, + { + "name": "MaxVoterWeightRecord", + "discriminator": [ + 157, + 95, + 242, + 151, + 16, + 98, + 26, + 118 + ] + }, + { + "name": "PositionData", + "discriminator": [ + 85, + 195, + 241, + 79, + 124, + 192, + 79, + 11 + ] + }, + { + "name": "SplitRequest", + "discriminator": [ + 80, + 85, + 187, + 143, + 62, + 147, + 234, + 248 + ] + }, + { + "name": "StakeAccountMetadataV2", + "discriminator": [ + 192, + 51, + 203, + 19, + 76, + 177, + 136, + 97 + ] + }, + { + "name": "TargetMetadata", + "discriminator": [ + 157, + 23, + 139, + 117, + 181, + 44, + 197, + 130 + ] + }, + { + "name": "VoterWeightRecord", + "discriminator": [ + 46, + 249, + 155, + 75, + 153, + 248, + 116, + 9 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "TooMuchExposureToIntegrityPool", + "msg": "Too much exposure to integrity pool" + }, + { + "code": 6001, + "name": "TooMuchExposureToGovernance", + "msg": "Too much exposure to governance" + }, + { + "code": 6002, + "name": "TokensNotYetVested", + "msg": "Tokens not yet vested" + }, + { + "code": 6003, + "name": "RiskLimitExceeded", + "msg": "Risk limit exceeded" + }, + { + "code": 6004, + "name": "TooManyPositions", + "msg": "Number of position limit reached" + }, + { + "code": 6005, + "name": "PositionNotInUse", + "msg": "Position not in use" + }, + { + "code": 6006, + "name": "CreatePositionWithZero", + "msg": "New position needs to have positive balance" + }, + { + "code": 6007, + "name": "ClosePositionWithZero", + "msg": "Closing a position of 0 is not allowed" + }, + { + "code": 6008, + "name": "InvalidPosition", + "msg": "Invalid product/publisher pair" + }, + { + "code": 6009, + "name": "AmountBiggerThanPosition", + "msg": "Amount to unlock bigger than position" + }, + { + "code": 6010, + "name": "AlreadyUnlocking", + "msg": "Position already unlocking" + }, + { + "code": 6011, + "name": "ZeroEpochDuration", + "msg": "Epoch duration is 0" + }, + { + "code": 6012, + "name": "WithdrawToUnauthorizedAccount", + "msg": "Owner needs to own destination account" + }, + { + "code": 6013, + "name": "InsufficientWithdrawableBalance", + "msg": "Insufficient balance to cover the withdrawal" + }, + { + "code": 6014, + "name": "WrongTarget", + "msg": "Target in position doesn't match target in instruction data" + }, + { + "code": 6015, + "name": "GenericOverflow", + "msg": "An arithmetic operation unexpectedly overflowed" + }, + { + "code": 6016, + "name": "NegativeBalance", + "msg": "Locked balance must be positive" + }, + { + "code": 6017, + "name": "Frozen", + "msg": "Protocol is frozen" + }, + { + "code": 6018, + "name": "DebuggingOnly", + "msg": "Not allowed when not debugging" + }, + { + "code": 6019, + "name": "ProposalTooLong", + "msg": "Proposal too long" + }, + { + "code": 6020, + "name": "InvalidVotingEpoch", + "msg": "Voting epoch is either too old or hasn't started" + }, + { + "code": 6021, + "name": "ProposalNotActive", + "msg": "Voting hasn't started" + }, + { + "code": 6022, + "name": "NoRemainingAccount", + "msg": "Extra governance account required" + }, + { + "code": 6023, + "name": "Unauthorized", + "msg": "Unauthorized caller" + }, + { + "code": 6024, + "name": "AccountUpgradeFailed", + "msg": "Precondition to upgrade account violated" + }, + { + "code": 6025, + "name": "NotImplemented", + "msg": "Not implemented" + }, + { + "code": 6026, + "name": "PositionSerDe", + "msg": "Error deserializing position" + }, + { + "code": 6027, + "name": "PositionOutOfBounds", + "msg": "Position out of bounds" + }, + { + "code": 6028, + "name": "VoteDuringTransferEpoch", + "msg": "Can't vote during an account's transfer epoch" + }, + { + "code": 6029, + "name": "NotLlcMember", + "msg": "You need to be an LLC member to perform this action" + }, + { + "code": 6030, + "name": "InvalidLlcAgreement", + "msg": "Invalid LLC agreement" + }, + { + "code": 6031, + "name": "SplitZeroTokens", + "msg": "Can't split 0 tokens from an account" + }, + { + "code": 6032, + "name": "SplitTooManyTokens", + "msg": "Can't split more tokens than are in the account" + }, + { + "code": 6033, + "name": "SplitWithStake", + "msg": "Can't split a token account with staking positions. Unstake your tokens first." + }, + { + "code": 6034, + "name": "InvalidApproval", + "msg": "The approval arguments do not match the split request." + }, + { + "code": 6035, + "name": "RecoverWithStake", + "msg": "Can't recover account with staking positions. Unstake your tokens first." + }, + { + "code": 6036, + "name": "InvalidPoolAuthority", + "msg": "The pool authority hasn't been passed or doesn't match the target" + }, + { + "code": 6037, + "name": "MissingTargetAccount", + "msg": "The target account is missing" + }, + { + "code": 6038, + "name": "InvalidSlashRatio", + "msg": "The slash ratio should be between 0 and 1" + }, + { + "code": 6039, + "name": "UnexpectedTargetAccount", + "msg": "The target account is only expected when dealing with the governance target" + }, + { + "code": 6040, + "name": "Other", + "msg": "Other" + } + ], + "types": [ + { + "name": "GlobalConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "governance_authority", + "type": "pubkey" + }, + { + "name": "pyth_token_mint", + "type": "pubkey" + }, + { + "name": "pyth_governance_realm", + "type": "pubkey" + }, + { + "name": "removed_unlocking_duration", + "type": "u8" + }, + { + "name": "epoch_duration", + "type": "u64" + }, + { + "name": "freeze", + "type": "bool" + }, + { + "name": "pda_authority", + "type": "pubkey" + }, + { + "name": "governance_program", + "type": "pubkey" + }, + { + "name": "pyth_token_list_time", + "docs": [ + "Once the pyth token is listed, governance can update the config to set this value.", + "Once this value is set, vesting schedules that depend on the token list date can start", + "vesting." + ], + "type": { + "option": "i64" + } + }, + { + "name": "agreement_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "mock_clock_time", + "type": "i64" + }, + { + "name": "pool_authority", + "type": "pubkey" + } + ] + } + }, + { + "name": "MaxVoterWeightRecord", + "docs": [ + "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/max_voter_weight.rs" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "realm", + "docs": [ + "The Realm the MaxVoterWeightRecord belongs to" + ], + "type": "pubkey" + }, + { + "name": "governing_token_mint", + "docs": [ + "Governing Token Mint the MaxVoterWeightRecord is associated with", + "Note: The addin can take deposits of any tokens and is not restricted to the community or", + "council tokens only" + ], + "type": "pubkey" + }, + { + "name": "max_voter_weight", + "docs": [ + "Max voter weight", + "The max voter weight provided by the addin for the given realm and governing_token_mint" + ], + "type": "u64" + }, + { + "name": "max_voter_weight_expiry", + "docs": [ + "The slot when the max voting weight expires", + "It should be set to None if the weight never expires", + "If the max vote weight decays with time, for example for time locked based weights, then", + "the expiry must be set As a pattern Revise instruction to update the max weight should", + "be invoked before governance instruction within the same transaction and the expiry set", + "to the current slot to provide up to date weight" + ], + "type": { + "option": "u64" + } + }, + { + "name": "reserved", + "docs": [ + "Reserved space for future versions" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "Position", + "docs": [ + "This represents a staking position, i.e. an amount that someone has staked to a particular", + "target. This is one of the core pieces of our staking design, and stores all", + "of the state related to a position The voting position is a position where the", + "target_with_parameters is VOTING" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "activation_epoch", + "type": "u64" + }, + { + "name": "unlocking_start", + "type": { + "option": "u64" + } + }, + { + "name": "target_with_parameters", + "type": { + "defined": { + "name": "TargetWithParameters" + } + } + } + ] + } + }, + { + "name": "PositionData", + "docs": [ + "The header of DynamicPositionArray" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "SplitRequest", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "StakeAccountMetadataV2", + "docs": [ + "This is the metadata account for each staker", + "It is derived from the positions account with seeds \"stake_metadata\" and the positions account", + "pubkey It stores some PDA bumps, the owner of the account and the vesting schedule" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "metadata_bump", + "type": "u8" + }, + { + "name": "custody_bump", + "type": "u8" + }, + { + "name": "authority_bump", + "type": "u8" + }, + { + "name": "voter_bump", + "type": "u8" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "lock", + "type": { + "defined": { + "name": "VestingSchedule" + } + } + }, + { + "name": "next_index", + "type": "u8" + }, + { + "name": "_deprecated", + "type": { + "option": "u64" + } + }, + { + "name": "signed_agreement_hash", + "type": { + "option": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + }, + { + "name": "TargetMetadata", + "docs": [ + "This represents a target that users can stake to", + "Currently we store the last time the target account was updated, the current locked balance", + "and the amount by which the locked balance will change in the next epoch" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "last_update_at", + "type": "u64" + }, + { + "name": "prev_epoch_locked", + "type": "u64" + }, + { + "name": "locked", + "type": "u64" + }, + { + "name": "delta_locked", + "type": "i64" + } + ] + } + }, + { + "name": "TargetWithParameters", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Voting" + }, + { + "name": "IntegrityPool", + "fields": [ + { + "name": "publisher", + "type": "pubkey" + } + ] + } + ] + } + }, + { + "name": "VestingSchedule", + "docs": [ + "Represents how a given initial balance vests over time", + "It is unit-less, but units must be consistent" + ], + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "FullyVested" + }, + { + "name": "PeriodicVesting", + "fields": [ + { + "name": "initial_balance", + "type": "u64" + }, + { + "name": "start_date", + "type": "i64" + }, + { + "name": "period_duration", + "type": "u64" + }, + { + "name": "num_periods", + "type": "u64" + } + ] + }, + { + "name": "PeriodicVestingAfterListing", + "fields": [ + { + "name": "initial_balance", + "type": "u64" + }, + { + "name": "period_duration", + "type": "u64" + }, + { + "name": "num_periods", + "type": "u64" + } + ] + } + ] + } + }, + { + "name": "VoterWeightAction", + "docs": [ + "The governance action VoterWeight is evaluated for" + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "CastVote" + }, + { + "name": "CommentProposal" + }, + { + "name": "CreateGovernance" + }, + { + "name": "CreateProposal" + }, + { + "name": "SignOffProposal" + } + ] + } + }, + { + "name": "VoterWeightRecord", + "docs": [ + "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/voter_weight.rs", + "Anchor has a macro (vote_weight_record) that is supposed to generate this struct, but it doesn't", + "work because the error's macros are not updated for anchor 0.22.0.", + "Even if it did work, the type wouldn't show up in the IDL. SPL doesn't produce an API, which", + "means that means we'd need the equivalent of this code on the client side.", + "If Anchor fixes the macro, we might consider changing it" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "realm", + "docs": [ + "VoterWeightRecord discriminator sha256(\"account:VoterWeightRecord\")[..8]", + "Note: The discriminator size must match the addin implementing program discriminator size", + "to ensure it's stored in the private space of the account data and it's unique", + "pub account_discriminator: [u8; 8],", + "The Realm the VoterWeightRecord belongs to" + ], + "type": "pubkey" + }, + { + "name": "governing_token_mint", + "docs": [ + "Governing Token Mint the VoterWeightRecord is associated with", + "Note: The addin can take deposits of any tokens and is not restricted to the community or", + "council tokens only" + ], + "type": "pubkey" + }, + { + "name": "governing_token_owner", + "docs": [ + "The owner of the governing token and voter", + "This is the actual owner (voter) and corresponds to TokenOwnerRecord.governing_token_owner" + ], + "type": "pubkey" + }, + { + "name": "voter_weight", + "docs": [ + "Voter's weight", + "The weight of the voter provided by the addin for the given realm, governing_token_mint and", + "governing_token_owner (voter)" + ], + "type": "u64" + }, + { + "name": "voter_weight_expiry", + "docs": [ + "The slot when the voting weight expires", + "It should be set to None if the weight never expires", + "If the voter weight decays with time, for example for time locked based weights, then the", + "expiry must be set As a common pattern Revise instruction to update the weight should", + "be invoked before governance instruction within the same transaction and the expiry set", + "to the current slot to provide up to date weight" + ], + "type": { + "option": "u64" + } + }, + { + "name": "weight_action", + "docs": [ + "The governance action the voter's weight pertains to", + "It allows to provided voter's weight specific to the particular action the weight is", + "evaluated for When the action is provided then the governance program asserts the", + "executing action is the same as specified by the addin" + ], + "type": { + "option": { + "defined": { + "name": "VoterWeightAction" + } + } + } + }, + { + "name": "weight_action_target", + "docs": [ + "The target the voter's weight action pertains to", + "It allows to provided voter's weight specific to the target the weight is evaluated for", + "For example when addin supplies weight to vote on a particular proposal then it must", + "specify the proposal as the action target When the target is provided then the", + "governance program asserts the target is the same as specified by the addin" + ], + "type": { + "option": "pubkey" + } + }, + { + "name": "reserved", + "docs": [ + "Reserved space for future versions" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + } + ] +} \ No newline at end of file diff --git a/staking/target/idl/wallet_tester.json b/staking/target/idl/wallet_tester.json new file mode 100644 index 00000000..e8ac59df --- /dev/null +++ b/staking/target/idl/wallet_tester.json @@ -0,0 +1,48 @@ +{ + "address": "tstPARXbQ5yxVkRU2UcZRbYphzbUEW6t5ihzpLaafgz", + "metadata": { + "name": "wallet_tester", + "version": "1.0.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "test", + "discriminator": [ + 163, + 36, + 134, + 53, + 232, + 223, + 146, + 222 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "test_receipt", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + } + ] +} \ No newline at end of file diff --git a/staking/target/types/profile.ts b/staking/target/types/profile.ts new file mode 100644 index 00000000..7ccfe560 --- /dev/null +++ b/staking/target/types/profile.ts @@ -0,0 +1,112 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/profile.json`. + */ +export type Profile = { + "address": "prfmVhiQTN5Spgoxa8uZJba35V1s7XXReqbBiqPDWeJ", + "metadata": { + "name": "profile", + "version": "1.0.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "updateIdentity", + "discriminator": [ + 130, + 54, + 88, + 104, + 222, + 124, + 238, + 252 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "identityAccount", + "writable": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "identity", + "type": { + "defined": { + "name": "identity" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "identityAccount", + "discriminator": [ + 194, + 90, + 181, + 160, + 182, + 206, + 116, + 158 + ] + } + ], + "types": [ + { + "name": "identity", + "type": { + "kind": "enum", + "variants": [ + { + "name": "evm", + "fields": [ + { + "name": "pubkey", + "type": { + "option": { + "array": [ + "u8", + 20 + ] + } + } + } + ] + } + ] + } + }, + { + "name": "identityAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "identity", + "type": { + "defined": { + "name": "identity" + } + } + } + ] + } + } + ] +}; diff --git a/staking/target/types/staking.ts b/staking/target/types/staking.ts new file mode 100644 index 00000000..a4c70c29 --- /dev/null +++ b/staking/target/types/staking.ts @@ -0,0 +1,3125 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/staking.json`. + */ +export type Staking = { + "address": "pytS9TjG1qyAZypk7n8rw8gfW9sUaqqYyMhJQ4E7JCQ", + "metadata": { + "name": "staking", + "version": "2.0.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "acceptSplit", + "docs": [ + "* A split request can only be accepted by the `pda_authority` from\n * the config account. If accepted, `amount` tokens are transferred to a new stake account\n * owned by the `recipient` and the split request is reset (by setting `amount` to 0).\n * The recipient of a transfer can't vote during the epoch of the transfer.\n *\n * The `pda_authority` must explicitly approve both the amount of tokens and recipient, and\n * these parameters must match the request (in the `split_request` account)." + ], + "discriminator": [ + 177, + 172, + 17, + 93, + 193, + 86, + 54, + 222 + ], + "accounts": [ + { + "name": "pdaAuthority", + "writable": true, + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "sourceStakeAccountPositions", + "writable": true + }, + { + "name": "sourceStakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "sourceStakeAccountPositions" + } + ] + } + }, + { + "name": "sourceStakeAccountSplitRequest", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 108, + 105, + 116, + 95, + 114, + 101, + 113, + 117, + 101, + 115, + 116 + ] + }, + { + "kind": "account", + "path": "sourceStakeAccountPositions" + } + ] + } + }, + { + "name": "sourceStakeAccountCustody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "sourceStakeAccountPositions" + } + ] + } + }, + { + "name": "sourceCustodyAuthority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "sourceStakeAccountPositions" + } + ] + } + }, + { + "name": "newStakeAccountPositions", + "writable": true + }, + { + "name": "newStakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "newStakeAccountPositions" + } + ] + } + }, + { + "name": "newStakeAccountCustody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "newStakeAccountPositions" + } + ] + } + }, + { + "name": "newCustodyAuthority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "newStakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "pythTokenMint", + "relations": [ + "config" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + }, + { + "name": "advanceClock", + "discriminator": [ + 52, + 57, + 147, + 111, + 56, + 227, + 33, + 127 + ], + "accounts": [ + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "seconds", + "type": "i64" + } + ] + }, + { + "name": "closePosition", + "discriminator": [ + 123, + 134, + 81, + 0, + 49, + 68, + 98, + 98 + ], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions", + "writable": true + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountCustody", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "targetAccount", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "poolAuthority", + "signer": true, + "optional": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "index", + "type": "u8" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "targetWithParameters", + "type": { + "defined": { + "name": "targetWithParameters" + } + } + } + ] + }, + { + "name": "createPosition", + "docs": [ + "Creates a position", + "Looks for the first available place in the array, fails if array is full", + "Computes risk and fails if new positions exceed risk limit" + ], + "discriminator": [ + 48, + 215, + 197, + 153, + 96, + 203, + 180, + 133 + ], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions", + "writable": true + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountCustody", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "targetAccount", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "poolAuthority", + "signer": true, + "optional": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "targetWithParameters", + "type": { + "defined": { + "name": "targetWithParameters" + } + } + }, + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "createStakeAccount", + "docs": [ + "Trustless instruction that creates a stake account for a user", + "The main account i.e. the position accounts needs to be initialized outside of the program", + "otherwise we run into stack limits" + ], + "discriminator": [ + 105, + 24, + 131, + 19, + 201, + 250, + 157, + 73 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "stakeAccountPositions", + "writable": true + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountCustody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "custodyAuthority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "pythTokenMint", + "relations": [ + "config" + ] + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "lock", + "type": { + "defined": { + "name": "vestingSchedule" + } + } + } + ] + }, + { + "name": "createTarget", + "discriminator": [ + 76, + 144, + 128, + 239, + 121, + 210, + 123, + 39 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "governanceAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "targetAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "createVoterRecord", + "discriminator": [ + 3, + 12, + 113, + 222, + 177, + 4, + 152, + 165 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "stakeAccountPositions" + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "voterRecord", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 101, + 114, + 95, + 119, + 101, + 105, + 103, + 104, + 116 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "exportPositionType", + "discriminator": [ + 219, + 172, + 149, + 212, + 103, + 230, + 164, + 179 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "configAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "position", + "type": { + "defined": { + "name": "position" + } + } + } + ] + }, + { + "name": "initConfig", + "discriminator": [ + 23, + 235, + 115, + 232, + 168, + 96, + 1, + 231 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "configAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "rent", + "address": "SysvarRent111111111111111111111111111111111" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "globalConfig", + "type": { + "defined": { + "name": "globalConfig" + } + } + } + ] + }, + { + "name": "joinDaoLlc", + "docs": [ + "* Accept to join the DAO LLC\n * This must happen before create_position or update_voter_weight\n * The user signs a hash of the agreement and the program checks that the hash matches the\n * agreement" + ], + "discriminator": [ + 79, + 241, + 203, + 177, + 232, + 143, + 124, + 14 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions" + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "agreementHash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "mergeTargetPositions", + "discriminator": [ + 21, + 136, + 57, + 2, + 204, + 219, + 242, + 141 + ], + "accounts": [ + { + "name": "owner", + "docs": [ + "CHECK : This AccountInfo is safe because it's checked against stake_account_metadata" + ], + "writable": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions", + "writable": true + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "poolAuthority", + "signer": true, + "optional": true + } + ], + "args": [ + { + "name": "targetWithParameters", + "type": { + "defined": { + "name": "targetWithParameters" + } + } + } + ] + }, + { + "name": "recoverAccount", + "docs": [ + "Recovers a user's `stake account` ownership by transferring ownership\n * from a token account to the `owner` of that token account.\n *\n * This functionality addresses the scenario where a user mistakenly\n * created a stake account using their token account address as the owner." + ], + "discriminator": [ + 240, + 223, + 246, + 118, + 26, + 121, + 34, + 128 + ], + "accounts": [ + { + "name": "governanceAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "owner", + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions", + "writable": true + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "voterRecord", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 101, + 114, + 95, + 119, + 101, + 105, + 103, + 104, + 116 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [] + }, + { + "name": "requestSplit", + "docs": [ + "* Any user of the staking program can request to split their account and\n * give a part of it to another user.\n * This is mostly useful to transfer unvested tokens. Each user can only have one active\n * request at a time.\n * In the first step, the user requests a split by specifying the `amount` of tokens\n * they want to give to the other user and the `recipient`'s pubkey." + ], + "discriminator": [ + 133, + 146, + 228, + 165, + 251, + 207, + 146, + 23 + ], + "accounts": [ + { + "name": "owner", + "writable": true, + "signer": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions" + }, + { + "name": "stakeAccountMetadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountSplitRequest", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 112, + 108, + 105, + 116, + 95, + 114, + 101, + 113, + 117, + 101, + 115, + 116 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + }, + { + "name": "slashAccount", + "discriminator": [ + 185, + 97, + 8, + 208, + 118, + 205, + 166, + 2 + ], + "accounts": [ + { + "name": "poolAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "publisher", + "docs": [ + "CHECK : This AccountInfo is just used to construct the target that will get slashed" + ] + }, + { + "name": "stakeAccountPositions", + "writable": true + }, + { + "name": "stakeAccountMetadata", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountCustody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "governanceTargetAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + }, + { + "name": "destination", + "writable": true + }, + { + "name": "custodyAuthority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "slashRatio", + "type": "u64" + } + ] + }, + { + "name": "updateAgreementHash", + "discriminator": [ + 86, + 232, + 181, + 137, + 158, + 110, + 129, + 238 + ], + "accounts": [ + { + "name": "governanceAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "agreementHash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "updateGovernanceAuthority", + "discriminator": [ + 11, + 185, + 227, + 55, + 39, + 32, + 168, + 14 + ], + "accounts": [ + { + "name": "governanceAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "newAuthority", + "type": "pubkey" + } + ] + }, + { + "name": "updateMaxVoterWeight", + "discriminator": [ + 248, + 36, + 229, + 234, + 11, + 132, + 145, + 20 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "maxVoterRecord", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 97, + 120, + 95, + 118, + 111, + 116, + 101, + 114 + ] + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "updatePdaAuthority", + "discriminator": [ + 178, + 112, + 199, + 196, + 59, + 40, + 140, + 61 + ], + "accounts": [ + { + "name": "pdaAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "newAuthority", + "type": "pubkey" + } + ] + }, + { + "name": "updatePoolAuthority", + "discriminator": [ + 160, + 162, + 113, + 9, + 99, + 187, + 23, + 239 + ], + "accounts": [ + { + "name": "governanceAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "poolAuthority", + "type": "pubkey" + } + ] + }, + { + "name": "updateTokenListTime", + "discriminator": [ + 38, + 217, + 99, + 222, + 253, + 253, + 31, + 83 + ], + "accounts": [ + { + "name": "governanceAuthority", + "signer": true, + "relations": [ + "config" + ] + }, + { + "name": "config", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "tokenListTime", + "type": { + "option": "i64" + } + } + ] + }, + { + "name": "updateVoterWeight", + "discriminator": [ + 92, + 35, + 133, + 94, + 230, + 70, + 14, + 157 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "stakeAccountPositions" + }, + { + "name": "stakeAccountMetadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountCustody", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "voterRecord", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 101, + 114, + 95, + 119, + 101, + 105, + 103, + 104, + 116 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "governanceTarget", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 97, + 114, + 103, + 101, + 116 + ] + }, + { + "kind": "const", + "value": [ + 118, + 111, + 116, + 105, + 110, + 103 + ] + } + ] + } + } + ], + "args": [ + { + "name": "action", + "type": { + "defined": { + "name": "voterWeightAction" + } + } + } + ] + }, + { + "name": "withdrawStake", + "discriminator": [ + 153, + 8, + 22, + 138, + 105, + 176, + 87, + 66 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "stakeAccountMetadata" + ] + }, + { + "name": "destination", + "writable": true + }, + { + "name": "stakeAccountPositions" + }, + { + "name": "stakeAccountMetadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 107, + 101, + 95, + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "stakeAccountCustody", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "custodyAuthority", + "docs": [ + "CHECK : This AccountInfo is safe because it's a checked PDA" + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "stakeAccountPositions" + } + ] + } + }, + { + "name": "config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ] + } + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + } + ], + "accounts": [ + { + "name": "globalConfig", + "discriminator": [ + 149, + 8, + 156, + 202, + 160, + 252, + 176, + 217 + ] + }, + { + "name": "maxVoterWeightRecord", + "discriminator": [ + 157, + 95, + 242, + 151, + 16, + 98, + 26, + 118 + ] + }, + { + "name": "positionData", + "discriminator": [ + 85, + 195, + 241, + 79, + 124, + 192, + 79, + 11 + ] + }, + { + "name": "splitRequest", + "discriminator": [ + 80, + 85, + 187, + 143, + 62, + 147, + 234, + 248 + ] + }, + { + "name": "stakeAccountMetadataV2", + "discriminator": [ + 192, + 51, + 203, + 19, + 76, + 177, + 136, + 97 + ] + }, + { + "name": "targetMetadata", + "discriminator": [ + 157, + 23, + 139, + 117, + 181, + 44, + 197, + 130 + ] + }, + { + "name": "voterWeightRecord", + "discriminator": [ + 46, + 249, + 155, + 75, + 153, + 248, + 116, + 9 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "tooMuchExposureToIntegrityPool", + "msg": "Too much exposure to integrity pool" + }, + { + "code": 6001, + "name": "tooMuchExposureToGovernance", + "msg": "Too much exposure to governance" + }, + { + "code": 6002, + "name": "tokensNotYetVested", + "msg": "Tokens not yet vested" + }, + { + "code": 6003, + "name": "riskLimitExceeded", + "msg": "Risk limit exceeded" + }, + { + "code": 6004, + "name": "tooManyPositions", + "msg": "Number of position limit reached" + }, + { + "code": 6005, + "name": "positionNotInUse", + "msg": "Position not in use" + }, + { + "code": 6006, + "name": "createPositionWithZero", + "msg": "New position needs to have positive balance" + }, + { + "code": 6007, + "name": "closePositionWithZero", + "msg": "Closing a position of 0 is not allowed" + }, + { + "code": 6008, + "name": "invalidPosition", + "msg": "Invalid product/publisher pair" + }, + { + "code": 6009, + "name": "amountBiggerThanPosition", + "msg": "Amount to unlock bigger than position" + }, + { + "code": 6010, + "name": "alreadyUnlocking", + "msg": "Position already unlocking" + }, + { + "code": 6011, + "name": "zeroEpochDuration", + "msg": "Epoch duration is 0" + }, + { + "code": 6012, + "name": "withdrawToUnauthorizedAccount", + "msg": "Owner needs to own destination account" + }, + { + "code": 6013, + "name": "insufficientWithdrawableBalance", + "msg": "Insufficient balance to cover the withdrawal" + }, + { + "code": 6014, + "name": "wrongTarget", + "msg": "Target in position doesn't match target in instruction data" + }, + { + "code": 6015, + "name": "genericOverflow", + "msg": "An arithmetic operation unexpectedly overflowed" + }, + { + "code": 6016, + "name": "negativeBalance", + "msg": "Locked balance must be positive" + }, + { + "code": 6017, + "name": "frozen", + "msg": "Protocol is frozen" + }, + { + "code": 6018, + "name": "debuggingOnly", + "msg": "Not allowed when not debugging" + }, + { + "code": 6019, + "name": "proposalTooLong", + "msg": "Proposal too long" + }, + { + "code": 6020, + "name": "invalidVotingEpoch", + "msg": "Voting epoch is either too old or hasn't started" + }, + { + "code": 6021, + "name": "proposalNotActive", + "msg": "Voting hasn't started" + }, + { + "code": 6022, + "name": "noRemainingAccount", + "msg": "Extra governance account required" + }, + { + "code": 6023, + "name": "unauthorized", + "msg": "Unauthorized caller" + }, + { + "code": 6024, + "name": "accountUpgradeFailed", + "msg": "Precondition to upgrade account violated" + }, + { + "code": 6025, + "name": "notImplemented", + "msg": "Not implemented" + }, + { + "code": 6026, + "name": "positionSerDe", + "msg": "Error deserializing position" + }, + { + "code": 6027, + "name": "positionOutOfBounds", + "msg": "Position out of bounds" + }, + { + "code": 6028, + "name": "voteDuringTransferEpoch", + "msg": "Can't vote during an account's transfer epoch" + }, + { + "code": 6029, + "name": "notLlcMember", + "msg": "You need to be an LLC member to perform this action" + }, + { + "code": 6030, + "name": "invalidLlcAgreement", + "msg": "Invalid LLC agreement" + }, + { + "code": 6031, + "name": "splitZeroTokens", + "msg": "Can't split 0 tokens from an account" + }, + { + "code": 6032, + "name": "splitTooManyTokens", + "msg": "Can't split more tokens than are in the account" + }, + { + "code": 6033, + "name": "splitWithStake", + "msg": "Can't split a token account with staking positions. Unstake your tokens first." + }, + { + "code": 6034, + "name": "invalidApproval", + "msg": "The approval arguments do not match the split request." + }, + { + "code": 6035, + "name": "recoverWithStake", + "msg": "Can't recover account with staking positions. Unstake your tokens first." + }, + { + "code": 6036, + "name": "invalidPoolAuthority", + "msg": "The pool authority hasn't been passed or doesn't match the target" + }, + { + "code": 6037, + "name": "missingTargetAccount", + "msg": "The target account is missing" + }, + { + "code": 6038, + "name": "invalidSlashRatio", + "msg": "The slash ratio should be between 0 and 1" + }, + { + "code": 6039, + "name": "unexpectedTargetAccount", + "msg": "The target account is only expected when dealing with the governance target" + }, + { + "code": 6040, + "name": "other", + "msg": "other" + } + ], + "types": [ + { + "name": "globalConfig", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "governanceAuthority", + "type": "pubkey" + }, + { + "name": "pythTokenMint", + "type": "pubkey" + }, + { + "name": "pythGovernanceRealm", + "type": "pubkey" + }, + { + "name": "removedUnlockingDuration", + "type": "u8" + }, + { + "name": "epochDuration", + "type": "u64" + }, + { + "name": "freeze", + "type": "bool" + }, + { + "name": "pdaAuthority", + "type": "pubkey" + }, + { + "name": "governanceProgram", + "type": "pubkey" + }, + { + "name": "pythTokenListTime", + "docs": [ + "Once the pyth token is listed, governance can update the config to set this value.", + "Once this value is set, vesting schedules that depend on the token list date can start", + "vesting." + ], + "type": { + "option": "i64" + } + }, + { + "name": "agreementHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "mockClockTime", + "type": "i64" + }, + { + "name": "poolAuthority", + "type": "pubkey" + } + ] + } + }, + { + "name": "maxVoterWeightRecord", + "docs": [ + "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/max_voter_weight.rs" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "realm", + "docs": [ + "The Realm the MaxVoterWeightRecord belongs to" + ], + "type": "pubkey" + }, + { + "name": "governingTokenMint", + "docs": [ + "Governing Token Mint the MaxVoterWeightRecord is associated with", + "Note: The addin can take deposits of any tokens and is not restricted to the community or", + "council tokens only" + ], + "type": "pubkey" + }, + { + "name": "maxVoterWeight", + "docs": [ + "Max voter weight", + "The max voter weight provided by the addin for the given realm and governing_token_mint" + ], + "type": "u64" + }, + { + "name": "maxVoterWeightExpiry", + "docs": [ + "The slot when the max voting weight expires", + "It should be set to None if the weight never expires", + "If the max vote weight decays with time, for example for time locked based weights, then", + "the expiry must be set As a pattern Revise instruction to update the max weight should", + "be invoked before governance instruction within the same transaction and the expiry set", + "to the current slot to provide up to date weight" + ], + "type": { + "option": "u64" + } + }, + { + "name": "reserved", + "docs": [ + "Reserved space for future versions" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + }, + { + "name": "position", + "docs": [ + "This represents a staking position, i.e. an amount that someone has staked to a particular", + "target. This is one of the core pieces of our staking design, and stores all", + "of the state related to a position The voting position is a position where the", + "target_with_parameters is VOTING" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "activationEpoch", + "type": "u64" + }, + { + "name": "unlockingStart", + "type": { + "option": "u64" + } + }, + { + "name": "targetWithParameters", + "type": { + "defined": { + "name": "targetWithParameters" + } + } + } + ] + } + }, + { + "name": "positionData", + "docs": [ + "The header of DynamicPositionArray" + ], + "serialization": "bytemuck", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "splitRequest", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "stakeAccountMetadataV2", + "docs": [ + "This is the metadata account for each staker", + "It is derived from the positions account with seeds \"stake_metadata\" and the positions account", + "pubkey It stores some PDA bumps, the owner of the account and the vesting schedule" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "metadataBump", + "type": "u8" + }, + { + "name": "custodyBump", + "type": "u8" + }, + { + "name": "authorityBump", + "type": "u8" + }, + { + "name": "voterBump", + "type": "u8" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "lock", + "type": { + "defined": { + "name": "vestingSchedule" + } + } + }, + { + "name": "nextIndex", + "type": "u8" + }, + { + "name": "deprecated", + "type": { + "option": "u64" + } + }, + { + "name": "signedAgreementHash", + "type": { + "option": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + }, + { + "name": "targetMetadata", + "docs": [ + "This represents a target that users can stake to", + "Currently we store the last time the target account was updated, the current locked balance", + "and the amount by which the locked balance will change in the next epoch" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "bump", + "type": "u8" + }, + { + "name": "lastUpdateAt", + "type": "u64" + }, + { + "name": "prevEpochLocked", + "type": "u64" + }, + { + "name": "locked", + "type": "u64" + }, + { + "name": "deltaLocked", + "type": "i64" + } + ] + } + }, + { + "name": "targetWithParameters", + "type": { + "kind": "enum", + "variants": [ + { + "name": "voting" + }, + { + "name": "integrityPool", + "fields": [ + { + "name": "publisher", + "type": "pubkey" + } + ] + } + ] + } + }, + { + "name": "vestingSchedule", + "docs": [ + "Represents how a given initial balance vests over time", + "It is unit-less, but units must be consistent" + ], + "repr": { + "kind": "rust" + }, + "type": { + "kind": "enum", + "variants": [ + { + "name": "fullyVested" + }, + { + "name": "periodicVesting", + "fields": [ + { + "name": "initialBalance", + "type": "u64" + }, + { + "name": "startDate", + "type": "i64" + }, + { + "name": "periodDuration", + "type": "u64" + }, + { + "name": "numPeriods", + "type": "u64" + } + ] + }, + { + "name": "periodicVestingAfterListing", + "fields": [ + { + "name": "initialBalance", + "type": "u64" + }, + { + "name": "periodDuration", + "type": "u64" + }, + { + "name": "numPeriods", + "type": "u64" + } + ] + } + ] + } + }, + { + "name": "voterWeightAction", + "docs": [ + "The governance action VoterWeight is evaluated for" + ], + "type": { + "kind": "enum", + "variants": [ + { + "name": "castVote" + }, + { + "name": "commentProposal" + }, + { + "name": "createGovernance" + }, + { + "name": "createProposal" + }, + { + "name": "signOffProposal" + } + ] + } + }, + { + "name": "voterWeightRecord", + "docs": [ + "Copied this struct from https://github.com/solana-labs/solana-program-library/blob/master/governance/addin-api/src/voter_weight.rs", + "Anchor has a macro (vote_weight_record) that is supposed to generate this struct, but it doesn't", + "work because the error's macros are not updated for anchor 0.22.0.", + "Even if it did work, the type wouldn't show up in the IDL. SPL doesn't produce an API, which", + "means that means we'd need the equivalent of this code on the client side.", + "If Anchor fixes the macro, we might consider changing it" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "realm", + "docs": [ + "VoterWeightRecord discriminator sha256(\"account:VoterWeightRecord\")[..8]", + "Note: The discriminator size must match the addin implementing program discriminator size", + "to ensure it's stored in the private space of the account data and it's unique", + "pub account_discriminator: [u8; 8],", + "The Realm the VoterWeightRecord belongs to" + ], + "type": "pubkey" + }, + { + "name": "governingTokenMint", + "docs": [ + "Governing Token Mint the VoterWeightRecord is associated with", + "Note: The addin can take deposits of any tokens and is not restricted to the community or", + "council tokens only" + ], + "type": "pubkey" + }, + { + "name": "governingTokenOwner", + "docs": [ + "The owner of the governing token and voter", + "This is the actual owner (voter) and corresponds to TokenOwnerRecord.governing_token_owner" + ], + "type": "pubkey" + }, + { + "name": "voterWeight", + "docs": [ + "Voter's weight", + "The weight of the voter provided by the addin for the given realm, governing_token_mint and", + "governing_token_owner (voter)" + ], + "type": "u64" + }, + { + "name": "voterWeightExpiry", + "docs": [ + "The slot when the voting weight expires", + "It should be set to None if the weight never expires", + "If the voter weight decays with time, for example for time locked based weights, then the", + "expiry must be set As a common pattern Revise instruction to update the weight should", + "be invoked before governance instruction within the same transaction and the expiry set", + "to the current slot to provide up to date weight" + ], + "type": { + "option": "u64" + } + }, + { + "name": "weightAction", + "docs": [ + "The governance action the voter's weight pertains to", + "It allows to provided voter's weight specific to the particular action the weight is", + "evaluated for When the action is provided then the governance program asserts the", + "executing action is the same as specified by the addin" + ], + "type": { + "option": { + "defined": { + "name": "voterWeightAction" + } + } + } + }, + { + "name": "weightActionTarget", + "docs": [ + "The target the voter's weight action pertains to", + "It allows to provided voter's weight specific to the target the weight is evaluated for", + "For example when addin supplies weight to vote on a particular proposal then it must", + "specify the proposal as the action target When the target is provided then the", + "governance program asserts the target is the same as specified by the addin" + ], + "type": { + "option": "pubkey" + } + }, + { + "name": "reserved", + "docs": [ + "Reserved space for future versions" + ], + "type": { + "array": [ + "u8", + 8 + ] + } + } + ] + } + } + ] +}; diff --git a/staking/target/types/wallet_tester.ts b/staking/target/types/wallet_tester.ts new file mode 100644 index 00000000..1208505b --- /dev/null +++ b/staking/target/types/wallet_tester.ts @@ -0,0 +1,54 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/wallet_tester.json`. + */ +export type WalletTester = { + "address": "tstPARXbQ5yxVkRU2UcZRbYphzbUEW6t5ihzpLaafgz", + "metadata": { + "name": "walletTester", + "version": "1.0.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "test", + "discriminator": [ + 163, + 36, + 134, + 53, + 232, + 223, + 146, + 222 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "testReceipt", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "payer" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + } + ] +};