mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Merge branch 'master' into paraswap
This commit is contained in:
		
						commit
						258a9be607
					
				
							
								
								
									
										51
									
								
								.github/workflows/node.js.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								.github/workflows/node.js.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,51 @@
 | 
			
		|||
name: Build
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  push:
 | 
			
		||||
    branches: [master]
 | 
			
		||||
  pull_request:
 | 
			
		||||
    branches: [master]
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
 | 
			
		||||
    strategy:
 | 
			
		||||
      matrix:
 | 
			
		||||
        node-version: [14.x]
 | 
			
		||||
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v2
 | 
			
		||||
      - name: Use Node.js ${{ matrix.node-version }}
 | 
			
		||||
        uses: actions/setup-node@v2
 | 
			
		||||
        with:
 | 
			
		||||
          node-version: ${{ matrix.node-version }}
 | 
			
		||||
      - uses: actions/cache@v2
 | 
			
		||||
        with:
 | 
			
		||||
          path: ~/.npm
 | 
			
		||||
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
			
		||||
          restore-keys: |
 | 
			
		||||
            ${{ runner.os }}-node-
 | 
			
		||||
      - name: Install dependencies
 | 
			
		||||
        run: npm ci
 | 
			
		||||
      - name: Test
 | 
			
		||||
        run: npm run ci:test
 | 
			
		||||
      - name: Dev deployment
 | 
			
		||||
        run: npm run aave:evm:dev:migration
 | 
			
		||||
      - name: Mainnet deployment at Mainnet fork
 | 
			
		||||
        run: npm run aave:fork:main
 | 
			
		||||
        env:
 | 
			
		||||
          ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
 | 
			
		||||
      - name: Amm deployment at Mainnet fork
 | 
			
		||||
        run: npm run amm:fork:main
 | 
			
		||||
        env:
 | 
			
		||||
          ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
 | 
			
		||||
      - name: Aave deployment at Kovan fork
 | 
			
		||||
        run: npm run aave:fork:kovan
 | 
			
		||||
        env:
 | 
			
		||||
          ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
 | 
			
		||||
      # - name: Coverage
 | 
			
		||||
      #   run: npm run coverage
 | 
			
		||||
      # - uses: codecov/codecov-action@v1
 | 
			
		||||
      #   with:
 | 
			
		||||
      #     fail_ci_if_error: true
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +1,5 @@
 | 
			
		|||
[](https://www.gnu.org/licenses/agpl-3.0)
 | 
			
		||||
[](https://github.com/aave/protocol-v2/actions/workflows/node.js.yml)
 | 
			
		||||
```
 | 
			
		||||
        .///.                .///.     //.            .//  `/////////////-
 | 
			
		||||
       `++:++`              .++:++`    :++`          `++:  `++:......---.`
 | 
			
		||||
| 
						 | 
				
			
			@ -53,8 +55,8 @@ import {ILendingPool} from "@aave/protocol-v2/contracts/interfaces/ILendingPool.
 | 
			
		|||
 | 
			
		||||
contract Misc {
 | 
			
		||||
 | 
			
		||||
  function deposit(address pool, address token, address user, uint256 amount) {
 | 
			
		||||
    ILendingPool(pool).deposit(token, amount, user, '0');
 | 
			
		||||
  function deposit(address pool, address token, address user, uint256 amount) public {
 | 
			
		||||
    ILendingPool(pool).deposit(token, amount, user, 0);
 | 
			
		||||
    {...}
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -32,6 +32,7 @@ contract ATokensAndRatesHelper is Ownable {
 | 
			
		|||
    uint256 liquidationBonus;
 | 
			
		||||
    uint256 reserveFactor;
 | 
			
		||||
    bool stableBorrowingEnabled;
 | 
			
		||||
    bool borrowingEnabled;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  constructor(
 | 
			
		||||
| 
						 | 
				
			
			@ -73,10 +74,12 @@ contract ATokensAndRatesHelper is Ownable {
 | 
			
		|||
        inputParams[i].liquidationBonus
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      configurator.enableBorrowingOnReserve(
 | 
			
		||||
        inputParams[i].asset,
 | 
			
		||||
        inputParams[i].stableBorrowingEnabled
 | 
			
		||||
      );
 | 
			
		||||
      if (inputParams[i].borrowingEnabled) {
 | 
			
		||||
        configurator.enableBorrowingOnReserve(
 | 
			
		||||
          inputParams[i].asset,
 | 
			
		||||
          inputParams[i].stableBorrowingEnabled
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
      configurator.setReserveFactor(inputParams[i].asset, inputParams[i].reserveFactor);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -99,4 +99,9 @@ interface IAToken is IERC20, IScaledBalanceToken, IInitializableAToken {
 | 
			
		|||
   * @dev Returns the address of the incentives controller contract
 | 
			
		||||
   **/
 | 
			
		||||
  function getIncentivesController() external view returns (IAaveIncentivesController);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)
 | 
			
		||||
   **/
 | 
			
		||||
  function UNDERLYING_ASSET_ADDRESS() external view returns (address);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,9 +3,126 @@ pragma solidity 0.6.12;
 | 
			
		|||
pragma experimental ABIEncoderV2;
 | 
			
		||||
 | 
			
		||||
interface IAaveIncentivesController {
 | 
			
		||||
  event RewardsAccrued(address indexed user, uint256 amount);
 | 
			
		||||
 | 
			
		||||
  event RewardsClaimed(address indexed user, address indexed to, uint256 amount);
 | 
			
		||||
 | 
			
		||||
  event RewardsClaimed(
 | 
			
		||||
    address indexed user,
 | 
			
		||||
    address indexed to,
 | 
			
		||||
    address indexed claimer,
 | 
			
		||||
    uint256 amount
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  event ClaimerSet(address indexed user, address indexed claimer);
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
   * @dev Returns the configuration of the distribution for a certain asset
 | 
			
		||||
   * @param asset The address of the reference asset of the distribution
 | 
			
		||||
   * @return The asset index, the emission per second and the last updated timestamp
 | 
			
		||||
   **/
 | 
			
		||||
  function getAssetData(address asset)
 | 
			
		||||
    external
 | 
			
		||||
    view
 | 
			
		||||
    returns (
 | 
			
		||||
      uint256,
 | 
			
		||||
      uint256,
 | 
			
		||||
      uint256
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Whitelists an address to claim the rewards on behalf of another address
 | 
			
		||||
   * @param user The address of the user
 | 
			
		||||
   * @param claimer The address of the claimer
 | 
			
		||||
   */
 | 
			
		||||
  function setClaimer(address user, address claimer) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Returns the whitelisted claimer for a certain address (0x0 if not set)
 | 
			
		||||
   * @param user The address of the user
 | 
			
		||||
   * @return The claimer address
 | 
			
		||||
   */
 | 
			
		||||
  function getClaimer(address user) external view returns (address);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Configure assets for a certain rewards emission
 | 
			
		||||
   * @param assets The assets to incentivize
 | 
			
		||||
   * @param emissionsPerSecond The emission for each asset
 | 
			
		||||
   */
 | 
			
		||||
  function configureAssets(address[] calldata assets, uint256[] calldata emissionsPerSecond)
 | 
			
		||||
    external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Called by the corresponding asset on any update that affects the rewards distribution
 | 
			
		||||
   * @param asset The address of the user
 | 
			
		||||
   * @param userBalance The balance of the user of the asset in the lending pool
 | 
			
		||||
   * @param totalSupply The total supply of the asset in the lending pool
 | 
			
		||||
   **/
 | 
			
		||||
  function handleAction(
 | 
			
		||||
    address user,
 | 
			
		||||
    address asset,
 | 
			
		||||
    uint256 userBalance,
 | 
			
		||||
    uint256 totalSupply
 | 
			
		||||
  ) external;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Returns the total of rewards of an user, already accrued + not yet accrued
 | 
			
		||||
   * @param user The address of the user
 | 
			
		||||
   * @return The rewards
 | 
			
		||||
   **/
 | 
			
		||||
  function getRewardsBalance(address[] calldata assets, address user)
 | 
			
		||||
    external
 | 
			
		||||
    view
 | 
			
		||||
    returns (uint256);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Claims reward for an user, on all the assets of the lending pool, accumulating the pending rewards
 | 
			
		||||
   * @param amount Amount of rewards to claim
 | 
			
		||||
   * @param to Address that will be receiving the rewards
 | 
			
		||||
   * @return Rewards claimed
 | 
			
		||||
   **/
 | 
			
		||||
  function claimRewards(
 | 
			
		||||
    address[] calldata assets,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    address to
 | 
			
		||||
  ) external returns (uint256);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Claims reward for an user on behalf, on all the assets of the lending pool, accumulating the pending rewards. The caller must
 | 
			
		||||
   * be whitelisted via "allowClaimOnBehalf" function by the RewardsAdmin role manager
 | 
			
		||||
   * @param amount Amount of rewards to claim
 | 
			
		||||
   * @param user Address to check and claim rewards
 | 
			
		||||
   * @param to Address that will be receiving the rewards
 | 
			
		||||
   * @return Rewards claimed
 | 
			
		||||
   **/
 | 
			
		||||
  function claimRewardsOnBehalf(
 | 
			
		||||
    address[] calldata assets,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    address user,
 | 
			
		||||
    address to
 | 
			
		||||
  ) external returns (uint256);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev returns the unclaimed rewards of the user
 | 
			
		||||
   * @param user the address of the user
 | 
			
		||||
   * @return the unclaimed user rewards
 | 
			
		||||
   */
 | 
			
		||||
  function getUserUnclaimedRewards(address user) external view returns (uint256);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev returns the unclaimed rewards of the user
 | 
			
		||||
   * @param user the address of the user
 | 
			
		||||
   * @param asset The asset to incentivize
 | 
			
		||||
   * @return the user index for the asset
 | 
			
		||||
   */
 | 
			
		||||
  function getUserAssetData(address user, address asset) external view returns (uint256);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev for backward compatibility with previous implementation of the Incentives controller
 | 
			
		||||
   */
 | 
			
		||||
  function REWARD_TOKEN() external view returns (address);
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev for backward compatibility with previous implementation of the Incentives controller
 | 
			
		||||
   */
 | 
			
		||||
  function PRECISION() external view returns (uint8);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ pragma experimental ABIEncoderV2;
 | 
			
		|||
 | 
			
		||||
import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol';
 | 
			
		||||
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
 | 
			
		||||
import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol';
 | 
			
		||||
import {IUiPoolDataProvider} from './interfaces/IUiPoolDataProvider.sol';
 | 
			
		||||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
 | 
			
		||||
import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol';
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +25,13 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
 | 
			
		|||
  using UserConfiguration for DataTypes.UserConfigurationMap;
 | 
			
		||||
 | 
			
		||||
  address public constant MOCK_USD_ADDRESS = 0x10F7Fc1F91Ba351f9C629c5947AD69bD03C05b96;
 | 
			
		||||
  IAaveIncentivesController public immutable incentivesController;
 | 
			
		||||
  IPriceOracleGetter public immutable oracle;
 | 
			
		||||
 | 
			
		||||
  constructor(IAaveIncentivesController _incentivesController, IPriceOracleGetter _oracle) public {
 | 
			
		||||
    incentivesController = _incentivesController;
 | 
			
		||||
    oracle = _oracle;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function getInterestRateStrategySlopes(DefaultReserveInterestRateStrategy interestRateStrategy)
 | 
			
		||||
    internal
 | 
			
		||||
| 
						 | 
				
			
			@ -50,11 +58,11 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
 | 
			
		|||
    returns (
 | 
			
		||||
      AggregatedReserveData[] memory,
 | 
			
		||||
      UserReserveData[] memory,
 | 
			
		||||
      uint256,
 | 
			
		||||
      uint256
 | 
			
		||||
    )
 | 
			
		||||
  {
 | 
			
		||||
    ILendingPool lendingPool = ILendingPool(provider.getLendingPool());
 | 
			
		||||
    IPriceOracleGetter oracle = IPriceOracleGetter(provider.getPriceOracle());
 | 
			
		||||
    address[] memory reserves = lendingPool.getReservesList();
 | 
			
		||||
    DataTypes.UserConfigurationMap memory userConfig = lendingPool.getUserConfiguration(user);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -122,7 +130,43 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
 | 
			
		|||
        DefaultReserveInterestRateStrategy(reserveData.interestRateStrategyAddress)
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // incentives
 | 
			
		||||
      if (address(0) != address(incentivesController)) {
 | 
			
		||||
        (
 | 
			
		||||
          reserveData.aEmissionPerSecond,
 | 
			
		||||
          reserveData.aIncentivesLastUpdateTimestamp,
 | 
			
		||||
          reserveData.aTokenIncentivesIndex
 | 
			
		||||
        ) = incentivesController.getAssetData(reserveData.aTokenAddress);
 | 
			
		||||
 | 
			
		||||
        (
 | 
			
		||||
          reserveData.sEmissionPerSecond,
 | 
			
		||||
          reserveData.sIncentivesLastUpdateTimestamp,
 | 
			
		||||
          reserveData.sTokenIncentivesIndex
 | 
			
		||||
        ) = incentivesController.getAssetData(reserveData.stableDebtTokenAddress);
 | 
			
		||||
 | 
			
		||||
        (
 | 
			
		||||
          reserveData.vEmissionPerSecond,
 | 
			
		||||
          reserveData.vIncentivesLastUpdateTimestamp,
 | 
			
		||||
          reserveData.vTokenIncentivesIndex
 | 
			
		||||
        ) = incentivesController.getAssetData(reserveData.variableDebtTokenAddress);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (user != address(0)) {
 | 
			
		||||
        // incentives
 | 
			
		||||
        if (address(0) != address(incentivesController)) {
 | 
			
		||||
          userReservesData[i].aTokenincentivesUserIndex = incentivesController.getUserAssetData(
 | 
			
		||||
            user,
 | 
			
		||||
            reserveData.aTokenAddress
 | 
			
		||||
          );
 | 
			
		||||
          userReservesData[i].vTokenincentivesUserIndex = incentivesController.getUserAssetData(
 | 
			
		||||
            user,
 | 
			
		||||
            reserveData.variableDebtTokenAddress
 | 
			
		||||
          );
 | 
			
		||||
          userReservesData[i].sTokenincentivesUserIndex = incentivesController.getUserAssetData(
 | 
			
		||||
            user,
 | 
			
		||||
            reserveData.stableDebtTokenAddress
 | 
			
		||||
          );
 | 
			
		||||
        }
 | 
			
		||||
        // user reserve data
 | 
			
		||||
        userReservesData[i].underlyingAsset = reserveData.underlyingAsset;
 | 
			
		||||
        userReservesData[i].scaledATokenBalance = IAToken(reserveData.aTokenAddress)
 | 
			
		||||
| 
						 | 
				
			
			@ -155,6 +199,12 @@ contract UiPoolDataProvider is IUiPoolDataProvider {
 | 
			
		|||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    return (reservesData, userReservesData, oracle.getAssetPrice(MOCK_USD_ADDRESS));
 | 
			
		||||
 | 
			
		||||
    return (
 | 
			
		||||
      reservesData,
 | 
			
		||||
      userReservesData,
 | 
			
		||||
      oracle.getAssetPrice(MOCK_USD_ADDRESS),
 | 
			
		||||
      incentivesController.getUserUnclaimedRewards(user)
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ pragma solidity 0.6.12;
 | 
			
		|||
pragma experimental ABIEncoderV2;
 | 
			
		||||
 | 
			
		||||
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
 | 
			
		||||
import {IAaveIncentivesController} from '../../interfaces/IAaveIncentivesController.sol';
 | 
			
		||||
 | 
			
		||||
interface IUiPoolDataProvider {
 | 
			
		||||
  struct AggregatedReserveData {
 | 
			
		||||
| 
						 | 
				
			
			@ -41,12 +42,17 @@ interface IUiPoolDataProvider {
 | 
			
		|||
    uint256 variableRateSlope2;
 | 
			
		||||
    uint256 stableRateSlope1;
 | 
			
		||||
    uint256 stableRateSlope2;
 | 
			
		||||
    // incentives
 | 
			
		||||
    uint256 aEmissionPerSecond;
 | 
			
		||||
    uint256 vEmissionPerSecond;
 | 
			
		||||
    uint256 sEmissionPerSecond;
 | 
			
		||||
    uint256 aIncentivesLastUpdateTimestamp;
 | 
			
		||||
    uint256 vIncentivesLastUpdateTimestamp;
 | 
			
		||||
    uint256 sIncentivesLastUpdateTimestamp;
 | 
			
		||||
    uint256 aTokenIncentivesIndex;
 | 
			
		||||
    uint256 vTokenIncentivesIndex;
 | 
			
		||||
    uint256 sTokenIncentivesIndex;
 | 
			
		||||
  }
 | 
			
		||||
  //
 | 
			
		||||
  //  struct ReserveData {
 | 
			
		||||
  //    uint256 averageStableBorrowRate;
 | 
			
		||||
  //    uint256 totalLiquidity;
 | 
			
		||||
  //  }
 | 
			
		||||
 | 
			
		||||
  struct UserReserveData {
 | 
			
		||||
    address underlyingAsset;
 | 
			
		||||
| 
						 | 
				
			
			@ -56,38 +62,19 @@ interface IUiPoolDataProvider {
 | 
			
		|||
    uint256 scaledVariableDebt;
 | 
			
		||||
    uint256 principalStableDebt;
 | 
			
		||||
    uint256 stableBorrowLastUpdateTimestamp;
 | 
			
		||||
    // incentives
 | 
			
		||||
    uint256 aTokenincentivesUserIndex;
 | 
			
		||||
    uint256 vTokenincentivesUserIndex;
 | 
			
		||||
    uint256 sTokenincentivesUserIndex;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //
 | 
			
		||||
  //  struct ATokenSupplyData {
 | 
			
		||||
  //    string name;
 | 
			
		||||
  //    string symbol;
 | 
			
		||||
  //    uint8 decimals;
 | 
			
		||||
  //    uint256 totalSupply;
 | 
			
		||||
  //    address aTokenAddress;
 | 
			
		||||
  //  }
 | 
			
		||||
 | 
			
		||||
  function getReservesData(ILendingPoolAddressesProvider provider, address user)
 | 
			
		||||
    external
 | 
			
		||||
    view
 | 
			
		||||
    returns (
 | 
			
		||||
      AggregatedReserveData[] memory,
 | 
			
		||||
      UserReserveData[] memory,
 | 
			
		||||
      uint256,
 | 
			
		||||
      uint256
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
  //  function getUserReservesData(ILendingPoolAddressesProvider provider, address user)
 | 
			
		||||
  //    external
 | 
			
		||||
  //    view
 | 
			
		||||
  //    returns (UserReserveData[] memory);
 | 
			
		||||
  //
 | 
			
		||||
  //  function getAllATokenSupply(ILendingPoolAddressesProvider provider)
 | 
			
		||||
  //    external
 | 
			
		||||
  //    view
 | 
			
		||||
  //    returns (ATokenSupplyData[] memory);
 | 
			
		||||
  //
 | 
			
		||||
  //  function getATokenSupply(address[] calldata aTokens)
 | 
			
		||||
  //    external
 | 
			
		||||
  //    view
 | 
			
		||||
  //    returns (ATokenSupplyData[] memory);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,6 @@ import {PercentageMath} from '../libraries/math/PercentageMath.sol';
 | 
			
		|||
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
 | 
			
		||||
import {ILendingRateOracle} from '../../interfaces/ILendingRateOracle.sol';
 | 
			
		||||
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
 | 
			
		||||
import 'hardhat/console.sol';
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @title DefaultReserveInterestRateStrategy contract
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -273,7 +273,7 @@ contract AToken is
 | 
			
		|||
  /**
 | 
			
		||||
   * @dev Returns the address of the underlying asset of this aToken (E.g. WETH for aWETH)
 | 
			
		||||
   **/
 | 
			
		||||
  function UNDERLYING_ASSET_ADDRESS() public view returns (address) {
 | 
			
		||||
  function UNDERLYING_ASSET_ADDRESS() public override view returns (address) {
 | 
			
		||||
    return _underlyingAsset;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -21,3 +21,5 @@ services:
 | 
			
		|||
      ALCHEMY_KEY: ${ALCHEMY_KEY}
 | 
			
		||||
      TENDERLY_FORK_ID: ${TENDERLY_FORK_ID}
 | 
			
		||||
      TENDERLY_HEAD_ID: ${TENDERLY_HEAD_ID}
 | 
			
		||||
      DEFENDER_API_KEY: ${DEFENDER_API_KEY}
 | 
			
		||||
      DEFENDER_SECRET_KEY: ${DEFENDER_SECRET_KEY}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,7 +5,12 @@ import { HardhatUserConfig } from 'hardhat/types';
 | 
			
		|||
import { accounts } from './test-wallets.js';
 | 
			
		||||
import { eEthereumNetwork, eNetwork, ePolygonNetwork, eXDaiNetwork } from './helpers/types';
 | 
			
		||||
import { BUIDLEREVM_CHAINID, COVERAGE_CHAINID } from './helpers/buidler-constants';
 | 
			
		||||
import { NETWORKS_RPC_URL, NETWORKS_DEFAULT_GAS } from './helper-hardhat-config';
 | 
			
		||||
import {
 | 
			
		||||
  NETWORKS_RPC_URL,
 | 
			
		||||
  NETWORKS_DEFAULT_GAS,
 | 
			
		||||
  BLOCK_TO_FORK,
 | 
			
		||||
  buildForkConfig,
 | 
			
		||||
} from './helper-hardhat-config';
 | 
			
		||||
 | 
			
		||||
require('dotenv').config();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +20,8 @@ import 'temp-hardhat-etherscan';
 | 
			
		|||
import 'hardhat-gas-reporter';
 | 
			
		||||
import 'hardhat-typechain';
 | 
			
		||||
import '@tenderly/hardhat-tenderly';
 | 
			
		||||
import 'solidity-coverage';
 | 
			
		||||
import { fork } from 'child_process';
 | 
			
		||||
 | 
			
		||||
const SKIP_LOAD = process.env.SKIP_LOAD === 'true';
 | 
			
		||||
const DEFAULT_BLOCK_GAS_LIMIT = 12450000;
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +30,6 @@ const HARDFORK = 'istanbul';
 | 
			
		|||
const ETHERSCAN_KEY = process.env.ETHERSCAN_KEY || '';
 | 
			
		||||
const MNEMONIC_PATH = "m/44'/60'/0'/0";
 | 
			
		||||
const MNEMONIC = process.env.MNEMONIC || '';
 | 
			
		||||
const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
 | 
			
		||||
 | 
			
		||||
// Prevent to load scripts before compilation and typechain
 | 
			
		||||
if (!SKIP_LOAD) {
 | 
			
		||||
| 
						 | 
				
			
			@ -56,12 +62,7 @@ const getCommonNetworkConfig = (networkName: eNetwork, networkId: number) => ({
 | 
			
		|||
  },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const mainnetFork = MAINNET_FORK
 | 
			
		||||
  ? {
 | 
			
		||||
      blockNumber: 12012081,
 | 
			
		||||
      url: NETWORKS_RPC_URL['main'],
 | 
			
		||||
    }
 | 
			
		||||
  : undefined;
 | 
			
		||||
let forkMode;
 | 
			
		||||
 | 
			
		||||
const buidlerConfig: HardhatUserConfig = {
 | 
			
		||||
  solidity: {
 | 
			
		||||
| 
						 | 
				
			
			@ -99,7 +100,7 @@ const buidlerConfig: HardhatUserConfig = {
 | 
			
		|||
    mumbai: getCommonNetworkConfig(ePolygonNetwork.mumbai, 80001),
 | 
			
		||||
    xdai: getCommonNetworkConfig(eXDaiNetwork.xdai, 100),
 | 
			
		||||
    hardhat: {
 | 
			
		||||
      hardfork: 'istanbul',
 | 
			
		||||
      hardfork: 'berlin',
 | 
			
		||||
      blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
 | 
			
		||||
      gas: DEFAULT_BLOCK_GAS_LIMIT,
 | 
			
		||||
      gasPrice: 8000000000,
 | 
			
		||||
| 
						 | 
				
			
			@ -110,10 +111,10 @@ const buidlerConfig: HardhatUserConfig = {
 | 
			
		|||
        privateKey: secretKey,
 | 
			
		||||
        balance,
 | 
			
		||||
      })),
 | 
			
		||||
      forking: mainnetFork,
 | 
			
		||||
      forking: buildForkConfig(),
 | 
			
		||||
    },
 | 
			
		||||
    buidlerevm_docker: {
 | 
			
		||||
      hardfork: 'istanbul',
 | 
			
		||||
      hardfork: 'berlin',
 | 
			
		||||
      blockGasLimit: 9500000,
 | 
			
		||||
      gas: 9500000,
 | 
			
		||||
      gasPrice: 8000000000,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,5 @@
 | 
			
		|||
// @ts-ignore
 | 
			
		||||
import { HardhatNetworkForkingUserConfig, HardhatUserConfig } from 'hardhat/types';
 | 
			
		||||
import {
 | 
			
		||||
  eEthereumNetwork,
 | 
			
		||||
  ePolygonNetwork,
 | 
			
		||||
| 
						 | 
				
			
			@ -11,9 +12,26 @@ require('dotenv').config();
 | 
			
		|||
const INFURA_KEY = process.env.INFURA_KEY || '';
 | 
			
		||||
const ALCHEMY_KEY = process.env.ALCHEMY_KEY || '';
 | 
			
		||||
const TENDERLY_FORK_ID = process.env.TENDERLY_FORK_ID || '';
 | 
			
		||||
const FORK = process.env.FORK || '';
 | 
			
		||||
const FORK_BLOCK_NUMBER = process.env.FORK_BLOCK_NUMBER
 | 
			
		||||
  ? parseInt(process.env.FORK_BLOCK_NUMBER)
 | 
			
		||||
  : 0;
 | 
			
		||||
 | 
			
		||||
const GWEI = 1000 * 1000 * 1000;
 | 
			
		||||
 | 
			
		||||
export const buildForkConfig = (): HardhatNetworkForkingUserConfig | undefined => {
 | 
			
		||||
  let forkMode;
 | 
			
		||||
  if (FORK) {
 | 
			
		||||
    forkMode = {
 | 
			
		||||
      url: NETWORKS_RPC_URL[FORK],
 | 
			
		||||
    };
 | 
			
		||||
    if (FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK]) {
 | 
			
		||||
      forkMode.blockNumber = FORK_BLOCK_NUMBER || BLOCK_TO_FORK[FORK];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return forkMode;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
 | 
			
		||||
  [eEthereumNetwork.kovan]: ALCHEMY_KEY
 | 
			
		||||
    ? `https://eth-kovan.alchemyapi.io/v2/${ALCHEMY_KEY}`
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +52,7 @@ export const NETWORKS_RPC_URL: iParamsPerNetwork<string> = {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
 | 
			
		||||
  [eEthereumNetwork.kovan]: 65 * GWEI,
 | 
			
		||||
  [eEthereumNetwork.kovan]: 1 * GWEI,
 | 
			
		||||
  [eEthereumNetwork.ropsten]: 65 * GWEI,
 | 
			
		||||
  [eEthereumNetwork.main]: 65 * GWEI,
 | 
			
		||||
  [eEthereumNetwork.coverage]: 65 * GWEI,
 | 
			
		||||
| 
						 | 
				
			
			@ -42,6 +60,19 @@ export const NETWORKS_DEFAULT_GAS: iParamsPerNetwork<number> = {
 | 
			
		|||
  [eEthereumNetwork.buidlerevm]: 65 * GWEI,
 | 
			
		||||
  [eEthereumNetwork.tenderlyMain]: 0.01 * GWEI,
 | 
			
		||||
  [ePolygonNetwork.mumbai]: 1 * GWEI,
 | 
			
		||||
  [ePolygonNetwork.matic]: 2 * GWEI,
 | 
			
		||||
  [ePolygonNetwork.matic]: 1 * GWEI,
 | 
			
		||||
  [eXDaiNetwork.xdai]: 1 * GWEI,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const BLOCK_TO_FORK: iParamsPerNetwork<number | undefined> = {
 | 
			
		||||
  [eEthereumNetwork.main]: 12406069,
 | 
			
		||||
  [eEthereumNetwork.kovan]: undefined,
 | 
			
		||||
  [eEthereumNetwork.ropsten]: undefined,
 | 
			
		||||
  [eEthereumNetwork.coverage]: undefined,
 | 
			
		||||
  [eEthereumNetwork.hardhat]: undefined,
 | 
			
		||||
  [eEthereumNetwork.buidlerevm]: undefined,
 | 
			
		||||
  [eEthereumNetwork.tenderlyMain]: 12406069,
 | 
			
		||||
  [ePolygonNetwork.mumbai]: undefined,
 | 
			
		||||
  [ePolygonNetwork.matic]: undefined,
 | 
			
		||||
  [eXDaiNetwork.xdai]: undefined,
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,7 @@ import {
 | 
			
		|||
  ICommonConfiguration,
 | 
			
		||||
  eNetwork,
 | 
			
		||||
} from './types';
 | 
			
		||||
import { getParamPerPool } from './contracts-helpers';
 | 
			
		||||
import { getEthersSignersAddresses, getParamPerPool } from './contracts-helpers';
 | 
			
		||||
import AaveConfig from '../markets/aave';
 | 
			
		||||
import MaticConfig from '../markets/matic';
 | 
			
		||||
import AmmConfig from '../markets/amm';
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
 | 
			
		|||
    case ConfigNames.Matic:
 | 
			
		||||
      return MaticConfig;
 | 
			
		||||
    case ConfigNames.Amm:
 | 
			
		||||
        return AmmConfig;
 | 
			
		||||
      return AmmConfig;
 | 
			
		||||
    case ConfigNames.Commons:
 | 
			
		||||
      return CommonsConfig;
 | 
			
		||||
    default:
 | 
			
		||||
| 
						 | 
				
			
			@ -61,14 +61,12 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
 | 
			
		|||
export const getGenesisPoolAdmin = async (
 | 
			
		||||
  config: ICommonConfiguration
 | 
			
		||||
): Promise<tEthereumAddress> => {
 | 
			
		||||
  const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
 | 
			
		||||
  const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
 | 
			
		||||
  const targetAddress = getParamPerNetwork(config.PoolAdmin, <eNetwork>currentNetwork);
 | 
			
		||||
  if (targetAddress) {
 | 
			
		||||
    return targetAddress;
 | 
			
		||||
  }
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
  const addressIndex = config.PoolAdminIndex;
 | 
			
		||||
  return addressList[addressIndex];
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -76,14 +74,12 @@ export const getGenesisPoolAdmin = async (
 | 
			
		|||
export const getEmergencyAdmin = async (
 | 
			
		||||
  config: ICommonConfiguration
 | 
			
		||||
): Promise<tEthereumAddress> => {
 | 
			
		||||
  const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
 | 
			
		||||
  const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
 | 
			
		||||
  const targetAddress = getParamPerNetwork(config.EmergencyAdmin, <eNetwork>currentNetwork);
 | 
			
		||||
  if (targetAddress) {
 | 
			
		||||
    return targetAddress;
 | 
			
		||||
  }
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
  const addressIndex = config.EmergencyAdminIndex;
 | 
			
		||||
  return addressList[addressIndex];
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +87,7 @@ export const getEmergencyAdmin = async (
 | 
			
		|||
export const getTreasuryAddress = async (
 | 
			
		||||
  config: ICommonConfiguration
 | 
			
		||||
): Promise<tEthereumAddress> => {
 | 
			
		||||
  const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
 | 
			
		||||
  const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
 | 
			
		||||
  return getParamPerNetwork(config.ReserveFactorTreasuryAddress, <eNetwork>currentNetwork);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -101,7 +97,7 @@ export const getATokenDomainSeparatorPerNetwork = (
 | 
			
		|||
): tEthereumAddress => getParamPerNetwork<tEthereumAddress>(config.ATokenDomainSeparator, network);
 | 
			
		||||
 | 
			
		||||
export const getWethAddress = async (config: ICommonConfiguration) => {
 | 
			
		||||
  const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
 | 
			
		||||
  const currentNetwork = process.env.FORK ? process.env.FORK : DRE.network.name;
 | 
			
		||||
  const wethAddress = getParamPerNetwork(config.WETH, <eNetwork>currentNetwork);
 | 
			
		||||
  if (wethAddress) {
 | 
			
		||||
    return wethAddress;
 | 
			
		||||
| 
						 | 
				
			
			@ -113,6 +109,19 @@ export const getWethAddress = async (config: ICommonConfiguration) => {
 | 
			
		|||
  return weth.address;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getWrappedNativeTokenAddress = async (config: ICommonConfiguration) => {
 | 
			
		||||
  const currentNetwork = process.env.MAINNET_FORK === 'true' ? 'main' : DRE.network.name;
 | 
			
		||||
  const wethAddress = getParamPerNetwork(config.WrappedNativeToken, <eNetwork>currentNetwork);
 | 
			
		||||
  if (wethAddress) {
 | 
			
		||||
    return wethAddress;
 | 
			
		||||
  }
 | 
			
		||||
  if (currentNetwork.includes('main')) {
 | 
			
		||||
    throw new Error('WETH not set at mainnet configuration.');
 | 
			
		||||
  }
 | 
			
		||||
  const weth = await deployWETHMocked();
 | 
			
		||||
  return weth.address;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => {
 | 
			
		||||
  const {
 | 
			
		||||
    ProtocolGlobalParams: { UsdAddress },
 | 
			
		||||
| 
						 | 
				
			
			@ -120,8 +129,7 @@ export const getLendingRateOracles = (poolConfig: ICommonConfiguration) => {
 | 
			
		|||
    ReserveAssets,
 | 
			
		||||
  } = poolConfig;
 | 
			
		||||
 | 
			
		||||
  const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
 | 
			
		||||
  const network = MAINNET_FORK ? 'main' : DRE.network.name;
 | 
			
		||||
  const network = process.env.FORK ? process.env.FORK : DRE.network.name;
 | 
			
		||||
  return filterMapBy(LendingRateOracleRatesCommon, (key) =>
 | 
			
		||||
    Object.keys(ReserveAssets[network]).includes(key)
 | 
			
		||||
  );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -58,12 +58,28 @@ import {
 | 
			
		|||
  registerContractInJsonDb,
 | 
			
		||||
  linkBytecode,
 | 
			
		||||
  insertContractAddressInDb,
 | 
			
		||||
  deployContract,
 | 
			
		||||
  verifyContract,
 | 
			
		||||
} from './contracts-helpers';
 | 
			
		||||
import { StableAndVariableTokensHelperFactory } from '../types/StableAndVariableTokensHelperFactory';
 | 
			
		||||
import { MintableDelegationERC20 } from '../types/MintableDelegationERC20';
 | 
			
		||||
import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
 | 
			
		||||
import { UiPoolDataProvider } from '../types';
 | 
			
		||||
 | 
			
		||||
export const deployUiPoolDataProvider = async (
 | 
			
		||||
  [incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const id = eContractid.UiPoolDataProvider;
 | 
			
		||||
  const args: string[] = [incentivesController, aaveOracle];
 | 
			
		||||
  const instance = await deployContract<UiPoolDataProvider>(id, args);
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(id, instance, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const readArtifact = async (id: string) => {
 | 
			
		||||
  if (DRE.network.name === eEthereumNetwork.buidlerevm) {
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +140,9 @@ export const deployGenericLogic = async (reserveLogic: Contract, verify?: boolea
 | 
			
		|||
    linkedGenericLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const genericLogic = await (await genericLogicFactory.deploy()).deployed();
 | 
			
		||||
  const genericLogic = await (
 | 
			
		||||
    await genericLogicFactory.connect(await getFirstSigner()).deploy()
 | 
			
		||||
  ).deployed();
 | 
			
		||||
  return withSaveAndVerify(genericLogic, eContractid.GenericLogic, [], verify);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +163,9 @@ export const deployValidationLogic = async (
 | 
			
		|||
    linkedValidationLogicByteCode
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const validationLogic = await (await validationLogicFactory.deploy()).deployed();
 | 
			
		||||
  const validationLogic = await (
 | 
			
		||||
    await validationLogicFactory.connect(await getFirstSigner()).deploy()
 | 
			
		||||
  ).deployed();
 | 
			
		||||
 | 
			
		||||
  return withSaveAndVerify(validationLogic, eContractid.ValidationLogic, [], verify);
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -549,7 +569,15 @@ export const deployMockVariableDebtToken = async (
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
export const deployMockAToken = async (
 | 
			
		||||
  args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string, string],
 | 
			
		||||
  args: [
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    tEthereumAddress,
 | 
			
		||||
    string,
 | 
			
		||||
    string,
 | 
			
		||||
    string
 | 
			
		||||
  ],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  const instance = await withSaveAndVerify(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -35,20 +35,20 @@ import {
 | 
			
		|||
  FlashLiquidationAdapterFactory,
 | 
			
		||||
} from '../types';
 | 
			
		||||
import { IERC20DetailedFactory } from '../types/IERC20DetailedFactory';
 | 
			
		||||
import { MockTokenMap } from './contracts-helpers';
 | 
			
		||||
import { DRE, getDb } from './misc-utils';
 | 
			
		||||
import { getEthersSigners, MockTokenMap } from './contracts-helpers';
 | 
			
		||||
import { DRE, getDb, notFalsyOrZeroAddress } from './misc-utils';
 | 
			
		||||
import { eContractid, PoolConfiguration, tEthereumAddress, TokenContractId } from './types';
 | 
			
		||||
 | 
			
		||||
export const getFirstSigner = async () => (await DRE.ethers.getSigners())[0];
 | 
			
		||||
export const getFirstSigner = async () => (await getEthersSigners())[0];
 | 
			
		||||
 | 
			
		||||
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await LendingPoolAddressesProviderFactory.connect(
 | 
			
		||||
export const getLendingPoolAddressesProvider = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await LendingPoolAddressesProviderFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (await getDb().get(`${eContractid.LendingPoolAddressesProvider}.${DRE.network.name}`).value())
 | 
			
		||||
        .address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
export const getLendingPoolConfiguratorProxy = async (address?: tEthereumAddress) => {
 | 
			
		||||
  return await LendingPoolConfiguratorFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +175,7 @@ export const getPairsTokenAggregator = (
 | 
			
		|||
  },
 | 
			
		||||
  aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress }
 | 
			
		||||
): [string[], string[]] => {
 | 
			
		||||
  const { ETH, USD, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses;
 | 
			
		||||
  const { ETH, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses;
 | 
			
		||||
 | 
			
		||||
  const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => {
 | 
			
		||||
    //if (true/*tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH' && tokenSymbol !== 'LpWETH'*/) {
 | 
			
		||||
| 
						 | 
				
			
			@ -198,12 +198,13 @@ export const getPairsTokenAggregator = (
 | 
			
		|||
 | 
			
		||||
export const getLendingPoolAddressesProviderRegistry = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await LendingPoolAddressesProviderRegistryFactory.connect(
 | 
			
		||||
    address ||
 | 
			
		||||
      (
 | 
			
		||||
        await getDb()
 | 
			
		||||
          .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${DRE.network.name}`)
 | 
			
		||||
          .value()
 | 
			
		||||
      ).address,
 | 
			
		||||
    notFalsyOrZeroAddress(address)
 | 
			
		||||
      ? address
 | 
			
		||||
      : (
 | 
			
		||||
          await getDb()
 | 
			
		||||
            .get(`${eContractid.LendingPoolAddressesProviderRegistry}.${DRE.network.name}`)
 | 
			
		||||
            .value()
 | 
			
		||||
        ).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,16 +22,18 @@ import {
 | 
			
		|||
import { MintableERC20 } from '../types/MintableERC20';
 | 
			
		||||
import { Artifact } from 'hardhat/types';
 | 
			
		||||
import { Artifact as BuidlerArtifact } from '@nomiclabs/buidler/types';
 | 
			
		||||
import { verifyContract } from './etherscan-verification';
 | 
			
		||||
import { getIErc20Detailed } from './contracts-getters';
 | 
			
		||||
import { usingTenderly } from './tenderly-utils';
 | 
			
		||||
import { verifyEtherscanContract } from './etherscan-verification';
 | 
			
		||||
import { getFirstSigner, getIErc20Detailed } from './contracts-getters';
 | 
			
		||||
import { usingTenderly, verifyAtTenderly } from './tenderly-utils';
 | 
			
		||||
import { usingPolygon, verifyAtPolygon } from './polygon-utils';
 | 
			
		||||
import { getDefenderRelaySigner, usingDefender } from './defender-utils';
 | 
			
		||||
 | 
			
		||||
export type MockTokenMap = { [symbol: string]: MintableERC20 };
 | 
			
		||||
 | 
			
		||||
export const registerContractInJsonDb = async (contractId: string, contractInstance: Contract) => {
 | 
			
		||||
  const currentNetwork = DRE.network.name;
 | 
			
		||||
  const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
 | 
			
		||||
  if (MAINNET_FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) {
 | 
			
		||||
  const FORK = process.env.FORK;
 | 
			
		||||
  if (FORK || (currentNetwork !== 'hardhat' && !currentNetwork.includes('coverage'))) {
 | 
			
		||||
    console.log(`*** ${contractId} ***\n`);
 | 
			
		||||
    console.log(`Network: ${currentNetwork}`);
 | 
			
		||||
    console.log(`tx: ${contractInstance.deployTransaction.hash}`);
 | 
			
		||||
| 
						 | 
				
			
			@ -65,11 +67,18 @@ export const rawInsertContractAddressInDb = async (id: string, address: tEthereu
 | 
			
		|||
    })
 | 
			
		||||
    .write();
 | 
			
		||||
 | 
			
		||||
export const getEthersSigners = async (): Promise<Signer[]> =>
 | 
			
		||||
  await Promise.all(await DRE.ethers.getSigners());
 | 
			
		||||
export const getEthersSigners = async (): Promise<Signer[]> => {
 | 
			
		||||
  const ethersSigners = await Promise.all(await DRE.ethers.getSigners());
 | 
			
		||||
 | 
			
		||||
  if (usingDefender()) {
 | 
			
		||||
    const [, ...users] = ethersSigners;
 | 
			
		||||
    return [await getDefenderRelaySigner(), ...users];
 | 
			
		||||
  }
 | 
			
		||||
  return ethersSigners;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getEthersSignersAddresses = async (): Promise<tEthereumAddress[]> =>
 | 
			
		||||
  await Promise.all((await DRE.ethers.getSigners()).map((signer) => signer.getAddress()));
 | 
			
		||||
  await Promise.all((await getEthersSigners()).map((signer) => signer.getAddress()));
 | 
			
		||||
 | 
			
		||||
export const getCurrentBlock = async () => {
 | 
			
		||||
  return DRE.ethers.provider.getBlockNumber();
 | 
			
		||||
| 
						 | 
				
			
			@ -82,9 +91,9 @@ export const deployContract = async <ContractType extends Contract>(
 | 
			
		|||
  contractName: string,
 | 
			
		||||
  args: any[]
 | 
			
		||||
): Promise<ContractType> => {
 | 
			
		||||
  const contract = (await (await DRE.ethers.getContractFactory(contractName)).deploy(
 | 
			
		||||
    ...args
 | 
			
		||||
  )) as ContractType;
 | 
			
		||||
  const contract = (await (await DRE.ethers.getContractFactory(contractName))
 | 
			
		||||
    .connect(await getFirstSigner())
 | 
			
		||||
    .deploy(...args)) as ContractType;
 | 
			
		||||
  await waitForTx(contract.deployTransaction);
 | 
			
		||||
  await registerContractInJsonDb(<eContractid>contractName, contract);
 | 
			
		||||
  return contract;
 | 
			
		||||
| 
						 | 
				
			
			@ -98,18 +107,8 @@ export const withSaveAndVerify = async <ContractType extends Contract>(
 | 
			
		|||
): Promise<ContractType> => {
 | 
			
		||||
  await waitForTx(instance.deployTransaction);
 | 
			
		||||
  await registerContractInJsonDb(id, instance);
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    console.log();
 | 
			
		||||
    console.log('Doing Tenderly contract verification of', id);
 | 
			
		||||
    await (DRE as any).tenderlyRPC.verify({
 | 
			
		||||
      name: id,
 | 
			
		||||
      address: instance.address,
 | 
			
		||||
    });
 | 
			
		||||
    console.log(`Verified ${id} at Tenderly!`);
 | 
			
		||||
    console.log();
 | 
			
		||||
  }
 | 
			
		||||
  if (verify) {
 | 
			
		||||
    await verifyContract(instance.address, args);
 | 
			
		||||
    await verifyContract(id, instance, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -153,9 +152,8 @@ export const getParamPerNetwork = <T>(param: iParamsPerNetwork<T>, network: eNet
 | 
			
		|||
  } = param as iEthereumParamsPerNetwork<T>;
 | 
			
		||||
  const { matic, mumbai } = param as iPolygonParamsPerNetwork<T>;
 | 
			
		||||
  const { xdai } = param as iXDaiParamsPerNetwork<T>;
 | 
			
		||||
  const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
 | 
			
		||||
  if (MAINNET_FORK) {
 | 
			
		||||
    return main;
 | 
			
		||||
  if (process.env.FORK) {
 | 
			
		||||
    return param[process.env.FORK as eNetwork] as T;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  switch (network) {
 | 
			
		||||
| 
						 | 
				
			
			@ -360,3 +358,19 @@ export const buildParaSwapLiquiditySwapParams = (
 | 
			
		|||
    ]
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const verifyContract = async (
 | 
			
		||||
  id: string,
 | 
			
		||||
  instance: Contract,
 | 
			
		||||
  args: (string | string[])[]
 | 
			
		||||
) => {
 | 
			
		||||
  if (usingPolygon()) {
 | 
			
		||||
    await verifyAtPolygon(id, instance, args);
 | 
			
		||||
  } else {
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      await verifyAtTenderly(id, instance);
 | 
			
		||||
    }
 | 
			
		||||
    await verifyEtherscanContract(instance.address, args);
 | 
			
		||||
  }
 | 
			
		||||
  return instance;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										41
									
								
								helpers/defender-utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								helpers/defender-utils.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,41 @@
 | 
			
		|||
import { formatEther } from '@ethersproject/units';
 | 
			
		||||
import { DefenderRelaySigner, DefenderRelayProvider } from 'defender-relay-client/lib/ethers';
 | 
			
		||||
import { Signer } from 'ethers';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { DRE, impersonateAccountsHardhat } from './misc-utils';
 | 
			
		||||
import { usingTenderly } from './tenderly-utils';
 | 
			
		||||
 | 
			
		||||
export const usingDefender = () => process.env.DEFENDER === 'true';
 | 
			
		||||
 | 
			
		||||
export const getDefenderRelaySigner = async () => {
 | 
			
		||||
  const { DEFENDER_API_KEY, DEFENDER_SECRET_KEY } = process.env;
 | 
			
		||||
  let defenderSigner: Signer;
 | 
			
		||||
 | 
			
		||||
  if (!DEFENDER_API_KEY || !DEFENDER_SECRET_KEY) {
 | 
			
		||||
    throw new Error('Defender secrets required');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const credentials = { apiKey: DEFENDER_API_KEY, apiSecret: DEFENDER_SECRET_KEY };
 | 
			
		||||
 | 
			
		||||
  defenderSigner = new DefenderRelaySigner(credentials, new DefenderRelayProvider(credentials), {
 | 
			
		||||
    speed: 'fast',
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const defenderAddress = await defenderSigner.getAddress();
 | 
			
		||||
  console.log('  - Using Defender Relay: ', defenderAddress);
 | 
			
		||||
 | 
			
		||||
  // Replace signer if FORK=main is active
 | 
			
		||||
  if (process.env.FORK === 'main') {
 | 
			
		||||
    console.log('  - Impersonating Defender Relay');
 | 
			
		||||
    await impersonateAccountsHardhat([defenderAddress]);
 | 
			
		||||
    defenderSigner = await (DRE as HardhatRuntimeEnvironment).ethers.getSigner(defenderAddress);
 | 
			
		||||
  }
 | 
			
		||||
  // Replace signer if Tenderly network is active
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    console.log('  - Impersonating Defender Relay via Tenderly');
 | 
			
		||||
    defenderSigner = await (DRE as HardhatRuntimeEnvironment).ethers.getSigner(defenderAddress);
 | 
			
		||||
  }
 | 
			
		||||
  console.log('  - Balance: ', formatEther(await defenderSigner.getBalance()));
 | 
			
		||||
 | 
			
		||||
  return defenderSigner;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -20,7 +20,7 @@ function delay(ms: number) {
 | 
			
		|||
  return new Promise((resolve) => setTimeout(resolve, ms));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const verifyContract = async (
 | 
			
		||||
export const verifyEtherscanContract = async (
 | 
			
		||||
  address: string,
 | 
			
		||||
  constructorArguments: (string | string[])[],
 | 
			
		||||
  libraries?: string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,6 +12,7 @@ import {
 | 
			
		|||
  getAaveProtocolDataProvider,
 | 
			
		||||
  getAToken,
 | 
			
		||||
  getATokensAndRatesHelper,
 | 
			
		||||
  getFirstSigner,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getStableAndVariableTokensHelper,
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +33,7 @@ import {
 | 
			
		|||
import { ZERO_ADDRESS } from './constants';
 | 
			
		||||
import { isZeroAddress } from 'ethereumjs-util';
 | 
			
		||||
import { DefaultReserveInterestRateStrategy, DelegationAwareAToken } from '../types';
 | 
			
		||||
import { config } from 'process';
 | 
			
		||||
 | 
			
		||||
export const chooseATokenDeployment = (id: eContractid) => {
 | 
			
		||||
  switch (id) {
 | 
			
		||||
| 
						 | 
				
			
			@ -144,6 +146,10 @@ export const initReservesByHelper = async (
 | 
			
		|||
  ) as [string, IReserveParams][];
 | 
			
		||||
 | 
			
		||||
  for (let [symbol, params] of reserves) {
 | 
			
		||||
    if (!tokenAddresses[symbol]) {
 | 
			
		||||
      console.log(`- Skipping init of ${symbol} due token address is not set at markets config`);
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
    const { strategy, aTokenImpl, reserveDecimals } = params;
 | 
			
		||||
    const {
 | 
			
		||||
      optimalUtilizationRate,
 | 
			
		||||
| 
						 | 
				
			
			@ -201,7 +207,7 @@ export const initReservesByHelper = async (
 | 
			
		|||
      interestRateStrategyAddress: strategyAddressPerAsset[reserveSymbols[i]],
 | 
			
		||||
      underlyingAsset: reserveTokens[i],
 | 
			
		||||
      treasury: treasuryAddress,
 | 
			
		||||
      incentivesController: ZERO_ADDRESS,
 | 
			
		||||
      incentivesController,
 | 
			
		||||
      underlyingAssetName: reserveSymbols[i],
 | 
			
		||||
      aTokenName: `${aTokenNamePrefix} ${reserveSymbols[i]}`,
 | 
			
		||||
      aTokenSymbol: `a${symbolPrefix}${reserveSymbols[i]}`,
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +215,7 @@ export const initReservesByHelper = async (
 | 
			
		|||
      variableDebtTokenSymbol: `variableDebt${symbolPrefix}${reserveSymbols[i]}`,
 | 
			
		||||
      stableDebtTokenName: `${stableDebtTokenNamePrefix} ${reserveSymbols[i]}`,
 | 
			
		||||
      stableDebtTokenSymbol: `stableDebt${symbolPrefix}${reserveSymbols[i]}`,
 | 
			
		||||
      params: '0x10'
 | 
			
		||||
      params: '0x10',
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -271,11 +277,6 @@ export const configureReservesByHelper = async (
 | 
			
		|||
  const atokenAndRatesDeployer = await getATokensAndRatesHelper();
 | 
			
		||||
  const tokens: string[] = [];
 | 
			
		||||
  const symbols: string[] = [];
 | 
			
		||||
  const baseLTVA: string[] = [];
 | 
			
		||||
  const liquidationThresholds: string[] = [];
 | 
			
		||||
  const liquidationBonuses: string[] = [];
 | 
			
		||||
  const reserveFactors: string[] = [];
 | 
			
		||||
  const stableRatesEnabled: boolean[] = [];
 | 
			
		||||
 | 
			
		||||
  const inputParams: {
 | 
			
		||||
    asset: string;
 | 
			
		||||
| 
						 | 
				
			
			@ -284,6 +285,7 @@ export const configureReservesByHelper = async (
 | 
			
		|||
    liquidationBonus: BigNumberish;
 | 
			
		||||
    reserveFactor: BigNumberish;
 | 
			
		||||
    stableBorrowingEnabled: boolean;
 | 
			
		||||
    borrowingEnabled: boolean;
 | 
			
		||||
  }[] = [];
 | 
			
		||||
 | 
			
		||||
  for (const [
 | 
			
		||||
| 
						 | 
				
			
			@ -294,8 +296,15 @@ export const configureReservesByHelper = async (
 | 
			
		|||
      liquidationThreshold,
 | 
			
		||||
      reserveFactor,
 | 
			
		||||
      stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled,
 | 
			
		||||
    },
 | 
			
		||||
  ] of Object.entries(reservesParams) as [string, IReserveParams][]) {
 | 
			
		||||
    if (!tokenAddresses[assetSymbol]) {
 | 
			
		||||
      console.log(
 | 
			
		||||
        `- Skipping init of ${assetSymbol} due token address is not set at markets config`
 | 
			
		||||
      );
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
    if (baseLTVAsCollateral === '-1') continue;
 | 
			
		||||
 | 
			
		||||
    const assetAddressIndex = Object.keys(tokenAddresses).findIndex(
 | 
			
		||||
| 
						 | 
				
			
			@ -321,15 +330,11 @@ export const configureReservesByHelper = async (
 | 
			
		|||
      liquidationBonus: liquidationBonus,
 | 
			
		||||
      reserveFactor: reserveFactor,
 | 
			
		||||
      stableBorrowingEnabled: stableBorrowRateEnabled,
 | 
			
		||||
      borrowingEnabled: borrowingEnabled,
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    tokens.push(tokenAddress);
 | 
			
		||||
    symbols.push(assetSymbol);
 | 
			
		||||
    baseLTVA.push(baseLTVAsCollateral);
 | 
			
		||||
    liquidationThresholds.push(liquidationThreshold);
 | 
			
		||||
    liquidationBonuses.push(liquidationBonus);
 | 
			
		||||
    reserveFactors.push(reserveFactor);
 | 
			
		||||
    stableRatesEnabled.push(stableBorrowRateEnabled);
 | 
			
		||||
  }
 | 
			
		||||
  if (tokens.length) {
 | 
			
		||||
    // Set aTokenAndRatesDeployer as temporal admin
 | 
			
		||||
| 
						 | 
				
			
			@ -360,229 +365,6 @@ const getAddressById = async (
 | 
			
		|||
): Promise<tEthereumAddress | undefined> =>
 | 
			
		||||
  (await getDb().get(`${id}.${network}`).value())?.address || undefined;
 | 
			
		||||
 | 
			
		||||
// Function deprecated? Updated but untested, script is not updated on package.json.
 | 
			
		||||
// This is not called during regular deployment, only in the "full:initialize-tokens"
 | 
			
		||||
// hardhat task.
 | 
			
		||||
export const initTokenReservesByHelper = async (
 | 
			
		||||
  reservesParams: iMultiPoolsAssets<IReserveParams>,
 | 
			
		||||
  tokenAddresses: { [symbol: string]: tEthereumAddress },
 | 
			
		||||
  admin: tEthereumAddress,
 | 
			
		||||
  addressesProviderAddress: tEthereumAddress,
 | 
			
		||||
  ratesHelperAddress: tEthereumAddress,
 | 
			
		||||
  dataProviderAddress: tEthereumAddress,
 | 
			
		||||
  signer: Signer,
 | 
			
		||||
  treasuryAddress: tEthereumAddress,
 | 
			
		||||
  verify: boolean
 | 
			
		||||
) => {
 | 
			
		||||
  let gasUsage = BigNumber.from('0');
 | 
			
		||||
  const atokenAndRatesDeployer = await (await getATokensAndRatesHelper(ratesHelperAddress)).connect(
 | 
			
		||||
    signer
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const addressProvider = await (
 | 
			
		||||
    await getLendingPoolAddressesProvider(addressesProviderAddress)
 | 
			
		||||
  ).connect(signer);
 | 
			
		||||
  const protocolDataProvider = await (
 | 
			
		||||
    await getAaveProtocolDataProvider(dataProviderAddress)
 | 
			
		||||
  ).connect(signer);
 | 
			
		||||
  const poolAddress = await addressProvider.getLendingPool();
 | 
			
		||||
 | 
			
		||||
  // Set aTokenAndRatesDeployer as temporal admin
 | 
			
		||||
  //await waitForTx(await addressProvider.setPoolAdmin(atokenAndRatesDeployer.address));
 | 
			
		||||
 | 
			
		||||
  // CHUNK CONFIGURATION
 | 
			
		||||
  const initChunks = 4;
 | 
			
		||||
 | 
			
		||||
  // Initialize variables for future reserves initialization
 | 
			
		||||
  let deployedStableTokens: string[] = [];
 | 
			
		||||
  let deployedVariableTokens: string[] = [];
 | 
			
		||||
  let deployedATokens: string[] = [];
 | 
			
		||||
  let deployedRates: string[] = [];
 | 
			
		||||
  //let reserveTokens: string[] = [];
 | 
			
		||||
  let reserveInitDecimals: string[] = [];
 | 
			
		||||
  let reserveSymbols: string[] = [];
 | 
			
		||||
 | 
			
		||||
  let initInputParams: {
 | 
			
		||||
    aTokenImpl: string;
 | 
			
		||||
    stableDebtTokenImpl: string;
 | 
			
		||||
    variableDebtTokenImpl: string;
 | 
			
		||||
    underlyingAssetDecimals: BigNumberish;
 | 
			
		||||
    interestRateStrategyAddress: string;
 | 
			
		||||
    underlyingAsset: string;
 | 
			
		||||
    treasury: string;
 | 
			
		||||
    incentivesController: string;
 | 
			
		||||
    underlyingAssetName: string;
 | 
			
		||||
    aTokenName: string;
 | 
			
		||||
    aTokenSymbol: string;
 | 
			
		||||
    variableDebtTokenName: string;
 | 
			
		||||
    variableDebtTokenSymbol: string;
 | 
			
		||||
    stableDebtTokenName: string;
 | 
			
		||||
    stableDebtTokenSymbol: string;
 | 
			
		||||
    params: string;
 | 
			
		||||
  }[] = [];
 | 
			
		||||
 | 
			
		||||
  const network =
 | 
			
		||||
    process.env.MAINNET_FORK === 'true' ? eEthereumNetwork.main : (DRE.network.name as eNetwork);
 | 
			
		||||
  // Grab config from DB
 | 
			
		||||
  for (const [symbol, address] of Object.entries(tokenAddresses)) {
 | 
			
		||||
    const { aTokenAddress } = await protocolDataProvider.getReserveTokensAddresses(address);
 | 
			
		||||
    const reserveParamIndex = Object.keys(reservesParams).findIndex((value) => value === symbol);
 | 
			
		||||
    const [, { reserveDecimals: decimals }] = (Object.entries(reservesParams) as [
 | 
			
		||||
      string,
 | 
			
		||||
      IReserveParams
 | 
			
		||||
    ][])[reserveParamIndex];
 | 
			
		||||
 | 
			
		||||
    if (!isZeroAddress(aTokenAddress)) {
 | 
			
		||||
      console.log(`- Skipping ${symbol} due already initialized`);
 | 
			
		||||
      continue;
 | 
			
		||||
    }
 | 
			
		||||
    let stableTokenImpl = await getAddressById(`stableDebtTokenImpl`, network);
 | 
			
		||||
    let variableTokenImpl = await getAddressById(`variableDebtTokenImpl`, network);
 | 
			
		||||
    let aTokenImplementation: string | undefined = '';
 | 
			
		||||
    const [, { aTokenImpl, strategy }] = (Object.entries(reservesParams) as [
 | 
			
		||||
      string,
 | 
			
		||||
      IReserveParams
 | 
			
		||||
    ][])[reserveParamIndex];
 | 
			
		||||
    if (aTokenImpl === eContractid.AToken) {
 | 
			
		||||
      aTokenImplementation = await getAddressById(`aTokenImpl`, network);
 | 
			
		||||
    } else if (aTokenImpl === eContractid.DelegationAwareAToken) {
 | 
			
		||||
      aTokenImplementation = await getAddressById(`delegationAwareATokenImpl`, network);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    let strategyImpl = await getAddressById(strategy.name, network);
 | 
			
		||||
 | 
			
		||||
    if (!stableTokenImpl) {
 | 
			
		||||
      const stableDebt = await deployStableDebtToken(
 | 
			
		||||
        [
 | 
			
		||||
          poolAddress,
 | 
			
		||||
          tokenAddresses[symbol],
 | 
			
		||||
          ZERO_ADDRESS, // Incentives controller
 | 
			
		||||
          `Aave stable debt bearing ${symbol}`,
 | 
			
		||||
          `stableDebt${symbol}`,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
      stableTokenImpl = stableDebt.address;
 | 
			
		||||
    }
 | 
			
		||||
    if (!variableTokenImpl) {
 | 
			
		||||
      const variableDebt = await deployVariableDebtToken(
 | 
			
		||||
        [
 | 
			
		||||
          poolAddress,
 | 
			
		||||
          tokenAddresses[symbol],
 | 
			
		||||
          ZERO_ADDRESS, // Incentives Controller
 | 
			
		||||
          `Aave variable debt bearing ${symbol}`,
 | 
			
		||||
          `variableDebt${symbol}`,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
      variableTokenImpl = variableDebt.address;
 | 
			
		||||
    }
 | 
			
		||||
    if (!aTokenImplementation) {
 | 
			
		||||
      const [, { aTokenImpl }] = (Object.entries(reservesParams) as [string, IReserveParams][])[
 | 
			
		||||
        reserveParamIndex
 | 
			
		||||
      ];
 | 
			
		||||
      const deployCustomAToken = chooseATokenDeployment(aTokenImpl);
 | 
			
		||||
      const aToken = await deployCustomAToken(
 | 
			
		||||
        [
 | 
			
		||||
          poolAddress,
 | 
			
		||||
          tokenAddresses[symbol],
 | 
			
		||||
          treasuryAddress,
 | 
			
		||||
          ZERO_ADDRESS,
 | 
			
		||||
          `Aave interest bearing ${symbol}`,
 | 
			
		||||
          `a${symbol}`,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
      aTokenImplementation = aToken.address;
 | 
			
		||||
    }
 | 
			
		||||
    if (!strategyImpl) {
 | 
			
		||||
      const [, { strategy }] = (Object.entries(reservesParams) as [string, IReserveParams][])[
 | 
			
		||||
        reserveParamIndex
 | 
			
		||||
      ];
 | 
			
		||||
      const {
 | 
			
		||||
        optimalUtilizationRate,
 | 
			
		||||
        baseVariableBorrowRate,
 | 
			
		||||
        variableRateSlope1,
 | 
			
		||||
        variableRateSlope2,
 | 
			
		||||
        stableRateSlope1,
 | 
			
		||||
        stableRateSlope2,
 | 
			
		||||
      } = strategy;
 | 
			
		||||
      const rates = await deployDefaultReserveInterestRateStrategy(
 | 
			
		||||
        [
 | 
			
		||||
          tokenAddresses[symbol],
 | 
			
		||||
          optimalUtilizationRate,
 | 
			
		||||
          baseVariableBorrowRate,
 | 
			
		||||
          variableRateSlope1,
 | 
			
		||||
          variableRateSlope2,
 | 
			
		||||
          stableRateSlope1,
 | 
			
		||||
          stableRateSlope2,
 | 
			
		||||
        ],
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
      strategyImpl = rates.address;
 | 
			
		||||
    }
 | 
			
		||||
    // --- REMOVED BECAUSE WE NOW USE THE SAME IMPLEMENTATIONS ---
 | 
			
		||||
    // const symbols = [`a${symbol}`, `variableDebt${symbol}`, `stableDebt${symbol}`];
 | 
			
		||||
    // const tokens = [aTokenImplementation, variableTokenImpl, stableTokenImpl];
 | 
			
		||||
    // for (let index = 0; index < symbols.length; index++) {
 | 
			
		||||
    //   if (!(await isErc20SymbolCorrect(tokens[index], symbols[index]))) {
 | 
			
		||||
    //     console.error(`${symbol} and implementation does not match: ${tokens[index]}`);
 | 
			
		||||
    //     throw Error('Symbol does not match implementation.');
 | 
			
		||||
    //   }
 | 
			
		||||
    // }
 | 
			
		||||
    console.log(`- Added ${symbol} to the initialize batch`);
 | 
			
		||||
    deployedStableTokens.push(stableTokenImpl);
 | 
			
		||||
    deployedVariableTokens.push(variableTokenImpl);
 | 
			
		||||
    deployedATokens.push(aTokenImplementation);
 | 
			
		||||
    //reserveTokens.push();
 | 
			
		||||
    deployedRates.push(strategyImpl);
 | 
			
		||||
    reserveInitDecimals.push(decimals.toString());
 | 
			
		||||
    reserveSymbols.push(symbol);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (let i = 0; i < deployedATokens.length; i++) {
 | 
			
		||||
    initInputParams.push({
 | 
			
		||||
      aTokenImpl: deployedATokens[i],
 | 
			
		||||
      stableDebtTokenImpl: deployedStableTokens[i],
 | 
			
		||||
      variableDebtTokenImpl: deployedVariableTokens[i],
 | 
			
		||||
      underlyingAssetDecimals: reserveInitDecimals[i],
 | 
			
		||||
      interestRateStrategyAddress: deployedRates[i],
 | 
			
		||||
      underlyingAsset: tokenAddresses[reserveSymbols[i]],
 | 
			
		||||
      treasury: treasuryAddress,
 | 
			
		||||
      incentivesController: ZERO_ADDRESS,
 | 
			
		||||
      underlyingAssetName: reserveSymbols[i],
 | 
			
		||||
      aTokenName: `Aave interest bearing ${reserveSymbols[i]}`,
 | 
			
		||||
      aTokenSymbol: `a${reserveSymbols[i]}`,
 | 
			
		||||
      variableDebtTokenName: `Aave variable debt bearing ${reserveSymbols[i]}`,
 | 
			
		||||
      variableDebtTokenSymbol: `variableDebt${reserveSymbols[i]}`,
 | 
			
		||||
      stableDebtTokenName: `Aave stable debt bearing ${reserveSymbols[i]}`,
 | 
			
		||||
      stableDebtTokenSymbol: `stableDebt${reserveSymbols[i]}`,
 | 
			
		||||
      params: '0x10'
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Deploy init reserves per chunks
 | 
			
		||||
  const chunkedSymbols = chunk(reserveSymbols, initChunks);
 | 
			
		||||
  const chunkedInitInputParams = chunk(initInputParams, initChunks);
 | 
			
		||||
 | 
			
		||||
  const configurator = await getLendingPoolConfiguratorProxy();
 | 
			
		||||
  //await waitForTx(await addressProvider.setPoolAdmin(admin));
 | 
			
		||||
 | 
			
		||||
  console.log(`- Reserves initialization in ${chunkedInitInputParams.length} txs`);
 | 
			
		||||
  for (let chunkIndex = 0; chunkIndex < chunkedInitInputParams.length; chunkIndex++) {
 | 
			
		||||
    const tx3 = await waitForTx(
 | 
			
		||||
      await configurator.batchInitReserve(chunkedInitInputParams[chunkIndex])
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    console.log(`  - Reserve ready for: ${chunkedSymbols[chunkIndex].join(', ')}`);
 | 
			
		||||
    console.log('    * gasUsed', tx3.gasUsed.toString());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Set deployer back as admin
 | 
			
		||||
  //await waitForTx(await addressProvider.setPoolAdmin(admin));
 | 
			
		||||
  return gasUsage;  // No longer relevant
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Function deprecated
 | 
			
		||||
const isErc20SymbolCorrect = async (token: tEthereumAddress, symbol: string) => {
 | 
			
		||||
  const erc20 = await getAToken(token); // using aToken for ERC20 interface
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -115,3 +115,17 @@ export const notFalsyOrZeroAddress = (address: tEthereumAddress | null | undefin
 | 
			
		|||
  }
 | 
			
		||||
  return isAddress(address) && !isZeroAddress(address);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const impersonateAccountsHardhat = async (accounts: string[]) => {
 | 
			
		||||
  if (process.env.TENDERLY === 'true') {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  // eslint-disable-next-line no-restricted-syntax
 | 
			
		||||
  for (const account of accounts) {
 | 
			
		||||
    // eslint-disable-next-line no-await-in-loop
 | 
			
		||||
    await (DRE as HardhatRuntimeEnvironment).network.provider.request({
 | 
			
		||||
      method: 'hardhat_impersonateAccount',
 | 
			
		||||
      params: [account],
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,9 +72,6 @@ export const setInitialAssetPricesInOracle = async (
 | 
			
		|||
  priceOracleInstance: PriceOracle
 | 
			
		||||
) => {
 | 
			
		||||
  for (const [assetSymbol, price] of Object.entries(prices) as [string, string][]) {
 | 
			
		||||
 | 
			
		||||
    console.log("Trying for ", assetsAddresses, assetSymbol);
 | 
			
		||||
    
 | 
			
		||||
    const assetAddressIndex = Object.keys(assetsAddresses).findIndex(
 | 
			
		||||
      (value) => value === assetSymbol
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										142
									
								
								helpers/polygon-utils.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										142
									
								
								helpers/polygon-utils.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,142 @@
 | 
			
		|||
import axios from 'axios';
 | 
			
		||||
import { Contract } from 'ethers/lib/ethers';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { DRE } from './misc-utils';
 | 
			
		||||
import { ePolygonNetwork, EthereumNetworkNames } from './types';
 | 
			
		||||
 | 
			
		||||
const TASK_FLATTEN_GET_FLATTENED_SOURCE = 'flatten:get-flattened-sources';
 | 
			
		||||
const TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS = 'compile:solidity:get-source-paths';
 | 
			
		||||
 | 
			
		||||
/* Polygon Helpers */
 | 
			
		||||
 | 
			
		||||
export const usingPolygon = () =>
 | 
			
		||||
  DRE && Object.keys(ePolygonNetwork).includes((DRE as HardhatRuntimeEnvironment).network.name);
 | 
			
		||||
 | 
			
		||||
/* Polygon Verifier */
 | 
			
		||||
 | 
			
		||||
const SOLIDITY_PRAGMA = 'pragma solidity';
 | 
			
		||||
const LICENSE_IDENTIFIER = 'License-Identifier';
 | 
			
		||||
const EXPERIMENTAL_ABIENCODER = 'pragma experimental ABIEncoderV2;';
 | 
			
		||||
 | 
			
		||||
const encodeDeployParams = (instance: Contract, args: (string | string[])[]) => {
 | 
			
		||||
  return instance.interface.encodeDeploy(args).replace('0x', '');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Remove lines at "text" that includes "matcher" string, but keeping first "keep" lines
 | 
			
		||||
const removeLines = (text: string, matcher: string, keep = 0): string => {
 | 
			
		||||
  let counter = keep;
 | 
			
		||||
  return text
 | 
			
		||||
    .split('\n')
 | 
			
		||||
    .filter((line) => {
 | 
			
		||||
      const match = !line.includes(matcher);
 | 
			
		||||
      if (match === false && counter > 0) {
 | 
			
		||||
        counter--;
 | 
			
		||||
        return true;
 | 
			
		||||
      }
 | 
			
		||||
      return match;
 | 
			
		||||
    })
 | 
			
		||||
    .join('\n');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Try to find the path of a Contract by name of the file without ".sol"
 | 
			
		||||
const findPath = async (id: string): Promise<string> => {
 | 
			
		||||
  const paths = await DRE.run(TASK_COMPILE_SOLIDITY_GET_SOURCE_PATHS);
 | 
			
		||||
  const path = paths.find((x) => {
 | 
			
		||||
    const t = x.split('/');
 | 
			
		||||
    return t[t.length - 1].split('.')[0] == id;
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  if (!path) {
 | 
			
		||||
    throw Error('Missing path for contract name: ${id}');
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return path;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Hardhat Flattener, similar to truffle flattener
 | 
			
		||||
const hardhatFlattener = async (filePath: string) =>
 | 
			
		||||
  await DRE.run(TASK_FLATTEN_GET_FLATTENED_SOURCE, { files: [filePath] });
 | 
			
		||||
 | 
			
		||||
// Verify a smart contract at Polygon Matic network via a GET request to the block explorer
 | 
			
		||||
export const verifyAtPolygon = async (
 | 
			
		||||
  id: string,
 | 
			
		||||
  instance: Contract,
 | 
			
		||||
  args: (string | string[])[]
 | 
			
		||||
) => {
 | 
			
		||||
  /*
 | 
			
		||||
    ${net == mumbai or mainnet}
 | 
			
		||||
    https://explorer-${net}.maticvigil.com/api
 | 
			
		||||
    ?module=contract
 | 
			
		||||
    &action=verify
 | 
			
		||||
    &addressHash={addressHash}
 | 
			
		||||
    &name={name}
 | 
			
		||||
    &compilerVersion={compilerVersion}
 | 
			
		||||
    &optimization={false}
 | 
			
		||||
    &contractSourceCode={contractSourceCode}
 | 
			
		||||
  */
 | 
			
		||||
  const network = (DRE as HardhatRuntimeEnvironment).network.name;
 | 
			
		||||
  const net = network === EthereumNetworkNames.matic ? 'mainnet' : network;
 | 
			
		||||
  const filePath = await findPath(id);
 | 
			
		||||
  const encodedConstructorParams = encodeDeployParams(instance, args);
 | 
			
		||||
  const flattenSourceCode = await hardhatFlattener(filePath);
 | 
			
		||||
 | 
			
		||||
  // Remove pragmas and license identifier after first match, required by block explorers like explorer-mainnet.maticgivil.com or Etherscan
 | 
			
		||||
  const cleanedSourceCode = removeLines(
 | 
			
		||||
    removeLines(removeLines(flattenSourceCode, LICENSE_IDENTIFIER, 1), SOLIDITY_PRAGMA, 1),
 | 
			
		||||
    EXPERIMENTAL_ABIENCODER,
 | 
			
		||||
    1
 | 
			
		||||
  );
 | 
			
		||||
  try {
 | 
			
		||||
    console.log(
 | 
			
		||||
      `[Polygon Verify] Verifying ${id} with address ${instance.address} at Matic ${net} network`
 | 
			
		||||
    );
 | 
			
		||||
    const response = await axios.post(
 | 
			
		||||
      `https://explorer-${net}.maticvigil.com/api`,
 | 
			
		||||
      {
 | 
			
		||||
        addressHash: instance.address,
 | 
			
		||||
        name: id,
 | 
			
		||||
        compilerVersion: 'v0.6.12+commit.27d51765',
 | 
			
		||||
        optimization: 'true',
 | 
			
		||||
        contractSourceCode: cleanedSourceCode,
 | 
			
		||||
        constructorArguments: encodedConstructorParams,
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
        params: {
 | 
			
		||||
          module: 'contract',
 | 
			
		||||
          action: 'verify',
 | 
			
		||||
        },
 | 
			
		||||
        headers: {
 | 
			
		||||
          'Content-Type': 'application/json',
 | 
			
		||||
          Referer: 'aavematic-42e1f6da',
 | 
			
		||||
        },
 | 
			
		||||
      }
 | 
			
		||||
    );
 | 
			
		||||
    if (response.status === 200 && response.data.message === 'OK') {
 | 
			
		||||
      console.log(`[Polygon Verify] Verified contract at Matic ${net} network.`);
 | 
			
		||||
      console.log(
 | 
			
		||||
        `[Polygon Verify] Check at: https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts) \n`
 | 
			
		||||
      );
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    throw Error(JSON.stringify(response.data, null, 2));
 | 
			
		||||
  } catch (error) {
 | 
			
		||||
    if (error?.message.includes('Smart-contract already verified.')) {
 | 
			
		||||
      console.log(
 | 
			
		||||
        `[Polygon Verify] Already verified. Check it at: https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts) \n`
 | 
			
		||||
      );
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    console.error('[Polygon Verify] Error:', error.toString());
 | 
			
		||||
    console.log(
 | 
			
		||||
      `[Polygon Verify] Skipping verification for ${id} with ${instance.address} due an unknown error.`
 | 
			
		||||
    );
 | 
			
		||||
    console.log(
 | 
			
		||||
      `Please proceed with manual verification at https://explorer-${net}.maticvigil.com/address/${instance.address}/contracts`
 | 
			
		||||
    );
 | 
			
		||||
    console.log(`- Use the following as encoded constructor params`);
 | 
			
		||||
    console.log(encodedConstructorParams);
 | 
			
		||||
    console.log(`- Flattened and cleaned source code`);
 | 
			
		||||
    console.log(cleanedSourceCode);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +1,4 @@
 | 
			
		|||
import { Contract } from 'ethers';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { DRE } from './misc-utils';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -5,3 +6,12 @@ export const usingTenderly = () =>
 | 
			
		|||
  DRE &&
 | 
			
		||||
  ((DRE as HardhatRuntimeEnvironment).network.name.includes('tenderly') ||
 | 
			
		||||
    process.env.TENDERLY === 'true');
 | 
			
		||||
 | 
			
		||||
export const verifyAtTenderly = async (id: string, instance: Contract) => {
 | 
			
		||||
  console.log('\n- Doing Tenderly contract verification of', id);
 | 
			
		||||
  await (DRE as any).tenderlyNetwork.verify({
 | 
			
		||||
    name: id,
 | 
			
		||||
    address: instance.address,
 | 
			
		||||
  });
 | 
			
		||||
  console.log(`  - Verified ${id} at Tenderly!`);
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -300,7 +300,7 @@ export type iLpPoolAssets<T> = Pick<
 | 
			
		|||
 | 
			
		||||
export type iMaticPoolAssets<T> = Pick<
 | 
			
		||||
  iAssetsWithoutUSD<T>,
 | 
			
		||||
  'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'WMATIC'
 | 
			
		||||
  'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'WMATIC' | 'AAVE'
 | 
			
		||||
>;
 | 
			
		||||
 | 
			
		||||
export type iXDAIPoolAssets<T> = Pick<
 | 
			
		||||
| 
						 | 
				
			
			@ -354,7 +354,7 @@ export enum TokenContractId {
 | 
			
		|||
  BptBALWETH = 'BptBALWETH',
 | 
			
		||||
  WMATIC = 'WMATIC',
 | 
			
		||||
  STAKE = 'STAKE',
 | 
			
		||||
  xSUSHI = 'xSUSHI'
 | 
			
		||||
  xSUSHI = 'xSUSHI',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
 | 
			
		||||
| 
						 | 
				
			
			@ -493,8 +493,10 @@ export interface ICommonConfiguration {
 | 
			
		|||
  ReservesConfig: iMultiPoolsAssets<IReserveParams>;
 | 
			
		||||
  ATokenDomainSeparator: iParamsPerNetwork<string>;
 | 
			
		||||
  WETH: iParamsPerNetwork<tEthereumAddress>;
 | 
			
		||||
  WrappedNativeToken: iParamsPerNetwork<tEthereumAddress>;
 | 
			
		||||
  WethGateway: iParamsPerNetwork<tEthereumAddress>;
 | 
			
		||||
  ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
 | 
			
		||||
  IncentivesController: iParamsPerNetwork<tEthereumAddress>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface IAaveConfiguration extends ICommonConfiguration {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,11 @@
 | 
			
		|||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import { oneEther, oneRay, RAY, ZERO_ADDRESS, MOCK_CHAINLINK_AGGREGATORS_PRICES } from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  oneEther,
 | 
			
		||||
  oneRay,
 | 
			
		||||
  RAY,
 | 
			
		||||
  ZERO_ADDRESS,
 | 
			
		||||
  MOCK_CHAINLINK_AGGREGATORS_PRICES,
 | 
			
		||||
} from '../../helpers/constants';
 | 
			
		||||
import { ICommonConfiguration, eEthereumNetwork } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
| 
						 | 
				
			
			@ -87,6 +93,9 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    UNI: {
 | 
			
		||||
      borrowRate: oneRay.multipliedBy(0.03).toFixed(),
 | 
			
		||||
    },
 | 
			
		||||
    ENJ: {
 | 
			
		||||
      borrowRate: oneRay.multipliedBy(0.03).toFixed(),
 | 
			
		||||
    },
 | 
			
		||||
    BUSD: {
 | 
			
		||||
      borrowRate: oneRay.multipliedBy(0.05).toFixed(),
 | 
			
		||||
    },
 | 
			
		||||
| 
						 | 
				
			
			@ -129,21 +138,21 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
  ProviderRegistryOwner: {
 | 
			
		||||
    [eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '',
 | 
			
		||||
    [eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
 | 
			
		||||
    [eEthereumNetwork.main]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
 | 
			
		||||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '',
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
 | 
			
		||||
  },
 | 
			
		||||
  LendingRateOracle: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '',
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '',//'0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '', //'0xdCde9Bb6a49e37fA433990832AB541AE2d4FEB4a',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '0x05dcca805a6562c1bdd0423768754acb6993241b',
 | 
			
		||||
    [eEthereumNetwork.main]: '',//'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
 | 
			
		||||
    [eEthereumNetwork.main]: '', //'0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0x8A32f49FFbA88aba6EFF96F45D8BD1D4b3f35c7D',
 | 
			
		||||
  },  
 | 
			
		||||
  },
 | 
			
		||||
  LendingPoolCollateralManager: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '',
 | 
			
		||||
| 
						 | 
				
			
			@ -175,7 +184,7 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '',
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '0xf99b8E67a0E044734B01EC4586D1c88C9a869718',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '',
 | 
			
		||||
    [eEthereumNetwork.main]: '',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '',
 | 
			
		||||
| 
						 | 
				
			
			@ -193,9 +202,9 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '',
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '',//'0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
 | 
			
		||||
    [eEthereumNetwork.kovan]: '', //'0xB8bE51E6563BB312Cbb2aa26e352516c25c26ac1',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.main]: '',//'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
 | 
			
		||||
    [eEthereumNetwork.main]: '', //'0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9',
 | 
			
		||||
  },
 | 
			
		||||
  FallbackOracle: {
 | 
			
		||||
| 
						 | 
				
			
			@ -276,6 +285,7 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
      YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4',
 | 
			
		||||
      ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962',
 | 
			
		||||
      USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
 | 
			
		||||
      xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
 | 
			
		||||
    },
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: {
 | 
			
		||||
      AAVE: '0x6Df09E975c830ECae5bd4eD9d90f3A95a4f88012',
 | 
			
		||||
| 
						 | 
				
			
			@ -298,6 +308,7 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
      YFI: '0x7c5d4F8345e66f68099581Db340cd65B078C41f4',
 | 
			
		||||
      ZRX: '0x2Da4983a622a8498bb1a21FaE9D8F6C664939962',
 | 
			
		||||
      USD: '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419',
 | 
			
		||||
      xSUSHI: '0x9b26214bEC078E68a394AaEbfbffF406Ce14893F',
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  ReserveAssets: {
 | 
			
		||||
| 
						 | 
				
			
			@ -331,6 +342,15 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
  },
 | 
			
		||||
  WrappedNativeToken: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '', // deployed in local evm
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '', // deployed in local evm
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '', // deployed in local evm
 | 
			
		||||
    [eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
 | 
			
		||||
    [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
  },
 | 
			
		||||
  ReserveFactorTreasuryAddress: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
| 
						 | 
				
			
			@ -340,4 +360,13 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
  },
 | 
			
		||||
  IncentivesController: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.hardhat]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.kovan]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.ropsten]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.main]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,7 @@ import {
 | 
			
		|||
  strategyWETH,
 | 
			
		||||
  strategyYFI,
 | 
			
		||||
  strategyXSUSHI,
 | 
			
		||||
  strategyENJ,
 | 
			
		||||
} from './reservesConfigs';
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +39,7 @@ export const AaveConfig: IAaveConfiguration = {
 | 
			
		|||
    BAT: strategyBAT,
 | 
			
		||||
    BUSD: strategyBUSD,
 | 
			
		||||
    DAI: strategyDAI,
 | 
			
		||||
    ENJ: strategyREN,
 | 
			
		||||
    ENJ: strategyENJ,
 | 
			
		||||
    KNC: strategyKNC,
 | 
			
		||||
    LINK: strategyLINK,
 | 
			
		||||
    MANA: strategyMANA,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -139,14 +139,13 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.tenderlyMain]: '0x52D306e36E3B6B02c153d0266ff0f85d18BCD413',
 | 
			
		||||
  },
 | 
			
		||||
  ProviderRegistryOwner: {
 | 
			
		||||
    // DEPLOYED WITH CORRECT ADDRESS
 | 
			
		||||
    [eEthereumNetwork.kovan]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '',
 | 
			
		||||
    [eEthereumNetwork.main]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
 | 
			
		||||
    [eEthereumNetwork.main]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
 | 
			
		||||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '',
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xbd723fc4f1d737dcfc48a07fe7336766d34cad5f',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xB9062896ec3A615a4e4444DF183F0531a77218AE',
 | 
			
		||||
  },
 | 
			
		||||
  LendingRateOracle: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '',
 | 
			
		||||
| 
						 | 
				
			
			@ -326,6 +325,15 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
  },
 | 
			
		||||
  WrappedNativeToken: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '', // deployed in local evm
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '', // deployed in local evm
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: '', // deployed in local evm
 | 
			
		||||
    [eEthereumNetwork.kovan]: '0xd0a1e359811322d97991e03f863a0c30c2cf029c',
 | 
			
		||||
    [eEthereumNetwork.ropsten]: '0xc778417e063141139fce010982780140aa0cd5ab',
 | 
			
		||||
    [eEthereumNetwork.main]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
 | 
			
		||||
  },
 | 
			
		||||
  ReserveFactorTreasuryAddress: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.hardhat]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
| 
						 | 
				
			
			@ -335,4 +343,13 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [eEthereumNetwork.main]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',
 | 
			
		||||
  },
 | 
			
		||||
  IncentivesController: {
 | 
			
		||||
    [eEthereumNetwork.coverage]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.hardhat]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.buidlerevm]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.kovan]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.ropsten]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.main]: ZERO_ADDRESS,
 | 
			
		||||
    [eEthereumNetwork.tenderlyMain]: ZERO_ADDRESS,
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,11 @@
 | 
			
		|||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import { oneEther, oneRay, RAY, ZERO_ADDRESS, MOCK_CHAINLINK_AGGREGATORS_PRICES } from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  oneEther,
 | 
			
		||||
  oneRay,
 | 
			
		||||
  RAY,
 | 
			
		||||
  ZERO_ADDRESS,
 | 
			
		||||
  MOCK_CHAINLINK_AGGREGATORS_PRICES,
 | 
			
		||||
} from '../../helpers/constants';
 | 
			
		||||
import { ICommonConfiguration, ePolygonNetwork } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +55,10 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
      borrowRate: oneRay.multipliedBy(0.03).toFixed(),
 | 
			
		||||
    },
 | 
			
		||||
    WMATIC: {
 | 
			
		||||
      borrowRate: oneRay.multipliedBy(0.05).toFixed(), // TEMP
 | 
			
		||||
      borrowRate: oneRay.multipliedBy(0.05).toFixed(),
 | 
			
		||||
    },
 | 
			
		||||
    AAVE: {
 | 
			
		||||
      borrowRate: oneRay.multipliedBy(0.03).toFixed(),
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
  // ----------------
 | 
			
		||||
| 
						 | 
				
			
			@ -62,46 +71,46 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [ePolygonNetwork.matic]: undefined,
 | 
			
		||||
  },
 | 
			
		||||
  PoolAdminIndex: 0,
 | 
			
		||||
  EmergencyAdminIndex: 0,
 | 
			
		||||
  EmergencyAdmin: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: undefined,
 | 
			
		||||
    [ePolygonNetwork.matic]: undefined,
 | 
			
		||||
  },
 | 
			
		||||
  LendingPool: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0xABdC61Cd16e5111f335f4135B7A0e65Cc7F86327',
 | 
			
		||||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },
 | 
			
		||||
  LendingPoolConfigurator: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x17c4A170FFF882862F656597889016D3a6073534',
 | 
			
		||||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },
 | 
			
		||||
  EmergencyAdminIndex: 1,
 | 
			
		||||
  ProviderRegistry: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '0x569859d41499B4dDC28bfaA43915051FF0A38a6F', // TEMP
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x28334e4791860a0c1eCF89a62B973ba04a5d643F',  // TEMP
 | 
			
		||||
    [ePolygonNetwork.mumbai]: ZERO_ADDRESS,
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x3ac4e9aa29940770aeC38fe853a4bbabb2dA9C19',
 | 
			
		||||
  },
 | 
			
		||||
  ProviderRegistryOwner: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '0x18d9bA2baEfBdE0FF137C4ad031427EF205f1Fd9', // TEMP
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x85e4A467343c0dc4aDAB74Af84448D9c45D8ae6F',  // TEMP
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0xD7D86236d6c463521920fCC50A9CB56f8C8Bf008',
 | 
			
		||||
  },
 | 
			
		||||
  LendingRateOracle: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },  
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x17F73aEaD876CC4059089ff815EDA37052960dFB',
 | 
			
		||||
  },
 | 
			
		||||
  LendingPoolCollateralManager: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x9Af76e0575D139570D3B4c821567Fe935E8c25C5',
 | 
			
		||||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },
 | 
			
		||||
  TokenDistributor: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },
 | 
			
		||||
  WethGateway: {
 | 
			
		||||
  WethGateway: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x15A46f5073789b7D16F6F46632aE50Bae838d938',
 | 
			
		||||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },
 | 
			
		||||
  AaveOracle: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x1B38fa90596F2C25bCf1B193A6c6a718349AFDfC',
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x0229F777B0fAb107F9591a41d5F02E4e98dB6f2d',
 | 
			
		||||
  },
 | 
			
		||||
  FallbackOracle: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: ZERO_ADDRESS,
 | 
			
		||||
| 
						 | 
				
			
			@ -109,12 +118,13 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
  },
 | 
			
		||||
  ChainlinkAggregator: {
 | 
			
		||||
    [ePolygonNetwork.matic]: {
 | 
			
		||||
      DAI: '0x4746DeC9e833A82EC7C2C1356372CcF2cfcD2F3D',
 | 
			
		||||
      USDC: '0xfE4A8cc5b5B2366C1B58Bea3858e81843581b2F7',
 | 
			
		||||
      USDT: '0x0A6513e40db6EB1b165753AD52E80663aeA50545',
 | 
			
		||||
      WBTC: '0xc907E116054Ad103354f2D350FD2514433D57F6f',
 | 
			
		||||
      WETH: '0xF9680D99D6C9589e2a93a78A04A279e509205945',
 | 
			
		||||
      WMATIC: '0xAB594600376Ec9fD91F8e885dADF0CE036862dE0',
 | 
			
		||||
      AAVE: '0xbE23a3AA13038CfC28aFd0ECe4FdE379fE7fBfc4',
 | 
			
		||||
      DAI: '0xFC539A559e170f848323e19dfD66007520510085',
 | 
			
		||||
      USDC: '0xefb7e6be8356cCc6827799B6A7348eE674A80EaE',
 | 
			
		||||
      USDT: '0xf9d5AAC6E5572AEFa6bd64108ff86a222F69B64d',
 | 
			
		||||
      WBTC: '0xA338e0492B2F944E9F8C0653D3AD1484f2657a37',
 | 
			
		||||
      WMATIC: '0x327e23A4855b6F663a28c5161541d69Af8973302',
 | 
			
		||||
      USD: '0xF9680D99D6C9589e2a93a78A04A279e509205945',
 | 
			
		||||
    },
 | 
			
		||||
    [ePolygonNetwork.mumbai]: {
 | 
			
		||||
      DAI: ZERO_ADDRESS,
 | 
			
		||||
| 
						 | 
				
			
			@ -134,11 +144,19 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
    [ePolygonNetwork.matic]: '',
 | 
			
		||||
  },
 | 
			
		||||
  WETH: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889', // WMATIC address (untested)
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',  // WMATIC address
 | 
			
		||||
    [ePolygonNetwork.mumbai]: ZERO_ADDRESS,
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
 | 
			
		||||
  },
 | 
			
		||||
  WrappedNativeToken: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: ZERO_ADDRESS,
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
 | 
			
		||||
  },
 | 
			
		||||
  ReserveFactorTreasuryAddress: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',   // TEMP 
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x464c71f6c2f760dda6093dcb91c24c39e5d6e18c',    // TEMP  
 | 
			
		||||
    [ePolygonNetwork.mumbai]: ZERO_ADDRESS,
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x7734280A4337F37Fbf4651073Db7c28C80B339e9',
 | 
			
		||||
  },
 | 
			
		||||
  IncentivesController: {
 | 
			
		||||
    [ePolygonNetwork.mumbai]: ZERO_ADDRESS,
 | 
			
		||||
    [ePolygonNetwork.matic]: '0x357D51124f59836DeD84c8a1730D72B749d8BC23',
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,4 +1,3 @@
 | 
			
		|||
import { oneRay, ZERO_ADDRESS } from '../../helpers/constants';
 | 
			
		||||
import { IMaticConfiguration, ePolygonNetwork } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
import { CommonsConfig } from './commons';
 | 
			
		||||
| 
						 | 
				
			
			@ -9,6 +8,7 @@ import {
 | 
			
		|||
  strategyWBTC,
 | 
			
		||||
  strategyWETH,
 | 
			
		||||
  strategyMATIC,
 | 
			
		||||
  strategyAAVE,
 | 
			
		||||
} from './reservesConfigs';
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ import {
 | 
			
		|||
export const MaticConfig: IMaticConfiguration = {
 | 
			
		||||
  ...CommonsConfig,
 | 
			
		||||
  MarketId: 'Matic Market',
 | 
			
		||||
  ProviderId: 3,    // Unknown?
 | 
			
		||||
  ProviderId: 3, // Unknown?
 | 
			
		||||
  ReservesConfig: {
 | 
			
		||||
    DAI: strategyDAI,
 | 
			
		||||
    USDC: strategyUSDC,
 | 
			
		||||
| 
						 | 
				
			
			@ -26,6 +26,7 @@ export const MaticConfig: IMaticConfiguration = {
 | 
			
		|||
    WBTC: strategyWBTC,
 | 
			
		||||
    WETH: strategyWETH,
 | 
			
		||||
    WMATIC: strategyMATIC,
 | 
			
		||||
    AAVE: strategyAAVE,
 | 
			
		||||
  },
 | 
			
		||||
  ReserveAssets: {
 | 
			
		||||
    [ePolygonNetwork.matic]: {
 | 
			
		||||
| 
						 | 
				
			
			@ -35,8 +36,10 @@ export const MaticConfig: IMaticConfiguration = {
 | 
			
		|||
      WBTC: '0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6',
 | 
			
		||||
      WETH: '0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619',
 | 
			
		||||
      WMATIC: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270',
 | 
			
		||||
      AAVE: '0xD6DF932A45C0f255f85145f286eA0b292B21C90B',
 | 
			
		||||
    },
 | 
			
		||||
    [ePolygonNetwork.mumbai]: { // Mock tokens with a simple "mint" external function, except wmatic
 | 
			
		||||
    [ePolygonNetwork.mumbai]: {
 | 
			
		||||
      // Mock tokens with a simple "mint" external function, except wmatic
 | 
			
		||||
      DAI: '0x13b3fda609C1eeb23b4F4b69257840760dCa6C4a',
 | 
			
		||||
      USDC: '0x52b63223994433FdE2F1350Ba69Dfd2779f06ABA',
 | 
			
		||||
      USDT: '0xB3abd1912F586fDFFa13606882c28E27913853d2',
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,15 +1,13 @@
 | 
			
		|||
// import BigNumber from 'bignumber.js';
 | 
			
		||||
// import { oneRay } from '../../helpers/constants';
 | 
			
		||||
import { eContractid, IReserveParams } from '../../helpers/types';
 | 
			
		||||
import { 
 | 
			
		||||
  rateStrategyStableOne,
 | 
			
		||||
import {
 | 
			
		||||
  rateStrategyStableTwo,
 | 
			
		||||
  rateStrategyStableThree,
 | 
			
		||||
  rateStrategyWETH,
 | 
			
		||||
  rateStrategyAAVE,
 | 
			
		||||
  rateStrategyVolatileOne,
 | 
			
		||||
  rateStrategyVolatileTwo,
 | 
			
		||||
  rateStrategyVolatileThree,
 | 
			
		||||
} from './rateStrategies';
 | 
			
		||||
 | 
			
		||||
export const strategyDAI: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -18,10 +16,10 @@ export const strategyDAI: IReserveParams = {
 | 
			
		|||
  liquidationThreshold: '8000',
 | 
			
		||||
  liquidationBonus: '10500',
 | 
			
		||||
  borrowingEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000'
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -30,22 +28,22 @@ export const strategyUSDC: IReserveParams = {
 | 
			
		|||
  liquidationThreshold: '8500',
 | 
			
		||||
  liquidationBonus: '10500',
 | 
			
		||||
  borrowingEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000'
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyUSDT: IReserveParams = {
 | 
			
		||||
    strategy: rateStrategyStableThree,
 | 
			
		||||
    baseLTVAsCollateral: '8000',
 | 
			
		||||
    liquidationThreshold: '8500',
 | 
			
		||||
    liquidationBonus: '10500',
 | 
			
		||||
    borrowingEnabled: true,
 | 
			
		||||
    stableBorrowRateEnabled: true,
 | 
			
		||||
    reserveDecimals: '6',
 | 
			
		||||
    aTokenImpl: eContractid.AToken,
 | 
			
		||||
    reserveFactor: '1000'
 | 
			
		||||
  strategy: rateStrategyStableThree,
 | 
			
		||||
  baseLTVAsCollateral: '0',
 | 
			
		||||
  liquidationThreshold: '0',
 | 
			
		||||
  liquidationBonus: '0',
 | 
			
		||||
  borrowingEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '6',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWETH: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -54,10 +52,10 @@ export const strategyWETH: IReserveParams = {
 | 
			
		|||
  liquidationThreshold: '8250',
 | 
			
		||||
  liquidationBonus: '10500',
 | 
			
		||||
  borrowingEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '1000'
 | 
			
		||||
  reserveFactor: '1000',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyWBTC: IReserveParams = {
 | 
			
		||||
| 
						 | 
				
			
			@ -66,20 +64,32 @@ export const strategyWBTC: IReserveParams = {
 | 
			
		|||
  liquidationThreshold: '7500',
 | 
			
		||||
  liquidationBonus: '11000',
 | 
			
		||||
  borrowingEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '8',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000'
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyMATIC: IReserveParams = {
 | 
			
		||||
  strategy: rateStrategyVolatileOne,    //Temp?
 | 
			
		||||
  strategy: rateStrategyVolatileOne, //Temp?
 | 
			
		||||
  baseLTVAsCollateral: '5000',
 | 
			
		||||
  liquidationThreshold: '6500',
 | 
			
		||||
  liquidationBonus: '11000',
 | 
			
		||||
  borrowingEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: true,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '2000'
 | 
			
		||||
};
 | 
			
		||||
  reserveFactor: '2000',
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const strategyAAVE: IReserveParams = {
 | 
			
		||||
  strategy: rateStrategyAAVE,
 | 
			
		||||
  baseLTVAsCollateral: '5000',
 | 
			
		||||
  liquidationThreshold: '6500',
 | 
			
		||||
  liquidationBonus: '11000',
 | 
			
		||||
  borrowingEnabled: false,
 | 
			
		||||
  stableBorrowRateEnabled: false,
 | 
			
		||||
  reserveDecimals: '18',
 | 
			
		||||
  aTokenImpl: eContractid.AToken,
 | 
			
		||||
  reserveFactor: '0',
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,11 @@
 | 
			
		|||
import BigNumber from 'bignumber.js';
 | 
			
		||||
import { oneEther, oneRay, RAY, ZERO_ADDRESS, MOCK_CHAINLINK_AGGREGATORS_PRICES } from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  oneEther,
 | 
			
		||||
  oneRay,
 | 
			
		||||
  RAY,
 | 
			
		||||
  ZERO_ADDRESS,
 | 
			
		||||
  MOCK_CHAINLINK_AGGREGATORS_PRICES,
 | 
			
		||||
} from '../../helpers/constants';
 | 
			
		||||
import { ICommonConfiguration, eXDaiNetwork } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
// ----------------
 | 
			
		||||
| 
						 | 
				
			
			@ -79,14 +85,14 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
  },
 | 
			
		||||
  LendingRateOracle: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '',
 | 
			
		||||
  },  
 | 
			
		||||
  },
 | 
			
		||||
  LendingPoolCollateralManager: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '',
 | 
			
		||||
  },
 | 
			
		||||
  TokenDistributor: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '',
 | 
			
		||||
  },
 | 
			
		||||
  WethGateway: {
 | 
			
		||||
  WethGateway: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '',
 | 
			
		||||
  },
 | 
			
		||||
  AaveOracle: {
 | 
			
		||||
| 
						 | 
				
			
			@ -114,7 +120,13 @@ export const CommonsConfig: ICommonConfiguration = {
 | 
			
		|||
  WETH: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI
 | 
			
		||||
  },
 | 
			
		||||
  WrappedNativeToken: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '', // DAI: xDAI is the base token, DAI is also there, We need WXDAI
 | 
			
		||||
  },
 | 
			
		||||
  ReserveFactorTreasuryAddress: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: '',   // TEMP 
 | 
			
		||||
    [eXDaiNetwork.xdai]: '', // TEMP
 | 
			
		||||
  },
 | 
			
		||||
  IncentivesController: {
 | 
			
		||||
    [eXDaiNetwork.xdai]: ZERO_ADDRESS,
 | 
			
		||||
  },
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										7618
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7618
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										88
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										88
									
								
								package.json
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -11,49 +11,53 @@
 | 
			
		|||
    "hardhat": "hardhat",
 | 
			
		||||
    "hardhat:kovan": "hardhat --network kovan",
 | 
			
		||||
    "hardhat:tenderly-main": "hardhat --network tenderlyMain",
 | 
			
		||||
    "hardhat:ropsten": "hardhat--network ropsten",
 | 
			
		||||
    "hardhat:ropsten": "hardhat --network ropsten",
 | 
			
		||||
    "hardhat:main": "hardhat --network main",
 | 
			
		||||
    "hardhat:docker": "hardhat --network hardhatevm_docker",
 | 
			
		||||
    "hardhat:mumbai": "hardhat --network mumbai",
 | 
			
		||||
    "hardhat:matic": "hardhat --network matic",
 | 
			
		||||
    "compile": "SKIP_LOAD=true hardhat compile",
 | 
			
		||||
    "console:fork": "MAINNET_FORK=true hardhat console",
 | 
			
		||||
    "test": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-aave/*.spec.ts",
 | 
			
		||||
    "test-amm": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-amm/*.spec.ts",
 | 
			
		||||
    "test-amm-scenarios": "TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-amm/__setup.spec.ts test-suites/test-amm/scenario.spec.ts",
 | 
			
		||||
    "test-scenarios": "npx hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/scenario.spec.ts",
 | 
			
		||||
    "test-repay-with-collateral": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/repay-with-collateral.spec.ts",
 | 
			
		||||
    "test-liquidate-with-collateral": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/flash-liquidation-with-collateral.spec.ts",
 | 
			
		||||
    "test-liquidate-underlying": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/liquidation-underlying.spec.ts",
 | 
			
		||||
    "test-configurator": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/configurator.spec.ts",
 | 
			
		||||
    "test-transfers": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/atoken-transfer.spec.ts",
 | 
			
		||||
    "test-flash": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/flashloan.spec.ts",
 | 
			
		||||
    "test-liquidate": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/liquidation-atoken.spec.ts",
 | 
			
		||||
    "test-deploy": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/test-init.spec.ts",
 | 
			
		||||
    "test-pausable": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/pausable-functions.spec.ts",
 | 
			
		||||
    "test-permit": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/atoken-permit.spec.ts",
 | 
			
		||||
    "test-stable-and-atokens": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/atoken-transfer.spec.ts test-suites/test-aave/stable-token.spec.ts",
 | 
			
		||||
    "test-subgraph:scenarios": "hardhat --network hardhatevm_docker test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/subgraph-scenarios.spec.ts",
 | 
			
		||||
    "test-weth:main": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/weth-gateway.spec.ts",
 | 
			
		||||
    "test-weth:amm": "hardhat test test-suites/test-amm/__setup.spec.ts test-suites/test-amm/weth-gateway.spec.ts",
 | 
			
		||||
    "test-uniswap": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/uniswapAdapters*.spec.ts",
 | 
			
		||||
    "test-paraswap": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/paraswapAdapters*.spec.ts",
 | 
			
		||||
    "test:main:check-list": "MAINNET_FORK=true TS_NODE_TRANSPILE_ONLY=1 hardhat test  test-suites/test-aave/__setup.spec.ts test-suites/test-aave/mainnet/check-list.spec.ts",
 | 
			
		||||
    "console:fork": "FORK=main hardhat console",
 | 
			
		||||
    "test": "npm run compile && TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-aave/*.spec.ts",
 | 
			
		||||
    "test-amm": "npm run compile && TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-amm/*.spec.ts",
 | 
			
		||||
    "test-amm-scenarios": "npm run compile && TS_NODE_TRANSPILE_ONLY=1 hardhat test ./test-suites/test-amm/__setup.spec.ts test-suites/test-amm/scenario.spec.ts",
 | 
			
		||||
    "test-scenarios": "npm run compile && npx hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/scenario.spec.ts",
 | 
			
		||||
    "test-subgraph:scenarios": "npm run compile && hardhat --network hardhatevm_docker test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/subgraph-scenarios.spec.ts",
 | 
			
		||||
    "test:main:check-list": "npm run compile && FORK=main TS_NODE_TRANSPILE_ONLY=1 hardhat test  test-suites/test-aave/__setup.spec.ts test-suites/test-aave/mainnet/check-list.spec.ts",
 | 
			
		||||
    "dev:coverage": "buidler compile --force && buidler coverage --network coverage",
 | 
			
		||||
    "aave:evm:dev:migration": "npm run compile && hardhat aave:dev",
 | 
			
		||||
    "aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet",
 | 
			
		||||
    "aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet --verify",
 | 
			
		||||
    "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai matic:mainnet",
 | 
			
		||||
    "matic:matic:full:migration": "npm run compile && npm run hardhat:matic matic:mainnet",
 | 
			
		||||
    "amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --verify",
 | 
			
		||||
    "aave:docker:full:migration": "npm run compile && npm run hardhat:docker -- aave:mainnet --skip-registry",
 | 
			
		||||
    "aave:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- aave:mainnet --skip-registry",
 | 
			
		||||
    "matic:mumbai:full:migration": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic --skip-registry",
 | 
			
		||||
    "matic:matic:full:migration": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic --skip-registry",
 | 
			
		||||
    "amm:kovan:full:migration": "npm run compile && npm run hardhat:kovan -- amm:mainnet --skip-registry",
 | 
			
		||||
    "aave:docker:full:migration:add-registry": "npm run compile && npm run hardhat:docker -- aave:mainnet",
 | 
			
		||||
    "aave:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- aave:mainnet",
 | 
			
		||||
    "matic:mumbai:full:migration:add-registry": "npm run compile && npm run hardhat:mumbai sidechain:mainnet -- --pool Matic",
 | 
			
		||||
    "matic:matic:full:migration:add-registry": "npm run compile && npm run hardhat:matic sidechain:mainnet -- --pool Matic",
 | 
			
		||||
    "amm:kovan:full:migration:add-registry": "npm run compile && npm run hardhat:kovan -- amm:mainnet",
 | 
			
		||||
    "aave:docker:add-market-to-registry-from-config": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave",
 | 
			
		||||
    "aave:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave",
 | 
			
		||||
    "matic:mumbai:add-market-to-registry-from-config": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic",
 | 
			
		||||
    "amm:kovan:add-market-to-registry-from-config": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Amm",
 | 
			
		||||
    "matic:matic:add-market-to-registry-from-config": "npm run compile && npm run hardhat:matic add-market-to-registry --pool Matic",
 | 
			
		||||
    "aave:main:add-market-to-registry-from-config": "npm run compile && npm run hardhat:main -- add-market-to-registry --pool Aave",
 | 
			
		||||
    "aave:docker:add-market-to-new-registry": "npm run compile && npm run hardhat:docker -- add-market-to-registry --pool Aave --deploy-registry",
 | 
			
		||||
    "aave:kovan:add-market-to-new-registry": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Aave --verify --deploy-registry",
 | 
			
		||||
    "matic:mumbai:add-market-to-new-registry": "npm run compile && npm run hardhat:mumbai add-market-to-registry --pool Matic --verify --deploy-registry",
 | 
			
		||||
    "amm:kovan:add-market-to-new-registry": "npm run compile && npm run hardhat:kovan -- add-market-to-registry --pool Amm --verify --deploy-registry",
 | 
			
		||||
    "matic:matic:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry",
 | 
			
		||||
    "aave:main:add-market-to-new-registry": "npm run compile && npm run hardhat:matic -- add-market-to-registry --pool Matic --verify --deploy-registry",
 | 
			
		||||
    "aave:kovan:full:initialize": "npm run hardhat:kovan -- full:initialize-lending-pool --verify --pool Aave",
 | 
			
		||||
    "aave:ropsten:full:migration": "npm run compile && npm run hardhat:ropsten -- aave:mainnet --verify",
 | 
			
		||||
    "aave:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- aave:mainnet",
 | 
			
		||||
    "aave:fork:main": "npm run compile && MAINNET_FORK=true hardhat aave:mainnet",
 | 
			
		||||
    "amm:fork:main": "npm run compile && MAINNET_FORK=true hardhat amm:mainnet",
 | 
			
		||||
    "aave:fork:main": "npm run compile && FORK=main hardhat aave:mainnet",
 | 
			
		||||
    "aave:fork:kovan": "npm run compile && FORK=kovan hardhat aave:mainnet",
 | 
			
		||||
    "amm:fork:main": "npm run compile && FORK=main hardhat amm:mainnet",
 | 
			
		||||
    "amm:fork:kovan": "npm run compile && FORK=kovan hardhat amm:mainnet",
 | 
			
		||||
    "amm:fork:main:tenderly": "npm run compile && npm run hardhat:tenderly-main -- amm:mainnet",
 | 
			
		||||
    "aave:main:full:migration": "npm run compile && npm run hardhat:main -- aave:mainnet --verify",
 | 
			
		||||
    "aave:main:full:initialize": "npm run compile && MAINNET_FORK=true full:initialize-tokens --pool Aave",
 | 
			
		||||
    "aave:main:full:initialize": "npm run compile && FORK=main full:initialize-tokens --pool Aave",
 | 
			
		||||
    "amm:main:full:migration": "npm run compile && npm run hardhat:main -- amm:mainnet --verify",
 | 
			
		||||
    "prettier:check": "npx prettier -c 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts'  'test-suites/test-aave/**/*.ts'",
 | 
			
		||||
    "prettier:write": "prettier --write 'tasks/**/*.ts' 'contracts/**/*.sol' 'helpers/**/*.ts'  'test-suites/test-aave/**/*.ts'",
 | 
			
		||||
| 
						 | 
				
			
			@ -62,7 +66,10 @@
 | 
			
		|||
    "print-contracts:kovan": "npm run hardhat:kovan -- print-contracts",
 | 
			
		||||
    "print-contracts:main": "npm run hardhat:main -- print-contracts",
 | 
			
		||||
    "print-contracts:ropsten": "npm run hardhat:main -- print-contracts",
 | 
			
		||||
    "dev:deployUIProvider": "npm run hardhat:kovan deploy-UiPoolDataProvider",
 | 
			
		||||
    "dev:deployUIProvider": "hardhat --network kovan deploy-UiPoolDataProvider --verify",
 | 
			
		||||
    "main:deployUIProvider": "hardhat --network main deploy-UiPoolDataProvider --verify",
 | 
			
		||||
    "matic:deployUIProvider": "hardhat --network matic deploy-UiPoolDataProvider",
 | 
			
		||||
    "mumbai:deployUIProvider": "hardhat --network mumbai deploy-UiPoolDataProvider",
 | 
			
		||||
    "dev:deployUniswapRepayAdapter": "hardhat --network kovan deploy-UniswapRepayAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c",
 | 
			
		||||
    "dev:UniswapLiquiditySwapAdapter": "hardhat --network kovan deploy-UniswapLiquiditySwapAdapter --provider 0x88757f2f99175387aB4C6a4b3067c77A695b0349 --router 0xfcd87315f0e4067070ade8682fcdbc3006631441 --weth 0xd0a1e359811322d97991e03f863a0c30c2cf029c",
 | 
			
		||||
    "main:deployUniswapRepayAdapter": "hardhat --network main deploy-UniswapRepayAdapter --provider 0xB53C1a33016B2DC2fF3653530bfF1848a515c8c5 --router 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D --weth 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
 | 
			
		||||
| 
						 | 
				
			
			@ -71,14 +78,15 @@
 | 
			
		|||
    "kovan:verify": "npm run hardhat:kovan verify:general -- --all --pool Aave",
 | 
			
		||||
    "ropsten:verify": "npm run hardhat:ropsten verify:general -- --all --pool Aave",
 | 
			
		||||
    "mainnet:verify": "npm run hardhat:main verify:general -- --all --pool Aave",
 | 
			
		||||
    "matic:mumbai:verify": "npm run hardhat:mumbai verify:general -- --all --pool Matic",
 | 
			
		||||
    "matic:mainnet:verify": "npm run hardhat:matic verify:general -- --all --pool Matic",
 | 
			
		||||
    "matic:mumbai:verify:tokens": "npm run hardhat:mumbai verify:tokens -- --pool Matic",
 | 
			
		||||
    "matic:mainnet:verify:tokens": "npm run hardhat:matic verify:tokens -- --pool Matic",
 | 
			
		||||
    "kovan:verify:tokens": "npm run hardhat:kovan verify:tokens -- --pool Aave",
 | 
			
		||||
    "ropsten:verify:tokens": "npm run hardhat:ropsten verify:tokens -- --pool Aave",
 | 
			
		||||
    "mainnet:verify:tokens": "npm run hardhat:main verify:tokens -- --pool Aave",
 | 
			
		||||
    "print-config:fork:mainnet": "MAINNET_FORK=true hardhat print-config:fork",
 | 
			
		||||
    "print-config:fork:mainnet": "FORK=main hardhat print-config:fork",
 | 
			
		||||
    "print-config:kovan": "hardhat --network kovan print-config --pool Aave --data-provider 0xA1901785c29cBd48bfA74e46b67C736b26054fa4",
 | 
			
		||||
    "main:fork:initialize-tokens": "npm run compile && MAINNET_FORK=true hardhat full:initialize-tokens --pool Aave",
 | 
			
		||||
    "main:initialize-tokens": "npm run compile && hardhat --network main full:initialize-tokens --pool Aave",
 | 
			
		||||
    "kovan:initialize-tokens": "npm run compile && hardhat --network kovan full:initialize-tokens --pool Aave",
 | 
			
		||||
    "external:deploy-assets-kovan": "npm run compile && hardhat --network kovan external:deploy-new-asset --symbol ${SYMBOL} --verify",
 | 
			
		||||
    "external:deploy-assets-main": "npm run compile && hardhat --network main external:deploy-new-asset --symbol ${SYMBOL} --verify",
 | 
			
		||||
    "prepublishOnly": "npm run compile"
 | 
			
		||||
| 
						 | 
				
			
			@ -91,7 +99,7 @@
 | 
			
		|||
    "@nomiclabs/hardhat-ethers": "^2.0.0",
 | 
			
		||||
    "@nomiclabs/hardhat-waffle": "^2.0.0",
 | 
			
		||||
    "@openzeppelin/contracts": "3.1.0",
 | 
			
		||||
    "@tenderly/hardhat-tenderly": "^1.1.0-beta.4",
 | 
			
		||||
    "@tenderly/hardhat-tenderly": "1.1.0-beta.5",
 | 
			
		||||
    "@typechain/ethers-v4": "1.0.0",
 | 
			
		||||
    "@typechain/ethers-v5": "^2.0.0",
 | 
			
		||||
    "@typechain/truffle-v4": "2.0.2",
 | 
			
		||||
| 
						 | 
				
			
			@ -106,13 +114,14 @@
 | 
			
		|||
    "chai": "4.2.0",
 | 
			
		||||
    "chai-bignumber": "3.0.0",
 | 
			
		||||
    "chai-bn": "^0.2.1",
 | 
			
		||||
    "defender-relay-client": "^1.7.0",
 | 
			
		||||
    "dotenv": "^8.2.0",
 | 
			
		||||
    "eth-sig-util": "2.5.3",
 | 
			
		||||
    "ethereum-waffle": "3.0.2",
 | 
			
		||||
    "ethereumjs-util": "7.0.2",
 | 
			
		||||
    "ethers": "^5.0.19",
 | 
			
		||||
    "globby": "^11.0.1",
 | 
			
		||||
    "hardhat": "^2.0.8",
 | 
			
		||||
    "hardhat": "^2.2.0",
 | 
			
		||||
    "hardhat-gas-reporter": "^1.0.0",
 | 
			
		||||
    "hardhat-typechain": "^0.3.3",
 | 
			
		||||
    "husky": "^4.2.5",
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +129,7 @@
 | 
			
		|||
    "prettier": "^2.0.5",
 | 
			
		||||
    "prettier-plugin-solidity": "^1.0.0-alpha.53",
 | 
			
		||||
    "pretty-quick": "^2.0.1",
 | 
			
		||||
    "solidity-coverage": "0.7.10",
 | 
			
		||||
    "solidity-coverage": "^0.7.16",
 | 
			
		||||
    "temp-hardhat-etherscan": "^2.0.2",
 | 
			
		||||
    "ts-generator": "^0.1.1",
 | 
			
		||||
    "ts-node": "^8.10.2",
 | 
			
		||||
| 
						 | 
				
			
			@ -146,6 +155,7 @@
 | 
			
		|||
  ],
 | 
			
		||||
  "license": "AGPLv3",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "axios-curlirize": "^1.3.7",
 | 
			
		||||
    "tmp-promise": "^3.0.2"
 | 
			
		||||
  },
 | 
			
		||||
  "keywords": [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										96
									
								
								tasks/deployments/add-market-to-registry.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										96
									
								
								tasks/deployments/add-market-to-registry.ts
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,96 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { waitForTx } from '../../helpers/misc-utils';
 | 
			
		||||
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
 | 
			
		||||
import { eNetwork } from '../../helpers/types';
 | 
			
		||||
import {
 | 
			
		||||
  getFirstSigner,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { isAddress, parseEther } from 'ethers/lib/utils';
 | 
			
		||||
import { isZeroAddress } from 'ethereumjs-util';
 | 
			
		||||
import { Signer } from 'ethers';
 | 
			
		||||
import { exit } from 'process';
 | 
			
		||||
 | 
			
		||||
task('add-market-to-registry', 'Adds address provider to registry')
 | 
			
		||||
  .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
 | 
			
		||||
  .addOptionalParam('addressesProvider', `Address of LendingPoolAddressProvider`)
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .addFlag('deployRegistry', 'Deploy a new address provider registry')
 | 
			
		||||
  .setAction(async ({ verify, addressesProvider, pool, deployRegistry }, DRE) => {
 | 
			
		||||
    await DRE.run('set-DRE');
 | 
			
		||||
    let signer: Signer;
 | 
			
		||||
    const network = <eNetwork>DRE.network.name;
 | 
			
		||||
    const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
    const { ProviderId } = poolConfig;
 | 
			
		||||
 | 
			
		||||
    let providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
 | 
			
		||||
    let providerRegistryOwner = getParamPerNetwork(poolConfig.ProviderRegistryOwner, network);
 | 
			
		||||
    const currentSignerAddress = await (
 | 
			
		||||
      await (await getFirstSigner()).getAddress()
 | 
			
		||||
    ).toLocaleLowerCase();
 | 
			
		||||
    let deployed = false;
 | 
			
		||||
 | 
			
		||||
    if (
 | 
			
		||||
      deployRegistry ||
 | 
			
		||||
      !providerRegistryAddress ||
 | 
			
		||||
      !isAddress(providerRegistryAddress) ||
 | 
			
		||||
      isZeroAddress(providerRegistryAddress)
 | 
			
		||||
    ) {
 | 
			
		||||
      console.log('- Deploying a new Address Providers Registry:');
 | 
			
		||||
 | 
			
		||||
      await DRE.run('full:deploy-address-provider-registry', { verify });
 | 
			
		||||
 | 
			
		||||
      providerRegistryAddress = (await getLendingPoolAddressesProviderRegistry()).address;
 | 
			
		||||
      providerRegistryOwner = await (await getFirstSigner()).getAddress();
 | 
			
		||||
      deployed = true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (
 | 
			
		||||
      !providerRegistryOwner ||
 | 
			
		||||
      !isAddress(providerRegistryOwner) ||
 | 
			
		||||
      isZeroAddress(providerRegistryOwner)
 | 
			
		||||
    ) {
 | 
			
		||||
      throw Error('config.ProviderRegistryOwner is missing or is not an address.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Checks if deployer address is registry owner
 | 
			
		||||
    if (process.env.FORK) {
 | 
			
		||||
      await DRE.network.provider.request({
 | 
			
		||||
        method: 'hardhat_impersonateAccount',
 | 
			
		||||
        params: [providerRegistryOwner],
 | 
			
		||||
      });
 | 
			
		||||
      signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
 | 
			
		||||
      const firstAccount = await getFirstSigner();
 | 
			
		||||
      await firstAccount.sendTransaction({ value: parseEther('10'), to: providerRegistryOwner });
 | 
			
		||||
    } else if (
 | 
			
		||||
      !deployed &&
 | 
			
		||||
      providerRegistryOwner.toLocaleLowerCase() !== currentSignerAddress.toLocaleLowerCase()
 | 
			
		||||
    ) {
 | 
			
		||||
      console.error('ProviderRegistryOwner config does not match current signer:');
 | 
			
		||||
      console.error('Expected:', providerRegistryOwner);
 | 
			
		||||
      console.error('Current:', currentSignerAddress);
 | 
			
		||||
      exit(2);
 | 
			
		||||
    } else {
 | 
			
		||||
      signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 1. Address Provider Registry instance
 | 
			
		||||
    const addressesProviderRegistry = (
 | 
			
		||||
      await getLendingPoolAddressesProviderRegistry(providerRegistryAddress)
 | 
			
		||||
    ).connect(signer);
 | 
			
		||||
 | 
			
		||||
    const addressesProviderInstance = await getLendingPoolAddressesProvider(addressesProvider);
 | 
			
		||||
 | 
			
		||||
    // 2. Set the provider at the Registry
 | 
			
		||||
    await waitForTx(
 | 
			
		||||
      await addressesProviderRegistry.registerAddressesProvider(
 | 
			
		||||
        addressesProviderInstance.address,
 | 
			
		||||
        ProviderId
 | 
			
		||||
      )
 | 
			
		||||
    );
 | 
			
		||||
    console.log(
 | 
			
		||||
      `Added LendingPoolAddressesProvider with address "${addressesProviderInstance.address}" to registry located at ${addressesProviderRegistry.address}`
 | 
			
		||||
    );
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
 | 
			
		||||
import { ParaSwapLiquiditySwapAdapterFactory } from '../../types';
 | 
			
		||||
import { verifyContract } from '../../helpers/etherscan-verification';
 | 
			
		||||
import { verifyContract } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { getFirstSigner } from '../../helpers/contracts-getters';
 | 
			
		||||
import { eContractid } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
const CONTRACT_NAME = 'ParaSwapLiquiditySwapAdapter';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +24,13 @@ task(`deploy-${CONTRACT_NAME}`, `Deploys the ${CONTRACT_NAME} contract`)
 | 
			
		|||
    ).deploy(provider, augustusRegistry);
 | 
			
		||||
    await adapter.deployTransaction.wait();
 | 
			
		||||
    console.log(`${CONTRACT_NAME}.address`, adapter.address);
 | 
			
		||||
    await verifyContract(adapter.address, [provider, augustusRegistry]);
 | 
			
		||||
 | 
			
		||||
    if (verify) {
 | 
			
		||||
      await verifyContract(eContractid.ParaSwapLiquiditySwapAdapter, adapter, [
 | 
			
		||||
        provider,
 | 
			
		||||
        augustusRegistry,
 | 
			
		||||
      ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log(`\tFinished ${CONTRACT_NAME} deployment`);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,27 +1,56 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
 | 
			
		||||
import { UiPoolDataProviderFactory } from '../../types';
 | 
			
		||||
import { verifyContract } from '../../helpers/etherscan-verification';
 | 
			
		||||
import { eContractid } from '../../helpers/types';
 | 
			
		||||
import { eContractid, eEthereumNetwork, eNetwork, ePolygonNetwork } from '../../helpers/types';
 | 
			
		||||
import { deployUiPoolDataProvider } from '../../helpers/contracts-deployments';
 | 
			
		||||
import { exit } from 'process';
 | 
			
		||||
 | 
			
		||||
task(`deploy-${eContractid.UiPoolDataProvider}`, `Deploys the UiPoolDataProvider contract`)
 | 
			
		||||
  .addFlag('verify', 'Verify UiPoolDataProvider contract via Etherscan API.')
 | 
			
		||||
  .setAction(async ({ verify }, localBRE) => {
 | 
			
		||||
    await localBRE.run('set-DRE');
 | 
			
		||||
 | 
			
		||||
    if (!localBRE.network.config.chainId) {
 | 
			
		||||
      throw new Error('INVALID_CHAIN_ID');
 | 
			
		||||
    }
 | 
			
		||||
    const network = localBRE.network.name;
 | 
			
		||||
 | 
			
		||||
    const addressesByNetwork: {
 | 
			
		||||
      [key: string]: { incentivesController: string; aaveOracle: string };
 | 
			
		||||
    } = {
 | 
			
		||||
      [eEthereumNetwork.kovan]: {
 | 
			
		||||
        incentivesController: '0x0000000000000000000000000000000000000000',
 | 
			
		||||
        aaveOracle: '0x8fb777d67e9945e2c01936e319057f9d41d559e6',
 | 
			
		||||
      },
 | 
			
		||||
      [eEthereumNetwork.main]: {
 | 
			
		||||
        incentivesController: '0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5',
 | 
			
		||||
        aaveOracle: '0xa50ba011c48153de246e5192c8f9258a2ba79ca9',
 | 
			
		||||
      },
 | 
			
		||||
      [ePolygonNetwork.matic]: {
 | 
			
		||||
        incentivesController: '0x357D51124f59836DeD84c8a1730D72B749d8BC23',
 | 
			
		||||
        aaveOracle: '0x21451bD7b528896B4AB2b9764b521D6ed641708d',
 | 
			
		||||
      },
 | 
			
		||||
      [ePolygonNetwork.mumbai]: {
 | 
			
		||||
        incentivesController: '0xd41aE58e803Edf4304334acCE4DC4Ec34a63C644',
 | 
			
		||||
        aaveOracle: '0xC365C653f7229894F93994CD0b30947Ab69Ff1D5',
 | 
			
		||||
      },
 | 
			
		||||
    };
 | 
			
		||||
    const supportedNetworks = Object.keys(addressesByNetwork);
 | 
			
		||||
 | 
			
		||||
    if (!supportedNetworks.includes(network)) {
 | 
			
		||||
      console.error(
 | 
			
		||||
        `[task][error] Network "${network}" not supported, please use one of: ${supportedNetworks.join()}`
 | 
			
		||||
      );
 | 
			
		||||
      exit(2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const oracle = addressesByNetwork[network].aaveOracle;
 | 
			
		||||
    const incentivesController = addressesByNetwork[network].aaveOracle;
 | 
			
		||||
 | 
			
		||||
    console.log(`\n- UiPoolDataProvider deployment`);
 | 
			
		||||
 | 
			
		||||
    console.log(`\tDeploying UiPoolDataProvider implementation ...`);
 | 
			
		||||
    const uiPoolDataProvider = await new UiPoolDataProviderFactory(
 | 
			
		||||
      await localBRE.ethers.provider.getSigner()
 | 
			
		||||
    ).deploy();
 | 
			
		||||
    await uiPoolDataProvider.deployTransaction.wait();
 | 
			
		||||
    console.log('uiPoolDataProvider.address', uiPoolDataProvider.address);
 | 
			
		||||
    await verifyContract(uiPoolDataProvider.address, []);
 | 
			
		||||
    const uiPoolDataProvider = await deployUiPoolDataProvider(
 | 
			
		||||
      [incentivesController, oracle],
 | 
			
		||||
      verify
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    console.log(`\tFinished UiPoolDataProvider proxy and implementation deployment`);
 | 
			
		||||
    console.log('UiPoolDataProvider deployed at:', uiPoolDataProvider.address);
 | 
			
		||||
    console.log(`\tFinished UiPoolDataProvider deployment`);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
 | 
			
		||||
import { UniswapLiquiditySwapAdapterFactory } from '../../types';
 | 
			
		||||
import { verifyContract } from '../../helpers/etherscan-verification';
 | 
			
		||||
import { verifyContract } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { getFirstSigner } from '../../helpers/contracts-getters';
 | 
			
		||||
import { eContractid } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
const CONTRACT_NAME = 'UniswapLiquiditySwapAdapter';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +30,14 @@ task(`deploy-${CONTRACT_NAME}`, `Deploys the ${CONTRACT_NAME} contract`)
 | 
			
		|||
    ).deploy(provider, router, weth);
 | 
			
		||||
    await uniswapRepayAdapter.deployTransaction.wait();
 | 
			
		||||
    console.log(`${CONTRACT_NAME}.address`, uniswapRepayAdapter.address);
 | 
			
		||||
    await verifyContract(uniswapRepayAdapter.address, [provider, router, weth]);
 | 
			
		||||
 | 
			
		||||
    if (verify) {
 | 
			
		||||
      await verifyContract(eContractid.UniswapLiquiditySwapAdapter, uniswapRepayAdapter, [
 | 
			
		||||
        provider,
 | 
			
		||||
        router,
 | 
			
		||||
        weth,
 | 
			
		||||
      ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log(`\tFinished ${CONTRACT_NAME} proxy and implementation deployment`);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,9 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
 | 
			
		||||
import { UniswapRepayAdapterFactory } from '../../types';
 | 
			
		||||
import { verifyContract } from '../../helpers/etherscan-verification';
 | 
			
		||||
import { verifyContract } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { getFirstSigner } from '../../helpers/contracts-getters';
 | 
			
		||||
import { eContractid } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
const CONTRACT_NAME = 'UniswapRepayAdapter';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +31,14 @@ task(`deploy-${CONTRACT_NAME}`, `Deploys the ${CONTRACT_NAME} contract`)
 | 
			
		|||
    );
 | 
			
		||||
    await uniswapRepayAdapter.deployTransaction.wait();
 | 
			
		||||
    console.log(`${CONTRACT_NAME}.address`, uniswapRepayAdapter.address);
 | 
			
		||||
    await verifyContract(uniswapRepayAdapter.address, [provider, router, weth]);
 | 
			
		||||
 | 
			
		||||
    if (verify) {
 | 
			
		||||
      await verifyContract(eContractid.UniswapRepayAdapter, uniswapRepayAdapter, [
 | 
			
		||||
        provider,
 | 
			
		||||
        router,
 | 
			
		||||
        weth,
 | 
			
		||||
      ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log(
 | 
			
		||||
      `\tFinished ${CONTRACT_NAME}${CONTRACT_NAME}lDataProvider proxy and implementation deployment`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ import {
 | 
			
		|||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
  deployLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import { getEthersSigners } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { waitForTx } from '../../helpers/misc-utils';
 | 
			
		||||
import { AaveConfig } from '../../markets/aave';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -14,10 +15,11 @@ task(
 | 
			
		|||
  .setAction(async ({ verify }, localBRE) => {
 | 
			
		||||
    await localBRE.run('set-DRE');
 | 
			
		||||
 | 
			
		||||
    const admin = await (await localBRE.ethers.getSigners())[0].getAddress();
 | 
			
		||||
    const admin = await (await getEthersSigners())[0].getAddress();
 | 
			
		||||
 | 
			
		||||
    const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId, verify);
 | 
			
		||||
    await waitForTx(await addressesProvider.setPoolAdmin(admin));
 | 
			
		||||
    await waitForTx(await addressesProvider.setEmergencyAdmin(admin));
 | 
			
		||||
 | 
			
		||||
    const addressesProviderRegistry = await deployLendingPoolAddressesProviderRegistry(verify);
 | 
			
		||||
    await waitForTx(
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,6 @@ import {
 | 
			
		|||
  deployMockFlashLoanReceiver,
 | 
			
		||||
  deployWalletBalancerProvider,
 | 
			
		||||
  deployAaveProtocolDataProvider,
 | 
			
		||||
  deployWETHGateway,
 | 
			
		||||
  authorizeWETHGateway,
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
| 
						 | 
				
			
			@ -13,18 +12,18 @@ import {
 | 
			
		|||
  ConfigNames,
 | 
			
		||||
  getReservesConfigByPool,
 | 
			
		||||
  getTreasuryAddress,
 | 
			
		||||
  getWethAddress,
 | 
			
		||||
  loadPoolConfig,
 | 
			
		||||
} from '../../helpers/configuration';
 | 
			
		||||
 | 
			
		||||
import { tEthereumAddress, AavePools, eContractid } from '../../helpers/types';
 | 
			
		||||
import { waitForTx, filterMapBy } from '../../helpers/misc-utils';
 | 
			
		||||
import { waitForTx, filterMapBy, notFalsyOrZeroAddress } from '../../helpers/misc-utils';
 | 
			
		||||
import { configureReservesByHelper, initReservesByHelper } from '../../helpers/init-helpers';
 | 
			
		||||
import { getAllTokenAddresses } from '../../helpers/mock-helpers';
 | 
			
		||||
import { ZERO_ADDRESS } from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  getAllMockedTokens,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getWETHGateway,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { insertContractAddressInDb } from '../../helpers/contracts-helpers';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +91,10 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
    await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address);
 | 
			
		||||
 | 
			
		||||
    const lendingPoolAddress = await addressesProvider.getLendingPool();
 | 
			
		||||
    const gateWay = await getParamPerNetwork(WethGateway, network);
 | 
			
		||||
    await authorizeWETHGateway(gateWay, lendingPoolAddress);
 | 
			
		||||
 | 
			
		||||
    let gateway = getParamPerNetwork(WethGateway, network);
 | 
			
		||||
    if (!notFalsyOrZeroAddress(gateway)) {
 | 
			
		||||
      gateway = (await getWETHGateway()).address;
 | 
			
		||||
    }
 | 
			
		||||
    await authorizeWETHGateway(gateway, lendingPoolAddress);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,30 @@
 | 
			
		|||
import { formatEther } from 'ethers/lib/utils';
 | 
			
		||||
import { task } from 'hardhat/config';
 | 
			
		||||
import { ConfigNames, loadPoolConfig } from '../../helpers/configuration';
 | 
			
		||||
import { deployLendingPoolAddressesProviderRegistry } from '../../helpers/contracts-deployments';
 | 
			
		||||
import { getFirstSigner } from '../../helpers/contracts-getters';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { notFalsyOrZeroAddress } from '../../helpers/misc-utils';
 | 
			
		||||
import { eNetwork } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
task('full:deploy-address-provider-registry', 'Deploy address provider registry')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .setAction(async ({ verify }, DRE) => {
 | 
			
		||||
  .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
 | 
			
		||||
  .setAction(async ({ verify, pool }, DRE) => {
 | 
			
		||||
    await DRE.run('set-DRE');
 | 
			
		||||
    const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
    const network = <eNetwork>DRE.network.name;
 | 
			
		||||
    const signer = await getFirstSigner();
 | 
			
		||||
 | 
			
		||||
    const contract = await deployLendingPoolAddressesProviderRegistry(verify);
 | 
			
		||||
    console.log('Registry Address:', contract.address);
 | 
			
		||||
    const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
 | 
			
		||||
 | 
			
		||||
    console.log('Signer', await signer.getAddress());
 | 
			
		||||
    console.log('Balance', formatEther(await signer.getBalance()));
 | 
			
		||||
 | 
			
		||||
    if (notFalsyOrZeroAddress(providerRegistryAddress)) {
 | 
			
		||||
      console.log('Already deployed Provider Registry Address at', providerRegistryAddress);
 | 
			
		||||
    } else {
 | 
			
		||||
      const contract = await deployLendingPoolAddressesProviderRegistry(verify);
 | 
			
		||||
      console.log('Deployed Registry Address:', contract.address);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,9 +1,5 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
  deployLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import { deployLendingPoolAddressesProvider } from '../../helpers/contracts-deployments';
 | 
			
		||||
import { notFalsyOrZeroAddress, waitForTx } from '../../helpers/misc-utils';
 | 
			
		||||
import {
 | 
			
		||||
  ConfigNames,
 | 
			
		||||
| 
						 | 
				
			
			@ -11,16 +7,8 @@ import {
 | 
			
		|||
  getGenesisPoolAdmin,
 | 
			
		||||
  getEmergencyAdmin,
 | 
			
		||||
} from '../../helpers/configuration';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { eNetwork } from '../../helpers/types';
 | 
			
		||||
import {
 | 
			
		||||
  getFirstSigner,
 | 
			
		||||
  getLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { formatEther, isAddress, parseEther } from 'ethers/lib/utils';
 | 
			
		||||
import { isZeroAddress } from 'ethereumjs-util';
 | 
			
		||||
import { Signer, BigNumber } from 'ethers';
 | 
			
		||||
import { parse } from 'path';
 | 
			
		||||
//import BigNumber from 'bignumber.js';
 | 
			
		||||
 | 
			
		||||
task(
 | 
			
		||||
  'full:deploy-address-provider',
 | 
			
		||||
| 
						 | 
				
			
			@ -28,65 +16,29 @@ task(
 | 
			
		|||
)
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
 | 
			
		||||
  .setAction(async ({ verify, pool }, DRE) => {
 | 
			
		||||
  .addFlag('skipRegistry')
 | 
			
		||||
  .setAction(async ({ verify, pool, skipRegistry }, DRE) => {
 | 
			
		||||
    await DRE.run('set-DRE');
 | 
			
		||||
    let signer: Signer;
 | 
			
		||||
    const network = <eNetwork>DRE.network.name;
 | 
			
		||||
    const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
    const { ProviderId, MarketId } = poolConfig;
 | 
			
		||||
    const { MarketId } = poolConfig;
 | 
			
		||||
 | 
			
		||||
    const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
 | 
			
		||||
    const providerRegistryOwner = getParamPerNetwork(poolConfig.ProviderRegistryOwner, network);
 | 
			
		||||
 | 
			
		||||
    if (
 | 
			
		||||
      !providerRegistryAddress ||
 | 
			
		||||
      !isAddress(providerRegistryAddress) ||
 | 
			
		||||
      isZeroAddress(providerRegistryAddress)
 | 
			
		||||
    ) {
 | 
			
		||||
      throw Error('config.ProviderRegistry is missing or is not an address.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (
 | 
			
		||||
      !providerRegistryOwner ||
 | 
			
		||||
      !isAddress(providerRegistryOwner) ||
 | 
			
		||||
      isZeroAddress(providerRegistryOwner)
 | 
			
		||||
    ) {
 | 
			
		||||
      throw Error('config.ProviderRegistryOwner is missing or is not an address.');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Checks if deployer address is registry owner
 | 
			
		||||
    if (process.env.MAINNET_FORK === 'true') {
 | 
			
		||||
      await DRE.network.provider.request({
 | 
			
		||||
        method: 'hardhat_impersonateAccount',
 | 
			
		||||
        params: [providerRegistryOwner],
 | 
			
		||||
      });
 | 
			
		||||
      signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
 | 
			
		||||
      const firstAccount = await getFirstSigner();
 | 
			
		||||
      await firstAccount.sendTransaction({ value: parseEther('10'), to: providerRegistryOwner });
 | 
			
		||||
    } else {
 | 
			
		||||
      signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
 | 
			
		||||
    }
 | 
			
		||||
    // 1. Address Provider Registry instance
 | 
			
		||||
    const addressesProviderRegistry = (
 | 
			
		||||
      await getLendingPoolAddressesProviderRegistry(providerRegistryAddress)
 | 
			
		||||
    ).connect(signer);
 | 
			
		||||
 | 
			
		||||
    console.log('Registry Address', addressesProviderRegistry.address);
 | 
			
		||||
 | 
			
		||||
    // 2. Deploy address provider and set genesis manager
 | 
			
		||||
    // 1. Deploy address provider and set genesis manager
 | 
			
		||||
    const addressesProvider = await deployLendingPoolAddressesProvider(MarketId, verify);
 | 
			
		||||
 | 
			
		||||
    // DISABLE SEC. 3 FOR GOVERNANCE USE!
 | 
			
		||||
    // 3. Set the provider at the Registry
 | 
			
		||||
    await waitForTx(
 | 
			
		||||
      await addressesProviderRegistry.registerAddressesProvider(
 | 
			
		||||
        addressesProvider.address,
 | 
			
		||||
        ProviderId
 | 
			
		||||
      )
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // 4. Set pool admins
 | 
			
		||||
    // 2. Add to registry or setup a new one
 | 
			
		||||
    if (!skipRegistry) {
 | 
			
		||||
      const providerRegistryAddress = getParamPerNetwork(
 | 
			
		||||
        poolConfig.ProviderRegistry,
 | 
			
		||||
        <eNetwork>DRE.network.name
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      await DRE.run('add-market-to-registry', {
 | 
			
		||||
        pool,
 | 
			
		||||
        addressesProvider: addressesProvider.address,
 | 
			
		||||
        deployRegistry: !notFalsyOrZeroAddress(providerRegistryAddress),
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
    // 3. Set pool admins
 | 
			
		||||
    await waitForTx(await addressesProvider.setPoolAdmin(await getGenesisPoolAdmin(poolConfig)));
 | 
			
		||||
    await waitForTx(await addressesProvider.setEmergencyAdmin(await getEmergencyAdmin(poolConfig)));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -34,6 +34,7 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
 | 
			
		|||
        console.log('\tDeploying new lending pool implementation & libraries...');
 | 
			
		||||
        const lendingPoolImpl = await deployLendingPool(verify);
 | 
			
		||||
        lendingPoolImplAddress = lendingPoolImpl.address;
 | 
			
		||||
        await lendingPoolImpl.initialize(addressesProvider.address);
 | 
			
		||||
      }
 | 
			
		||||
      console.log('\tSetting lending pool implementation with address:', lendingPoolImplAddress);
 | 
			
		||||
      // Set lending pool impl to Address provider
 | 
			
		||||
| 
						 | 
				
			
			@ -81,7 +82,7 @@ task('full:deploy-lending-pool', 'Deploy lending pool for dev enviroment')
 | 
			
		|||
      if (DRE.network.name.includes('tenderly')) {
 | 
			
		||||
        const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
 | 
			
		||||
          DRE.config.tenderly.project
 | 
			
		||||
        }/fork/${DRE.tenderlyRPC.getFork()}/simulation/${DRE.tenderlyRPC.getHead()}`;
 | 
			
		||||
        }/fork/${DRE.tenderlyNetwork.getFork()}/simulation/${DRE.tenderlyNetwork.getHead()}`;
 | 
			
		||||
        console.error('Check tx error:', transactionLink);
 | 
			
		||||
      }
 | 
			
		||||
      throw error;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ import {
 | 
			
		|||
  getLendingRateOracle,
 | 
			
		||||
  getPairsTokenAggregator,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { AaveOracle } from '../../types';
 | 
			
		||||
import { AaveOracle, LendingRateOracle } from '../../types';
 | 
			
		||||
 | 
			
		||||
task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			@ -49,38 +49,34 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
 | 
			
		|||
      const [tokens, aggregators] = getPairsTokenAggregator(tokensToWatch, chainlinkAggregators);
 | 
			
		||||
 | 
			
		||||
      let aaveOracle: AaveOracle;
 | 
			
		||||
      let lendingRateOracle: LendingRateOracle;
 | 
			
		||||
 | 
			
		||||
      if (notFalsyOrZeroAddress(aaveOracleAddress)) {
 | 
			
		||||
        aaveOracle = await await getAaveOracle(aaveOracleAddress);
 | 
			
		||||
        const owner = await aaveOracle.owner();
 | 
			
		||||
        const signer = DRE.ethers.provider.getSigner(owner);
 | 
			
		||||
 | 
			
		||||
        aaveOracle = await (await getAaveOracle(aaveOracleAddress)).connect(signer);
 | 
			
		||||
        await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
 | 
			
		||||
      } else {
 | 
			
		||||
        aaveOracle = await deployAaveOracle(
 | 
			
		||||
          [tokens, aggregators, fallbackOracleAddress, await getWethAddress(poolConfig)],
 | 
			
		||||
          verify
 | 
			
		||||
        );
 | 
			
		||||
        await waitForTx(await aaveOracle.setAssetSources(tokens, aggregators));
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      let lendingRateOracle = notFalsyOrZeroAddress(lendingRateOracleAddress)
 | 
			
		||||
        ? await getLendingRateOracle(lendingRateOracleAddress)
 | 
			
		||||
        : await deployLendingRateOracle(verify);
 | 
			
		||||
      const { USD, ...tokensAddressesWithoutUsd } = tokensToWatch;
 | 
			
		||||
      if (notFalsyOrZeroAddress(lendingRateOracleAddress)) {
 | 
			
		||||
        lendingRateOracle = await getLendingRateOracle(lendingRateOracleAddress);
 | 
			
		||||
      } else {
 | 
			
		||||
        lendingRateOracle = await deployLendingRateOracle(verify);
 | 
			
		||||
        const { USD, ...tokensAddressesWithoutUsd } = tokensToWatch;
 | 
			
		||||
        await setInitialMarketRatesInRatesOracleByHelper(
 | 
			
		||||
          lendingRateOracles,
 | 
			
		||||
          tokensAddressesWithoutUsd,
 | 
			
		||||
          lendingRateOracle,
 | 
			
		||||
          admin
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      console.log('Aave Oracle: %s', lendingRateOracle.address);
 | 
			
		||||
      console.log('Lending Rate Oracle: %s', lendingRateOracle.address);
 | 
			
		||||
 | 
			
		||||
      lendingRateOracle = lendingRateOracle.connect(
 | 
			
		||||
        DRE.ethers.provider.getSigner(await lendingRateOracle.owner())
 | 
			
		||||
      );
 | 
			
		||||
      // This must be done any time a new market is created I believe
 | 
			
		||||
      //if (!lendingRateOracleAddress) {
 | 
			
		||||
      await setInitialMarketRatesInRatesOracleByHelper(
 | 
			
		||||
        lendingRateOracles,
 | 
			
		||||
        tokensAddressesWithoutUsd,
 | 
			
		||||
        lendingRateOracle,
 | 
			
		||||
        admin
 | 
			
		||||
      );
 | 
			
		||||
      //}
 | 
			
		||||
      console.log('ORACLES: %s and %s', aaveOracle.address, lendingRateOracle.address);
 | 
			
		||||
      // Register the proxy price provider on the addressesProvider
 | 
			
		||||
      await waitForTx(await addressesProvider.setPriceOracle(aaveOracle.address));
 | 
			
		||||
      await waitForTx(await addressesProvider.setLendingRateOracle(lendingRateOracle.address));
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +84,7 @@ task('full:deploy-oracles', 'Deploy oracles for dev enviroment')
 | 
			
		|||
      if (DRE.network.name.includes('tenderly')) {
 | 
			
		||||
        const transactionLink = `https://dashboard.tenderly.co/${DRE.config.tenderly.username}/${
 | 
			
		||||
          DRE.config.tenderly.project
 | 
			
		||||
        }/fork/${DRE.tenderlyRPC.getFork()}/simulation/${DRE.tenderlyRPC.getHead()}`;
 | 
			
		||||
        }/fork/${DRE.tenderlyNetwork.getFork()}/simulation/${DRE.tenderlyNetwork.getHead()}`;
 | 
			
		||||
        console.error('Check tx error:', transactionLink);
 | 
			
		||||
      }
 | 
			
		||||
      throw error;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,10 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { AaveConfig } from '../../markets/aave/index';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { loadPoolConfig, ConfigNames, getWethAddress } from '../../helpers/configuration';
 | 
			
		||||
import {
 | 
			
		||||
  loadPoolConfig,
 | 
			
		||||
  ConfigNames,
 | 
			
		||||
  getWrappedNativeTokenAddress,
 | 
			
		||||
} from '../../helpers/configuration';
 | 
			
		||||
import { deployWETHGateway } from '../../helpers/contracts-deployments';
 | 
			
		||||
import { DRE } from '../../helpers/misc-utils';
 | 
			
		||||
import { eNetwork } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
const CONTRACT_NAME = 'WETHGateway';
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -13,20 +13,13 @@ task(`full-deploy-weth-gateway`, `Deploys the ${CONTRACT_NAME} contract`)
 | 
			
		|||
  .addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`)
 | 
			
		||||
  .setAction(async ({ verify, pool }, localBRE) => {
 | 
			
		||||
    await localBRE.run('set-DRE');
 | 
			
		||||
    const network = <eNetwork>localBRE.network.name;
 | 
			
		||||
    const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
    const Weth = await getWethAddress(poolConfig);
 | 
			
		||||
    const { WethGateway } = poolConfig;
 | 
			
		||||
    const Weth = await getWrappedNativeTokenAddress(poolConfig);
 | 
			
		||||
 | 
			
		||||
    if (!localBRE.network.config.chainId) {
 | 
			
		||||
      throw new Error('INVALID_CHAIN_ID');
 | 
			
		||||
    }
 | 
			
		||||
    let gateWay = getParamPerNetwork(WethGateway, network);
 | 
			
		||||
    if (gateWay === '') {
 | 
			
		||||
      const wethGateWay = await deployWETHGateway([Weth], verify);
 | 
			
		||||
      console.log(`${CONTRACT_NAME}.address`, wethGateWay.address);
 | 
			
		||||
      console.log(`\tFinished ${CONTRACT_NAME} deployment`);
 | 
			
		||||
    } else {
 | 
			
		||||
      console.log(`Weth gateway already deployed. Address: ${gateWay}`);
 | 
			
		||||
    }
 | 
			
		||||
    const wethGateWay = await deployWETHGateway([Weth], verify);
 | 
			
		||||
    console.log(`${CONTRACT_NAME}.address`, wethGateWay.address);
 | 
			
		||||
    console.log(`\tFinished ${CONTRACT_NAME} deployment`);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,10 +40,11 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
        ReservesConfig,
 | 
			
		||||
        LendingPoolCollateralManager,
 | 
			
		||||
        WethGateway,
 | 
			
		||||
        IncentivesController,
 | 
			
		||||
      } = poolConfig as ICommonConfiguration;
 | 
			
		||||
 | 
			
		||||
      const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
 | 
			
		||||
 | 
			
		||||
      const incentivesController = await getParamPerNetwork(IncentivesController, network);
 | 
			
		||||
      const addressesProvider = await getLendingPoolAddressesProvider();
 | 
			
		||||
 | 
			
		||||
      const testHelpers = await getAaveProtocolDataProvider();
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +65,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
        SymbolPrefix,
 | 
			
		||||
        admin,
 | 
			
		||||
        treasuryAddress,
 | 
			
		||||
        ZERO_ADDRESS,
 | 
			
		||||
        incentivesController,
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
      await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
 | 
			
		||||
| 
						 | 
				
			
			@ -87,6 +88,18 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
        await addressesProvider.setLendingPoolCollateralManager(collateralManagerAddress)
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      console.log(
 | 
			
		||||
        '\tSetting AaveProtocolDataProvider at AddressesProvider at id: 0x01',
 | 
			
		||||
        collateralManagerAddress
 | 
			
		||||
      );
 | 
			
		||||
      const aaveProtocolDataProvider = await getAaveProtocolDataProvider();
 | 
			
		||||
      await waitForTx(
 | 
			
		||||
        await addressesProvider.setAddress(
 | 
			
		||||
          '0x0100000000000000000000000000000000000000000000000000000000000000',
 | 
			
		||||
          aaveProtocolDataProvider.address
 | 
			
		||||
        )
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      await deployWalletBalancerProvider(verify);
 | 
			
		||||
 | 
			
		||||
      const lendingPoolAddress = await addressesProvider.getLendingPool();
 | 
			
		||||
| 
						 | 
				
			
			@ -95,6 +108,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
      if (!notFalsyOrZeroAddress(gateWay)) {
 | 
			
		||||
        gateWay = (await getWETHGateway()).address;
 | 
			
		||||
      }
 | 
			
		||||
      console.log('GATEWAY', gateWay);
 | 
			
		||||
      await authorizeWETHGateway(gateWay, lendingPoolAddress);
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      console.error(err);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -82,12 +82,12 @@ WRONG RESERVE ASSET SETUP:
 | 
			
		|||
    const rates = await deployDefaultReserveInterestRateStrategy(
 | 
			
		||||
      [
 | 
			
		||||
        addressProvider.address,
 | 
			
		||||
        strategyParams.optimalUtilizationRate,
 | 
			
		||||
        strategyParams.baseVariableBorrowRate,
 | 
			
		||||
        strategyParams.variableRateSlope1,
 | 
			
		||||
        strategyParams.variableRateSlope2,
 | 
			
		||||
        strategyParams.stableRateSlope1,
 | 
			
		||||
        strategyParams.stableRateSlope2,
 | 
			
		||||
        strategyParams.strategy.optimalUtilizationRate,
 | 
			
		||||
        strategyParams.strategy.baseVariableBorrowRate,
 | 
			
		||||
        strategyParams.strategy.variableRateSlope1,
 | 
			
		||||
        strategyParams.strategy.variableRateSlope2,
 | 
			
		||||
        strategyParams.strategy.stableRateSlope1,
 | 
			
		||||
        strategyParams.strategy.stableRateSlope2,
 | 
			
		||||
      ],
 | 
			
		||||
      verify
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ import { ConfigNames } from '../../helpers/configuration';
 | 
			
		|||
import { printContracts } from '../../helpers/misc-utils';
 | 
			
		||||
 | 
			
		||||
task('aave:dev', 'Deploy development enviroment')
 | 
			
		||||
  .addOptionalParam('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .setAction(async ({ verify }, localBRE) => {
 | 
			
		||||
    const POOL_NAME = ConfigNames.Aave;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +29,10 @@ task('aave:dev', 'Deploy development enviroment')
 | 
			
		|||
    console.log('4. Deploy oracles');
 | 
			
		||||
    await localBRE.run('dev:deploy-oracles', { verify, pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
    console.log('5. Initialize lending pool');
 | 
			
		||||
    console.log('5. Deploy WETH Gateway');
 | 
			
		||||
    await localBRE.run('full-deploy-weth-gateway', { verify, pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
    console.log('6. Initialize lending pool');
 | 
			
		||||
    await localBRE.run('dev:initialize-lending-pool', { verify, pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
    console.log('\nFinished migration');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,8 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
 | 
			
		|||
 | 
			
		||||
task('aave:mainnet', 'Deploy development enviroment')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .setAction(async ({ verify }, DRE) => {
 | 
			
		||||
  .addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
 | 
			
		||||
  .setAction(async ({ verify, skipRegistry }, DRE) => {
 | 
			
		||||
    const POOL_NAME = ConfigNames.Aave;
 | 
			
		||||
    await DRE.run('set-DRE');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +19,7 @@ task('aave:mainnet', 'Deploy development enviroment')
 | 
			
		|||
    console.log('Migration started\n');
 | 
			
		||||
 | 
			
		||||
    console.log('1. Deploy address provider');
 | 
			
		||||
    await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
 | 
			
		||||
    await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
 | 
			
		||||
 | 
			
		||||
    console.log('2. Deploy lending pool');
 | 
			
		||||
    await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +46,8 @@ task('aave:mainnet', 'Deploy development enviroment')
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      const postDeployHead = DRE.tenderlyRPC.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyRPC.getFork();
 | 
			
		||||
      const postDeployHead = DRE.tenderlyNetwork.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyNetwork.getFork();
 | 
			
		||||
      console.log('Tenderly Info');
 | 
			
		||||
      console.log('- Head', postDeployHead);
 | 
			
		||||
      console.log('- Fork', postDeployFork);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,7 +6,8 @@ import { usingTenderly } from '../../helpers/tenderly-utils';
 | 
			
		|||
 | 
			
		||||
task('amm:mainnet', 'Deploy development enviroment')
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .setAction(async ({ verify }, DRE) => {
 | 
			
		||||
  .addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
 | 
			
		||||
  .setAction(async ({ verify, skipRegistry }, DRE) => {
 | 
			
		||||
    const POOL_NAME = ConfigNames.Amm;
 | 
			
		||||
    await DRE.run('set-DRE');
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -18,7 +19,7 @@ task('amm:mainnet', 'Deploy development enviroment')
 | 
			
		|||
    console.log('Migration started\n');
 | 
			
		||||
 | 
			
		||||
    console.log('1. Deploy address provider');
 | 
			
		||||
    await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
 | 
			
		||||
    await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
 | 
			
		||||
 | 
			
		||||
    console.log('2. Deploy lending pool');
 | 
			
		||||
    await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
 | 
			
		||||
| 
						 | 
				
			
			@ -45,8 +46,8 @@ task('amm:mainnet', 'Deploy development enviroment')
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      const postDeployHead = DRE.tenderlyRPC.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyRPC.getFork();
 | 
			
		||||
      const postDeployHead = DRE.tenderlyNetwork.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyNetwork.getFork();
 | 
			
		||||
      console.log('Tenderly Info');
 | 
			
		||||
      console.log('- Head', postDeployHead);
 | 
			
		||||
      console.log('- Fork', postDeployFork);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,10 +4,12 @@ import { ConfigNames } from '../../helpers/configuration';
 | 
			
		|||
import { printContracts } from '../../helpers/misc-utils';
 | 
			
		||||
import { usingTenderly } from '../../helpers/tenderly-utils';
 | 
			
		||||
 | 
			
		||||
task('matic:mainnet', 'Deploy development enviroment')
 | 
			
		||||
task('sidechain:mainnet', 'Deploy market at sidechain')
 | 
			
		||||
  .addParam('pool', `Market pool configuration, one of ${Object.keys(ConfigNames)}`)
 | 
			
		||||
  .addFlag('verify', 'Verify contracts at Etherscan')
 | 
			
		||||
  .setAction(async ({ verify }, DRE) => {
 | 
			
		||||
    const POOL_NAME = ConfigNames.Matic;
 | 
			
		||||
  .addFlag('skipRegistry', 'Skip addresses provider registration at Addresses Provider Registry')
 | 
			
		||||
  .setAction(async ({ verify, pool, skipRegistry }, DRE) => {
 | 
			
		||||
    const POOL_NAME = pool;
 | 
			
		||||
    await DRE.run('set-DRE');
 | 
			
		||||
 | 
			
		||||
    // Prevent loss of gas verifying all the needed ENVs for Etherscan verification
 | 
			
		||||
| 
						 | 
				
			
			@ -17,8 +19,11 @@ task('matic:mainnet', 'Deploy development enviroment')
 | 
			
		|||
 | 
			
		||||
    console.log('Migration started\n');
 | 
			
		||||
 | 
			
		||||
    console.log('0. Deploy address provider registry');
 | 
			
		||||
    await DRE.run('full:deploy-address-provider-registry', { pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
    console.log('1. Deploy address provider');
 | 
			
		||||
    await DRE.run('full:deploy-address-provider', { pool: POOL_NAME });
 | 
			
		||||
    await DRE.run('full:deploy-address-provider', { pool: POOL_NAME, skipRegistry });
 | 
			
		||||
 | 
			
		||||
    console.log('2. Deploy lending pool');
 | 
			
		||||
    await DRE.run('full:deploy-lending-pool', { pool: POOL_NAME });
 | 
			
		||||
| 
						 | 
				
			
			@ -28,22 +33,24 @@ task('matic:mainnet', 'Deploy development enviroment')
 | 
			
		|||
 | 
			
		||||
    console.log('4. Deploy Data Provider');
 | 
			
		||||
    await DRE.run('full:data-provider', { pool: POOL_NAME });
 | 
			
		||||
    console.log('5. Deploy WETH Gateway');
 | 
			
		||||
    await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
    console.log('5. Initialize lending pool');
 | 
			
		||||
    console.log('6. Initialize lending pool');
 | 
			
		||||
    await DRE.run('full:initialize-lending-pool', { pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
    if (verify) {
 | 
			
		||||
      printContracts();
 | 
			
		||||
      console.log('4. Veryfing contracts');
 | 
			
		||||
      console.log('7. Veryfing contracts');
 | 
			
		||||
      await DRE.run('verify:general', { all: true, pool: POOL_NAME });
 | 
			
		||||
 | 
			
		||||
      console.log('5. Veryfing aTokens and debtTokens');
 | 
			
		||||
      console.log('8. Veryfing aTokens and debtTokens');
 | 
			
		||||
      await DRE.run('verify:tokens', { pool: POOL_NAME });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (usingTenderly()) {
 | 
			
		||||
      const postDeployHead = DRE.tenderlyRPC.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyRPC.getFork();
 | 
			
		||||
      const postDeployHead = DRE.tenderlyNetwork.getHead();
 | 
			
		||||
      const postDeployFork = DRE.tenderlyNetwork.getFork();
 | 
			
		||||
      console.log('Tenderly Info');
 | 
			
		||||
      console.log('- Head', postDeployHead);
 | 
			
		||||
      console.log('- Fork', postDeployFork);
 | 
			
		||||
| 
						 | 
				
			
			@ -1,88 +0,0 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { loadPoolConfig, ConfigNames, getTreasuryAddress } from '../../helpers/configuration';
 | 
			
		||||
import { eEthereumNetwork, eNetwork, ICommonConfiguration } from '../../helpers/types';
 | 
			
		||||
import { waitForTx } from '../../helpers/misc-utils';
 | 
			
		||||
import { initTokenReservesByHelper } from '../../helpers/init-helpers';
 | 
			
		||||
import { exit } from 'process';
 | 
			
		||||
import {
 | 
			
		||||
  getFirstSigner,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPoolAddressesProviderRegistry,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { Signer } from 'ethers';
 | 
			
		||||
import { formatEther, parseEther } from 'ethers/lib/utils';
 | 
			
		||||
 | 
			
		||||
task('full:initialize-tokens', 'Initialize lending pool configuration.')
 | 
			
		||||
  .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
 | 
			
		||||
  .addParam('ratesDeployer', `RatesHelper address `)
 | 
			
		||||
  .addParam('dataProvider', `Data provider address`)
 | 
			
		||||
  .addFlag('verify')
 | 
			
		||||
  .setAction(async ({ verify, pool, dataProvider, ratesDeployer }, DRE) => {
 | 
			
		||||
    try {
 | 
			
		||||
      await DRE.run('set-DRE');
 | 
			
		||||
      let signer: Signer;
 | 
			
		||||
      const network =
 | 
			
		||||
        process.env.MAINNET_FORK === 'true' ? eEthereumNetwork.main : <eNetwork>DRE.network.name;
 | 
			
		||||
      const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
      const { ReserveAssets, ReservesConfig } = poolConfig as ICommonConfiguration;
 | 
			
		||||
 | 
			
		||||
      const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
 | 
			
		||||
 | 
			
		||||
      const treasuryAddress = await getTreasuryAddress(poolConfig);
 | 
			
		||||
      const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
 | 
			
		||||
      const providerRegistryOwner = getParamPerNetwork(poolConfig.ProviderRegistryOwner, network);
 | 
			
		||||
 | 
			
		||||
      const providerRegistry = await getLendingPoolAddressesProviderRegistry(
 | 
			
		||||
        providerRegistryAddress
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      const providers = await providerRegistry.getAddressesProvidersList();
 | 
			
		||||
 | 
			
		||||
      const addressesProvider = await getLendingPoolAddressesProvider(providers[0]); // Checks first provider
 | 
			
		||||
 | 
			
		||||
      const admin = await addressesProvider.getPoolAdmin();
 | 
			
		||||
      if (!reserveAssets) {
 | 
			
		||||
        throw 'Reserve assets is undefined. Check ReserveAssets configuration at config directory';
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (process.env.MAINNET_FORK === 'true') {
 | 
			
		||||
        await DRE.network.provider.request({
 | 
			
		||||
          method: 'hardhat_impersonateAccount',
 | 
			
		||||
          params: [providerRegistryOwner],
 | 
			
		||||
        });
 | 
			
		||||
        signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
 | 
			
		||||
        const user = await getFirstSigner();
 | 
			
		||||
        await waitForTx(
 | 
			
		||||
          await user.sendTransaction({ to: await signer.getAddress(), value: parseEther('10') })
 | 
			
		||||
        );
 | 
			
		||||
 | 
			
		||||
        const balance = await signer.getBalance();
 | 
			
		||||
        console.log('signer balance', formatEther(balance));
 | 
			
		||||
      } else {
 | 
			
		||||
        signer = DRE.ethers.provider.getSigner(providerRegistryOwner);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      // Init unitilialized reserves
 | 
			
		||||
      await initTokenReservesByHelper(
 | 
			
		||||
        ReservesConfig,
 | 
			
		||||
        reserveAssets,
 | 
			
		||||
        admin,
 | 
			
		||||
        addressesProvider.address,
 | 
			
		||||
        ratesDeployer,
 | 
			
		||||
        dataProvider,
 | 
			
		||||
        signer,
 | 
			
		||||
        treasuryAddress,
 | 
			
		||||
        verify
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Show contracts state
 | 
			
		||||
      await DRE.run('print-config', {
 | 
			
		||||
        pool: 'Aave',
 | 
			
		||||
        dataProvider,
 | 
			
		||||
      });
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      console.error(err);
 | 
			
		||||
      exit(1);
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			@ -14,10 +14,10 @@ task('print-config', 'Inits the DRE, to have access to all the plugins')
 | 
			
		|||
  .addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
 | 
			
		||||
  .setAction(async ({ pool, dataProvider }, localBRE) => {
 | 
			
		||||
    await localBRE.run('set-DRE');
 | 
			
		||||
    const network =
 | 
			
		||||
      process.env.MAINNET_FORK === 'true'
 | 
			
		||||
        ? eEthereumNetwork.main
 | 
			
		||||
        : (localBRE.network.name as eNetwork);
 | 
			
		||||
    const network = process.env.FORK
 | 
			
		||||
      ? (process.env.FORK as eNetwork)
 | 
			
		||||
      : (localBRE.network.name as eNetwork);
 | 
			
		||||
    console.log(network);
 | 
			
		||||
    const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
 | 
			
		||||
    const providerRegistryAddress = getParamPerNetwork(poolConfig.ProviderRegistry, network);
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ task('print-config', 'Inits the DRE, to have access to all the plugins')
 | 
			
		|||
    ];
 | 
			
		||||
    const tokensFields = ['aToken', 'stableDebtToken', 'variableDebtToken'];
 | 
			
		||||
    for (const [symbol, address] of Object.entries(
 | 
			
		||||
      getParamPerNetwork(poolConfig.ReserveAssets, network)
 | 
			
		||||
      getParamPerNetwork(poolConfig.ReserveAssets, network as eNetwork)
 | 
			
		||||
    )) {
 | 
			
		||||
      console.log(`- ${symbol} asset config`);
 | 
			
		||||
      console.log(`  - reserve address: ${address}`);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,10 +1,6 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { DRE, setDRE } from '../../helpers/misc-utils';
 | 
			
		||||
import { EthereumNetworkNames } from '../../helpers/types';
 | 
			
		||||
import { usingTenderly } from '../../helpers/tenderly-utils';
 | 
			
		||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
 | 
			
		||||
import { getFirstSigner } from '../../helpers/contracts-getters';
 | 
			
		||||
import { formatEther } from 'ethers/lib/utils';
 | 
			
		||||
 | 
			
		||||
task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).setAction(
 | 
			
		||||
  async (_, _DRE) => {
 | 
			
		||||
| 
						 | 
				
			
			@ -16,26 +12,36 @@ task(`set-DRE`, `Inits the DRE, to have access to all the plugins' objects`).set
 | 
			
		|||
      process.env.TENDERLY === 'true'
 | 
			
		||||
    ) {
 | 
			
		||||
      console.log('- Setting up Tenderly provider');
 | 
			
		||||
      const net = _DRE.tenderly.network();
 | 
			
		||||
 | 
			
		||||
      if (process.env.TENDERLY_FORK_ID && process.env.TENDERLY_HEAD_ID) {
 | 
			
		||||
        console.log('- Connecting to a Tenderly Fork');
 | 
			
		||||
        _DRE.tenderlyRPC.setFork(process.env.TENDERLY_FORK_ID);
 | 
			
		||||
        _DRE.tenderlyRPC.setHead(process.env.TENDERLY_HEAD_ID);
 | 
			
		||||
        await net.setFork(process.env.TENDERLY_FORK_ID);
 | 
			
		||||
        await net.setHead(process.env.TENDERLY_HEAD_ID);
 | 
			
		||||
      } else {
 | 
			
		||||
        console.log('- Creating a new Tenderly Fork');
 | 
			
		||||
        await _DRE.tenderlyRPC.initializeFork();
 | 
			
		||||
        await net.initializeFork();
 | 
			
		||||
      }
 | 
			
		||||
      const provider = new _DRE.ethers.providers.Web3Provider(_DRE.tenderlyRPC as any);
 | 
			
		||||
      const provider = new _DRE.ethers.providers.Web3Provider(net);
 | 
			
		||||
      _DRE.ethers.provider = provider;
 | 
			
		||||
      console.log('- Initialized Tenderly fork:');
 | 
			
		||||
      console.log('  - Fork: ', _DRE.tenderlyRPC.getFork());
 | 
			
		||||
      console.log('  - Head: ', _DRE.tenderlyRPC.getHead());
 | 
			
		||||
      console.log('  - First account:', await (await _DRE.ethers.getSigners())[0].getAddress());
 | 
			
		||||
      console.log(
 | 
			
		||||
        '  - Balance:',
 | 
			
		||||
        formatEther(await (await _DRE.ethers.getSigners())[0].getBalance())
 | 
			
		||||
      );
 | 
			
		||||
      console.log('  - Fork: ', net.getFork());
 | 
			
		||||
      console.log('  - Head: ', net.getHead());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log('- Enviroment');
 | 
			
		||||
    if (process.env.FORK) {
 | 
			
		||||
      console.log('  - Fork Mode activated at network: ', process.env.FORK);
 | 
			
		||||
      if (_DRE?.config?.networks?.hardhat?.forking?.url) {
 | 
			
		||||
        console.log('  - Provider URL:', _DRE.config.networks.hardhat.forking?.url?.split('/')[2]);
 | 
			
		||||
      } else {
 | 
			
		||||
        console.error(
 | 
			
		||||
          `[FORK][Error], missing Provider URL for "${_DRE.network.name}" network. Fill the URL at './helper-hardhat-config.ts' file`
 | 
			
		||||
        );
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    console.log('  - Network :', _DRE.network.name);
 | 
			
		||||
 | 
			
		||||
    setDRE(_DRE);
 | 
			
		||||
    return _DRE;
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,5 @@
 | 
			
		|||
import { task } from 'hardhat/config';
 | 
			
		||||
import { verifyContract, checkVerification } from '../../helpers/etherscan-verification';
 | 
			
		||||
 | 
			
		||||
import { verifyEtherscanContract, checkVerification } from '../../helpers/etherscan-verification';
 | 
			
		||||
interface VerifyParams {
 | 
			
		||||
  contractName: string;
 | 
			
		||||
  address: string;
 | 
			
		||||
| 
						 | 
				
			
			@ -24,6 +23,6 @@ task('verify-sc', 'Inits the DRE, to have access to all the plugins')
 | 
			
		|||
 | 
			
		||||
    checkVerification();
 | 
			
		||||
 | 
			
		||||
    const result = await verifyContract(address, constructorArguments, libraries);
 | 
			
		||||
    const result = await verifyEtherscanContract(address, constructorArguments, libraries);
 | 
			
		||||
    return result;
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,13 +19,13 @@ import {
 | 
			
		|||
  getLendingPoolConfiguratorImpl,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getLendingPoolImpl,
 | 
			
		||||
  getProxy,
 | 
			
		||||
  getWalletProvider,
 | 
			
		||||
  getWETHGateway,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { verifyContract } from '../../helpers/etherscan-verification';
 | 
			
		||||
import { verifyContract, getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { notFalsyOrZeroAddress } from '../../helpers/misc-utils';
 | 
			
		||||
import { eNetwork, ICommonConfiguration } from '../../helpers/types';
 | 
			
		||||
import { eContractid, eNetwork, ICommonConfiguration } from '../../helpers/types';
 | 
			
		||||
 | 
			
		||||
task('verify:general', 'Verify contracts at Etherscan')
 | 
			
		||||
  .addFlag('all', 'Verify all contracts at Etherscan')
 | 
			
		||||
| 
						 | 
				
			
			@ -55,6 +55,10 @@ task('verify:general', 'Verify contracts at Etherscan')
 | 
			
		|||
    const lendingPoolConfiguratorAddress = await addressesProvider.getLendingPoolConfigurator(); //getLendingPoolConfiguratorProxy();
 | 
			
		||||
    const lendingPoolCollateralManagerAddress = await addressesProvider.getLendingPoolCollateralManager();
 | 
			
		||||
 | 
			
		||||
    const lendingPoolProxy = await getProxy(lendingPoolAddress);
 | 
			
		||||
    const lendingPoolConfiguratorProxy = await getProxy(lendingPoolConfiguratorAddress);
 | 
			
		||||
    const lendingPoolCollateralManagerProxy = await getProxy(lendingPoolCollateralManagerAddress);
 | 
			
		||||
 | 
			
		||||
    if (all) {
 | 
			
		||||
      const lendingPoolImplAddress = getParamPerNetwork(LendingPool, network);
 | 
			
		||||
      const lendingPoolImpl = notFalsyOrZeroAddress(lendingPoolImplAddress)
 | 
			
		||||
| 
						 | 
				
			
			@ -89,64 +93,69 @@ task('verify:general', 'Verify contracts at Etherscan')
 | 
			
		|||
 | 
			
		||||
      // Address Provider
 | 
			
		||||
      console.log('\n- Verifying address provider...\n');
 | 
			
		||||
      await verifyContract(addressesProvider.address, [MarketId]);
 | 
			
		||||
      await verifyContract(eContractid.LendingPoolAddressesProvider, addressesProvider, [MarketId]);
 | 
			
		||||
 | 
			
		||||
      // Address Provider Registry
 | 
			
		||||
      console.log('\n- Verifying address provider registry...\n');
 | 
			
		||||
      await verifyContract(addressesProviderRegistry.address, []);
 | 
			
		||||
      await verifyContract(
 | 
			
		||||
        eContractid.LendingPoolAddressesProviderRegistry,
 | 
			
		||||
        addressesProviderRegistry,
 | 
			
		||||
        []
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Lending Pool implementation
 | 
			
		||||
      console.log('\n- Verifying LendingPool Implementation...\n');
 | 
			
		||||
      await verifyContract(lendingPoolImpl.address, []);
 | 
			
		||||
      await verifyContract(eContractid.LendingPool, lendingPoolImpl, []);
 | 
			
		||||
 | 
			
		||||
      // Lending Pool Configurator implementation
 | 
			
		||||
      console.log('\n- Verifying LendingPool Configurator Implementation...\n');
 | 
			
		||||
      await verifyContract(lendingPoolConfiguratorImpl.address, []);
 | 
			
		||||
      await verifyContract(eContractid.LendingPoolConfigurator, lendingPoolConfiguratorImpl, []);
 | 
			
		||||
 | 
			
		||||
      // Lending Pool Collateral Manager implementation
 | 
			
		||||
      console.log('\n- Verifying LendingPool Collateral Manager Implementation...\n');
 | 
			
		||||
      await verifyContract(lendingPoolCollateralManagerImpl.address, []);
 | 
			
		||||
      await verifyContract(
 | 
			
		||||
        eContractid.LendingPoolCollateralManager,
 | 
			
		||||
        lendingPoolCollateralManagerImpl,
 | 
			
		||||
        []
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Test helpers
 | 
			
		||||
      console.log('\n- Verifying  Aave  Provider Helpers...\n');
 | 
			
		||||
      await verifyContract(dataProvider.address, [addressesProvider.address]);
 | 
			
		||||
      await verifyContract(eContractid.AaveProtocolDataProvider, dataProvider, [
 | 
			
		||||
        addressesProvider.address,
 | 
			
		||||
      ]);
 | 
			
		||||
 | 
			
		||||
      // Wallet balance provider
 | 
			
		||||
      console.log('\n- Verifying  Wallet Balance Provider...\n');
 | 
			
		||||
      await verifyContract(walletProvider.address, []);
 | 
			
		||||
      await verifyContract(eContractid.WalletBalanceProvider, walletProvider, []);
 | 
			
		||||
 | 
			
		||||
      // WETHGateway
 | 
			
		||||
      console.log('\n- Verifying  WETHGateway...\n');
 | 
			
		||||
      await verifyContract(wethGateway.address, [await getWethAddress(poolConfig)]);
 | 
			
		||||
      await verifyContract(eContractid.WETHGateway, wethGateway, [
 | 
			
		||||
        await getWethAddress(poolConfig),
 | 
			
		||||
      ]);
 | 
			
		||||
    }
 | 
			
		||||
    // Lending Pool proxy
 | 
			
		||||
    console.log('\n- Verifying  Lending Pool Proxy...\n');
 | 
			
		||||
    await verifyContract(lendingPoolAddress, [addressesProvider.address]);
 | 
			
		||||
    await verifyContract(eContractid.InitializableAdminUpgradeabilityProxy, lendingPoolProxy, [
 | 
			
		||||
      addressesProvider.address,
 | 
			
		||||
    ]);
 | 
			
		||||
 | 
			
		||||
    // LendingPool Conf proxy
 | 
			
		||||
    console.log('\n- Verifying  Lending Pool Configurator Proxy...\n');
 | 
			
		||||
    await verifyContract(lendingPoolConfiguratorAddress, [addressesProvider.address]);
 | 
			
		||||
    await verifyContract(
 | 
			
		||||
      eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
      lendingPoolConfiguratorProxy,
 | 
			
		||||
      [addressesProvider.address]
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // Proxy collateral manager
 | 
			
		||||
    console.log('\n- Verifying  Lending Pool Collateral Manager Proxy...\n');
 | 
			
		||||
    await verifyContract(lendingPoolCollateralManagerAddress, []);
 | 
			
		||||
    await verifyContract(
 | 
			
		||||
      eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
      lendingPoolCollateralManagerProxy,
 | 
			
		||||
      []
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    // DelegatedAwareAToken
 | 
			
		||||
    console.log('\n- Verifying DelegatedAwareAToken...\n');
 | 
			
		||||
    const UNI = getParamPerNetwork(ReserveAssets, network).UNI;
 | 
			
		||||
    const aUNI = await getAddressById('aUNI');
 | 
			
		||||
    if (aUNI) {
 | 
			
		||||
      console.log('Verifying aUNI');
 | 
			
		||||
      await verifyContract(aUNI, [
 | 
			
		||||
        lendingPoolAddress,
 | 
			
		||||
        UNI,
 | 
			
		||||
        treasuryAddress,
 | 
			
		||||
        'Aave interest bearing UNI',
 | 
			
		||||
        'aUNI',
 | 
			
		||||
        ZERO_ADDRESS,
 | 
			
		||||
      ]);
 | 
			
		||||
    } else {
 | 
			
		||||
      console.error('Missing aUNI address at JSON DB. Skipping...');
 | 
			
		||||
    }
 | 
			
		||||
    console.log('Finished verifications.');
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,14 +8,16 @@ import {
 | 
			
		|||
import { ZERO_ADDRESS } from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  getAddressById,
 | 
			
		||||
  getAToken,
 | 
			
		||||
  getFirstSigner,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getInterestRateStrategy,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getProxy,
 | 
			
		||||
  getStableDebtToken,
 | 
			
		||||
  getVariableDebtToken,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { verifyContract } from '../../helpers/etherscan-verification';
 | 
			
		||||
import { eNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types';
 | 
			
		||||
import { getParamPerNetwork, verifyContract } from '../../helpers/contracts-helpers';
 | 
			
		||||
import { eContractid, eNetwork, ICommonConfiguration, IReserveParams } from '../../helpers/types';
 | 
			
		||||
import { LendingPoolConfiguratorFactory, LendingPoolFactory } from '../../types';
 | 
			
		||||
 | 
			
		||||
task('verify:tokens', 'Deploy oracles for dev enviroment')
 | 
			
		||||
| 
						 | 
				
			
			@ -66,27 +68,43 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
 | 
			
		|||
      console.log;
 | 
			
		||||
      // Proxy Stable Debt
 | 
			
		||||
      console.log(`\n- Verifying Stable Debt Token proxy...\n`);
 | 
			
		||||
      await verifyContract(stableDebtTokenAddress, [lendingPoolConfigurator.address]);
 | 
			
		||||
      await verifyContract(
 | 
			
		||||
        eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
        await getProxy(stableDebtTokenAddress),
 | 
			
		||||
        [lendingPoolConfigurator.address]
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Proxy Variable Debt
 | 
			
		||||
      console.log(`\n- Verifying  Debt Token proxy...\n`);
 | 
			
		||||
      await verifyContract(variableDebtTokenAddress, [lendingPoolConfigurator.address]);
 | 
			
		||||
      await verifyContract(
 | 
			
		||||
        eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
        await getProxy(variableDebtTokenAddress),
 | 
			
		||||
        [lendingPoolConfigurator.address]
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Proxy aToken
 | 
			
		||||
      console.log('\n- Verifying aToken proxy...\n');
 | 
			
		||||
      await verifyContract(aTokenAddress, [lendingPoolConfigurator.address]);
 | 
			
		||||
      await verifyContract(
 | 
			
		||||
        eContractid.InitializableAdminUpgradeabilityProxy,
 | 
			
		||||
        await getProxy(aTokenAddress),
 | 
			
		||||
        [lendingPoolConfigurator.address]
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      // Strategy Rate
 | 
			
		||||
      console.log(`\n- Verifying Strategy rate...\n`);
 | 
			
		||||
      await verifyContract(interestRateStrategyAddress, [
 | 
			
		||||
        addressesProvider.address,
 | 
			
		||||
        optimalUtilizationRate,
 | 
			
		||||
        baseVariableBorrowRate,
 | 
			
		||||
        variableRateSlope1,
 | 
			
		||||
        variableRateSlope2,
 | 
			
		||||
        stableRateSlope1,
 | 
			
		||||
        stableRateSlope2,
 | 
			
		||||
      ]);
 | 
			
		||||
      await verifyContract(
 | 
			
		||||
        eContractid.DefaultReserveInterestRateStrategy,
 | 
			
		||||
        await getInterestRateStrategy(interestRateStrategyAddress),
 | 
			
		||||
        [
 | 
			
		||||
          addressesProvider.address,
 | 
			
		||||
          optimalUtilizationRate,
 | 
			
		||||
          baseVariableBorrowRate,
 | 
			
		||||
          variableRateSlope1,
 | 
			
		||||
          variableRateSlope2,
 | 
			
		||||
          stableRateSlope1,
 | 
			
		||||
          stableRateSlope2,
 | 
			
		||||
        ]
 | 
			
		||||
      );
 | 
			
		||||
 | 
			
		||||
      const stableDebt = await getAddressById(`stableDebt${token}`);
 | 
			
		||||
      const variableDebt = await getAddressById(`variableDebt${token}`);
 | 
			
		||||
| 
						 | 
				
			
			@ -94,7 +112,7 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
 | 
			
		|||
 | 
			
		||||
      if (aToken) {
 | 
			
		||||
        console.log('\n- Verifying aToken...\n');
 | 
			
		||||
        await verifyContract(aToken, [
 | 
			
		||||
        await verifyContract(eContractid.AToken, await getAToken(aToken), [
 | 
			
		||||
          lendingPoolProxy.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          treasuryAddress,
 | 
			
		||||
| 
						 | 
				
			
			@ -107,7 +125,7 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
 | 
			
		|||
      }
 | 
			
		||||
      if (stableDebt) {
 | 
			
		||||
        console.log('\n- Verifying StableDebtToken...\n');
 | 
			
		||||
        await verifyContract(stableDebt, [
 | 
			
		||||
        await verifyContract(eContractid.StableDebtToken, await getStableDebtToken(stableDebt), [
 | 
			
		||||
          lendingPoolProxy.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          `Aave stable debt bearing ${token}`,
 | 
			
		||||
| 
						 | 
				
			
			@ -119,13 +137,17 @@ task('verify:tokens', 'Deploy oracles for dev enviroment')
 | 
			
		|||
      }
 | 
			
		||||
      if (variableDebt) {
 | 
			
		||||
        console.log('\n- Verifying VariableDebtToken...\n');
 | 
			
		||||
        await verifyContract(variableDebt, [
 | 
			
		||||
          lendingPoolProxy.address,
 | 
			
		||||
          tokenAddress,
 | 
			
		||||
          `Aave variable debt bearing ${token}`,
 | 
			
		||||
          `variableDebt${token}`,
 | 
			
		||||
          ZERO_ADDRESS,
 | 
			
		||||
        ]);
 | 
			
		||||
        await verifyContract(
 | 
			
		||||
          eContractid.VariableDebtToken,
 | 
			
		||||
          await getVariableDebtToken(variableDebt),
 | 
			
		||||
          [
 | 
			
		||||
            lendingPoolProxy.address,
 | 
			
		||||
            tokenAddress,
 | 
			
		||||
            `Aave variable debt bearing ${token}`,
 | 
			
		||||
            `variableDebt${token}`,
 | 
			
		||||
            ZERO_ADDRESS,
 | 
			
		||||
          ]
 | 
			
		||||
        );
 | 
			
		||||
      } else {
 | 
			
		||||
        console.error(`Skipping variable debt verify for ${token}. Missing address at JSON DB.`);
 | 
			
		||||
      }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ import {
 | 
			
		|||
  insertContractAddressInDb,
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  registerContractInJsonDb,
 | 
			
		||||
  getEthersSignersAddresses,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
| 
						 | 
				
			
			@ -105,9 +106,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
 | 
			
		||||
 | 
			
		||||
  //setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
 | 
			
		||||
  await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -194,7 +193,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
      WMATIC: mockTokens.WMATIC.address,
 | 
			
		||||
      USD: USD_ADDRESS,
 | 
			
		||||
      STAKE: mockTokens.STAKE.address,
 | 
			
		||||
      xSUSHI: mockTokens.xSUSHI.address
 | 
			
		||||
      xSUSHI: mockTokens.xSUSHI.address,
 | 
			
		||||
    },
 | 
			
		||||
    fallbackOracle
 | 
			
		||||
  );
 | 
			
		||||
| 
						 | 
				
			
			@ -304,9 +303,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
before(async () => {
 | 
			
		||||
  await rawBRE.run('set-DRE');
 | 
			
		||||
  const [deployer, secondaryWallet] = await getEthersSigners();
 | 
			
		||||
  const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
 | 
			
		||||
  const FORK = process.env.FORK;
 | 
			
		||||
 | 
			
		||||
  if (MAINNET_FORK) {
 | 
			
		||||
  if (FORK) {
 | 
			
		||||
    await rawBRE.run('aave:mainnet');
 | 
			
		||||
  } else {
 | 
			
		||||
    console.log('-> Deploying test environment...');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ import {
 | 
			
		|||
  getFlashLiquidationAdapter,
 | 
			
		||||
  getParaSwapLiquiditySwapAdapter,
 | 
			
		||||
} from '../../../helpers/contracts-getters';
 | 
			
		||||
import { eEthereumNetwork, tEthereumAddress } from '../../../helpers/types';
 | 
			
		||||
import { eEthereumNetwork, eNetwork, tEthereumAddress } from '../../../helpers/types';
 | 
			
		||||
import { LendingPool } from '../../../types/LendingPool';
 | 
			
		||||
import { AaveProtocolDataProvider } from '../../../types/AaveProtocolDataProvider';
 | 
			
		||||
import { MintableERC20 } from '../../../types/MintableERC20';
 | 
			
		||||
| 
						 | 
				
			
			@ -120,9 +120,9 @@ export async function initializeMakeSuite() {
 | 
			
		|||
 | 
			
		||||
  testEnv.addressesProvider = await getLendingPoolAddressesProvider();
 | 
			
		||||
 | 
			
		||||
  if (process.env.MAINNET_FORK === 'true') {
 | 
			
		||||
  if (process.env.FORK) {
 | 
			
		||||
    testEnv.registry = await getLendingPoolAddressesProviderRegistry(
 | 
			
		||||
      getParamPerNetwork(AaveConfig.ProviderRegistry, eEthereumNetwork.main)
 | 
			
		||||
      getParamPerNetwork(AaveConfig.ProviderRegistry, process.env.FORK as eNetwork)
 | 
			
		||||
    );
 | 
			
		||||
  } else {
 | 
			
		||||
    testEnv.registry = await getLendingPoolAddressesProviderRegistry();
 | 
			
		||||
| 
						 | 
				
			
			@ -169,7 +169,7 @@ export async function initializeMakeSuite() {
 | 
			
		|||
const setSnapshot = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyRPC.getHead()) || '0x1');
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyNetwork.getHead()) || '0x1');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  setBuidlerevmSnapshotId(await evmSnapshot());
 | 
			
		||||
| 
						 | 
				
			
			@ -178,7 +178,7 @@ const setSnapshot = async () => {
 | 
			
		|||
const revertHead = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    await hre.tenderlyRPC.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    await hre.tenderlyNetwork.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  await evmRevert(buidlerevmSnapshotId);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4,6 +4,7 @@ import {
 | 
			
		|||
  insertContractAddressInDb,
 | 
			
		||||
  getEthersSigners,
 | 
			
		||||
  registerContractInJsonDb,
 | 
			
		||||
  getEthersSignersAddresses,
 | 
			
		||||
} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {
 | 
			
		||||
  deployLendingPoolAddressesProvider,
 | 
			
		||||
| 
						 | 
				
			
			@ -26,7 +27,7 @@ import {
 | 
			
		|||
  deployUniswapLiquiditySwapAdapter,
 | 
			
		||||
  deployUniswapRepayAdapter,
 | 
			
		||||
  deployFlashLiquidationAdapter,
 | 
			
		||||
  authorizeWETHGateway
 | 
			
		||||
  authorizeWETHGateway,
 | 
			
		||||
} from '../../helpers/contracts-deployments';
 | 
			
		||||
import { Signer } from 'ethers';
 | 
			
		||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
 | 
			
		||||
| 
						 | 
				
			
			@ -101,9 +102,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
 | 
			
		||||
 | 
			
		||||
  //setting users[1] as emergency admin, which is in position 2 in the DRE addresses list
 | 
			
		||||
  const addressList = await Promise.all(
 | 
			
		||||
    (await DRE.ethers.getSigners()).map((signer) => signer.getAddress())
 | 
			
		||||
  );
 | 
			
		||||
  const addressList = await getEthersSignersAddresses();
 | 
			
		||||
 | 
			
		||||
  await waitForTx(await addressesProvider.setEmergencyAdmin(addressList[2]));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -240,8 +239,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
  console.log('Initialize configuration');
 | 
			
		||||
 | 
			
		||||
  const config = loadPoolConfig(ConfigNames.Amm);
 | 
			
		||||
  
 | 
			
		||||
  const { 
 | 
			
		||||
 | 
			
		||||
  const {
 | 
			
		||||
    ATokenNamePrefix,
 | 
			
		||||
    StableDebtTokenNamePrefix,
 | 
			
		||||
    VariableDebtTokenNamePrefix,
 | 
			
		||||
| 
						 | 
				
			
			@ -292,9 +291,9 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
before(async () => {
 | 
			
		||||
  await rawBRE.run('set-DRE');
 | 
			
		||||
  const [deployer, secondaryWallet] = await getEthersSigners();
 | 
			
		||||
  const MAINNET_FORK = process.env.MAINNET_FORK === 'true';
 | 
			
		||||
  const FORK = process.env.FORK;
 | 
			
		||||
 | 
			
		||||
  if (MAINNET_FORK) {
 | 
			
		||||
  if (FORK) {
 | 
			
		||||
    await rawBRE.run('amm:mainnet');
 | 
			
		||||
  } else {
 | 
			
		||||
    console.log('-> Deploying test environment...');
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ import {
 | 
			
		|||
  getUniswapRepayAdapter,
 | 
			
		||||
  getFlashLiquidationAdapter,
 | 
			
		||||
} from '../../../helpers/contracts-getters';
 | 
			
		||||
import { eEthereumNetwork, tEthereumAddress } from '../../../helpers/types';
 | 
			
		||||
import { eEthereumNetwork, eNetwork, tEthereumAddress } from '../../../helpers/types';
 | 
			
		||||
import { LendingPool } from '../../../types/LendingPool';
 | 
			
		||||
import { AaveProtocolDataProvider } from '../../../types/AaveProtocolDataProvider';
 | 
			
		||||
import { MintableERC20 } from '../../../types/MintableERC20';
 | 
			
		||||
| 
						 | 
				
			
			@ -116,9 +116,9 @@ export async function initializeMakeSuite() {
 | 
			
		|||
 | 
			
		||||
  testEnv.addressesProvider = await getLendingPoolAddressesProvider();
 | 
			
		||||
 | 
			
		||||
  if (process.env.MAINNET_FORK === 'true') {
 | 
			
		||||
  if (process.env.FORK) {
 | 
			
		||||
    testEnv.registry = await getLendingPoolAddressesProviderRegistry(
 | 
			
		||||
      getParamPerNetwork(AmmConfig.ProviderRegistry, eEthereumNetwork.main)
 | 
			
		||||
      getParamPerNetwork(AmmConfig.ProviderRegistry, process.env.FORK as eNetwork)
 | 
			
		||||
    );
 | 
			
		||||
  } else {
 | 
			
		||||
    testEnv.registry = await getLendingPoolAddressesProviderRegistry();
 | 
			
		||||
| 
						 | 
				
			
			@ -163,7 +163,7 @@ export async function initializeMakeSuite() {
 | 
			
		|||
const setSnapshot = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyRPC.getHead()) || '0x1');
 | 
			
		||||
    setBuidlerevmSnapshotId((await hre.tenderlyNetwork.getHead()) || '0x1');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  setBuidlerevmSnapshotId(await evmSnapshot());
 | 
			
		||||
| 
						 | 
				
			
			@ -172,7 +172,7 @@ const setSnapshot = async () => {
 | 
			
		|||
const revertHead = async () => {
 | 
			
		||||
  const hre = DRE as HardhatRuntimeEnvironment;
 | 
			
		||||
  if (usingTenderly()) {
 | 
			
		||||
    await hre.tenderlyRPC.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    await hre.tenderlyNetwork.setHead(buidlerevmSnapshotId);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  await evmRevert(buidlerevmSnapshotId);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@
 | 
			
		|||
    "noImplicitAny": false,
 | 
			
		||||
    "resolveJsonModule": true
 | 
			
		||||
  },
 | 
			
		||||
  "include": ["./scripts", "./test", "./tasks", "test-suites/test-aave/uniswapAdapters.repay.spec.ts", "test-suites/test-aave/upgradeability.spec.ts", "test-suites/test-aave/variable-debt-token.spec.ts", "test-suites/test-aave/weth-gateway.spec.ts"],
 | 
			
		||||
  "include": ["./scripts", "./test", "./tasks", "./helpers", "test-suites/test-aave/uniswapAdapters.repay.spec.ts", "test-suites/test-aave/upgradeability.spec.ts", "test-suites/test-aave/variable-debt-token.spec.ts", "test-suites/test-aave/weth-gateway.spec.ts"],
 | 
			
		||||
  "files": [
 | 
			
		||||
    "./hardhat.config.ts",
 | 
			
		||||
    "./modules/tenderly/tenderly.d.ts",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user