-
Notifications
You must be signed in to change notification settings - Fork 15
blockreward contract #10
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e447149
feat(block-reward): first untested draft
ngyam 28f399b
WIP
ngyam 791b1ab
Merge branch 'master' into feat/reward_contract
ngyam 8606b3d
feat(reward-contracts): first draft without S curve
ngyam fab277b
feat(reward-contracts); natspec + tests cleaning
ngyam 6b21639
feat(reward-contracts): S curve
ngyam 038d531
feat(reward-contracts): eternal storage mapping replaced
ngyam 795057c
Merge branch 'master' into feat/reward_contract
ngyam 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
feat(reward-contracts): S curve
- S curve + tests added - some existing tests reworked/fixed - testing on concrete error messages added - eternal storage/proxy removed
- Loading branch information
commit 6b216397cb3e6ef4aed9c7573b6bcbc32dd5c2e1
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| module.exports = { | ||
| skipFiles: ['interfaces','libs'] | ||
| skipFiles: ['interfaces','libs', 'misc/Ownable.sol'], | ||
| compileCommand: 'npx truffle compile', | ||
| testCommand: 'npx truffle test --network coverage' | ||
| } |
This file contains hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,193 @@ | ||
| pragma solidity ^0.5.4; | ||
|
|
||
|
|
||
| /// @title S Curve Reward provider | ||
| /// @notice Provides the appropriate block author rewards | ||
| /// based on points of a discrete, inverse S curve | ||
| contract SCurveProvider { | ||
|
|
||
| /// Discrete points of the curve | ||
| uint256[] public sCurve; | ||
| /// Discrete step size | ||
| uint256 public blockStepSize; | ||
ngyam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /// End of the reward period (both block- and community reward) | ||
| /// expressed in block number | ||
| uint256 public rewardPeriodEnd; | ||
|
|
||
| constructor() | ||
| public | ||
| { | ||
| _initCurve(); | ||
| } | ||
|
|
||
| /// @notice Returns the block reward amount based on the block number | ||
| /// and points of the S curve | ||
| /// @param _currentBlock The block number to calculate the reward to | ||
| /// @return The block reward amount in wei | ||
| function getBlockReward(uint256 _currentBlock) | ||
| public | ||
| view | ||
| returns (uint256) | ||
| { | ||
| return 5; | ||
| if (_checkRewardPeriodEnded(_currentBlock)) { | ||
| return 0; | ||
| } | ||
| return sCurve[_currentBlock / blockStepSize]; | ||
| } | ||
|
|
||
| /// @notice Checks whether the reward period is over or not (block and community) | ||
| /// @return True if the reward period has ended, false otherwise | ||
| function checkRewardPeriodEnded() | ||
| public | ||
| view | ||
| returns (bool) | ||
| { | ||
| return _checkRewardPeriodEnded(block.number); | ||
| } | ||
|
|
||
| /// @notice Checks whether the block reward period is over or not | ||
| /// @param _currentBlock The block number to check on | ||
| /// @return True if the block reward period has ended, false otherwise | ||
| function _checkRewardPeriodEnded(uint256 _currentBlock) | ||
ngyam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| internal | ||
| view | ||
| returns (bool) | ||
| { | ||
| return (_currentBlock >= rewardPeriodEnd); | ||
| } | ||
|
|
||
| // solhint-disable function-max-lines | ||
| /// @dev Inits the S curve. Values are hardcoded, | ||
| /// everyhting is calculated beforehand | ||
| function _initCurve() | ||
ngyam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private | ||
| { | ||
| sCurve = [ | ||
| uint256(304418979390926464), | ||
| 304418979390926464, | ||
| 304418979390926464, | ||
| 304418979390926464, | ||
| 304418979390926464, | ||
| 304418979390926464, | ||
| 304418979390926464, | ||
| 304369560376526464, | ||
| 304221303333326464, | ||
| 303974208261326464, | ||
| 303628275160526464, | ||
| 303183504030926464, | ||
| 302639894872526464, | ||
| 301997447685326464, | ||
| 301256162469326464, | ||
| 300416039224526464, | ||
| 299477077950926464, | ||
| 298439278648526464, | ||
| 297302641317326464, | ||
| 296067165957326464, | ||
| 294732852568526464, | ||
| 293299701150926464, | ||
| 291767711704526464, | ||
| 290136884229326464, | ||
| 288407218725326464, | ||
| 286578715192526464, | ||
| 284651373630926464, | ||
| 282625194040526464, | ||
| 280500176421326464, | ||
| 278276320773326464, | ||
| 275953627096526464, | ||
| 273532095390926464, | ||
| 271011725656526464, | ||
| 268392517893326464, | ||
| 265674472101326464, | ||
| 262857588280526464, | ||
| 259941866430926464, | ||
| 256927306552526464, | ||
| 253813908645326464, | ||
| 250601672709326464, | ||
| 247290598744526464, | ||
| 243880686750926464, | ||
| 240371936728526464, | ||
| 236764348677326464, | ||
| 233057922597326464, | ||
| 229252658488526464, | ||
| 225348556350926464, | ||
| 221345616184526464, | ||
| 217243837989326464, | ||
| 213043221765326464, | ||
| 208743767512526464, | ||
| 204345475230926464, | ||
| 199848344920526464, | ||
| 195252376581326464, | ||
| 190557570213326464, | ||
| 185763925816526464, | ||
| 180871443390926464, | ||
| 175880122936526464, | ||
| 170789964453326464, | ||
| 165600967941326464, | ||
| 160117606656000000, | ||
| 154824830213760000, | ||
| 149621007997440000, | ||
| 144506140007040000, | ||
| 139480226242560000, | ||
| 134543266704000000, | ||
| 129695261391360000, | ||
| 124936210304640000, | ||
| 120266113443840000, | ||
| 115684970808960000, | ||
| 111192782400000000, | ||
| 106789548216960000, | ||
| 102475268259840000, | ||
| 98249942528640000, | ||
| 94113571023360000, | ||
| 90066153744000000, | ||
| 86107690690560000, | ||
| 82238181863040000, | ||
| 78457627261440000, | ||
| 74766026885760000, | ||
| 71163380736000000, | ||
| 67649688812160000, | ||
| 64224951114240000, | ||
| 60889167642240000, | ||
| 57642338396160000, | ||
| 54484463376000000, | ||
| 51415542581760000, | ||
| 48435576013440000, | ||
| 45544563671040000, | ||
| 42742505554560000, | ||
| 40029401664000000, | ||
| 37405251999360000, | ||
| 34870056560640000, | ||
| 32423815347840000, | ||
| 30066528360960000, | ||
| 27798195600000000, | ||
| 25618817064960000, | ||
| 23528392755840000, | ||
| 21526922672640000, | ||
| 19614406815360000, | ||
| 17790845184000000, | ||
| 16056237778560000, | ||
| 14410584599040000, | ||
| 12853885645440000, | ||
| 11386140917760000, | ||
| 10007350416000000, | ||
| 8717514140160000, | ||
| 7516632090240000, | ||
| 6404704266240000, | ||
| 5381730668160000, | ||
| 4447711296000000, | ||
| 3602646149760000, | ||
| 2846535229440000, | ||
| 2179378535040000, | ||
| 1601176066560000, | ||
| 1111927824000000, | ||
| 711633807360000, | ||
| 400294016640000, | ||
| 177908451840000, | ||
| 44477112960000 | ||
| ]; | ||
| // roughly 1 month with a 5 sec step size | ||
| blockStepSize = 525600; | ||
| //roughly 10 years with a 5 sec step size | ||
| rewardPeriodEnd = blockStepSize * sCurve.length; | ||
| } | ||
| } | ||
| // solhint-enable function-max-lines | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.