diff --git a/scripts/deploy.ts b/scripts/deploy.ts index a1347953a..fa8936534 100644 --- a/scripts/deploy.ts +++ b/scripts/deploy.ts @@ -90,7 +90,8 @@ async function main() { 'phase2-assets/collaterals/deploy_USDe.ts', 'phase2-assets/assets/deploy_crv.ts', 'phase2-assets/assets/deploy_cvx.ts', - 'phase2-assets/collaterals/deploy_pyusd.ts' + 'phase2-assets/collaterals/deploy_pyusd.ts', + 'phase2-assets/collaterals/deploy_sky_susds.ts' ) } else if (chainId == '8453' || chainId == '84531') { // Base L2 chains diff --git a/scripts/deployment/phase2-assets/collaterals/deploy_sky_susds.ts b/scripts/deployment/phase2-assets/collaterals/deploy_sky_susds.ts new file mode 100644 index 000000000..1d2440829 --- /dev/null +++ b/scripts/deployment/phase2-assets/collaterals/deploy_sky_susds.ts @@ -0,0 +1,84 @@ +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 } from '../../utils' +import { SUSDSCollateral } from '../../../../typechain' +import { ContractFactory } from 'ethers' +import { ORACLE_ERROR, ORACLE_TIMEOUT } from '#/test/plugins/individual-collateral/sky/constants' + +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 SUSDS Collateral - sUSDS **************************/ + + const SUSDSCollateralFactory: ContractFactory = await hre.ethers.getContractFactory( + 'SUSDSCollateral' + ) + + const collateral = await SUSDSCollateralFactory.connect(deployer).deploy( + { + priceTimeout: priceTimeout.toString(), + chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDS, + oracleError: ORACLE_ERROR.toString(), // 0.3% + erc20: networkConfig[chainId].tokens.sUSDS, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: ORACLE_TIMEOUT.toString(), // 24h + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: ORACLE_ERROR.add(fp('0.01')).toString(), // 1.3% + delayUntilDefault: bn('86400').toString(), // 24h + }, + bn(0) + ) + await collateral.deployed() + + console.log(`Deployed sUSDS to ${hre.network.name} (${chainId}): ${collateral.address}`) + await (await collateral.refresh()).wait() + expect(await collateral.status()).to.equal(CollateralStatus.SOUND) + + assetCollDeployments.collateral.sUSDS = collateral.address + assetCollDeployments.erc20s.sUSDS = networkConfig[chainId].tokens.sUSDS + 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_susds.ts b/scripts/verification/collateral-plugins/verify_susds.ts new file mode 100644 index 000000000..3773fa443 --- /dev/null +++ b/scripts/verification/collateral-plugins/verify_susds.ts @@ -0,0 +1,57 @@ +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, verifyContract } from '../../deployment/utils' +import { + ORACLE_ERROR, + ORACLE_TIMEOUT, +} from '../../../test/plugins/individual-collateral/sky/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}`) + } + + const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) + deployments = getDeploymentFile(assetCollDeploymentFilename) + + /******** Verify sUSDS **************************/ + await verifyContract( + chainId, + deployments.collateral.sUSDS, + [ + { + priceTimeout: priceTimeout.toString(), + chainlinkFeed: networkConfig[chainId].chainlinkFeeds.USDS, + oracleError: ORACLE_ERROR.toString(), // 0.3% + erc20: networkConfig[chainId].tokens.sUSDS, + maxTradeVolume: fp('1e6').toString(), // $1m, + oracleTimeout: ORACLE_TIMEOUT.toString(), // 24h + targetName: hre.ethers.utils.formatBytes32String('USD'), + defaultThreshold: ORACLE_ERROR.add(fp('0.01')).toString(), // 1.3% + delayUntilDefault: bn('86400').toString(), // 24h + }, + bn(0), + ], + 'contracts/plugins/assets/sky/SUSDSCollateral.sol:SUSDSCollateral' + ) +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/scripts/verify_etherscan.ts b/scripts/verify_etherscan.ts index a448a9ee8..1d4ce4bef 100644 --- a/scripts/verify_etherscan.ts +++ b/scripts/verify_etherscan.ts @@ -80,7 +80,8 @@ async function main() { 'collateral-plugins/verify_ethx.ts', 'collateral-plugins/verify_apxeth.ts', 'collateral-plugins/verify_USDe.ts', - 'collateral-plugins/verify_pyusd.ts' + 'collateral-plugins/verify_pyusd.ts', + 'collateral-plugins/verify_susds.ts' ) } else if (chainId == '8453' || chainId == '84531') { // Base L2 chains