Merge branch 'master' into feat/182-cred-del-interface

This commit is contained in:
eboado 2020-11-30 18:16:47 +01:00
commit 12121d41f4
2 changed files with 16 additions and 13 deletions

View File

@ -151,8 +151,8 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '',
[eEthereumNetwork.kovan]: '0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
[eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
[eEthereumNetwork.main]: ZERO_ADDRESS,
[eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
[eEthereumNetwork.main]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
[eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
},
TokenDistributor: {
[eEthereumNetwork.coverage]: '',
@ -169,8 +169,8 @@ export const CommonsConfig: ICommonConfiguration = {
[eEthereumNetwork.buidlerevm]: '',
[EthereumNetwork.kovan]: '0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
[EthereumNetwork.ropsten]: ZERO_ADDRESS,
[EthereumNetwork.main]: ZERO_ADDRESS,
[EthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
[EthereumNetwork.main]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
[EthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
},
FallbackOracle: {
[eEthereumNetwork.coverage]: '',

View File

@ -1,10 +1,5 @@
import BigNumber from 'bignumber.js';
import {
ONE_YEAR,
RAY,
MAX_UINT_AMOUNT,
PERCENTAGE_FACTOR,
} from '../../../helpers/constants';
import { ONE_YEAR, RAY, MAX_UINT_AMOUNT, PERCENTAGE_FACTOR } from '../../../helpers/constants';
import {
IReserveParams,
iAavePoolAssets,
@ -525,11 +520,10 @@ export const calcExpectedReserveDataAfterRepay = (
//due to accumulation errors, the total stable debt might be smaller than the last user debt.
//in this case we simply set the total supply and avg stable rate to 0.
if (expectedReserveData.principalStableDebt.lt(0)) {
expectedReserveData.principalStableDebt = expectedReserveData.totalStableDebt = new BigNumber(
if (expectedReserveData.totalStableDebt.lt(0)) {
expectedReserveData.principalStableDebt = expectedReserveData.totalStableDebt = expectedReserveData.averageStableBorrowRate = new BigNumber(
0
);
expectedReserveData.averageStableBorrowRate = new BigNumber(0);
} else {
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
reserveDataBeforeAction.averageStableBorrowRate,
@ -537,6 +531,15 @@ export const calcExpectedReserveDataAfterRepay = (
amountRepaidBN.negated(),
userDataBeforeAction.stableBorrowRate
);
//also due to accumulation errors, the final avg stable rate when the last user repays might be negative.
//if that is the case, it means a small leftover of total stable debt is left, which can be erased.
if (expectedReserveData.averageStableBorrowRate.lt(0)) {
expectedReserveData.principalStableDebt = expectedReserveData.totalStableDebt = expectedReserveData.averageStableBorrowRate = new BigNumber(
0
);
}
}
expectedReserveData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt;