-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGenericAaveFraxStaker.ts
96 lines (84 loc) · 3.77 KB
/
GenericAaveFraxStaker.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import hre, { network } from 'hardhat';
import { DeployFunction } from 'hardhat-deploy/types';
import { CONTRACTS_ADDRESSES, ChainId } from '@angleprotocol/sdk';
import { GenericAaveFraxStaker__factory, OptimizerAPRGreedyStrategy, OptimizerAPRGreedyStrategy__factory } from '../typechain';
import { DAY } from '../test/hardhat/contants';
import { BigNumber } from 'ethers';
const func: DeployFunction = async ({ deployments, ethers }) => {
const { deploy } = deployments;
const { deployer, keeper: fakeKeeper } = await ethers.getNamedSigners();
const stableName = 'EUR';
const collateralName = 'FRAX';
let strategyAddress: string;
let guardian: string;
let governor: string;
let keeper: string;
let proxyAdmin: string;
// If fork we suppose that we are in mainnet
if (!network.live) {
guardian = CONTRACTS_ADDRESSES[ChainId.MAINNET].Guardian!;
governor = CONTRACTS_ADDRESSES[ChainId.MAINNET].GovernanceMultiSig! as string;
proxyAdmin = CONTRACTS_ADDRESSES[ChainId.MAINNET].ProxyAdmin! as string;
strategyAddress = CONTRACTS_ADDRESSES[ChainId.MAINNET].agEUR?.collaterals?.[collateralName]?.Strategies
?.GenericOptimisedLender.Contract as string;
keeper = '0xcC617C6f9725eACC993ac626C7efC6B96476916E';
} else {
guardian = CONTRACTS_ADDRESSES[network.config.chainId as ChainId].Guardian!;
governor = CONTRACTS_ADDRESSES[network.config.chainId as ChainId].GovernanceMultiSig! as string;
proxyAdmin = CONTRACTS_ADDRESSES[network.config.chainId as ChainId].ProxyAdmin! as string;
strategyAddress = CONTRACTS_ADDRESSES[network.config.chainId as ChainId].agEUR?.collaterals?.[collateralName]
?.Strategies?.GenericOptimisedLender.Contract as string;
keeper = fakeKeeper.address;
}
const strategy = new ethers.Contract(
strategyAddress,
OptimizerAPRGreedyStrategy__factory.createInterface(),
deployer,
) as OptimizerAPRGreedyStrategy;
let lenderImplementation = await deployments.getOrNull(
`GenericAave_${stableName}_${collateralName}_Staker_Implementation`,
);
if (!lenderImplementation) {
lenderImplementation = await deploy(`GenericAave_${stableName}_${collateralName}_Staker_Implementation`, {
contract: 'GenericAaveFraxStaker',
from: deployer.address,
args: [],
});
console.log('success: deployed strategy implementation', lenderImplementation.address);
} else {
console.log('strategy implementation already deployed: ', lenderImplementation.address);
}
const initializeData = GenericAaveFraxStaker__factory.createInterface().encodeFunctionData('initialize', [
strategy.address,
'FRAXStaker',
true,
[governor],
guardian,
[keeper],
DAY,
]);
const proxyLender = await deploy(`GenericAave_${stableName}_${collateralName}_Staker`, {
contract: 'TransparentUpgradeableProxy',
from: deployer.address,
args: [lenderImplementation.address, proxyAdmin, initializeData],
});
console.log('Implementation deployed at address: ', lenderImplementation.address);
console.log('Aave Lender with FRAX staking (proxy) successfully deployed at address: ', proxyLender.address);
console.log(
`Deploy cost: ${(lenderImplementation.receipt?.gasUsed as BigNumber)?.toString()} (implem) + ${(
proxyLender.receipt?.gasUsed as BigNumber
)?.toString()} (proxy)`,
);
// The lender still needs to be plugged to the strategy
if (!network.live) {
await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [governor],
});
await hre.network.provider.send('hardhat_setBalance', [governor, '0x10000000000000000000000000000']);
const signer = await ethers.getSigner(governor);
await (await strategy.connect(signer).addLender(proxyLender.address)).wait();
}
};
func.tags = ['lenderFraxStaking'];
export default func;