Skip to content

Commit

Permalink
fix: Remove unneeded flag
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf committed Apr 5, 2023
1 parent 9079b79 commit 1445e6d
Showing 1 changed file with 25 additions and 43 deletions.
68 changes: 25 additions & 43 deletions src/ProtocolV3TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ contract ProtocolV3TestBase is CommonTestBase {
* @param pool the pool to be snapshotted
* @return ReserveConfig[] list of configs
*/
function createConfigurationSnapshot(string memory reportName, IPool pool)
public
returns (ReserveConfig[] memory)
{
function createConfigurationSnapshot(
string memory reportName,
IPool pool
) public returns (ReserveConfig[] memory) {
string memory path = string(abi.encodePacked('./reports/', reportName, '.json'));
// overwrite with empty json to later be extended
vm.writeFile(
Expand Down Expand Up @@ -99,11 +99,9 @@ contract ProtocolV3TestBase is CommonTestBase {
/**
* @dev returns the first collateral in the list that cannot be borrowed in stable mode
*/
function _getFirstCollateral(ReserveConfig[] memory configs)
private
pure
returns (ReserveConfig memory config)
{
function _getFirstCollateral(
ReserveConfig[] memory configs
) private pure returns (ReserveConfig memory config) {
for (uint256 i = 0; i < configs.length; i++) {
if (configs[i].usageAsCollateralEnabled && !configs[i].stableBorrowRateEnabled)
return configs[i];
Expand All @@ -114,14 +112,10 @@ contract ProtocolV3TestBase is CommonTestBase {
/**
* @dev tests that all assets can be deposited & withdrawn
*/
function _supplyWithdrawFlow(
ReserveConfig[] memory configs,
IPool pool,
address user
) internal {
function _supplyWithdrawFlow(ReserveConfig[] memory configs, IPool pool, address user) internal {
// test all basic interactions
for (uint256 i = 0; i < configs.length; i++) {
uint256 amount = 100 * 10**configs[i].decimals;
uint256 amount = 100 * 10 ** configs[i].decimals;
if (!configs[i].isFrozen) {
_deposit(configs[i], pool, user, amount);
_skipBlocks(1000);
Expand All @@ -138,16 +132,12 @@ contract ProtocolV3TestBase is CommonTestBase {
/**
* @dev tests that all assets with borrowing enabled can be borrowed
*/
function _variableBorrowFlow(
ReserveConfig[] memory configs,
IPool pool,
address user
) internal {
function _variableBorrowFlow(ReserveConfig[] memory configs, IPool pool, address user) internal {
// put 1M whatever collateral, which should be enough to borrow 1 of each
ReserveConfig memory collateralConfig = _getFirstCollateral(configs);
_deposit(collateralConfig, pool, user, 1000000 ether);
for (uint256 i = 0; i < configs.length; i++) {
uint256 amount = 10**configs[i].decimals;
uint256 amount = 10 ** configs[i].decimals;
if (configs[i].borrowingEnabled) {
_deposit(configs[i], pool, EOA, amount * 2);
this._borrow(configs[i], pool, user, amount, false);
Expand All @@ -160,16 +150,12 @@ contract ProtocolV3TestBase is CommonTestBase {
/**
* @dev tests that all assets with stable borrowing enabled can be borrowed
*/
function _stableBorrowFlow(
ReserveConfig[] memory configs,
IPool pool,
address user
) internal {
function _stableBorrowFlow(ReserveConfig[] memory configs, IPool pool, address user) internal {
// put 1M whatever collateral, which should be enough to borrow 1 of each
ReserveConfig memory collateralConfig = _getFirstCollateral(configs);
_deposit(collateralConfig, pool, user, 1000000 ether);
for (uint256 i = 0; i < configs.length; i++) {
uint256 amount = 10**configs[i].decimals;
uint256 amount = 10 ** configs[i].decimals;
if (configs[i].borrowingEnabled && configs[i].stableBorrowRateEnabled) {
_deposit(configs[i], pool, EOA, amount * 2);
this._borrow(configs[i], pool, user, amount, true);
Expand Down Expand Up @@ -296,9 +282,7 @@ contract ProtocolV3TestBase is CommonTestBase {
);
string memory key = vm.toString(address(strategy));
vm.serializeAddress(key, 'address', address(strategy));
bool defaultIR = false;
try strategy.getBaseStableBorrowRate() returns (uint256 baseStableBorrowRate) {
defaultIR = true;
vm.serializeString(key, 'baseStableBorrowRate', vm.toString(baseStableBorrowRate));
vm.serializeString(key, 'stableRateSlope1', vm.toString(strategy.getStableRateSlope1()));
vm.serializeString(key, 'stableRateSlope2', vm.toString(strategy.getStableRateSlope2()));
Expand Down Expand Up @@ -480,11 +464,10 @@ contract ProtocolV3TestBase is CommonTestBase {
return vars.configs;
}

function _getStructReserveTokens(IPoolDataProvider pdp, address underlyingAddress)
internal
view
returns (ReserveTokens memory)
{
function _getStructReserveTokens(
IPoolDataProvider pdp,
address underlyingAddress
) internal view returns (ReserveTokens memory) {
ReserveTokens memory reserveTokens;
(reserveTokens.aToken, reserveTokens.stableDebtToken, reserveTokens.variableDebtToken) = pdp
.getReserveTokensAddresses(underlyingAddress);
Expand Down Expand Up @@ -574,11 +557,10 @@ contract ProtocolV3TestBase is CommonTestBase {
});
}

function _findReserveConfig(ReserveConfig[] memory configs, address underlying)
internal
pure
returns (ReserveConfig memory)
{
function _findReserveConfig(
ReserveConfig[] memory configs,
address underlying
) internal pure returns (ReserveConfig memory) {
for (uint256 i = 0; i < configs.length; i++) {
if (configs[i].underlying == underlying) {
// Important to clone the struct, to avoid unexpected side effect if modifying the returned config
Expand Down Expand Up @@ -816,10 +798,10 @@ contract ProtocolV3TestBase is CommonTestBase {
}
}

function _requireNoChangeInConfigs(ReserveConfig memory config1, ReserveConfig memory config2)
internal
pure
{
function _requireNoChangeInConfigs(
ReserveConfig memory config1,
ReserveConfig memory config2
) internal pure {
require(
keccak256(abi.encodePacked(config1.symbol)) == keccak256(abi.encodePacked(config2.symbol)),
'_noReservesConfigsChangesApartNewListings() : UNEXPECTED_SYMBOL_CHANGED'
Expand Down

0 comments on commit 1445e6d

Please sign in to comment.