Skip to content

Commit

Permalink
feat: Organize function ordering in FlashMinter (#262)
Browse files Browse the repository at this point in the history
* feat: Organize function ordering in FlashMinter
  • Loading branch information
Zer0dot authored Feb 2, 2023
1 parent fc1bf75 commit b81545c
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions src/contracts/facilitators/flashMinter/GhoFlashMinter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,6 @@ contract GhoFlashMinter is IGhoFlashMinter {
_aclManager = IACLManager(IPoolAddressesProvider(addressesProvider).getACLManager());
}

/// @inheritdoc IERC3156FlashLender
function maxFlashLoan(address token) external view override returns (uint256) {
if (token != address(GHO_TOKEN)) {
return 0;
} else {
IGhoToken.Facilitator memory flashMinterFacilitator = GHO_TOKEN.getFacilitator(address(this));
uint256 capacity = flashMinterFacilitator.bucketCapacity;
uint256 level = flashMinterFacilitator.bucketLevel;
return capacity > level ? capacity - level : 0;
}
}

/// @inheritdoc IERC3156FlashLender
function flashLoan(
IERC3156FlashBorrower receiver,
Expand All @@ -101,41 +89,53 @@ contract GhoFlashMinter is IGhoFlashMinter {
return true;
}

/// @inheritdoc IERC3156FlashLender
function flashFee(address token, uint256 amount) external view override returns (uint256) {
require(token == address(GHO_TOKEN), 'FlashMinter: Unsupported currency');
return _aclManager.isFlashBorrower(msg.sender) ? 0 : _flashFee(amount);
}

/// @inheritdoc IGhoFacilitator
function distributeFeesToTreasury() external virtual override {
function distributeFeesToTreasury() external override {
uint256 balance = GHO_TOKEN.balanceOf(address(this));
GHO_TOKEN.transfer(_ghoTreasury, balance);
emit FeesDistributedToTreasury(_ghoTreasury, address(GHO_TOKEN), balance);
}

// @inheritdoc IGhoFlashMinter
function updateFee(uint256 newFee) external onlyPoolAdmin {
function updateFee(uint256 newFee) external override onlyPoolAdmin {
require(newFee <= MAX_FEE, 'FlashMinter: Fee out of range');
uint256 oldFee = _fee;
_fee = newFee;
emit FeeUpdated(oldFee, newFee);
}

/// @inheritdoc IGhoFlashMinter
function getFee() external view returns (uint256) {
return _fee;
}

/// @inheritdoc IGhoFacilitator
function updateGhoTreasury(address newGhoTreasury) external override onlyPoolAdmin {
address oldGhoTreasury = _ghoTreasury;
_ghoTreasury = newGhoTreasury;
emit GhoTreasuryUpdated(oldGhoTreasury, newGhoTreasury);
}

/// @inheritdoc IERC3156FlashLender
function maxFlashLoan(address token) external view override returns (uint256) {
if (token != address(GHO_TOKEN)) {
return 0;
} else {
IGhoToken.Facilitator memory flashMinterFacilitator = GHO_TOKEN.getFacilitator(address(this));
uint256 capacity = flashMinterFacilitator.bucketCapacity;
uint256 level = flashMinterFacilitator.bucketLevel;
return capacity > level ? capacity - level : 0;
}
}

/// @inheritdoc IERC3156FlashLender
function flashFee(address token, uint256 amount) external view override returns (uint256) {
require(token == address(GHO_TOKEN), 'FlashMinter: Unsupported currency');
return _aclManager.isFlashBorrower(msg.sender) ? 0 : _flashFee(amount);
}

/// @inheritdoc IGhoFlashMinter
function getFee() external view override returns (uint256) {
return _fee;
}

/// @inheritdoc IGhoFacilitator
function getGhoTreasury() external view returns (address) {
function getGhoTreasury() external view override returns (address) {
return _ghoTreasury;
}

Expand Down

0 comments on commit b81545c

Please sign in to comment.