/
deploy.js
176 lines (159 loc) · 5.98 KB
/
deploy.js
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
const { task } = require('hardhat/config')
const { networks } = require('@unlock-protocol/networks')
task('deploy', 'Deploy the entire Unlock protocol')
.addOptionalParam(
'unlockAddress',
'the address of an existing Unlock contract'
)
.addOptionalParam('udtAddress', 'the address of an existing UDT contract')
.addOptionalParam(
'publicLockAddress',
'the address of an existing public Lock contract'
)
.addOptionalParam('publicLockVersion', 'the version of public Lock to deploy')
.addOptionalParam('wethAddress', 'the address of the WETH token contract')
.addOptionalParam(
'oracleAddress',
'the address of an existing Uniswap Oracle contract'
)
.addOptionalParam(
'premintAmount',
'the amount of tokens to be pre-minted when originating UDT'
)
.addOptionalParam(
'liquidity',
'the amount of liquidity to be added to the WETH<>UDT pool'
)
.addOptionalParam('unlockVersion', 'the version of Unlock to deploy')
.addOptionalParam('estimatedGasForPurchase', 'gas estimate for buying a key')
.addOptionalParam('locksmithURI', 'the URL locksmith to use in Unlock config')
.addOptionalParam(
'owner',
'address of the owner. defaults to the multisig address set for the network, it uses it'
)
.addFlag('setTemplate', 'set the PublicLock instance in Unlock')
.setAction(
async ({
unlockAddress,
unlockVersion,
publicLockVersion,
udtAddress,
publicLockAddress,
wethAddress,
oracleAddress,
premintAmount,
liquidity,
setTemplate,
estimatedGasForPurchase,
locksmithURI,
owner,
}) => {
// eslint-disable-next-line global-require
const mainDeployer = require('../scripts/deployments')
const {
unlockAddress: newUnlockAddress,
publicLockAddress: newPublicLockAddress,
} = await mainDeployer({
unlockAddress,
unlockVersion,
publicLockVersion,
udtAddress,
publicLockAddress,
wethAddress,
oracleAddress,
premintAmount,
liquidity,
setTemplate,
estimatedGasForPurchase,
locksmithURI,
owner,
})
return {
unlockAddress: newUnlockAddress,
publicLockAddress: newPublicLockAddress,
}
}
)
task('deploy:udt', 'Deploy Unlock Discount Token proxy').setAction(async () => {
// eslint-disable-next-line global-require
const udtDeployer = require('../scripts/deployments/udt')
return await udtDeployer()
})
task('deploy:unlock', 'Deploy Unlock proxy')
.addOptionalParam('unlockVersion', 'the version of unlock to deploy')
.setAction(async ({ unlockVersion }) => {
// eslint-disable-next-line global-require
const unlockDeployer = require('../scripts/deployments/unlock')
return await unlockDeployer({ unlockVersion })
})
task('deploy:weth', 'Deploy WETH contract').setAction(async () => {
// eslint-disable-next-line global-require
const wethDeployer = require('../scripts/deployments/weth')
return await wethDeployer()
})
task('deploy:oracle', 'Deploy Uniswap Oracle contract')
.addOptionalParam(
'uniswapFactoryAddress',
'the address of an existing Uniswap V2 Factory contract'
)
.setAction(async ({ uniswapFactoryAddress }) => {
// eslint-disable-next-line global-require
const oracleDeployer = require('../scripts/deployments/oracle')
return await oracleDeployer({ uniswapFactoryAddress })
})
task('deploy:template', 'Deploy PublicLock contract')
.addOptionalParam('publicLockVersion', 'the version of unlock to deploy')
.setAction(async ({ publicLockVersion }) => {
// eslint-disable-next-line global-require
const templateDeployer = require('../scripts/deployments/publicLock')
return await templateDeployer({ publicLockVersion })
})
task('deploy:serializer', 'Deploy LockSerializer').setAction(async () => {
// eslint-disable-next-line global-require
const serializerDeployer = require('../scripts/deployments/serializer')
return await serializerDeployer()
})
task('deploy:governor', 'Deploy Governor Alpha contracts')
.addParam('udtAddress', 'address of the ERC20 token to use for governance')
.addOptionalParam('timelockAddress', 'address of a timelock contract')
.addFlag('testing', 'lower vesting periods for dev purposes')
.setAction(async ({ udtAddress, timelockAddress, testing }) => {
// eslint-disable-next-line global-require
const govDeployer = require('../scripts/deployments/governor')
return await govDeployer({ udtAddress, timelockAddress, testing })
})
task('deploy:keyManager', 'Deploy KeyManager contract')
.addOptionalParam(
'locksmiths',
'addresses for the locksmith signers, comma separated'
)
.setAction(async ({ locksmiths }) => {
const locksmithsArray = !locksmiths ? [] : locksmiths.split(',')
// eslint-disable-next-line global-require
const keyManagerDeployer = require('../scripts/deployments/keyManager')
return await keyManagerDeployer(locksmithsArray)
})
task(
'deploy:protocol-upgrade',
'Deploy latest versions of Unlock and PublicLock contracts'
)
.addParam('publicLockVersion', 'version for publicLock')
.addParam('unlockVersion', 'version for Unlock')
.setAction(async ({ publicLockVersion, unlockVersion }, { ethers }) => {
// eslint-disable-next-line global-require
const deployPublicLock = require('../scripts/deployments/publicLock')
// eslint-disable-next-line global-require
const deployImpl = require('../scripts/upgrade/prepare')
const { chainId } = await ethers.provider.getNetwork()
const { unlockAddress, name } = networks[chainId]
console.log(`Deploying to ${name}(${chainId}) - Unlock: ${unlockAddress}`)
// deploy publicLock
const publicLockAddress = await deployPublicLock({ publicLockVersion })
// deploy unlock impl
const unlockImplAddress = await deployImpl({
proxyAddress: unlockAddress,
contractName: 'Unlock',
contractVersion: unlockVersion,
})
return { publicLockAddress, unlockImplAddress }
})