-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.config.ts
More file actions
162 lines (154 loc) · 5.4 KB
/
Copy pathdeploy.config.ts
File metadata and controls
162 lines (154 loc) · 5.4 KB
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
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'
import { Networks } from '../../hardhat'
import path from 'path'
// Define a base directory for deployments
export const DEPLOYMENTS_BASE_DIR = path.resolve(__dirname, '../../deployments')
/**
* Get the deploy config for a given network
* @param network
* @returns
*/
export const getDeployConfig = (network: DeployableNetworks, overrides: FixtureOverrides = {}): DeploymentVariables => {
const config = deployableNetworkConfig[network]
if (!config) {
throw new Error(`No deploy config for network ${network}`)
}
return config(overrides)
}
export interface FixtureOverrides {
accountOverrides?: Partial<DeploymentAccounts>
contractOverrides?: DeploymentContractOverrides
}
/**
* DeployableNetworks is a subset of the Networks type, specifically including
* networks where deployment scripts will be executed. To support additional networks,
* extend the Extract type with the network's key as defined in the Networks type.
*/
export type DeployableNetworks = Extract<Networks, 'bsc' | 'bscTestnet' | 'hardhat'>
/**
* DeploymentAccounts defines the structure for account-related configurations
* needed during the deployment process. It currently includes an adminAddress
* which can be a string or a SignerWithAddress object.
*
* Extend or modify this interface to include additional account-related configurations as needed.
*/
export interface DeploymentAccounts {
adminAddress: string | SignerWithAddress
}
/**
* DeploymentContractOverrides allows for specifying addresses of already deployed
* contracts or for overriding the default addresses during deployment.
*
* Extend or modify this interface to include overrides for additional contracts as needed.
*/
export interface DeploymentContractOverrides {
lockToken?: string
votingEscrowV2Upgradeable?: string
escrowWeightLens?: string
proxyAdminAddress?: string
artProxy?: string
}
/**
* Deployment variables used for the deployment of contracts in this project.
*
* Extend or modify the DeploymentVariables interface if additional variables are required.
*/
interface DeploymentVariables {
// Accounts and contract overrides should be configured above
accounts: DeploymentAccounts
contractOverrides: DeploymentContractOverrides
// These deployment variables can be changed and extended as needed.
wNative?: string
veDetails: {
name: string
symbol: string
version: string
}
escrowWeightLens: {
durationDaysThresholds: number[]
multipliers: number[]
}
}
/**
* Configuration for each deployable network. The structure is based on the interfaces above.
*
* accountOverrides and contractOverrides are optional and can be used to override configured values in this file.
*/
const deployableNetworkConfig: Record<
DeployableNetworks,
({ accountOverrides, contractOverrides }: FixtureOverrides) => DeploymentVariables
> = {
bsc: ({ accountOverrides, contractOverrides }: FixtureOverrides) => {
return {
accounts: {
// NOTE: Example of extracting signers
adminAddress: accountOverrides?.adminAddress || '',
},
contractOverrides: {
// lockToken: contractOverrides?.lockToken || '0x2F760FCb977AF39E94A3E074dcd3649a16F8652C',
votingEscrowV2Upgradeable: contractOverrides?.votingEscrowV2Upgradeable || '',
proxyAdminAddress: contractOverrides?.proxyAdminAddress || '',
artProxy: contractOverrides?.artProxy || '',
},
wNative: '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c',
veDetails: {
name: 'Vote Escrow',
symbol: 'veToken',
version: '1',
},
escrowWeightLens: {
durationDaysThresholds: [365, 180, 90, 45],
multipliers: [2000, 1500, 1250, 1000],
},
}
},
bscTestnet: ({ accountOverrides, contractOverrides }: FixtureOverrides) => {
return {
accounts: {
// NOTE: Example of extracting signers
adminAddress: accountOverrides?.adminAddress || '0x',
},
contractOverrides: {
lockToken: contractOverrides?.lockToken || '0xedb8b85a779e872e2aeef39df96a7fcc7d5ea6af',
votingEscrowV2Upgradeable: contractOverrides?.votingEscrowV2Upgradeable || '',
proxyAdminAddress: contractOverrides?.proxyAdminAddress || '',
artProxy: contractOverrides?.artProxy || '',
},
wNative: '0x',
veDetails: {
name: 'Vote Escrow',
symbol: 'veToken',
version: '1',
},
escrowWeightLens: {
durationDaysThresholds: [365, 180, 90, 45],
multipliers: [2000, 1500, 1250, 1000],
},
}
},
hardhat: ({ accountOverrides, contractOverrides }: FixtureOverrides) => {
const defaultAccount = '0x-no-address-passed'
return {
accounts: {
// NOTE: Example of extracting signers
adminAddress: accountOverrides?.adminAddress || defaultAccount,
},
contractOverrides: {
lockToken: contractOverrides?.lockToken || '',
votingEscrowV2Upgradeable: contractOverrides?.votingEscrowV2Upgradeable || '',
proxyAdminAddress: contractOverrides?.proxyAdminAddress || '',
artProxy: contractOverrides?.artProxy || '',
},
wNative: '0x',
veDetails: {
name: 'Vote Escrow',
symbol: 'veToken',
version: '1',
},
escrowWeightLens: {
durationDaysThresholds: [365, 180, 90, 45],
multipliers: [2000, 1500, 1250, 1000],
},
}
},
}