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

View File

@ -1,10 +1,5 @@
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { import { ONE_YEAR, RAY, MAX_UINT_AMOUNT, PERCENTAGE_FACTOR } from '../../../helpers/constants';
ONE_YEAR,
RAY,
MAX_UINT_AMOUNT,
PERCENTAGE_FACTOR,
} from '../../../helpers/constants';
import { import {
IReserveParams, IReserveParams,
iAavePoolAssets, iAavePoolAssets,
@ -525,11 +520,10 @@ export const calcExpectedReserveDataAfterRepay = (
//due to accumulation errors, the total stable debt might be smaller than the last user debt. //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. //in this case we simply set the total supply and avg stable rate to 0.
if (expectedReserveData.principalStableDebt.lt(0)) { if (expectedReserveData.totalStableDebt.lt(0)) {
expectedReserveData.principalStableDebt = expectedReserveData.totalStableDebt = new BigNumber( expectedReserveData.principalStableDebt = expectedReserveData.totalStableDebt = expectedReserveData.averageStableBorrowRate = new BigNumber(
0 0
); );
expectedReserveData.averageStableBorrowRate = new BigNumber(0);
} else { } else {
expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate( expectedReserveData.averageStableBorrowRate = calcExpectedAverageStableBorrowRate(
reserveDataBeforeAction.averageStableBorrowRate, reserveDataBeforeAction.averageStableBorrowRate,
@ -537,6 +531,15 @@ export const calcExpectedReserveDataAfterRepay = (
amountRepaidBN.negated(), amountRepaidBN.negated(),
userDataBeforeAction.stableBorrowRate 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; expectedReserveData.scaledVariableDebt = reserveDataBeforeAction.scaledVariableDebt;