mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added collateral enable and stable migration optimization.
This commit is contained in:
parent
41592c4b48
commit
e17f2ec814
|
@ -10,7 +10,7 @@ import {
|
||||||
DefaultReserveInterestRateStrategy
|
DefaultReserveInterestRateStrategy
|
||||||
} from '../lendingpool/DefaultReserveInterestRateStrategy.sol';
|
} from '../lendingpool/DefaultReserveInterestRateStrategy.sol';
|
||||||
|
|
||||||
contract DeployATokensAndRates {
|
contract ATokensAndRatesHelper {
|
||||||
address payable private pool;
|
address payable private pool;
|
||||||
address private addressesProvider;
|
address private addressesProvider;
|
||||||
address private poolConfigurator;
|
address private poolConfigurator;
|
||||||
|
@ -87,4 +87,37 @@ contract DeployATokensAndRates {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function enableReservesAsCollateral(
|
||||||
|
address[] calldata tokens,
|
||||||
|
uint256[] calldata baseLTVs,
|
||||||
|
uint256[] calldata liquidationThresholds,
|
||||||
|
uint256[] calldata liquidationBonuses
|
||||||
|
) external {
|
||||||
|
require(baseLTVs.length == tokens.length);
|
||||||
|
require(liquidationThresholds.length == tokens.length);
|
||||||
|
require(liquidationBonuses.length == tokens.length);
|
||||||
|
|
||||||
|
for (uint256 i = 0; i < tokens.length; i++) {
|
||||||
|
LendingPoolConfigurator(poolConfigurator).enableReserveAsCollateral(
|
||||||
|
tokens[i],
|
||||||
|
baseLTVs[i],
|
||||||
|
liquidationThresholds[i],
|
||||||
|
liquidationBonuses[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function enableBorrowingOnReserves(address[] calldata tokens, bool[] calldata stableBorrows)
|
||||||
|
external
|
||||||
|
{
|
||||||
|
require(stableBorrows.length == tokens.length);
|
||||||
|
|
||||||
|
for (uint256 i = 0; i < tokens.length; i++) {
|
||||||
|
LendingPoolConfigurator(poolConfigurator).enableBorrowingOnReserve(
|
||||||
|
tokens[i],
|
||||||
|
stableBorrows[i]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -4,9 +4,8 @@ pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import {StableDebtToken} from '../tokenization/StableDebtToken.sol';
|
import {StableDebtToken} from '../tokenization/StableDebtToken.sol';
|
||||||
import {VariableDebtToken} from '../tokenization/VariableDebtToken.sol';
|
import {VariableDebtToken} from '../tokenization/VariableDebtToken.sol';
|
||||||
import '@nomiclabs/buidler/console.sol';
|
|
||||||
|
|
||||||
contract DeployStableAndVariableTokens {
|
contract StableAndVariableTokensHelper {
|
||||||
address payable private pool;
|
address payable private pool;
|
||||||
address private addressesProvider;
|
address private addressesProvider;
|
||||||
event deployedContracts(address stableToken, address variableToken);
|
event deployedContracts(address stableToken, address variableToken);
|
|
@ -27,7 +27,7 @@
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"kovan": {
|
"kovan": {
|
||||||
"address": "0xF9a2E6D57c691f3aa5269858178a13Ef06378579",
|
"address": "0x4Fa53B048dbf5F87324C81639984619aB1D98ff7",
|
||||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"kovan": {
|
"kovan": {
|
||||||
"address": "0xf3266d89e6742fAE2C35D05eD549cd4e117300a7",
|
"address": "0x87223624f91EaA7B0627Bf81F541D4F6A1083072",
|
||||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
"address": "0x9Ec55627757348b322c8dD0865D704649bFa0c7b"
|
"address": "0x9Ec55627757348b322c8dD0865D704649bFa0c7b"
|
||||||
},
|
},
|
||||||
"kovan": {
|
"kovan": {
|
||||||
"address": "0x1aae278bCcdb95817c7A546d752fC662F09b6DBa"
|
"address": "0x633CD212D4f7aa6d221353Fb9c6edB746498cC8C"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LendingPoolDataProvider": {
|
"LendingPoolDataProvider": {
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
"address": "0x3EE716e38f21e5FC16BFDB773db24D63C637A5d8"
|
"address": "0x3EE716e38f21e5FC16BFDB773db24D63C637A5d8"
|
||||||
},
|
},
|
||||||
"kovan": {
|
"kovan": {
|
||||||
"address": "0x8E05A3054cb736258FaF4638D07058cE6e294d2C"
|
"address": "0xAD7abA67B6A32de493f684f3c418E324312da0f7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"PriceOracle": {
|
"PriceOracle": {
|
||||||
|
@ -224,7 +224,7 @@
|
||||||
},
|
},
|
||||||
"MockFlashLoanReceiver": {
|
"MockFlashLoanReceiver": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xB8054085AF605D93c32E6B829d3d7eA2A8C84F9A"
|
"address": "0x2530ce07D254eA185E8e0bCC37a39e2FbA3bE548"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
"address": "0x9c91aEaD98b1354C7B0EAfb8ff539d0796c79894"
|
"address": "0x9c91aEaD98b1354C7B0EAfb8ff539d0796c79894"
|
||||||
|
@ -235,7 +235,7 @@
|
||||||
},
|
},
|
||||||
"WalletBalanceProvider": {
|
"WalletBalanceProvider": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xA3Ab089388B0C1BA83B3496696242FcA3F8eb9D5",
|
"address": "0x0Cf45557d25a4e4c0F1aC65EF6c48ae67c61a0E6",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
|
@ -245,6 +245,10 @@
|
||||||
"coverage": {
|
"coverage": {
|
||||||
"address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10",
|
"address": "0xDf73fC454FA018051D4a1509e63D11530A59DE10",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x067400A1e5DfaD5B7537acfd1c981F62c22Ea53E",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DAI": {
|
"DAI": {
|
||||||
|
@ -580,7 +584,7 @@
|
||||||
"address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4"
|
"address": "0x2cfcA5785261fbC88EFFDd46fCFc04c22525F9e4"
|
||||||
},
|
},
|
||||||
"kovan": {
|
"kovan": {
|
||||||
"address": "0xfF28b837352d9531bAb6dFF3650D7831192117F7",
|
"address": "0x9A82710F3fFEF29e5940F3D5f15E8d8d9CaF8C44",
|
||||||
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -640,7 +644,7 @@
|
||||||
},
|
},
|
||||||
"MockAToken": {
|
"MockAToken": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0x2dC17ABe95C889aA4c9474eD45Dd454Ed1Ec1ec1",
|
"address": "0x7fAeC7791277Ff512c41CA903c177B2Ed952dDAc",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
|
@ -668,7 +672,7 @@
|
||||||
},
|
},
|
||||||
"MockStableDebtToken": {
|
"MockStableDebtToken": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0x8b949D7E587518A6ad727ef30C5815De4a16A0D7",
|
"address": "0x33958cC3535Fc328369EAC2B2Bebd120D67C7fa1",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
|
@ -682,7 +686,7 @@
|
||||||
},
|
},
|
||||||
"MockVariableDebtToken": {
|
"MockVariableDebtToken": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xCC5F3Be6e695bD0239dFd0efC8E9FFC6E969D29e",
|
"address": "0x2cBbbBE1B75Ad7848F0844215816F551f429c64f",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
},
|
},
|
||||||
"localhost": {
|
"localhost": {
|
||||||
|
@ -708,24 +712,60 @@
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xFAe0fd738dAbc8a0426F47437322b6d026A9FD95",
|
"address": "0xFAe0fd738dAbc8a0426F47437322b6d026A9FD95",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0xd9A66F000e278710a44525AC43EAE38c63984a23",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"GenericLogic": {
|
"GenericLogic": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0x6082731fdAba4761277Fb31299ebC782AD3bCf24",
|
"address": "0x6082731fdAba4761277Fb31299ebC782AD3bCf24",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0xF412a3A5Ae0CBDc0809d27DE317F531e7477C03f",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ValidationLogic": {
|
"ValidationLogic": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0x8456161947DFc1fC159A0B26c025cD2b4bba0c3e",
|
"address": "0x8456161947DFc1fC159A0B26c025cD2b4bba0c3e",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x3F6d595c3b83E4F35601B51B05B7862381d459f6",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"LendingPoolCollateralManager": {
|
"LendingPoolCollateralManager": {
|
||||||
"buidlerevm": {
|
"buidlerevm": {
|
||||||
"address": "0xeB80313502EA077FA9B8E89b45e4a1B236cA17Ea",
|
"address": "0x8BFFF31B1757da579Bb5B118489568526F7fb6D4",
|
||||||
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x1A9333aA3e524463680FAcE1F734c47D681b32ed",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"StableAndVariableTokensHelper": {
|
||||||
|
"buidlerevm": {
|
||||||
|
"address": "0x3392c115Ff2CE1A782B4a965fF770da61e69228E",
|
||||||
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0x1d8496a2C0e78008dDDF56c84b1d0f14707D3323",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ATokensAndRatesHelper": {
|
||||||
|
"buidlerevm": {
|
||||||
|
"address": "0x72358bcB1b8B60Ca2f30244e50Be20C3ecaC74B2",
|
||||||
|
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
|
||||||
|
},
|
||||||
|
"kovan": {
|
||||||
|
"address": "0xbaAa0c348ed045eF7c57136578339b20d6c375AE",
|
||||||
|
"deployer": "0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {ZERO_ADDRESS} from './constants';
|
||||||
import {
|
import {
|
||||||
AaveProtocolTestHelpersFactory,
|
AaveProtocolTestHelpersFactory,
|
||||||
ATokenFactory,
|
ATokenFactory,
|
||||||
|
ATokensAndRatesHelperFactory,
|
||||||
ChainlinkProxyPriceProviderFactory,
|
ChainlinkProxyPriceProviderFactory,
|
||||||
DefaultReserveInterestRateStrategyFactory,
|
DefaultReserveInterestRateStrategyFactory,
|
||||||
InitializableAdminUpgradeabilityProxyFactory,
|
InitializableAdminUpgradeabilityProxyFactory,
|
||||||
|
@ -40,6 +41,7 @@ import {
|
||||||
WalletBalanceProviderFactory,
|
WalletBalanceProviderFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers';
|
import {withSaveAndVerify, registerContractInJsonDb, linkBytecode} from './contracts-helpers';
|
||||||
|
import {StableAndVariableTokensHelperFactory} from '../types/StableAndVariableTokensHelperFactory';
|
||||||
|
|
||||||
export const deployLendingPoolAddressesProvider = async (verify?: boolean) =>
|
export const deployLendingPoolAddressesProvider = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
|
@ -350,3 +352,25 @@ export const deployMockTokens = async (config: PoolConfiguration, verify?: boole
|
||||||
}
|
}
|
||||||
return tokens;
|
return tokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deployStableAndVariableTokensHelper = async (
|
||||||
|
args: [tEthereumAddress, tEthereumAddress],
|
||||||
|
verify?: boolean
|
||||||
|
) =>
|
||||||
|
withSaveAndVerify(
|
||||||
|
await new StableAndVariableTokensHelperFactory(await getFirstSigner()).deploy(...args),
|
||||||
|
eContractid.StableAndVariableTokensHelper,
|
||||||
|
args,
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
||||||
|
export const deployATokensAndRatesHelper = async (
|
||||||
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress],
|
||||||
|
verify?: boolean
|
||||||
|
) =>
|
||||||
|
withSaveAndVerify(
|
||||||
|
await new ATokensAndRatesHelperFactory(await getFirstSigner()).deploy(...args),
|
||||||
|
eContractid.ATokensAndRatesHelper,
|
||||||
|
args,
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
|
@ -2,6 +2,8 @@ import {
|
||||||
AaveProtocolTestHelpersFactory,
|
AaveProtocolTestHelpersFactory,
|
||||||
ATokenFactory,
|
ATokenFactory,
|
||||||
DefaultReserveInterestRateStrategyFactory,
|
DefaultReserveInterestRateStrategyFactory,
|
||||||
|
DeployATokensAndRatesFactory,
|
||||||
|
DeployStableAndVariableTokensFactory,
|
||||||
GenericLogicFactory,
|
GenericLogicFactory,
|
||||||
LendingPoolAddressesProviderFactory,
|
LendingPoolAddressesProviderFactory,
|
||||||
LendingPoolAddressesProviderRegistryFactory,
|
LendingPoolAddressesProviderRegistryFactory,
|
||||||
|
@ -16,7 +18,7 @@ import {
|
||||||
VariableDebtTokenFactory,
|
VariableDebtTokenFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory';
|
import {Ierc20DetailedFactory} from '../types/Ierc20DetailedFactory';
|
||||||
import {getContract, MockTokenMap} from './contracts-helpers';
|
import {MockTokenMap} from './contracts-helpers';
|
||||||
import {BRE, getDb} from './misc-utils';
|
import {BRE, getDb} from './misc-utils';
|
||||||
import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types';
|
import {eContractid, PoolConfiguration, tEthereumAddress, TokenContractId} from './types';
|
||||||
|
|
||||||
|
@ -201,3 +203,22 @@ export const getGenericLogic = async (address?: tEthereumAddress) =>
|
||||||
(await getDb().get(`${eContractid.GenericLogic}.${BRE.network.name}`).value()).address,
|
(await getDb().get(`${eContractid.GenericLogic}.${BRE.network.name}`).value()).address,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const getStableAndVariableTokensHelper = async (address?: tEthereumAddress) =>
|
||||||
|
await DeployStableAndVariableTokensFactory.connect(
|
||||||
|
address ||
|
||||||
|
(
|
||||||
|
await getDb()
|
||||||
|
.get(`${eContractid.StableAndVariableTokensHelper}.${BRE.network.name}`)
|
||||||
|
.value()
|
||||||
|
).address,
|
||||||
|
await getFirstSigner()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const getATokensAndRatesHelper = async (address?: tEthereumAddress) =>
|
||||||
|
await DeployATokensAndRatesFactory.connect(
|
||||||
|
address ||
|
||||||
|
(await getDb().get(`${eContractid.ATokensAndRatesHelper}.${BRE.network.name}`).value())
|
||||||
|
.address,
|
||||||
|
await getFirstSigner()
|
||||||
|
);
|
||||||
|
|
|
@ -1,106 +1,12 @@
|
||||||
import {AavePools, iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types';
|
import {iMultiPoolsAssets, IReserveParams, tEthereumAddress} from './types';
|
||||||
import {LendingPool} from '../types/LendingPool';
|
|
||||||
import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator';
|
import {LendingPoolConfigurator} from '../types/LendingPoolConfigurator';
|
||||||
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
|
import {AaveProtocolTestHelpers} from '../types/AaveProtocolTestHelpers';
|
||||||
import {LendingPoolAddressesProvider} from '../types/LendingPoolAddressesProvider';
|
|
||||||
import {
|
import {
|
||||||
deployDefaultReserveInterestRateStrategy,
|
deployATokensAndRatesHelper,
|
||||||
deployStableDebtToken,
|
deployStableAndVariableTokensHelper,
|
||||||
deployVariableDebtToken,
|
|
||||||
deployGenericAToken,
|
|
||||||
} from './contracts-deployments';
|
} from './contracts-deployments';
|
||||||
import {chunk, waitForTx} from './misc-utils';
|
import {chunk, waitForTx} from './misc-utils';
|
||||||
import {getFirstSigner, getLendingPoolAddressesProvider} from './contracts-getters';
|
import {getATokensAndRatesHelper, getLendingPoolAddressesProvider} from './contracts-getters';
|
||||||
import {DeployATokensAndRatesFactory} from '../types/DeployATokensAndRatesFactory';
|
|
||||||
import {DeployStableAndVariableTokensFactory} from '../types/DeployStableAndVariableTokensFactory';
|
|
||||||
|
|
||||||
export const enableReservesToBorrow = async (
|
|
||||||
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
|
||||||
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
|
||||||
helpers: AaveProtocolTestHelpers,
|
|
||||||
lendingPoolConfigurator: LendingPoolConfigurator
|
|
||||||
) => {
|
|
||||||
for (const [assetSymbol, {borrowingEnabled, stableBorrowRateEnabled}] of Object.entries(
|
|
||||||
reservesParams
|
|
||||||
) as [string, IReserveParams][]) {
|
|
||||||
if (!borrowingEnabled) continue;
|
|
||||||
try {
|
|
||||||
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
|
||||||
(value) => value === assetSymbol
|
|
||||||
);
|
|
||||||
const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[
|
|
||||||
assetAddressIndex
|
|
||||||
];
|
|
||||||
const {borrowingEnabled: borrowingAlreadyEnabled} = await helpers.getReserveConfigurationData(
|
|
||||||
tokenAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
if (borrowingAlreadyEnabled) {
|
|
||||||
console.log(`Reserve ${assetSymbol} is already enabled for borrowing, skipping`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Enabling borrowing on reserve ', assetSymbol);
|
|
||||||
|
|
||||||
await waitForTx(
|
|
||||||
await lendingPoolConfigurator.enableBorrowingOnReserve(
|
|
||||||
tokenAddress,
|
|
||||||
stableBorrowRateEnabled
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(
|
|
||||||
`Enabling reserve for borrowings for ${assetSymbol} failed with error ${e}. Skipped.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const enableReservesAsCollateral = async (
|
|
||||||
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
|
||||||
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
|
||||||
helpers: AaveProtocolTestHelpers,
|
|
||||||
lendingPoolConfigurator: LendingPoolConfigurator
|
|
||||||
) => {
|
|
||||||
for (const [
|
|
||||||
assetSymbol,
|
|
||||||
{baseLTVAsCollateral, liquidationBonus, liquidationThreshold},
|
|
||||||
] of Object.entries(reservesParams) as [string, IReserveParams][]) {
|
|
||||||
if (baseLTVAsCollateral === '-1') continue;
|
|
||||||
|
|
||||||
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
|
||||||
(value) => value === assetSymbol
|
|
||||||
);
|
|
||||||
const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[
|
|
||||||
assetAddressIndex
|
|
||||||
];
|
|
||||||
const {usageAsCollateralEnabled: alreadyEnabled} = await helpers.getReserveConfigurationData(
|
|
||||||
tokenAddress
|
|
||||||
);
|
|
||||||
|
|
||||||
if (alreadyEnabled) {
|
|
||||||
console.log(`Reserve ${assetSymbol} is already enabled as collateral, skipping`);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
console.log(`Enabling reserve ${assetSymbol} as collateral`);
|
|
||||||
|
|
||||||
await waitForTx(
|
|
||||||
await lendingPoolConfigurator.enableReserveAsCollateral(
|
|
||||||
tokenAddress,
|
|
||||||
baseLTVAsCollateral,
|
|
||||||
liquidationThreshold,
|
|
||||||
liquidationBonus
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(
|
|
||||||
`Enabling reserve as collateral for ${assetSymbol} failed with error ${e}. Skipped.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const initReservesByHelper = async (
|
export const initReservesByHelper = async (
|
||||||
lendingPoolProxy: tEthereumAddress,
|
lendingPoolProxy: tEthereumAddress,
|
||||||
|
@ -110,16 +16,18 @@ export const initReservesByHelper = async (
|
||||||
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
||||||
helpers: AaveProtocolTestHelpers,
|
helpers: AaveProtocolTestHelpers,
|
||||||
admin: tEthereumAddress,
|
admin: tEthereumAddress,
|
||||||
incentivesController: tEthereumAddress
|
incentivesController: tEthereumAddress,
|
||||||
|
verify?: boolean
|
||||||
) => {
|
) => {
|
||||||
const stableAndVariableDeployer = await new DeployStableAndVariableTokensFactory(
|
const stableAndVariableDeployer = await deployStableAndVariableTokensHelper(
|
||||||
await getFirstSigner()
|
[lendingPoolProxy, addressesProvider],
|
||||||
).deploy(lendingPoolProxy, addressesProvider);
|
verify
|
||||||
await waitForTx(stableAndVariableDeployer.deployTransaction);
|
);
|
||||||
const atokenAndRatesDeployer = await new DeployATokensAndRatesFactory(
|
const atokenAndRatesDeployer = await deployATokensAndRatesHelper([
|
||||||
await getFirstSigner()
|
lendingPoolProxy,
|
||||||
).deploy(lendingPoolProxy, addressesProvider, lendingPoolConfigurator);
|
addressesProvider,
|
||||||
await waitForTx(atokenAndRatesDeployer.deployTransaction);
|
lendingPoolConfigurator,
|
||||||
|
]);
|
||||||
const addressProvider = await getLendingPoolAddressesProvider(addressesProvider);
|
const addressProvider = await getLendingPoolAddressesProvider(addressesProvider);
|
||||||
|
|
||||||
// Set aTokenAndRatesDeployer as temporal admin
|
// Set aTokenAndRatesDeployer as temporal admin
|
||||||
|
@ -269,121 +177,140 @@ export const getPairsTokenAggregator = (
|
||||||
return [mappedPairs, mappedAggregators];
|
return [mappedPairs, mappedAggregators];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const initReserves = async (
|
export const enableReservesToBorrowByHelper = async (
|
||||||
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
||||||
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
||||||
lendingPoolAddressesProvider: LendingPoolAddressesProvider,
|
|
||||||
lendingPool: LendingPool,
|
|
||||||
helpers: AaveProtocolTestHelpers,
|
helpers: AaveProtocolTestHelpers,
|
||||||
lendingPoolConfigurator: LendingPoolConfigurator,
|
admin: tEthereumAddress
|
||||||
aavePool: AavePools,
|
|
||||||
incentivesController: tEthereumAddress,
|
|
||||||
verify: boolean
|
|
||||||
) => {
|
) => {
|
||||||
if (aavePool !== AavePools.proto && aavePool !== AavePools.secondary) {
|
const addressProvider = await getLendingPoolAddressesProvider();
|
||||||
console.log(`Invalid Aave pool ${aavePool}`);
|
const atokenAndRatesDeployer = await getATokensAndRatesHelper();
|
||||||
process.exit(1);
|
const tokens: string[] = [];
|
||||||
}
|
const symbols: string[] = [];
|
||||||
|
const stableEnabled: boolean[] = [];
|
||||||
|
|
||||||
for (let [assetSymbol, {reserveDecimals}] of Object.entries(reservesParams) as [
|
// Prepare data
|
||||||
string,
|
for (const [assetSymbol, {borrowingEnabled, stableBorrowRateEnabled}] of Object.entries(
|
||||||
IReserveParams
|
reservesParams
|
||||||
][]) {
|
) as [string, IReserveParams][]) {
|
||||||
|
if (!borrowingEnabled) continue;
|
||||||
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
||||||
(value) => value === assetSymbol
|
(value) => value === assetSymbol
|
||||||
);
|
);
|
||||||
const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[
|
const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[
|
||||||
assetAddressIndex
|
assetAddressIndex
|
||||||
];
|
];
|
||||||
|
const {borrowingEnabled: borrowingAlreadyEnabled} = await helpers.getReserveConfigurationData(
|
||||||
|
tokenAddress
|
||||||
|
);
|
||||||
|
|
||||||
const {isActive: reserveInitialized} = await helpers.getReserveConfigurationData(tokenAddress);
|
if (borrowingAlreadyEnabled) {
|
||||||
|
console.log(`Reserve ${assetSymbol} is already enabled for borrowing, skipping`);
|
||||||
if (reserveInitialized) {
|
|
||||||
console.log(`Reserve ${assetSymbol} is already active, skipping configuration`);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
tokens.push(tokenAddress);
|
||||||
|
stableEnabled.push(stableBorrowRateEnabled);
|
||||||
|
symbols.push(assetSymbol);
|
||||||
|
}
|
||||||
|
if (tokens.length) {
|
||||||
|
// Set aTokenAndRatesDeployer as temporal admin
|
||||||
|
await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address));
|
||||||
|
|
||||||
|
// Deploy init per chunks
|
||||||
|
const stableChunks = 20;
|
||||||
|
const chunkedTokens = chunk(tokens, stableChunks);
|
||||||
|
const chunkedSymbols = chunk(symbols, stableChunks);
|
||||||
|
const chunkedStableEnabled = chunk(stableEnabled, stableChunks);
|
||||||
|
|
||||||
|
console.log(`- Borrow stable initialization in ${chunkedTokens.length} txs`);
|
||||||
|
for (let chunkIndex = 0; chunkIndex < chunkedTokens.length; chunkIndex++) {
|
||||||
try {
|
try {
|
||||||
const reserveParamIndex = Object.keys(reservesParams).findIndex(
|
await waitForTx(
|
||||||
(value) => value === assetSymbol
|
await atokenAndRatesDeployer.enableBorrowingOnReserves(
|
||||||
|
chunkedTokens[chunkIndex],
|
||||||
|
chunkedStableEnabled[chunkIndex],
|
||||||
|
{gasLimit: 12000000}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
const [
|
} catch (error) {
|
||||||
,
|
console.error(error);
|
||||||
{
|
throw error;
|
||||||
baseVariableBorrowRate,
|
|
||||||
variableRateSlope1,
|
|
||||||
variableRateSlope2,
|
|
||||||
stableRateSlope1,
|
|
||||||
stableRateSlope2,
|
|
||||||
},
|
|
||||||
] = (Object.entries(reservesParams) as [string, IReserveParams][])[reserveParamIndex];
|
|
||||||
console.log('deploy the interest rate strategy for ', assetSymbol);
|
|
||||||
const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
|
|
||||||
[
|
|
||||||
lendingPoolAddressesProvider.address,
|
|
||||||
baseVariableBorrowRate,
|
|
||||||
variableRateSlope1,
|
|
||||||
variableRateSlope2,
|
|
||||||
stableRateSlope1,
|
|
||||||
stableRateSlope2,
|
|
||||||
],
|
|
||||||
verify
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('deploy the stable debt totken for ', assetSymbol);
|
|
||||||
const stableDebtToken = await deployStableDebtToken(
|
|
||||||
[
|
|
||||||
`Aave stable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
|
||||||
`stableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
|
||||||
tokenAddress,
|
|
||||||
lendingPool.address,
|
|
||||||
incentivesController,
|
|
||||||
],
|
|
||||||
verify
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('deploy the variable debt totken for ', assetSymbol);
|
|
||||||
const variableDebtToken = await deployVariableDebtToken(
|
|
||||||
[
|
|
||||||
`Aave variable debt bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
|
||||||
`variableDebt${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
|
||||||
tokenAddress,
|
|
||||||
lendingPool.address,
|
|
||||||
incentivesController,
|
|
||||||
],
|
|
||||||
verify
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log('deploy the aToken for ', assetSymbol);
|
|
||||||
const aToken = await deployGenericAToken(
|
|
||||||
[
|
|
||||||
lendingPool.address,
|
|
||||||
tokenAddress,
|
|
||||||
`Aave interest bearing ${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
|
||||||
`a${assetSymbol === 'WETH' ? 'ETH' : assetSymbol}`,
|
|
||||||
incentivesController,
|
|
||||||
],
|
|
||||||
verify
|
|
||||||
);
|
|
||||||
|
|
||||||
if (process.env.POOL === AavePools.secondary) {
|
|
||||||
if (assetSymbol.search('UNI') === -1) {
|
|
||||||
assetSymbol = `Uni${assetSymbol}`;
|
|
||||||
} else {
|
|
||||||
assetSymbol = assetSymbol.replace(/_/g, '').replace('UNI', 'Uni');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('initialize the reserve ', assetSymbol);
|
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||||
await lendingPoolConfigurator.initReserve(
|
|
||||||
aToken.address,
|
|
||||||
stableDebtToken.address,
|
|
||||||
variableDebtToken.address,
|
|
||||||
reserveDecimals,
|
|
||||||
rateStrategyContract.address
|
|
||||||
);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(`Reserve initialization for ${assetSymbol} failed with error ${e}. Skipped.`);
|
|
||||||
}
|
}
|
||||||
|
// Set deployer back as admin
|
||||||
|
await waitForTx(await addressProvider.setAaveAdmin(admin));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const enableReservesAsCollateralByHelper = async (
|
||||||
|
reservesParams: iMultiPoolsAssets<IReserveParams>,
|
||||||
|
tokenAddresses: {[symbol: string]: tEthereumAddress},
|
||||||
|
helpers: AaveProtocolTestHelpers,
|
||||||
|
admin: tEthereumAddress
|
||||||
|
) => {
|
||||||
|
const addressProvider = await getLendingPoolAddressesProvider();
|
||||||
|
const atokenAndRatesDeployer = await getATokensAndRatesHelper();
|
||||||
|
const tokens: string[] = [];
|
||||||
|
const symbols: string[] = [];
|
||||||
|
const baseLTVA: string[] = [];
|
||||||
|
const liquidationThresholds: string[] = [];
|
||||||
|
const liquidationBonuses: string[] = [];
|
||||||
|
|
||||||
|
for (const [
|
||||||
|
assetSymbol,
|
||||||
|
{baseLTVAsCollateral, liquidationBonus, liquidationThreshold},
|
||||||
|
] of Object.entries(reservesParams) as [string, IReserveParams][]) {
|
||||||
|
if (baseLTVAsCollateral === '-1') continue;
|
||||||
|
|
||||||
|
const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
|
||||||
|
(value) => value === assetSymbol
|
||||||
|
);
|
||||||
|
const [, tokenAddress] = (Object.entries(tokenAddresses) as [string, string][])[
|
||||||
|
assetAddressIndex
|
||||||
|
];
|
||||||
|
const {usageAsCollateralEnabled: alreadyEnabled} = await helpers.getReserveConfigurationData(
|
||||||
|
tokenAddress
|
||||||
|
);
|
||||||
|
|
||||||
|
if (alreadyEnabled) {
|
||||||
|
console.log(`- Reserve ${assetSymbol} is already enabled as collateral, skipping`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Push data
|
||||||
|
tokens.push(tokenAddress);
|
||||||
|
symbols.push(assetSymbol);
|
||||||
|
baseLTVA.push(baseLTVAsCollateral);
|
||||||
|
liquidationThresholds.push(liquidationThreshold);
|
||||||
|
liquidationBonuses.push(liquidationBonus);
|
||||||
|
}
|
||||||
|
if (tokens.length) {
|
||||||
|
// Set aTokenAndRatesDeployer as temporal admin
|
||||||
|
await waitForTx(await addressProvider.setAaveAdmin(atokenAndRatesDeployer.address));
|
||||||
|
|
||||||
|
// Deploy init per chunks
|
||||||
|
const enableChunks = 20;
|
||||||
|
const chunkedTokens = chunk(tokens, enableChunks);
|
||||||
|
const chunkedSymbols = chunk(symbols, enableChunks);
|
||||||
|
const chunkedBase = chunk(baseLTVA, enableChunks);
|
||||||
|
const chunkedliquidationThresholds = chunk(liquidationThresholds, enableChunks);
|
||||||
|
const chunkedliquidationBonuses = chunk(liquidationBonuses, enableChunks);
|
||||||
|
|
||||||
|
console.log(`- Enable reserve as collateral in ${chunkedTokens.length} txs`);
|
||||||
|
for (let chunkIndex = 0; chunkIndex < chunkedTokens.length; chunkIndex++) {
|
||||||
|
await waitForTx(
|
||||||
|
await atokenAndRatesDeployer.enableReservesAsCollateral(
|
||||||
|
chunkedTokens[chunkIndex],
|
||||||
|
chunkedBase[chunkIndex],
|
||||||
|
chunkedliquidationThresholds[chunkIndex],
|
||||||
|
chunkedliquidationBonuses[chunkIndex],
|
||||||
|
{gasLimit: 12000000}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
console.log(` - Init for: ${chunkedSymbols[chunkIndex].join(', ')}`);
|
||||||
|
}
|
||||||
|
// Set deployer back as admin
|
||||||
|
await waitForTx(await addressProvider.setAaveAdmin(admin));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {PriceOracle} from '../types/PriceOracle';
|
||||||
import {MockAggregator} from '../types/MockAggregator';
|
import {MockAggregator} from '../types/MockAggregator';
|
||||||
import {deployMockAggregator} from './contracts-deployments';
|
import {deployMockAggregator} from './contracts-deployments';
|
||||||
import {waitForTx} from './misc-utils';
|
import {waitForTx} from './misc-utils';
|
||||||
import {verifyContract} from './etherscan-verification';
|
|
||||||
|
|
||||||
export const setInitialMarketRatesInRatesOracle = async (
|
export const setInitialMarketRatesInRatesOracle = async (
|
||||||
marketRates: iMultiPoolsAssets<IMarketRates>,
|
marketRates: iMultiPoolsAssets<IMarketRates>,
|
||||||
|
|
|
@ -55,6 +55,8 @@ export enum eContractid {
|
||||||
VariableDebtToken = 'VariableDebtToken',
|
VariableDebtToken = 'VariableDebtToken',
|
||||||
FeeProvider = 'FeeProvider',
|
FeeProvider = 'FeeProvider',
|
||||||
TokenDistributor = 'TokenDistributor',
|
TokenDistributor = 'TokenDistributor',
|
||||||
|
StableAndVariableTokensHelper = 'StableAndVariableTokensHelper',
|
||||||
|
ATokensAndRatesHelper = 'ATokensAndRatesHelper',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ProtocolErrors {
|
export enum ProtocolErrors {
|
||||||
|
|
|
@ -10,9 +10,8 @@ import {getReservesConfigByPool} from '../../helpers/configuration';
|
||||||
import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
|
import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types';
|
||||||
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
import {waitForTx, filterMapBy} from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
enableReservesToBorrow,
|
enableReservesToBorrowByHelper,
|
||||||
enableReservesAsCollateral,
|
enableReservesAsCollateralByHelper,
|
||||||
initReserves,
|
|
||||||
initReservesByHelper,
|
initReservesByHelper,
|
||||||
} from '../../helpers/init-helpers';
|
} from '../../helpers/init-helpers';
|
||||||
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
|
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
|
||||||
|
@ -55,19 +54,20 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
admin,
|
admin,
|
||||||
ZERO_ADDRESS
|
ZERO_ADDRESS,
|
||||||
|
verify
|
||||||
);
|
);
|
||||||
await enableReservesToBorrow(
|
await enableReservesToBorrowByHelper(
|
||||||
reservesParams,
|
reservesParams,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
lendingPoolConfiguratorProxy
|
admin
|
||||||
);
|
);
|
||||||
await enableReservesAsCollateral(
|
await enableReservesAsCollateralByHelper(
|
||||||
reservesParams,
|
reservesParams,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
lendingPoolConfiguratorProxy
|
admin
|
||||||
);
|
);
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
|
|
|
@ -6,20 +6,20 @@ import {
|
||||||
deployAaveProtocolTestHelpers,
|
deployAaveProtocolTestHelpers,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
|
import {loadPoolConfig, ConfigNames} from '../../helpers/configuration';
|
||||||
import {AavePools, eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
import {eEthereumNetwork, ICommonConfiguration} from '../../helpers/types';
|
||||||
import {waitForTx} from '../../helpers/misc-utils';
|
import {waitForTx} from '../../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
enableReservesToBorrow,
|
|
||||||
enableReservesAsCollateral,
|
|
||||||
initReservesByHelper,
|
initReservesByHelper,
|
||||||
|
enableReservesToBorrowByHelper,
|
||||||
|
enableReservesAsCollateralByHelper,
|
||||||
} from '../../helpers/init-helpers';
|
} from '../../helpers/init-helpers';
|
||||||
import {ZERO_ADDRESS} from '../../helpers/constants';
|
|
||||||
import {exit} from 'process';
|
import {exit} from 'process';
|
||||||
import {
|
import {
|
||||||
getLendingPool,
|
getLendingPool,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
} from '../../helpers/contracts-getters';
|
} from '../../helpers/contracts-getters';
|
||||||
|
import {ZERO_ADDRESS} from '../../helpers/constants';
|
||||||
|
|
||||||
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
.addFlag('verify', 'Verify contracts at Etherscan')
|
.addFlag('verify', 'Verify contracts at Etherscan')
|
||||||
|
@ -52,20 +52,11 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
reserveAssets,
|
reserveAssets,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
admin,
|
admin,
|
||||||
ZERO_ADDRESS
|
ZERO_ADDRESS,
|
||||||
);
|
verify
|
||||||
await enableReservesToBorrow(
|
|
||||||
ReservesConfig,
|
|
||||||
reserveAssets,
|
|
||||||
testHelpers,
|
|
||||||
lendingPoolConfiguratorProxy
|
|
||||||
);
|
|
||||||
await enableReservesAsCollateral(
|
|
||||||
ReservesConfig,
|
|
||||||
reserveAssets,
|
|
||||||
testHelpers,
|
|
||||||
lendingPoolConfiguratorProxy
|
|
||||||
);
|
);
|
||||||
|
await enableReservesToBorrowByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
|
await enableReservesAsCollateralByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
|
|
|
@ -32,10 +32,9 @@ import {
|
||||||
} from '../helpers/oracles-helpers';
|
} from '../helpers/oracles-helpers';
|
||||||
import {waitForTx} from '../helpers/misc-utils';
|
import {waitForTx} from '../helpers/misc-utils';
|
||||||
import {
|
import {
|
||||||
enableReservesToBorrow,
|
|
||||||
enableReservesAsCollateral,
|
|
||||||
initReserves,
|
|
||||||
initReservesByHelper,
|
initReservesByHelper,
|
||||||
|
enableReservesToBorrowByHelper,
|
||||||
|
enableReservesAsCollateralByHelper,
|
||||||
} from '../helpers/init-helpers';
|
} from '../helpers/init-helpers';
|
||||||
import {AaveConfig} from '../config/aave';
|
import {AaveConfig} from '../config/aave';
|
||||||
import {ZERO_ADDRESS} from '../helpers/constants';
|
import {ZERO_ADDRESS} from '../helpers/constants';
|
||||||
|
@ -205,6 +204,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address);
|
const testHelpers = await deployAaveProtocolTestHelpers(addressesProvider.address);
|
||||||
|
|
||||||
await insertContractAddressInDb(eContractid.AaveProtocolTestHelpers, testHelpers.address);
|
await insertContractAddressInDb(eContractid.AaveProtocolTestHelpers, testHelpers.address);
|
||||||
|
const admin = await deployer.getAddress();
|
||||||
|
|
||||||
console.log('Initialize configuration');
|
console.log('Initialize configuration');
|
||||||
await initReservesByHelper(
|
await initReservesByHelper(
|
||||||
|
@ -214,20 +214,20 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
reservesParams,
|
reservesParams,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
await deployer.getAddress(),
|
admin,
|
||||||
ZERO_ADDRESS
|
ZERO_ADDRESS
|
||||||
);
|
);
|
||||||
await enableReservesToBorrow(
|
await enableReservesToBorrowByHelper(
|
||||||
reservesParams,
|
reservesParams,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
lendingPoolConfiguratorProxy
|
admin
|
||||||
);
|
);
|
||||||
await enableReservesAsCollateral(
|
await enableReservesAsCollateralByHelper(
|
||||||
reservesParams,
|
reservesParams,
|
||||||
protoPoolReservesAddresses,
|
protoPoolReservesAddresses,
|
||||||
testHelpers,
|
testHelpers,
|
||||||
lendingPoolConfiguratorProxy
|
admin
|
||||||
);
|
);
|
||||||
|
|
||||||
const collateralManager = await deployLendingPoolCollateralManager();
|
const collateralManager = await deployLendingPoolCollateralManager();
|
||||||
|
@ -245,7 +245,6 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
console.log('aaaaa');
|
|
||||||
await rawBRE.run('set-bre');
|
await rawBRE.run('set-bre');
|
||||||
const [deployer, secondaryWallet] = await getEthersSigners();
|
const [deployer, secondaryWallet] = await getEthersSigners();
|
||||||
console.log('-> Deploying test environment...');
|
console.log('-> Deploying test environment...');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user