generated from 0xDaksh/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
fixtures.ts
65 lines (58 loc) · 2.03 KB
/
fixtures.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { ethers } from "hardhat";
import { aDAIAddr, aUSDCAddr, LendingPoolAddr, LendingPoolAddressProviderAddr, PriceOracleAddr } from "./consts";
import {
ERC20,
ERC20__factory,
IAToken,
IAToken__factory,
ILendingPool,
ILendingPoolAddressesProvider,
ILendingPoolAddressesProvider__factory,
ILendingPool__factory,
IPriceOracle,
IPriceOracle__factory,
} from "../../../typechain";
import { DAIAddr, USDCAddr, DAIWhaleAddr } from "../../consts";
import { impersonate } from "../../utils";
import { parseEther } from "@ethersproject/units";
interface AaveV2FixtureResult {
wallet: SignerWithAddress;
addrProvider: ILendingPoolAddressesProvider;
lendingPool: ILendingPool;
priceOracle: IPriceOracle;
aDAI: IAToken;
aUSDC: IAToken;
DAI: ERC20;
USDC: ERC20;
}
export const aaveV2Fixture = async (): Promise<AaveV2FixtureResult> => {
const [wallet] = await ethers.getSigners();
const addrProvider = ILendingPoolAddressesProvider__factory.connect(LendingPoolAddressProviderAddr, wallet);
const lendingPool = ILendingPool__factory.connect(LendingPoolAddr, wallet);
const priceOracle = IPriceOracle__factory.connect(PriceOracleAddr, wallet);
const aDAI = IAToken__factory.connect(aDAIAddr, wallet);
const aUSDC = IAToken__factory.connect(aUSDCAddr, wallet);
const DAI = ERC20__factory.connect(DAIAddr, wallet);
const USDC = ERC20__factory.connect(USDCAddr, wallet);
const [daiWhaleSigner] = await impersonate([DAIWhaleAddr]);
// let's impersonate the account that has a lot of DAI and transfer some to ours
// before we do that, let's send some eth to cover up if the account doesn't
// have any eth
await wallet.sendTransaction({
to: daiWhaleSigner.address,
value: parseEther("1"),
});
// send 10K+ DAI to our master wallet
await DAI.connect(daiWhaleSigner).transfer(wallet.address, parseEther("10000"));
return {
wallet,
addrProvider,
lendingPool,
priceOracle,
aDAI,
aUSDC,
DAI,
USDC,
};
};