mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Merge pull request #39 from aave/feat/update-wethgateway
Feat/update wethgateway
This commit is contained in:
commit
e9451c85eb
|
@ -18,39 +18,47 @@ contract WETHGateway is IWETHGateway, Ownable {
|
|||
using UserConfiguration for DataTypes.UserConfigurationMap;
|
||||
|
||||
IWETH internal immutable WETH;
|
||||
ILendingPool internal immutable POOL;
|
||||
IAToken internal immutable aWETH;
|
||||
|
||||
/**
|
||||
* @dev Sets the WETH address and the LendingPoolAddressesProvider address. Infinite approves lending pool.
|
||||
* @param weth Address of the Wrapped Ether contract
|
||||
* @param pool Address of the LendingPool contract
|
||||
**/
|
||||
constructor(address weth, address pool) public {
|
||||
ILendingPool poolInstance = ILendingPool(pool);
|
||||
constructor(address weth) public {
|
||||
WETH = IWETH(weth);
|
||||
POOL = poolInstance;
|
||||
aWETH = IAToken(poolInstance.getReserveData(weth).aTokenAddress);
|
||||
IWETH(weth).approve(pool, uint256(-1));
|
||||
}
|
||||
|
||||
function authorizeLendingPool(address lendingPool) external onlyOwner {
|
||||
WETH.approve(lendingPool, uint256(-1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens)
|
||||
* is minted.
|
||||
* @param lendingPool address of the targeted underlying lending pool
|
||||
* @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 payable override {
|
||||
function depositETH(
|
||||
address lendingPool,
|
||||
address onBehalfOf,
|
||||
uint16 referralCode
|
||||
) external payable override {
|
||||
WETH.deposit{value: msg.value}();
|
||||
POOL.deposit(address(WETH), msg.value, onBehalfOf, referralCode);
|
||||
ILendingPool(lendingPool).deposit(address(WETH), msg.value, onBehalfOf, referralCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev withdraws the WETH _reserves of msg.sender.
|
||||
* @param lendingPool address of the targeted underlying lending pool
|
||||
* @param amount amount of aWETH to withdraw and receive native ETH
|
||||
* @param to address of the user who will receive native ETH
|
||||
*/
|
||||
function withdrawETH(uint256 amount, address to) external override {
|
||||
function withdrawETH(
|
||||
address lendingPool,
|
||||
uint256 amount,
|
||||
address to
|
||||
) external override {
|
||||
IAToken aWETH = IAToken(ILendingPool(lendingPool).getReserveData(address(WETH)).aTokenAddress);
|
||||
uint256 userBalance = aWETH.balanceOf(msg.sender);
|
||||
uint256 amountToWithdraw = amount;
|
||||
|
||||
|
@ -59,24 +67,29 @@ contract WETHGateway is IWETHGateway, Ownable {
|
|||
amountToWithdraw = userBalance;
|
||||
}
|
||||
aWETH.transferFrom(msg.sender, address(this), amountToWithdraw);
|
||||
POOL.withdraw(address(WETH), amountToWithdraw, address(this));
|
||||
ILendingPool(lendingPool).withdraw(address(WETH), amountToWithdraw, address(this));
|
||||
WETH.withdraw(amountToWithdraw);
|
||||
_safeTransferETH(to, amountToWithdraw);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified).
|
||||
* @param lendingPool address of the targeted underlying lending pool
|
||||
* @param amount the amount to repay, or uint256(-1) if the user wants to repay everything
|
||||
* @param rateMode the rate mode to repay
|
||||
* @param onBehalfOf the address for which msg.sender is repaying
|
||||
*/
|
||||
function repayETH(
|
||||
address lendingPool,
|
||||
uint256 amount,
|
||||
uint256 rateMode,
|
||||
address onBehalfOf
|
||||
) external payable override {
|
||||
(uint256 stableDebt, uint256 variableDebt) =
|
||||
Helpers.getUserCurrentDebtMemory(onBehalfOf, POOL.getReserveData(address(WETH)));
|
||||
Helpers.getUserCurrentDebtMemory(
|
||||
onBehalfOf,
|
||||
ILendingPool(lendingPool).getReserveData(address(WETH))
|
||||
);
|
||||
|
||||
uint256 paybackAmount =
|
||||
DataTypes.InterestRateMode(rateMode) == DataTypes.InterestRateMode.STABLE
|
||||
|
@ -88,7 +101,7 @@ contract WETHGateway is IWETHGateway, Ownable {
|
|||
}
|
||||
require(msg.value >= paybackAmount, 'msg.value is less than repayment amount');
|
||||
WETH.deposit{value: paybackAmount}();
|
||||
POOL.repay(address(WETH), msg.value, rateMode, onBehalfOf);
|
||||
ILendingPool(lendingPool).repay(address(WETH), msg.value, rateMode, onBehalfOf);
|
||||
|
||||
// refund remaining dust eth
|
||||
if (msg.value > paybackAmount) _safeTransferETH(msg.sender, msg.value - paybackAmount);
|
||||
|
@ -96,16 +109,24 @@ contract WETHGateway is IWETHGateway, Ownable {
|
|||
|
||||
/**
|
||||
* @dev borrow WETH, unwraps to ETH and send both the ETH and DebtTokens to msg.sender, via `approveDelegation` and onBehalf argument in `LendingPool.borrow`.
|
||||
* @param lendingPool address of the targeted underlying lending pool
|
||||
* @param amount the amount of ETH to borrow
|
||||
* @param interesRateMode the interest rate mode
|
||||
* @param referralCode integrators are assigned a referral code and can potentially receive rewards
|
||||
*/
|
||||
function borrowETH(
|
||||
address lendingPool,
|
||||
uint256 amount,
|
||||
uint256 interesRateMode,
|
||||
uint16 referralCode
|
||||
) external override {
|
||||
POOL.borrow(address(WETH), amount, interesRateMode, referralCode, msg.sender);
|
||||
ILendingPool(lendingPool).borrow(
|
||||
address(WETH),
|
||||
amount,
|
||||
interesRateMode,
|
||||
referralCode,
|
||||
msg.sender
|
||||
);
|
||||
WETH.withdraw(amount);
|
||||
_safeTransferETH(msg.sender, amount);
|
||||
}
|
||||
|
@ -152,20 +173,6 @@ contract WETHGateway is IWETHGateway, Ownable {
|
|||
return address(WETH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get aWETH address used by WETHGateway
|
||||
*/
|
||||
function getAWETHAddress() external view returns (address) {
|
||||
return address(aWETH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Get LendingPool address used by WETHGateway
|
||||
*/
|
||||
function getLendingPoolAddress() external view returns (address) {
|
||||
return address(POOL);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Only WETH contract is allowed to transfer ETH here. Prevent other addresses to send Ether to this contract.
|
||||
*/
|
||||
|
|
|
@ -2,17 +2,27 @@
|
|||
pragma solidity 0.6.12;
|
||||
|
||||
interface IWETHGateway {
|
||||
function depositETH(address onBehalfOf, uint16 referralCode) external payable;
|
||||
function depositETH(
|
||||
address lendingPool,
|
||||
address onBehalfOf,
|
||||
uint16 referralCode
|
||||
) external payable;
|
||||
|
||||
function withdrawETH(uint256 amount, address onBehalfOf) external;
|
||||
function withdrawETH(
|
||||
address lendingPool,
|
||||
uint256 amount,
|
||||
address onBehalfOf
|
||||
) external;
|
||||
|
||||
function repayETH(
|
||||
address lendingPool,
|
||||
uint256 amount,
|
||||
uint256 rateMode,
|
||||
address onBehalfOf
|
||||
) external payable;
|
||||
|
||||
function borrowETH(
|
||||
address lendingPool,
|
||||
uint256 amount,
|
||||
uint256 interesRateMode,
|
||||
uint16 referralCode
|
||||
|
|
|
@ -310,18 +310,10 @@ export const deployStableDebtToken = async (
|
|||
verify
|
||||
);
|
||||
|
||||
await instance.initialize(
|
||||
args[0],
|
||||
args[1],
|
||||
args[2],
|
||||
"18",
|
||||
args[3],
|
||||
args[4]
|
||||
);
|
||||
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const deployVariableDebtToken = async (
|
||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||
|
@ -334,18 +326,10 @@ export const deployVariableDebtToken = async (
|
|||
verify
|
||||
);
|
||||
|
||||
await instance.initialize(
|
||||
args[0],
|
||||
args[1],
|
||||
args[2],
|
||||
"18",
|
||||
args[3],
|
||||
args[4]
|
||||
);
|
||||
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const deployGenericAToken = async (
|
||||
[poolAddress, underlyingAssetAddress, treasuryAddress, incentivesController, name, symbol]: [
|
||||
|
@ -364,23 +348,22 @@ export const deployGenericAToken = async (
|
|||
[],
|
||||
verify
|
||||
);
|
||||
|
||||
|
||||
await instance.initialize(
|
||||
poolAddress,
|
||||
poolAddress,
|
||||
treasuryAddress,
|
||||
underlyingAssetAddress,
|
||||
incentivesController,
|
||||
"18",
|
||||
name,
|
||||
underlyingAssetAddress,
|
||||
incentivesController,
|
||||
'18',
|
||||
name,
|
||||
symbol
|
||||
);
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
export const deployGenericATokenImpl = async (
|
||||
verify: boolean
|
||||
) => withSaveAndVerify(
|
||||
export const deployGenericATokenImpl = async (verify: boolean) =>
|
||||
withSaveAndVerify(
|
||||
await new ATokenFactory(await getFirstSigner()).deploy(),
|
||||
eContractid.AToken,
|
||||
[],
|
||||
|
@ -404,23 +387,22 @@ export const deployDelegationAwareAToken = async (
|
|||
[],
|
||||
verify
|
||||
);
|
||||
|
||||
|
||||
await instance.initialize(
|
||||
pool,
|
||||
treasuryAddress,
|
||||
underlyingAssetAddress,
|
||||
incentivesController,
|
||||
"18",
|
||||
'18',
|
||||
name,
|
||||
symbol
|
||||
)
|
||||
);
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
export const deployDelegationAwareATokenImpl = async (
|
||||
verify: boolean
|
||||
) => withSaveAndVerify(
|
||||
export const deployDelegationAwareATokenImpl = async (verify: boolean) =>
|
||||
withSaveAndVerify(
|
||||
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(),
|
||||
eContractid.DelegationAwareAToken,
|
||||
[],
|
||||
|
@ -489,10 +471,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,
|
||||
|
@ -500,6 +479,14 @@ export const deployWETHGateway = async (
|
|||
verify
|
||||
);
|
||||
|
||||
export const authorizeWETHGateway = async (
|
||||
wethGateWay: tEthereumAddress,
|
||||
lendingPool: tEthereumAddress
|
||||
) =>
|
||||
await new WETHGatewayFactory(await getFirstSigner())
|
||||
.attach(wethGateWay)
|
||||
.authorizeLendingPool(lendingPool);
|
||||
|
||||
export const deployMockStableDebtToken = async (
|
||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||
verify?: boolean
|
||||
|
@ -511,18 +498,10 @@ export const deployMockStableDebtToken = async (
|
|||
verify
|
||||
);
|
||||
|
||||
await instance.initialize(
|
||||
args[0],
|
||||
args[1],
|
||||
args[2],
|
||||
"18",
|
||||
args[3],
|
||||
args[4]
|
||||
);
|
||||
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const deployWETHMocked = async (verify?: boolean) =>
|
||||
withSaveAndVerify(
|
||||
|
@ -543,21 +522,13 @@ export const deployMockVariableDebtToken = async (
|
|||
verify
|
||||
);
|
||||
|
||||
await instance.initialize(
|
||||
args[0],
|
||||
args[1],
|
||||
args[2],
|
||||
"18",
|
||||
args[3],
|
||||
args[4]
|
||||
);
|
||||
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const deployMockAToken = async (
|
||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress,tEthereumAddress, string, string],
|
||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||
verify?: boolean
|
||||
) => {
|
||||
const instance = await withSaveAndVerify(
|
||||
|
@ -566,20 +537,11 @@ args: [tEthereumAddress, tEthereumAddress, tEthereumAddress,tEthereumAddress, st
|
|||
[],
|
||||
verify
|
||||
);
|
||||
|
||||
await instance.initialize(
|
||||
args[0],
|
||||
args[2],
|
||||
args[1],
|
||||
args[3],
|
||||
"18",
|
||||
args[4],
|
||||
args[5],
|
||||
);
|
||||
|
||||
await instance.initialize(args[0], args[2], args[1], args[3], '18', args[4], args[5]);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export const deploySelfdestructTransferMock = async (verify?: boolean) =>
|
||||
withSaveAndVerify(
|
||||
|
|
|
@ -336,7 +336,7 @@ export interface IReserveParams extends IReserveBorrowParams, IReserveCollateral
|
|||
}
|
||||
|
||||
export interface IInterestRateStrategyParams {
|
||||
name: string,
|
||||
name: string;
|
||||
optimalUtilizationRate: string;
|
||||
baseVariableBorrowRate: string;
|
||||
variableRateSlope1: string;
|
||||
|
@ -452,6 +452,7 @@ export interface ICommonConfiguration {
|
|||
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
||||
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
||||
WETH: iParamsPerNetwork<tEthereumAddress>;
|
||||
WethGateway: iParamsPerNetwork<tEthereumAddress>;
|
||||
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import BigNumber from 'bignumber.js';
|
||||
import { oneEther, oneRay, RAY, ZERO_ADDRESS } from '../../helpers/constants';
|
||||
import { ICommonConfiguration, EthereumNetwork, eEthereumNetwork } from '../../helpers/types';
|
||||
|
||||
|
@ -196,6 +195,15 @@ export const CommonsConfig: ICommonConfiguration = {
|
|||
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||
[eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||
},
|
||||
WethGateway: {
|
||||
[eEthereumNetwork.coverage]: '',
|
||||
[eEthereumNetwork.hardhat]: '',
|
||||
[eEthereumNetwork.buidlerevm]: '',
|
||||
[eEthereumNetwork.kovan]: '0xf99b8E67a0E044734B01EC4586D1c88C9a869718',
|
||||
[eEthereumNetwork.ropsten]: '',
|
||||
[eEthereumNetwork.main]: '',
|
||||
[eEthereumNetwork.tenderlyMain]: '',
|
||||
},
|
||||
TokenDistributor: {
|
||||
[eEthereumNetwork.coverage]: '',
|
||||
[eEthereumNetwork.buidlerevm]: '',
|
||||
|
|
|
@ -199,6 +199,15 @@ export const CommonsConfig: ICommonConfiguration = {
|
|||
[eEthereumNetwork.main]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||
[eEthereumNetwork.tenderlyMain]: '0xbd4765210d4167CE2A5b87280D9E8Ee316D5EC7C',
|
||||
},
|
||||
WethGateway: {
|
||||
[eEthereumNetwork.coverage]: '',
|
||||
[eEthereumNetwork.hardhat]: '',
|
||||
[eEthereumNetwork.buidlerevm]: '',
|
||||
[eEthereumNetwork.kovan]: '',
|
||||
[eEthereumNetwork.ropsten]: '',
|
||||
[eEthereumNetwork.main]: '',
|
||||
[eEthereumNetwork.tenderlyMain]: '',
|
||||
},
|
||||
TokenDistributor: {
|
||||
[eEthereumNetwork.coverage]: '',
|
||||
[eEthereumNetwork.buidlerevm]: '',
|
||||
|
|
25493
package-lock.json
generated
25493
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -32,7 +32,8 @@
|
|||
"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": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/weth-gateway.spec.ts",
|
||||
"test-weth:main": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/weth-gateway.spec.ts",
|
||||
"test-weth:lp": "hardhat test test-suites/test-lp/__setup.spec.ts test-suites/test-lp/weth-gateway.spec.ts",
|
||||
"test-uniswap": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/uniswapAdapters*.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",
|
||||
"dev:coverage": "buidler compile --force && buidler coverage --network coverage",
|
||||
|
|
|
@ -5,7 +5,10 @@ import {
|
|||
deployWalletBalancerProvider,
|
||||
deployAaveProtocolDataProvider,
|
||||
deployWETHGateway,
|
||||
authorizeWETHGateway,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||
import { eEthereumNetwork } from '../../helpers/types';
|
||||
import {
|
||||
ConfigNames,
|
||||
getReservesConfigByPool,
|
||||
|
@ -30,12 +33,14 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.setAction(async ({ verify, pool }, localBRE) => {
|
||||
await localBRE.run('set-DRE');
|
||||
const network = <eEthereumNetwork>localBRE.network.name;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const {
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
VariableDebtTokenNamePrefix,
|
||||
SymbolPrefix,
|
||||
WethGateway,
|
||||
} = poolConfig;
|
||||
const mockTokens = await getAllMockedTokens();
|
||||
const allTokenAddresses = getAllTokenAddresses(mockTokens);
|
||||
|
@ -87,6 +92,6 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address);
|
||||
|
||||
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
||||
const wethAddress = await getWethAddress(poolConfig);
|
||||
await deployWETHGateway([wethAddress, lendingPoolAddress]);
|
||||
const gateWay = await getParamPerNetwork(WethGateway, network);
|
||||
await authorizeWETHGateway(gateWay, lendingPoolAddress);
|
||||
});
|
||||
|
|
32
tasks/full/5-deploy-wethGateWay.ts
Normal file
32
tasks/full/5-deploy-wethGateWay.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
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 { deployWETHGateway } from '../../helpers/contracts-deployments';
|
||||
import { DRE } from '../../helpers/misc-utils';
|
||||
import { eEthereumNetwork } from '../../helpers/types';
|
||||
|
||||
const CONTRACT_NAME = 'WETHGateway';
|
||||
|
||||
task(`full-deploy-weth-gateway`, `Deploys the ${CONTRACT_NAME} contract`)
|
||||
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||
.addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`)
|
||||
.setAction(async ({ verify, pool }, localBRE) => {
|
||||
await localBRE.run('set-DRE');
|
||||
const network = <eEthereumNetwork>localBRE.network.name;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const Weth = await getWethAddress(poolConfig);
|
||||
const { WethGateway } = 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}`);
|
||||
}
|
||||
});
|
|
@ -4,6 +4,7 @@ import {
|
|||
deployLendingPoolCollateralManager,
|
||||
deployWalletBalancerProvider,
|
||||
deployWETHGateway,
|
||||
authorizeWETHGateway,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import {
|
||||
loadPoolConfig,
|
||||
|
@ -11,6 +12,7 @@ import {
|
|||
getWethAddress,
|
||||
getTreasuryAddress,
|
||||
} from '../../helpers/configuration';
|
||||
import { getWETHGateway } from '../../helpers/contracts-getters';
|
||||
import { eEthereumNetwork, ICommonConfiguration } from '../../helpers/types';
|
||||
import { waitForTx } from '../../helpers/misc-utils';
|
||||
import { initReservesByHelper, configureReservesByHelper } from '../../helpers/init-helpers';
|
||||
|
@ -29,14 +31,15 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
await localBRE.run('set-DRE');
|
||||
const network = <eEthereumNetwork>localBRE.network.name;
|
||||
const poolConfig = loadPoolConfig(pool);
|
||||
const {
|
||||
const {
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
VariableDebtTokenNamePrefix,
|
||||
SymbolPrefix,
|
||||
ReserveAssets,
|
||||
ReservesConfig,
|
||||
LendingPoolCollateralManager
|
||||
LendingPoolCollateralManager,
|
||||
WethGateway,
|
||||
} = poolConfig as ICommonConfiguration;
|
||||
|
||||
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
||||
|
@ -66,9 +69,10 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
);
|
||||
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||
|
||||
|
||||
|
||||
let collateralManagerAddress = await getParamPerNetwork(LendingPoolCollateralManager, network);
|
||||
let collateralManagerAddress = await getParamPerNetwork(
|
||||
LendingPoolCollateralManager,
|
||||
network
|
||||
);
|
||||
if (!collateralManagerAddress) {
|
||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||
collateralManagerAddress = collateralManager.address;
|
||||
|
@ -81,10 +85,13 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
|||
|
||||
await deployWalletBalancerProvider(verify);
|
||||
|
||||
const wethAddress = await getWethAddress(poolConfig);
|
||||
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
||||
|
||||
await deployWETHGateway([wethAddress, lendingPoolAddress]);
|
||||
let gateWay = getParamPerNetwork(WethGateway, network);
|
||||
if (gateWay == '') {
|
||||
gateWay = (await getWETHGateway()).address;
|
||||
}
|
||||
await authorizeWETHGateway(gateWay, lendingPoolAddress);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
exit(1);
|
|
@ -29,15 +29,18 @@ task('aave:mainnet', 'Deploy development enviroment')
|
|||
console.log('4. Deploy Data Provider');
|
||||
await DRE.run('full:data-provider', { pool: POOL_NAME });
|
||||
|
||||
console.log('5. Initialize lending pool');
|
||||
console.log('5. Deploy WETH Gateway');
|
||||
await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME });
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
|
|
|
@ -29,15 +29,18 @@ task('lp:mainnet', 'Deploy development enviroment')
|
|||
console.log('4. Deploy Data Provider');
|
||||
await DRE.run('full:data-provider', { pool: POOL_NAME });
|
||||
|
||||
console.log('5. Initialize lending pool');
|
||||
console.log('5. Deploy WETH Gateway');
|
||||
await DRE.run('full-deploy-weth-gateway', { pool: POOL_NAME });
|
||||
|
||||
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 });
|
||||
}
|
||||
|
||||
|
|
|
@ -89,10 +89,7 @@ task('verify:general', 'Deploy oracles for dev enviroment')
|
|||
|
||||
// WETHGateway
|
||||
console.log('\n- Verifying WETHGateway...\n');
|
||||
await verifyContract(wethGateway.address, [
|
||||
await getWethAddress(poolConfig),
|
||||
lendingPoolProxy.address,
|
||||
]);
|
||||
await verifyContract(wethGateway.address, [await getWethAddress(poolConfig)]);
|
||||
}
|
||||
// Lending Pool proxy
|
||||
console.log('\n- Verifying Lending Pool Proxy...\n');
|
||||
|
|
|
@ -26,7 +26,9 @@ import {
|
|||
deployUniswapLiquiditySwapAdapter,
|
||||
deployUniswapRepayAdapter,
|
||||
deployFlashLiquidationAdapter,
|
||||
authorizeWETHGateway,
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { eEthereumNetwork } from '../../helpers/types';
|
||||
import { Signer } from 'ethers';
|
||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||
import { MintableERC20 } from '../../types/MintableERC20';
|
||||
|
@ -95,7 +97,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
const aaveAdmin = await deployer.getAddress();
|
||||
|
||||
const mockTokens = await deployAllMockTokens(deployer);
|
||||
console.log("Deployed mocks");
|
||||
console.log('Deployed mocks');
|
||||
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||
|
||||
|
@ -191,7 +193,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
);
|
||||
|
||||
const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES);
|
||||
console.log("Mock aggs deployed");
|
||||
console.log('Mock aggs deployed');
|
||||
const allTokenAddresses = Object.entries(mockTokens).reduce(
|
||||
(accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({
|
||||
...accum,
|
||||
|
@ -237,7 +239,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
|
||||
const config = loadPoolConfig(ConfigNames.Aave);
|
||||
|
||||
const {
|
||||
const {
|
||||
ATokenNamePrefix,
|
||||
StableDebtTokenNamePrefix,
|
||||
VariableDebtTokenNamePrefix,
|
||||
|
@ -280,7 +282,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
|
||||
await deployWalletBalancerProvider();
|
||||
|
||||
await deployWETHGateway([mockTokens.WETH.address, lendingPoolAddress]);
|
||||
const gateWay = await deployWETHGateway([mockTokens.WETH.address]);
|
||||
await authorizeWETHGateway(gateWay.address, lendingPoolAddress);
|
||||
|
||||
console.timeEnd('setup');
|
||||
};
|
||||
|
|
|
@ -14,7 +14,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
const depositSize = parseEther('5');
|
||||
const daiSize = parseEther('10000');
|
||||
it('Deposit WETH via WethGateway and DAI', async () => {
|
||||
const { users, wethGateway, aWETH } = testEnv;
|
||||
const { users, wethGateway, aWETH, pool } = testEnv;
|
||||
|
||||
const user = users[1];
|
||||
const depositor = users[0];
|
||||
|
@ -22,10 +22,12 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
// Deposit liquidity with native ETH
|
||||
await wethGateway
|
||||
.connect(depositor.signer)
|
||||
.depositETH(depositor.address, '0', { value: depositSize });
|
||||
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -53,7 +55,9 @@ 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();
|
||||
|
@ -87,7 +91,9 @@ 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();
|
||||
|
@ -111,7 +117,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
// Deposit with native ETH
|
||||
await wethGateway
|
||||
.connect(depositor.signer)
|
||||
.depositETH(depositor.address, '0', { value: depositSize });
|
||||
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||
|
||||
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||
weth.address
|
||||
|
@ -142,7 +148,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);
|
||||
|
@ -166,7 +172,9 @@ 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);
|
||||
|
||||
|
@ -187,7 +195,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);
|
||||
|
@ -197,14 +205,14 @@ 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);
|
||||
});
|
||||
|
||||
it('Borrow ETH via delegateApprove ETH and repays back', async () => {
|
||||
const { users, wethGateway, aWETH, weth, helpersContract } = testEnv;
|
||||
const { users, wethGateway, aWETH, weth, helpersContract, pool } = testEnv;
|
||||
const borrowSize = parseEther('1');
|
||||
const user = users[2];
|
||||
const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||
|
@ -216,7 +224,9 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
expect(priorDebtBalance).to.be.eq(zero);
|
||||
|
||||
// Deposit WETH 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);
|
||||
|
||||
|
@ -229,7 +239,9 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
);
|
||||
|
||||
// Borrows ETH with WETH as collateral
|
||||
await waitForTx(await wethGateway.connect(user.signer).borrowETH(borrowSize, '2', '0'));
|
||||
await waitForTx(
|
||||
await wethGateway.connect(user.signer).borrowETH(pool.address, borrowSize, '2', '0')
|
||||
);
|
||||
|
||||
const debtBalance = await varDebtToken.balanceOf(user.address);
|
||||
|
||||
|
@ -239,7 +251,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: borrowSize.mul(2) })
|
||||
.repayETH(pool.address, MAX_UINT_AMOUNT, '2', user.address, { value: borrowSize.mul(2) })
|
||||
);
|
||||
const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
|
||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
||||
|
@ -297,18 +309,6 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
).to.be.revertedWith('Fallback not allowed');
|
||||
});
|
||||
|
||||
it('Getters should retrieve correct state', async () => {
|
||||
const { aWETH, weth, pool, wethGateway } = testEnv;
|
||||
|
||||
const WETHAddress = await wethGateway.getWETHAddress();
|
||||
const aWETHAddress = await wethGateway.getAWETHAddress();
|
||||
const poolAddress = await wethGateway.getLendingPoolAddress();
|
||||
|
||||
expect(WETHAddress).to.be.equal(weth.address);
|
||||
expect(aWETHAddress).to.be.equal(aWETH.address);
|
||||
expect(poolAddress).to.be.equal(pool.address);
|
||||
});
|
||||
|
||||
it('Owner can do emergency token recovery', async () => {
|
||||
const { users, dai, wethGateway, deployer } = testEnv;
|
||||
const user = users[0];
|
||||
|
|
|
@ -26,6 +26,7 @@ import {
|
|||
deployUniswapLiquiditySwapAdapter,
|
||||
deployUniswapRepayAdapter,
|
||||
deployFlashLiquidationAdapter,
|
||||
authorizeWETHGateway
|
||||
} from '../../helpers/contracts-deployments';
|
||||
import { Signer } from 'ethers';
|
||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||
|
@ -279,7 +280,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
|||
|
||||
await deployWalletBalancerProvider();
|
||||
|
||||
await deployWETHGateway([mockTokens.WETH.address, lendingPoolAddress]);
|
||||
const gateWay = await deployWETHGateway([mockTokens.WETH.address]);
|
||||
await authorizeWETHGateway(gateWay.address, lendingPoolAddress);
|
||||
|
||||
console.timeEnd('setup');
|
||||
};
|
||||
|
|
|
@ -15,7 +15,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
const depositSize = parseEther('5');
|
||||
const daiSize = parseEther('10000');
|
||||
it('Deposit WETH via WethGateway and DAI', async () => {
|
||||
const { users, wethGateway, aWETH } = testEnv;
|
||||
const { users, wethGateway, aWETH, pool } = testEnv;
|
||||
|
||||
const user = users[1];
|
||||
const depositor = users[0];
|
||||
|
@ -23,10 +23,10 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
// Deposit liquidity with native ETH
|
||||
await wethGateway
|
||||
.connect(depositor.signer)
|
||||
.depositETH(depositor.address, '0', { value: depositSize });
|
||||
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||
|
||||
// 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);
|
||||
|
||||
|
@ -54,7 +54,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();
|
||||
|
@ -88,7 +88,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();
|
||||
|
@ -112,7 +112,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
// Deposit with native ETH
|
||||
await wethGateway
|
||||
.connect(depositor.signer)
|
||||
.depositETH(depositor.address, '0', { value: depositSize });
|
||||
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||
|
||||
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||
weth.address
|
||||
|
@ -168,7 +168,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);
|
||||
|
||||
|
@ -189,7 +189,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);
|
||||
|
@ -199,14 +199,14 @@ 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);
|
||||
});
|
||||
|
||||
it('Borrow ETH via delegateApprove ETH and repays back', async () => {
|
||||
const { users, wethGateway, aWETH, weth, helpersContract } = testEnv;
|
||||
const { users, wethGateway, aWETH, weth, helpersContract, pool } = testEnv;
|
||||
const borrowSize = parseEther('1');
|
||||
const user = users[2];
|
||||
const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||
|
@ -218,7 +218,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
expect(priorDebtBalance).to.be.eq(zero);
|
||||
|
||||
// Deposit WETH 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);
|
||||
|
||||
|
@ -231,7 +231,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
);
|
||||
|
||||
// Borrows ETH with WETH as collateral
|
||||
await waitForTx(await wethGateway.connect(user.signer).borrowETH(borrowSize, '2', '0'));
|
||||
await waitForTx(await wethGateway.connect(user.signer).borrowETH(pool.address, borrowSize, '2', '0'));
|
||||
|
||||
const debtBalance = await varDebtToken.balanceOf(user.address);
|
||||
|
||||
|
@ -241,7 +241,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: borrowSize.mul(2) })
|
||||
.repayETH(pool.address, MAX_UINT_AMOUNT, '2', user.address, { value: borrowSize.mul(2) })
|
||||
);
|
||||
const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
|
||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
||||
|
@ -299,17 +299,6 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
|||
).to.be.revertedWith('Fallback not allowed');
|
||||
});
|
||||
|
||||
it('Getters should retrieve correct state', async () => {
|
||||
const { aWETH, weth, pool, wethGateway } = testEnv;
|
||||
|
||||
const WETHAddress = await wethGateway.getWETHAddress();
|
||||
const aWETHAddress = await wethGateway.getAWETHAddress();
|
||||
const poolAddress = await wethGateway.getLendingPoolAddress();
|
||||
|
||||
expect(WETHAddress).to.be.equal(weth.address);
|
||||
expect(aWETHAddress).to.be.equal(aWETH.address);
|
||||
expect(poolAddress).to.be.equal(pool.address);
|
||||
});
|
||||
|
||||
it('Owner can do emergency token recovery', async () => {
|
||||
const { users, dai, wethGateway, deployer } = testEnv;
|
||||
|
|
Loading…
Reference in New Issue
Block a user