-
Notifications
You must be signed in to change notification settings - Fork 107
Remote GSM #451
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?
Remote GSM #451
Conversation
@miguelmtzinf all comments have been addressed, thanks for the name suggestions, didn't know what to use! |
src/contracts/facilitators/gsm/interfaces/IOwnableFacilitator.sol
Outdated
Show resolved
Hide resolved
src/contracts/facilitators/gsm/interfaces/IOwnableFacilitator.sol
Outdated
Show resolved
Hide resolved
@@ -43,14 +44,14 @@ contract Gsm4626 is Gsm, IGsm4626 { | |||
) external notSeized onlyRole(CONFIGURATOR_ROLE) returns (uint256) { | |||
require(amount > 0, 'INVALID_AMOUNT'); | |||
|
|||
(, uint256 ghoMinted) = IGhoToken(GHO_TOKEN).getFacilitatorBucket(address(this)); | |||
(, uint256 deficit) = _getCurrentBacking(ghoMinted); | |||
uint256 ghoUsed = _getUsedGho(); |
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.
change to usedGho
for consistency
|
||
/// Map of entities and their assigned capacity and amount of GHO used | ||
mapping(address => GhoUsage) private _ghoUsage; | ||
|
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.
Wondering if we should add global variables for total limit and total used. It's a bit hard to iterate over entities also, to calculate totals
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.
Would total limit be every time we set a limit +/- to the global variable? For used it's easy to keep track
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.
yeah, would be keeping global accounting every time an entity updates its usage (limit or used). Not sure it's completely needed
GhoUsage memory usage = _ghoUsage[msg.sender]; | ||
require(usage.limit >= usage.used + amount, 'LIMIT_REACHED'); | ||
|
||
_ghoUsage[msg.sender].used += uint128(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.
GhoUsage memory usage = _ghoUsage[msg.sender]; | |
require(usage.limit >= usage.used + amount, 'LIMIT_REACHED'); | |
_ghoUsage[msg.sender].used += uint128(amount); | |
GhoUsage storage entity = _ghoUsage[msg.sender]; | |
require(entity.limit >= entity.used + amount, 'LIMIT_REACHED'); | |
entity.used += uint128(amount); |
} | ||
|
||
/// @inheritdoc IGhoReserve | ||
function setEntityLimit(address entity, uint256 limit) external onlyOwner { |
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.
function setEntityLimit(address entity, uint256 limit) external onlyOwner { | |
function setLimit(address entity, uint256 limit) external onlyOwner { |
*/ | ||
interface IGhoReserve { | ||
/** | ||
* Struct representing GSM's maximum allowed GHO usage and amount used |
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.
* Struct representing GSM's maximum allowed GHO usage and amount used | |
* @dev Struct data representing GHO usage. |
* @notice Returns amount of GHO used by a specified address | ||
* @param entity Address of the contract that withdrew GHO from reserve |
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.
* @notice Returns amount of GHO used by a specified address | |
* @param entity Address of the contract that withdrew GHO from reserve | |
* @notice Returns the amount of GHO used by a specified entity | |
* @param entity The address of the entity | |
* @return The amount of GHO used |
* @notice Returns limit of GHO and used amount for a given entity | ||
* @param entity Address of the contract that can use GHO from reserve | ||
* @return Limit of GHO that can be used | ||
* @return Used 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.
* @notice Returns limit of GHO and used amount for a given entity | |
* @param entity Address of the contract that can use GHO from reserve | |
* @return Limit of GHO that can be used | |
* @return Used amount | |
* @notice Returns the usage data of a specified entity | |
* @param entity The address of the entity | |
* @return The usage limit | |
* @return The amount of GHO used |
* @notice Returns maximum amount of GHO that can be used by a specified address | ||
* @param entity Address of the contract that uses GHO from reserve |
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.
* @notice Returns maximum amount of GHO that can be used by a specified address | |
* @param entity Address of the contract that uses GHO from reserve | |
* @notice Returns the usage limit of a specified entity | |
* @param entity The address of the entity | |
* @return The usage limit |
* @param entity The address that can use GHO | ||
* @param limit The maximum usage limit of the entity | ||
*/ | ||
event EntityLimitUpdated(address indexed entity, uint256 limit); |
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.
feels more aligned
event EntityLimitUpdated(address indexed entity, uint256 limit); | |
event GhoLimitUpdated(address indexed entity, uint256 limit); |
* @param entity The address that can use GHO | ||
* @param limit The maximum usage limit of the entity |
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.
* @param entity The address that can use GHO | |
* @param limit The maximum usage limit of the entity | |
* @param entity The address of the entity | |
* @param limit The new usage limit |
_transferOwnership(initialOwner); | ||
|
||
GHO_TOKEN = ghoAddress; |
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.
_transferOwnership(initialOwner); | |
GHO_TOKEN = ghoAddress; | |
_transferOwnership(initialOwner); | |
GHO_TOKEN = ghoAddress; |
* @param initialOwner Address of the initial owner of the contract | ||
* @param ghoAddress Address of GHO token on mainnet |
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.
* @param initialOwner Address of the initial owner of the contract | |
* @param ghoAddress Address of GHO token on mainnet | |
* @param initialOwner The address of the initial owner | |
* @param ghoAddress The address of GHO token |
uint256 ghoLevel = _getUsedGho(); | ||
uint256 ghoLimit = _getLimit(); |
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 create an internal function _getUsage
that returns both?
apart from that, let's rename Level
to Used
please
Changelog
Add RemoteGSM Implementation
Abstract methods on GSM