Skip to content
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

feat: remove isolation and silo code from contracts, harness and test… #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 40 additions & 64 deletions certora/harness/ReserveConfigurationHarness.sol
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pragma solidity 0.8.10;
pragma experimental ABIEncoderV2;

import {ReserveConfiguration} from '../munged/protocol/libraries/configuration/ReserveConfiguration.sol';
import {DataTypes} from '../munged/protocol/libraries/types/DataTypes.sol';
import {ReserveConfiguration} from "../munged/protocol/libraries/configuration/ReserveConfiguration.sol";
import {DataTypes} from "../munged/protocol/libraries/types/DataTypes.sol";

contract ReserveConfigurationHarness {
DataTypes.ReserveConfigurationMap public reservesConfig;
mapping(uint256 => uint256) public intSettersUpperBounds;
mapping(uint256 => uint256) public intSetterslowerBounds;
mapping(uint256 => uint256) public boolSettersCompare;

// Sets the Loan to Value of the reserve
function setLtv(uint256 ltv) public {
DataTypes.ReserveConfigurationMap memory configNew = reservesConfig;
Expand Down Expand Up @@ -94,30 +94,6 @@ contract ReserveConfigurationHarness {
return ReserveConfiguration.getPaused(reservesConfig);
}

// Sets the borrowable in isolation flag for the reserve.
function setBorrowableInIsolation(bool borrowable) public {
DataTypes.ReserveConfigurationMap memory configNew = reservesConfig;
ReserveConfiguration.setBorrowableInIsolation(configNew, borrowable);
reservesConfig.data = configNew.data;
}

// Gets the borrowable in isolation flag for the reserve.
function getBorrowableInIsolation() public view returns (bool) {
return ReserveConfiguration.getBorrowableInIsolation(reservesConfig);
}

// Sets the siloed borrowing flag for the reserve.
function setSiloedBorrowing(bool siloed) public {
DataTypes.ReserveConfigurationMap memory configNew = reservesConfig;
ReserveConfiguration.setSiloedBorrowing(configNew, siloed);
reservesConfig.data = configNew.data;
}

// Gets the siloed borrowing flag for the reserve.
function getSiloedBorrowing() public view returns (bool) {
return ReserveConfiguration.getSiloedBorrowing(reservesConfig);
}

// Enables or disables borrowing on the reserve
function setBorrowingEnabled(bool enabled) public {
DataTypes.ReserveConfigurationMap memory configNew = reservesConfig;
Expand Down Expand Up @@ -247,91 +223,91 @@ contract ReserveConfigurationHarness {
function executeIntSetterById(uint256 id, uint256 val) public {
require(id >= 0 && id <= 10);
if (id == 0) {
setLtv(val);
setLtv(val);
} else if (id == 1) {
setLiquidationThreshold(val);
setLiquidationThreshold(val);
} else if (id == 2) {
setLiquidationBonus(val);
setLiquidationBonus(val);
} else if (id == 3) {
setDecimals(val);
setDecimals(val);
} else if (id == 4) {
setReserveFactor(val);
setReserveFactor(val);
} else if (id == 5) {
setBorrowCap(val);
setBorrowCap(val);
} else if (id == 6) {
setSupplyCap(val);
setSupplyCap(val);
} else if (id == 7) {
setLiquidationProtocolFee(val);
setLiquidationProtocolFee(val);
} else if (id == 8) {
setEModeCategory(val);
setEModeCategory(val);
} else if (id == 9) {
setUnbackedMintCap(val);
setUnbackedMintCap(val);
} else {
setDebtCeiling(val);
setDebtCeiling(val);
}
}

// Executes a getter of an int parameter according to the given id
function executeIntGetterById(uint256 id) public view returns(uint256) {
function executeIntGetterById(uint256 id) public view returns (uint256) {
require(id >= 0 && id <= 10);
if (id == 0) {
return getLtv();
return getLtv();
} else if (id == 1) {
return getLiquidationThreshold();
return getLiquidationThreshold();
} else if (id == 2) {
return getLiquidationBonus();
return getLiquidationBonus();
} else if (id == 3) {
return getDecimals();
return getDecimals();
} else if (id == 4) {
return getReserveFactor();
return getReserveFactor();
} else if (id == 5) {
return getBorrowCap();
return getBorrowCap();
} else if (id == 6) {
return getSupplyCap();
return getSupplyCap();
} else if (id == 7) {
return getLiquidationProtocolFee();
return getLiquidationProtocolFee();
} else if (id == 8) {
return getEModeCategory();
return getEModeCategory();
} else if (id == 9) {
return getUnbackedMintCap();
return getUnbackedMintCap();
} else {
return getDebtCeiling();
return getDebtCeiling();
}
}

// Executes a setter of a bool parameter according to the given id
function executeBoolSetterById(uint256 id, bool val) public {
require(id >= 0 && id <= 5);
if (id == 0) {
setActive(val);
setActive(val);
} else if (id == 1) {
setFrozen(val);
setFrozen(val);
} else if (id == 2) {
setBorrowingEnabled(val);
setBorrowingEnabled(val);
} else if (id == 3) {
setStableRateBorrowingEnabled(val);
setStableRateBorrowingEnabled(val);
} else if (id == 4) {
setPaused(val);
setPaused(val);
} else {
setBorrowableInIsolation(val);
setBorrowableInIsolation(val);
}
}

// Executes a getter of a bool parameter according to the given id
function executeBoolGetterById(uint256 id) public view returns(bool) {
function executeBoolGetterById(uint256 id) public view returns (bool) {
require(id >= 0 && id <= 5);
if (id == 0) {
return getActive();
return getActive();
} else if (id == 1) {
return getFrozen();
return getFrozen();
} else if (id == 2) {
return getBorrowingEnabled();
return getBorrowingEnabled();
} else if (id == 3) {
return getStableRateBorrowingEnabled();
return getStableRateBorrowingEnabled();
} else if (id == 4) {
return getPaused();
return getPaused();
} else {
return getBorrowableInIsolation();
return getBorrowableInIsolation();
}
}
}
}
21 changes: 5 additions & 16 deletions certora/harness/UserConfigurationHarness.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
pragma solidity 0.8.10;
pragma experimental ABIEncoderV2;

import {UserConfiguration} from '../munged/protocol/libraries/configuration/UserConfiguration.sol';
import {DataTypes} from '../munged/protocol/libraries/types/DataTypes.sol';
import {PoolStorage} from '../munged/protocol/pool/PoolStorage.sol';
import {UserConfiguration} from "../munged/protocol/libraries/configuration/UserConfiguration.sol";
import {DataTypes} from "../munged/protocol/libraries/types/DataTypes.sol";
import {PoolStorage} from "../munged/protocol/pool/PoolStorage.sol";

/*
A wrapper contract for calling functions from the library UserConfiguration.
*/
contract UserConfigurationHarness is PoolStorage {
DataTypes.UserConfigurationMap public usersConfig;

// Sets if the user is borrowing the reserve identified by reserveIndex
function setBorrowing(uint256 reserveIndex, bool borrowing) public {
UserConfiguration.setBorrowing(usersConfig, reserveIndex, borrowing);
Expand Down Expand Up @@ -45,7 +45,7 @@ contract UserConfigurationHarness is PoolStorage {
function isUsingAsCollateralAny() public view returns (bool) {
return UserConfiguration.isUsingAsCollateralAny(usersConfig);
}

// Checks if a user has been borrowing only one asset
function isBorrowingOne() public view returns (bool) {
return UserConfiguration.isBorrowingOne(usersConfig);
Expand All @@ -60,15 +60,4 @@ contract UserConfigurationHarness is PoolStorage {
function isEmpty() public view returns (bool) {
return UserConfiguration.isEmpty(usersConfig);
}

// Returns the Isolation Mode state of the user
function getIsolationModeState()
public view returns (bool, address, uint256) {
return UserConfiguration.getIsolationModeState(usersConfig, _reserves, _reservesList);
}

// Returns the siloed borrowing state for the user
function getSiloedBorrowingState() public view returns (bool, address) {
return UserConfiguration.getSiloedBorrowingState(usersConfig, _reserves, _reservesList);
}
}
14 changes: 0 additions & 14 deletions contracts/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ interface IPool {
DataTypes.InterestRateMode interestRateMode
);

/**
* @dev Emitted on borrow(), repay() and liquidationCall() when using isolated assets
* @param asset The address of the underlying asset of the reserve
* @param totalDebt The total isolation mode debt for the reserve
*/
event IsolationModeTotalDebtUpdated(address indexed asset, uint256 totalDebt);

/**
* @dev Emitted when the user selects a certain asset category for eMode
* @param user The address of the user
Expand Down Expand Up @@ -670,13 +663,6 @@ interface IPool {
*/
function getUserEMode(address user) external view returns (uint256);

/**
* @notice Resets the isolation mode total debt of the given asset to zero
* @dev It requires the given asset has zero debt ceiling
* @param asset The address of the underlying asset to reset the isolationModeTotalDebt
*/
function resetIsolationModeTotalDebt(address asset) external;

/**
* @notice Returns the percentage of available liquidity that can be borrowed at once at stable rate
* @return The percentage of available liquidity to borrow, expressed in bps
Expand Down
32 changes: 0 additions & 32 deletions contracts/interfaces/IPoolConfigurator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,6 @@ interface IPoolConfigurator {
*/
event DebtCeilingChanged(address indexed asset, uint256 oldDebtCeiling, uint256 newDebtCeiling);

/**
* @dev Emitted when the the siloed borrowing state for an asset is changed.
* @param asset The address of the underlying asset of the reserve
* @param oldState The old siloed borrowing state
* @param newState The new siloed borrowing state
*/
event SiloedBorrowingChanged(address indexed asset, bool oldState, bool newState);

/**
* @dev Emitted when the bridge protocol fee is updated.
* @param oldBridgeProtocolFee The old protocol fee, expressed in bps
Expand Down Expand Up @@ -252,13 +244,6 @@ interface IPoolConfigurator {
uint128 newFlashloanPremiumToProtocol
);

/**
* @dev Emitted when the reserve is set as borrowable/non borrowable in isolation mode.
* @param asset The address of the underlying asset of the reserve
* @param borrowable True if the reserve is borrowable in isolation, false otherwise
*/
event BorrowableInIsolationChanged(address asset, bool borrowable);

/**
* @notice Initializes multiple reserves.
* @param input The array of initialization parameters
Expand Down Expand Up @@ -341,17 +326,6 @@ interface IPoolConfigurator {
*/
function setReserveFreeze(address asset, bool freeze) external;

/**
* @notice Sets the borrowable in isolation flag for the reserve.
* @dev When this flag is set to true, the asset will be borrowable against isolated collaterals and the
* borrowed amount will be accumulated in the isolated collateral's total debt exposure
* @dev Only assets of the same family (e.g. USD stablecoins) should be borrowable in isolation mode to keep
* consistency in the debt ceiling calculations
* @param asset The address of the underlying asset of the reserve
* @param borrowable True if the asset should be borrowable in isolation, false otherwise
*/
function setBorrowableInIsolation(address asset, bool borrowable) external;

/**
* @notice Pauses a reserve. A paused reserve does not allow any interaction (supply, borrow, repay,
* swap interest rate, liquidate, atoken transfers).
Expand Down Expand Up @@ -477,10 +451,4 @@ interface IPoolConfigurator {
* @param newDebtCeiling The new debt ceiling
*/
function setDebtCeiling(address asset, uint256 newDebtCeiling) external;

/**
* @notice Sets siloed borrowing for an asset
* @param siloed The new siloed borrowing state
*/
function setSiloedBorrowing(address asset, bool siloed) external;
}
7 changes: 0 additions & 7 deletions contracts/interfaces/IPoolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,6 @@ interface IPoolDataProvider {
*/
function getPaused(address asset) external view returns (bool isPaused);

/**
* @notice Returns the siloed borrowing flag
* @param asset The address of the underlying asset of the reserve
* @return True if the asset is siloed for borrowing
*/
function getSiloedBorrowing(address asset) external view returns (bool);

/**
* @notice Returns the protocol fee on the liquidation bonus
* @param asset The address of the underlying asset of the reserve
Expand Down
5 changes: 0 additions & 5 deletions contracts/misc/AaveProtocolDataProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ contract AaveProtocolDataProvider is IPoolDataProvider {
(, , , , isPaused) = IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getFlags();
}

/// @inheritdoc IPoolDataProvider
function getSiloedBorrowing(address asset) external view override returns (bool) {
return IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getSiloedBorrowing();
}

/// @inheritdoc IPoolDataProvider
function getLiquidationProtocolFee(address asset) external view override returns (uint256) {
return IPool(ADDRESSES_PROVIDER.getPool()).getConfiguration(asset).getLiquidationProtocolFee();
Expand Down
Loading