-
Notifications
You must be signed in to change notification settings - Fork 47
minter: Add inflation bounds to inflation adjustment algorithm #645
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
Open
SidestreamSweatyPumpkin
wants to merge
14
commits into
livepeer:delta
Choose a base branch
from
sidestream-tech:finish-minter-update
base: delta
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 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7201cf0
Add inflation bounds to inflation adjustment algorithm
stronk-dev f0f6687
add tests and a new migrateOldMinterState function
SidestreamSweatyPumpkin 06e4647
100% coverage
SidestreamSweatyPumpkin 48e4f36
enforce 100% test coverage in the CI
SidestreamSweatyPumpkin 73de871
rename transferStateData->migrateOldMinterState in the tests
SidestreamSweatyPumpkin 161d634
additionally check revert message
SidestreamSweatyPumpkin 2a602e0
improve tests which are independent from bonding rate
SidestreamSweatyPumpkin 3030b8c
add TODO to set correct inflation bounds
SidestreamSweatyPumpkin 7f2385e
rename maxInflation->inflationCeiling, minInflation->inflationFloor
SidestreamSweatyPumpkin 78176a0
set correct minter values in the migrations.config and deploy_minter
SidestreamSweatyPumpkin e317d26
fix typo in setInflationCeiling, setInflationFloor
SidestreamSweatyPumpkin 7dbc7f7
improve variable naming consistency in tests after renaming
SidestreamSweatyPumpkin 73d0e9b
improve test naming
SidestreamSweatyPumpkin a1f8096
Minter deployment artifacts
SidestreamSweatyPumpkin 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -23,10 +23,10 @@ contract Minter is Manager, IMinter { | |||||
|
||||||
// Per round inflation rate | ||||||
uint256 public inflation; | ||||||
// Max per round inflation rate | ||||||
uint256 public maxInflation; | ||||||
// Min per round inflation rate | ||||||
uint256 public minInflation; | ||||||
// Target maximum inflation rate | ||||||
uint256 public inflationCeiling; | ||||||
// Target minimum inflation rate | ||||||
uint256 public inflationFloor; | ||||||
// Change in inflation rate per round until the target bonding rate is achieved | ||||||
uint256 public inflationChange; | ||||||
// Target bonding rate | ||||||
|
@@ -74,24 +74,24 @@ contract Minter is Manager, IMinter { | |||||
* @param _inflation Base inflation rate as a percentage of current total token supply | ||||||
* @param _inflationChange Change in inflation rate each round (increase or decrease) if target bonding rate is not achieved | ||||||
* @param _targetBondingRate Target bonding rate as a percentage of total bonded tokens / total token supply | ||||||
* @param _maxInflation Inflation rate ceiling as a percentage of current total token supply | ||||||
* @param _minInflation Inflation rate floor as a percentage of current total token supply | ||||||
* @param _inflationCeiling Inflation rate ceiling as a percentage of current total token supply | ||||||
* @param _inflationFloor Inflation rate floor as a percentage of current total token supply | ||||||
*/ | ||||||
constructor( | ||||||
address _controller, | ||||||
uint256 _inflation, | ||||||
uint256 _inflationChange, | ||||||
uint256 _targetBondingRate, | ||||||
uint256 _maxInflation, | ||||||
uint256 _minInflation | ||||||
uint256 _inflationCeiling, | ||||||
uint256 _inflationFloor | ||||||
) Manager(_controller) { | ||||||
// Inflation must be valid percentage | ||||||
require(MathUtils.validPerc(_inflation), "_inflation is invalid percentage"); | ||||||
// Inflation bounds must be valid percentages | ||||||
require(MathUtils.validPerc(_maxInflation), "_maxInflation is invalid percentage"); | ||||||
require(MathUtils.validPerc(_minInflation), "_minInflation is invalid percentage"); | ||||||
require(MathUtils.validPerc(_inflationCeiling), "_inflationCeiling is invalid percentage"); | ||||||
require(MathUtils.validPerc(_inflationFloor), "_inflationFloor is invalid percentage"); | ||||||
// Inflation floor should be lower or equal to the ceiling | ||||||
require(_minInflation <= _maxInflation, "_minInflation must be <= _maxInflation"); | ||||||
require(_inflationFloor <= _inflationCeiling, "_inflationFloor must be <= _inflationCeiling"); | ||||||
// Inflation change must be valid percentage | ||||||
require(MathUtils.validPerc(_inflationChange), "_inflationChange is invalid percentage"); | ||||||
// Target bonding rate must be valid percentage | ||||||
|
@@ -100,8 +100,8 @@ contract Minter is Manager, IMinter { | |||||
inflation = _inflation; | ||||||
inflationChange = _inflationChange; | ||||||
targetBondingRate = _targetBondingRate; | ||||||
maxInflation = _maxInflation; | ||||||
minInflation = _minInflation; | ||||||
inflationCeiling = _inflationCeiling; | ||||||
inflationFloor = _inflationFloor; | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -131,33 +131,33 @@ contract Minter is Manager, IMinter { | |||||
} | ||||||
|
||||||
/** | ||||||
* @notice Set maxInflation. Only callable by Controller owner | ||||||
* @param _maxInflation New inflation cap as a percentage of total token supply | ||||||
* @notice Set inflationCeiling. Only callable by Controller owner | ||||||
* @param _inflationCeiling New inflation cap as a percentage of total token supply | ||||||
*/ | ||||||
function setMaxInflation(uint256 _maxInflation) external onlyControllerOwner { | ||||||
function setinflationCeiling(uint256 _inflationCeiling) external onlyControllerOwner { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same
Suggested change
|
||||||
// Must be valid percentage | ||||||
require(MathUtils.validPerc(_maxInflation), "_maxInflation is invalid percentage"); | ||||||
require(MathUtils.validPerc(_inflationCeiling), "_inflationCeiling is invalid percentage"); | ||||||
// Inflation ceiling should be higher or equal to the floor | ||||||
require(_maxInflation >= minInflation, "_maxInflation must be >= minInflation"); | ||||||
require(_inflationCeiling >= inflationFloor, "_inflationCeiling must be >= inflationFloor"); | ||||||
|
||||||
maxInflation = _maxInflation; | ||||||
inflationCeiling = _inflationCeiling; | ||||||
|
||||||
emit ParameterUpdate("maxInflation"); | ||||||
emit ParameterUpdate("inflationCeiling"); | ||||||
} | ||||||
|
||||||
/** | ||||||
* @notice Set minInflation. Only callable by Controller owner | ||||||
* @param _minInflation New inflation floor as a percentage of total token supply | ||||||
* @notice Set inflationFloor. Only callable by Controller owner | ||||||
* @param _inflationFloor New inflation floor as a percentage of total token supply | ||||||
*/ | ||||||
function setMinInflation(uint256 _minInflation) external onlyControllerOwner { | ||||||
function setinflationFloor(uint256 _inflationFloor) external onlyControllerOwner { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably mis-replaced the name here:
Suggested change
Will need to rename in other places like tests etc |
||||||
// Must be valid percentage | ||||||
require(MathUtils.validPerc(_minInflation), "_minInflation is invalid percentage"); | ||||||
require(MathUtils.validPerc(_inflationFloor), "_inflationFloor is invalid percentage"); | ||||||
// Inflation floor should be lower or equal to the ceiling | ||||||
require(_minInflation <= maxInflation, "_minInflation must be <= maxInflation"); | ||||||
require(_inflationFloor <= inflationCeiling, "_inflationFloor must be <= inflationCeiling"); | ||||||
|
||||||
minInflation = _minInflation; | ||||||
inflationFloor = _inflationFloor; | ||||||
|
||||||
emit ParameterUpdate("minInflation"); | ||||||
emit ParameterUpdate("inflationFloor"); | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -301,19 +301,21 @@ contract Minter is Manager, IMinter { | |||||
} | ||||||
|
||||||
// Adjust inflation based on current bonding rate and target bonding rate, ensuring it stays within the floor and ceiling | ||||||
if ((currentBondingRate < targetBondingRate && inflation < maxInflation) || inflation < minInflation) { | ||||||
if ((currentBondingRate < targetBondingRate && inflation < inflationCeiling) || inflation < inflationFloor) { | ||||||
// Bonding rate is below the target - increase inflation | ||||||
if (inflation.add(inflationChange) > maxInflation) { | ||||||
if (inflation.add(inflationChange) > inflationCeiling) { | ||||||
// If inflation would go above the ceiling, set it to the ceiling | ||||||
inflation = maxInflation; | ||||||
inflation = inflationCeiling; | ||||||
} else { | ||||||
inflation = inflation.add(inflationChange); | ||||||
} | ||||||
} else if ((currentBondingRate > targetBondingRate && inflation > minInflation) || inflation > maxInflation) { | ||||||
} else if ( | ||||||
(currentBondingRate > targetBondingRate && inflation > inflationFloor) || inflation > inflationCeiling | ||||||
) { | ||||||
// Bonding rate is above the target - decrease inflation | ||||||
if (minInflation.add(inflationChange) > inflation) { | ||||||
if (inflationFloor.add(inflationChange) > inflation) { | ||||||
// If inflation would go below the floor, set it to the floor | ||||||
inflation = minInflation; | ||||||
inflation = inflationFloor; | ||||||
} else { | ||||||
inflation = inflation.sub(inflationChange); | ||||||
} | ||||||
|
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
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
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
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.
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 like the rename! Make sure there's no occurences of
[Mm]ax.+[Ii]nflation
on the project anymore 👀