-
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
1 parent
db527b7
commit abbbb9f
Showing
15 changed files
with
279 additions
and
20 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
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,9 @@ | ||
{ | ||
"assets": {}, | ||
"collateral": { | ||
"meUSD": "0x0f1e10871e6a2D3A5Aa696b85b39d61a22A9e8C3" | ||
}, | ||
"erc20s": { | ||
"meUSD": "0xbb819D845b573B5D7C538F5b85057160cfb5f313" | ||
} | ||
} |
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
94 changes: 94 additions & 0 deletions
94
scripts/deployment/phase2-assets/collaterals/deploy_morphoeUSD.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,94 @@ | ||
import fs from 'fs' | ||
import hre from 'hardhat' | ||
import { getChainId } from '../../../../common/blockchain-utils' | ||
import { baseL2Chains, networkConfig } from '../../../../common/configuration' | ||
import { fp } from '../../../../common/numbers' | ||
import { expect } from 'chai' | ||
import { CollateralStatus } from '../../../../common/constants' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
getDeploymentFilename, | ||
fileExists, | ||
} from '../../common' | ||
import { | ||
eUSD_ORACLE_TIMEOUT, | ||
eUSD_ORACLE_ERROR, | ||
eUSD_USD_FEED, | ||
PRICE_TIMEOUT, | ||
DELAY_UNTIL_DEFAULT, | ||
} from '../../../../test/plugins/individual-collateral/meta-morpho/constants' | ||
import { MetaMorphoFiatCollateral } 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 MetaMorpho Morpho eUSD - meUSD **************************/ | ||
|
||
// Only for base | ||
if (baseL2Chains.includes(hre.network.name)) { | ||
const MetaMorphoFiatCollateralFactory: ContractFactory = await hre.ethers.getContractFactory( | ||
'MetaMorphoFiatCollateral' | ||
) | ||
|
||
const collateral = <MetaMorphoFiatCollateral>await MetaMorphoFiatCollateralFactory.connect( | ||
deployer | ||
).deploy( | ||
{ | ||
priceTimeout: PRICE_TIMEOUT.toString(), | ||
chainlinkFeed: eUSD_USD_FEED, | ||
oracleError: eUSD_ORACLE_ERROR.toString(), | ||
erc20: networkConfig[chainId].tokens.meUSD, | ||
maxTradeVolume: fp('1e6').toString(), // 17m vault | ||
oracleTimeout: eUSD_ORACLE_TIMEOUT.toString(), | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: eUSD_ORACLE_ERROR.add(fp('0.01')).toString(), // +1% buffer rule | ||
delayUntilDefault: DELAY_UNTIL_DEFAULT.toString(), | ||
}, | ||
fp('1e-4') // can have mild drawdowns | ||
) | ||
await collateral.deployed() | ||
|
||
console.log(`Deployed meUSD to ${hre.network.name} (${chainId}): ${collateral.address}`) | ||
await (await collateral.refresh()).wait() | ||
expect(await collateral.status()).to.equal(CollateralStatus.SOUND) | ||
|
||
assetCollDeployments.collateral.meUSD = collateral.address | ||
assetCollDeployments.erc20s.meUSD = networkConfig[chainId].tokens.meUSD | ||
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 | ||
}) |
60 changes: 60 additions & 0 deletions
60
scripts/verification/collateral-plugins/verify_morphoeUSD.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,60 @@ | ||
import hre from 'hardhat' | ||
import { getChainId } from '../../../common/blockchain-utils' | ||
import { developmentChains, networkConfig } from '../../../common/configuration' | ||
import { fp } from '../../../common/numbers' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
} from '../../deployment/common' | ||
import { | ||
eUSD_ORACLE_TIMEOUT, | ||
eUSD_ORACLE_ERROR, | ||
eUSD_USD_FEED, | ||
PRICE_TIMEOUT, | ||
DELAY_UNTIL_DEFAULT, | ||
} from '../../../test/plugins/individual-collateral/meta-morpho/constants' | ||
import { 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 meUSD **************************/ | ||
await verifyContract( | ||
chainId, | ||
deployments.collateral.meUSD, | ||
[ | ||
{ | ||
priceTimeout: PRICE_TIMEOUT.toString(), | ||
chainlinkFeed: eUSD_USD_FEED, | ||
oracleError: eUSD_ORACLE_ERROR.toString(), | ||
erc20: networkConfig[chainId].tokens.meUSD, | ||
maxTradeVolume: fp('1e6').toString(), | ||
oracleTimeout: eUSD_ORACLE_TIMEOUT.toString(), | ||
targetName: hre.ethers.utils.formatBytes32String('USD'), | ||
defaultThreshold: eUSD_ORACLE_ERROR.add(fp('0.01')).toString(), // +1% buffer rule | ||
delayUntilDefault: DELAY_UNTIL_DEFAULT.toString(), | ||
}, | ||
fp('1e-4'), // can have small drawdowns | ||
], | ||
'contracts/plugins/assets/meta-morpho/MetaMorphoFiatCollateral.sol:MetaMorphoFiatCollateral' | ||
) | ||
} | ||
|
||
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
Oops, something went wrong.