-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add deployment and verification scripts
- Loading branch information
1 parent
11f1313
commit cd4d156
Showing
4 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
scripts/deployment/phase2-assets/collaterals/deploy_sky_susds.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import fs from 'fs' | ||
import hre from 'hardhat' | ||
import { getChainId } from '../../../../common/blockchain-utils' | ||
import { networkConfig } from '../../../../common/configuration' | ||
import { bn, fp } from '../../../../common/numbers' | ||
import { expect } from 'chai' | ||
import { CollateralStatus } from '../../../../common/constants' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
getDeploymentFilename, | ||
fileExists, | ||
} from '../../common' | ||
import { priceTimeout } from '../../utils' | ||
import { SUSDSCollateral } from '../../../../typechain' | ||
import { ContractFactory } from 'ethers' | ||
import { ORACLE_ERROR, ORACLE_TIMEOUT } from '#/test/plugins/individual-collateral/sky/constants' | ||
|
||
async function main() { | ||
// ==== Read Configuration ==== | ||
const [deployer] = await hre.ethers.getSigners() | ||
|
||
const chainId = await getChainId(hre) | ||
|
||
console.log(`Deploying Collateral to network ${hre.network.name} (${chainId}) | ||
with burner account: ${deployer.address}`) | ||
|
||
if (!networkConfig[chainId]) { | ||
throw new Error(`Missing network configuration for ${hre.network.name}`) | ||
} | ||
|
||
// Get phase1 deployment | ||
const phase1File = getDeploymentFilename(chainId) | ||
if (!fileExists(phase1File)) { | ||
throw new Error(`${phase1File} doesn't exist yet. Run phase 1`) | ||
} | ||
// Check previous step completed | ||
const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) | ||
const assetCollDeployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename) | ||
|
||
const deployedCollateral: string[] = [] | ||
|
||
/******** Deploy SUSDS Collateral - sUSDS **************************/ | ||
|
||
const SUSDSCollateralFactory: ContractFactory = await hre.ethers.getContractFactory( | ||
'SUSDSCollateral' | ||
) | ||
|
||
const collateral = <SUSDSCollateral>await SUSDSCollateralFactory.connect(deployer).deploy( | ||
{ | ||
priceTimeout: priceTimeout.toString(), | ||
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDS, | ||
oracleError: ORACLE_ERROR.toString(), // 0.3% | ||
erc20: networkConfig[chainId].tokens.sUSDS, | ||
maxTradeVolume: fp('1e6').toString(), // $1m, | ||
oracleTimeout: ORACLE_TIMEOUT.toString(), // 24h | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: ORACLE_ERROR.add(fp('0.01')).toString(), // 1.3% | ||
delayUntilDefault: bn('86400').toString(), // 24h | ||
}, | ||
bn(0) | ||
) | ||
await collateral.deployed() | ||
|
||
console.log(`Deployed sUSDS to ${hre.network.name} (${chainId}): ${collateral.address}`) | ||
await (await collateral.refresh()).wait() | ||
expect(await collateral.status()).to.equal(CollateralStatus.SOUND) | ||
|
||
assetCollDeployments.collateral.sUSDS = collateral.address | ||
assetCollDeployments.erc20s.sUSDS = networkConfig[chainId].tokens.sUSDS | ||
deployedCollateral.push(collateral.address.toString()) | ||
|
||
fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) | ||
|
||
console.log(`Deployed collateral to ${hre.network.name} (${chainId}) | ||
New deployments: ${deployedCollateral} | ||
Deployment file: ${assetCollDeploymentFilename}`) | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import hre from 'hardhat' | ||
import { getChainId } from '../../../common/blockchain-utils' | ||
import { developmentChains, networkConfig } from '../../../common/configuration' | ||
import { fp, bn } from '../../../common/numbers' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
} from '../../deployment/common' | ||
import { priceTimeout, verifyContract } from '../../deployment/utils' | ||
import { | ||
ORACLE_ERROR, | ||
ORACLE_TIMEOUT, | ||
} from '../../../test/plugins/individual-collateral/sky/constants' | ||
|
||
let deployments: IAssetCollDeployments | ||
|
||
async function main() { | ||
// ********** Read config ********** | ||
const chainId = await getChainId(hre) | ||
if (!networkConfig[chainId]) { | ||
throw new Error(`Missing network configuration for ${hre.network.name}`) | ||
} | ||
|
||
if (developmentChains.includes(hre.network.name)) { | ||
throw new Error(`Cannot verify contracts for development chain ${hre.network.name}`) | ||
} | ||
|
||
const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) | ||
deployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename) | ||
|
||
/******** Verify sUSDS **************************/ | ||
await verifyContract( | ||
chainId, | ||
deployments.collateral.sUSDS, | ||
[ | ||
{ | ||
priceTimeout: priceTimeout.toString(), | ||
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDS, | ||
oracleError: ORACLE_ERROR.toString(), // 0.3% | ||
erc20: networkConfig[chainId].tokens.sUSDS, | ||
maxTradeVolume: fp('1e6').toString(), // $1m, | ||
oracleTimeout: ORACLE_TIMEOUT.toString(), // 24h | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: ORACLE_ERROR.add(fp('0.01')).toString(), // 1.3% | ||
delayUntilDefault: bn('86400').toString(), // 24h | ||
}, | ||
bn(0), | ||
], | ||
'contracts/plugins/assets/sky/SUSDSCollateral.sol:SUSDSCollateral' | ||
) | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters