Skip to content

Commit

Permalink
feat: use addresses provider instead of acl (aave-dao#66)
Browse files Browse the repository at this point in the history
umbrella should be a single address tied to the pool, so using acl is overkill, which also will be cheaper
  • Loading branch information
sakulstra committed Oct 16, 2024
1 parent c4c438e commit 26b632d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/contracts/protocol/libraries/helpers/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ library Errors {
string public constant INVALID_FREEZE_STATE = '99'; // Reserve is already in the passed freeze state
string public constant NOT_BORROWABLE_IN_EMODE = '100'; // Asset not borrowable in eMode
string public constant USER_NOT_IN_BAD_DEBT = '101'; // The user is not in bad debt
string public constant CALLER_NOT_COVERAGE_ADMIN = '102'; // The caller of the function is not the coverage admin
string public constant CALLER_NOT_UMBRELLA = '102'; // The caller of the function is not the umbrella contract
string public constant RESERVE_NOT_IN_DEFICIT = '103'; // The reserve is not in deficit
}
21 changes: 7 additions & 14 deletions src/contracts/protocol/pool/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,13 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool {
}

/**
* @dev Only aToken Burner can call functions marked by this modifier.
* @dev Only the umbrella contract can call functions marked by this modifier.
*/
modifier onlyCoverageAdmin() {
_onlyCoverageAdmin();
modifier onlyUmbrella() {
require(
ADDRESSES_PROVIDER.getAddress(bytes32('UMBRELLA')) == msg.sender,
Errors.CALLER_NOT_UMBRELLA
);
_;
}

Expand All @@ -94,13 +97,6 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool {
);
}

function _onlyCoverageAdmin() internal view virtual {
require(
IAccessControl(ADDRESSES_PROVIDER.getACLManager()).hasRole('COVERAGE_ADMIN', msg.sender),
Errors.CALLER_NOT_COVERAGE_ADMIN
);
}

/**
* @dev Constructor.
* @param provider The address of the PoolAddressesProvider contract
Expand Down Expand Up @@ -864,10 +860,7 @@ abstract contract Pool is VersionedInitializable, PoolStorage, IPool {
}

/// @inheritdoc IPool
function eliminateReserveDeficit(
address asset,
uint256 amount
) external override onlyCoverageAdmin {
function eliminateReserveDeficit(address asset, uint256 amount) external override onlyUmbrella {
ReserveLogic.eliminateDeficit(
_reserves,
_reservesList,
Expand Down
12 changes: 6 additions & 6 deletions tests/protocol/pool/Pool.Deficit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract PoolDeficitTests is TestnetProcedures {
(address reserveToken, uint256 currentDeficit) = _createReserveDeficit(supplyAmount);

vm.prank(poolAdmin);
IAccessControl(report.aclManager).grantRole('COVERAGE_ADMIN', coverageAdmin);
contracts.poolAddressesProvider.setAddress(bytes32('UMBRELLA'), coverageAdmin);

deal(reserveToken, coverageAdmin, currentDeficit);

Expand All @@ -49,7 +49,7 @@ contract PoolDeficitTests is TestnetProcedures {
vm.assume(amountToCover != 0 && amountToCover < currentDeficit);

vm.prank(poolAdmin);
IAccessControl(report.aclManager).grantRole('COVERAGE_ADMIN', coverageAdmin);
contracts.poolAddressesProvider.setAddress(bytes32('UMBRELLA'), coverageAdmin);

deal(reserveToken, coverageAdmin, currentDeficit);

Expand All @@ -73,7 +73,7 @@ contract PoolDeficitTests is TestnetProcedures {
vm.assume(cAdminBorrowAmount != 0 && uint256(cAdminBorrowAmount) * 2 <= currentDeficit);

vm.prank(poolAdmin);
IAccessControl(report.aclManager).grantRole('COVERAGE_ADMIN', coverageAdmin);
contracts.poolAddressesProvider.setAddress(bytes32('UMBRELLA'), coverageAdmin);

deal(reserveToken, coverageAdmin, currentDeficit);

Expand All @@ -93,7 +93,7 @@ contract PoolDeficitTests is TestnetProcedures {
_filterAddresses(caller);
(address reserveToken, uint256 currentDeficit) = _createReserveDeficit(supplyAmount);

vm.expectRevert(bytes(Errors.CALLER_NOT_COVERAGE_ADMIN));
vm.expectRevert(bytes(Errors.CALLER_NOT_UMBRELLA));
vm.prank(caller);
contracts.poolProxy.eliminateReserveDeficit(reserveToken, currentDeficit);
}
Expand All @@ -107,7 +107,7 @@ contract PoolDeficitTests is TestnetProcedures {
(address reserveToken, ) = _createReserveDeficit(supplyAmount);

vm.prank(poolAdmin);
IAccessControl(report.aclManager).grantRole('COVERAGE_ADMIN', coverageAdmin);
contracts.poolAddressesProvider.setAddress(bytes32('UMBRELLA'), coverageAdmin);

vm.startPrank(coverageAdmin);
vm.expectRevert(bytes(Errors.INVALID_AMOUNT));
Expand All @@ -120,7 +120,7 @@ contract PoolDeficitTests is TestnetProcedures {
_filterAddresses(coverageAdmin);

vm.prank(poolAdmin);
IAccessControl(report.aclManager).grantRole('COVERAGE_ADMIN', coverageAdmin);
contracts.poolAddressesProvider.setAddress(bytes32('UMBRELLA'), coverageAdmin);

vm.startPrank(coverageAdmin);

Expand Down

0 comments on commit 26b632d

Please sign in to comment.