diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 8b163095..86bc3d7f 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -376,8 +376,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { if(CoreLibrary.InterestRateMode(_interestRateMode) == CoreLibrary.InterestRateMode.STABLE) { IStableDebtToken(reserve.stableDebtTokenAddress).mint(msg.sender, _amount, userStableRate); uint40 stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated(msg.sender); - console.log("Stable rate last updated in borrow is %s", stableRateLastUpdated); - } else { IVariableDebtToken(reserve.variableDebtTokenAddress).mint(msg.sender, _amount); @@ -391,10 +389,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { (uint256 stableBalance, uint256 variableBalance) = UserLogic.getUserBorrowBalances(msg.sender, reserve); - console.log("Debt balances: %s %s", stableBalance, variableBalance); - - console.log("User variable borrow index %s reserve index %s", IVariableDebtToken(reserve.variableDebtTokenAddress).getUserIndex(msg.sender), reserve.lastVariableBorrowCumulativeIndex); - console.log("User stable rate %s", IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(msg.sender)); emit Borrow( _reserve, msg.sender, @@ -437,33 +431,21 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { CoreLibrary.ReserveData storage reserve = reserves[_reserve]; CoreLibrary.UserReserveData storage user = usersReserveData[_onBehalfOf][_reserve]; - console.log("Getting balances..."); - + ( vars.stableBorrowBalance, vars.variableBorrowBalance ) = UserLogic.getUserBorrowBalances(_onBehalfOf, reserve); - - - console.log("Balances calculated, %s %s", vars.stableBorrowBalance, vars.variableBorrowBalance); - - console.log("Interest rate mode %s", _rateMode); - + CoreLibrary.InterestRateMode rateMode = CoreLibrary.InterestRateMode(_rateMode); - console.log("Interest rate mode %s", _rateMode); - //default to max amount vars.paybackAmount = rateMode == CoreLibrary.InterestRateMode.STABLE ? vars.stableBorrowBalance : vars.variableBorrowBalance; - console.log("Payback amount %s stable rate %s", vars.paybackAmount, IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(_onBehalfOf)); - if (_amount != UINT_MAX_VALUE && _amount < vars.paybackAmount) { vars.paybackAmount = _amount; } - console.log("Validating repay..."); - ValidationLogic.validateRepay( reserve, _reserve, @@ -478,7 +460,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { reserve.updateCumulativeIndexesAndTimestamp(); - console.log("Burning tokens..."); //burns an equivalent amount of debt tokens if(rateMode == CoreLibrary.InterestRateMode.STABLE) { IStableDebtToken(reserve.stableDebtTokenAddress).burn(_onBehalfOf, vars.paybackAmount); @@ -894,7 +875,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { liquidityRate = reserve.currentLiquidityRate; stableBorrowRate = IStableDebtToken(reserve.stableDebtTokenAddress).getUserStableRate(_user); stableRateLastUpdated = IStableDebtToken(reserve.stableDebtTokenAddress).getUserLastUpdated(_user); - console.log("Stable rate last updated is %s", stableRateLastUpdated); usageAsCollateralEnabled = usersReserveData[_user][_reserve].useAsCollateral; variableBorrowIndex = IVariableDebtToken(reserve.variableDebtTokenAddress).getUserIndex(_user); } diff --git a/test/helpers/scenarios/interest-redirection.json b/test/helpers/scenarios/interest-redirection.json index e89c8620..00d82155 100644 --- a/test/helpers/scenarios/interest-redirection.json +++ b/test/helpers/scenarios/interest-redirection.json @@ -123,7 +123,8 @@ "reserve": "DAI", "amount": "-1", "user": "1", - "onBehalfOf": "1" + "onBehalfOf": "1", + "borrowRateMode": "stable" }, "expected": "success" }, diff --git a/test/helpers/utils/calculations.ts b/test/helpers/utils/calculations.ts index 400e8e64..9c8ddb92 100644 --- a/test/helpers/utils/calculations.ts +++ b/test/helpers/utils/calculations.ts @@ -152,7 +152,7 @@ export const calcExpectedUserDataAfterRedeem = ( txTimestamp ); - expectedUserData.principalATokenBalance = userDataBeforeAction.principalStableBorrowBalance; + expectedUserData.principalStableBorrowBalance = userDataBeforeAction.principalStableBorrowBalance; expectedUserData.principalVariableBorrowBalance = userDataBeforeAction.principalVariableBorrowBalance; expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex; diff --git a/test/scenario.spec.ts b/test/scenario.spec.ts index 80186a27..10db45fb 100644 --- a/test/scenario.spec.ts +++ b/test/scenario.spec.ts @@ -1,33 +1,31 @@ -import {configuration as actionsConfiguration} from "./helpers/actions"; -import {configuration as calculationsConfiguration} from "./helpers/utils/calculations"; +import {configuration as actionsConfiguration} from './helpers/actions'; +import {configuration as calculationsConfiguration} from './helpers/utils/calculations'; -import fs from "fs"; -import BigNumber from "bignumber.js"; -import {makeSuite} from "./helpers/make-suite"; -import {MOCK_ETH_ADDRESS, getReservesConfigByPool} from "../helpers/constants"; -import {AavePools, iAavePoolAssets, IReserveParams} from "../helpers/types"; -import {executeStory} from "./helpers/scenario-engine"; +import fs from 'fs'; +import BigNumber from 'bignumber.js'; +import {makeSuite} from './helpers/make-suite'; +import {MOCK_ETH_ADDRESS, getReservesConfigByPool} from '../helpers/constants'; +import {AavePools, iAavePoolAssets, IReserveParams} from '../helpers/types'; +import {executeStory} from './helpers/scenario-engine'; BigNumber.config({DECIMAL_PLACES: 0, ROUNDING_MODE: BigNumber.ROUND_DOWN}); -const scenarioFolder = "./test/helpers/scenarios/"; +const scenarioFolder = './test/helpers/scenarios/'; + +const selectedScenarios: string[] = []; fs.readdirSync(scenarioFolder).forEach((file) => { - if (![ - "borrow-repay-variable.json", - ].includes(file) - ) - return; + if (selectedScenarios.length > 0 && !selectedScenarios.includes(file)) return; const scenario = require(`./helpers/scenarios/${file}`); makeSuite(scenario.title, async (testEnv) => { - before("Initializing configuration", async () => { + before('Initializing configuration', async () => { actionsConfiguration.skipIntegrityCheck = false; //set this to true to execute solidity-coverage - calculationsConfiguration.reservesParams = < - iAavePoolAssets - >getReservesConfigByPool(AavePools.proto); + calculationsConfiguration.reservesParams = >( + getReservesConfigByPool(AavePools.proto) + ); calculationsConfiguration.ethereumAddress = MOCK_ETH_ADDRESS; });