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

fix: Move lqty allocation checks #77

Merged
merged 2 commits into from
Nov 21, 2024
Merged

fix: Move lqty allocation checks #77

merged 2 commits into from
Nov 21, 2024

Conversation

bingen
Copy link
Contributor

@bingen bingen commented Nov 19, 2024

As value now encodes timestamp, it would never be zero, we need to decode and then check.

As value now encodes timestamp, it would never be zero, we need to
decode and then check.
@bingen bingen self-assigned this Nov 19, 2024
&& (totalLQTYAllocation.next > _epoch || totalLQTYAllocation.next == 0),
"BribeInitiative: invalid-prev-total-lqty-allocation-epoch"
);

(uint88 totalLQTY, uint120 totalAverageTimestamp) = _decodeLQTYAllocation(totalLQTYAllocation.value);
require(totalLQTY > 0, "BribeInitiative: invalid-prev-total-lqty");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rephrase the error message. The variable being checked stands for the total LQTY allocated to the initiative in the epoch from which the bribes are being claimed from. Thus, I guess a better message would be: invalid-total-lqty-allocation or total-lqty-allocation-zero.

@@ -113,6 +113,7 @@ contract BribeInitiative is IInitiative, IBribeInitiative {
uint240 totalVotes = governance.lqtyToVotes(totalLQTY, scaledEpochEnd, totalAverageTimestamp);
if (totalVotes != 0) {
(uint88 lqty, uint120 averageTimestamp) = _decodeLQTYAllocation(lqtyAllocation.value);
require(lqty > 0, "BribeInitiative: invalid-prev-lqty");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor

@danielattilasimon danielattilasimon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I suggest we tweak the revert messages!

@bingen bingen merged commit d6d3edf into main Nov 21, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants