Skip to content

Commit

Permalink
Fix bug in reward calc involving fractional delegations.
Browse files Browse the repository at this point in the history
  • Loading branch information
FiveMovesAhead committed Dec 22, 2024
1 parent 14c7b65 commit c8e4378
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tig-protocol/src/contracts/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ pub(crate) async fn update(cache: &mut AddBlockCache) {

for delegator in opow_data.delegators.iter() {
let player_data = active_players_block_data.get_mut(delegator).unwrap();
player_data.reward_by_type.insert(
RewardType::Delegator,
shared_amount * player_data.weighted_deposit / opow_data.delegated_weighted_deposit,
);
let fraction = PreciseNumber::from_f64(*player_data.delegatees.get(delegatee).unwrap());
*player_data
.reward_by_type
.entry(RewardType::Delegator)
.or_insert(zero.clone()) += shared_amount * fraction * player_data.weighted_deposit
/ opow_data.delegated_weighted_deposit;
}
}
}

0 comments on commit c8e4378

Please sign in to comment.