mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
fixed redeem tests, removed console.log
This commit is contained in:
parent
30ab5ddec2
commit
34efb0c917
contracts/lendingpool
test
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,8 @@
|
|||
"reserve": "DAI",
|
||||
"amount": "-1",
|
||||
"user": "1",
|
||||
"onBehalfOf": "1"
|
||||
"onBehalfOf": "1",
|
||||
"borrowRateMode": "stable"
|
||||
},
|
||||
"expected": "success"
|
||||
},
|
||||
|
|
|
@ -152,7 +152,7 @@ export const calcExpectedUserDataAfterRedeem = (
|
|||
txTimestamp
|
||||
);
|
||||
|
||||
expectedUserData.principalATokenBalance = userDataBeforeAction.principalStableBorrowBalance;
|
||||
expectedUserData.principalStableBorrowBalance = userDataBeforeAction.principalStableBorrowBalance;
|
||||
expectedUserData.principalVariableBorrowBalance =
|
||||
userDataBeforeAction.principalVariableBorrowBalance;
|
||||
expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
|
||||
|
|
|
@ -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<IReserveParams>
|
||||
>getReservesConfigByPool(AavePools.proto);
|
||||
calculationsConfiguration.reservesParams = <iAavePoolAssets<IReserveParams>>(
|
||||
getReservesConfigByPool(AavePools.proto)
|
||||
);
|
||||
calculationsConfiguration.ethereumAddress = MOCK_ETH_ADDRESS;
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user