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

Adds assertions to verify rewards contract balance, rewards surplus and weight #144

Merged
merged 18 commits into from
Jun 28, 2024

Conversation

has5aan
Copy link
Member

@has5aan has5aan commented May 20, 2024

What was the problem?

This PR resolves issues:

How was it solved?

Added checkRewardsContractBalance to verify that rewards contract balance after all stakes claim rewards at a day is equal to funds - sum of dailyRewards from 1st day to yesterday.

Added verifyRewardsSurplusForLockedAmountBetweenDays to verify reward surplus amount.

Added checkConsistencyTotalWeight to verify that at all times totalWeight is the sum of daily weights and it is zero if all positions are expired or greater than zero if at least one position is active.

Added checks to verify zero values for amount and duration for fundStakingRewards, addUnusedRewards and _addRewards.

Refactored scenarios.

@has5aan has5aan self-assigned this May 20, 2024
@has5aan has5aan requested a review from gkoumout May 20, 2024 11:09
@has5aan has5aan changed the title checkRewardsContractBalance for scenario1 Adds assertions to verify rewards contract balance May 24, 2024
@matjazv matjazv force-pushed the feature/improvements-and-recommendations branch from 98cfef1 to 07b3d82 Compare May 28, 2024 09:57
@has5aan has5aan force-pushed the 128 branch 2 times, most recently from c56b1e0 to 29af93c Compare June 3, 2024 19:09
@has5aan has5aan changed the title Adds assertions to verify rewards contract balance Adds assertions to verify rewards contract balance and rewards surplus Jun 4, 2024
@has5aan has5aan marked this pull request as ready for review June 4, 2024 11:27
@has5aan has5aan changed the base branch from feature/improvements-and-recommendations to development June 10, 2024 08:50
@has5aan has5aan changed the base branch from development to feature/improvements-and-recommendations June 10, 2024 08:51
@has5aan has5aan changed the title Adds assertions to verify rewards contract balance and rewards surplus Adds assertions to verify rewards contract balance, rewards surplus and weight Jun 17, 2024
Copy link
Contributor

@gkoumout gkoumout left a comment

Choose a reason for hiding this comment

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

Left a few comments/questions

test/L2/L2Reward.t.sol Outdated Show resolved Hide resolved
test/L2/L2Reward.t.sol Outdated Show resolved Hide resolved
test/L2/L2Reward.t.sol Outdated Show resolved Hide resolved
@gkoumout gkoumout self-requested a review June 21, 2024 12:40
@matjazv matjazv force-pushed the feature/improvements-and-recommendations branch from 48b2eba to 24e88be Compare June 21, 2024 13:06
test/L2/L2Reward.t.sol Show resolved Hide resolved
test/L2/L2Reward.t.sol Show resolved Hide resolved
Copy link
Contributor

@gkoumout gkoumout 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! Just left a few last minor comments.

test/L2/L2Reward.t.sol Outdated Show resolved Hide resolved
test/L2/L2Reward.t.sol Show resolved Hide resolved
test/L2/L2Reward.t.sol Show resolved Hide resolved
@has5aan has5aan requested a review from matjazv June 27, 2024 13:05
Copy link
Contributor

@matjazv matjazv left a comment

Choose a reason for hiding this comment

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

Nice work!

@matjazv matjazv merged commit 2183bf3 into feature/improvements-and-recommendations Jun 28, 2024
3 checks passed
@matjazv matjazv deleted the 128 branch June 28, 2024 14:32
matjazv pushed a commit that referenced this pull request Jun 28, 2024
…nd weight (#144)

* Refactors scenarios

* refactor: test_scenario1_dailyRewards

* refactor: merge all tests for scenario1 into test_scenario1

refactor: merge all tests for scenario1 into test_scenario1

refactor: merge all tests for scenario1 into test_scenario1

* Adds checkRewardsContractBalance

* refactor: removes redundant pending unlock amount test methods for scenario2 and scenario3

* refactor: moves the logic from scenario2_dailyRewards to scenario2

* refactor: moves the logic from scenario3_dailyRewards to scenario3

* add scenario4 to test surplus and reward contract balance

* Reverts L2Reward

* Adds more complex assertions to scenario4 regarding surplus verification

* adds checkConsistencyTotalWeight

* adds zero value check for amount and duration when adding rewards

* added stakerClaimOnDayAndCheckConsistencyTotalWeight and removed checkConsistencyTotalWeight

* test consistency of total weight and daily weights

* updates scenario2 and scenario3 to check reward contract balance

* refactors and adds docs

* resolves compiler warnings

* adds documentation to assertion functions
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.

3 participants