diff --git a/common/configuration.ts b/common/configuration.ts index afe7ed4ca..69ce706b6 100644 --- a/common/configuration.ts +++ b/common/configuration.ts @@ -111,6 +111,7 @@ export interface ITokens { steakPYUSD?: string Re7WETH?: string meUSD?: string + AlphaWETH?: string pxETH?: string apxETH?: string @@ -285,6 +286,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = { steakPYUSD: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a', bbUSDT: '0x2C25f6C25770fFEC5959D34B94Bf898865e5D6b1', Re7WETH: '0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0', + AlphaWETH: '0x47fe8Ab9eE47DD65c24df52324181790b9F47EfC', sdUSDCUSDCPlus: '0x9bbF31E99F30c38a5003952206C31EEa77540BeF', USDe: '0x4c9edd5852cd905f086c759e8383e09bff1e68b3', sUSDe: '0x9D39A5DE30e57443BfF2A8307A4256c8797A3497', diff --git a/scripts/deploy.ts b/scripts/deploy.ts index 6d1fd0fd6..a62398616 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -99,7 +99,8 @@ async function main() { 'phase2-assets/assets/deploy_cvx.ts', 'phase2-assets/collaterals/deploy_pyusd.ts', 'phase2-assets/collaterals/deploy_sky_susds.ts', - 'phase2-assets/collaterals/deploy_origin_oeth.ts' + 'phase2-assets/collaterals/deploy_origin_oeth.ts', + 'phase2-assets/collaterals/deploy_alphaweth.ts' ) } else if (chainId == '8453' || chainId == '84531') { // Base L2 chains diff --git a/scripts/deployment/phase2-assets/collaterals/deploy_alphaweth.ts b/scripts/deployment/phase2-assets/collaterals/deploy_alphaweth.ts new file mode 100644 index 000000000..ebc67c05a --- /dev/null +++ b/scripts/deployment/phase2-assets/collaterals/deploy_alphaweth.ts @@ -0,0 +1,91 @@ +import fs from 'fs' +import hre from 'hardhat' +import { getChainId } from '../../../../common/blockchain-utils' +import { 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 { + ETH_ORACLE_TIMEOUT, + ETH_ORACLE_ERROR, + ETH_USD_FEED, + PRICE_TIMEOUT, + DELAY_UNTIL_DEFAULT, +} from '../../../../test/plugins/individual-collateral/meta-morpho/constants' +import { MetaMorphoSelfReferentialCollateral } 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 = getDeploymentFile(assetCollDeploymentFilename) + + const deployedCollateral: string[] = [] + + /******** Deploy MetaMorpho AlphaPing WETH - AlphaWETH **************************/ + + const MetaMorphoFiatCollateralFactory: ContractFactory = await hre.ethers.getContractFactory( + 'MetaMorphoSelfReferentialCollateral' + ) + + const collateral = ( + await MetaMorphoFiatCollateralFactory.connect(deployer).deploy( + { + priceTimeout: PRICE_TIMEOUT.toString(), + chainlinkFeed: ETH_USD_FEED, + oracleError: ETH_ORACLE_ERROR.toString(), + erc20: networkConfig[chainId].tokens.AlphaWETH, + maxTradeVolume: fp('1e6').toString(), + oracleTimeout: ETH_ORACLE_TIMEOUT.toString(), + targetName: hre.ethers.utils.formatBytes32String('ETH'), + defaultThreshold: '0', // WETH + delayUntilDefault: DELAY_UNTIL_DEFAULT.toString(), + }, + fp('1e-3') // can have large drawdowns + ) + ) + await collateral.deployed() + + console.log(`Deployed AlphaWETH to ${hre.network.name} (${chainId}): ${collateral.address}`) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.AlphaWETH = collateral.address + assetCollDeployments.erc20s.AlphaWETH = networkConfig[chainId].tokens.AlphaWETH + 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 +}) diff --git a/scripts/verification/collateral-plugins/verify_alphaweth.ts b/scripts/verification/collateral-plugins/verify_alphaweth.ts new file mode 100644 index 000000000..be26d5564 --- /dev/null +++ b/scripts/verification/collateral-plugins/verify_alphaweth.ts @@ -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 { + ETH_ORACLE_TIMEOUT, + ETH_ORACLE_ERROR, + ETH_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 = getDeploymentFile(assetCollDeploymentFilename) + + /******** Verify AlphaWETH **************************/ + await verifyContract( + chainId, + deployments.collateral.AlphaWETH, + [ + { + priceTimeout: PRICE_TIMEOUT.toString(), + chainlinkFeed: ETH_USD_FEED, + oracleError: ETH_ORACLE_ERROR.toString(), + erc20: networkConfig[chainId].tokens.AlphaWETH, + maxTradeVolume: fp('1e6').toString(), + oracleTimeout: ETH_ORACLE_TIMEOUT.toString(), + targetName: hre.ethers.utils.formatBytes32String('ETH'), + defaultThreshold: '0', // WETH + delayUntilDefault: DELAY_UNTIL_DEFAULT.toString(), + }, + fp('1e-3'), // can have large drawdowns + ], + 'contracts/plugins/assets/meta-morpho/MetaMorphoSelfReferentialCollateral.sol:MetaMorphoSelfReferentialCollateral' + ) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/scripts/verify_etherscan.ts b/scripts/verify_etherscan.ts index bca599e39..1a3f41369 100644 --- a/scripts/verify_etherscan.ts +++ b/scripts/verify_etherscan.ts @@ -84,7 +84,8 @@ async function main() { 'collateral-plugins/verify_USDe.ts', 'collateral-plugins/verify_pyusd.ts', 'collateral-plugins/verify_susds.ts', - 'collateral-plugins/verify_oeth.ts' + 'collateral-plugins/verify_oeth.ts', + 'collateral-plugins/verify_alphaweth.ts' ) } else if (chainId == '8453' || chainId == '84531') { // Base L2 chains diff --git a/test/integration/fork-block-numbers.ts b/test/integration/fork-block-numbers.ts index ca7f078db..707822d79 100644 --- a/test/integration/fork-block-numbers.ts +++ b/test/integration/fork-block-numbers.ts @@ -11,7 +11,7 @@ const forkBlockNumber = { 'mainnet-3.4.0': 20328530, // Ethereum // TODO add all the block numbers we fork from to benefit from caching - default: 20890018, // Ethereum + default: 21874647, // Ethereum } export default forkBlockNumber diff --git a/test/plugins/individual-collateral/meta-morpho/MetaMorphoSelfReferentialCollateral.test.ts b/test/plugins/individual-collateral/meta-morpho/MetaMorphoSelfReferentialCollateral.test.ts index 288a78dea..b49b5205a 100644 --- a/test/plugins/individual-collateral/meta-morpho/MetaMorphoSelfReferentialCollateral.test.ts +++ b/test/plugins/individual-collateral/meta-morpho/MetaMorphoSelfReferentialCollateral.test.ts @@ -18,8 +18,8 @@ import { ETH_ORACLE_TIMEOUT, PRICE_TIMEOUT, RE7WETH, + ALPHAWETH, ETH_USD_FEED, - forkNetwork, } from './constants' import { mintCollateralTo } from './mintCollateralTo' @@ -214,3 +214,8 @@ makeFiatCollateralTestSuite( 'MetaMorphoSelfReferentialCollateral - Re7WETH', makeOpts(RE7WETH, ETH_USD_FEED, ETH_ORACLE_TIMEOUT, ETH_ORACLE_ERROR, 'mainnet') ) + +makeFiatCollateralTestSuite( + 'MetaMorphoSelfReferentialCollateral - Alpha WETH Core', + makeOpts(ALPHAWETH, ETH_USD_FEED, ETH_ORACLE_TIMEOUT, ETH_ORACLE_ERROR, 'mainnet') +) diff --git a/test/plugins/individual-collateral/meta-morpho/constants.ts b/test/plugins/individual-collateral/meta-morpho/constants.ts index 7e1e5caa9..2cf03ef92 100644 --- a/test/plugins/individual-collateral/meta-morpho/constants.ts +++ b/test/plugins/individual-collateral/meta-morpho/constants.ts @@ -27,6 +27,7 @@ export const STEAKPYUSD = networkConfig[chainId].tokens.steakPYUSD! export const BBUSDT = networkConfig[chainId].tokens.bbUSDT! export const RE7WETH = networkConfig[chainId].tokens.Re7WETH! export const MEUSD = networkConfig[chainId].tokens.meUSD! +export const ALPHAWETH = networkConfig[chainId].tokens.AlphaWETH! // USDC export const USDC_USD_FEED = networkConfig[chainId].chainlinkFeeds.USDC! @@ -58,7 +59,7 @@ export const PRICE_TIMEOUT = bn(604800) // 1 week export const DELAY_UNTIL_DEFAULT = bn(86400) const FORK_BLOCKS: { [key: string]: number } = { - '1': 19463181, + '1': 22974224, '8453': 20454200, '42161': 193157126, // not used } diff --git a/test/plugins/individual-collateral/meta-morpho/mintCollateralTo.ts b/test/plugins/individual-collateral/meta-morpho/mintCollateralTo.ts index 5d5318e23..dabe6daa6 100644 --- a/test/plugins/individual-collateral/meta-morpho/mintCollateralTo.ts +++ b/test/plugins/individual-collateral/meta-morpho/mintCollateralTo.ts @@ -8,8 +8,9 @@ import { whileImpersonating } from '#/utils/impersonation' export const whales: { [key: string]: string } = { [networkConfig['31337'].tokens.steakUSDC!]: '0xC977d218Fde6A39c7aCE71C8243545c276B48931', [networkConfig['31337'].tokens.steakPYUSD!]: '0x7E4B4DC22111B84594d9b7707A8DCFFd793D477A', - [networkConfig['31337'].tokens.bbUSDT!]: '0xc8E3C36a72B9AA4Af0a057eb4A11e1AFC16465bB', - [networkConfig['31337'].tokens.Re7WETH!]: '0xd553294B42bdFEb49D8f5A64E8B2D3A65fc673A9', + [networkConfig['31337'].tokens.bbUSDT!]: '0x99A1a22Cf24C86A8f1cB8583c3de4d9fC4b705C9', + [networkConfig['31337'].tokens.Re7WETH!]: '0x310D5C8EE1512D5092ee4377061aE82E48973689', + [networkConfig['31337'].tokens.AlphaWETH!]: '0x5E46884a77E0aC5F3126e30720Bd5218814dc5E2', [networkConfig['8453'].tokens.meUSD!]: '0xF02ea73c7A3057649f09899aaE1606712758bE8b', }