From 8df743205e39ec0e375de2c7731fe95a1f2591ff Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Wed, 3 Jul 2024 14:53:15 +0300 Subject: [PATCH 1/9] feat: add dai market on mainnet --- .github/workflows/run-scenarios.yaml | 2 +- deployments/mainnet/dai/configuration.json | 66 +++++ deployments/mainnet/dai/deploy.ts | 37 +++ .../1719910152_configurate_and_ens.ts | 246 ++++++++++++++++++ deployments/mainnet/dai/relations.ts | 18 ++ deployments/mainnet/dai/roots.json | 1 + deployments/mainnet/usdc/roots.json | 2 +- hardhat.config.ts | 9 +- scenario/LiquidationBotScenario.ts | 2 +- scenario/SupplyScenario.ts | 6 +- .../liquidateUnderwaterBorrowers.ts | 18 +- 11 files changed, 399 insertions(+), 8 deletions(-) create mode 100644 deployments/mainnet/dai/configuration.json create mode 100644 deployments/mainnet/dai/deploy.ts create mode 100644 deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts create mode 100644 deployments/mainnet/dai/relations.ts create mode 100644 deployments/mainnet/dai/roots.json diff --git a/.github/workflows/run-scenarios.yaml b/.github/workflows/run-scenarios.yaml index 0d9805358..c7a27cc36 100644 --- a/.github/workflows/run-scenarios.yaml +++ b/.github/workflows/run-scenarios.yaml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - bases: [ development, mainnet, mainnet-weth, goerli, goerli-weth, sepolia-usdc, sepolia-weth, fuji, mumbai, polygon, arbitrum-usdc.e, arbitrum-usdc, arbitrum-weth, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-usdbc, base-weth, base-usdc, base-goerli, base-goerli-weth, linea-goerli, optimism-usdc, optimism-usdt, scroll-goerli, scroll-usdc] + bases: [ development, mainnet, mainnet-weth, mainnet-dai, goerli, goerli-weth, sepolia-usdc, sepolia-weth, fuji, mumbai, polygon, arbitrum-usdc.e, arbitrum-usdc, arbitrum-weth, arbitrum-goerli-usdc, arbitrum-goerli-usdc.e, base-usdbc, base-weth, base-usdc, base-goerli, base-goerli-weth, linea-goerli, optimism-usdc, optimism-usdt, scroll-goerli, scroll-usdc] name: Run scenarios env: ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }} diff --git a/deployments/mainnet/dai/configuration.json b/deployments/mainnet/dai/configuration.json new file mode 100644 index 000000000..a3d110853 --- /dev/null +++ b/deployments/mainnet/dai/configuration.json @@ -0,0 +1,66 @@ +{ + "name": "Compound DAI", + "symbol": "cDAIv3", + "baseToken": "DAI", + "baseTokenAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F", + "baseTokenPriceFeed": "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9", + "borrowMin": "100e6", + "governor": "0x6d903f6003cca6255d85cca4d3b5e5146dc33925", + "pauseGuardian": "0xbbf3f1421d886e9b2c5d716b5192ac998af2012c", + "storeFrontPriceFactor": 0.6, + "targetReserves": "20000000e18", + "rates": { + "supplyBase": 0, + "supplySlopeLow": 0.069, + "supplyKink": 0.85, + "supplySlopeHigh": 3.2, + "borrowBase": 0.015, + "borrowSlopeLow": 0.081, + "borrowKink": 0.85, + "borrowSlopeHigh": 4.2 + }, + "tracking": { + "indexScale": "1e15", + "baseSupplySpeed": "0e15", + "baseBorrowSpeed": "0e15", + "baseMinForRewards": "1000000e18" + }, + "rewardTokenAddress": "0xc00e94Cb662C3520282E6f5717214004A7f26888", + "assets": { + "USDe": { + "address": "0x4c9EDD5852cd905f086C759E8383e09bff1E68B3", + "priceFeed": "0xa569d910839Ae8865Da8F8e70FfFb0cBA869F961", + "decimals": "18", + "borrowCF": 0.70, + "liquidateCF": 0.75, + "liquidationFactor": 0.85, + "supplyCap": "0e18" + }, + "WETH": { + "address": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2", + "priceFeed": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419", + "decimals": "18", + "borrowCF": 0.83, + "liquidateCF": 0.9, + "liquidationFactor": 0.95, + "supplyCap": "0e18" + }, + "WBTC": { + "address": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599", + "decimals": "8", + "borrowCF": 0.80, + "liquidateCF": 0.85, + "liquidationFactor": 0.95, + "supplyCap": "0e8" + }, + "sUSDe": { + "address": "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497", + "priceFeed": "0xFF3BC18cCBd5999CE63E788A1c250a88626aD099", + "decimals": "18", + "borrowCF": 0.70, + "liquidateCF": 0.75, + "liquidationFactor": 0.85, + "supplyCap": "0e18" + } + } +} \ No newline at end of file diff --git a/deployments/mainnet/dai/deploy.ts b/deployments/mainnet/dai/deploy.ts new file mode 100644 index 000000000..df556c64f --- /dev/null +++ b/deployments/mainnet/dai/deploy.ts @@ -0,0 +1,37 @@ +import { Deployed, DeploymentManager } from '../../../plugins/deployment_manager'; +import { DeploySpec, deployComet } from '../../../src/deploy'; + +export default async function deploy(deploymentManager: DeploymentManager, deploySpec: DeploySpec): Promise<Deployed> { + const DAI = await deploymentManager.existing('DAI', '0x6B175474E89094C44Da98b954EedeAC495271d0F'); + const WBTC = await deploymentManager.existing('WBTC', '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'); + const WETH = await deploymentManager.existing('WETH', '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'); + const USDe = await deploymentManager.existing('USDe', '0x4c9EDD5852cd905f086C759E8383e09bff1E68B3'); + const sUSDe = await deploymentManager.existing('sUSDe', '0x9D39A5DE30e57443BfF2A8307A4256c8797A3497'); + const COMP = await deploymentManager.existing('COMP', '0xc00e94Cb662C3520282E6f5717214004A7f26888'); + + const wbtcScalingPriceFeed = await deploymentManager.deploy( + 'WBTC:priceFeed', + 'pricefeeds/WBTCPriceFeed.sol', + [ + '0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23', // WBTC / BTC price feed + '0xdeb288F737066589598e9214E782fa5A8eD689e8', // BTC / USD price feed + 8 // decimals + ] + ); + + // Import shared contracts from cUSDCv3 + const cometAdmin = await deploymentManager.fromDep('cometAdmin', 'mainnet', 'usdc'); + const $configuratorImpl = await deploymentManager.fromDep('configurator:implementation', 'mainnet', 'usdc'); + const configurator = await deploymentManager.fromDep('configurator', 'mainnet', 'usdc'); + const rewards = await deploymentManager.fromDep('rewards', 'mainnet', 'usdc'); + const bulker = await deploymentManager.fromDep('bulker', 'mainnet', 'usdc'); + + // Deploy Comet + const deployed = await deployComet(deploymentManager, deploySpec); + return { + ...deployed, + bulker, + rewards, + COMP + }; +} diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts new file mode 100644 index 000000000..cadd02023 --- /dev/null +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -0,0 +1,246 @@ +import { ethers, utils } from 'ethers'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { exp, getConfigurationStruct, proposal } from '../../../../src/deploy'; +import { expect } from 'chai'; + +const ENSName = 'compound-community-licenses.eth'; +const ENSResolverAddress = '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'; +const ENSRegistryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'; +const ENSSubdomainLabel = 'v3-additional-grants'; +const ENSSubdomain = `${ENSSubdomainLabel}.${ENSName}`; +const ENSTextRecordKey = 'v3-official-markets'; + +const cDAIAddress = '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643'; +const DAIAmount = ethers.BigNumber.from(exp(250_000, 18)); + +export default migration('1719910152_configurate_and_ens', { + async prepare() { + return {}; + }, + + async enact(deploymentManager: DeploymentManager) { + const trace = deploymentManager.tracer(); + + const { + comet, + cometAdmin, + configurator, + rewards, + COMP, + DAI, + governor, + timelock + } = await deploymentManager.getContracts(); + + const cometFactory = await deploymentManager.fromDep( + 'cometFactory', + 'mainnet', + 'usdc' + ); + const configuration = await getConfigurationStruct(deploymentManager); + + const ENSResolver = await deploymentManager.existing('ENSResolver', ENSResolverAddress); + const subdomainHash = deploymentManager.hre.ethers.utils.namehash(ENSSubdomain); + const currentChainId = 1; + const newMarketObject = { baseSymbol: 'DAI', cometAddress: comet.address }; + const officialMarketsJSON = JSON.parse(await ENSResolver.text(subdomainHash, ENSTextRecordKey)); + + if (officialMarketsJSON[currentChainId]) { + officialMarketsJSON[currentChainId].push(newMarketObject); + } else { + officialMarketsJSON[currentChainId] = [newMarketObject]; + } + + const _reduceReservesCalldata = utils.defaultAbiCoder.encode( + ['uint256'], + [DAIAmount] + ); + + const actions = [ + // 1. Set Comet factory + { + contract: configurator, + signature: 'setFactory(address,address)', + args: [comet.address, cometFactory.address], + }, + // 2. Set the Comet configuration + { + contract: configurator, + signature: 'setConfiguration(address,(address,address,address,address,address,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint104,uint104,uint104,(address,address,uint8,uint64,uint64,uint64,uint128)[]))', + args: [comet.address, configuration], + }, + // 3. Deploy Comet and upgrade it to the new implementation + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + // 4. Set the reward configuration + { + contract: rewards, + signature: 'setRewardConfig(address,address)', + args: [comet.address, COMP.address], + }, + // 5. Get DAI reserves from cDAI contract + { + target: cDAIAddress, + signature: '_reduceReserves(uint256)', + calldata: _reduceReservesCalldata + }, + // 6. Transfer DAI to the Comet contract + { + contract: DAI, + signature: 'transfer(address,uint256)', + args: [comet.address, DAIAmount], + }, + // 7. Update the list of official markets + { + target: ENSResolverAddress, + signature: 'setText(bytes32,string,string)', + calldata: ethers.utils.defaultAbiCoder.encode( + ['bytes32', 'string', 'string'], + [subdomainHash, ENSTextRecordKey, JSON.stringify(officialMarketsJSON)] + ) + } + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry( + async () => trace((await governor.propose(...await proposal(actions, description)))) + ); + + const event = txn.events.find(event => event.event === 'ProposalCreated'); + const [proposalId] = event.args; + + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise<boolean> { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + + const { + comet, + rewards, + timelock, + COMP, + WBTC, + WETH, + USDe, + sUSDe + } = await deploymentManager.getContracts(); + + // 1. & 2. & 3 + const wbtcInfo = await comet.getAssetInfoByAddress(WBTC.address); + const wethInfo = await comet.getAssetInfoByAddress(WETH.address); + const usdeInfo = await comet.getAssetInfoByAddress(USDe.address); + const susdeInfo = await comet.getAssetInfoByAddress(sUSDe.address); + + // expect(wbtcInfo.borrowCap).to.be.eq(exp(7_200, 8)); + // expect(wethInfo.borrowCap).to.be.eq(exp(175_000 , 18)); + // expect(usdeInfo.supplyCap).to.be.eq(exp(66_000_000, 6)); + // expect(susdeInfo.borrowCap).to.be.eq(exp(35_000_000, 6)); + + // expect(await comet.baseTrackingSupplySpeed()).to.be.equal(exp(25 / 86400, 15, 18)); // 289351851851 + // expect(await comet.baseTrackingBorrowSpeed()).to.be.equal(exp(15 / 86400, 15, 18)); // 173611111111 + + // 4. + const config = await rewards.rewardConfig(comet.address); + expect(config.token).to.be.equal(COMP.address); + expect(config.rescaleFactor).to.be.equal(exp(1, 12)); + expect(config.shouldUpscale).to.be.equal(true); + + expect((await comet.pauseGuardian()).toLowerCase()).to.be.eq('0xbbf3f1421d886e9b2c5d716b5192ac998af2012c'); + + // 5. & 6. + expect(await comet.getReserves()).to.be.equal(DAIAmount); + + // 7. + const ENSResolver = await deploymentManager.existing('ENSResolver', ENSResolverAddress); + const ENSRegistry = await deploymentManager.existing('ENSRegistry', ENSRegistryAddress); + const subdomainHash = ethers.utils.namehash(ENSSubdomain); + const officialMarketsJSON = await ENSResolver.text(subdomainHash, ENSTextRecordKey); + const officialMarkets = JSON.parse(officialMarketsJSON); + expect(await ENSRegistry.recordExists(subdomainHash)).to.be.equal(true); + expect(await ENSRegistry.owner(subdomainHash)).to.be.equal(timelock.address); + expect(await ENSRegistry.resolver(subdomainHash)).to.be.equal(ENSResolverAddress); + expect(await ENSRegistry.ttl(subdomainHash)).to.be.equal(0); + expect(officialMarkets).to.deep.equal({ + 1: [ + { + baseSymbol: 'USDC', + cometAddress: '0xc3d688B66703497DAA19211EEdff47f25384cdc3', + }, + { + baseSymbol: 'WETH', + cometAddress: '0xA17581A9E3356d9A858b789D68B4d866e593aE94', + }, + { + baseSymbol: 'DAI', + cometAddress: comet.address, + } + ], + 10: [ + { + baseSymbol: 'USDC', + cometAddress: '0x2e44e174f7D53F0212823acC11C01A11d58c5bCB' + }, + { + baseSymbol: 'USDT', + cometAddress: '0x995E394b8B2437aC8Ce61Ee0bC610D617962B214' + } + ], + 137: [ + { + baseSymbol: 'USDC', + cometAddress: '0xF25212E676D1F7F89Cd72fFEe66158f541246445' + }, + { + baseSymbol: 'USDT', + cometAddress: '0xaeB318360f27748Acb200CE616E389A6C9409a07' + } + ], + 8453: [ + { + baseSymbol: 'USDbC', + cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf', + }, + { + baseSymbol: 'WETH', + cometAddress: '0x46e6b214b524310239732D51387075E0e70970bf', + }, + { + baseSymbol: 'USDC', + cometAddress: '0xb125E6687d4313864e53df431d5425969c15Eb2F', + } + ], + 42161: [ + { + baseSymbol: 'USDC.e', + cometAddress: '0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA', + }, + { + baseSymbol: 'USDC', + cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf', + }, + { + baseSymbol: 'WETH', + cometAddress: '0x6f7D514bbD4aFf3BcD1140B7344b32f063dEe486' + }, + { + baseSymbol: 'USDT', + cometAddress: '0xd98Be00b5D27fc98112BdE293e487f8D4cA57d07' + } + ], + 534352: [ + { + baseSymbol: 'USDC', + cometAddress: '0xB2f97c1Bd3bf02f5e74d13f02E3e26F93D77CE44', + } + ] + }); + } +}); \ No newline at end of file diff --git a/deployments/mainnet/dai/relations.ts b/deployments/mainnet/dai/relations.ts new file mode 100644 index 000000000..e0a67a984 --- /dev/null +++ b/deployments/mainnet/dai/relations.ts @@ -0,0 +1,18 @@ +import { RelationConfigMap } from '../../../plugins/deployment_manager/RelationConfig'; +import baseRelationConfig from '../../relations'; + +export default { + ...baseRelationConfig, + 'AppProxyUpgradeable': { + artifact: 'contracts/ERC20.sol:ERC20', + }, + 'sUSDe': { + artifact: 'contracts/ERC20.sol:ERC20', + }, + 'USDe': { + artifact: 'contracts/ERC20.sol:ERC20', + }, + 'DAI': { + artifact: 'contracts/ERC20.sol:ERC20', + }, +}; diff --git a/deployments/mainnet/dai/roots.json b/deployments/mainnet/dai/roots.json new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/deployments/mainnet/dai/roots.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/deployments/mainnet/usdc/roots.json b/deployments/mainnet/usdc/roots.json index 637e34be5..d25e3fbcd 100644 --- a/deployments/mainnet/usdc/roots.json +++ b/deployments/mainnet/usdc/roots.json @@ -15,4 +15,4 @@ "opL1StandardBridge": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1", "scrollMessenger": "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367", "scrollL1USDCGateway": "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B" -} +} \ No newline at end of file diff --git a/hardhat.config.ts b/hardhat.config.ts index 02b603d6e..d3108c73d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -25,6 +25,7 @@ import sepoliaWethRelationConfigMap from './deployments/sepolia/weth/relations'; import mumbaiRelationConfigMap from './deployments/mumbai/usdc/relations'; import mainnetRelationConfigMap from './deployments/mainnet/usdc/relations'; import mainnetWethRelationConfigMap from './deployments/mainnet/weth/relations'; +import mainnetDaiRelationConfigMap from './deployments/mainnet/dai/relations'; import polygonRelationConfigMap from './deployments/polygon/usdc/relations'; import arbitrumBridgedUsdcRelationConfigMap from './deployments/arbitrum/usdc.e/relations'; import arbitrumNativeUsdcRelationConfigMap from './deployments/arbitrum/usdc/relations'; @@ -348,7 +349,8 @@ const config: HardhatUserConfig = { }, mainnet: { usdc: mainnetRelationConfigMap, - weth: mainnetWethRelationConfigMap + weth: mainnetWethRelationConfigMap, + dai: mainnetDaiRelationConfigMap }, polygon: { usdc: polygonRelationConfigMap @@ -400,6 +402,11 @@ const config: HardhatUserConfig = { network: 'mainnet', deployment: 'weth', }, + { + name: 'mainnet-dai', + network: 'mainnet', + deployment: 'dai', + }, { name: 'development', network: 'hardhat', diff --git a/scenario/LiquidationBotScenario.ts b/scenario/LiquidationBotScenario.ts index 763468c9e..2898a475e 100644 --- a/scenario/LiquidationBotScenario.ts +++ b/scenario/LiquidationBotScenario.ts @@ -749,7 +749,7 @@ scenario( upgrade: { targetReserves: exp(20_000, 18) }, - filter: async (ctx) => matchesDeployment(ctx, [{network: 'mainnet'}]), + filter: async (ctx) => matchesDeployment(ctx, [{network: 'mainnet'}]) && !matchesDeployment(ctx, [{deployment: 'dai'}]), tokenBalances: async (ctx) => ( { $comet: { diff --git a/scenario/SupplyScenario.ts b/scenario/SupplyScenario.ts index a3ec668af..dc482f5a3 100644 --- a/scenario/SupplyScenario.ts +++ b/scenario/SupplyScenario.ts @@ -309,7 +309,8 @@ scenario( /ERC20: insufficient allowance/, /transfer amount exceeds spender allowance/, /Dai\/insufficient-allowance/, - symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/ + symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/, + symbol === 'WBTC' ? /Transaction reverted without a reason string/ : /.^/ ] ); } @@ -393,7 +394,8 @@ scenario( [ /transfer amount exceeds balance/, /Dai\/insufficient-balance/, - symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/ + symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/, + symbol === 'WBTC' ? /Transaction reverted without a reason string/ : /.^/ ] ); } diff --git a/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts b/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts index 577bf2fef..783fd1b19 100644 --- a/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts +++ b/scripts/liquidation_bot/liquidateUnderwaterBorrowers.ts @@ -38,7 +38,8 @@ const addresses = { WBTC: '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599', WETH9: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', CB_ETH: '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704', - WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0' + WST_ETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0', + USDe: '0x4c9EDD5852cd905f086C759E8383e09bff1E68B3' }, goerli: { WETH: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d' @@ -67,7 +68,8 @@ const addresses = { const liquidationThresholds = { mainnet: { 'usdc': 10e6, - 'weth': 1e18 + 'weth': 1e18, + 'dai': 10e18 }, goerli: { 'usdc': 10e6 @@ -90,6 +92,10 @@ export const flashLoanPools = { weth: { tokenAddress: addresses.mainnet.USDC, poolFee: 500 + }, + dai: { + tokenAddress: addresses.mainnet.USDC, + poolFee: 100 } }, goerli: { @@ -184,6 +190,14 @@ export function getPoolConfig(tokenAddress: string) { balancerPoolId: '0x32296969ef14eb0c6d29669c550d4a0449130230000200000000000000000080' } }, + [addresses.mainnet.USDe.toLowerCase()]: { + ...defaultPoolConfig, + ...{ + exchange: Exchange.Uniswap, + swapViaWeth: false, + uniswapPoolFee: 100 + } + }, [addresses.polygon.WMATIC.toLowerCase()]: { ...defaultPoolConfig, ...{ From 2a4d6e6a3f8a9719b4f57ecf8b632dd5327ce837 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Thu, 4 Jul 2024 20:40:01 +0300 Subject: [PATCH 2/9] fix: update ens and add description --- .../migrations/1719910152_configurate_and_ens.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index cadd02023..5b7565f94 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -36,7 +36,8 @@ export default migration('1719910152_configurate_and_ens', { const cometFactory = await deploymentManager.fromDep( 'cometFactory', 'mainnet', - 'usdc' + // 'usdt' // Uncomment this line after deployment of the cUSDTv3 will be finished + 'usdc' // Comment this line after deployment of the cUSDTv3 will be finished ); const configuration = await getConfigurationStruct(deploymentManager); @@ -46,6 +47,12 @@ export default migration('1719910152_configurate_and_ens', { const newMarketObject = { baseSymbol: 'DAI', cometAddress: comet.address }; const officialMarketsJSON = JSON.parse(await ENSResolver.text(subdomainHash, ENSTextRecordKey)); + // add mainnet-usdt comet (0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840) + // mainnet chain id is 1 + if (!(officialMarketsJSON[1].find(market => market.baseSymbol === 'USDT'))) { + officialMarketsJSON[1].push({ baseSymbol: 'USDT', cometAddress: '0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840'}); + } + if (officialMarketsJSON[currentChainId]) { officialMarketsJSON[currentChainId].push(newMarketObject); } else { @@ -105,7 +112,7 @@ export default migration('1719910152_configurate_and_ens', { } ]; - const description = 'DESCRIPTION'; + const description = '# Initialize cDAIv3 on Ethereum Mainnet\n\n## Proposal summary\n\nFranklinDAO team with advice support from Woof Software team proposes deployment of Compound III to the Ethereum Mainnet network. This proposal takes the governance steps recommended and necessary to initialize a Compound III DAI market on Ethereum Mainnet; upon execution, cDAIv3 will be ready for use. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet](https://www.comp.xyz/t/gauntlet-dai-v3-comet-on-mainnet-recommendation/5380/1).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/879), [deploy market GitHub action run](<>) and [forum discussion](https://www.comp.xyz/t/gauntlet-dai-v3-comet-on-mainnet-recommendation/5380).\n\n\n## Proposal Actions\n\nThe first proposal action sets the CometFactory for the new Comet instance in the existing Configurator.\n\nThe second action configures the Comet instance in the Configurator.\n\nThe third action deploys an instance of the newly configured factory and upgrades the Comet instance to use that implementation.\n\nThe fourth action configures the existing rewards contract for the newly deployed Comet instance.\n\nThe fifth action reduces Compound’s [cDAI](https://etherscan.io/address/0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643) reserves and transfers it to Timelock, in order to seed the market reserves for the cDAIv3 Comet.\n\nThe sixth action transfers reserves from Timelock to the cDAIv3 Comet.\n\nThe seventh action updates the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, updating the official markets JSON to include the new Ethereum Mainnet cDAIv3 market.'; const txn = await deploymentManager.retry( async () => trace((await governor.propose(...await proposal(actions, description)))) ); @@ -178,6 +185,10 @@ export default migration('1719910152_configurate_and_ens', { baseSymbol: 'WETH', cometAddress: '0xA17581A9E3356d9A858b789D68B4d866e593aE94', }, + { + baseSymbol: 'USDT', + cometAddress: '0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840', + }, { baseSymbol: 'DAI', cometAddress: comet.address, From 20dd095dd756cd606a1c24329bea941a5ee22369 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Fri, 5 Jul 2024 12:49:57 +0300 Subject: [PATCH 3/9] fix: clean up and description update --- .../dai/migrations/1719910152_configurate_and_ens.ts | 2 +- scenario/SupplyScenario.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index 5b7565f94..3e187ae09 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -112,7 +112,7 @@ export default migration('1719910152_configurate_and_ens', { } ]; - const description = '# Initialize cDAIv3 on Ethereum Mainnet\n\n## Proposal summary\n\nFranklinDAO team with advice support from Woof Software team proposes deployment of Compound III to the Ethereum Mainnet network. This proposal takes the governance steps recommended and necessary to initialize a Compound III DAI market on Ethereum Mainnet; upon execution, cDAIv3 will be ready for use. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet](https://www.comp.xyz/t/gauntlet-dai-v3-comet-on-mainnet-recommendation/5380/1).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/879), [deploy market GitHub action run](<>) and [forum discussion](https://www.comp.xyz/t/gauntlet-dai-v3-comet-on-mainnet-recommendation/5380).\n\n\n## Proposal Actions\n\nThe first proposal action sets the CometFactory for the new Comet instance in the existing Configurator.\n\nThe second action configures the Comet instance in the Configurator.\n\nThe third action deploys an instance of the newly configured factory and upgrades the Comet instance to use that implementation.\n\nThe fourth action configures the existing rewards contract for the newly deployed Comet instance.\n\nThe fifth action reduces Compound’s [cDAI](https://etherscan.io/address/0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643) reserves and transfers it to Timelock, in order to seed the market reserves for the cDAIv3 Comet.\n\nThe sixth action transfers reserves from Timelock to the cDAIv3 Comet.\n\nThe seventh action updates the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, updating the official markets JSON to include the new Ethereum Mainnet cDAIv3 market.'; + const description = '# Initialize cDAIv3 on Ethereum Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes the deployment of Compound III to the Mainnet network. This proposal takes the governance steps recommended and necessary to initialize a Compound III DAI market on Mainnet; upon execution, cDAIv3 will be ready for use. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet](https://www.comp.xyz/t/gauntlet-dai-v3-comet-on-mainnet-recommendation/5380/1).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/879), [deploy market GitHub action run](<>) and [forum discussion](https://www.comp.xyz/t/gauntlet-dai-v3-comet-on-mainnet-recommendation/5380).\n\n\n## Proposal Actions\n\nThe first proposal action sets the CometFactory for the new Comet instance in the existing Configurator.\n\nThe second action configures the Comet instance in the Configurator.\n\nThe third action deploys an instance of the newly configured factory and upgrades the Comet instance to use that implementation.\n\nThe fourth action configures the existing rewards contract for the newly deployed Comet instance.\n\nThe fifth action reduces Compound’s [cDAI](https://etherscan.io/address/0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643) reserves and transfers it to Timelock, in order to seed the market reserves for the cDAIv3 Comet.\n\nThe sixth action transfers reserves from Timelock to the cDAIv3 Comet.\n\nThe seventh action updates the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, updating the official markets JSON to include the new Ethereum Mainnet cDAIv3 market.'; const txn = await deploymentManager.retry( async () => trace((await governor.propose(...await proposal(actions, description)))) ); diff --git a/scenario/SupplyScenario.ts b/scenario/SupplyScenario.ts index 5bcc4e41c..5c12fc065 100644 --- a/scenario/SupplyScenario.ts +++ b/scenario/SupplyScenario.ts @@ -506,8 +506,7 @@ scenario( /ERC20: insufficient allowance/, /transfer amount exceeds spender allowance/, /Dai\/insufficient-allowance/, - symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/, - symbol === 'WBTC' ? /Transaction reverted without a reason string/ : /.^/ + symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/ ] ); } @@ -591,8 +590,7 @@ scenario( [ /transfer amount exceeds balance/, /Dai\/insufficient-balance/, - symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/, - symbol === 'WBTC' ? /Transaction reverted without a reason string/ : /.^/ + symbol === 'WETH' ? /Transaction reverted without a reason string/ : /.^/ ] ); } From 3786fe9d960f12dceaaa97bc5b98c8e49a637467 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Fri, 5 Jul 2024 14:14:24 +0300 Subject: [PATCH 4/9] fix: fix decimals --- deployments/mainnet/dai/configuration.json | 2 +- .../mainnet/dai/migrations/1719910152_configurate_and_ens.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/deployments/mainnet/dai/configuration.json b/deployments/mainnet/dai/configuration.json index a3d110853..324dd2e7f 100644 --- a/deployments/mainnet/dai/configuration.json +++ b/deployments/mainnet/dai/configuration.json @@ -4,7 +4,7 @@ "baseToken": "DAI", "baseTokenAddress": "0x6B175474E89094C44Da98b954EedeAC495271d0F", "baseTokenPriceFeed": "0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9", - "borrowMin": "100e6", + "borrowMin": "100e18", "governor": "0x6d903f6003cca6255d85cca4d3b5e5146dc33925", "pauseGuardian": "0xbbf3f1421d886e9b2c5d716b5192ac998af2012c", "storeFrontPriceFactor": 0.6, diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index 3e187ae09..f6ad1f942 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -148,8 +148,8 @@ export default migration('1719910152_configurate_and_ens', { // expect(wbtcInfo.borrowCap).to.be.eq(exp(7_200, 8)); // expect(wethInfo.borrowCap).to.be.eq(exp(175_000 , 18)); - // expect(usdeInfo.supplyCap).to.be.eq(exp(66_000_000, 6)); - // expect(susdeInfo.borrowCap).to.be.eq(exp(35_000_000, 6)); + // expect(usdeInfo.supplyCap).to.be.eq(exp(66_000_000, 18)); + // expect(susdeInfo.borrowCap).to.be.eq(exp(35_000_000, 18)); // expect(await comet.baseTrackingSupplySpeed()).to.be.equal(exp(25 / 86400, 15, 18)); // 289351851851 // expect(await comet.baseTrackingBorrowSpeed()).to.be.equal(exp(15 / 86400, 15, 18)); // 173611111111 From d6f6dd0fb31d827a21e92e6314852923b9694473 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Fri, 5 Jul 2024 15:25:57 +0300 Subject: [PATCH 5/9] fix: update initial reserves and base min for rewards --- deployments/mainnet/dai/configuration.json | 2 +- .../mainnet/dai/migrations/1719910152_configurate_and_ens.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deployments/mainnet/dai/configuration.json b/deployments/mainnet/dai/configuration.json index 324dd2e7f..a0bc8f724 100644 --- a/deployments/mainnet/dai/configuration.json +++ b/deployments/mainnet/dai/configuration.json @@ -23,7 +23,7 @@ "indexScale": "1e15", "baseSupplySpeed": "0e15", "baseBorrowSpeed": "0e15", - "baseMinForRewards": "1000000e18" + "baseMinForRewards": "100000e18" }, "rewardTokenAddress": "0xc00e94Cb662C3520282E6f5717214004A7f26888", "assets": { diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index f6ad1f942..602d20b34 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -12,7 +12,7 @@ const ENSSubdomain = `${ENSSubdomainLabel}.${ENSName}`; const ENSTextRecordKey = 'v3-official-markets'; const cDAIAddress = '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643'; -const DAIAmount = ethers.BigNumber.from(exp(250_000, 18)); +const DAIAmount = ethers.BigNumber.from(exp(200_000, 18)); export default migration('1719910152_configurate_and_ens', { async prepare() { From 0bf289bb35c08e5f895d3d93919c7eded9083cbf Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Thu, 1 Aug 2024 17:41:47 +0300 Subject: [PATCH 6/9] fix: working migration --- .../mainnet/dai/migrations/1719910152_configurate_and_ens.ts | 4 ++++ scenario/LiquidationBotScenario.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index 602d20b34..b2f277771 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -202,6 +202,10 @@ export default migration('1719910152_configurate_and_ens', { { baseSymbol: 'USDT', cometAddress: '0x995E394b8B2437aC8Ce61Ee0bC610D617962B214' + }, + { + baseSymbol: 'WETH', + cometAddress: '0xE36A30D249f7761327fd973001A32010b521b6Fd' } ], 137: [ diff --git a/scenario/LiquidationBotScenario.ts b/scenario/LiquidationBotScenario.ts index ef4cadbb9..032654159 100644 --- a/scenario/LiquidationBotScenario.ts +++ b/scenario/LiquidationBotScenario.ts @@ -778,7 +778,7 @@ scenario( upgrade: { targetReserves: exp(20_000, 18) }, - filter: async (ctx) => matchesDeployment(ctx, [{network: 'mainnet'}]), + filter: async (ctx) => matchesDeployment(ctx, [{network: 'mainnet'}]) && !matchesDeployment(ctx, [{deployment: 'dai'}]), tokenBalances: async (ctx) => ( { $comet: { From ecd1394f5248e08fd54b84af62bc1df601f0c146 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Thu, 1 Aug 2024 20:30:33 +0300 Subject: [PATCH 7/9] fix: clean up --- .../dai/migrations/1719910152_configurate_and_ens.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index b2f277771..eb6036c08 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -30,14 +30,12 @@ export default migration('1719910152_configurate_and_ens', { COMP, DAI, governor, - timelock } = await deploymentManager.getContracts(); const cometFactory = await deploymentManager.fromDep( 'cometFactory', 'mainnet', - // 'usdt' // Uncomment this line after deployment of the cUSDTv3 will be finished - 'usdc' // Comment this line after deployment of the cUSDTv3 will be finished + 'usdt' // Uncomment this line after deployment of the cUSDTv3 will be finished ); const configuration = await getConfigurationStruct(deploymentManager); @@ -47,12 +45,6 @@ export default migration('1719910152_configurate_and_ens', { const newMarketObject = { baseSymbol: 'DAI', cometAddress: comet.address }; const officialMarketsJSON = JSON.parse(await ENSResolver.text(subdomainHash, ENSTextRecordKey)); - // add mainnet-usdt comet (0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840) - // mainnet chain id is 1 - if (!(officialMarketsJSON[1].find(market => market.baseSymbol === 'USDT'))) { - officialMarketsJSON[1].push({ baseSymbol: 'USDT', cometAddress: '0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840'}); - } - if (officialMarketsJSON[currentChainId]) { officialMarketsJSON[currentChainId].push(newMarketObject); } else { From 3b3062762a678c1293b2006e0381bd653655da0b Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Fri, 2 Aug 2024 20:23:55 +0300 Subject: [PATCH 8/9] fix: clean up --- .../dai/migrations/1719910152_configurate_and_ens.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts index eb6036c08..da6a0ee61 100644 --- a/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts +++ b/deployments/mainnet/dai/migrations/1719910152_configurate_and_ens.ts @@ -12,6 +12,7 @@ const ENSSubdomain = `${ENSSubdomainLabel}.${ENSName}`; const ENSTextRecordKey = 'v3-official-markets'; const cDAIAddress = '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643'; +const NEW_FACTORY_ADDRESS = '0x698A949f3b4f7a5DdE236106F25Fa0eAcA0FcEF1'; const DAIAmount = ethers.BigNumber.from(exp(200_000, 18)); export default migration('1719910152_configurate_and_ens', { @@ -32,15 +33,10 @@ export default migration('1719910152_configurate_and_ens', { governor, } = await deploymentManager.getContracts(); - const cometFactory = await deploymentManager.fromDep( - 'cometFactory', - 'mainnet', - 'usdt' // Uncomment this line after deployment of the cUSDTv3 will be finished - ); const configuration = await getConfigurationStruct(deploymentManager); const ENSResolver = await deploymentManager.existing('ENSResolver', ENSResolverAddress); - const subdomainHash = deploymentManager.hre.ethers.utils.namehash(ENSSubdomain); + const subdomainHash = ethers.utils.namehash(ENSSubdomain); const currentChainId = 1; const newMarketObject = { baseSymbol: 'DAI', cometAddress: comet.address }; const officialMarketsJSON = JSON.parse(await ENSResolver.text(subdomainHash, ENSTextRecordKey)); @@ -61,7 +57,7 @@ export default migration('1719910152_configurate_and_ens', { { contract: configurator, signature: 'setFactory(address,address)', - args: [comet.address, cometFactory.address], + args: [comet.address, NEW_FACTORY_ADDRESS], }, // 2. Set the Comet configuration { From 2c792fc453a01cff33b2c6d6f60c27ce2b1facd6 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash <misha.sh@woof.software> Date: Mon, 5 Aug 2024 16:00:54 +0300 Subject: [PATCH 9/9] fix: correct price feed --- deployments/mainnet/dai/deploy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/mainnet/dai/deploy.ts b/deployments/mainnet/dai/deploy.ts index df556c64f..13dc35ff1 100644 --- a/deployments/mainnet/dai/deploy.ts +++ b/deployments/mainnet/dai/deploy.ts @@ -14,7 +14,7 @@ export default async function deploy(deploymentManager: DeploymentManager, deplo 'pricefeeds/WBTCPriceFeed.sol', [ '0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23', // WBTC / BTC price feed - '0xdeb288F737066589598e9214E782fa5A8eD689e8', // BTC / USD price feed + '0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c', // BTC / USD price feed 8 // decimals ] );