-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
126 additions
and
6 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
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
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
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,66 @@ | ||
import fs from 'fs' | ||
import hre, { ethers } from 'hardhat' | ||
import { getChainId } from '../../../../common/blockchain-utils' | ||
import { networkConfig } from '../../../../common/configuration' | ||
import { fp } from '../../../../common/numbers' | ||
import { | ||
getDeploymentFile, | ||
getDeploymentFilename, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
fileExists, | ||
} from '../../../deployment/common' | ||
import { priceTimeout, oracleTimeout } from '../../../deployment/utils' | ||
import { Asset } from '../../../../typechain' | ||
|
||
async function main() { | ||
// ==== Read Configuration ==== | ||
const [burner] = await hre.ethers.getSigners() | ||
const chainId = await getChainId(hre) | ||
|
||
console.log(`Deploying STG asset to network ${hre.network.name} (${chainId}) | ||
with burner account: ${burner.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 deployedAssets: string[] = [] | ||
|
||
/******** Deploy STG asset **************************/ | ||
const { asset: stgAsset } = await hre.run('deploy-asset', { | ||
priceTimeout: priceTimeout.toString(), | ||
priceFeed: networkConfig[chainId].chainlinkFeeds.STG, | ||
oracleError: fp('0.02').toString(), // 2% | ||
tokenAddress: networkConfig[chainId].tokens.STG, | ||
maxTradeVolume: fp('1e6').toString(), // $1m, | ||
oracleTimeout: oracleTimeout(chainId, '86400').toString(), // 24 hr | ||
}) | ||
await (<Asset>await ethers.getContractAt('Asset', stgAsset)).refresh() | ||
|
||
assetCollDeployments.assets.STG = stgAsset | ||
assetCollDeployments.erc20s.STG = networkConfig[chainId].tokens.STG | ||
deployedAssets.push(stgAsset.toString()) | ||
|
||
/**************************************************************/ | ||
|
||
fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) | ||
|
||
console.log(`Deployed STG asset to ${hre.network.name} (${chainId}): | ||
New deployments: ${deployedAssets} | ||
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,45 @@ | ||
import hre from 'hardhat' | ||
|
||
import { getChainId } from '../../../common/blockchain-utils' | ||
import { developmentChains, networkConfig } from '../../../common/configuration' | ||
import { getAssetCollDeploymentFilename, getDeploymentFile, getDeploymentFilename, IAssetCollDeployments, IDeployments } from '../../deployment/common' | ||
import { verifyContract } from '../../deployment/utils' | ||
import { fp } from '../../../common/numbers' | ||
|
||
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}`) | ||
} | ||
|
||
deployments = <IAssetCollDeployments>getDeploymentFile(getAssetCollDeploymentFilename(chainId)) | ||
|
||
const asset = await hre.ethers.getContractAt('Asset', deployments.assets.STG!) | ||
|
||
/** ******************** Verify RSR Asset ****************************************/ | ||
await verifyContract( | ||
chainId, | ||
deployments.assets.STG, | ||
[ | ||
(await asset.priceTimeout()).toString(), | ||
await asset.chainlinkFeed(), | ||
fp('0.02').toString(), | ||
await asset.erc20(), | ||
(await asset.maxTradeVolume()).toString(), | ||
(await asset.oracleTimeout()).toString(), | ||
], | ||
'contracts/plugins/assets/Asset.sol:Asset' | ||
) | ||
} | ||
|
||
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