-
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.
deployment + verification scripts for sFRAX (#1010)
- Loading branch information
Showing
6 changed files
with
144 additions
and
7 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
83 changes: 83 additions & 0 deletions
83
scripts/deployment/phase2-assets/collaterals/deploy_sfrax.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,83 @@ | ||
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, oracleTimeout } from '../../utils' | ||
import { SFraxCollateral } from '../../../../typechain' | ||
import { ContractFactory } from 'ethers' | ||
|
||
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 SFRAX Collateral - sFRAX **************************/ | ||
|
||
const SFraxCollateralFactory: ContractFactory = await hre.ethers.getContractFactory( | ||
'SFraxCollateral' | ||
) | ||
|
||
const collateral = <SFraxCollateral>await SFraxCollateralFactory.connect(deployer).deploy( | ||
{ | ||
priceTimeout: priceTimeout.toString(), | ||
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.FRAX, | ||
oracleError: fp('0.01').toString(), // 1% | ||
erc20: networkConfig[chainId].tokens.sFRAX, | ||
maxTradeVolume: fp('1e6').toString(), // $1m, | ||
oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: fp('0.02').toString(), // 2% = 1% oracleError + 1% buffer | ||
delayUntilDefault: bn('86400').toString(), // 24h | ||
}, | ||
'0' // revenueHiding = 0 | ||
) | ||
await collateral.deployed() | ||
|
||
console.log(`Deployed sFRAX to ${hre.network.name} (${chainId}): ${collateral.address}`) | ||
await (await collateral.refresh()).wait() | ||
expect(await collateral.status()).to.equal(CollateralStatus.SOUND) | ||
|
||
assetCollDeployments.collateral.sFRAX = collateral.address | ||
assetCollDeployments.erc20s.sFRAX = networkConfig[chainId].tokens.sFRAX | ||
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,53 @@ | ||
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, oracleTimeout, verifyContract } from '../../deployment/utils' | ||
|
||
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 sFRAX **************************/ | ||
await verifyContract( | ||
chainId, | ||
deployments.collateral.sFRAX, | ||
[ | ||
{ | ||
priceTimeout: priceTimeout.toString(), | ||
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.FRAX, | ||
oracleError: fp('0.01').toString(), // 1% | ||
erc20: networkConfig[chainId].tokens.sFRAX, | ||
maxTradeVolume: fp('1e6').toString(), // $1m, | ||
oracleTimeout: oracleTimeout(chainId, '3600').toString(), // 1 hr | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: fp('0.02').toString(), // 2% | ||
delayUntilDefault: bn('86400').toString(), // 24h | ||
}, | ||
'0', // revenueHiding = 0 | ||
], | ||
'contracts/plugins/assets/frax/SFraxCollateral.sol:SFraxCollateral' | ||
) | ||
} | ||
|
||
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
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