-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.ts
71 lines (59 loc) · 2.3 KB
/
deploy.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
import { ethers, network } from 'hardhat'
import {
OracleLib,
OracleLib__factory,
CvxCurveStableLPCollateral,
CvxCurveStableLPCollateral__factory,
ConvexStakingWrapper,
ConvexStakingWrapper__factory,
} from '../typechain-types'
import { networkConfig } from './configuration'
async function main() {
const [deployer] = await ethers.getSigners()
console.log(`Starting full deployment on network ${network.name}`)
console.log(`Deployer account: ${deployer.address}\n`)
const config = networkConfig[network.name]
if (config.oracleLib === undefined) {
const OracleLibFactory: OracleLib__factory = await ethers.getContractFactory('OracleLib')
const oracleLib = <OracleLib>await OracleLibFactory.deploy()
await oracleLib.deployed()
config.oracleLib = oracleLib.address
console.log(`Wrapped oracleLib deployed to ${oracleLib.address}`)
}
if (config.convexStakingWrapper == undefined) {
const CvxMiningFactory = await ethers.getContractFactory('CvxMining')
const cvxMining = await CvxMiningFactory.deploy()
const ConvexStakingWrapperFactory = <ConvexStakingWrapper__factory>(
await ethers.getContractFactory('ConvexStakingWrapper', {
libraries: {
CvxMining: cvxMining.address,
},
})
)
const convexStakingWrapper = <ConvexStakingWrapper>await ConvexStakingWrapperFactory.deploy()
await convexStakingWrapper.initialize(config.convexPoolId)
config.convexStakingWrapper = convexStakingWrapper.address
}
const CvxCurveStableLPCollateralFactory: CvxCurveStableLPCollateral__factory =
await ethers.getContractFactory('CvxCurveStableLPCollateral', {
libraries: { OracleLib: config.oracleLib },
})
const deployConfig: CvxCurveStableLPCollateral.ConfigurationStruct = {
...config.collateralOpts,
wrappedStakeToken: config.convexStakingWrapper,
}
const collateral = <CvxCurveStableLPCollateral>(
await CvxCurveStableLPCollateralFactory.deploy(deployConfig)
)
console.log(
`Deploying CvxCurveStableLPCollateral with transaction ${collateral.deployTransaction.hash}`
)
await collateral.deployed()
console.log(
`CvxCurveStableLPCollateral deployed to ${collateral.address} as collateral to ${config.convexStakingWrapper}`
)
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})