mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Removed ETH specific logic in tests
This commit is contained in:
parent
45cb9ab680
commit
b2d8a9e053
|
@ -15,7 +15,6 @@ export const strToBN = (amount: string): BigNumber => new BigNumber(amount);
|
||||||
|
|
||||||
interface Configuration {
|
interface Configuration {
|
||||||
reservesParams: iAavePoolAssets<IReserveParams>;
|
reservesParams: iAavePoolAssets<IReserveParams>;
|
||||||
ethereumAddress: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const configuration: Configuration = <Configuration>{};
|
export const configuration: Configuration = <Configuration>{};
|
||||||
|
@ -66,17 +65,7 @@ export const calcExpectedUserDataAfterDeposit = (
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
|
expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
|
||||||
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
// console.log("** ETH CASE ****")
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance
|
|
||||||
.minus(txCost)
|
|
||||||
.minus(amountDeposited);
|
|
||||||
} else {
|
|
||||||
// console.log("** TOKEN CASE ****")
|
|
||||||
// console.log(userDataBeforeAction.walletBalance.toString())
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(amountDeposited);
|
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(amountDeposited);
|
||||||
}
|
|
||||||
|
|
||||||
expectedUserData.principalATokenBalance = expectedUserData.currentATokenBalance = calcExpectedATokenBalance(
|
expectedUserData.principalATokenBalance = expectedUserData.currentATokenBalance = calcExpectedATokenBalance(
|
||||||
reserveDataBeforeAction,
|
reserveDataBeforeAction,
|
||||||
|
@ -171,14 +160,7 @@ export const calcExpectedUserDataAfterWithdraw = (
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
|
expectedUserData.variableBorrowIndex = userDataBeforeAction.variableBorrowIndex;
|
||||||
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance
|
|
||||||
.minus(txCost)
|
|
||||||
.plus(amountWithdrawn);
|
|
||||||
} else {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.plus(amountWithdrawn);
|
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.plus(amountWithdrawn);
|
||||||
}
|
|
||||||
|
|
||||||
expectedUserData.redirectedBalance = userDataBeforeAction.redirectedBalance;
|
expectedUserData.redirectedBalance = userDataBeforeAction.redirectedBalance;
|
||||||
|
|
||||||
|
@ -600,13 +582,7 @@ export const calcExpectedUserDataAfterBorrow = (
|
||||||
userDataBeforeAction.redirectionAddressRedirectedBalance;
|
userDataBeforeAction.redirectionAddressRedirectedBalance;
|
||||||
expectedUserData.currentATokenUserIndex = userDataBeforeAction.currentATokenUserIndex;
|
expectedUserData.currentATokenUserIndex = userDataBeforeAction.currentATokenUserIndex;
|
||||||
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance
|
|
||||||
.minus(txCost)
|
|
||||||
.plus(amountBorrowed);
|
|
||||||
} else {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.plus(amountBorrowed);
|
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.plus(amountBorrowed);
|
||||||
}
|
|
||||||
|
|
||||||
return expectedUserData;
|
return expectedUserData;
|
||||||
};
|
};
|
||||||
|
@ -657,8 +633,7 @@ export const calcExpectedUserDataAfterRepay = (
|
||||||
expectedUserData.stableBorrowRate = expectedUserData.stableRateLastUpdated = new BigNumber(
|
expectedUserData.stableBorrowRate = expectedUserData.stableRateLastUpdated = new BigNumber(
|
||||||
'0'
|
'0'
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
expectedUserData.stableBorrowRate = userDataBeforeAction.stableBorrowRate;
|
expectedUserData.stableBorrowRate = userDataBeforeAction.stableBorrowRate;
|
||||||
expectedUserData.stableRateLastUpdated = txTimestamp;
|
expectedUserData.stableRateLastUpdated = txTimestamp;
|
||||||
}
|
}
|
||||||
|
@ -697,14 +672,7 @@ export const calcExpectedUserDataAfterRepay = (
|
||||||
expectedUserData.currentATokenUserIndex = userDataBeforeAction.currentATokenUserIndex;
|
expectedUserData.currentATokenUserIndex = userDataBeforeAction.currentATokenUserIndex;
|
||||||
|
|
||||||
if (user === onBehalfOf) {
|
if (user === onBehalfOf) {
|
||||||
//if user repaid for himself, update the wallet balances
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance
|
|
||||||
.minus(txCost)
|
|
||||||
.minus(totalRepaid);
|
|
||||||
} else {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(totalRepaid);
|
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(totalRepaid);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//wallet balance didn't change
|
//wallet balance didn't change
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance;
|
expectedUserData.walletBalance = userDataBeforeAction.walletBalance;
|
||||||
|
@ -723,10 +691,6 @@ export const calcExpectedUserDataAfterSetUseAsCollateral = (
|
||||||
|
|
||||||
expectedUserData.usageAsCollateralEnabled = useAsCollateral;
|
expectedUserData.usageAsCollateralEnabled = useAsCollateral;
|
||||||
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(txCost);
|
|
||||||
}
|
|
||||||
|
|
||||||
return expectedUserData;
|
return expectedUserData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -892,9 +856,6 @@ export const calcExpectedUserDataAfterSwapRateMode = (
|
||||||
|
|
||||||
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
||||||
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(txCost);
|
|
||||||
}
|
|
||||||
return expectedUserData;
|
return expectedUserData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1000,12 +961,6 @@ export const calcExpectedUserDataAfterStableRateRebalance = (
|
||||||
|
|
||||||
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
||||||
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedUserData.walletBalance = userDataBeforeAction.walletBalance.minus(txCost);
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedUserData.liquidityRate = expectedDataAfterAction.liquidityRate;
|
|
||||||
|
|
||||||
expectedUserData.currentATokenBalance = calcExpectedATokenBalance(
|
expectedUserData.currentATokenBalance = calcExpectedATokenBalance(
|
||||||
reserveDataBeforeAction,
|
reserveDataBeforeAction,
|
||||||
userDataBeforeAction,
|
userDataBeforeAction,
|
||||||
|
@ -1069,12 +1024,6 @@ export const calcExpectedUsersDataAfterRedirectInterest = (
|
||||||
txTimestamp
|
txTimestamp
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isFromExecutingTx) {
|
|
||||||
if (reserveDataBeforeAction.address === configuration.ethereumAddress) {
|
|
||||||
expectedFromData.walletBalance = fromDataBeforeAction.walletBalance.minus(txCost);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
expectedToData.redirectedBalance = toDataBeforeAction.redirectedBalance.plus(
|
expectedToData.redirectedBalance = toDataBeforeAction.redirectedBalance.plus(
|
||||||
expectedFromData.currentATokenBalance
|
expectedFromData.currentATokenBalance
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user