-
Notifications
You must be signed in to change notification settings - Fork 0
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
Open
fbslo
wants to merge
14
commits into
master
Choose a base branch
from
code-review-reduction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
71e5338
Add option to reduce amount in the pools
fbslo fbaa36f
Add more tests
fbslo 4f8f702
Update emissions every time mint is called
fbslo e08468a
remove hardhat console
fbslo 8a47d31
make updateEmissions public
fbslo 059a28c
create updateAllEmissions function
fbslo 7eb6825
add minimum payout and don't `mint` if amount is 0
fbslo 33850d2
update tests
fbslo fcc6031
fix typo
fbslo 0d13256
enforce newReductionBlocks <= 100
fbslo 5f52f7d
Use basis points instead of percentage for higher precision
fbslo 4b55a65
fix variable name
fbslo df5fbf6
replace 10000 with BPS const
fbslo 1cb41c3
add option to call external contracts when amountPerBlock is changed
fbslo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.