Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed TODO and added error handling to rewards distributor #858

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
};

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