Skip to content

Commit

Permalink
fix: Mark all functions as virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Jan 26, 2022
1 parent 63d935f commit f6932b3
Showing 1 changed file with 57 additions and 40 deletions.
97 changes: 57 additions & 40 deletions contracts/protocol/pool/Pool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
_;
}

function _onlyPoolConfigurator() internal view {
function _onlyPoolConfigurator() internal view virtual {
require(
ADDRESSES_PROVIDER.getPoolConfigurator() == msg.sender,
Errors.CALLER_NOT_POOL_CONFIGURATOR
);
}

function _onlyPoolAdmin() internal view {
function _onlyPoolAdmin() internal view virtual {
require(
IACLManager(ADDRESSES_PROVIDER.getACLManager()).isPoolAdmin(msg.sender),
Errors.CALLER_NOT_POOL_ADMIN
);
}

function _onlyBridge() internal view {
function _onlyBridge() internal view virtual {
require(
IACLManager(ADDRESSES_PROVIDER.getACLManager()).isBridge(msg.sender),
Errors.CALLER_NOT_BRIDGE
Expand All @@ -107,7 +107,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
* @dev Caching the address of the PoolAddressesProvider in order to reduce gas consumption on subsequent operations
* @param provider The address of the PoolAddressesProvider
**/
function initialize(IPoolAddressesProvider provider) external initializer {
function initialize(IPoolAddressesProvider provider) external virtual initializer {
require(provider == ADDRESSES_PROVIDER, Errors.INVALID_ADDRESSES_PROVIDER);
_maxStableRateBorrowSizePercent = 0.25e4;
_flashLoanPremiumTotal = 0.0009e4;
Expand All @@ -120,7 +120,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external override onlyBridge {
) external virtual override onlyBridge {
BridgeLogic.executeMintUnbacked(
_reserves,
_reservesList,
Expand All @@ -137,7 +137,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address asset,
uint256 amount,
uint256 fee
) external override onlyBridge {
) external virtual override onlyBridge {
BridgeLogic.executeBackUnbacked(_reserves[asset], asset, amount, fee, _bridgeProtocolFee);
}

Expand All @@ -147,7 +147,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external override {
) external virtual override {
SupplyLogic.executeSupply(
_reserves,
_reservesList,
Expand All @@ -171,7 +171,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external override {
) external virtual override {
IERC20WithPermit(asset).permit(
msg.sender,
address(this),
Expand Down Expand Up @@ -199,7 +199,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address asset,
uint256 amount,
address to
) external override returns (uint256) {
) external virtual override returns (uint256) {
return
SupplyLogic.executeWithdraw(
_reserves,
Expand All @@ -224,7 +224,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 interestRateMode,
uint16 referralCode,
address onBehalfOf
) external override {
) external virtual override {
BorrowLogic.executeBorrow(
_reserves,
_reservesList,
Expand Down Expand Up @@ -253,7 +253,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 amount,
uint256 interestRateMode,
address onBehalfOf
) external override returns (uint256) {
) external virtual override returns (uint256) {
return
BorrowLogic.executeRepay(
_reserves,
Expand All @@ -279,7 +279,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint8 permitV,
bytes32 permitR,
bytes32 permitS
) external override returns (uint256) {
) external virtual override returns (uint256) {
{
IERC20WithPermit(asset).permit(
msg.sender,
Expand Down Expand Up @@ -308,7 +308,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address asset,
uint256 amount,
uint256 interestRateMode
) external override returns (uint256) {
) external virtual override returns (uint256) {
return
BorrowLogic.executeRepay(
_reserves,
Expand All @@ -325,7 +325,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
}

/// @inheritdoc IPool
function swapBorrowRateMode(address asset, uint256 interestRateMode) external override {
function swapBorrowRateMode(address asset, uint256 interestRateMode) external virtual override {
BorrowLogic.executeSwapBorrowRateMode(
_reserves[asset],
_usersConfig[msg.sender],
Expand All @@ -335,12 +335,16 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
}

/// @inheritdoc IPool
function rebalanceStableBorrowRate(address asset, address user) external override {
function rebalanceStableBorrowRate(address asset, address user) external virtual override {
BorrowLogic.executeRebalanceStableBorrowRate(_reserves[asset], asset, user);
}

/// @inheritdoc IPool
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral) external override {
function setUserUseReserveAsCollateral(address asset, bool useAsCollateral)
external
virtual
override
{
SupplyLogic.executeUseReserveAsCollateral(
_reserves,
_reservesList,
Expand All @@ -361,7 +365,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address user,
uint256 debtToCover,
bool receiveAToken
) external override {
) external virtual override {
LiquidationLogic.executeLiquidationCall(
_reserves,
_usersConfig,
Expand Down Expand Up @@ -390,7 +394,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address onBehalfOf,
bytes calldata params,
uint16 referralCode
) external override {
) external virtual override {
DataTypes.FlashloanParams memory flashParams = DataTypes.FlashloanParams({
receiverAddress: receiverAddress,
assets: assets,
Expand Down Expand Up @@ -426,7 +430,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 amount,
bytes calldata params,
uint16 referralCode
) external override {
) external virtual override {
DataTypes.FlashloanSimpleParams memory flashParams = DataTypes.FlashloanSimpleParams({
receiverAddress: receiverAddress,
asset: asset,
Expand All @@ -440,14 +444,15 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
}

/// @inheritdoc IPool
function mintToTreasury(address[] calldata assets) external override {
function mintToTreasury(address[] calldata assets) external virtual override {
PoolLogic.executeMintToTreasury(_reserves, assets);
}

/// @inheritdoc IPool
function getReserveData(address asset)
external
view
virtual
override
returns (DataTypes.ReserveData memory)
{
Expand All @@ -458,6 +463,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
function getUserAccountData(address user)
external
view
virtual
override
returns (
uint256 totalCollateralBase,
Expand Down Expand Up @@ -499,6 +505,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
function getConfiguration(address asset)
external
view
virtual
override
returns (DataTypes.ReserveConfigurationMap memory)
{
Expand All @@ -509,35 +516,31 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
function getUserConfiguration(address user)
external
view
virtual
override
returns (DataTypes.UserConfigurationMap memory)
{
return _usersConfig[user];
}

/// @inheritdoc IPool
function getReserveNormalizedIncome(address asset)
external
view
virtual
override
returns (uint256)
{
function getReserveNormalizedIncome(address asset) external view override returns (uint256) {
return _reserves[asset].getNormalizedIncome();
}

/// @inheritdoc IPool
function getReserveNormalizedVariableDebt(address asset)
external
view
virtual
override
returns (uint256)
{
return _reserves[asset].getNormalizedDebt();
}

/// @inheritdoc IPool
function getReservesList() external view override returns (address[] memory) {
function getReservesList() external view virtual override returns (address[] memory) {
uint256 reservesListCount = _reservesCount;
uint256 droppedReservesCount = 0;
address[] memory reservesList = new address[](reservesListCount);
Expand All @@ -558,22 +561,22 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
}

/// @inheritdoc IPool
function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() public view override returns (uint256) {
function MAX_STABLE_RATE_BORROW_SIZE_PERCENT() public view virtual override returns (uint256) {
return _maxStableRateBorrowSizePercent;
}

/// @inheritdoc IPool
function BRIDGE_PROTOCOL_FEE() public view override returns (uint256) {
function BRIDGE_PROTOCOL_FEE() public view virtual override returns (uint256) {
return _bridgeProtocolFee;
}

/// @inheritdoc IPool
function FLASHLOAN_PREMIUM_TOTAL() public view override returns (uint128) {
function FLASHLOAN_PREMIUM_TOTAL() public view virtual override returns (uint128) {
return _flashLoanPremiumTotal;
}

/// @inheritdoc IPool
function FLASHLOAN_PREMIUM_TO_PROTOCOL() public view override returns (uint128) {
function FLASHLOAN_PREMIUM_TO_PROTOCOL() public view virtual override returns (uint128) {
return _flashLoanPremiumToProtocol;
}

Expand All @@ -590,7 +593,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 amount,
uint256 balanceFromBefore,
uint256 balanceToBefore
) external override {
) external virtual override {
require(msg.sender == _reserves[asset].aTokenAddress, Errors.CALLER_NOT_ATOKEN);
SupplyLogic.executeFinalizeTransfer(
_reserves,
Expand Down Expand Up @@ -618,7 +621,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address stableDebtAddress,
address variableDebtAddress,
address interestRateStrategyAddress
) external override onlyPoolConfigurator {
) external virtual override onlyPoolConfigurator {
if (
PoolLogic.executeInitReserve(
_reserves,
Expand Down Expand Up @@ -646,6 +649,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
/// @inheritdoc IPool
function setReserveInterestRateStrategyAddress(address asset, address rateStrategyAddress)
external
virtual
override
onlyPoolConfigurator
{
Expand All @@ -657,6 +661,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
/// @inheritdoc IPool
function setConfiguration(address asset, DataTypes.ReserveConfigurationMap calldata configuration)
external
virtual
override
onlyPoolConfigurator
{
Expand All @@ -666,22 +671,28 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
}

/// @inheritdoc IPool
function updateBridgeProtocolFee(uint256 protocolFee) external override onlyPoolConfigurator {
function updateBridgeProtocolFee(uint256 protocolFee)
external
virtual
override
onlyPoolConfigurator
{
_bridgeProtocolFee = protocolFee;
}

/// @inheritdoc IPool
function updateFlashloanPremiums(
uint128 flashLoanPremiumTotal,
uint128 flashLoanPremiumToProtocol
) external override onlyPoolConfigurator {
) external virtual override onlyPoolConfigurator {
_flashLoanPremiumTotal = flashLoanPremiumTotal;
_flashLoanPremiumToProtocol = flashLoanPremiumToProtocol;
}

/// @inheritdoc IPool
function configureEModeCategory(uint8 id, DataTypes.EModeCategory memory category)
external
virtual
override
onlyPoolConfigurator
{
Expand All @@ -694,6 +705,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
function getEModeCategoryData(uint8 id)
external
view
virtual
override
returns (DataTypes.EModeCategory memory)
{
Expand All @@ -717,12 +729,17 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
}

/// @inheritdoc IPool
function getUserEMode(address user) external view override returns (uint256) {
function getUserEMode(address user) external view virtual override returns (uint256) {
return _usersEModeCategory[user];
}

/// @inheritdoc IPool
function resetIsolationModeTotalDebt(address asset) external override onlyPoolConfigurator {
function resetIsolationModeTotalDebt(address asset)
external
virtual
override
onlyPoolConfigurator
{
PoolLogic.executeResetIsolationModeTotalDebt(_reserves, asset);
}

Expand All @@ -731,7 +748,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
address token,
address to,
uint256 amount
) external override onlyPoolAdmin {
) external virtual override onlyPoolAdmin {
PoolLogic.executeRescueTokens(token, to, amount);
}

Expand All @@ -742,7 +759,7 @@ contract Pool is VersionedInitializable, IPool, PoolStorage {
uint256 amount,
address onBehalfOf,
uint16 referralCode
) external override {
) external virtual override {
SupplyLogic.executeSupply(
_reserves,
_reservesList,
Expand Down

0 comments on commit f6932b3

Please sign in to comment.