Skip to content

Commit

Permalink
replaced todo with descriptive error (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso authored Jul 22, 2024
1 parent aa0fa5f commit f0dceb1
Show file tree
Hide file tree
Showing 2 changed files with 7 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. (Overflow: {err})")]
DistributionHistoryTooLarge { err: String },
}
6 changes: 4 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,12 @@ 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(|err| ContractError::DistributionHistoryTooLarge {
err: err.to_string(),
})?;

// 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 f0dceb1

Please sign in to comment.