diff --git a/pallets/creator-staking/src/functions.rs b/pallets/creator-staking/src/functions.rs index 99c04e12..2e307870 100644 --- a/pallets/creator-staking/src/functions.rs +++ b/pallets/creator-staking/src/functions.rs @@ -366,10 +366,10 @@ impl Pallet { staked: BalanceOf, era: EraIndex, ) -> BalanceOf { - if let Some(reward_and_stake) = Self::general_era_info(era) { + if let Some(era_info) = Self::general_era_info(era) { let (_, combined_backers_reward_share) = - Self::distributed_rewards_between_creator_and_backers(creator_stake_info, &reward_and_stake); - Perbill::from_rational(staked, reward_and_stake.staked) * combined_backers_reward_share + Self::distributed_rewards_between_creator_and_backers(creator_stake_info, &era_info); + Perbill::from_rational(staked, era_info.staked) * combined_backers_reward_share } else { Zero::zero() } diff --git a/pallets/creator-staking/src/lib.rs b/pallets/creator-staking/src/lib.rs index 326a46ef..494ad162 100644 --- a/pallets/creator-staking/src/lib.rs +++ b/pallets/creator-staking/src/lib.rs @@ -612,12 +612,12 @@ pub mod pallet { let current_era = Self::current_era(); ensure!(era_to_claim < current_era, Error::::CannotClaimInFutureEra); - let staking_info = Self::creator_stake_info(creator_id, era_to_claim).unwrap_or_default(); + let creator_stake_info = Self::creator_stake_info(creator_id, era_to_claim).unwrap_or_default(); let reward_and_stake = Self::general_era_info(era_to_claim).ok_or(Error::::EraNotFound)?; let (_, combined_backers_reward_share) = - Self::distributed_rewards_between_creator_and_backers(&staking_info, &reward_and_stake); + Self::distributed_rewards_between_creator_and_backers(&creator_stake_info, &reward_and_stake); let backer_reward = Perbill::from_rational(backer_staked, reward_and_stake.staked) * combined_backers_reward_share; diff --git a/pallets/creator-staking/src/tests/testing_utils.rs b/pallets/creator-staking/src/tests/testing_utils.rs index ecbb79d6..ef48f7c6 100644 --- a/pallets/creator-staking/src/tests/testing_utils.rs +++ b/pallets/creator-staking/src/tests/testing_utils.rs @@ -595,7 +595,7 @@ pub(super) fn assert_claim_creator(creator_id: SpaceId, claim_era: EraIndex) { assert!(final_state.creator_stakes_info.rewards_claimed); - // Just in case dev is also a backer - this shouldn't cause any change in StakesInfo or BackerLocksByAccount + // Just in case creator is also a backer - this shouldn't cause any change in StakesInfo or BackerLocksByAccount assert_eq!(init_state.backer_stakes.stakes, final_state.backer_stakes.stakes); assert_eq!(init_state.backer_locks.total_locked, final_state.backer_locks.total_locked); assert_eq!(init_state.backer_locks.unbonding_info.vec(), final_state.backer_locks.unbonding_info.vec()); diff --git a/pallets/creator-staking/src/tests/tests.rs b/pallets/creator-staking/src/tests/tests.rs index eaead87e..76a4a034 100644 --- a/pallets/creator-staking/src/tests/tests.rs +++ b/pallets/creator-staking/src/tests/tests.rs @@ -1817,12 +1817,12 @@ fn distributed_rewards_between_creator_and_backers_util() { let creator_stake_ratio = Perbill::from_rational(staked_on_creator, total_staked); let calculated_backers_reward = base_backers_reward; - let calculated_dev_reward = creator_stake_ratio * base_creators_reward; - assert_eq!(calculated_dev_reward, creator_reward_share); + let calculated_creator_reward = creator_stake_ratio * base_creators_reward; + assert_eq!(calculated_creator_reward, creator_reward_share); assert_eq!(calculated_backers_reward, combined_backers_reward_share); assert_eq!( - calculated_backers_reward + calculated_dev_reward, + calculated_backers_reward + calculated_creator_reward, creator_reward_share + combined_backers_reward_share ); }