diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 47b96e0e..5fdb704f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,6 @@ stages: - test + - deploy-mainnet-fork test: stage: test @@ -12,3 +13,14 @@ test: after_script: - docker-compose -f docker-compose.test.yml run contracts-env npm run ci:clean - docker-compose -f docker-compose.test.yml down +deploy-mainnet-fork: + stage: deploy-mainnet-fork + tags: + - aave-build-runner + before_script: + - docker-compose build + script: + - docker-compose run contracts-env npm aave:main:fork + after_script: + - docker-compose -f docker-compose.test.yml run contracts-env npm run ci:clean + - docker-compose -f docker-compose.test.yml down diff --git a/contracts/misc/WalletBalanceProvider.sol b/contracts/misc/WalletBalanceProvider.sol index c3f5dd7f..e0db2522 100644 --- a/contracts/misc/WalletBalanceProvider.sol +++ b/contracts/misc/WalletBalanceProvider.sol @@ -24,13 +24,8 @@ contract WalletBalanceProvider { using SafeERC20 for IERC20; using ReserveConfiguration for ReserveConfiguration.Map; - ILendingPoolAddressesProvider internal immutable _provider; address constant MOCK_ETH_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE; - constructor(ILendingPoolAddressesProvider provider) public { - _provider = provider; - } - /** @dev Fallback function, don't accept any ETH **/ @@ -80,12 +75,12 @@ contract WalletBalanceProvider { /** @dev provides balances of user wallet for all reserves available on the pool */ - function getUserWalletBalances(address user) + function getUserWalletBalances(address provider, address user) external view returns (address[] memory, uint256[] memory) { - ILendingPool pool = ILendingPool(_provider.getLendingPool()); + ILendingPool pool = ILendingPool(ILendingPoolAddressesProvider(provider).getLendingPool()); address[] memory reserves = pool.getReservesList(); address[] memory reservesWithEth = new address[](reserves.length + 1); diff --git a/helpers/contracts-deployments.ts b/helpers/contracts-deployments.ts index 4ca6cede..c9dc2367 100644 --- a/helpers/contracts-deployments.ts +++ b/helpers/contracts-deployments.ts @@ -244,14 +244,11 @@ export const deployMockFlashLoanReceiver = async ( verify ); -export const deployWalletBalancerProvider = async ( - addressesProvider: tEthereumAddress, - verify?: boolean -) => +export const deployWalletBalancerProvider = async (verify?: boolean) => withSaveAndVerify( - await new WalletBalanceProviderFactory(await getFirstSigner()).deploy(addressesProvider), + await new WalletBalanceProviderFactory(await getFirstSigner()).deploy(), eContractid.WalletBalanceProvider, - [addressesProvider], + [], verify ); @@ -288,7 +285,7 @@ export const deployMintableDelegationERC20 = async ( verify ); export const deployDefaultReserveInterestRateStrategy = async ( - args: [tEthereumAddress, string, string, string, string, string], + args: [tEthereumAddress, string, string, string, string, string, string], verify: boolean ) => withSaveAndVerify( diff --git a/tasks/dev/5_initialize.ts b/tasks/dev/5_initialize.ts index 11d25729..3fca4332 100644 --- a/tasks/dev/5_initialize.ts +++ b/tasks/dev/5_initialize.ts @@ -1,4 +1,4 @@ -import {task} from 'hardhat/config'; +import { task } from 'hardhat/config'; import { deployLendingPoolCollateralManager, deployMockFlashLoanReceiver, @@ -13,22 +13,25 @@ import { loadPoolConfig, } from '../../helpers/configuration'; -import {tEthereumAddress, AavePools, eContractid} from '../../helpers/types'; -import {waitForTx, filterMapBy} from '../../helpers/misc-utils'; +import { tEthereumAddress, AavePools, eContractid } from '../../helpers/types'; +import { waitForTx, filterMapBy } from '../../helpers/misc-utils'; import { enableReservesToBorrowByHelper, enableReservesAsCollateralByHelper, initReservesByHelper, } from '../../helpers/init-helpers'; -import {getAllTokenAddresses} from '../../helpers/mock-helpers'; -import {ZERO_ADDRESS} from '../../helpers/constants'; -import {getAllMockedTokens, getLendingPoolAddressesProvider} from '../../helpers/contracts-getters'; -import {insertContractAddressInDb} from '../../helpers/contracts-helpers'; +import { getAllTokenAddresses } from '../../helpers/mock-helpers'; +import { ZERO_ADDRESS } from '../../helpers/constants'; +import { + getAllMockedTokens, + getLendingPoolAddressesProvider, +} from '../../helpers/contracts-getters'; +import { insertContractAddressInDb } from '../../helpers/contracts-helpers'; task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') .addFlag('verify', 'Verify contracts at Etherscan') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) - .setAction(async ({verify, pool}, localBRE) => { + .setAction(async ({ verify, pool }, localBRE) => { await localBRE.run('set-DRE'); const poolConfig = loadPoolConfig(pool); @@ -37,7 +40,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') const addressesProvider = await getLendingPoolAddressesProvider(); - const protoPoolReservesAddresses = <{[symbol: string]: tEthereumAddress}>( + const protoPoolReservesAddresses = <{ [symbol: string]: tEthereumAddress }>( filterMapBy(allTokenAddresses, (key: string) => !key.includes('UNI_')) ); @@ -75,7 +78,7 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.') mockFlashLoanReceiver.address ); - await deployWalletBalancerProvider(addressesProvider.address, verify); + await deployWalletBalancerProvider(verify); await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address); diff --git a/tasks/dev/6_wallet_balance_provider.ts b/tasks/dev/6_wallet_balance_provider.ts index be7f6419..1b444598 100644 --- a/tasks/dev/6_wallet_balance_provider.ts +++ b/tasks/dev/6_wallet_balance_provider.ts @@ -1,13 +1,12 @@ -import {task} from 'hardhat/config'; -import {deployWalletBalancerProvider} from '../../helpers/contracts-deployments'; +import { task } from 'hardhat/config'; +import { deployWalletBalancerProvider } from '../../helpers/contracts-deployments'; -import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters'; +import { getLendingPoolAddressesProvider } from '../../helpers/contracts-getters'; task('dev:wallet-balance-provider', 'Initialize lending pool configuration.') .addFlag('verify', 'Verify contracts at Etherscan') - .setAction(async ({verify}, localBRE) => { + .setAction(async ({ verify }, localBRE) => { await localBRE.run('set-DRE'); - const addressesProvider = await getLendingPoolAddressesProvider(); - await deployWalletBalancerProvider(addressesProvider.address, verify); + await deployWalletBalancerProvider(verify); }); diff --git a/tasks/full/7_data-provider.ts b/tasks/full/4_data-provider.ts similarity index 58% rename from tasks/full/7_data-provider.ts rename to tasks/full/4_data-provider.ts index 4f0954a5..af03779f 100644 --- a/tasks/full/7_data-provider.ts +++ b/tasks/full/4_data-provider.ts @@ -1,11 +1,11 @@ -import {task} from 'hardhat/config'; -import {deployAaveProtocolDataProvider} from '../../helpers/contracts-deployments'; -import {exit} from 'process'; -import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters'; +import { task } from 'hardhat/config'; +import { deployAaveProtocolDataProvider } from '../../helpers/contracts-deployments'; +import { exit } from 'process'; +import { getLendingPoolAddressesProvider } from '../../helpers/contracts-getters'; task('full:data-provider', 'Initialize lending pool configuration.') .addFlag('verify', 'Verify contracts at Etherscan') - .setAction(async ({verify}, localBRE) => { + .setAction(async ({ verify }, localBRE) => { try { await localBRE.run('set-DRE'); diff --git a/tasks/full/5_initialize.ts b/tasks/full/5_initialize.ts index 99b55f15..a377d0ca 100644 --- a/tasks/full/5_initialize.ts +++ b/tasks/full/5_initialize.ts @@ -1,38 +1,41 @@ -import {task} from 'hardhat/config'; -import {getParamPerNetwork} from '../../helpers/contracts-helpers'; +import { task } from 'hardhat/config'; +import { getParamPerNetwork } from '../../helpers/contracts-helpers'; import { deployLendingPoolCollateralManager, deployWalletBalancerProvider, deployAaveProtocolDataProvider, deployWETHGateway, } from '../../helpers/contracts-deployments'; -import {loadPoolConfig, ConfigNames, getWethAddress} from '../../helpers/configuration'; -import {eEthereumNetwork, ICommonConfiguration} from '../../helpers/types'; -import {waitForTx} from '../../helpers/misc-utils'; +import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration'; +import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types'; +import { waitForTx } from '../../helpers/misc-utils'; import { initReservesByHelper, enableReservesToBorrowByHelper, enableReservesAsCollateralByHelper, } from '../../helpers/init-helpers'; -import {exit} from 'process'; -import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters'; -import {ZERO_ADDRESS} from '../../helpers/constants'; +import { exit } from 'process'; +import { + getAaveProtocolDataProvider, + getLendingPoolAddressesProvider, +} from '../../helpers/contracts-getters'; +import { ZERO_ADDRESS } from '../../helpers/constants'; task('full:initialize-lending-pool', 'Initialize lending pool configuration.') .addFlag('verify', 'Verify contracts at Etherscan') .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`) - .setAction(async ({verify, pool}, localBRE) => { + .setAction(async ({ verify, pool }, localBRE) => { try { await localBRE.run('set-DRE'); const network = localBRE.network.name; const poolConfig = loadPoolConfig(pool); - const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration; + const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration; const reserveAssets = await getParamPerNetwork(ReserveAssets, network); const addressesProvider = await getLendingPoolAddressesProvider(); - const testHelpers = await deployAaveProtocolDataProvider(addressesProvider.address, verify); + const testHelpers = await getAaveProtocolDataProvider(); const admin = await addressesProvider.getPoolAdmin(); if (!reserveAssets) { @@ -48,7 +51,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.') await addressesProvider.setLendingPoolCollateralManager(collateralManager.address) ); - await deployWalletBalancerProvider(addressesProvider.address, verify); + await deployWalletBalancerProvider(verify); const wethAddress = await getWethAddress(poolConfig); const lendingPoolAddress = await addressesProvider.getLendingPool(); diff --git a/test/__setup.spec.ts b/test/__setup.spec.ts index c6d605e4..04bf3636 100644 --- a/test/__setup.spec.ts +++ b/test/__setup.spec.ts @@ -226,7 +226,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => { const mockFlashLoanReceiver = await deployMockFlashLoanReceiver(addressesProvider.address); await insertContractAddressInDb(eContractid.MockFlashLoanReceiver, mockFlashLoanReceiver.address); - await deployWalletBalancerProvider(addressesProvider.address); + await deployWalletBalancerProvider(); await deployWETHGateway([mockTokens.WETH.address, lendingPoolAddress]);