-
Notifications
You must be signed in to change notification settings - Fork 10
Feat: add sGhoSteward #6
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
base: main
Are you sure you want to change the base?
Conversation
| address public executor = vm.addr(0x0001); | ||
| address public ghoCommittee = vm.addr(0x0002); | ||
|
|
||
| bytes32 public constant YIELD_MANAGER_ROLE = 'YIELD_MANAGER'; |
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.
Nbd, but why is yield manager role defined differently from the ones below? EDIT: Oh perhaps because it's to distinguish it's a role on sGho rather than Steward contract
src/contracts/misc/sGhoSteward.md
Outdated
| - Supports updating with each rate parameter *individually* or *multiple parameters simultaneously*. | ||
| - Integrates **Role-Based Access Control** from OpenZeppelin, enabling secure assignment, modification, and revocation of roles. | ||
| - Provides functions to view the current configuration and pre-calculate the `targetRate` for any given configuration. | ||
| - Enforces a hard cap of `50%` for the computed `targetRate`, regardless of configuration input. |
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.
To me, this sentence is a bit misleading, because it kind of sounds like the contract does not revert (and perhaps instead just uses 50% target rate even if it would calculate higher based on input config), when indeed it does revert based on the configuration input. It's mentioned below and indeed the contract does revert when this exceeds 50%. Perhaps can clarify here too that the contract reverts if configuration input would put target rate over 50%.
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.
Description has been fixed.
tests/misc/sGhoSteward.t.sol
Outdated
| fixedRate: 300 // 3% | ||
| }); | ||
|
|
||
| vm.expectRevert(); |
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.
Perhaps explicitly verify that the revert reason is because of the role?
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.
Fixed.
tests/misc/sGhoSteward.t.sol
Outdated
| assertEq(sGho.targetRate(), 400); | ||
| } | ||
|
|
||
| function test_setRateConfigNotAllRoles() public { |
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.
Might be cleaner and more straightforward imo to break this up into multiple tests, showing that each role can set each different config param, and reverts for exactly the reason of not having the particular role after revoking it.
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.
Test splitted into 3 different.
|
|
||
| uint16 public constant AMPLIFICATION_DENOMINATOR = 100_00; | ||
|
|
||
| bytes32 public constant AMPLIFICATION_MANAGER_ROLE = keccak256('AMPLIFICATION_MANAGER_ROLE'); |
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.
Should we add the @inheritdoc for all of these?
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.
Added.
src/contracts/misc/sGhoSteward.sol
Outdated
| /// @notice Current rate parameters | ||
| RateConfig public rateConfig; | ||
|
|
||
| IsGHO public immutable sGHO; |
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.
In the other contracts in the repo these are prefixed and then params on functions don't have prefix/suffix from what i've seen
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.
Fixed accoarding to other contracts in this repo.
src/contracts/misc/sGhoSteward.sol
Outdated
| rateConfig_.fixedRate; | ||
|
|
||
| if (targetRate > MAX_RATE) { | ||
| revert TooBigRate(); |
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'd change to RateTooBig()
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.
Error name changed.
Adding code for
sGhoStewardthat can updatesupplyCapandtargetRateinsGho.For this to work, this steward should be granted with
YIELD_MANAGER_ROLE.For convenience, the
targetRateis divided into three components and a special role is allocated for updating each variable.