diff --git a/deployments/polygon/usdc/migrations/1782122727_deprecate_maticx.ts b/deployments/polygon/usdc/migrations/1782122727_deprecate_maticx.ts new file mode 100644 index 000000000..714f0f005 --- /dev/null +++ b/deployments/polygon/usdc/migrations/1782122727_deprecate_maticx.ts @@ -0,0 +1,211 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { calldata, proposal } from '../../../../src/deploy'; +import { utils, Contract } from 'ethers'; + + +let minPricePriceFeed: string; + +const USDC_COMET = '0xF25212E676D1F7F89Cd72fFEe66158f541246445'; +const USDT_COMET = '0xaeB318360f27748Acb200CE616E389A6C9409a07'; + +export default migration('1782122727_deprecate_maticx', { + async prepare() { + return {}; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager) { + + const trace = deploymentManager.tracer(); + + const { + configurator, + bridgeReceiver, + cometAdmin, + MaticX, + 'stMATIC:priceFeed': stMaticPriceFeed + } = await deploymentManager.getContracts(); + minPricePriceFeed = stMaticPriceFeed.address; + + const { + governor, + fxRoot + } = await govDeploymentManager.getContracts(); + + const updateMaticXBorrowCollateralFactorCalldataUsdc = await calldata( + configurator.populateTransaction.updateAssetBorrowCollateralFactor( + USDC_COMET, + MaticX.address, + 0 + ) + ); + + const updateMaticXPriceFeedCalldataUsdc = await calldata( + configurator.populateTransaction.updateAssetPriceFeed( + USDC_COMET, + MaticX.address, + minPricePriceFeed + ) + ); + + const updateMaticXSupplyCapCalldataUsdc = await calldata( + configurator.populateTransaction.updateAssetSupplyCap( + USDC_COMET, + MaticX.address, + 0 + ) + ); + + const deployAndUpgradeToCalldataUsdc = await calldata( + cometAdmin.populateTransaction.deployAndUpgradeTo( + configurator.address, + USDC_COMET + ) + ); + + const updateMaticXBorrowCollateralFactorCalldataUsdt = await calldata( + configurator.populateTransaction.updateAssetBorrowCollateralFactor( + USDT_COMET, + MaticX.address, + 0 + ) + ); + + const updateMaticXPriceFeedCalldataUsdt = await calldata( + configurator.populateTransaction.updateAssetPriceFeed( + USDT_COMET, + MaticX.address, + minPricePriceFeed + ) + ); + + const updateMaticXSupplyCapCalldataUsdt = await calldata( + configurator.populateTransaction.updateAssetSupplyCap( + USDT_COMET, + MaticX.address, + 0 + ) + ); + + const deployAndUpgradeToCalldataUsdt = await calldata( + cometAdmin.populateTransaction.deployAndUpgradeTo( + configurator.address, + USDT_COMET + ) + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [ + configurator.address, configurator.address, configurator.address, cometAdmin.address, + configurator.address, configurator.address, configurator.address, cometAdmin.address, + ], + [ + 0, 0, 0, 0, + 0, 0, 0, 0, + ], + [ + 'updateAssetBorrowCollateralFactor(address,address,uint64)', 'updateAssetPriceFeed(address,address,address)', 'updateAssetSupplyCap(address,address,uint128)', 'deployAndUpgradeTo(address,address)', + 'updateAssetBorrowCollateralFactor(address,address,uint64)', 'updateAssetPriceFeed(address,address,address)', 'updateAssetSupplyCap(address,address,uint128)', 'deployAndUpgradeTo(address,address)', + ], + [ + updateMaticXBorrowCollateralFactorCalldataUsdc, updateMaticXPriceFeedCalldataUsdc, updateMaticXSupplyCapCalldataUsdc, deployAndUpgradeToCalldataUsdc, + updateMaticXBorrowCollateralFactorCalldataUsdt, updateMaticXPriceFeedCalldataUsdt, updateMaticXSupplyCapCalldataUsdt, deployAndUpgradeToCalldataUsdt, + ], + ] + ); + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo new Comet on Polygon. + { + contract: fxRoot, + signature: 'sendMessageToChild(address,bytes)', + args: [bridgeReceiver.address, l2ProposalData], + }, + ]; + + const description = `# Deprecate MaticX in cUSDCv3 and cUSDTv3 on Polygon + +## Proposal summary + +Woof proposes to deprecate MaticX as collateral in cUSDCv3 and cUSDTv3 on Polygon by updating its price feed to a constant price feed with a price of 1 wei, setting its supply cap to 0, and setting its borrow collateral factor to 0. + +Further detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/1136) and [forum discussion](<>). + +## Proposal actions + +The first action updates MaticX price feed to the constant price feed with a price of 1 wei, sets its supply cap to 0, and sets its borrow collateral factor to 0. This sends the encoded 'updateAssetBorrowCollateralFactor', 'updateAssetPriceFeed', 'updateAssetSupplyCap' and 'deployAndUpgradeTo' calls across the bridge to the governance receiver for both cUSDCv3 and cUSDTv3 on Polygon. +`; + + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ), 0, 300_000 + ); + const event = txn.events.find( + (event: { event: string }) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { configurator, MaticX } = await deploymentManager.getContracts(); + + // USDC + const usdcComet = new Contract( + USDC_COMET, + [ + 'function getAssetInfoByAddress(address) external view returns(tuple(uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))', + 'function getPrice(address priceFeed) view returns (uint256)', + ], + await deploymentManager.getSigner() + ); + + const maticXIndexInUsdcComet = await configurator.getAssetIndex(usdcComet.address, MaticX.address); + + const maticXInUsdcCometInfo = await usdcComet.getAssetInfoByAddress(MaticX.address); + const maticXInUsdcConfiguratorInfo = (await configurator.getConfiguration(usdcComet.address)).assetConfigs[maticXIndexInUsdcComet]; + + expect(maticXInUsdcCometInfo.priceFeed).to.eq(minPricePriceFeed); + expect(maticXInUsdcConfiguratorInfo.priceFeed).to.eq(minPricePriceFeed); + expect(await usdcComet.getPrice(minPricePriceFeed)).to.equal(1); + + expect(maticXInUsdcCometInfo.supplyCap).to.eq(0); + expect(maticXInUsdcConfiguratorInfo.supplyCap).to.eq(0); + + expect(maticXInUsdcCometInfo.borrowCollateralFactor).to.eq(0); + expect(maticXInUsdcConfiguratorInfo.borrowCollateralFactor).to.eq(0); + + // USDT + const usdtComet = new Contract( + USDT_COMET, + [ + 'function getAssetInfoByAddress(address) external view returns(tuple(uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))', + 'function getPrice(address priceFeed) view returns (uint256)', + ], + await deploymentManager.getSigner() + ); + + const maticXIndexInUsdtComet = await configurator.getAssetIndex(usdtComet.address, MaticX.address); + + const maticXInUsdtCometInfo = await usdtComet.getAssetInfoByAddress(MaticX.address); + const maticXInUsdtConfiguratorInfo = (await configurator.getConfiguration(usdtComet.address)).assetConfigs[maticXIndexInUsdtComet]; + + expect(maticXInUsdtCometInfo.priceFeed).to.eq(minPricePriceFeed); + expect(maticXInUsdtConfiguratorInfo.priceFeed).to.eq(minPricePriceFeed); + expect(await usdtComet.getPrice(minPricePriceFeed)).to.equal(1); + + expect(maticXInUsdtCometInfo.supplyCap).to.eq(0); + expect(maticXInUsdtConfiguratorInfo.supplyCap).to.eq(0); + + expect(maticXInUsdtCometInfo.borrowCollateralFactor).to.eq(0); + expect(maticXInUsdtConfiguratorInfo.borrowCollateralFactor).to.eq(0); + }, +}); diff --git a/deployments/polygon/usdt/migrations/1782122727_deprecate_maticx.ts b/deployments/polygon/usdt/migrations/1782122727_deprecate_maticx.ts new file mode 100644 index 000000000..714f0f005 --- /dev/null +++ b/deployments/polygon/usdt/migrations/1782122727_deprecate_maticx.ts @@ -0,0 +1,211 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { calldata, proposal } from '../../../../src/deploy'; +import { utils, Contract } from 'ethers'; + + +let minPricePriceFeed: string; + +const USDC_COMET = '0xF25212E676D1F7F89Cd72fFEe66158f541246445'; +const USDT_COMET = '0xaeB318360f27748Acb200CE616E389A6C9409a07'; + +export default migration('1782122727_deprecate_maticx', { + async prepare() { + return {}; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager) { + + const trace = deploymentManager.tracer(); + + const { + configurator, + bridgeReceiver, + cometAdmin, + MaticX, + 'stMATIC:priceFeed': stMaticPriceFeed + } = await deploymentManager.getContracts(); + minPricePriceFeed = stMaticPriceFeed.address; + + const { + governor, + fxRoot + } = await govDeploymentManager.getContracts(); + + const updateMaticXBorrowCollateralFactorCalldataUsdc = await calldata( + configurator.populateTransaction.updateAssetBorrowCollateralFactor( + USDC_COMET, + MaticX.address, + 0 + ) + ); + + const updateMaticXPriceFeedCalldataUsdc = await calldata( + configurator.populateTransaction.updateAssetPriceFeed( + USDC_COMET, + MaticX.address, + minPricePriceFeed + ) + ); + + const updateMaticXSupplyCapCalldataUsdc = await calldata( + configurator.populateTransaction.updateAssetSupplyCap( + USDC_COMET, + MaticX.address, + 0 + ) + ); + + const deployAndUpgradeToCalldataUsdc = await calldata( + cometAdmin.populateTransaction.deployAndUpgradeTo( + configurator.address, + USDC_COMET + ) + ); + + const updateMaticXBorrowCollateralFactorCalldataUsdt = await calldata( + configurator.populateTransaction.updateAssetBorrowCollateralFactor( + USDT_COMET, + MaticX.address, + 0 + ) + ); + + const updateMaticXPriceFeedCalldataUsdt = await calldata( + configurator.populateTransaction.updateAssetPriceFeed( + USDT_COMET, + MaticX.address, + minPricePriceFeed + ) + ); + + const updateMaticXSupplyCapCalldataUsdt = await calldata( + configurator.populateTransaction.updateAssetSupplyCap( + USDT_COMET, + MaticX.address, + 0 + ) + ); + + const deployAndUpgradeToCalldataUsdt = await calldata( + cometAdmin.populateTransaction.deployAndUpgradeTo( + configurator.address, + USDT_COMET + ) + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [ + configurator.address, configurator.address, configurator.address, cometAdmin.address, + configurator.address, configurator.address, configurator.address, cometAdmin.address, + ], + [ + 0, 0, 0, 0, + 0, 0, 0, 0, + ], + [ + 'updateAssetBorrowCollateralFactor(address,address,uint64)', 'updateAssetPriceFeed(address,address,address)', 'updateAssetSupplyCap(address,address,uint128)', 'deployAndUpgradeTo(address,address)', + 'updateAssetBorrowCollateralFactor(address,address,uint64)', 'updateAssetPriceFeed(address,address,address)', 'updateAssetSupplyCap(address,address,uint128)', 'deployAndUpgradeTo(address,address)', + ], + [ + updateMaticXBorrowCollateralFactorCalldataUsdc, updateMaticXPriceFeedCalldataUsdc, updateMaticXSupplyCapCalldataUsdc, deployAndUpgradeToCalldataUsdc, + updateMaticXBorrowCollateralFactorCalldataUsdt, updateMaticXPriceFeedCalldataUsdt, updateMaticXSupplyCapCalldataUsdt, deployAndUpgradeToCalldataUsdt, + ], + ] + ); + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo new Comet on Polygon. + { + contract: fxRoot, + signature: 'sendMessageToChild(address,bytes)', + args: [bridgeReceiver.address, l2ProposalData], + }, + ]; + + const description = `# Deprecate MaticX in cUSDCv3 and cUSDTv3 on Polygon + +## Proposal summary + +Woof proposes to deprecate MaticX as collateral in cUSDCv3 and cUSDTv3 on Polygon by updating its price feed to a constant price feed with a price of 1 wei, setting its supply cap to 0, and setting its borrow collateral factor to 0. + +Further detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/1136) and [forum discussion](<>). + +## Proposal actions + +The first action updates MaticX price feed to the constant price feed with a price of 1 wei, sets its supply cap to 0, and sets its borrow collateral factor to 0. This sends the encoded 'updateAssetBorrowCollateralFactor', 'updateAssetPriceFeed', 'updateAssetSupplyCap' and 'deployAndUpgradeTo' calls across the bridge to the governance receiver for both cUSDCv3 and cUSDTv3 on Polygon. +`; + + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ), 0, 300_000 + ); + const event = txn.events.find( + (event: { event: string }) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { configurator, MaticX } = await deploymentManager.getContracts(); + + // USDC + const usdcComet = new Contract( + USDC_COMET, + [ + 'function getAssetInfoByAddress(address) external view returns(tuple(uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))', + 'function getPrice(address priceFeed) view returns (uint256)', + ], + await deploymentManager.getSigner() + ); + + const maticXIndexInUsdcComet = await configurator.getAssetIndex(usdcComet.address, MaticX.address); + + const maticXInUsdcCometInfo = await usdcComet.getAssetInfoByAddress(MaticX.address); + const maticXInUsdcConfiguratorInfo = (await configurator.getConfiguration(usdcComet.address)).assetConfigs[maticXIndexInUsdcComet]; + + expect(maticXInUsdcCometInfo.priceFeed).to.eq(minPricePriceFeed); + expect(maticXInUsdcConfiguratorInfo.priceFeed).to.eq(minPricePriceFeed); + expect(await usdcComet.getPrice(minPricePriceFeed)).to.equal(1); + + expect(maticXInUsdcCometInfo.supplyCap).to.eq(0); + expect(maticXInUsdcConfiguratorInfo.supplyCap).to.eq(0); + + expect(maticXInUsdcCometInfo.borrowCollateralFactor).to.eq(0); + expect(maticXInUsdcConfiguratorInfo.borrowCollateralFactor).to.eq(0); + + // USDT + const usdtComet = new Contract( + USDT_COMET, + [ + 'function getAssetInfoByAddress(address) external view returns(tuple(uint8 offset, address asset, address priceFeed, uint64 scale, uint64 borrowCollateralFactor, uint64 liquidateCollateralFactor, uint64 liquidationFactor, uint128 supplyCap))', + 'function getPrice(address priceFeed) view returns (uint256)', + ], + await deploymentManager.getSigner() + ); + + const maticXIndexInUsdtComet = await configurator.getAssetIndex(usdtComet.address, MaticX.address); + + const maticXInUsdtCometInfo = await usdtComet.getAssetInfoByAddress(MaticX.address); + const maticXInUsdtConfiguratorInfo = (await configurator.getConfiguration(usdtComet.address)).assetConfigs[maticXIndexInUsdtComet]; + + expect(maticXInUsdtCometInfo.priceFeed).to.eq(minPricePriceFeed); + expect(maticXInUsdtConfiguratorInfo.priceFeed).to.eq(minPricePriceFeed); + expect(await usdtComet.getPrice(minPricePriceFeed)).to.equal(1); + + expect(maticXInUsdtCometInfo.supplyCap).to.eq(0); + expect(maticXInUsdtConfiguratorInfo.supplyCap).to.eq(0); + + expect(maticXInUsdtCometInfo.borrowCollateralFactor).to.eq(0); + expect(maticXInUsdtConfiguratorInfo.borrowCollateralFactor).to.eq(0); + }, +}); diff --git a/scenario/utils/index.ts b/scenario/utils/index.ts index 4562f920b..9c2407291 100644 --- a/scenario/utils/index.ts +++ b/scenario/utils/index.ts @@ -1002,7 +1002,9 @@ async function simulateBundle( const results = []; for (const sim of simulations) { - const { username, project, accessKey } = (dm.hre.config as any).tenderly; + const project = 'comet'; + const username = process.env.TENDERLY_USERNAME || ''; + const accessKey = process.env.TENDERLY_ACCESS_KEY || ''; // Merge rolling state changes with simulation's own state_objects const stateObjects = sim.state_objects @@ -1060,7 +1062,10 @@ async function simulateBundle( } async function shareSimulation(dm: DeploymentManager, simulationId: string) { - const { username, project, accessKey } = (dm.hre.config as any).tenderly; + const project = 'comet'; + const username = process.env.TENDERLY_USERNAME || ''; + const accessKey = process.env.TENDERLY_ACCESS_KEY || ''; + return axios.post( `https://api.tenderly.co/api/v1/account/${username}/project/${project}/simulations/${simulationId}/share`, {}, diff --git a/scenario/utils/scenarioHelper.ts b/scenario/utils/scenarioHelper.ts index 26381efc0..8f5cc98b7 100644 --- a/scenario/utils/scenarioHelper.ts +++ b/scenario/utils/scenarioHelper.ts @@ -212,7 +212,7 @@ export function getConfigForScenario(ctx: CometContext, i?: number) { config.transferAsset = 500000; config.transferBase = 100; config.rewardsAsset = 20000; - config.rewardsBase = 1000; + config.rewardsBase = 100; } if (ctx.world.base.network === 'scroll' && ctx.world.base.deployment === 'usdc') { diff --git a/src/deploy/index.ts b/src/deploy/index.ts index 58c7bb9e3..3f60aa0e2 100644 --- a/src/deploy/index.ts +++ b/src/deploy/index.ts @@ -125,6 +125,7 @@ export const WHALES = { '0x167384319b41f7094e62f7506409eb38079abff8', // WMATIC whale '0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97', // WMATIC whale '0x4D97DCd97eC945f40cF65F87097ACe5EA0476045', // USDC.e whale + '0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae', // COMP whale ], arbitrum: [ '0x8eb270e296023e9d92081fdf967ddd7878724424', // rETH whale