Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions programs/steward/src/instructions/rebalance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ use crate::{
errors::StewardError,
events::{DecreaseComponents, RebalanceEvent, RebalanceTypeTag},
maybe_transition,
stake_pool_utils::deserialize_stake_pool,
stake_pool_utils::{
deserialize_stake_pool, stake_pool_reserve_stake, stake_pool_validator_list,
stake_pool_withdraw_bump_seed,
},
utils::{get_stake_pool_address, get_validator_stake_info_at_index, state_checks},
Config, StewardStateAccount, StewardStateAccountV2, StewardStateEnum,
};
Expand Down Expand Up @@ -62,21 +65,21 @@ pub struct Rebalance<'info> {
STAKE_POOL_WITHDRAW_SEED
],
seeds::program = spl_stake_pool::ID,
bump = deserialize_stake_pool(&stake_pool)?.stake_withdraw_bump_seed
bump = stake_pool_withdraw_bump_seed(&stake_pool)?
)]
pub withdraw_authority: AccountInfo<'info>,

/// CHECK: passing through, checks are done by spl-stake-pool
#[account(
mut,
address = deserialize_stake_pool(&stake_pool)?.validator_list
address = stake_pool_validator_list(&stake_pool)?
)]
pub validator_list: AccountInfo<'info>,

/// CHECK: passing through, checks are done by spl-stake-pool
#[account(
mut,
address = deserialize_stake_pool(&stake_pool)?.reserve_stake
address = stake_pool_reserve_stake(&stake_pool)?
)]
pub reserve_stake: AccountInfo<'info>,

Expand Down
15 changes: 15 additions & 0 deletions programs/steward/src/stake_pool_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,21 @@ pub fn deserialize_stake_pool(
)?)
}

#[inline(never)]
pub fn stake_pool_withdraw_bump_seed(account_info: &AccountInfo) -> Result<u8> {
Ok(deserialize_stake_pool(account_info)?.stake_withdraw_bump_seed)
}

#[inline(never)]
pub fn stake_pool_validator_list(account_info: &AccountInfo) -> Result<Pubkey> {
Ok(deserialize_stake_pool(account_info)?.validator_list)
}

#[inline(never)]
pub fn stake_pool_reserve_stake(account_info: &AccountInfo) -> Result<Pubkey> {
Ok(deserialize_stake_pool(account_info)?.reserve_stake)
}

pub fn deserialize_validator_list(
account_info: &AccountInfo,
) -> Result<spl_stake_pool::state::ValidatorList> {
Expand Down
Loading