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/on chain accounting #40

Merged
merged 15 commits into from
May 16, 2024
Merged

Feat/on chain accounting #40

merged 15 commits into from
May 16, 2024

Conversation

0xean
Copy link
Contributor

@0xean 0xean commented May 13, 2024

Add on-chain accounting for "rewards" a generic unit of account that we can use to reconcile off chain for RUNE distribution. Essentially, they act like points.

Also adds some paranoia with a non-reentrant modifier...

Only last question is should we add the ability to set the REWARD_RATE so that if we end up using these as points, and we have multiple pools as is being discussed with DFC, we can modify the REWARD_RATE to be meaningful.

@0xean 0xean force-pushed the feat/on-chain-accounting branch from 3666a2e to 82e7693 Compare May 13, 2024 20:17
@gomesalexandre gomesalexandre self-requested a review May 13, 2024 20:18
@0xean 0xean marked this pull request as ready for review May 13, 2024 21:23
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

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

First pass - looks good to me and actually brings a lot less additional logic in than expected.
A bunch of nitpicks to disregard, but conceptually this sounds very sane.

The only thing that may not be a nitpick is we may want to leverage emitting events more, but at the end of the day we'd still need to go through historical blocks so this may be fluff?

@0xean
Copy link
Contributor Author

0xean commented May 14, 2024

The only thing that may not be a nitpick is we may want to leverage emitting events more, but at the end of the day we'd still need to go through historical blocks so this may be fluff?

I think we now have two ways to do off-chain accounting.

  1. We get all of the staking and unstaking events and manually process each of them, no archive node required, but a lot of math to get right.
  2. We use the new on-chain accounting and an archive node. Essentially no-math. endRewards - startRewards.

Combining both of these allows us to double check our work and flexibility for different scenarios.

Copy link
Member

@woodenfurniture woodenfurniture left a comment

Choose a reason for hiding this comment

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

LGTM ser, only nitpicks and observations.

@0xean 0xean merged commit ddc25b9 into main May 16, 2024
1 check passed
@0xean 0xean deleted the feat/on-chain-accounting branch May 16, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants