-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.ts
50 lines (42 loc) · 1.66 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
import { ethers, network } from 'hardhat'
import {
OracleLib,
OracleLib__factory,
UniswapV2VolatileLPCollateral,
UniswapV2VolatileLPCollateral__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]
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`)
}
const UniswapV2VolatileLPCollateralFactory: UniswapV2VolatileLPCollateral__factory =
await ethers.getContractFactory('UniswapV2VolatileLPCollateral', {
libraries: { OracleLib: oracleLib.address },
})
const collateral = <UniswapV2VolatileLPCollateral>(
await UniswapV2VolatileLPCollateralFactory.deploy(config.collateralOpts)
)
console.log(
`Deploying UniswapV2VolatileLPCollateral with transaction ${collateral.deployTransaction.hash}`
)
await collateral.deployed()
console.log(
`UniswapV2VolatileLPCollateral deployed to ${collateral.address} as collateral to ${config.collateralOpts.pair}`
)
}
main().catch((error) => {
console.error(error)
process.exitCode = 1
})