From c6ae23823033af49c3d65d91b8b7635db3abfb41 Mon Sep 17 00:00:00 2001 From: dmitriy-bergman-works Date: Fri, 21 Jun 2024 13:33:56 +0200 Subject: [PATCH 1/6] feat: add weETH collateral into Mainnet WETH market --- .../1718968177_add_weeth_collateral.ts | 179 ++++++++++++++++++ deployments/mainnet/weth/relations.ts | 10 +- scenario/LiquidationBotScenario.ts | 2 +- 3 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts diff --git a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts new file mode 100644 index 000000000..dae7f7432 --- /dev/null +++ b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts @@ -0,0 +1,179 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { exp, proposal } from '../../../../src/deploy'; + +const WEETH_ADDRESS = '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee'; +const WEETH_PRICE_FEED_ADDRESS = '0x5c9C449BbC9a6075A2c061dF312a35fd1E05fF22'; + +export default migration('1718968177_add_weeth_collateral', { + async prepare(deploymentManager: DeploymentManager) { + const _weETHScalingPriceFeed = await deploymentManager.deploy( + 'weETH:priceFeed', + 'pricefeeds/ScalingPriceFeed.sol', + [ + WEETH_PRICE_FEED_ADDRESS, // weETH / ETH price feed + 8 // decimals + ] + ); + return { weETHScalingPriceFeed: _weETHScalingPriceFeed.address }; + }, + + async enact(deploymentManager: DeploymentManager, _, { weETHScalingPriceFeed }) { + + const trace = deploymentManager.tracer(); + + const weETH = await deploymentManager.existing( + 'weETH', + WEETH_ADDRESS, + 'mainnet', + 'contracts/ERC20.sol:ERC20' + ); + const weEthPricefeed = await deploymentManager.existing( + 'weETH:priceFeed', + weETHScalingPriceFeed, + 'mainnet' + ); + + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + // https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3 + const weETHAssetConfig = { + asset: weETH.address, + priceFeed: weEthPricefeed.address, + decimals: await weETH.decimals(), + borrowCollateralFactor: exp(0.82, 18), + liquidateCollateralFactor: exp(0.87, 18), + liquidationFactor: exp(0.92, 18), + supplyCap: exp(22_500, 18), + }; + + const mainnetActions = [ + // 1. Add weETH as asset + { + contract: configurator, + signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))', + args: [comet.address, weETHAssetConfig], + }, + // 2. Set new Annual Supply Interest Rate Slope High to 100% + { + contract: configurator, + signature: 'setSupplyPerYearInterestRateSlopeHigh(address,uint64)', + args: [ + comet.address, + exp(1, 18) // newSupplyPerYearInterestRateSlopeHigh + ], + }, + // 3. Set new Annual Borrow Interest Rate Slope High to 115% + { + contract: configurator, + signature: 'setBorrowPerYearInterestRateSlopeHigh(address,uint64)', + args: [ + comet.address, + exp(1.15, 18) // newBorrowPerYearInterestRateSlopeHigh + ], + }, + // 4. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = '# Add weETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add weETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](PR - https://github.com/compound-finance/comet/pull/867) and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179).\n\n\n## Proposal Actions\n\nThe first proposal action adds weETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; + 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(deploymentManager: DeploymentManager): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet, configurator } = await deploymentManager.getContracts(); + + const weETHAssetIndex = Number(await comet.numAssets()) - 1; + + const weETH = await deploymentManager.existing( + 'weETH', + WEETH_ADDRESS, + 'mainnet', + 'contracts/ERC20.sol:ERC20' + ); + + const weETHAssetConfig = { + asset: weETH.address, + priceFeed: '', + decimals: await weETH.decimals(), + borrowCollateralFactor: exp(0.82, 18), + liquidateCollateralFactor: exp(0.87, 18), + liquidationFactor: exp(0.92, 18), + supplyCap: exp(22_500, 18) + }; + + // 1. Compare weETH asset config with Comet and Configurator asset config + const cometWeETHAssetInfo = await comet.getAssetInfoByAddress( + WEETH_ADDRESS + ); + expect(weETHAssetIndex).to.be.equal(cometWeETHAssetInfo.offset); + expect(weETHAssetConfig.asset).to.be.equal(cometWeETHAssetInfo.asset); + expect(exp(1, weETHAssetConfig.decimals)).to.be.equal( + cometWeETHAssetInfo.scale + ); + expect(weETHAssetConfig.borrowCollateralFactor).to.be.equal( + cometWeETHAssetInfo.borrowCollateralFactor + ); + expect(weETHAssetConfig.liquidateCollateralFactor).to.be.equal( + cometWeETHAssetInfo.liquidateCollateralFactor + ); + expect(weETHAssetConfig.liquidationFactor).to.be.equal( + cometWeETHAssetInfo.liquidationFactor + ); + expect(weETHAssetConfig.supplyCap).to.be.equal( + cometWeETHAssetInfo.supplyCap + ); + + const configuratorWeETHAssetConfig = ( + await configurator.getConfiguration(comet.address) + ).assetConfigs[weETHAssetIndex]; + expect(weETHAssetConfig.asset).to.be.equal( + configuratorWeETHAssetConfig.asset + ); + expect(weETHAssetConfig.decimals).to.be.equal( + configuratorWeETHAssetConfig.decimals + ); + expect(weETHAssetConfig.borrowCollateralFactor).to.be.equal( + configuratorWeETHAssetConfig.borrowCollateralFactor + ); + expect(weETHAssetConfig.liquidateCollateralFactor).to.be.equal( + configuratorWeETHAssetConfig.liquidateCollateralFactor + ); + expect(weETHAssetConfig.liquidationFactor).to.be.equal( + configuratorWeETHAssetConfig.liquidationFactor + ); + expect(weETHAssetConfig.supplyCap).to.be.equal( + configuratorWeETHAssetConfig.supplyCap + ); + + // 2. Check new Annual Supply Interest Rate Slope High + expect(exp(1, 18) / BigInt(31_536_000)).to.be.equal(await comet.supplyPerSecondInterestRateSlopeHigh()); + + // 3. Check new Annual Borrow Interest Rate Slope High + expect(exp(1.15, 18) / BigInt(31_536_000)).to.be.equal(await comet.borrowPerSecondInterestRateSlopeHigh()); + }, +}); diff --git a/deployments/mainnet/weth/relations.ts b/deployments/mainnet/weth/relations.ts index 37278965c..b6c6bcf85 100644 --- a/deployments/mainnet/weth/relations.ts +++ b/deployments/mainnet/weth/relations.ts @@ -13,5 +13,13 @@ export default { }, 'AppProxyUpgradeable': { artifact: 'contracts/ERC20.sol:ERC20', - } + }, + UUPSProxy: { + artifact: 'contracts/ERC20.sol:ERC20', + delegates: { + field: { + slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' + } + } + }, }; \ No newline at end of file diff --git a/scenario/LiquidationBotScenario.ts b/scenario/LiquidationBotScenario.ts index 763468c9e..6cf5b64ec 100644 --- a/scenario/LiquidationBotScenario.ts +++ b/scenario/LiquidationBotScenario.ts @@ -739,7 +739,7 @@ scenario( const assetAmounts = { mainnet: { usdc: ' == 5000', // COMP - weth: ' == 10000', // CB_ETH + weth: ' == 7000', // CB_ETH }, }; From fb322c07463fb3fdca82600416751d0a387b2c6e Mon Sep 17 00:00:00 2001 From: dmitriy-bergman-works Date: Fri, 21 Jun 2024 13:35:37 +0200 Subject: [PATCH 2/6] feat: update description --- .../mainnet/weth/migrations/1718968177_add_weeth_collateral.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts index dae7f7432..406b4e381 100644 --- a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts +++ b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts @@ -86,7 +86,7 @@ export default migration('1718968177_add_weeth_collateral', { }, ]; - const description = '# Add weETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add weETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](PR - https://github.com/compound-finance/comet/pull/867) and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179).\n\n\n## Proposal Actions\n\nThe first proposal action adds weETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; + const description = '# Add weETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add weETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](PR - https://github.com/compound-finance/comet/pull/869) and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179).\n\n\n## Proposal Actions\n\nThe first proposal action adds weETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; const txn = await deploymentManager.retry(async () => trace( await governor.propose(...(await proposal(mainnetActions, description))) From 4b1b278473498e64f110e7579f564cc803607194 Mon Sep 17 00:00:00 2001 From: dmitriy-bergman-works Date: Fri, 21 Jun 2024 13:39:52 +0200 Subject: [PATCH 3/6] feat: add impersonate into enact-migration.yaml --- .github/workflows/enact-migration.yaml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/enact-migration.yaml b/.github/workflows/enact-migration.yaml index 1b1558688..6842ba074 100644 --- a/.github/workflows/enact-migration.yaml +++ b/.github/workflows/enact-migration.yaml @@ -36,6 +36,10 @@ on: description: Run ID for Artifact eth_pk: description: Ignore if you plan to use WalletConnect, otherwise, you can paste in a Ethereum private key + impersonateAccount: + description: Impersonate Account + required: false + default: '' jobs: enact-migration: name: Enact Migration @@ -114,7 +118,18 @@ jobs: GOV_NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8685"]')[github.event.inputs.eth_pk == '' && env.GOV_NETWORK != ''] }} GOV_NETWORK: ${{ env.GOV_NETWORK }} REMOTE_ACCOUNTS: ${{ fromJSON('["", "true"]')[github.event.inputs.eth_pk == ''] }} - + if: github.event.inputs.impersonateAccount == '' + - name: Run Enact Migration (impersonate) + run: | + yarn hardhat migrate --network ${{ github.event.inputs.network }} --deployment ${{ github.event.inputs.deployment }} --enact --overwrite ${{ fromJSON('["", "--simulate"]')[github.event.inputs.simulate == 'true'] }} ${{ fromJSON('["", "--no-enacted"]')[github.event.inputs.no_enacted == 'true'] }} ${{ github.event.inputs.migration }} --impersonate ${{ github.event.inputs.impersonateAccount }} + env: + DEBUG: true + ETH_PK: "${{ inputs.eth_pk }}" + NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8585"]')[github.event.inputs.eth_pk == ''] }} + GOV_NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8685"]')[github.event.inputs.eth_pk == '' && env.GOV_NETWORK != ''] }} + GOV_NETWORK: ${{ env.GOV_NETWORK }} + REMOTE_ACCOUNTS: ${{ fromJSON('["", "true"]')[github.event.inputs.eth_pk == ''] }} + if: github.event.inputs.impersonateAccount != '' - name: Commit changes if: ${{ github.event.inputs.simulate == 'false' }} run: | From bf71d4ba001f05ebb26925c146694bdb2c7101d4 Mon Sep 17 00:00:00 2001 From: dmitriy-bergman-works Date: Fri, 21 Jun 2024 13:43:02 +0200 Subject: [PATCH 4/6] feat: update description --- .../mainnet/weth/migrations/1718968177_add_weeth_collateral.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts index 406b4e381..3aea95104 100644 --- a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts +++ b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts @@ -86,7 +86,7 @@ export default migration('1718968177_add_weeth_collateral', { }, ]; - const description = '# Add weETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add weETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](PR - https://github.com/compound-finance/comet/pull/869) and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179).\n\n\n## Proposal Actions\n\nThe first proposal action adds weETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; + const description = '# Add weETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add weETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based on the [recommendations from Gauntlet weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](PR - https://github.com/compound-finance/comet/pull/869) and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179).\n\n\n## Proposal Actions\n\nThe first proposal action adds weETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; const txn = await deploymentManager.retry(async () => trace( await governor.propose(...(await proposal(mainnetActions, description))) From bfcc1e2ee3fcf6805dedb7be115a18a38aa82675 Mon Sep 17 00:00:00 2001 From: dmitriy-bergman-works Date: Fri, 21 Jun 2024 14:38:23 +0200 Subject: [PATCH 5/6] feat: add rsETH collateral into Mainnet WETH market --- .../1718968177_add_weeth_collateral.ts | 179 ------------------ .../1718972942_add_rseth_collateral.ts | 177 +++++++++++++++++ deployments/mainnet/weth/relations.ts | 2 +- 3 files changed, 178 insertions(+), 180 deletions(-) delete mode 100644 deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts create mode 100644 deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts diff --git a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts b/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts deleted file mode 100644 index 3aea95104..000000000 --- a/deployments/mainnet/weth/migrations/1718968177_add_weeth_collateral.ts +++ /dev/null @@ -1,179 +0,0 @@ -import { expect } from 'chai'; -import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; -import { migration } from '../../../../plugins/deployment_manager/Migration'; -import { exp, proposal } from '../../../../src/deploy'; - -const WEETH_ADDRESS = '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee'; -const WEETH_PRICE_FEED_ADDRESS = '0x5c9C449BbC9a6075A2c061dF312a35fd1E05fF22'; - -export default migration('1718968177_add_weeth_collateral', { - async prepare(deploymentManager: DeploymentManager) { - const _weETHScalingPriceFeed = await deploymentManager.deploy( - 'weETH:priceFeed', - 'pricefeeds/ScalingPriceFeed.sol', - [ - WEETH_PRICE_FEED_ADDRESS, // weETH / ETH price feed - 8 // decimals - ] - ); - return { weETHScalingPriceFeed: _weETHScalingPriceFeed.address }; - }, - - async enact(deploymentManager: DeploymentManager, _, { weETHScalingPriceFeed }) { - - const trace = deploymentManager.tracer(); - - const weETH = await deploymentManager.existing( - 'weETH', - WEETH_ADDRESS, - 'mainnet', - 'contracts/ERC20.sol:ERC20' - ); - const weEthPricefeed = await deploymentManager.existing( - 'weETH:priceFeed', - weETHScalingPriceFeed, - 'mainnet' - ); - - const { - governor, - comet, - cometAdmin, - configurator, - } = await deploymentManager.getContracts(); - - // https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3 - const weETHAssetConfig = { - asset: weETH.address, - priceFeed: weEthPricefeed.address, - decimals: await weETH.decimals(), - borrowCollateralFactor: exp(0.82, 18), - liquidateCollateralFactor: exp(0.87, 18), - liquidationFactor: exp(0.92, 18), - supplyCap: exp(22_500, 18), - }; - - const mainnetActions = [ - // 1. Add weETH as asset - { - contract: configurator, - signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))', - args: [comet.address, weETHAssetConfig], - }, - // 2. Set new Annual Supply Interest Rate Slope High to 100% - { - contract: configurator, - signature: 'setSupplyPerYearInterestRateSlopeHigh(address,uint64)', - args: [ - comet.address, - exp(1, 18) // newSupplyPerYearInterestRateSlopeHigh - ], - }, - // 3. Set new Annual Borrow Interest Rate Slope High to 115% - { - contract: configurator, - signature: 'setBorrowPerYearInterestRateSlopeHigh(address,uint64)', - args: [ - comet.address, - exp(1.15, 18) // newBorrowPerYearInterestRateSlopeHigh - ], - }, - // 4. Deploy and upgrade to a new version of Comet - { - contract: cometAdmin, - signature: 'deployAndUpgradeTo(address,address)', - args: [configurator.address, comet.address], - }, - ]; - - const description = '# Add weETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add weETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based on the [recommendations from Gauntlet weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](PR - https://github.com/compound-finance/comet/pull/869) and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179).\n\n\n## Proposal Actions\n\nThe first proposal action adds weETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; - 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(deploymentManager: DeploymentManager): Promise { - return false; - }, - - async verify(deploymentManager: DeploymentManager) { - const { comet, configurator } = await deploymentManager.getContracts(); - - const weETHAssetIndex = Number(await comet.numAssets()) - 1; - - const weETH = await deploymentManager.existing( - 'weETH', - WEETH_ADDRESS, - 'mainnet', - 'contracts/ERC20.sol:ERC20' - ); - - const weETHAssetConfig = { - asset: weETH.address, - priceFeed: '', - decimals: await weETH.decimals(), - borrowCollateralFactor: exp(0.82, 18), - liquidateCollateralFactor: exp(0.87, 18), - liquidationFactor: exp(0.92, 18), - supplyCap: exp(22_500, 18) - }; - - // 1. Compare weETH asset config with Comet and Configurator asset config - const cometWeETHAssetInfo = await comet.getAssetInfoByAddress( - WEETH_ADDRESS - ); - expect(weETHAssetIndex).to.be.equal(cometWeETHAssetInfo.offset); - expect(weETHAssetConfig.asset).to.be.equal(cometWeETHAssetInfo.asset); - expect(exp(1, weETHAssetConfig.decimals)).to.be.equal( - cometWeETHAssetInfo.scale - ); - expect(weETHAssetConfig.borrowCollateralFactor).to.be.equal( - cometWeETHAssetInfo.borrowCollateralFactor - ); - expect(weETHAssetConfig.liquidateCollateralFactor).to.be.equal( - cometWeETHAssetInfo.liquidateCollateralFactor - ); - expect(weETHAssetConfig.liquidationFactor).to.be.equal( - cometWeETHAssetInfo.liquidationFactor - ); - expect(weETHAssetConfig.supplyCap).to.be.equal( - cometWeETHAssetInfo.supplyCap - ); - - const configuratorWeETHAssetConfig = ( - await configurator.getConfiguration(comet.address) - ).assetConfigs[weETHAssetIndex]; - expect(weETHAssetConfig.asset).to.be.equal( - configuratorWeETHAssetConfig.asset - ); - expect(weETHAssetConfig.decimals).to.be.equal( - configuratorWeETHAssetConfig.decimals - ); - expect(weETHAssetConfig.borrowCollateralFactor).to.be.equal( - configuratorWeETHAssetConfig.borrowCollateralFactor - ); - expect(weETHAssetConfig.liquidateCollateralFactor).to.be.equal( - configuratorWeETHAssetConfig.liquidateCollateralFactor - ); - expect(weETHAssetConfig.liquidationFactor).to.be.equal( - configuratorWeETHAssetConfig.liquidationFactor - ); - expect(weETHAssetConfig.supplyCap).to.be.equal( - configuratorWeETHAssetConfig.supplyCap - ); - - // 2. Check new Annual Supply Interest Rate Slope High - expect(exp(1, 18) / BigInt(31_536_000)).to.be.equal(await comet.supplyPerSecondInterestRateSlopeHigh()); - - // 3. Check new Annual Borrow Interest Rate Slope High - expect(exp(1.15, 18) / BigInt(31_536_000)).to.be.equal(await comet.borrowPerSecondInterestRateSlopeHigh()); - }, -}); diff --git a/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts b/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts new file mode 100644 index 000000000..52bd22188 --- /dev/null +++ b/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts @@ -0,0 +1,177 @@ +import { expect } from 'chai'; +import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; +import { migration } from '../../../../plugins/deployment_manager/Migration'; +import { exp, proposal } from '../../../../src/deploy'; + +const RSETH_ADDRESS = '0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7'; +const RSETH_PRICE_FEED_ADDRESS = '0x03c68933f7a3F76875C0bc670a58e69294cDFD01'; + +export default migration('1718972942_add_rseth_collateral', { + async prepare(deploymentManager: DeploymentManager) { + const _rsETHScalingPriceFeed = await deploymentManager.deploy( + 'rsETH:priceFeed', + 'pricefeeds/ScalingPriceFeed.sol', + [ + RSETH_PRICE_FEED_ADDRESS, // rsETH / ETH price feed + 8 // decimals + ] + ); + return { rsETHScalingPriceFeed: _rsETHScalingPriceFeed.address }; + }, + + async enact(deploymentManager: DeploymentManager, _, { rsETHScalingPriceFeed }) { + + const trace = deploymentManager.tracer(); + + const rsETH = await deploymentManager.existing( + 'rsETH', + RSETH_ADDRESS, + 'mainnet', + 'contracts/ERC20.sol:ERC20' + ); + const rsEthPricefeed = await deploymentManager.existing( + 'rsETH:priceFeed', + rsETHScalingPriceFeed, + 'mainnet' + ); + + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + const rsETHAssetConfig = { + asset: rsETH.address, + priceFeed: rsEthPricefeed.address, + decimals: await rsETH.decimals(), + borrowCollateralFactor: exp(0.80, 18), + liquidateCollateralFactor: exp(0.85, 18), + liquidationFactor: exp(0.9, 18), + supplyCap: exp(5_000, 18), + }; + + const mainnetActions = [ + // 1. Add rsETH as asset + { + contract: configurator, + signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))', + args: [comet.address, rsETHAssetConfig], + }, + // 2. Set new Annual Supply Interest Rate Slope High to 100% + { + contract: configurator, + signature: 'setSupplyPerYearInterestRateSlopeHigh(address,uint64)', + args: [ + comet.address, + exp(1, 18) // newSupplyPerYearInterestRateSlopeHigh + ], + }, + // 3. Set new Annual Borrow Interest Rate Slope High to 115% + { + contract: configurator, + signature: 'setBorrowPerYearInterestRateSlopeHigh(address,uint64)', + args: [ + comet.address, + exp(1.15, 18) // newBorrowPerYearInterestRateSlopeHigh + ], + }, + // 4. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = '# Add rsETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add rsETH into cWETHv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III WETH market on Ethereum. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based on the [recommendations from Gauntlet rsETH](https://www.comp.xyz/t/add-rseth-market-on-ethereum-mainnet/5118/8).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/870) and [forum discussion rsETH](https://www.comp.xyz/t/add-rseth-market-on-ethereum-mainnet/5118).\n\n\n## Proposal Actions\n\nThe first proposal action adds rsETH asset as collateral with corresponding configurations.\n\nThe second action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe third action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fourth action deploys and upgrades Comet to a new version.'; + 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(deploymentManager: DeploymentManager): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet, configurator } = await deploymentManager.getContracts(); + + const rsETHAssetIndex = Number(await comet.numAssets()) - 1; + + const rsETH = await deploymentManager.existing( + 'rsETH', + RSETH_ADDRESS, + 'mainnet', + 'contracts/ERC20.sol:ERC20' + ); + + const rsETHAssetConfig = { + asset: rsETH.address, + priceFeed: '', + decimals: await rsETH.decimals(), + borrowCollateralFactor: exp(0.80, 18), + liquidateCollateralFactor: exp(0.85, 18), + liquidationFactor: exp(0.9, 18), + supplyCap: exp(5_000, 18), // 5_000 + }; + + // 1. Compare rsETH asset config with Comet and Configurator asset info + const cometRsETHAssetInfo = await comet.getAssetInfoByAddress( + RSETH_ADDRESS + ); + expect(rsETHAssetIndex).to.be.equal(cometRsETHAssetInfo.offset); + expect(rsETHAssetConfig.asset).to.be.equal(cometRsETHAssetInfo.asset); + expect(exp(1, rsETHAssetConfig.decimals)).to.be.equal( + cometRsETHAssetInfo.scale + ); + expect(rsETHAssetConfig.borrowCollateralFactor).to.be.equal( + cometRsETHAssetInfo.borrowCollateralFactor + ); + expect(rsETHAssetConfig.liquidateCollateralFactor).to.be.equal( + cometRsETHAssetInfo.liquidateCollateralFactor + ); + expect(rsETHAssetConfig.liquidationFactor).to.be.equal( + cometRsETHAssetInfo.liquidationFactor + ); + expect(rsETHAssetConfig.supplyCap).to.be.equal( + cometRsETHAssetInfo.supplyCap + ); + const configuratorRsETHAssetConfig = ( + await configurator.getConfiguration(comet.address) + ).assetConfigs[rsETHAssetIndex]; + expect(rsETHAssetConfig.asset).to.be.equal( + configuratorRsETHAssetConfig.asset + ); + expect(rsETHAssetConfig.decimals).to.be.equal( + configuratorRsETHAssetConfig.decimals + ); + expect(rsETHAssetConfig.borrowCollateralFactor).to.be.equal( + configuratorRsETHAssetConfig.borrowCollateralFactor + ); + expect(rsETHAssetConfig.liquidateCollateralFactor).to.be.equal( + configuratorRsETHAssetConfig.liquidateCollateralFactor + ); + expect(rsETHAssetConfig.liquidationFactor).to.be.equal( + configuratorRsETHAssetConfig.liquidationFactor + ); + expect(rsETHAssetConfig.supplyCap).to.be.equal( + configuratorRsETHAssetConfig.supplyCap + ); + + // 2. Check new Annual Supply Interest Rate Slope High + expect(exp(1, 18) / BigInt(31_536_000)).to.be.equal(await comet.supplyPerSecondInterestRateSlopeHigh()); + + // 3. Check new Annual Borrow Interest Rate Slope High + expect(exp(1.15, 18) / BigInt(31_536_000)).to.be.equal(await comet.borrowPerSecondInterestRateSlopeHigh()); + }, +}); diff --git a/deployments/mainnet/weth/relations.ts b/deployments/mainnet/weth/relations.ts index b6c6bcf85..2c5e8b038 100644 --- a/deployments/mainnet/weth/relations.ts +++ b/deployments/mainnet/weth/relations.ts @@ -14,7 +14,7 @@ export default { 'AppProxyUpgradeable': { artifact: 'contracts/ERC20.sol:ERC20', }, - UUPSProxy: { + TransparentUpgradeableProxy: { artifact: 'contracts/ERC20.sol:ERC20', delegates: { field: { From e7419e2f47cee6853e5850e10170c8769857cd99 Mon Sep 17 00:00:00 2001 From: dmitriy-woof-software Date: Mon, 1 Jul 2024 12:49:49 +0200 Subject: [PATCH 6/6] manual enact of migration --- .../mainnet/weth/migrations/1718972942_add_rseth_collateral.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts b/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts index 52bd22188..dc32ca483 100644 --- a/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts +++ b/deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts @@ -100,7 +100,7 @@ export default migration('1718972942_add_rseth_collateral', { }, async enacted(deploymentManager: DeploymentManager): Promise { - return false; + return true; }, async verify(deploymentManager: DeploymentManager) {