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

Feat/Add Events and Natspec to Staking Contract #3

Merged
merged 6 commits into from
Jan 26, 2024

Conversation

sayandcode
Copy link
Owner

What?

This PR adds events to the Staking Contract. It also adds Natspec documentation to the same file.

Why?

This helps us to access historical data to conduct analytics off-chain.

How?

We have added Solidity Events as well as associated tests. The Natspec was added next to every code symbol.

This helps to calculate the user rewards off-chain
Helper functions were added to calcualte alpha and rewards in tests.
However these are not meant to test the implementation of the
test calculation. Rather they are intended to help check whether the
stored values such as in events are same as the calculated values.
- The Unstake event was added, along with associated tests

- The test for events in staking was modified to include a time variable
  as well
Earlier alpha was being updated in its own function `_updateAlpha`. This
was made a view function `_calculateAccruedAlpha`, and the actual
updating of alpha was done within the `_updateReward` function. This
makes the logic within it clean - It calls other view functions for the
calculation, and handles the events and storage variable updates within
itself.
@sayandcode sayandcode merged commit c175cd0 into main Jan 26, 2024
1 check passed
@sayandcode sayandcode deleted the feat/staking-events-and-natspec branch January 26, 2024 11:08
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.

1 participant