diff --git a/.github/workflows/run-slither.yaml b/.github/workflows/run-slither.yaml index bab788973..80dfa2f8c 100644 --- a/.github/workflows/run-slither.yaml +++ b/.github/workflows/run-slither.yaml @@ -28,4 +28,4 @@ jobs: run: solc-select install 0.8.15;solc-select use 0.8.15 - name: Function clash analysis - run: yarn slither:fn-clashes &> tmp_res; cat tmp_res | { grep 'Function id collision found' || false; } && exit 1 || exit 0 + run: yarn slither:fn-clashes &> tmp_res; cat tmp_res | grep 'Function id collision found' && exit 1 || exit 0 \ No newline at end of file diff --git a/deployments/arbitrum/usdc.e/migrations/1735299634_update_comet_to_support_more_collaterals.ts b/deployments/arbitrum/usdc.e/migrations/1735299634_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..762cdcf21 --- /dev/null +++ b/deployments/arbitrum/usdc.e/migrations/1735299634_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,170 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; +import { applyL1ToL2Alias, estimateL2Transaction } from '../../../../scenario/utils/arbitrumUtils'; + +let newCometExtAddress: string; + +export default migration('1735299634_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + timelock: l2Timelock, + } = await deploymentManager.getContracts(); + + const { + arbitrumInbox, + timelock, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const createRetryableTicketGasParams = await estimateL2Transaction( + { + from: applyL1ToL2Alias(timelock.address), + to: bridgeReceiver.address, + data: l2ProposalData + }, + deploymentManager + ); + const refundAddress = l2Timelock.address; + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo WETH Comet on Arbitrum. + { + contract: arbitrumInbox, + signature: 'createRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,bytes)', + args: [ + bridgeReceiver.address, // address to, + 0, // uint256 l2CallValue, + createRetryableTicketGasParams.maxSubmissionCost, // uint256 maxSubmissionCost, + refundAddress, // address excessFeeRefundAddress, + refundAddress, // address callValueRefundAddress, + createRetryableTicketGasParams.gasLimit, // uint256 gasLimit, + createRetryableTicketGasParams.maxFeePerGas, // uint256 maxFeePerGas, + l2ProposalData, // bytes calldata data + ], + value: createRetryableTicketGasParams.deposit + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/arbitrum/usdc/migrations/1735299626_update_comet_to_support_more_collaterals.ts b/deployments/arbitrum/usdc/migrations/1735299626_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..b55987a78 --- /dev/null +++ b/deployments/arbitrum/usdc/migrations/1735299626_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,170 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; +import { applyL1ToL2Alias, estimateL2Transaction } from '../../../../scenario/utils/arbitrumUtils'; + +let newCometExtAddress: string; + +export default migration('1735299626_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + timelock: l2Timelock, + } = await deploymentManager.getContracts(); + + const { + arbitrumInbox, + timelock, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const createRetryableTicketGasParams = await estimateL2Transaction( + { + from: applyL1ToL2Alias(timelock.address), + to: bridgeReceiver.address, + data: l2ProposalData + }, + deploymentManager + ); + const refundAddress = l2Timelock.address; + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo WETH Comet on Arbitrum. + { + contract: arbitrumInbox, + signature: 'createRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,bytes)', + args: [ + bridgeReceiver.address, // address to, + 0, // uint256 l2CallValue, + createRetryableTicketGasParams.maxSubmissionCost, // uint256 maxSubmissionCost, + refundAddress, // address excessFeeRefundAddress, + refundAddress, // address callValueRefundAddress, + createRetryableTicketGasParams.gasLimit, // uint256 gasLimit, + createRetryableTicketGasParams.maxFeePerGas, // uint256 maxFeePerGas, + l2ProposalData, // bytes calldata data + ], + value: createRetryableTicketGasParams.deposit + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/arbitrum/usdt/migrations/1735299656_update_comet_to_support_more_collaterals.ts b/deployments/arbitrum/usdt/migrations/1735299656_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..7e008e321 --- /dev/null +++ b/deployments/arbitrum/usdt/migrations/1735299656_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,170 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; +import { applyL1ToL2Alias, estimateL2Transaction } from '../../../../scenario/utils/arbitrumUtils'; + +let newCometExtAddress: string; + +export default migration('1735299656_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + timelock: l2Timelock, + } = await deploymentManager.getContracts(); + + const { + arbitrumInbox, + timelock, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const createRetryableTicketGasParams = await estimateL2Transaction( + { + from: applyL1ToL2Alias(timelock.address), + to: bridgeReceiver.address, + data: l2ProposalData + }, + deploymentManager + ); + const refundAddress = l2Timelock.address; + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo WETH Comet on Arbitrum. + { + contract: arbitrumInbox, + signature: 'createRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,bytes)', + args: [ + bridgeReceiver.address, // address to, + 0, // uint256 l2CallValue, + createRetryableTicketGasParams.maxSubmissionCost, // uint256 maxSubmissionCost, + refundAddress, // address excessFeeRefundAddress, + refundAddress, // address callValueRefundAddress, + createRetryableTicketGasParams.gasLimit, // uint256 gasLimit, + createRetryableTicketGasParams.maxFeePerGas, // uint256 maxFeePerGas, + l2ProposalData, // bytes calldata data + ], + value: createRetryableTicketGasParams.deposit + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/arbitrum/weth/migrations/1735299663_update_comet_to_support_more_collaterals.ts b/deployments/arbitrum/weth/migrations/1735299663_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..7641ccc30 --- /dev/null +++ b/deployments/arbitrum/weth/migrations/1735299663_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,170 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; +import { applyL1ToL2Alias, estimateL2Transaction } from '../../../../scenario/utils/arbitrumUtils'; + +let newCometExtAddress: string; + +export default migration('1735299663_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + timelock: l2Timelock, + } = await deploymentManager.getContracts(); + + const { + arbitrumInbox, + timelock, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const createRetryableTicketGasParams = await estimateL2Transaction( + { + from: applyL1ToL2Alias(timelock.address), + to: bridgeReceiver.address, + data: l2ProposalData + }, + deploymentManager + ); + const refundAddress = l2Timelock.address; + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo WETH Comet on Arbitrum. + { + contract: arbitrumInbox, + signature: 'createRetryableTicket(address,uint256,uint256,address,address,uint256,uint256,bytes)', + args: [ + bridgeReceiver.address, // address to, + 0, // uint256 l2CallValue, + createRetryableTicketGasParams.maxSubmissionCost, // uint256 maxSubmissionCost, + refundAddress, // address excessFeeRefundAddress, + refundAddress, // address callValueRefundAddress, + createRetryableTicketGasParams.gasLimit, // uint256 gasLimit, + createRetryableTicketGasParams.maxFeePerGas, // uint256 maxFeePerGas, + l2ProposalData, // bytes calldata data + ], + value: createRetryableTicketGasParams.deposit + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts b/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..9bdec850e --- /dev/null +++ b/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,147 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299703_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + + const { + baseL1CrossDomainMessenger, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: baseL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/base/usdbc/migrations/1735299714_update_comet_to_support_more_collaterals.ts b/deployments/base/usdbc/migrations/1735299714_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..a78ef3c7d --- /dev/null +++ b/deployments/base/usdbc/migrations/1735299714_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,147 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299714_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + + const { + baseL1CrossDomainMessenger, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: baseL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/base/usdc/migrations/1735299718_update_comet_to_support_more_collaterals.ts b/deployments/base/usdc/migrations/1735299718_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..5d1501a3d --- /dev/null +++ b/deployments/base/usdc/migrations/1735299718_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,147 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299718_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + + const { + baseL1CrossDomainMessenger, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: baseL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/base/weth/migrations/1735299723_update_comet_to_support_more_collaterals.ts b/deployments/base/weth/migrations/1735299723_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..a9be12cdd --- /dev/null +++ b/deployments/base/weth/migrations/1735299723_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,147 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299723_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + + const { + baseL1CrossDomainMessenger, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: baseL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/mainnet/weth/migrations/1723198576_update_comet_to_support_more_collaterals.ts b/deployments/mainnet/usdc/migrations/1735299739_update_comet_to_support_more_collaterals.ts similarity index 98% rename from deployments/mainnet/weth/migrations/1723198576_update_comet_to_support_more_collaterals.ts rename to deployments/mainnet/usdc/migrations/1735299739_update_comet_to_support_more_collaterals.ts index 7235fba0c..4aa8a8743 100644 --- a/deployments/mainnet/weth/migrations/1723198576_update_comet_to_support_more_collaterals.ts +++ b/deployments/mainnet/usdc/migrations/1735299739_update_comet_to_support_more_collaterals.ts @@ -7,7 +7,7 @@ import { Contract } from 'ethers'; let newCometExtAddress: string; -export default migration('1723198576_update_comet_to_support_more_collaterals', { +export default migration('1735299739_update_comet_to_support_more_collaterals', { async prepare(deploymentManager: DeploymentManager) { const _assetListFactory = await deploymentManager.deploy( 'assetListFactory', diff --git a/deployments/mainnet/usds/migrations/1735299744_update_comet_to_support_more_collaterals.ts b/deployments/mainnet/usds/migrations/1735299744_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..ed41f83a3 --- /dev/null +++ b/deployments/mainnet/usds/migrations/1735299744_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,126 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { proposal } from '../../../../src/deploy'; +import { ethers } from 'ethers'; +import { Contract } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299744_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, _, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const mainnetActions = [ + // 1. Set the factory in the Configurator + { + contract: configurator, + signature: 'setFactory(address,address)', + args: [comet.address, cometFactoryExtendedAssetList], + }, + // 2. Set new CometExt as the extension delegate + { + contract: configurator, + signature: 'setExtensionDelegate(address,address)', + args: [comet.address, newCometExt], + }, + // 3. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/mainnet/usdt/migrations/1735299748_update_comet_to_support_more_collaterals.ts b/deployments/mainnet/usdt/migrations/1735299748_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..defc79f86 --- /dev/null +++ b/deployments/mainnet/usdt/migrations/1735299748_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,126 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { proposal } from '../../../../src/deploy'; +import { ethers } from 'ethers'; +import { Contract } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299748_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, _, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const mainnetActions = [ + // 1. Set the factory in the Configurator + { + contract: configurator, + signature: 'setFactory(address,address)', + args: [comet.address, cometFactoryExtendedAssetList], + }, + // 2. Set new CometExt as the extension delegate + { + contract: configurator, + signature: 'setExtensionDelegate(address,address)', + args: [comet.address, newCometExt], + }, + // 3. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/mainnet/weth/migrations/1735299752_update_comet_to_support_more_collaterals.ts b/deployments/mainnet/weth/migrations/1735299752_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..4049619f2 --- /dev/null +++ b/deployments/mainnet/weth/migrations/1735299752_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,126 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { proposal } from '../../../../src/deploy'; +import { ethers } from 'ethers'; +import { Contract } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299752_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, _, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const mainnetActions = [ + // 1. Set the factory in the Configurator + { + contract: configurator, + signature: 'setFactory(address,address)', + args: [comet.address, cometFactoryExtendedAssetList], + }, + // 2. Set new CometExt as the extension delegate + { + contract: configurator, + signature: 'setExtensionDelegate(address,address)', + args: [comet.address, newCometExt], + }, + // 3. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/mainnet/wsteth/migrations/1735299760_update_comet_to_support_more_collaterals.ts b/deployments/mainnet/wsteth/migrations/1735299760_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..4ee265202 --- /dev/null +++ b/deployments/mainnet/wsteth/migrations/1735299760_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,126 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { proposal } from '../../../../src/deploy'; +import { ethers } from 'ethers'; +import { Contract } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299760_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, _, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const mainnetActions = [ + // 1. Set the factory in the Configurator + { + contract: configurator, + signature: 'setFactory(address,address)', + args: [comet.address, cometFactoryExtendedAssetList], + }, + // 2. Set new CometExt as the extension delegate + { + contract: configurator, + signature: 'setExtensionDelegate(address,address)', + args: [comet.address, newCometExt], + }, + // 3. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/mantle/usde/migrations/1735299778_update_comet_to_support_more_collaterals.ts b/deployments/mantle/usde/migrations/1735299778_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..be1c8bb1c --- /dev/null +++ b/deployments/mantle/usde/migrations/1735299778_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,147 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299778_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + + const { + mantleL1CrossDomainMessenger, + governor + } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // 1. Set Comet configuration + deployAndUpgradeTo new Comet and set reward config on Mantle. + { + contract: mantleL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 2_500_000], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/optimism/usdc/migrations/1735299799_update_comet_to_support_more_collaterals.ts b/deployments/optimism/usdc/migrations/1735299799_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..b5bd49600 --- /dev/null +++ b/deployments/optimism/usdc/migrations/1735299799_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,143 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299799_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + const { governor, opL1CrossDomainMessenger } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: opL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/optimism/usdt/migrations/1735054359_update_comet_to_support_more_collaterals.ts b/deployments/optimism/usdt/migrations/1735054359_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..efe8db336 --- /dev/null +++ b/deployments/optimism/usdt/migrations/1735054359_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,143 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735054359_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + const { governor, opL1CrossDomainMessenger } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: opL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/optimism/usdt/migrations/1735299805_my_migration.ts b/deployments/optimism/usdt/migrations/1735299805_my_migration.ts new file mode 100644 index 000000000..2c56259f4 --- /dev/null +++ b/deployments/optimism/usdt/migrations/1735299805_my_migration.ts @@ -0,0 +1,14 @@ +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; + +interface Vars {}; + +export default migration('1735299805_my_migration', { + prepare: async (deploymentManager: DeploymentManager) => { + return {}; + }, + + enact: async (deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager, vars: Vars) => { + // No governance changes + } +}); diff --git a/deployments/optimism/weth/migrations/1735054364_update_comet_to_support_more_collaterals.ts b/deployments/optimism/weth/migrations/1735054364_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..717387093 --- /dev/null +++ b/deployments/optimism/weth/migrations/1735054364_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,143 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735054364_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + const { governor, opL1CrossDomainMessenger } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // Send the proposal to the L2 bridge + { + contract: opL1CrossDomainMessenger, + signature: 'sendMessage(address,bytes,uint32)', + args: [bridgeReceiver.address, l2ProposalData, 3_000_000] + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/optimism/weth/migrations/1735299811_my_migration.ts b/deployments/optimism/weth/migrations/1735299811_my_migration.ts new file mode 100644 index 000000000..045229c67 --- /dev/null +++ b/deployments/optimism/weth/migrations/1735299811_my_migration.ts @@ -0,0 +1,14 @@ +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; + +interface Vars {}; + +export default migration('1735299811_my_migration', { + prepare: async (deploymentManager: DeploymentManager) => { + return {}; + }, + + enact: async (deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager, vars: Vars) => { + // No governance changes + } +}); diff --git a/deployments/polygon/usdc/migrations/1735299827_update_comet_to_support_more_collaterals.ts b/deployments/polygon/usdc/migrations/1735299827_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..b8fa2aa26 --- /dev/null +++ b/deployments/polygon/usdc/migrations/1735299827_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,143 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299827_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + const { governor, fxRoot } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo new Comet on Polygon. + { + contract: fxRoot, + signature: 'sendMessageToChild(address,bytes)', + args: [bridgeReceiver.address, l2ProposalData], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/polygon/usdt/migrations/1735299832_update_comet_to_support_more_collaterals.ts b/deployments/polygon/usdt/migrations/1735299832_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..55e772a1c --- /dev/null +++ b/deployments/polygon/usdt/migrations/1735299832_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,143 @@ +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 { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299832_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + const { governor, fxRoot } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + // 1. Set Comet configuration and deployAndUpgradeTo new Comet on Polygon. + { + contract: fxRoot, + signature: 'sendMessageToChild(address,bytes)', + args: [bridgeReceiver.address, l2ProposalData], + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/deployments/scroll/usdc/migrations/1735299855_update_comet_to_support_more_collaterals.ts b/deployments/scroll/usdc/migrations/1735299855_update_comet_to_support_more_collaterals.ts new file mode 100644 index 000000000..36788dd99 --- /dev/null +++ b/deployments/scroll/usdc/migrations/1735299855_update_comet_to_support_more_collaterals.ts @@ -0,0 +1,143 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { calldata, proposal, exp } from '../../../../src/deploy'; +import { ethers } from 'ethers'; +import { Contract } from 'ethers'; +import { utils } from 'ethers'; + +let newCometExtAddress: string; + +export default migration('1735299855_update_comet_to_support_more_collaterals', { + async prepare(deploymentManager: DeploymentManager) { + const _assetListFactory = await deploymentManager.deploy( + 'assetListFactory', + 'AssetListFactory.sol', + [] + ); + + const cometFactoryExtendedAssetList = await deploymentManager.deploy( + 'cometFactoryExtendedAssetList', + 'CometFactoryExtendedAssetList.sol', + [] + ); + const { + comet + } = await deploymentManager.getContracts(); + + const extensionDelegate = new Contract( + await comet.extensionDelegate(), + [ + 'function name() external view returns (string)', + 'function symbol() external view returns (string)', + ], + deploymentManager.hre.ethers.provider + ); + const name = await extensionDelegate.name(); + const symbol = await extensionDelegate.symbol(); + + const _newCometExt = await deploymentManager.deploy( + 'CometExtAssetList', + 'CometExtAssetList.sol', + [ + { + name32: ethers.utils.formatBytes32String(name), + symbol32: ethers.utils.formatBytes32String(symbol) + }, + _assetListFactory.address + ] + ); + return { + cometFactoryExtendedAssetList: cometFactoryExtendedAssetList.address, + newCometExt: _newCometExt.address + }; + }, + + async enact(deploymentManager: DeploymentManager, govDeploymentManager, { + cometFactoryExtendedAssetList, + newCometExt, + }) { + + const trace = deploymentManager.tracer(); + const { + comet, + cometAdmin, + configurator, + bridgeReceiver, + } = await deploymentManager.getContracts(); + const { governor, scrollMessenger } = await govDeploymentManager.getContracts(); + + newCometExtAddress = newCometExt; + + const setFactoryCalldata = await calldata( + configurator.populateTransaction.setFactory(comet.address, cometFactoryExtendedAssetList) + ); + + const setExtensionDelegateCalldata = await calldata( + configurator.populateTransaction.setExtensionDelegate(comet.address, newCometExt) + ); + + const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode( + ['address', 'address'], + [configurator.address, comet.address] + ); + + const l2ProposalData = utils.defaultAbiCoder.encode( + ['address[]', 'uint256[]', 'string[]', 'bytes[]'], + [ + [configurator.address, configurator.address, cometAdmin.address], + [0, 0, 0], + [ + 'setFactory(address,address)', + 'setExtensionDelegate(address,address)', + 'deployAndUpgradeTo(address,address)', + ], + [setFactoryCalldata, setExtensionDelegateCalldata, deployAndUpgradeToCalldata], + ] + ); + + const mainnetActions = [ + { + contract: scrollMessenger, + signature: 'sendMessage(address,uint256,bytes,uint256)', + args: [bridgeReceiver.address, 0, l2ProposalData, 1_000_000], + value: exp(0.2, 18) + }, + ]; + + const description = 'DESCRIPTION'; + const txn = await deploymentManager.retry(async () => + trace( + await governor.propose(...(await proposal(mainnetActions, description))) + ) + ); + + const event = txn.events.find( + (event) => event.event === 'ProposalCreated' + ); + const [proposalId] = event.args; + trace(`Created proposal ${proposalId}.`); + }, + + async enacted(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet } = await deploymentManager.getContracts(); + + const cometNew = new Contract( + comet.address, + [ + 'function assetList() external view returns (address)', + ], + deploymentManager.hre.ethers.provider + ); + + const assetListAddress = await cometNew.assetList(); + + expect(assetListAddress).to.not.be.equal(ethers.constants.AddressZero); + + expect(await comet.extensionDelegate()).to.be.equal(newCometExtAddress); + }, +}); diff --git a/hardhat.config.ts b/hardhat.config.ts index 86661713e..9e0512f98 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -56,7 +56,6 @@ const { BASESCAN_KEY, OPTIMISMSCAN_KEY, MANTLESCAN_KEY, - INFURA_KEY, ANKR_KEY, MNEMONIC = 'myth like bonus scare over problem client lizard pioneer submit female collect', REPORT_GAS = 'false', @@ -158,7 +157,7 @@ const networkConfigs: NetworkConfig[] = [ ]; function getDefaultProviderURL(network: string) { - return `https://${network}.infura.io/v3/${INFURA_KEY}`; + return `https://rpc.ankr.com/${network}/${ANKR_KEY}`; } function setupDefaultNetworkProviders(hardhatConfig: HardhatUserConfig) { @@ -225,8 +224,6 @@ const config: HardhatUserConfig = { apiKey: { // Ethereum mainnet: ETHERSCAN_KEY, - ropsten: ETHERSCAN_KEY, - rinkeby: ETHERSCAN_KEY, sepolia: ETHERSCAN_KEY, // Avalanche avalanche: SNOWTRACE_KEY, diff --git a/plugins/deployment_manager/test/VerifyTest.ts b/plugins/deployment_manager/test/VerifyTest.ts index 2c63e3937..e2e48f0c6 100644 --- a/plugins/deployment_manager/test/VerifyTest.ts +++ b/plugins/deployment_manager/test/VerifyTest.ts @@ -16,12 +16,12 @@ export function mockVerifySuccess(hre: HardhatRuntimeEnvironment) { let solcList = JSON.parse(fs.readFileSync(path.join(__dirname, './SolcList.json'), 'utf8')); - // Note: we need to convince the prober task that this is sepolia, which it's not. + // Note: we need to convince the prober task that this is goerli, which it's not. // So we'll fake the network name and the chain ID hre.config.etherscan.apiKey = { - sepolia: 'SEPOLIA_KEY', + goerli: 'GOERLI_KEY', }; - hre.network.name = 'sepolia'; + hre.network.name = 'goerli'; let sendOld = hre.network.provider.send.bind(hre.network.provider); hre.network.provider.send = function (...args) { if (args.length === 1 && args[0] === 'eth_chainId') { @@ -32,7 +32,7 @@ export function mockVerifySuccess(hre: HardhatRuntimeEnvironment) { }; const solcMockPool = mockAgent.get('https://solc-bin.ethereum.org'); - const etherscanMockPool = mockAgent.get('https://api-sepolia.etherscan.io'); + const etherscanMockPool = mockAgent.get('https://api-goerli.etherscan.io'); solcMockPool.intercept({ path: '/bin/list.json', @@ -53,7 +53,7 @@ export function mockVerifySuccess(hre: HardhatRuntimeEnvironment) { path: '/api', method: 'GET', query: { - apikey: 'SEPOLIA_KEY', + apikey: 'GOERLI_KEY', module: 'contract', action: 'checkverifystatus', guid: 'MYGUID', diff --git a/plugins/scenario/utils/hreForBase.ts b/plugins/scenario/utils/hreForBase.ts index f7dd53b7d..326db975a 100644 --- a/plugins/scenario/utils/hreForBase.ts +++ b/plugins/scenario/utils/hreForBase.ts @@ -76,7 +76,7 @@ export async function forkedHreForBase(base: ForkSpec): Promise ( { $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset, + $asset1: getConfigForScenario(ctx).bulkerAsset1, } ), tokenBalances: async (ctx) => ( @@ -35,7 +35,7 @@ scenario( albert: { $base: '== 0', $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset + $asset1: getConfigForScenario(ctx).bulkerAsset1 }, $comet: { $base: getConfigForScenario(ctx).bulkerComet }, } @@ -53,7 +53,7 @@ scenario( const { asset: collateralAssetAddress, scale: scaleBN } = asset0 === wrappedNativeToken ? { asset: asset1, scale: scale1 } : { asset: asset0, scale: scale0 }; const collateralAsset = context.getAssetByAddress(collateralAssetAddress); const collateralScale = scaleBN.toBigInt(); - const toSupplyCollateral = BigInt(getConfigForScenario(context).bulkerAsset) * collateralScale; + const toSupplyCollateral = BigInt(asset0 === wrappedNativeToken ? getConfigForScenario(context).bulkerAsset1 : getConfigForScenario(context).bulkerAsset) * collateralScale; const toBorrowBase = BigInt(getConfigForScenario(context).bulkerBorrowBase) * baseScale; const toTransferBase = BigInt(getConfigForScenario(context).bulkerBorrowAsset) * baseScale; const toSupplyEth = exp(0.01, 18); @@ -120,7 +120,7 @@ scenario( supplyCaps: async (ctx) => ( { $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset, + $asset1: getConfigForScenario(ctx).bulkerAsset1, } ), tokenBalances: async (ctx) => ( @@ -128,7 +128,7 @@ scenario( albert: { $base: '== 0', $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset + $asset1: getConfigForScenario(ctx).bulkerAsset1 }, $comet: { $base: getConfigForScenario(ctx).bulkerComet }, } @@ -146,7 +146,7 @@ scenario( const { asset: collateralAssetAddress, scale: scaleBN } = asset0 === wrappedNativeToken ? { asset: asset1, scale: scale1 } : { asset: asset0, scale: scale0 }; const collateralAsset = context.getAssetByAddress(collateralAssetAddress); const collateralScale = scaleBN.toBigInt(); - const toSupplyCollateral = BigInt(getConfigForScenario(context).bulkerAsset) * collateralScale; + const toSupplyCollateral = BigInt(asset0 === wrappedNativeToken ? getConfigForScenario(context).bulkerAsset1 : getConfigForScenario(context).bulkerAsset) * collateralScale; const toBorrowBase = BigInt(getConfigForScenario(context).bulkerBorrowBase) * baseScale; const toTransferBase = BigInt(getConfigForScenario(context).bulkerBorrowAsset) * baseScale; const toSupplyEth = exp(0.01, 18); @@ -296,7 +296,7 @@ scenario( supplyCaps: async (ctx) => ( { $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset, + $asset1: getConfigForScenario(ctx).bulkerAsset1, } ), tokenBalances: async (ctx) => ( @@ -304,7 +304,7 @@ scenario( albert: { $base: `== ${getConfigForScenario(ctx).bulkerBase}`, $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset + $asset1: getConfigForScenario(ctx).bulkerAsset1 }, $comet: { $base: getConfigForScenario(ctx).bulkerComet }, } @@ -324,7 +324,7 @@ scenario( const collateralScale = scaleBN.toBigInt(); const [rewardTokenAddress] = await rewards.rewardConfig(comet.address); const toSupplyBase = BigInt(getConfigForScenario(context).bulkerBase) * baseScale; - const toSupplyCollateral = BigInt(getConfigForScenario(context).bulkerAsset) * collateralScale; + const toSupplyCollateral = BigInt(asset0 === wrappedNativeToken ? getConfigForScenario(context).bulkerAsset1 : getConfigForScenario(context).bulkerAsset) * collateralScale; const toBorrowBase = BigInt(getConfigForScenario(context).bulkerBorrowBase) * baseScale; const toTransferBase = BigInt(getConfigForScenario(context).bulkerBorrowAsset) * baseScale; const toSupplyEth = exp(0.01, 18); @@ -408,7 +408,7 @@ scenario( supplyCaps: async (ctx) => ( { $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset, + $asset1: getConfigForScenario(ctx).bulkerAsset1, } ), tokenBalances: async (ctx) => ( @@ -416,7 +416,7 @@ scenario( albert: { $base: `== ${getConfigForScenario(ctx).bulkerBase}`, $asset0: getConfigForScenario(ctx).bulkerAsset, - $asset1: getConfigForScenario(ctx).bulkerAsset + $asset1: getConfigForScenario(ctx).bulkerAsset1 }, $comet: { $base: getConfigForScenario(ctx).bulkerComet }, } @@ -436,7 +436,7 @@ scenario( const collateralScale = scaleBN.toBigInt(); const [rewardTokenAddress] = await rewards.rewardConfig(comet.address); const toSupplyBase = BigInt(getConfigForScenario(context).bulkerBase) * baseScale; - const toSupplyCollateral = BigInt(getConfigForScenario(context).bulkerAsset) * collateralScale; + const toSupplyCollateral = BigInt(asset0 === wrappedNativeToken ? getConfigForScenario(context).bulkerAsset1 : getConfigForScenario(context).bulkerAsset) * collateralScale; const toBorrowBase = BigInt(getConfigForScenario(context).bulkerBorrowBase) * baseScale; const toTransferBase = BigInt(getConfigForScenario(context).bulkerBorrowAsset) * baseScale; const toSupplyEth = exp(0.01, 18); diff --git a/scenario/context/CometContext.ts b/scenario/context/CometContext.ts index 9687cdd1c..e72b5a3dc 100644 --- a/scenario/context/CometContext.ts +++ b/scenario/context/CometContext.ts @@ -74,7 +74,7 @@ export class CometContext { } async getCompWhales(): Promise { - const useMainnetComp = ['mainnet', 'polygon', 'arbitrum', 'base', 'optimism', 'mantle'].includes(this.world.base.network); + const useMainnetComp = ['mainnet', 'polygon', 'arbitrum', 'base', 'optimism', 'scroll', 'mantle'].includes(this.world.base.network); return COMP_WHALES[useMainnetComp ? 'mainnet' : 'testnet']; } diff --git a/scenario/utils/index.ts b/scenario/utils/index.ts index 567c3c276..ccf143c19 100644 --- a/scenario/utils/index.ts +++ b/scenario/utils/index.ts @@ -299,11 +299,16 @@ export function matchesDeployment(ctx: CometContext, deploymentCriteria: Deploym export async function isRewardSupported(ctx: CometContext): Promise { const rewards = await ctx.getRewards(); const comet = await ctx.getComet(); + const COMP = await ctx.getComp(); + if (rewards == null) return false; const [rewardTokenAddress] = await rewards.rewardConfig(comet.address); if (rewardTokenAddress === constants.AddressZero) return false; + const totalSupply = await COMP.totalSupply(); + if (totalSupply.toBigInt() < exp(1, 18)) return false; + return true; } diff --git a/scenario/utils/relayScrollMessage.ts b/scenario/utils/relayScrollMessage.ts index 161b4bccb..4b7672778 100644 --- a/scenario/utils/relayScrollMessage.ts +++ b/scenario/utils/relayScrollMessage.ts @@ -48,10 +48,19 @@ export default async function relayScrollMessage( await setNextBaseFeeToZero(bridgeDeploymentManager); - let aliasAccount = await impersonateAddress( - bridgeDeploymentManager, - applyL1ToL2Alias(scrollMessenger.address) - ); + let aliasAccount; + if (bridgeDeploymentManager.network == 'scroll-goerli'){ + aliasAccount = await impersonateAddress( + bridgeDeploymentManager, + '0xD69c917c7F1C0a724A51c189B4A8F4F8C8E8cA0a' + ); + } else { + aliasAccount = await impersonateAddress( + bridgeDeploymentManager, + applyL1ToL2Alias(scrollMessenger.address) + ); + } + const relayMessageTxn = await ( await l2Messenger.connect(aliasAccount).relayMessage( sender, @@ -72,21 +81,21 @@ export default async function relayScrollMessage( // 2. Cross-chain message passing if (target === l2ERC20Gateway.address) { // 1a. Bridging ERC20 token - const { l1Token, _l2Token, _from, to, amount, _data } = ethers.utils.defaultAbiCoder.decode( + const [ l1Token, _l2Token, _from, to, amount, _data ] = ethers.utils.defaultAbiCoder.decode( ['address _l1Token', 'address _l2Token','address _from', 'address _to','uint256 _amount', 'bytes _data'], messageWithoutSigHash ); - + console.log( `[${governanceDeploymentManager.network} -> ${bridgeDeploymentManager.network}] Bridged over ${amount} of ${l1Token} to user ${to}` ); } else if (target === l2ETHGateway.address){ // 1a. Bridging ETH - const { _from, to, amount, _data } = ethers.utils.defaultAbiCoder.decode( + const [ _from, to, amount, _data ] = ethers.utils.defaultAbiCoder.decode( ['address _from', 'address _to', 'uint256 _amount', 'bytes _data'], messageWithoutSigHash ); - + const oldBalance = await bridgeDeploymentManager.hre.ethers.provider.getBalance(to); const newBalance = oldBalance.add(BigNumber.from(amount)); // This is our best attempt to mimic the deposit transaction type (not supported in Hardhat) that Optimism uses to deposit ETH to an L2 address @@ -94,48 +103,48 @@ export default async function relayScrollMessage( to, ethers.utils.hexStripZeros(newBalance.toHexString()), ]); - + console.log( `[${governanceDeploymentManager.network} -> ${bridgeDeploymentManager.network}] Bridged over ${amount} of ETH to user ${to}` ); }else if (target === l2WETHGateway.address){ // 1c. Bridging WETH - const { _l1Token, _l2Token, _from, to, amount, _data } = ethers.utils.defaultAbiCoder.decode( + const [ _l1Token, _l2Token, _from, to, amount, _data ] = ethers.utils.defaultAbiCoder.decode( ['address _l1Token', 'address _l2Token','address _from', 'address _to','uint256 _amount', 'bytes _data'], messageWithoutSigHash ); - + console.log( `[${governanceDeploymentManager.network} -> ${bridgeDeploymentManager.network}] Bridged over ${amount} of WETH to user ${to}` ); } else if (target === l2WstETHGateway.address){ // 1d. Bridging WstETH - const { _l1Token, _l2Token, _from, to, amount, _data } = ethers.utils.defaultAbiCoder.decode( + const [ _l1Token, _l2Token, _from, to, amount, _data ] = ethers.utils.defaultAbiCoder.decode( ['address _l1Token', 'address _l2Token','address _from', 'address _to','uint256 _amount', 'bytes _data'], messageWithoutSigHash ); - + console.log( `[${governanceDeploymentManager.network} -> ${bridgeDeploymentManager.network}] Bridged over ${amount} of WstETH to user ${to}` ); } else if (target === bridgeReceiver.address) { // Cross-chain message passing - const proposalCreatedEvent = relayMessageTxn.events.find(event => event.address === bridgeReceiver.address); + const proposalCreatedEvent = relayMessageTxn.events.find(event => event.address.toLowerCase() === bridgeReceiver.address.toLowerCase()); const { args: { id, eta } } = bridgeReceiver.interface.parseLog(proposalCreatedEvent); - + // Add the proposal to the list of open bridged proposals to be executed after all the messages have been relayed openBridgedProposals.push({ id, eta }); } else { throw new Error(`[${governanceDeploymentManager.network} -> ${bridgeDeploymentManager.network}] Unrecognized target for cross-chain message`); } } - + // Execute open bridged proposals now that all messages have been bridged for (let proposal of openBridgedProposals) { const { eta, id } = proposal; // Fast forward l2 time await setNextBlockTimestamp(bridgeDeploymentManager, eta.toNumber() + 1); - + // Execute queued proposal await setNextBaseFeeToZero(bridgeDeploymentManager); await bridgeReceiver.executeProposal(id, { gasPrice: 0 }); diff --git a/scenario/utils/scenarioHelper.ts b/scenario/utils/scenarioHelper.ts index a5a8d82a7..9d2ddbc76 100644 --- a/scenario/utils/scenarioHelper.ts +++ b/scenario/utils/scenarioHelper.ts @@ -3,6 +3,7 @@ import { CometContext } from '../context/CometContext'; const config = { bulkerBase: 1000000, bulkerAsset: 5000, + bulkerAsset1: 5000, bulkerComet: 5000, bulkerBorrowBase: 1000, bulkerBorrowAsset: 500, @@ -24,6 +25,7 @@ export function getConfigForScenario(ctx: CometContext) { if (ctx.world.base.network === 'mainnet' && ctx.world.base.deployment === 'wbtc') { config.bulkerBase = 5000; config.bulkerAsset = 200; + config.bulkerAsset1 = 200; config.bulkerComet = 200; config.bulkerBorrowBase = 100; config.bulkerBorrowAsset = 50; @@ -66,11 +68,21 @@ export function getConfigForScenario(ctx: CometContext) { if (ctx.world.base.network === 'polygon' && ctx.world.base.deployment === 'usdc') { config.bulkerAsset = 200; + config.bulkerAsset1 = 200; } if (ctx.world.base.network === 'polygon' && ctx.world.base.deployment === 'usdt') { config.withdrawAsset = 10000; } + if (ctx.world.base.network === 'scroll' && ctx.world.base.deployment === 'usdc') { + config.bulkerAsset = 500; + config.bulkerAsset1 = 500; + } + + if (ctx.world.base.network === 'sepolia' && ctx.world.base.deployment === 'usdc') { + config.bulkerAsset1 = 10; + } + return config; } \ No newline at end of file diff --git a/src/deploy/index.ts b/src/deploy/index.ts index 938362227..134c23a91 100644 --- a/src/deploy/index.ts +++ b/src/deploy/index.ts @@ -128,7 +128,8 @@ export const WHALES = { '0xb125E6687d4313864e53df431d5425969c15Eb2F', // cbETH whale ], scroll: [ - '0xaaaaAAAACB71BF2C8CaE522EA5fa455571A74106' // USDC whale + '0xaaaaAAAACB71BF2C8CaE522EA5fa455571A74106', // USDC whale + '0x5B1322eeb46240b02e20062b8F0F9908d525B09c', // wstETH whale ], optimism: [ '0x2A82Ae142b2e62Cb7D10b55E323ACB1Cab663a26', // OP whale