Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Reduce rewards every X blocks #3
base: master
Are you sure you want to change the base?
Reduce rewards every X blocks #3
Changes from 11 commits
71e5338
fbaa36f
4f8f702
e08468a
8a47d31
059a28c
7eb6825
33850d2
fcc6031
0d13256
5f52f7d
4b55a65
df5fbf6
1cb41c3
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't know why this didn't occur to me earlier, but I think we can remove a lot of complexity and gas cost by calculating the current emission rather than actually updating the state like this. If you replace
lastUpdate
in the Pool struct with something likebaseBlock
:Then you should be able to do something like this (untested):
Inside the mint function you can then use the getter above to calculate the amount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the same approach, but the requirements I was given were to use exponential decay (
"...after the first day (28800 blocks) it would drop to 0.99 SPS / block, and then the next day it would drop to 0.9801 (1% reduction from 0.99), then 0.9702, etc..."
), I tried implementing it, but the standardx*(1-y)**z)
formula doesn't work in solidity.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes, great point! My version is not exponential. Missed that.
Just out of curiosity, what kind of issue did you hit implementing this formula?
If it's not possible, we should still be able to do something iteratively. Here's a quick attempt (not tested):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with using
x*(1-y)**z) formula
was that1-z
should be less than 1, which doesn't work with solidity.I was thinking about an iterative approach but wasn't sure if gas savings are worth it, did some testing now, and while it's cheaper (~1k gas), I don't think it's worth changing it considering it will be used on BSC anyway, so gas cost is not an issue.
While using a non-iterative approach requires calling
updateEmissions
everyreductionBlocks
, minter will be integrated with a yield farming contract where users will call it, so I don't think that will be an issue either.