Skip to content

Commit

Permalink
feat: add delegation fee to cli (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
guibescos authored Sep 11, 2024
1 parent ea0e6f8 commit 54ef7b6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions staking/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ pub enum Action {
wormhole: Pubkey,
},
InitializePoolRewardCustody {},
UpdateDelegationFee {
#[clap(long, help = "New fee")]
delegation_fee: u64,
},
}
29 changes: 29 additions & 0 deletions staking/cli/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,32 @@ pub fn fetch_publisher_caps_and_advance(

advance(rpc_client, payer, publisher_caps);
}

pub fn update_delegation_fee(rpc_client: &RpcClient, payer: &Keypair, 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)
.unwrap()
.as_slice(),
)
.unwrap();

let accounts = integrity_pool::accounts::UpdateDelegationFee {
reward_program_authority: payer.pubkey(),
pool_config,
pool_data,
system_program: system_program::ID,
};

let instruction_data = integrity_pool::instruction::UpdateDelegationFee { delegation_fee };

let instruction = Instruction {
program_id: integrity_pool::ID,
accounts: accounts.to_account_metas(None),
data: instruction_data.data(),
};

process_transaction(rpc_client, &[instruction], &[payer]);
}
4 changes: 4 additions & 0 deletions staking/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use {
fetch_publisher_caps_and_advance,
initialize_pool,
initialize_reward_custody,
update_delegation_fee,
},
solana_client::rpc_client::RpcClient,
solana_sdk::commitment_config::CommitmentConfig,
Expand Down Expand Up @@ -50,5 +51,8 @@ fn main() {
Action::InitializePoolRewardCustody {} => {
initialize_reward_custody(&rpc_client, &keypair);
}
Action::UpdateDelegationFee { delegation_fee } => {
update_delegation_fee(&rpc_client, &keypair, delegation_fee)
}
}
}

0 comments on commit 54ef7b6

Please sign in to comment.