Skip to content

Commit

Permalink
fix: Fetch addressesProvider from AToken
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Mar 22, 2023
1 parent b252276 commit 27d2e6e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
5 changes: 2 additions & 3 deletions contracts/protocol/libraries/logic/BridgeLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ library BridgeLogic {
address asset,
uint256 amount,
address onBehalfOf,
uint16 referralCode,
address addressesProvider
uint16 referralCode
) external {
DataTypes.ReserveData storage reserve = reservesData[asset];
DataTypes.ReserveCache memory reserveCache = reserve.cache();
Expand Down Expand Up @@ -89,7 +88,7 @@ library BridgeLogic {
reservesList,
userConfig,
reserveCache.reserveConfiguration,
addressesProvider
reserveCache.aTokenAddress
)
) {
userConfig.setUsingAsCollateral(reserve.id, true);
Expand Down
2 changes: 1 addition & 1 deletion contracts/protocol/libraries/logic/LiquidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ library LiquidationLogic {
reservesList,
liquidatorConfig,
collateralReserve.configuration,
params.addressesProvider
collateralReserve.aTokenAddress
)
) {
liquidatorConfig.setUsingAsCollateral(collateralReserve.id, true);
Expand Down
4 changes: 2 additions & 2 deletions contracts/protocol/libraries/logic/SupplyLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ library SupplyLogic {
reservesList,
userConfig,
reserveCache.reserveConfiguration,
params.addressesProvider
reserveCache.aTokenAddress
)
) {
userConfig.setUsingAsCollateral(reserve.id, true);
Expand Down Expand Up @@ -218,7 +218,7 @@ library SupplyLogic {
reservesList,
toConfig,
reserve.configuration,
params.addressesProvider
reserve.aTokenAddress
)
) {
toConfig.setUsingAsCollateral(reserveId, true);
Expand Down
20 changes: 15 additions & 5 deletions contracts/protocol/libraries/logic/ValidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {DataTypes} from '../types/DataTypes.sol';
import {ReserveLogic} from './ReserveLogic.sol';
import {GenericLogic} from './GenericLogic.sol';
import {SafeCast} from '../../../dependencies/openzeppelin/contracts/SafeCast.sol';
import {IncentivizedERC20} from '../../tokenization/base/IncentivizedERC20.sol';

/**
* @title ReserveLogic library
Expand Down Expand Up @@ -52,9 +53,10 @@ library ValidationLogic {
uint256 public constant HEALTH_FACTOR_LIQUIDATION_THRESHOLD = 1e18;

/**
* @dev Role identifier for the role allowed to supply isolated reserves as collateral
*/
bytes32 public constant ISOLATED_COLLATERAL_SUPPLIER_ROLE = keccak256('ISOLATED_COLLATERAL_SUPPLIER');
* @dev Role identifier for the role allowed to supply isolated reserves as collateral
*/
bytes32 public constant ISOLATED_COLLATERAL_SUPPLIER_ROLE =
keccak256('ISOLATED_COLLATERAL_SUPPLIER');

/**
* @notice Validates a supply action.
Expand Down Expand Up @@ -734,11 +736,19 @@ library ValidationLogic {
mapping(uint256 => address) storage reservesList,
DataTypes.UserConfigurationMap storage userConfig,
DataTypes.ReserveConfigurationMap memory reserveConfig,
address addressesProvider
address aTokenAddress
) internal view returns (bool) {
if (reserveConfig.getDebtCeiling() != 0) {
// ensures only the ISOLATED_COLLATERAL_SUPPLIER_ROLE can enable collateral as side-effect of an action
if(!IAccessControl(IPoolAddressesProvider(addressesProvider).getACLManager()).hasRole(ISOLATED_COLLATERAL_SUPPLIER_ROLE, msg.sender)) return false;
IPoolAddressesProvider addressesProvider = IncentivizedERC20(aTokenAddress)
.POOL()
.ADDRESSES_PROVIDER();
if (
!IAccessControl(addressesProvider.getACLManager()).hasRole(
ISOLATED_COLLATERAL_SUPPLIER_ROLE,
msg.sender
)
) return false;
}
return validateUseAsCollateral(reservesData, reservesList, userConfig, reserveConfig);
}
Expand Down
3 changes: 0 additions & 3 deletions contracts/protocol/libraries/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,13 @@ library DataTypes {
address priceOracle;
uint8 userEModeCategory;
address priceOracleSentinel;
address addressesProvider;
}

struct ExecuteSupplyParams {
address asset;
uint256 amount;
address onBehalfOf;
uint16 referralCode;
address addressesProvider;
}

struct ExecuteBorrowParams {
Expand Down Expand Up @@ -172,7 +170,6 @@ library DataTypes {
uint256 reservesCount;
address oracle;
uint8 fromEModeCategory;
address addressesProvider;
}

struct FlashloanParams {
Expand Down
18 changes: 6 additions & 12 deletions contracts/protocol/pool/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,7 @@ contract Pool is VersionedInitializable, PoolStorage, IPool {
asset,
amount,
onBehalfOf,
referralCode,
address(ADDRESSES_PROVIDER)
referralCode
);
}

Expand Down Expand Up @@ -157,8 +156,7 @@ contract Pool is VersionedInitializable, PoolStorage, IPool {
asset: asset,
amount: amount,
onBehalfOf: onBehalfOf,
referralCode: referralCode,
addressesProvider: address(ADDRESSES_PROVIDER)
referralCode: referralCode
})
);
}
Expand Down Expand Up @@ -191,8 +189,7 @@ contract Pool is VersionedInitializable, PoolStorage, IPool {
asset: asset,
amount: amount,
onBehalfOf: onBehalfOf,
referralCode: referralCode,
addressesProvider: address(ADDRESSES_PROVIDER)
referralCode: referralCode
})
);
}
Expand Down Expand Up @@ -383,8 +380,7 @@ contract Pool is VersionedInitializable, PoolStorage, IPool {
receiveAToken: receiveAToken,
priceOracle: ADDRESSES_PROVIDER.getPriceOracle(),
userEModeCategory: _usersEModeCategory[user],
priceOracleSentinel: ADDRESSES_PROVIDER.getPriceOracleSentinel(),
addressesProvider: address(ADDRESSES_PROVIDER)
priceOracleSentinel: ADDRESSES_PROVIDER.getPriceOracleSentinel()
})
);
}
Expand Down Expand Up @@ -612,8 +608,7 @@ contract Pool is VersionedInitializable, PoolStorage, IPool {
balanceToBefore: balanceToBefore,
reservesCount: _reservesCount,
oracle: ADDRESSES_PROVIDER.getPriceOracle(),
fromEModeCategory: _usersEModeCategory[from],
addressesProvider: address(ADDRESSES_PROVIDER)
fromEModeCategory: _usersEModeCategory[from]
})
);
}
Expand Down Expand Up @@ -772,8 +767,7 @@ contract Pool is VersionedInitializable, PoolStorage, IPool {
asset: asset,
amount: amount,
onBehalfOf: onBehalfOf,
referralCode: referralCode,
addressesProvider: address(ADDRESSES_PROVIDER)
referralCode: referralCode
})
);
}
Expand Down

0 comments on commit 27d2e6e

Please sign in to comment.