Skip to content

Commit

Permalink
replaced todo with descriptive error
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Jul 22, 2024
1 parent cf86aed commit e02c2fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions contracts/distribution/dao-rewards-distributor/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,7 @@ pub enum ContractError {

#[error("There is no voting power registered, so no one will receive these funds")]
NoVotingPowerNoRewards {},

#[error("Cannot update emission rate because this distribution has accumulated the maximum rewards. Start a new distribution with the new emission rate instead.")]
DistributionHistoryTooLarge {},
}
4 changes: 2 additions & 2 deletions contracts/distribution/dao-rewards-distributor/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,10 @@ impl DistributionState {
};

// 2. add current epoch rewards earned to historical rewards
// TODO: what to do on overflow?
self.historical_earned_puvp = self
.historical_earned_puvp
.checked_add(self.active_epoch.total_earned_puvp)?;
.checked_add(self.active_epoch.total_earned_puvp)
.map_err(|_| ContractError::DistributionHistoryTooLarge {})?;

// 3. deduct the distributed rewards amount from total funded amount, as
// those rewards are no longer distributed in the new epoch
Expand Down

0 comments on commit e02c2fd

Please sign in to comment.