-
Notifications
You must be signed in to change notification settings - Fork 10
Modify GhoReserve and Facilitator AccessControl #19
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
miguelmtzinf
merged 2 commits into
aave-dao:tokenlogic/gho-reserve-steward
from
TokenLogic-com-au:gho-reserve-steward
Jan 7, 2026
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.10; | ||
|
|
||
| import {AccessControl} from 'src/contracts/dependencies/openzeppelin-contracts/contracts/access/AccessControl.sol'; | ||
| import {IGhoToken} from 'src/contracts/gho/interfaces/IGhoToken.sol'; | ||
| import {IGhoDirectFacilitator} from 'src/contracts/facilitators/gsm/interfaces/IGhoDirectFacilitator.sol'; | ||
|
|
||
| /** | ||
| * @title GhoDirectFacilitator | ||
| * @author Aave/TokenLogic | ||
| * @notice GHO Facilitator used to directly mint GHO to a given address. | ||
miguelmtzinf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| contract GhoDirectFacilitator is AccessControl, IGhoDirectFacilitator { | ||
| /// @inheritdoc IGhoDirectFacilitator | ||
| bytes32 public constant MINTER_ROLE = keccak256('MINTER_ROLE'); | ||
|
|
||
| /// @inheritdoc IGhoDirectFacilitator | ||
| bytes32 public constant BURNER_ROLE = keccak256('MINTER_ROLE'); | ||
|
|
||
| /// @inheritdoc IGhoDirectFacilitator | ||
| address public immutable GHO_TOKEN; | ||
|
|
||
| /** | ||
| * @dev Constructor | ||
| * @param admin The address of the initial owner | ||
| * @param ghoAddress The address of GHO token | ||
| */ | ||
| constructor(address admin, address ghoAddress) { | ||
miguelmtzinf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| require(admin != address(0), 'ZERO_ADDRESS_NOT_VALID'); | ||
| require(ghoAddress != address(0), 'ZERO_ADDRESS_NOT_VALID'); | ||
|
|
||
| _grantRole(DEFAULT_ADMIN_ROLE, admin); | ||
| _grantRole(MINTER_ROLE, admin); | ||
| _grantRole(BURNER_ROLE, admin); | ||
|
|
||
| GHO_TOKEN = ghoAddress; | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectFacilitator | ||
| function mint(address account, uint256 amount) external onlyRole(MINTER_ROLE) { | ||
| IGhoToken(GHO_TOKEN).mint(account, amount); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectFacilitator | ||
| function burn(uint256 amount) external onlyRole(BURNER_ROLE) { | ||
| IGhoToken(GHO_TOKEN).burn(amount); | ||
| } | ||
| } | ||
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,8 +1,8 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.10; | ||
|
|
||
| import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; | ||
| import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol'; | ||
| import {AccessControl} from 'src/contracts/dependencies/openzeppelin-contracts/contracts/access/AccessControl.sol'; | ||
| import {SafeCast} from 'src/contracts/dependencies/openzeppelin-contracts/contracts/utils/math/SafeCast.sol'; | ||
| import {IERC20} from 'aave-v3-origin/contracts/dependencies/openzeppelin/contracts/IERC20.sol'; | ||
| import {VersionedInitializable} from 'aave-v3-origin/contracts/misc/aave-upgradeability/VersionedInitializable.sol'; | ||
|
|
@@ -14,10 +14,19 @@ import {IGhoReserve} from 'src/contracts/facilitators/gsm/interfaces/IGhoReserve | |
| * @notice It allows approved entities to withdraw and return GHO funds, with a defined maximum withdrawal capacity per entity. | ||
| * @dev To be covered by a proxy contract. | ||
| */ | ||
| contract GhoReserve is Ownable, VersionedInitializable, IGhoReserve { | ||
| contract GhoReserve is AccessControl, VersionedInitializable, IGhoReserve { | ||
| using EnumerableSet for EnumerableSet.AddressSet; | ||
| using SafeCast for uint256; | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| bytes32 public constant MANAGE_ENTITY_ROLE = keccak256('MANAGE_ENTITY_ROLE'); | ||
miguelmtzinf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| bytes32 public constant SET_LIMIT_ROLE = keccak256('SET_LIMIT_ROLE'); | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| bytes32 public constant TRANSFER_ROLE = keccak256('TRANSFER_ROLE'); | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| address public immutable GHO_TOKEN; | ||
|
|
||
|
|
@@ -31,18 +40,22 @@ contract GhoReserve is Ownable, VersionedInitializable, IGhoReserve { | |
| * @dev Constructor | ||
| * @param ghoAddress The address of the GHO token on the remote chain | ||
| */ | ||
| constructor(address ghoAddress) Ownable(msg.sender) { | ||
| constructor(address ghoAddress) { | ||
miguelmtzinf marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| require(ghoAddress != address(0), 'ZERO_ADDRESS_NOT_VALID'); | ||
| GHO_TOKEN = ghoAddress; | ||
| } | ||
|
|
||
| /** | ||
| * @dev Initializer | ||
| * @param newOwner The address of the new owner | ||
| * @param admin The address of the new owner | ||
| */ | ||
| function initialize(address newOwner) external initializer { | ||
| require(newOwner != address(0), 'ZERO_ADDRESS_NOT_VALID'); | ||
| _transferOwnership(newOwner); | ||
| function initialize(address admin) external initializer { | ||
| require(admin != address(0), 'ZERO_ADDRESS_NOT_VALID'); | ||
|
|
||
| _grantRole(DEFAULT_ADMIN_ROLE, admin); | ||
| _grantRole(MANAGE_ENTITY_ROLE, admin); | ||
| _grantRole(SET_LIMIT_ROLE, admin); | ||
| _grantRole(TRANSFER_ROLE, admin); | ||
|
Comment on lines
55
to
58
Collaborator
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. we could only give default admin role, but i'm fine with this given that most likely it d be assigned to the Executor. |
||
| } | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
|
|
@@ -63,19 +76,19 @@ contract GhoReserve is Ownable, VersionedInitializable, IGhoReserve { | |
| } | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| function transfer(address to, uint256 amount) external onlyOwner { | ||
| function transfer(address to, uint256 amount) external onlyRole(TRANSFER_ROLE) { | ||
| IERC20(GHO_TOKEN).transfer(to, amount); | ||
| emit GhoTransferred(to, amount); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| function addEntity(address entity) external onlyOwner { | ||
| function addEntity(address entity) external onlyRole(MANAGE_ENTITY_ROLE) { | ||
| require(_entities.add(entity), 'ENTITY_ALREADY_EXISTS'); | ||
| emit EntityAdded(entity); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| function removeEntity(address entity) external onlyOwner { | ||
| function removeEntity(address entity) external onlyRole(MANAGE_ENTITY_ROLE) { | ||
| GhoUsage memory usage = _ghoUsage[entity]; | ||
| require(usage.used == 0, 'ENTITY_GHO_USED_NOT_ZERO'); | ||
| require(usage.limit == 0, 'ENTITY_GHO_LIMIT_NOT_ZERO'); | ||
|
|
@@ -85,7 +98,7 @@ contract GhoReserve is Ownable, VersionedInitializable, IGhoReserve { | |
| } | ||
|
|
||
| /// @inheritdoc IGhoReserve | ||
| function setLimit(address entity, uint256 limit) external onlyOwner { | ||
| function setLimit(address entity, uint256 limit) external onlyRole(SET_LIMIT_ROLE) { | ||
| require(_entities.contains(entity), 'ENTITY_DOES_NOT_EXIST'); | ||
| _ghoUsage[entity].limit = limit.toUint128(); | ||
|
|
||
|
|
||
This file was deleted.
Oops, something went wrong.
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
miguelmtzinf marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
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.