Fixed setup

This commit is contained in:
The3D 2020-06-26 14:34:44 +02:00
parent 9a92cb08f7
commit 51fee50e50
6 changed files with 144 additions and 44 deletions

View File

@ -5,6 +5,7 @@ import {ILendingPoolAddressesProvider} from "../interfaces/ILendingPoolAddresses
import {IERC20Detailed} from "../interfaces/IERC20Detailed.sol";
import {LendingPool} from "../lendingpool/LendingPool.sol";
import {AToken} from "../tokenization/AToken.sol";
import "@nomiclabs/buidler/console.sol";
contract AaveProtocolTestHelpers {
struct TokenData {
@ -20,7 +21,11 @@ contract AaveProtocolTestHelpers {
function getAllReservesTokens() external view returns(TokenData[] memory) {
LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool()));
console.log("Getting reserves...");
address[] memory reserves = pool.getReserves();
console.log("Reserves retrivied");
TokenData[] memory reservesTokens = new TokenData[](reserves.length);
for (uint256 i = 0; i < reserves.length; i++) {
reservesTokens[i] = TokenData({
@ -33,10 +38,15 @@ contract AaveProtocolTestHelpers {
function getAllATokens() external view returns(TokenData[] memory) {
LendingPool pool = LendingPool(payable(ADDRESSES_PROVIDER.getLendingPool()));
console.log("Getting all the tokens...");
address[] memory reserves = pool.getReserves();
console.log("Reserves retrivied");
TokenData[] memory aTokens = new TokenData[](reserves.length);
for (uint256 i = 0; i < reserves.length; i++) {
(,,,address aTokenAddress,,,,,) = pool.getReserveConfigurationData(reserves[i]);
console.log("Getting configuration for reserve %s", i);
(,,,,address aTokenAddress,,,,) = pool.getReserveConfigurationData(reserves[i]);
aTokens[i] = TokenData({
symbol: AToken(aTokenAddress).symbol(),
tokenAddress: aTokenAddress

51
data.txt Normal file

File diff suppressed because one or more lines are too long

View File

@ -44,36 +44,36 @@
},
"LendingPool": {
"buidlerevm": {
"address": "0x820ED3d0675676203514f5fd76E5Ac40c9F0c4Bd"
"address": "0xA10958a24032283FbE2D23cedf264d6eC9411CBA"
}
},
"PriceOracle": {
"buidlerevm": {
"address": "0xe1B3b8F6b298b52bCd15357ED29e65e66a4045fF",
"address": "0x8731324a6C09a1745bD15009Dc8FcceF11c05F4a",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"MockAggregator": {
"buidlerevm": {
"address": "0xD83D2773a7873ae2b5f8Fb92097e20a8C64F691E",
"address": "0x474d9b0D5F1Bb1602711F9346743a7a7478d6f52",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"ChainlinkProxyPriceProvider": {
"buidlerevm": {
"address": "0x474d9b0D5F1Bb1602711F9346743a7a7478d6f52",
"address": "0xf91aC1098F3b154671Ce83290114aaE45ac0225f",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"LendingRateOracle": {
"buidlerevm": {
"address": "0xFc01AF83D78742DfD42631a352e33f8098e7274B",
"address": "0xf4830d6b1D70C8595d3BD8A63f9ed9F636DB9ef2",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"DefaultReserveInterestRateStrategy": {
"buidlerevm": {
"address": "0x603A373A1571783bD82b708C20a5A4b019BAB78F",
"address": "0xFf130817Aa9863B3D809A2A11617c05646245d80",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
@ -85,35 +85,35 @@
},
"MockOneSplit": {
"buidlerevm": {
"address": "0xd44937448A9f229bfae84e7d256810Ba4C4a93cC",
"address": "0xe5a5a5b78F165C875EE2264a8743570176eA39d9",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"OneSplitAdapter": {
"buidlerevm": {
"address": "0x70c5a4348710Fa80eE8f2bD2eD5243d1bAB90752",
"address": "0x828C9C41Fae6113C1DEA9056Dcd9C85A19002d52",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"TokenDistributor": {
"buidlerevm": {
"address": "0xbCf57D16d9d63aDDea3c2056A1de2A33ebD353F0"
"address": "0x7d40dD74d3aE1a7e4A7dd08eaE899e85940563cd"
}
},
"InitializableAdminUpgradeabilityProxy": {
"buidlerevm": {
"address": "0xbCf57D16d9d63aDDea3c2056A1de2A33ebD353F0",
"address": "0x7d40dD74d3aE1a7e4A7dd08eaE899e85940563cd",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
"MockFlashLoanReceiver": {
"buidlerevm": {
"address": "0xe5a5a5b78F165C875EE2264a8743570176eA39d9"
"address": "0xB660Fdd109a95718cB9d20E3A89EE6cE342aDcB6"
}
},
"WalletBalanceProvider": {
"buidlerevm": {
"address": "0x828C9C41Fae6113C1DEA9056Dcd9C85A19002d52",
"address": "0x830bceA96E56DBC1F8578f75fBaC0AF16B32A07d",
"deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
}
},
@ -257,7 +257,7 @@
},
"AaveProtocolTestHelpers": {
"buidlerevm": {
"address": "0xAb35dEf6f863FC1e91dE4c20A3596b388eB1CFb4"
"address": "0xA0AB1cB92A4AF81f84dCd258155B5c25D247b54E"
}
}
}

View File

@ -145,13 +145,12 @@ const deployLibrary = async(libraryId: eContractid) => {
return library
}
export const deployLendingPool = async () => {
export const linkLibrariesToArtifact = async(artifact: Artifact) => {
const coreLibrary = await deployLibrary(eContractid.CoreLibrary);
const userLogic = await deployLibrary(eContractid.UserLogic);
const reserveLogic = await deployLibrary(eContractid.ReserveLogic);
console.log("Deployed user logic and reserve logic, addresses:", userLogic.address, reserveLogic.address)
const genericLogicArtifact = await readArtifact(
BRE.config.paths.artifacts,
eContractid.GenericLogic
@ -168,8 +167,6 @@ export const deployLendingPool = async () => {
);
const genericLogic = await (await genericLogicFactory.deploy()).deployed();
console.log("Deployed generic logic, addresses:", genericLogic.address)
const validationLogicArtifact = await readArtifact(
BRE.config.paths.artifacts,
@ -189,25 +186,33 @@ export const deployLendingPool = async () => {
const validationLogic = await (await validationLogicFactory.deploy()).deployed();
console.log("Deployed validation logic, address:", validationLogic.address)
const lendingPoolArtifact = await readArtifact(
BRE.config.paths.artifacts,
eContractid.LendingPool
);
const linkedBytecode = linkBytecode(lendingPoolArtifact, {
const linkedBytecode = linkBytecode(artifact, {
[eContractid.CoreLibrary]: coreLibrary.address,
[eContractid.UserLogic]: userLogic.address,
[eContractid.ReserveLogic] : reserveLogic.address,
[eContractid.GenericLogic] : genericLogic.address,
[eContractid.ValidationLogic] : validationLogic.address
});
const LendingPoolFactory = await BRE.ethers.getContractFactory(
lendingPoolArtifact.abi,
const factory = await BRE.ethers.getContractFactory(
artifact.abi,
linkedBytecode
);
const lendingPool = await LendingPoolFactory.deploy();
return factory;
}
export const deployLendingPool = async () => {
const lendingPoolArtifact = await readArtifact(
BRE.config.paths.artifacts,
eContractid.LendingPool
);
const factory = await linkLibrariesToArtifact(lendingPoolArtifact);
const lendingPool = await factory.deploy();
return (await lendingPool.deployed()) as LendingPool;
}
@ -232,11 +237,19 @@ export const deployChainlinkProxyPriceProvider = async ([
export const deployLendingRateOracle = async () =>
await deployContract<LendingRateOracle>(eContractid.LendingRateOracle, []);
export const deployLendingPoolLiquidationManager = async () =>
await deployContract<LendingPoolLiquidationManager>(
eContractid.LendingPoolLiquidationManager,
[]
export const deployLendingPoolLiquidationManager = async () => {
const liquidationManagerArtifact = await readArtifact(
BRE.config.paths.artifacts,
eContractid.LendingPoolLiquidationManager
);
const factory = await linkLibrariesToArtifact(liquidationManagerArtifact);
const liquidationManager = await factory.deploy();
return (await liquidationManager.deployed()) as LendingPoolLiquidationManager;
}
export const deployTokenDistributor = async () =>
await deployContract<TokenDistributor>(eContractid.TokenDistributor, []);
@ -289,7 +302,6 @@ export const deployMintableErc20 = async ([name, symbol, decimals]: [
]);
export const deployDefaultReserveInterestRateStrategy = async ([
reserve,
addressesProvider,
baseVariableBorrowRate,
variableSlope1,
@ -297,7 +309,6 @@ export const deployDefaultReserveInterestRateStrategy = async ([
stableSlope1,
stableSlope2,
]: [
tEthereumAddress,
tEthereumAddress,
string,
string,
@ -308,7 +319,6 @@ export const deployDefaultReserveInterestRateStrategy = async ([
await deployContract<DefaultReserveInterestRateStrategy>(
eContractid.DefaultReserveInterestRateStrategy,
[
reserve,
addressesProvider,
baseVariableBorrowRate,
variableSlope1,
@ -349,15 +359,23 @@ export const getLendingPoolConfiguratorProxy = async (
};
export const getLendingPool = async (address?: tEthereumAddress) => {
return await getContract<LendingPool>(
eContractid.LendingPool,
const lendingPoolArtifact = await readArtifact(
BRE.config.paths.artifacts,
eContractid.LendingPool
);
const factory = await linkLibrariesToArtifact(lendingPoolArtifact);
return <LendingPool>(await factory.attach(
address ||
(
await getDb()
.get(`${eContractid.LendingPool}.${BRE.network.name}`)
.value()
).address
);
));
};
export const getFeeProvider = async (address?: tEthereumAddress) => {

View File

@ -194,9 +194,14 @@ const initReserves = async (
string,
string
][])[assetAddressIndex];
const reserveInitialized = await lendingPool.getReserveIsActive(
console.log("Getting active flag for reserve ", tokenAddress);
const {isActive: reserveInitialized} = await lendingPool.getReserveConfigurationData(
tokenAddress
);
console.log("Result ",reserveInitialized);
if (reserveInitialized) {
console.log(
@ -223,7 +228,6 @@ const initReserves = async (
];
const rateStrategyContract = await deployDefaultReserveInterestRateStrategy(
[
tokenAddress,
lendingPoolAddressesProvider.address,
baseVariableBorrowRate,
variableRateSlope1,
@ -233,6 +237,8 @@ const initReserves = async (
]
);
console.log("Interest rate strategy deployed");
if (process.env.POOL === AavePools.secondary) {
if (assetSymbol.search("UNI") === -1) {
assetSymbol = `Uni${assetSymbol}`;
@ -275,7 +281,7 @@ const enableReservesToBorrow = async (
string,
string
][])[assetAddressIndex];
const borrowingAlreadyEnabled = await lendingPool.isReserveBorrowingEnabled(
const {borrowingEnabled: borrowingAlreadyEnabled} = await lendingPool.getReserveConfigurationData(
tokenAddress
);
@ -317,7 +323,7 @@ const enableReservesAsCollateral = async (
string,
string
][])[assetAddressIndex];
const alreadyEnabled = await lendingPool.isReserveUsageAsCollateralEnabled(
const {usageAsCollateralEnabled: alreadyEnabled} = await lendingPool.getReserveConfigurationData(
tokenAddress
);
@ -406,7 +412,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
address
);
console.log("implementation set, address:", lendingPoolProxy)
console.log("implementation set, address:", lendingPoolProxy.address)
await insertContractAddressInDb(
eContractid.LendingPool,

View File

@ -75,15 +75,30 @@ export async function initializeMakeSuite() {
}
testEnv.deployer = deployer;
testEnv.pool = await getLendingPool();
console.log("Pool loaded");
testEnv.configurator = await getLendingPoolConfiguratorProxy();
console.log("Configurator loaded");
testEnv.oracle = await getPriceOracle();
console.log("oracle loaded");
testEnv.addressesProvider = await getLendingPoolAddressesProvider();
console.log("addresses provider loaded");
testEnv.helpersContract = await getAaveProtocolTestHelpers();
console.log("helpers loaded");
const aDaiAddress = (await testEnv.helpersContract.getAllATokens()).find(
(aToken) => aToken.symbol === "aDAI"
)?.tokenAddress;
console.log("getting reserves");
const reservesTokens = await testEnv.helpersContract.getAllReservesTokens();
console.log("reserve tokens loaded");
const daiAddress = reservesTokens.find(token => token.symbol === "DAI")?.tokenAddress;
const usdcAddress = reservesTokens.find(token => token.symbol === "USDC")?.tokenAddress;
if (!aDaiAddress) {