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 4089720
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(),

Check warning on line 280 in contracts/distribution/dao-rewards-distributor/src/state.rs

View check run for this annotation

Codecov / codecov/patch

contracts/distribution/dao-rewards-distributor/src/state.rs#L280

Added line #L280 was not covered by tests
})?;

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

Please sign in to comment.