-
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.
Merge branch '4.0.0' into validate-eth+-prop
- Loading branch information
Showing
5 changed files
with
144 additions
and
4 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
85 changes: 85 additions & 0 deletions
85
scripts/deployment/phase2-assets/collaterals/deploy_pyusd.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,85 @@ | ||
import fs from 'fs' | ||
import hre, { ethers } from 'hardhat' | ||
import { getChainId } from '../../../../common/blockchain-utils' | ||
import { arbitrumL2Chains, baseL2Chains, networkConfig } from '../../../../common/configuration' | ||
import { bn, fp } from '../../../../common/numbers' | ||
import { | ||
getDeploymentFile, | ||
getDeploymentFilename, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
fileExists, | ||
} from '../../../deployment/common' | ||
import { priceTimeout } from '../../../deployment/utils' | ||
import { Asset, ICollateral } from '../../../../typechain' | ||
import { | ||
PYUSD_MAX_TRADE_VOLUME, | ||
PYUSD_ORACLE_ERROR, | ||
PYUSD_ORACLE_TIMEOUT, | ||
} from '#/test/plugins/individual-collateral/aave-v3/constants' | ||
import { CollateralStatus } from '#/common/constants' | ||
import { expect } from 'chai' | ||
|
||
async function main() { | ||
// ==== Read Configuration ==== | ||
const [burner] = await hre.ethers.getSigners() | ||
const chainId = await getChainId(hre) | ||
|
||
console.log(`Deploying pyUSD 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}`) | ||
} | ||
|
||
// Only exists on Mainnet | ||
if (baseL2Chains.includes(hre.network.name) || arbitrumL2Chains.includes(hre.network.name)) { | ||
throw new Error(`Invalid network ${hre.network.name} - only available on Mainnet`) | ||
} | ||
|
||
// 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[] = [] | ||
|
||
let collateral: ICollateral | ||
|
||
/******** Deploy pyUSD asset **************************/ | ||
const { collateral: pyUsdCollateral } = await hre.run('deploy-fiat-collateral', { | ||
priceTimeout: priceTimeout.toString(), | ||
priceFeed: networkConfig[chainId].chainlinkFeeds.pyUSD, | ||
oracleError: PYUSD_ORACLE_ERROR.toString(), | ||
tokenAddress: networkConfig[chainId].tokens.pyUSD, | ||
maxTradeVolume: PYUSD_MAX_TRADE_VOLUME.toString(), // $500k, | ||
oracleTimeout: PYUSD_ORACLE_TIMEOUT.toString(), | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: fp('0.01').add(PYUSD_ORACLE_ERROR).toString(), | ||
delayUntilDefault: bn('86400').toString(), // 24h | ||
}) | ||
collateral = <ICollateral>await ethers.getContractAt('ICollateral', pyUsdCollateral) | ||
await (await collateral.refresh()).wait() | ||
expect(await collateral.status()).to.equal(CollateralStatus.SOUND) | ||
|
||
assetCollDeployments.collateral.pyUSD = pyUsdCollateral | ||
assetCollDeployments.erc20s.pyUSD = networkConfig[chainId].tokens.pyUSD | ||
deployedCollateral.push(pyUsdCollateral.toString()) | ||
|
||
/**************************************************************/ | ||
|
||
fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) | ||
|
||
console.log(`Deployed pyUSD asset 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,51 @@ | ||
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 { priceTimeout, verifyContract } from '../../deployment/utils' | ||
import { bn, fp } from '../../../common/numbers' | ||
import { PYUSD_MAX_TRADE_VOLUME, PYUSD_ORACLE_ERROR, PYUSD_ORACLE_TIMEOUT } from '#/test/plugins/individual-collateral/aave-v3/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}`) | ||
} | ||
|
||
deployments = <IAssetCollDeployments>getDeploymentFile(getAssetCollDeploymentFilename(chainId)) | ||
|
||
const collat = await hre.ethers.getContractAt('FiatCollateral', deployments.collateral.pyUSD!) | ||
|
||
/** ******************** Verify pyUSD Asset ****************************************/ | ||
await verifyContract( | ||
chainId, | ||
deployments.collateral.pyUSD, | ||
[ | ||
{ | ||
priceTimeout: priceTimeout.toString(), | ||
chainlinkFeed: networkConfig[chainId].chainlinkFeeds.pyUSD, | ||
oracleError: PYUSD_ORACLE_ERROR.toString(), | ||
erc20: networkConfig[chainId].tokens.pyUSD, | ||
maxTradeVolume: PYUSD_MAX_TRADE_VOLUME.toString(), // $500k, | ||
oracleTimeout: PYUSD_ORACLE_TIMEOUT, | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: fp('0.01').add(PYUSD_ORACLE_ERROR).toString(), | ||
delayUntilDefault: bn('86400').toString(), // 24h | ||
}, | ||
], | ||
'contracts/plugins/assets/FiatCollateral.sol:FiatCollateral' | ||
) | ||
} | ||
|
||
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