mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Fixed credit delegation tests
This commit is contained in:
parent
a1a45d392a
commit
6f9ff11e49
|
@ -47,7 +47,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
uint256 public constant UINT_MAX_VALUE = uint256(-1);
|
||||
uint256 public constant LENDINGPOOL_REVISION = 0x2;
|
||||
|
||||
|
||||
/**
|
||||
* @dev only lending pools configurator can use functions affected by this modifier
|
||||
**/
|
||||
|
@ -68,7 +67,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
function whenNotPaused() internal view {
|
||||
require(!_paused, Errors.IS_PAUSED);
|
||||
}
|
||||
|
||||
|
||||
function getRevision() internal override pure returns (uint256) {
|
||||
return LENDINGPOOL_REVISION;
|
||||
}
|
||||
|
@ -248,9 +247,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
uint256 rateMode,
|
||||
address onBehalfOf
|
||||
) external override {
|
||||
|
||||
whenNotPaused();
|
||||
|
||||
|
||||
ReserveLogic.ReserveData storage reserve = _reserves[asset];
|
||||
|
||||
(uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebt(onBehalfOf, reserve);
|
||||
|
@ -281,7 +279,11 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
if (interestRateMode == ReserveLogic.InterestRateMode.STABLE) {
|
||||
IStableDebtToken(reserve.stableDebtTokenAddress).burn(onBehalfOf, paybackAmount);
|
||||
} else {
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).burn(onBehalfOf, paybackAmount, reserve.variableBorrowIndex);
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).burn(
|
||||
onBehalfOf,
|
||||
paybackAmount,
|
||||
reserve.variableBorrowIndex
|
||||
);
|
||||
}
|
||||
|
||||
address aToken = reserve.aTokenAddress;
|
||||
|
@ -322,10 +324,18 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
if (interestRateMode == ReserveLogic.InterestRateMode.STABLE) {
|
||||
//burn stable rate tokens, mint variable rate tokens
|
||||
IStableDebtToken(reserve.stableDebtTokenAddress).burn(msg.sender, stableDebt);
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).mint(msg.sender, stableDebt, reserve.variableBorrowIndex);
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).mint(
|
||||
msg.sender,
|
||||
stableDebt,
|
||||
reserve.variableBorrowIndex
|
||||
);
|
||||
} else {
|
||||
//do the opposite
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).burn(msg.sender, variableDebt, reserve.variableBorrowIndex);
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).burn(
|
||||
msg.sender,
|
||||
variableDebt,
|
||||
reserve.variableBorrowIndex
|
||||
);
|
||||
IStableDebtToken(reserve.stableDebtTokenAddress).mint(
|
||||
msg.sender,
|
||||
variableDebt,
|
||||
|
@ -372,7 +382,6 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
Errors.INTEREST_RATE_REBALANCE_CONDITIONS_NOT_MET
|
||||
);
|
||||
|
||||
|
||||
reserve.updateState();
|
||||
|
||||
//burn old debt tokens, mint new ones
|
||||
|
@ -502,7 +511,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
_flashLiquidationLocked = false;
|
||||
}
|
||||
|
||||
struct FlashLoanLocalVars {
|
||||
struct FlashLoanLocalVars {
|
||||
uint256 premium;
|
||||
uint256 amountPlusPremium;
|
||||
IFlashLoanReceiver receiver;
|
||||
|
@ -883,9 +892,17 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage
|
|||
) {
|
||||
currentStableRate = reserve.currentStableBorrowRate;
|
||||
|
||||
IStableDebtToken(reserve.stableDebtTokenAddress).mint(vars.user, vars.amount, currentStableRate);
|
||||
IStableDebtToken(reserve.stableDebtTokenAddress).mint(
|
||||
vars.onBehalfOf,
|
||||
vars.amount,
|
||||
currentStableRate
|
||||
);
|
||||
} else {
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).mint(vars.user, vars.amount, reserve.variableBorrowIndex);
|
||||
IVariableDebtToken(reserve.variableDebtTokenAddress).mint(
|
||||
vars.onBehalfOf,
|
||||
vars.amount,
|
||||
reserve.variableBorrowIndex
|
||||
);
|
||||
}
|
||||
|
||||
reserve.updateInterestRates(
|
||||
|
|
|
@ -369,9 +369,7 @@ export const borrow = async (
|
|||
expectedReserveData,
|
||||
userDataBefore,
|
||||
txTimestamp,
|
||||
timestamp,
|
||||
onBehalfOf,
|
||||
user.address
|
||||
timestamp
|
||||
);
|
||||
|
||||
console.log("total debt stable exp ", expectedReserveData.totalStableDebt.toFixed());
|
||||
|
@ -381,10 +379,13 @@ export const borrow = async (
|
|||
console.log("total debt variable act ", reserveDataAfter.totalVariableDebt.toFixed());
|
||||
|
||||
console.log("avl liquidity exp ", expectedReserveData.availableLiquidity.toFixed());
|
||||
console.log("avl liquidity exp ", reserveDataAfter.availableLiquidity.toFixed());
|
||||
console.log("avl liquidity act ", reserveDataAfter.availableLiquidity.toFixed());
|
||||
|
||||
console.log("avg borrow rate exp ", expectedReserveData.averageStableBorrowRate.toFixed());
|
||||
console.log("avl borrow rate exp ", reserveDataAfter.averageStableBorrowRate.toFixed());
|
||||
console.log("avl borrow rate act ", reserveDataAfter.averageStableBorrowRate.toFixed());
|
||||
|
||||
console.log("liquidity rate exp ", expectedReserveData.averageStableBorrowRate.toFixed());
|
||||
console.log("avl borrow rate act ", reserveDataAfter.averageStableBorrowRate.toFixed());
|
||||
|
||||
|
||||
expectEqual(reserveDataAfter, expectedReserveData);
|
||||
|
@ -487,8 +488,7 @@ export const repay = async (
|
|||
user.address,
|
||||
onBehalfOf.address,
|
||||
txTimestamp,
|
||||
timestamp,
|
||||
txCost
|
||||
timestamp
|
||||
);
|
||||
|
||||
expectEqual(reserveDataAfter, expectedReserveData);
|
||||
|
|
|
@ -597,9 +597,7 @@ export const calcExpectedUserDataAfterBorrow = (
|
|||
expectedDataAfterAction: ReserveData,
|
||||
userDataBeforeAction: UserReserveData,
|
||||
txTimestamp: BigNumber,
|
||||
currentTimestamp: BigNumber,
|
||||
user: tEthereumAddress,
|
||||
onBehalfOf: tEthereumAddress
|
||||
currentTimestamp: BigNumber
|
||||
): UserReserveData => {
|
||||
const expectedUserData = <UserReserveData>{};
|
||||
|
||||
|
@ -682,8 +680,7 @@ export const calcExpectedUserDataAfterRepay = (
|
|||
user: string,
|
||||
onBehalfOf: string,
|
||||
txTimestamp: BigNumber,
|
||||
currentTimestamp: BigNumber,
|
||||
txCost: BigNumber
|
||||
currentTimestamp: BigNumber
|
||||
): UserReserveData => {
|
||||
const expectedUserData = <UserReserveData>{};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user