diff --git a/staking/integration-tests/src/utils/constants.rs b/staking/integration-tests/src/utils/constants.rs index f7ac1275..cd19a51a 100644 --- a/staking/integration-tests/src/utils/constants.rs +++ b/staking/integration-tests/src/utils/constants.rs @@ -6,5 +6,5 @@ use integrity_pool::utils::types::{ // 100 PYTH tokens pub const STAKED_TOKENS: frac64 = 100 * FRAC_64_MULTIPLIER; -// 10% yield per epoch -pub const YIELD: frac64 = FRAC_64_MULTIPLIER / 10; +// 1% yield per epoch +pub const YIELD: frac64 = FRAC_64_MULTIPLIER / 100; diff --git a/staking/integration-tests/tests/initialize_pool.rs b/staking/integration-tests/tests/initialize_pool.rs index 1617a8c4..4eb8a007 100644 --- a/staking/integration-tests/tests/initialize_pool.rs +++ b/staking/integration-tests/tests/initialize_pool.rs @@ -19,6 +19,7 @@ use { integrity_pool::{ error::IntegrityPoolError, state::pool::PoolConfig, + utils::types::FRAC_64_MULTIPLIER, }, solana_sdk::{ program_error::ProgramError, @@ -101,4 +102,15 @@ fn test_update_y() { IntegrityPoolError::InvalidRewardProgramAuthority, 0 ); + + assert_anchor_program_error!( + update_y( + &mut svm, + &payer, + &reward_program_authority, + FRAC_64_MULTIPLIER / 100 + 1 + ), + IntegrityPoolError::InvalidY, + 0 + ); } diff --git a/staking/programs/integrity-pool/src/error.rs b/staking/programs/integrity-pool/src/error.rs index 88ce4d77..6051075c 100644 --- a/staking/programs/integrity-pool/src/error.rs +++ b/staking/programs/integrity-pool/src/error.rs @@ -30,4 +30,6 @@ pub enum IntegrityPoolError { #[msg("Delegation fee must not be greater than 100%")] InvalidDelegationFee, InvalidPublisher, + #[msg("Y should not be greater than 1%")] + InvalidY, } diff --git a/staking/programs/integrity-pool/src/lib.rs b/staking/programs/integrity-pool/src/lib.rs index 61c73047..1cdfe7bf 100644 --- a/staking/programs/integrity-pool/src/lib.rs +++ b/staking/programs/integrity-pool/src/lib.rs @@ -36,6 +36,8 @@ pub mod integrity_pool { pyth_token_mint: Pubkey, y: frac64, ) -> Result<()> { + require_gte!(FRAC_64_MULTIPLIER / 100, y, IntegrityPoolError::InvalidY); + let pool_config = &mut ctx.accounts.pool_config; pool_config.pool_data = ctx.accounts.pool_data.key(); pool_config.reward_program_authority = reward_program_authority; @@ -49,6 +51,8 @@ pub mod integrity_pool { } pub fn update_y(ctx: Context, y: frac64) -> Result<()> { + require_gte!(FRAC_64_MULTIPLIER / 100, y, IntegrityPoolError::InvalidY); + ctx.accounts.pool_config.y = y; Ok(()) }