-
Notifications
You must be signed in to change notification settings - Fork 83
/
deployUnwrapper.ts
105 lines (89 loc) · 4.28 KB
/
deployUnwrapper.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
97
98
99
100
101
102
103
104
105
import "ts-node/register"
import "tsconfig-paths/register"
import { Contract, Signer } from "ethers"
import { task, types } from "hardhat/config"
import { Unwrapper__factory, AssetProxy__factory } from "types/generated"
import { deployContract } from "./utils/deploy-utils"
import { getSigner } from "./utils/signerFactory"
import { getChain, resolveAddress } from "./utils/networkAddressFactory"
import { Chain } from "./utils/tokens"
import { verifyEtherscan } from "./utils/etherscan"
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const approveUnwrapperTokens = async (chain: Chain, unwrapper: Contract, governor: Signer) => {
// Mainnet and Polygon
const fraxFeederPool = resolveAddress("FRAX", chain, "feederPool")
const musdAddress = resolveAddress("mUSD", chain)
let routers = []
let tokens = []
if (chain === Chain.polygon) {
routers = [fraxFeederPool]
tokens = [musdAddress]
} else {
const alusdFeederPool = resolveAddress("alUSD", chain, "feederPool")
const gusdFeederPool = resolveAddress("GUSD", chain, "feederPool")
const busdFeederPool = resolveAddress("BUSD", chain, "feederPool")
const raiFeederPool = resolveAddress("RAI", chain, "feederPool")
const feiFeederPool = resolveAddress("FEI", chain, "feederPool")
const hbtcFeederPool = resolveAddress("HBTC", chain, "feederPool")
const tbtcv2FeederPool = resolveAddress("tBTCv2", chain, "feederPool")
const mbtcAddress = resolveAddress("mBTC", chain)
routers = [
musdAddress,
alusdFeederPool,
gusdFeederPool,
busdFeederPool,
raiFeederPool,
feiFeederPool,
mbtcAddress,
hbtcFeederPool,
tbtcv2FeederPool,
]
tokens = [musdAddress, musdAddress, musdAddress, musdAddress, musdAddress, musdAddress, mbtcAddress, mbtcAddress, mbtcAddress]
}
// approve tokens for router
await unwrapper.connect(governor).approve(routers, tokens)
}
task("deploy-unwrapper-single", "Deploy Unwrapper without a proxy")
.addOptionalParam("speed", "Defender Relayer speed param: 'safeLow' | 'average' | 'fast' | 'fastest'", "fast", types.string)
.setAction(async (taskArgs, hre) => {
const signer = await getSigner(hre, taskArgs.speed)
const chain = getChain(hre)
const nexus = resolveAddress("Nexus", chain)
const constructorArguments = [nexus]
// Deploy step 1 - Deploy Unwrapper
const unwrapper = await deployContract(new Unwrapper__factory(signer), "Unwrapper", constructorArguments)
await verifyEtherscan(hre, {
address: unwrapper.address,
contract: "contracts/savings/peripheral/Unwrapper.sol:Unwrapper",
constructorArguments,
})
// Deploy step 2 - Approve tokens
// approveUnwrapperTokens(chain, unwrapper, signer)
})
task("deploy-unwrapper-proxy", "Deploy Unwrapper as a proxy on mainnet")
.addOptionalParam("speed", "Defender Relayer speed param: 'safeLow' | 'average' | 'fast' | 'fastest'", "fast", types.string)
.setAction(async (taskArgs, hre) => {
const signer = await getSigner(hre, taskArgs.speed)
const chain = getChain(hre)
const nexus = resolveAddress("Nexus", chain)
const proxyAdminAddress = resolveAddress("DelayedProxyAdmin", chain)
const constructorArguments = [nexus]
// Deploy step 1 - Deploy Unwrapper
const unwrapperImpl = await deployContract(new Unwrapper__factory(signer), "Unwrapper", constructorArguments)
const initializeData = []
const proxy = await deployContract(new AssetProxy__factory(signer), "AssetProxy", [
unwrapperImpl.address,
proxyAdminAddress,
initializeData,
])
const unwrapper = new Unwrapper__factory(signer).attach(proxy.address)
await verifyEtherscan(hre, {
address: unwrapperImpl.address,
contract: "contracts/savings/peripheral/Unwrapper.sol:Unwrapper",
constructorArguments,
})
console.log(`Set Unwrapper in the networkAddressFactory to ${unwrapper.address}`)
// Deploy step 2 - Approve tokens
// approveUnwrapperTokens(chain, unwrapper, signer)
})
module.exports = {}