mirror of
				https://github.com/Instadapp/aave-protocol-v2.git
				synced 2024-07-29 21:47:30 +00:00 
			
		
		
		
	Allow WETHGateway to be used by multiple pools. Remove logger.
This commit is contained in:
		
							parent
							
								
									cabff851d0
								
							
						
					
					
						commit
						7282f7678b
					
				| 
						 | 
				
			
			@ -5,56 +5,56 @@ pragma experimental ABIEncoderV2;
 | 
			
		|||
import {IWETH} from './interfaces/IWETH.sol';
 | 
			
		||||
import {IWETHGateway} from './interfaces/IWETHGateway.sol';
 | 
			
		||||
import {ILendingPool} from '../interfaces/ILendingPool.sol';
 | 
			
		||||
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
 | 
			
		||||
import {IAToken} from '../tokenization/interfaces/IAToken.sol';
 | 
			
		||||
import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol';
 | 
			
		||||
import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol';
 | 
			
		||||
import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol';
 | 
			
		||||
import {Helpers} from '../libraries/helpers/Helpers.sol';
 | 
			
		||||
import '@nomiclabs/buidler/console.sol';
 | 
			
		||||
 | 
			
		||||
contract WETHGateway is IWETHGateway {
 | 
			
		||||
  using ReserveConfiguration for ReserveConfiguration.Map;
 | 
			
		||||
  using UserConfiguration for UserConfiguration.Map;
 | 
			
		||||
 | 
			
		||||
  IWETH public immutable WETH;
 | 
			
		||||
  ILendingPoolAddressesProvider public immutable ADDRESSES_PROVIDER;
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev Sets the WETH address and the LendingPoolAddressesProvider address. Infinite approves lending pool.
 | 
			
		||||
   * @param _WETH Address of the Wrapped Ether contract
 | 
			
		||||
   * @param _ADDRESSES_PROVIDER Address of the LendingPoolAddressesProvider contract
 | 
			
		||||
   **/
 | 
			
		||||
  constructor(address _WETH, address _ADDRESSES_PROVIDER) public {
 | 
			
		||||
  constructor(address _WETH) public {
 | 
			
		||||
    WETH = IWETH(_WETH);
 | 
			
		||||
    ADDRESSES_PROVIDER = ILendingPoolAddressesProvider(_ADDRESSES_PROVIDER);
 | 
			
		||||
    IWETH(_WETH).approve(
 | 
			
		||||
      address(ILendingPool(ILendingPoolAddressesProvider(_ADDRESSES_PROVIDER).getLendingPool())),
 | 
			
		||||
      uint256(-1)
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens)
 | 
			
		||||
   * is minted.
 | 
			
		||||
   * @param pool lending pool address to deposit
 | 
			
		||||
   * @param onBehalfOf address of the user who will receive the aTokens representing the deposit
 | 
			
		||||
   * @param referralCode integrators are assigned a referral code and can potentially receive rewards.
 | 
			
		||||
   **/
 | 
			
		||||
  function depositETH(address onBehalfOf, uint16 referralCode) external override payable {
 | 
			
		||||
    ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool());
 | 
			
		||||
  function depositETH(
 | 
			
		||||
    ILendingPool pool,
 | 
			
		||||
    address onBehalfOf,
 | 
			
		||||
    uint16 referralCode
 | 
			
		||||
  ) external override payable {
 | 
			
		||||
    require(address(pool) != address(0));
 | 
			
		||||
    WETH.deposit{value: msg.value}();
 | 
			
		||||
    WETH.approve(address(pool), msg.value);
 | 
			
		||||
    pool.deposit(address(WETH), msg.value, onBehalfOf, referralCode);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
   * @dev withdraws the WETH _reserves of msg.sender.
 | 
			
		||||
   * @param amount address of the user who will receive the aTokens representing the deposit
 | 
			
		||||
   * @param pool lending pool address to withdraw
 | 
			
		||||
   * @param amount amount of aWETH to burn and withdraw ETH asset
 | 
			
		||||
   * @param onBehalfOf address of the user who will receive the ETH withdrawal
 | 
			
		||||
   */
 | 
			
		||||
  function withdrawETH(uint256 amount, address onBehalfOf) external override {
 | 
			
		||||
    ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool());
 | 
			
		||||
  function withdrawETH(
 | 
			
		||||
    ILendingPool pool,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    address onBehalfOf
 | 
			
		||||
  ) external override {
 | 
			
		||||
    require(address(pool) != address(0));
 | 
			
		||||
 | 
			
		||||
    uint256 userBalance = IAToken(pool.getReserveData(address(WETH)).aTokenAddress).balanceOf(
 | 
			
		||||
      msg.sender
 | 
			
		||||
    );
 | 
			
		||||
| 
						 | 
				
			
			@ -81,11 +81,11 @@ contract WETHGateway is IWETHGateway {
 | 
			
		|||
   * @param onBehalfOf the address for which msg.sender is repaying
 | 
			
		||||
   */
 | 
			
		||||
  function repayETH(
 | 
			
		||||
    ILendingPool pool,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    uint256 rateMode,
 | 
			
		||||
    address onBehalfOf
 | 
			
		||||
  ) external override payable {
 | 
			
		||||
    ILendingPool pool = ILendingPool(ADDRESSES_PROVIDER.getLendingPool());
 | 
			
		||||
    require(address(pool) != address(0));
 | 
			
		||||
    (uint256 stableDebt, uint256 variableDebt) = Helpers.getUserCurrentDebtMemory(
 | 
			
		||||
      onBehalfOf,
 | 
			
		||||
| 
						 | 
				
			
			@ -102,6 +102,7 @@ contract WETHGateway is IWETHGateway {
 | 
			
		|||
    }
 | 
			
		||||
    require(msg.value >= paybackAmount, 'msg.value is less than repayment amount');
 | 
			
		||||
    WETH.deposit{value: paybackAmount}();
 | 
			
		||||
    WETH.approve(address(pool), msg.value);
 | 
			
		||||
    pool.repay(address(WETH), msg.value, rateMode, onBehalfOf);
 | 
			
		||||
 | 
			
		||||
    // refund remaining dust eth
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,12 +1,23 @@
 | 
			
		|||
// SPDX-License-Identifier: agpl-3.0
 | 
			
		||||
pragma solidity ^0.6.8;
 | 
			
		||||
 | 
			
		||||
interface IWETHGateway {
 | 
			
		||||
  function depositETH(address onBehalfOf, uint16 referralCode) external payable;
 | 
			
		||||
import {ILendingPool} from '../../interfaces/ILendingPool.sol';
 | 
			
		||||
 | 
			
		||||
  function withdrawETH(uint256 amount, address onBehalfOf) external;
 | 
			
		||||
interface IWETHGateway {
 | 
			
		||||
  function depositETH(
 | 
			
		||||
    ILendingPool pool,
 | 
			
		||||
    address onBehalfOf,
 | 
			
		||||
    uint16 referralCode
 | 
			
		||||
  ) external payable;
 | 
			
		||||
 | 
			
		||||
  function withdrawETH(
 | 
			
		||||
    ILendingPool pool,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    address onBehalfOf
 | 
			
		||||
  ) external;
 | 
			
		||||
 | 
			
		||||
  function repayETH(
 | 
			
		||||
    ILendingPool pool,
 | 
			
		||||
    uint256 amount,
 | 
			
		||||
    uint256 rateMode,
 | 
			
		||||
    address onBehalfOf
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -279,13 +279,13 @@
 | 
			
		|||
  },
 | 
			
		||||
  "MintableDelegationERC20": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x77B0b5636fEA30eA79BB65AeCCdb599997A849A8",
 | 
			
		||||
      "address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "AToken": {
 | 
			
		||||
    "buidlerevm": {
 | 
			
		||||
      "address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c",
 | 
			
		||||
      "address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7",
 | 
			
		||||
      "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,7 +15,7 @@ import {ZERO_ADDRESS} from './constants';
 | 
			
		|||
import {BRE} from './misc-utils';
 | 
			
		||||
import {tEthereumAddress} from './types';
 | 
			
		||||
import {getParamPerNetwork} from './contracts-helpers';
 | 
			
		||||
import {deployWETH} from './contracts-deployments';
 | 
			
		||||
import {deployWETHMocked} from './contracts-deployments';
 | 
			
		||||
 | 
			
		||||
export enum ConfigNames {
 | 
			
		||||
  Commons = 'Commons',
 | 
			
		||||
| 
						 | 
				
			
			@ -88,6 +88,9 @@ export const getWethAddress = async (config: ICommonConfiguration) => {
 | 
			
		|||
  if (wethAddress) {
 | 
			
		||||
    return wethAddress;
 | 
			
		||||
  }
 | 
			
		||||
  const weth = await deployWETH();
 | 
			
		||||
  if (currentNetwork.includes('main')) {
 | 
			
		||||
    throw new Error('WETH not set at mainnet configuration.');
 | 
			
		||||
  }
 | 
			
		||||
  const weth = await deployWETHMocked();
 | 
			
		||||
  return weth.address;
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -421,10 +421,7 @@ export const deployATokensAndRatesHelper = async (
 | 
			
		|||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployWETHGateway = async (
 | 
			
		||||
  args: [tEthereumAddress, tEthereumAddress],
 | 
			
		||||
  verify?: boolean
 | 
			
		||||
) =>
 | 
			
		||||
export const deployWETHGateway = async (args: [tEthereumAddress], verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new WethGatewayFactory(await getFirstSigner()).deploy(...args),
 | 
			
		||||
    eContractid.WETHGateway,
 | 
			
		||||
| 
						 | 
				
			
			@ -443,14 +440,6 @@ export const deployMockStableDebtToken = async (
 | 
			
		|||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployWETH = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new Weth9Factory(await getFirstSigner()).deploy(),
 | 
			
		||||
    eContractid.WETH,
 | 
			
		||||
    [],
 | 
			
		||||
    verify
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const deployWETHMocked = async (verify?: boolean) =>
 | 
			
		||||
  withSaveAndVerify(
 | 
			
		||||
    await new Weth9MockedFactory(await getFirstSigner()).deploy(),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -236,12 +236,6 @@ export const getWETHGateway = async (address?: tEthereumAddress) =>
 | 
			
		|||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getWETH = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await Weth9Factory.connect(
 | 
			
		||||
    address || (await getDb().get(`${eContractid.WETH}.${BRE.network.name}`).value()).address,
 | 
			
		||||
    await getFirstSigner()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
export const getWETHMocked = async (address?: tEthereumAddress) =>
 | 
			
		||||
  await Weth9MockedFactory.connect(
 | 
			
		||||
    address || (await getDb().get(`${eContractid.WETHMocked}.${BRE.network.name}`).value()).address,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,12 +22,7 @@ import {
 | 
			
		|||
} from '../../helpers/init-helpers';
 | 
			
		||||
import {getAllTokenAddresses} from '../../helpers/mock-helpers';
 | 
			
		||||
import {ZERO_ADDRESS} from '../../helpers/constants';
 | 
			
		||||
import {
 | 
			
		||||
  getAllMockedTokens,
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import {getAllMockedTokens, getLendingPoolAddressesProvider} from '../../helpers/contracts-getters';
 | 
			
		||||
import {insertContractAddressInDb} from '../../helpers/contracts-helpers';
 | 
			
		||||
 | 
			
		||||
task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		||||
| 
						 | 
				
			
			@ -38,8 +33,6 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
    const poolConfig = loadPoolConfig(pool);
 | 
			
		||||
 | 
			
		||||
    const mockTokens = await getAllMockedTokens();
 | 
			
		||||
    const lendingPoolProxy = await getLendingPool();
 | 
			
		||||
    const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy();
 | 
			
		||||
    const allTokenAddresses = getAllTokenAddresses(mockTokens);
 | 
			
		||||
 | 
			
		||||
    const addressesProvider = await getLendingPoolAddressesProvider();
 | 
			
		||||
| 
						 | 
				
			
			@ -87,5 +80,5 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
    await insertContractAddressInDb(eContractid.AaveProtocolTestHelpers, testHelpers.address);
 | 
			
		||||
 | 
			
		||||
    const wethAddress = await getWethAddress(poolConfig);
 | 
			
		||||
    await deployWETHGateway([wethAddress, addressesProvider.address]);
 | 
			
		||||
    await deployWETHGateway([wethAddress]);
 | 
			
		||||
  });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,11 +15,7 @@ import {
 | 
			
		|||
  enableReservesAsCollateralByHelper,
 | 
			
		||||
} from '../../helpers/init-helpers';
 | 
			
		||||
import {exit} from 'process';
 | 
			
		||||
import {
 | 
			
		||||
  getLendingPool,
 | 
			
		||||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getLendingPoolAddressesProvider,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
import {getLendingPoolAddressesProvider} from '../../helpers/contracts-getters';
 | 
			
		||||
import {ZERO_ADDRESS} from '../../helpers/constants';
 | 
			
		||||
 | 
			
		||||
task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		||||
| 
						 | 
				
			
			@ -33,8 +29,6 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
      const {ReserveAssets, ReservesConfig} = poolConfig as ICommonConfiguration;
 | 
			
		||||
 | 
			
		||||
      const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
 | 
			
		||||
      const lendingPoolProxy = await getLendingPool();
 | 
			
		||||
      const lendingPoolConfiguratorProxy = await getLendingPoolConfiguratorProxy();
 | 
			
		||||
 | 
			
		||||
      const addressesProvider = await getLendingPoolAddressesProvider();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -57,7 +51,7 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
 | 
			
		|||
      await deployWalletBalancerProvider(addressesProvider.address, verify);
 | 
			
		||||
 | 
			
		||||
      const wethAddress = await getWethAddress(poolConfig);
 | 
			
		||||
      await deployWETHGateway([wethAddress, addressesProvider.address]);
 | 
			
		||||
      await deployWETHGateway([wethAddress]);
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      console.error(err);
 | 
			
		||||
      exit(1);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -250,7 +250,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
 | 
			
		|||
 | 
			
		||||
  await deployWalletBalancerProvider(addressesProvider.address);
 | 
			
		||||
 | 
			
		||||
  await deployWETHGateway([mockTokens.WETH.address, addressesProvider.address]);
 | 
			
		||||
  await deployWETHGateway([mockTokens.WETH.address]);
 | 
			
		||||
 | 
			
		||||
  console.timeEnd('setup');
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,17 +18,16 @@ import {
 | 
			
		|||
import {getReserveAddressFromSymbol, getReserveData, getUserData} from './utils/helpers';
 | 
			
		||||
 | 
			
		||||
import {convertToCurrencyDecimals} from '../../helpers/contracts-helpers';
 | 
			
		||||
import {getAToken, getMintableErc20, getWETH} from '../../helpers/contracts-getters';
 | 
			
		||||
import {getAToken, getMintableErc20} from '../../helpers/contracts-getters';
 | 
			
		||||
import {MAX_UINT_AMOUNT, ONE_YEAR} from '../../helpers/constants';
 | 
			
		||||
import {SignerWithAddress, TestEnv} from './make-suite';
 | 
			
		||||
import {BRE, increaseTime, timeLatest, waitForTx} from '../../helpers/misc-utils';
 | 
			
		||||
 | 
			
		||||
import chai from 'chai';
 | 
			
		||||
import {ReserveData, UserReserveData} from './utils/interfaces';
 | 
			
		||||
import {ContractReceipt, Signer} from 'ethers';
 | 
			
		||||
import {ContractReceipt} from 'ethers';
 | 
			
		||||
import {AToken} from '../../types/AToken';
 | 
			
		||||
import {RateMode, tEthereumAddress} from '../../helpers/types';
 | 
			
		||||
import {getWethAddress} from '../../helpers/configuration';
 | 
			
		||||
 | 
			
		||||
const {expect} = chai;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,7 +9,6 @@ import {
 | 
			
		|||
  getLendingPoolConfiguratorProxy,
 | 
			
		||||
  getPriceOracle,
 | 
			
		||||
  getLendingPoolAddressesProviderRegistry,
 | 
			
		||||
  getWETH,
 | 
			
		||||
  getWETHMocked,
 | 
			
		||||
  getWETHGateway,
 | 
			
		||||
} from '../../helpers/contracts-getters';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,12 +13,12 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
  const depositSize = parseEther('5');
 | 
			
		||||
 | 
			
		||||
  it('Deposit WETH', async () => {
 | 
			
		||||
    const {users, wethGateway, aWETH} = testEnv;
 | 
			
		||||
    const {users, wethGateway, aWETH, pool} = testEnv;
 | 
			
		||||
 | 
			
		||||
    const user = users[1];
 | 
			
		||||
 | 
			
		||||
    // Deposit with native ETH
 | 
			
		||||
    await wethGateway.connect(user.signer).depositETH(user.address, '0', {value: depositSize});
 | 
			
		||||
    await wethGateway.connect(user.signer).depositETH(pool.address, user.address, '0', {value: depositSize});
 | 
			
		||||
 | 
			
		||||
    const aTokensBalance = await aWETH.balanceOf(user.address);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
  });
 | 
			
		||||
 | 
			
		||||
  it('Withdraw WETH - Partial', async () => {
 | 
			
		||||
    const {users, wethGateway, aWETH} = testEnv;
 | 
			
		||||
    const {users, wethGateway, aWETH, pool} = testEnv;
 | 
			
		||||
 | 
			
		||||
    const user = users[1];
 | 
			
		||||
    const priorEthersBalance = await user.signer.getBalance();
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
 | 
			
		||||
    // Partial Withdraw and send native Ether to user
 | 
			
		||||
    const {gasUsed: withdrawGas} = await waitForTx(
 | 
			
		||||
      await wethGateway.connect(user.signer).withdrawETH(partialWithdraw, user.address)
 | 
			
		||||
      await wethGateway.connect(user.signer).withdrawETH(pool.address, partialWithdraw, user.address)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const afterPartialEtherBalance = await user.signer.getBalance();
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
  });
 | 
			
		||||
 | 
			
		||||
  it('Withdraw WETH - Full', async () => {
 | 
			
		||||
    const {users, aWETH, wethGateway} = testEnv;
 | 
			
		||||
    const {users, aWETH, wethGateway, pool} = testEnv;
 | 
			
		||||
 | 
			
		||||
    const user = users[1];
 | 
			
		||||
    const priorEthersBalance = await user.signer.getBalance();
 | 
			
		||||
| 
						 | 
				
			
			@ -80,7 +80,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
 | 
			
		||||
    // Full withdraw
 | 
			
		||||
    const {gasUsed: withdrawGas} = await waitForTx(
 | 
			
		||||
      await wethGateway.connect(user.signer).withdrawETH(MAX_UINT_AMOUNT, user.address)
 | 
			
		||||
      await wethGateway.connect(user.signer).withdrawETH(pool.address, MAX_UINT_AMOUNT, user.address)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const afterFullEtherBalance = await user.signer.getBalance();
 | 
			
		||||
| 
						 | 
				
			
			@ -105,7 +105,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
    const stableDebtToken = await getStableDebtToken(stableDebtTokenAddress);
 | 
			
		||||
 | 
			
		||||
    // Deposit with native ETH
 | 
			
		||||
    await wethGateway.connect(user.signer).depositETH(user.address, '0', {value: depositSize});
 | 
			
		||||
    await wethGateway.connect(user.signer).depositETH(pool.address, user.address, '0', {value: depositSize});
 | 
			
		||||
 | 
			
		||||
    const aTokensBalance = await aWETH.balanceOf(user.address);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -125,7 +125,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
    await waitForTx(
 | 
			
		||||
      await wethGateway
 | 
			
		||||
        .connect(user.signer)
 | 
			
		||||
        .repayETH(MAX_UINT_AMOUNT, '1', user.address, {value: repaySize})
 | 
			
		||||
        .repayETH(pool.address, MAX_UINT_AMOUNT, '1', user.address, {value: repaySize})
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const debtBalanceAfterRepay = await stableDebtToken.balanceOf(user.address);
 | 
			
		||||
| 
						 | 
				
			
			@ -145,7 +145,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
    const varDebtToken = await getVariableDebtToken(variableDebtTokenAddress);
 | 
			
		||||
 | 
			
		||||
    // Deposit with native ETH
 | 
			
		||||
    await wethGateway.connect(user.signer).depositETH(user.address, '0', {value: depositSize});
 | 
			
		||||
    await wethGateway.connect(user.signer).depositETH(pool.address, user.address, '0', {value: depositSize});
 | 
			
		||||
 | 
			
		||||
    const aTokensBalance = await aWETH.balanceOf(user.address);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -166,7 +166,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
    await waitForTx(
 | 
			
		||||
      await wethGateway
 | 
			
		||||
        .connect(user.signer)
 | 
			
		||||
        .repayETH(partialPayment, '2', user.address, {value: partialPayment})
 | 
			
		||||
        .repayETH(pool.address, partialPayment, '2', user.address, {value: partialPayment})
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
    const debtBalanceAfterPartialRepay = await varDebtToken.balanceOf(user.address);
 | 
			
		||||
| 
						 | 
				
			
			@ -176,7 +176,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
 | 
			
		|||
    await waitForTx(
 | 
			
		||||
      await wethGateway
 | 
			
		||||
        .connect(user.signer)
 | 
			
		||||
        .repayETH(MAX_UINT_AMOUNT, '2', user.address, {value: repaySize})
 | 
			
		||||
        .repayETH(pool.address, MAX_UINT_AMOUNT, '2', user.address, {value: repaySize})
 | 
			
		||||
    );
 | 
			
		||||
    const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
 | 
			
		||||
    expect(debtBalanceAfterFullRepay).to.be.eq(zero);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user