diff --git a/bot/src/generic_stake_pool.rs b/bot/src/generic_stake_pool.rs index 42ec051a..dded407c 100644 --- a/bot/src/generic_stake_pool.rs +++ b/bot/src/generic_stake_pool.rs @@ -40,6 +40,7 @@ pub trait GenericStakePool { client: &MultiClient, dry_run: bool, desired_validator_stake: &[ValidatorStake], + bonus_multiplier: Option, ) -> Result< ( EpochStakeNotes, diff --git a/bot/src/main.rs b/bot/src/main.rs index 3da2d5ad..9e47be44 100644 --- a/bot/src/main.rs +++ b/bot/src/main.rs @@ -2576,6 +2576,11 @@ fn main() -> BoxResult<()> { cluster_multi_client, pre_run_dry_run || config.dry_run, &desired_validator_stake, + if config.cluster == Testnet { + Some(0.85) + } else { + None + }, )?; let mut summary_messages: Vec = vec![format!( diff --git a/bot/src/noop_stake_pool.rs b/bot/src/noop_stake_pool.rs index 3f233131..4873b898 100644 --- a/bot/src/noop_stake_pool.rs +++ b/bot/src/noop_stake_pool.rs @@ -20,6 +20,7 @@ impl GenericStakePool for NoopStakePool { _client: &MultiClient, dry_run: bool, desired_validator_stake: &[ValidatorStake], + _bonus_multiplier: Option, ) -> Result< ( EpochStakeNotes, diff --git a/bot/src/stake_pool.rs b/bot/src/stake_pool.rs index 7e7b974d..b00b438f 100644 --- a/bot/src/stake_pool.rs +++ b/bot/src/stake_pool.rs @@ -157,6 +157,7 @@ impl GenericStakePool for StakePoolOMatic { client: &MultiClient, dry_run: bool, desired_validator_stake: &[ValidatorStake], + _bonus_multiplier: Option, ) -> Result< ( EpochStakeNotes, @@ -932,13 +933,13 @@ mod test { .collect::>(); stake_o_matic - .apply(client, false, &desired_validator_stake) + .apply(client, false, &desired_validator_stake, None) .unwrap(); assert!(num_stake_accounts(client, pool_withdraw_authority) > 1 + validators.len()); let _epoch = wait_for_next_epoch(client).unwrap(); stake_o_matic - .apply(client, false, &desired_validator_stake) + .apply(client, false, &desired_validator_stake, None) .unwrap(); assert_eq!( @@ -1095,6 +1096,7 @@ mod test { priority: false, }) .collect::>(), + None, ) .unwrap(); @@ -1156,6 +1158,7 @@ mod test { priority: false, }) .collect::>(), + None, ) .unwrap(); @@ -1203,6 +1206,7 @@ mod test { priority: false, }) .collect::>(), + None, ) .unwrap(); @@ -1253,11 +1257,11 @@ mod test { ]; stake_o_matic - .apply(&client, false, &desired_validator_stake) + .apply(&client, false, &desired_validator_stake, None) .unwrap(); let _epoch = wait_for_next_epoch(&client).unwrap(); stake_o_matic - .apply(&client, false, &desired_validator_stake) + .apply(&client, false, &desired_validator_stake, None) .unwrap(); info!("Check after first epoch"); @@ -1285,7 +1289,7 @@ mod test { info!("Check after second epoch"); let _epoch = wait_for_next_epoch(&client).unwrap(); stake_o_matic - .apply(&client, false, &desired_validator_stake) + .apply(&client, false, &desired_validator_stake, None) .unwrap(); assert_eq!( @@ -1310,11 +1314,11 @@ mod test { // =========================================================== info!("remove all validators"); // deactivate all validator stake and remove from pool - stake_o_matic.apply(&client, false, &[]).unwrap(); + stake_o_matic.apply(&client, false, &[], None).unwrap(); // withdraw removed validator stake into the staker let _epoch = wait_for_next_epoch(&client).unwrap(); - stake_o_matic.apply(&client, false, &[]).unwrap(); + stake_o_matic.apply(&client, false, &[], None).unwrap(); // all stake has been returned to the reserve account assert_reserve_account_only( min_reserve_stake_balance + stake_rent_exemption + total_stake_amount, diff --git a/bot/src/stake_pool_v0.rs b/bot/src/stake_pool_v0.rs index 885ac4fa..5d4331b4 100644 --- a/bot/src/stake_pool_v0.rs +++ b/bot/src/stake_pool_v0.rs @@ -109,6 +109,7 @@ impl GenericStakePool for StakePool { client: &MultiClient, dry_run: bool, desired_validator_stake: &[ValidatorStake], + bonus_multiplier: Option, ) -> Result< ( EpochStakeNotes, @@ -210,10 +211,11 @@ impl GenericStakePool for StakePool { Sol(total_bonus_stake_amount) ); - let bonus_stake_amount = if bonus_stake_node_count == 0 { + let bonus_stake_amount: u64 = if bonus_stake_node_count == 0 { 0 } else { - total_bonus_stake_amount / (bonus_stake_node_count as u64) + (bonus_multiplier.unwrap_or(1.0) + * ((total_bonus_stake_amount / bonus_stake_node_count) as f64)) as u64 }; info!("Bonus stake amount: {}", Sol(bonus_stake_amount)); @@ -900,7 +902,7 @@ mod test { .collect::>(); stake_pool - .apply(client, false, &desired_validator_stake) + .apply(client, false, &desired_validator_stake, None) .unwrap(); assert_eq!( @@ -909,7 +911,7 @@ mod test { ); let _epoch = wait_for_next_epoch(client).unwrap(); stake_pool - .apply(client, false, &desired_validator_stake) + .apply(client, false, &desired_validator_stake, None) .unwrap(); assert_eq!( @@ -1034,6 +1036,7 @@ mod test { priority: false, }) .collect::>(), + None, ) .unwrap(); @@ -1107,11 +1110,11 @@ mod test { ]; stake_pool - .apply(&client, false, &desired_validator_stake) + .apply(&client, false, &desired_validator_stake, None) .unwrap(); let _epoch = wait_for_next_epoch(&client).unwrap(); stake_pool - .apply(&client, false, &desired_validator_stake) + .apply(&client, false, &desired_validator_stake, None) .unwrap(); // after the first epoch, validators 0 and 1 are at their target levels but validator 2 @@ -1142,7 +1145,7 @@ mod test { let _epoch = wait_for_next_epoch(&client).unwrap(); stake_pool - .apply(&client, false, &desired_validator_stake) + .apply(&client, false, &desired_validator_stake, None) .unwrap(); assert_eq!( @@ -1173,10 +1176,10 @@ mod test { info!("remove all validators"); // deactivate all validator stake - stake_pool.apply(&client, false, &[]).unwrap(); + stake_pool.apply(&client, false, &[], None).unwrap(); let _epoch = wait_for_next_epoch(&client).unwrap(); // merge deactivated validator stake back into the reserve - stake_pool.apply(&client, false, &[]).unwrap(); + stake_pool.apply(&client, false, &[], None).unwrap(); // all stake has returned to the reserve account assert_reserve_account_only(); }