mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Added Weth gateway contract in config, updated deployment
This commit is contained in:
parent
a7e1cad87b
commit
da2ade5d3b
|
@ -28,16 +28,13 @@ contract WETHGateway is IWETHGateway, Ownable {
|
||||||
}
|
}
|
||||||
|
|
||||||
function authorizeLendingPool(address lendingPool) external onlyOwner {
|
function authorizeLendingPool(address lendingPool) external onlyOwner {
|
||||||
require(
|
|
||||||
ILendingPool(lendingPool).getReserveData(address(WETH)).aTokenAddress != address(0),
|
|
||||||
'AWETH_NOT_SETUP'
|
|
||||||
);
|
|
||||||
WETH.approve(lendingPool, uint256(-1));
|
WETH.approve(lendingPool, uint256(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens)
|
* @dev deposits WETH into the reserve, using native ETH. A corresponding amount of the overlying asset (aTokens)
|
||||||
* is minted.
|
* 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 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.
|
* @param referralCode integrators are assigned a referral code and can potentially receive rewards.
|
||||||
**/
|
**/
|
||||||
|
@ -52,6 +49,7 @@ contract WETHGateway is IWETHGateway, Ownable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev withdraws the WETH _reserves of msg.sender.
|
* @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 amount amount of aWETH to withdraw and receive native ETH
|
||||||
* @param to address of the user who will receive native ETH
|
* @param to address of the user who will receive native ETH
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +74,7 @@ contract WETHGateway is IWETHGateway, Ownable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev repays a borrow on the WETH reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified).
|
* @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 amount the amount to repay, or uint256(-1) if the user wants to repay everything
|
||||||
* @param rateMode the rate mode to repay
|
* @param rateMode the rate mode to repay
|
||||||
* @param onBehalfOf the address for which msg.sender is repaying
|
* @param onBehalfOf the address for which msg.sender is repaying
|
||||||
|
@ -110,6 +109,7 @@ 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`.
|
* @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 amount the amount of ETH to borrow
|
||||||
* @param interesRateMode the interest rate mode
|
* @param interesRateMode the interest rate mode
|
||||||
* @param referralCode integrators are assigned a referral code and can potentially receive rewards
|
* @param referralCode integrators are assigned a referral code and can potentially receive rewards
|
||||||
|
|
|
@ -310,17 +310,10 @@ export const deployStableDebtToken = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||||
args[0],
|
|
||||||
args[1],
|
|
||||||
args[2],
|
|
||||||
"18",
|
|
||||||
args[3],
|
|
||||||
args[4]
|
|
||||||
);
|
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const deployVariableDebtToken = async (
|
export const deployVariableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||||
|
@ -333,31 +326,26 @@ export const deployVariableDebtToken = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||||
args[0],
|
|
||||||
args[1],
|
|
||||||
args[2],
|
|
||||||
"18",
|
|
||||||
args[3],
|
|
||||||
args[4]
|
|
||||||
);
|
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const deployGenericStableDebtToken = async () => withSaveAndVerify(
|
export const deployGenericStableDebtToken = async () =>
|
||||||
await new StableDebtTokenFactory(await getFirstSigner()).deploy(),
|
withSaveAndVerify(
|
||||||
eContractid.StableDebtToken,
|
await new StableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
[],
|
eContractid.StableDebtToken,
|
||||||
false
|
[],
|
||||||
);
|
false
|
||||||
|
);
|
||||||
|
|
||||||
export const deployGenericVariableDebtToken = async () => withSaveAndVerify(
|
export const deployGenericVariableDebtToken = async () =>
|
||||||
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
withSaveAndVerify(
|
||||||
eContractid.VariableDebtToken,
|
await new VariableDebtTokenFactory(await getFirstSigner()).deploy(),
|
||||||
[],
|
eContractid.VariableDebtToken,
|
||||||
false
|
[],
|
||||||
);
|
false
|
||||||
|
);
|
||||||
|
|
||||||
export const deployGenericAToken = async (
|
export const deployGenericAToken = async (
|
||||||
[poolAddress, underlyingAssetAddress, treasuryAddress, incentivesController, name, symbol]: [
|
[poolAddress, underlyingAssetAddress, treasuryAddress, incentivesController, name, symbol]: [
|
||||||
|
@ -376,23 +364,22 @@ export const deployGenericAToken = async (
|
||||||
[],
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(
|
||||||
poolAddress,
|
poolAddress,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
underlyingAssetAddress,
|
underlyingAssetAddress,
|
||||||
incentivesController,
|
incentivesController,
|
||||||
"18",
|
'18',
|
||||||
name,
|
name,
|
||||||
symbol
|
symbol
|
||||||
);
|
);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployGenericATokenImpl = async (
|
export const deployGenericATokenImpl = async (verify: boolean) =>
|
||||||
verify: boolean
|
withSaveAndVerify(
|
||||||
) => withSaveAndVerify(
|
|
||||||
await new ATokenFactory(await getFirstSigner()).deploy(),
|
await new ATokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.AToken,
|
eContractid.AToken,
|
||||||
[],
|
[],
|
||||||
|
@ -416,23 +403,22 @@ export const deployDelegationAwareAToken = async (
|
||||||
[],
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(
|
||||||
pool,
|
pool,
|
||||||
treasuryAddress,
|
treasuryAddress,
|
||||||
underlyingAssetAddress,
|
underlyingAssetAddress,
|
||||||
incentivesController,
|
incentivesController,
|
||||||
"18",
|
'18',
|
||||||
name,
|
name,
|
||||||
symbol
|
symbol
|
||||||
)
|
);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const deployDelegationAwareATokenImpl = async (
|
export const deployDelegationAwareATokenImpl = async (verify: boolean) =>
|
||||||
verify: boolean
|
withSaveAndVerify(
|
||||||
) => withSaveAndVerify(
|
|
||||||
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(),
|
await new DelegationAwareATokenFactory(await getFirstSigner()).deploy(),
|
||||||
eContractid.DelegationAwareAToken,
|
eContractid.DelegationAwareAToken,
|
||||||
[],
|
[],
|
||||||
|
@ -501,10 +487,7 @@ export const deployATokensAndRatesHelper = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
export const deployWETHGateway = async (
|
export const deployWETHGateway = async (args: [tEthereumAddress], verify?: boolean) =>
|
||||||
args: [tEthereumAddress, tEthereumAddress],
|
|
||||||
verify?: boolean
|
|
||||||
) =>
|
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
await new WETHGatewayFactory(await getFirstSigner()).deploy(...args),
|
await new WETHGatewayFactory(await getFirstSigner()).deploy(...args),
|
||||||
eContractid.WETHGateway,
|
eContractid.WETHGateway,
|
||||||
|
@ -512,6 +495,14 @@ export const deployWETHGateway = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const authorizeWETHGateway = async (
|
||||||
|
wethGateWay: tEthereumAddress,
|
||||||
|
lendingPool: tEthereumAddress
|
||||||
|
) =>
|
||||||
|
await new WETHGatewayFactory(await getFirstSigner())
|
||||||
|
.attach(wethGateWay)
|
||||||
|
.authorizeLendingPool(lendingPool);
|
||||||
|
|
||||||
export const deployMockStableDebtToken = async (
|
export const deployMockStableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
|
@ -523,18 +514,10 @@ export const deployMockStableDebtToken = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||||
args[0],
|
|
||||||
args[1],
|
|
||||||
args[2],
|
|
||||||
"18",
|
|
||||||
args[3],
|
|
||||||
args[4]
|
|
||||||
);
|
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const deployWETHMocked = async (verify?: boolean) =>
|
export const deployWETHMocked = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
|
@ -555,21 +538,13 @@ export const deployMockVariableDebtToken = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(args[0], args[1], args[2], '18', args[3], args[4]);
|
||||||
args[0],
|
|
||||||
args[1],
|
|
||||||
args[2],
|
|
||||||
"18",
|
|
||||||
args[3],
|
|
||||||
args[4]
|
|
||||||
);
|
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const deployMockAToken = async (
|
export const deployMockAToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress,tEthereumAddress, string, string],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) => {
|
) => {
|
||||||
const instance = await withSaveAndVerify(
|
const instance = await withSaveAndVerify(
|
||||||
|
@ -578,20 +553,11 @@ args: [tEthereumAddress, tEthereumAddress, tEthereumAddress,tEthereumAddress, st
|
||||||
[],
|
[],
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
await instance.initialize(
|
await instance.initialize(args[0], args[2], args[1], args[3], '18', args[4], args[5]);
|
||||||
args[0],
|
|
||||||
args[2],
|
|
||||||
args[1],
|
|
||||||
args[3],
|
|
||||||
"18",
|
|
||||||
args[4],
|
|
||||||
args[5],
|
|
||||||
);
|
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
export const deploySelfdestructTransferMock = async (verify?: boolean) =>
|
export const deploySelfdestructTransferMock = async (verify?: boolean) =>
|
||||||
withSaveAndVerify(
|
withSaveAndVerify(
|
||||||
|
|
|
@ -287,12 +287,7 @@ export type iLpPoolAssets<T> = Pick<
|
||||||
|
|
||||||
export type iMaticPoolAssets<T> = Pick<
|
export type iMaticPoolAssets<T> = Pick<
|
||||||
iAssetsWithoutUSD<T>,
|
iAssetsWithoutUSD<T>,
|
||||||
| 'DAI'
|
'DAI' | 'USDC' | 'USDT' | 'WBTC' | 'WETH' | 'WMATIC'
|
||||||
| 'USDC'
|
|
||||||
| 'USDT'
|
|
||||||
| 'WBTC'
|
|
||||||
| 'WETH'
|
|
||||||
| 'WMATIC'
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
|
export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;
|
||||||
|
@ -353,7 +348,7 @@ export interface IReserveParams extends IReserveBorrowParams, IReserveCollateral
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInterestRateStrategyParams {
|
export interface IInterestRateStrategyParams {
|
||||||
name: string,
|
name: string;
|
||||||
optimalUtilizationRate: string;
|
optimalUtilizationRate: string;
|
||||||
baseVariableBorrowRate: string;
|
baseVariableBorrowRate: string;
|
||||||
variableRateSlope1: string;
|
variableRateSlope1: string;
|
||||||
|
@ -474,6 +469,7 @@ export interface ICommonConfiguration {
|
||||||
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
ReservesConfig: iMultiPoolsAssets<IReserveParams>;
|
||||||
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
ATokenDomainSeparator: iParamsPerNetwork<string>;
|
||||||
WETH: iParamsPerNetwork<tEthereumAddress>;
|
WETH: iParamsPerNetwork<tEthereumAddress>;
|
||||||
|
WethGateway: iParamsPerNetwork<tEthereumAddress>;
|
||||||
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
|
ReserveFactorTreasuryAddress: iParamsPerNetwork<tEthereumAddress>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -494,4 +490,3 @@ export interface ITokenAddress {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration;
|
export type PoolConfiguration = ICommonConfiguration | IAaveConfiguration;
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,15 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.mumbai]: '',
|
[eEthereumNetwork.mumbai]: '',
|
||||||
[eEthereumNetwork.matic]: '',
|
[eEthereumNetwork.matic]: '',
|
||||||
},
|
},
|
||||||
|
WethGateway: {
|
||||||
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
[eEthereumNetwork.hardhat]: '',
|
||||||
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
|
[eEthereumNetwork.kovan]: '',
|
||||||
|
[eEthereumNetwork.ropsten]: '',
|
||||||
|
[eEthereumNetwork.main]: '',
|
||||||
|
[eEthereumNetwork.tenderlyMain]: '',
|
||||||
|
},
|
||||||
TokenDistributor: {
|
TokenDistributor: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
[eEthereumNetwork.buidlerevm]: '',
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
|
|
|
@ -168,6 +168,15 @@ export const CommonsConfig: ICommonConfiguration = {
|
||||||
[eEthereumNetwork.mumbai]: '',
|
[eEthereumNetwork.mumbai]: '',
|
||||||
[eEthereumNetwork.matic]: '',
|
[eEthereumNetwork.matic]: '',
|
||||||
},
|
},
|
||||||
|
WethGateway: {
|
||||||
|
[eEthereumNetwork.coverage]: '',
|
||||||
|
[eEthereumNetwork.hardhat]: '',
|
||||||
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
|
[eEthereumNetwork.kovan]: '',
|
||||||
|
[eEthereumNetwork.ropsten]: '',
|
||||||
|
[eEthereumNetwork.main]: '',
|
||||||
|
[eEthereumNetwork.tenderlyMain]: '',
|
||||||
|
},
|
||||||
TokenDistributor: {
|
TokenDistributor: {
|
||||||
[eEthereumNetwork.coverage]: '',
|
[eEthereumNetwork.coverage]: '',
|
||||||
[eEthereumNetwork.buidlerevm]: '',
|
[eEthereumNetwork.buidlerevm]: '',
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
"test-permit": "hardhat test test-suites/test-aave/__setup.spec.ts test-suites/test-aave/atoken-permit.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-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-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-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",
|
"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",
|
"dev:coverage": "buidler compile --force && buidler coverage --network coverage",
|
||||||
|
|
21
tasks/deployments/deploy-wethGateWay.ts
Normal file
21
tasks/deployments/deploy-wethGateWay.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { task } from 'hardhat/config';
|
||||||
|
|
||||||
|
import { deployWETHGateway } from '../../helpers/contracts-deployments';
|
||||||
|
|
||||||
|
const CONTRACT_NAME = 'WETHGateway';
|
||||||
|
|
||||||
|
task(`deploy-${CONTRACT_NAME}`, `Deploys the ${CONTRACT_NAME} contract`)
|
||||||
|
.addParam('weth', 'Address of the weth token')
|
||||||
|
.addFlag('verify', `Verify ${CONTRACT_NAME} contract via Etherscan API.`)
|
||||||
|
.setAction(async ({ weth, verify }, localBRE) => {
|
||||||
|
await localBRE.run('set-DRE');
|
||||||
|
|
||||||
|
if (!localBRE.network.config.chainId) {
|
||||||
|
throw new Error('INVALID_CHAIN_ID');
|
||||||
|
}
|
||||||
|
|
||||||
|
const wethGateWay = await deployWETHGateway([weth], verify);
|
||||||
|
console.log(`${CONTRACT_NAME}.address`, wethGateWay.address);
|
||||||
|
|
||||||
|
console.log(`\tFinished ${CONTRACT_NAME} deployment`);
|
||||||
|
});
|
|
@ -5,7 +5,10 @@ import {
|
||||||
deployWalletBalancerProvider,
|
deployWalletBalancerProvider,
|
||||||
deployAaveProtocolDataProvider,
|
deployAaveProtocolDataProvider,
|
||||||
deployWETHGateway,
|
deployWETHGateway,
|
||||||
|
authorizeWETHGateway,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
|
import { getParamPerNetwork } from '../../helpers/contracts-helpers';
|
||||||
|
import { eEthereumNetwork } from '../../helpers/types';
|
||||||
import {
|
import {
|
||||||
ConfigNames,
|
ConfigNames,
|
||||||
getReservesConfigByPool,
|
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)}`)
|
.addParam('pool', `Pool name to retrieve configuration, supported: ${Object.values(ConfigNames)}`)
|
||||||
.setAction(async ({ verify, pool }, localBRE) => {
|
.setAction(async ({ verify, pool }, localBRE) => {
|
||||||
await localBRE.run('set-DRE');
|
await localBRE.run('set-DRE');
|
||||||
|
const network = <eEthereumNetwork>localBRE.network.name;
|
||||||
const poolConfig = loadPoolConfig(pool);
|
const poolConfig = loadPoolConfig(pool);
|
||||||
const {
|
const {
|
||||||
ATokenNamePrefix,
|
ATokenNamePrefix,
|
||||||
StableDebtTokenNamePrefix,
|
StableDebtTokenNamePrefix,
|
||||||
VariableDebtTokenNamePrefix,
|
VariableDebtTokenNamePrefix,
|
||||||
SymbolPrefix,
|
SymbolPrefix,
|
||||||
|
WethGateway,
|
||||||
} = poolConfig;
|
} = poolConfig;
|
||||||
const mockTokens = await getAllMockedTokens();
|
const mockTokens = await getAllMockedTokens();
|
||||||
const allTokenAddresses = getAllTokenAddresses(mockTokens);
|
const allTokenAddresses = getAllTokenAddresses(mockTokens);
|
||||||
|
@ -87,6 +92,6 @@ task('dev:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address);
|
await insertContractAddressInDb(eContractid.AaveProtocolDataProvider, testHelpers.address);
|
||||||
|
|
||||||
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
||||||
const wethAddress = await getWethAddress(poolConfig);
|
const gateWay = await getParamPerNetwork(WethGateway, network);
|
||||||
await deployWETHGateway([wethAddress, lendingPoolAddress]);
|
await authorizeWETHGateway(gateWay, lendingPoolAddress);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {
|
||||||
deployLendingPoolCollateralManager,
|
deployLendingPoolCollateralManager,
|
||||||
deployWalletBalancerProvider,
|
deployWalletBalancerProvider,
|
||||||
deployWETHGateway,
|
deployWETHGateway,
|
||||||
|
authorizeWETHGateway,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import {
|
import {
|
||||||
loadPoolConfig,
|
loadPoolConfig,
|
||||||
|
@ -29,14 +30,15 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
await localBRE.run('set-DRE');
|
await localBRE.run('set-DRE');
|
||||||
const network = <eEthereumNetwork>localBRE.network.name;
|
const network = <eEthereumNetwork>localBRE.network.name;
|
||||||
const poolConfig = loadPoolConfig(pool);
|
const poolConfig = loadPoolConfig(pool);
|
||||||
const {
|
const {
|
||||||
ATokenNamePrefix,
|
ATokenNamePrefix,
|
||||||
StableDebtTokenNamePrefix,
|
StableDebtTokenNamePrefix,
|
||||||
VariableDebtTokenNamePrefix,
|
VariableDebtTokenNamePrefix,
|
||||||
SymbolPrefix,
|
SymbolPrefix,
|
||||||
ReserveAssets,
|
ReserveAssets,
|
||||||
ReservesConfig,
|
ReservesConfig,
|
||||||
LendingPoolCollateralManager
|
LendingPoolCollateralManager,
|
||||||
|
WethGateway,
|
||||||
} = poolConfig as ICommonConfiguration;
|
} = poolConfig as ICommonConfiguration;
|
||||||
|
|
||||||
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
const reserveAssets = await getParamPerNetwork(ReserveAssets, network);
|
||||||
|
@ -66,9 +68,10 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
);
|
);
|
||||||
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
await configureReservesByHelper(ReservesConfig, reserveAssets, testHelpers, admin);
|
||||||
|
|
||||||
|
let collateralManagerAddress = await getParamPerNetwork(
|
||||||
|
LendingPoolCollateralManager,
|
||||||
let collateralManagerAddress = await getParamPerNetwork(LendingPoolCollateralManager, network);
|
network
|
||||||
|
);
|
||||||
if (!collateralManagerAddress) {
|
if (!collateralManagerAddress) {
|
||||||
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
const collateralManager = await deployLendingPoolCollateralManager(verify);
|
||||||
collateralManagerAddress = collateralManager.address;
|
collateralManagerAddress = collateralManager.address;
|
||||||
|
@ -81,11 +84,9 @@ task('full:initialize-lending-pool', 'Initialize lending pool configuration.')
|
||||||
|
|
||||||
await deployWalletBalancerProvider(verify);
|
await deployWalletBalancerProvider(verify);
|
||||||
|
|
||||||
const wethAddress = await getWethAddress(poolConfig);
|
|
||||||
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
const lendingPoolAddress = await addressesProvider.getLendingPool();
|
||||||
|
const gateWay = await getParamPerNetwork(WethGateway, network);
|
||||||
await deployWETHGateway([wethAddress, lendingPoolAddress]);
|
await authorizeWETHGateway(gateWay, lendingPoolAddress);
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -26,7 +26,9 @@ import {
|
||||||
deployUniswapLiquiditySwapAdapter,
|
deployUniswapLiquiditySwapAdapter,
|
||||||
deployUniswapRepayAdapter,
|
deployUniswapRepayAdapter,
|
||||||
deployFlashLiquidationAdapter,
|
deployFlashLiquidationAdapter,
|
||||||
|
authorizeWETHGateway,
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
|
import { eEthereumNetwork } from '../../helpers/types';
|
||||||
import { Signer } from 'ethers';
|
import { Signer } from 'ethers';
|
||||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||||
import { MintableERC20 } from '../../types/MintableERC20';
|
import { MintableERC20 } from '../../types/MintableERC20';
|
||||||
|
@ -95,7 +97,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
const aaveAdmin = await deployer.getAddress();
|
const aaveAdmin = await deployer.getAddress();
|
||||||
|
|
||||||
const mockTokens = await deployAllMockTokens(deployer);
|
const mockTokens = await deployAllMockTokens(deployer);
|
||||||
console.log("Deployed mocks");
|
console.log('Deployed mocks');
|
||||||
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
const addressesProvider = await deployLendingPoolAddressesProvider(AaveConfig.MarketId);
|
||||||
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
await waitForTx(await addressesProvider.setPoolAdmin(aaveAdmin));
|
||||||
|
|
||||||
|
@ -192,7 +194,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES);
|
const mockAggregators = await deployAllMockAggregators(MOCK_CHAINLINK_AGGREGATORS_PRICES);
|
||||||
console.log("Mock aggs deployed");
|
console.log('Mock aggs deployed');
|
||||||
const allTokenAddresses = Object.entries(mockTokens).reduce(
|
const allTokenAddresses = Object.entries(mockTokens).reduce(
|
||||||
(accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({
|
(accum: { [tokenSymbol: string]: tEthereumAddress }, [tokenSymbol, tokenContract]) => ({
|
||||||
...accum,
|
...accum,
|
||||||
|
@ -238,7 +240,7 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
|
|
||||||
const config = loadPoolConfig(ConfigNames.Aave);
|
const config = loadPoolConfig(ConfigNames.Aave);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ATokenNamePrefix,
|
ATokenNamePrefix,
|
||||||
StableDebtTokenNamePrefix,
|
StableDebtTokenNamePrefix,
|
||||||
VariableDebtTokenNamePrefix,
|
VariableDebtTokenNamePrefix,
|
||||||
|
@ -281,7 +283,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
|
|
||||||
await deployWalletBalancerProvider();
|
await deployWalletBalancerProvider();
|
||||||
|
|
||||||
await deployWETHGateway([mockTokens.WETH.address, lendingPoolAddress]);
|
const gateWay = await deployWETHGateway([mockTokens.WETH.address]);
|
||||||
|
await authorizeWETHGateway(gateWay.address, lendingPoolAddress);
|
||||||
|
|
||||||
console.timeEnd('setup');
|
console.timeEnd('setup');
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
const depositSize = parseEther('5');
|
const depositSize = parseEther('5');
|
||||||
const daiSize = parseEther('10000');
|
const daiSize = parseEther('10000');
|
||||||
it('Deposit WETH via WethGateway and DAI', async () => {
|
it('Deposit WETH via WethGateway and DAI', async () => {
|
||||||
const { users, wethGateway, aWETH } = testEnv;
|
const { users, wethGateway, aWETH, pool } = testEnv;
|
||||||
|
|
||||||
const user = users[1];
|
const user = users[1];
|
||||||
const depositor = users[0];
|
const depositor = users[0];
|
||||||
|
@ -22,10 +22,12 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
// Deposit liquidity with native ETH
|
// Deposit liquidity with native ETH
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(depositor.signer)
|
.connect(depositor.signer)
|
||||||
.depositETH(depositor.address, '0', { value: depositSize });
|
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||||
|
|
||||||
// Deposit with native ETH
|
// 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);
|
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
|
// Partial Withdraw and send native Ether to user
|
||||||
const { gasUsed: withdrawGas } = await waitForTx(
|
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();
|
const afterPartialEtherBalance = await user.signer.getBalance();
|
||||||
|
@ -87,7 +91,9 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
|
|
||||||
// Full withdraw
|
// Full withdraw
|
||||||
const { gasUsed: withdrawGas } = await waitForTx(
|
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();
|
const afterFullEtherBalance = await user.signer.getBalance();
|
||||||
|
@ -111,7 +117,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
// Deposit with native ETH
|
// Deposit with native ETH
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(depositor.signer)
|
.connect(depositor.signer)
|
||||||
.depositETH(depositor.address, '0', { value: depositSize });
|
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||||
|
|
||||||
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||||
weth.address
|
weth.address
|
||||||
|
@ -142,7 +148,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
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);
|
const varDebtToken = await getVariableDebtToken(variableDebtTokenAddress);
|
||||||
|
|
||||||
// Deposit with native ETH
|
// 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);
|
const aTokensBalance = await aWETH.balanceOf(user.address);
|
||||||
|
|
||||||
|
@ -187,7 +195,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
const debtBalanceAfterPartialRepay = await varDebtToken.balanceOf(user.address);
|
||||||
|
@ -197,14 +205,14 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
|
||||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Borrow ETH via delegateApprove ETH and repays back', async () => {
|
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 borrowSize = parseEther('1');
|
||||||
const user = users[2];
|
const user = users[2];
|
||||||
const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
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);
|
expect(priorDebtBalance).to.be.eq(zero);
|
||||||
|
|
||||||
// Deposit WETH with native ETH
|
// 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);
|
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
|
// 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);
|
const debtBalance = await varDebtToken.balanceOf(user.address);
|
||||||
|
|
||||||
|
@ -239,7 +251,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
|
||||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
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');
|
).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 () => {
|
it('Owner can do emergency token recovery', async () => {
|
||||||
const { users, dai, wethGateway, deployer } = testEnv;
|
const { users, dai, wethGateway, deployer } = testEnv;
|
||||||
const user = users[0];
|
const user = users[0];
|
||||||
|
|
|
@ -26,6 +26,7 @@ import {
|
||||||
deployUniswapLiquiditySwapAdapter,
|
deployUniswapLiquiditySwapAdapter,
|
||||||
deployUniswapRepayAdapter,
|
deployUniswapRepayAdapter,
|
||||||
deployFlashLiquidationAdapter,
|
deployFlashLiquidationAdapter,
|
||||||
|
authorizeWETHGateway
|
||||||
} from '../../helpers/contracts-deployments';
|
} from '../../helpers/contracts-deployments';
|
||||||
import { Signer } from 'ethers';
|
import { Signer } from 'ethers';
|
||||||
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
import { TokenContractId, eContractid, tEthereumAddress, AavePools } from '../../helpers/types';
|
||||||
|
@ -280,7 +281,8 @@ const buildTestEnv = async (deployer: Signer, secondaryWallet: Signer) => {
|
||||||
|
|
||||||
await deployWalletBalancerProvider();
|
await deployWalletBalancerProvider();
|
||||||
|
|
||||||
await deployWETHGateway([mockTokens.WETH.address, lendingPoolAddress]);
|
const gateWay = await deployWETHGateway([mockTokens.WETH.address]);
|
||||||
|
await authorizeWETHGateway(gateWay.address, lendingPoolAddress);
|
||||||
|
|
||||||
console.timeEnd('setup');
|
console.timeEnd('setup');
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
const depositSize = parseEther('5');
|
const depositSize = parseEther('5');
|
||||||
const daiSize = parseEther('10000');
|
const daiSize = parseEther('10000');
|
||||||
it('Deposit WETH via WethGateway and DAI', async () => {
|
it('Deposit WETH via WethGateway and DAI', async () => {
|
||||||
const { users, wethGateway, aWETH } = testEnv;
|
const { users, wethGateway, aWETH, pool } = testEnv;
|
||||||
|
|
||||||
const user = users[1];
|
const user = users[1];
|
||||||
const depositor = users[0];
|
const depositor = users[0];
|
||||||
|
@ -23,10 +23,10 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
// Deposit liquidity with native ETH
|
// Deposit liquidity with native ETH
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(depositor.signer)
|
.connect(depositor.signer)
|
||||||
.depositETH(depositor.address, '0', { value: depositSize });
|
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||||
|
|
||||||
// Deposit with native ETH
|
// 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);
|
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
|
// Partial Withdraw and send native Ether to user
|
||||||
const { gasUsed: withdrawGas } = await waitForTx(
|
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();
|
const afterPartialEtherBalance = await user.signer.getBalance();
|
||||||
|
@ -88,7 +88,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
|
|
||||||
// Full withdraw
|
// Full withdraw
|
||||||
const { gasUsed: withdrawGas } = await waitForTx(
|
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();
|
const afterFullEtherBalance = await user.signer.getBalance();
|
||||||
|
@ -112,7 +112,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
// Deposit with native ETH
|
// Deposit with native ETH
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(depositor.signer)
|
.connect(depositor.signer)
|
||||||
.depositETH(depositor.address, '0', { value: depositSize });
|
.depositETH(pool.address, depositor.address, '0', { value: depositSize });
|
||||||
|
|
||||||
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
const { stableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
||||||
weth.address
|
weth.address
|
||||||
|
@ -168,7 +168,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
const varDebtToken = await getVariableDebtToken(variableDebtTokenAddress);
|
const varDebtToken = await getVariableDebtToken(variableDebtTokenAddress);
|
||||||
|
|
||||||
// Deposit with native ETH
|
// 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);
|
const aTokensBalance = await aWETH.balanceOf(user.address);
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
const debtBalanceAfterPartialRepay = await varDebtToken.balanceOf(user.address);
|
||||||
|
@ -199,14 +199,14 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
|
||||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Borrow ETH via delegateApprove ETH and repays back', async () => {
|
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 borrowSize = parseEther('1');
|
||||||
const user = users[2];
|
const user = users[2];
|
||||||
const { variableDebtTokenAddress } = await helpersContract.getReserveTokensAddresses(
|
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);
|
expect(priorDebtBalance).to.be.eq(zero);
|
||||||
|
|
||||||
// Deposit WETH with native ETH
|
// 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);
|
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
|
// 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);
|
const debtBalance = await varDebtToken.balanceOf(user.address);
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ makeSuite('Use native ETH at LendingPool via WETHGateway', (testEnv: TestEnv) =>
|
||||||
await waitForTx(
|
await waitForTx(
|
||||||
await wethGateway
|
await wethGateway
|
||||||
.connect(user.signer)
|
.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);
|
const debtBalanceAfterFullRepay = await varDebtToken.balanceOf(user.address);
|
||||||
expect(debtBalanceAfterFullRepay).to.be.eq(zero);
|
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');
|
).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 () => {
|
it('Owner can do emergency token recovery', async () => {
|
||||||
const { users, dai, wethGateway, deployer } = testEnv;
|
const { users, dai, wethGateway, deployer } = testEnv;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user