-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.ts
68 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
import { ethers, network } from 'hardhat'
import {
OracleLib,
OracleLib__factory,
CTokenV3Collateral,
CTokenV3Collateral__factory,
CusdcV3Wrapper__factory,
CusdcV3Wrapper,
} 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]
let oracleLib: OracleLib
if (config.oracleLib === undefined) {
const OracleLibFactory: OracleLib__factory = await ethers.getContractFactory('OracleLib')
oracleLib = <OracleLib>await OracleLibFactory.deploy()
await oracleLib.deployed()
console.log(`Wrapped oracleLib deployed to ${oracleLib.address}`)
} else {
oracleLib = <OracleLib>await ethers.getContractAt('OracleLib', config.oracleLib)
console.log(`Existing OracleLib at ${oracleLib.address} being used`)
}
let wcusdcV3: CusdcV3Wrapper
if (config.cusdcV3Wrapper === undefined) {
const CusdcV3WrapperFactory = <CusdcV3Wrapper__factory>(
await ethers.getContractFactory('CusdcV3Wrapper')
)
const { address, rewards, comp } = config.comet
wcusdcV3 = <CusdcV3Wrapper>await CusdcV3WrapperFactory.deploy(address, rewards, comp)
await wcusdcV3.deployed()
console.log(`Wrapped cUSDv3 deployed to ${wcusdcV3.address}`)
} else {
wcusdcV3 = <CusdcV3Wrapper>await ethers.getContractAt('CusdcV3Wrapper', config.cusdcV3Wrapper)
console.log(`Existing Wrapped cUSDv3 at ${wcusdcV3.address} being used`)
}
const CTokenV3CollateralFactory: CTokenV3Collateral__factory = await ethers.getContractFactory(
'CTokenV3Collateral',
{
libraries: { OracleLib: oracleLib.address },
}
)
const opts: CTokenV3Collateral.ConfigurationStruct = {
...config.collateralOpts,
erc20: wcusdcV3.address,
}
const collateral = <CTokenV3Collateral>await CTokenV3CollateralFactory.deploy(opts)
console.log(`Deploying CTokenV3Collateral with transaction ${collateral.deployTransaction.hash}`)
await collateral.deployed()
console.log(
`CTokenV3Collateral deployed to ${collateral.address} as collateral to ${wcusdcV3.address}`
)
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})