From d940b1a775298b69571308ce80bc0aa2d4522dbf Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Thu, 12 Sep 2024 23:18:21 +0300 Subject: [PATCH 01/12] feat: add migration and type fix --- .../pricefeeds/METHExchangeRatePriceFeed.sol | 99 ++++++++++++ contracts/vendor/mantle/IRateProvider.sol | 6 + .../1726138937_add_meth_collateral.ts | 145 ++++++++++++++++++ deployments/mainnet/usdt/relations.ts | 10 +- scenario/SupplyScenario.ts | 2 +- scenario/constraints/ProposalConstraint.ts | 6 +- scenario/constraints/SupplyCapConstraint.ts | 5 +- 7 files changed, 267 insertions(+), 6 deletions(-) create mode 100644 contracts/pricefeeds/METHExchangeRatePriceFeed.sol create mode 100644 contracts/vendor/mantle/IRateProvider.sol create mode 100644 deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts diff --git a/contracts/pricefeeds/METHExchangeRatePriceFeed.sol b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol new file mode 100644 index 000000000..f8868ca9c --- /dev/null +++ b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.15; + +import "../vendor/mantle/IRateProvider.sol"; +import "../IPriceFeed.sol"; + +/** + * @title mETH Scaling price feed + * @notice A custom price feed that scales up or down the price received from an underlying Renzo mETH / ETH exchange rate price feed and returns the result + * @author Compound + */ +contract METHExchangeRatePriceFeed is IPriceFeed { + /** Custom errors **/ + error InvalidInt256(); + error BadDecimals(); + + /// @notice Version of the price feed + uint public constant VERSION = 1; + + /// @notice Description of the price feed + string public description; + + /// @notice Number of decimals for returned prices + uint8 public immutable override decimals; + + /// @notice mETH price feed where prices are fetched from + address public immutable underlyingPriceFeed; + + /// @notice Whether or not the price should be upscaled + bool internal immutable shouldUpscale; + + /// @notice The amount to upscale or downscale the price by + int256 internal immutable rescaleFactor; + + /** + * @notice Construct a new mETH scaling price feed + * @param mETHRateProvider The address of the underlying price feed to fetch prices from + * @param decimals_ The number of decimals for the returned prices + **/ + constructor(address mETHRateProvider, uint8 decimals_, string memory description_) { + underlyingPriceFeed = mETHRateProvider; + if (decimals_ > 18) revert BadDecimals(); + decimals = decimals_; + description = description_; + + uint8 mETHRateProviderDecimals = 18; + // Note: Solidity does not allow setting immutables in if/else statements + shouldUpscale = mETHRateProviderDecimals < decimals_ ? true : false; + rescaleFactor = (shouldUpscale + ? signed256(10 ** (decimals_ - mETHRateProviderDecimals)) + : signed256(10 ** (mETHRateProviderDecimals - decimals_)) + ); + } + + /** + * @notice Price for the latest round + * @return roundId Round id from the underlying price feed + * @return answer Latest price for the asset in terms of ETH + * @return startedAt Timestamp when the round was started; passed on from underlying price feed + * @return updatedAt Timestamp when the round was last updated; passed on from underlying price feed + * @return answeredInRound Round id in which the answer was computed; passed on from underlying price feed + **/ + function latestRoundData() override external view returns ( + uint80 roundId, + int256 answer, + uint256 startedAt, + uint256 updatedAt, + uint80 answeredInRound + ) { + // https://etherscan.io/address/0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f#readProxyContract#F19 + // rate = 1 mETH in ETH + uint256 rate = IRateProvider(underlyingPriceFeed).mETHToETH(1e18); + // protocol uses only the answer value. Other data fields are not provided by the underlying pricefeed and are not used in Comet protocol + return (1, scalePrice(signed256(rate)), block.timestamp, block.timestamp, 1); + } + + function signed256(uint256 n) internal pure returns (int256) { + if (n > uint256(type(int256).max)) revert InvalidInt256(); + return int256(n); + } + + function scalePrice(int256 price) internal view returns (int256) { + int256 scaledPrice; + if (shouldUpscale) { + scaledPrice = price * rescaleFactor; + } else { + scaledPrice = price / rescaleFactor; + } + return scaledPrice; + } + + /** + * @notice Price for the latest round + * @return The version of the price feed contract + **/ + function version() external pure returns (uint256) { + return VERSION; + } +} diff --git a/contracts/vendor/mantle/IRateProvider.sol b/contracts/vendor/mantle/IRateProvider.sol new file mode 100644 index 000000000..d6e994837 --- /dev/null +++ b/contracts/vendor/mantle/IRateProvider.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.15; + +interface IRateProvider { + function mETHToETH(uint256) external view returns (uint256); +} diff --git a/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts b/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts new file mode 100644 index 000000000..7093c8578 --- /dev/null +++ b/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts @@ -0,0 +1,145 @@ +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 METH_ADDRESS = '0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa'; +const METH_EXCHANGE_RATE_PROVIDER_ADDRESS = '0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f'; +let newPriceFeedAddress: string; + +export default migration('1726138937_add_meth_collateral', { + async prepare(deploymentManager: DeploymentManager) { + const _mETHToETHPriceFeed = await deploymentManager.deploy( + 'mETH:priceFeedToETH', + 'pricefeeds/METHExchangeRatePriceFeed.sol', + [ + METH_EXCHANGE_RATE_PROVIDER_ADDRESS, // mETH / ETH price feed + 8, // decimals + 'mETH/ETH exchange rate', // description + ] + ); + const ethToUSDPriceFeed = await deploymentManager.fromDep('WETH:priceFeed', 'mainnet', 'usdt'); + + const _mETHPriceFeed = await deploymentManager.deploy( + 'mETH:priceFeed', + 'pricefeeds/MultiplicativePriceFeed.sol', + [ + _mETHToETHPriceFeed.address, // mETH / ETH price feed + ethToUSDPriceFeed.address, // ETH / USD price feed + 8, // decimals + 'wstETH / ETH price feed' // description + ] + ); + return { mETHPriceFeedAddress: _mETHPriceFeed.address }; + }, + + async enact(deploymentManager: DeploymentManager, _, { mETHPriceFeedAddress }) { + + const trace = deploymentManager.tracer(); + + const mETH = await deploymentManager.existing( + 'mETH', + METH_ADDRESS, + 'mainnet', + 'contracts/ERC20.sol:ERC20' + ); + const mEthPriceFeed = await deploymentManager.existing( + 'mETH:priceFeed', + mETHPriceFeedAddress, + 'mainnet' + ); + + newPriceFeedAddress = mEthPriceFeed.address; + + const { + governor, + comet, + cometAdmin, + configurator, + } = await deploymentManager.getContracts(); + + const mETHAssetConfig = { + asset: mETH.address, + priceFeed: mEthPriceFeed.address, + decimals: await mETH.decimals(), + borrowCollateralFactor: exp(0.8, 18), + liquidateCollateralFactor: exp(0.85, 18), + liquidationFactor: exp(0.95, 18), + supplyCap: exp(4000, 18), + }; + + const mainnetActions = [ + // 1. Add mETH as asset + { + contract: configurator, + signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))', + args: [comet.address, mETHAssetConfig], + }, + // 2. Deploy and upgrade to a new version of Comet + { + contract: cometAdmin, + signature: 'deployAndUpgradeTo(address,address)', + args: [configurator.address, comet.address], + }, + ]; + + const description = '# Add mETH as collateral into cUSDTv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add mETH into cUSDTv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III USDT 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](https://www.comp.xyz/t/add-meth-market-on-ethereum/5647/5).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/917) and [forum discussion](https://www.comp.xyz/t/add-meth-market-on-ethereum/5647).\n\n\n## Proposal Actions\n\nThe first action adds mETH asset as collateral with corresponding configurations.\n\nThe second 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(): Promise { + return false; + }, + + async verify(deploymentManager: DeploymentManager) { + const { comet, configurator } = await deploymentManager.getContracts(); + + const mETHAssetIndex = Number(await comet.numAssets()) - 1; + + const mETH = await deploymentManager.existing( + 'mETH', + METH_ADDRESS, + 'mainnet', + 'contracts/ERC20.sol:ERC20' + ); + const mETHAssetConfig = { + asset: mETH.address, + priceFeed: newPriceFeedAddress, + decimals: await mETH.decimals(), + borrowCollateralFactor: exp(0.8, 18), + liquidateCollateralFactor: exp(0.85, 18), + liquidationFactor: exp(0.95, 18), + supplyCap: exp(4000, 18), + }; + + // 1. Compare mETH asset config with Comet and Configurator asset info + const cometMETHAssetInfo = await comet.getAssetInfoByAddress(METH_ADDRESS); + expect(mETHAssetIndex).to.be.equal(cometMETHAssetInfo.offset); + expect(mETHAssetConfig.asset).to.be.equal(cometMETHAssetInfo.asset); + expect(mETHAssetConfig.priceFeed).to.be.equal(cometMETHAssetInfo.priceFeed); + expect(exp(1, mETHAssetConfig.decimals)).to.be.equal(cometMETHAssetInfo.scale); + expect(mETHAssetConfig.borrowCollateralFactor).to.be.equal(cometMETHAssetInfo.borrowCollateralFactor); + expect(mETHAssetConfig.liquidateCollateralFactor).to.be.equal(cometMETHAssetInfo.liquidateCollateralFactor); + expect(mETHAssetConfig.liquidationFactor).to.be.equal(cometMETHAssetInfo.liquidationFactor); + expect(mETHAssetConfig.supplyCap).to.be.equal(cometMETHAssetInfo.supplyCap); + + const configuratorMETHAssetConfig = (await configurator.getConfiguration(comet.address)).assetConfigs[mETHAssetIndex]; + expect(mETHAssetConfig.asset).to.be.equal(configuratorMETHAssetConfig.asset); + expect(mETHAssetConfig.priceFeed).to.be.equal(configuratorMETHAssetConfig.priceFeed); + expect(mETHAssetConfig.decimals).to.be.equal(configuratorMETHAssetConfig.decimals); + expect(mETHAssetConfig.borrowCollateralFactor).to.be.equal(configuratorMETHAssetConfig.borrowCollateralFactor); + expect(mETHAssetConfig.liquidateCollateralFactor).to.be.equal(configuratorMETHAssetConfig.liquidateCollateralFactor); + expect(mETHAssetConfig.liquidationFactor).to.be.equal(configuratorMETHAssetConfig.liquidationFactor); + expect(mETHAssetConfig.supplyCap).to.be.equal(configuratorMETHAssetConfig.supplyCap); + }, +}); diff --git a/deployments/mainnet/usdt/relations.ts b/deployments/mainnet/usdt/relations.ts index 7d7c02b2a..59fabbc80 100644 --- a/deployments/mainnet/usdt/relations.ts +++ b/deployments/mainnet/usdt/relations.ts @@ -19,5 +19,13 @@ export default { }, 'AppProxyUpgradeable': { artifact: 'contracts/ERC20.sol:ERC20', - } + }, + 'TransparentUpgradeableProxy': { + artifact: 'contracts/ERC20.sol:ERC20', + delegates: { + field: { + slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' + } + } + }, }; \ No newline at end of file diff --git a/scenario/SupplyScenario.ts b/scenario/SupplyScenario.ts index f9075208b..7082f87a6 100644 --- a/scenario/SupplyScenario.ts +++ b/scenario/SupplyScenario.ts @@ -300,7 +300,7 @@ scenario( const utilization = await comet.getUtilization(); const borrowRate = (await comet.getBorrowRate(utilization)).toBigInt(); - expectApproximately(await albert.getCometBaseBalance(), -999n * scale, getInterest(999n * scale, borrowRate, 1n) + 1n); + expectApproximately(await albert.getCometBaseBalance(), -999n * scale, getInterest(999n * scale, borrowRate, 1n) + 2n); // Albert repays 1000 units of base borrow await baseAsset.approve(albert, comet.address); diff --git a/scenario/constraints/ProposalConstraint.ts b/scenario/constraints/ProposalConstraint.ts index f1b9fa204..36d792478 100644 --- a/scenario/constraints/ProposalConstraint.ts +++ b/scenario/constraints/ProposalConstraint.ts @@ -62,9 +62,9 @@ export class ProposalConstraint implements StaticConstra ); } - // temporary hack to skip proposal 281 - if (proposal.id.eq(281)) { - console.log('Skipping proposal 281'); + // temporary hack to skip proposal 329 + if (proposal.id.eq(329)) { + console.log('Skipping proposal 329'); continue; } diff --git a/scenario/constraints/SupplyCapConstraint.ts b/scenario/constraints/SupplyCapConstraint.ts index 8a71312af..1842b73f0 100644 --- a/scenario/constraints/SupplyCapConstraint.ts +++ b/scenario/constraints/SupplyCapConstraint.ts @@ -7,7 +7,10 @@ import { ComparisonOp, getAssetFromName, parseAmount } from '../utils'; export class SupplyCapConstraint implements Constraint { async solve(requirements: R, _initialContext: T) { - const supplyCaps = requirements.supplyCaps; + let supplyCaps = requirements.supplyCaps; + if (typeof supplyCaps === 'function') { + supplyCaps = await supplyCaps(_initialContext); + } if (supplyCaps !== undefined) { const solutions: Solution[] = []; solutions.push(async function barelyMeet(context: T) { From fe9a21cda48ca81cff67e040df1f90c1ed0bf7ec Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 13 Sep 2024 11:03:34 +0300 Subject: [PATCH 02/12] fix: update pr link --- .../mainnet/usdt/migrations/1726138937_add_meth_collateral.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts b/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts index 7093c8578..692359fe6 100644 --- a/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts +++ b/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts @@ -83,7 +83,7 @@ export default migration('1726138937_add_meth_collateral', { }, ]; - const description = '# Add mETH as collateral into cUSDTv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add mETH into cUSDTv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III USDT 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](https://www.comp.xyz/t/add-meth-market-on-ethereum/5647/5).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/917) and [forum discussion](https://www.comp.xyz/t/add-meth-market-on-ethereum/5647).\n\n\n## Proposal Actions\n\nThe first action adds mETH asset as collateral with corresponding configurations.\n\nThe second action deploys and upgrades Comet to a new version.'; + const description = '# Add mETH as collateral into cUSDTv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add mETH into cUSDTv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III USDT 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](https://www.comp.xyz/t/add-meth-market-on-ethereum/5647/5).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/918) and [forum discussion](https://www.comp.xyz/t/add-meth-market-on-ethereum/5647).\n\n\n## Proposal Actions\n\nThe first action adds mETH asset as collateral with corresponding configurations.\n\nThe second action deploys and upgrades Comet to a new version.'; const txn = await deploymentManager.retry(async () => trace( await governor.propose(...(await proposal(mainnetActions, description))) From 69f9891c93d54d3f714cf14963b0b6329fefbb2b Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 13 Sep 2024 15:22:04 +0300 Subject: [PATCH 03/12] fix: working workflow --- .github/workflows/deploy-market.yaml | 2 +- .github/workflows/prepare-migration.yaml | 2 +- .github/workflows/run-scenarios.yaml | 2 +- .github/workflows/run-unit-tests.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-market.yaml b/.github/workflows/deploy-market.yaml index 5de6eb684..eb1b1d90b 100644 --- a/.github/workflows/deploy-market.yaml +++ b/.github/workflows/deploy-market.yaml @@ -77,7 +77,7 @@ jobs: NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8585"]')[github.event.inputs.eth_pk == ''] }} REMOTE_ACCOUNTS: ${{ fromJSON('["", "true"]')[github.event.inputs.eth_pk == ''] }} - - uses: actions/upload-artifact@v2 # upload test results + - uses: actions/upload-artifact@v4 # upload test results if: success() || failure() # run this step even if previous step failed with: name: ${{ github.event.inputs.network }}-${{ github.event.inputs.deployment }}-verify-args diff --git a/.github/workflows/prepare-migration.yaml b/.github/workflows/prepare-migration.yaml index c27bc569e..1bbaa6646 100644 --- a/.github/workflows/prepare-migration.yaml +++ b/.github/workflows/prepare-migration.yaml @@ -77,7 +77,7 @@ jobs: NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8585"]')[github.event.inputs.eth_pk == ''] }} REMOTE_ACCOUNTS: ${{ fromJSON('["", "true"]')[github.event.inputs.eth_pk == ''] }} - - uses: actions/upload-artifact@v2 # upload test results + - uses: actions/upload-artifact@v4 # upload test results if: success() || failure() # run this step even if previous step failed with: name: ${{ github.event.inputs.network }}-${{ github.event.inputs.deployment }}-${{ github.event.inputs.migration }} diff --git a/.github/workflows/run-scenarios.yaml b/.github/workflows/run-scenarios.yaml index 0fecdd98c..6ae46e623 100644 --- a/.github/workflows/run-scenarios.yaml +++ b/.github/workflows/run-scenarios.yaml @@ -54,7 +54,7 @@ jobs: - name: Run scenarios run: yarn scenario --bases ${{ matrix.bases }} - - uses: actions/upload-artifact@v2 # upload scenario results + - uses: actions/upload-artifact@v4 # upload scenario results if: success() || failure() # run this step even if previous step failed with: name: scenario-results diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index d198e156e..849ae43b8 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -34,7 +34,7 @@ jobs: - name: Run tests run: yarn test - - uses: actions/upload-artifact@v2 # upload test results + - uses: actions/upload-artifact@v4 # upload test results if: success() || failure() # run this step even if previous step failed with: name: test-results From 9ce23e4b02a80be0ce713a131fc4b8e94c087dc1 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 13 Sep 2024 15:27:28 +0300 Subject: [PATCH 04/12] fix: additional workflow fixes --- .github/workflows/deploy-market.yaml | 4 ++-- .github/workflows/enact-migration.yaml | 4 ++-- .github/workflows/prepare-migration.yaml | 4 ++-- .github/workflows/run-contract-linter.yaml | 4 ++-- .github/workflows/run-coverage.yaml | 4 ++-- .github/workflows/run-eslint.yaml | 4 ++-- .github/workflows/run-forge-tests.yaml | 2 +- .github/workflows/run-gas-profiler.yaml | 4 ++-- .github/workflows/run-scenarios.yaml | 6 +++--- .github/workflows/run-semgrep.yaml | 6 +++--- .github/workflows/run-slither.yaml | 4 ++-- .github/workflows/run-unit-tests.yaml | 4 ++-- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/deploy-market.yaml b/.github/workflows/deploy-market.yaml index eb1b1d90b..fe6e35024 100644 --- a/.github/workflows/deploy-market.yaml +++ b/.github/workflows/deploy-market.yaml @@ -53,9 +53,9 @@ jobs: if: github.event.inputs.eth_pk == '' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/enact-migration.yaml b/.github/workflows/enact-migration.yaml index f3a5e4524..b3202dbed 100644 --- a/.github/workflows/enact-migration.yaml +++ b/.github/workflows/enact-migration.yaml @@ -85,9 +85,9 @@ jobs: if: github.event.inputs.eth_pk == '' && env.GOV_NETWORK != '' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/prepare-migration.yaml b/.github/workflows/prepare-migration.yaml index 1bbaa6646..9d6206a18 100644 --- a/.github/workflows/prepare-migration.yaml +++ b/.github/workflows/prepare-migration.yaml @@ -53,9 +53,9 @@ jobs: if: github.event.inputs.eth_pk == '' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-contract-linter.yaml b/.github/workflows/run-contract-linter.yaml index b027b58fb..2513cc18c 100644 --- a/.github/workflows/run-contract-linter.yaml +++ b/.github/workflows/run-contract-linter.yaml @@ -15,11 +15,11 @@ jobs: LINEASCAN_KEY: ${{ secrets.LINEASCAN_KEY }} OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-coverage.yaml b/.github/workflows/run-coverage.yaml index e2272a9d5..b28829b56 100644 --- a/.github/workflows/run-coverage.yaml +++ b/.github/workflows/run-coverage.yaml @@ -18,9 +18,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: cache: 'yarn' node-version: '16' diff --git a/.github/workflows/run-eslint.yaml b/.github/workflows/run-eslint.yaml index 9763d45d4..1961fec4c 100644 --- a/.github/workflows/run-eslint.yaml +++ b/.github/workflows/run-eslint.yaml @@ -16,9 +16,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: cache: 'yarn' node-version: '16' diff --git a/.github/workflows/run-forge-tests.yaml b/.github/workflows/run-forge-tests.yaml index 069a30bdb..6a10f7523 100644 --- a/.github/workflows/run-forge-tests.yaml +++ b/.github/workflows/run-forge-tests.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/run-gas-profiler.yaml b/.github/workflows/run-gas-profiler.yaml index d2418ad42..d49ba9152 100644 --- a/.github/workflows/run-gas-profiler.yaml +++ b/.github/workflows/run-gas-profiler.yaml @@ -17,9 +17,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-scenarios.yaml b/.github/workflows/run-scenarios.yaml index 6ae46e623..b651c8880 100644 --- a/.github/workflows/run-scenarios.yaml +++ b/.github/workflows/run-scenarios.yaml @@ -22,17 +22,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: cache: 'yarn' node-version: '16' - name: Cache Deployments - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | deployments/*/.contracts diff --git a/.github/workflows/run-semgrep.yaml b/.github/workflows/run-semgrep.yaml index dad4eb51a..ec9237e4e 100644 --- a/.github/workflows/run-semgrep.yaml +++ b/.github/workflows/run-semgrep.yaml @@ -28,16 +28,16 @@ jobs: steps: # Fetch project source with GitHub Actions Checkout. - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Fetch generic rules - name: Fetch generic semgrep rules - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: decurity/semgrep-smart-contracts path: rules # Fetch Compound rules - name: Fetch Compound semgrep rules - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: decurity/compound-semgrep-rules path: compound diff --git a/.github/workflows/run-slither.yaml b/.github/workflows/run-slither.yaml index 3c80df49e..2ca5a871d 100644 --- a/.github/workflows/run-slither.yaml +++ b/.github/workflows/run-slither.yaml @@ -8,9 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index 849ae43b8..49779a40f 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -16,9 +16,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' From 91b09ebcfdbe96184de262c9fbe28393bacde647 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 13 Sep 2024 16:28:06 +0300 Subject: [PATCH 05/12] fix: final fix to workflow --- .github/workflows/run-scenarios.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run-scenarios.yaml b/.github/workflows/run-scenarios.yaml index b651c8880..c2b7adcce 100644 --- a/.github/workflows/run-scenarios.yaml +++ b/.github/workflows/run-scenarios.yaml @@ -57,7 +57,7 @@ jobs: - uses: actions/upload-artifact@v4 # upload scenario results if: success() || failure() # run this step even if previous step failed with: - name: scenario-results + name: scenario-results-${{ matrix.bases }} path: scenario-results.json - uses: dorny/test-reporter@v1 From 51d804b5cbe09bdd9dace16780e40470d31f60a7 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 13 Sep 2024 17:06:41 +0300 Subject: [PATCH 06/12] fix: relations --- deployments/optimism/weth/relations.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/deployments/optimism/weth/relations.ts b/deployments/optimism/weth/relations.ts index e88708f5d..45457356a 100644 --- a/deployments/optimism/weth/relations.ts +++ b/deployments/optimism/weth/relations.ts @@ -56,14 +56,4 @@ export default { WBTC: { artifact: 'contracts/ERC20.sol:ERC20' }, - - // weETH - TransparentUpgradeableProxy: { - artifact: 'contracts/ERC20.sol:ERC20', - delegates: { - field: { - slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' - } - } - }, }; From 8e8749a7f13e72534b40e6506a68214ea2e9a48b Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 13 Sep 2024 17:51:53 +0300 Subject: [PATCH 07/12] update versions and fix one relation --- .github/workflows/deploy-market.yaml | 6 +++--- .github/workflows/enact-migration.yaml | 6 +++--- .github/workflows/prepare-migration.yaml | 6 +++--- .github/workflows/run-contract-linter.yaml | 4 ++-- .github/workflows/run-coverage.yaml | 4 ++-- .github/workflows/run-eslint.yaml | 4 ++-- .github/workflows/run-forge-tests.yaml | 2 +- .github/workflows/run-gas-profiler.yaml | 4 ++-- .github/workflows/run-scenarios.yaml | 10 +++++----- .github/workflows/run-slither.yaml | 4 ++-- .github/workflows/run-unit-tests.yaml | 6 +++--- deployments/optimism/weth/relations.ts | 10 ---------- 12 files changed, 28 insertions(+), 38 deletions(-) diff --git a/.github/workflows/deploy-market.yaml b/.github/workflows/deploy-market.yaml index 5de6eb684..fe6e35024 100644 --- a/.github/workflows/deploy-market.yaml +++ b/.github/workflows/deploy-market.yaml @@ -53,9 +53,9 @@ jobs: if: github.event.inputs.eth_pk == '' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' @@ -77,7 +77,7 @@ jobs: NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8585"]')[github.event.inputs.eth_pk == ''] }} REMOTE_ACCOUNTS: ${{ fromJSON('["", "true"]')[github.event.inputs.eth_pk == ''] }} - - uses: actions/upload-artifact@v2 # upload test results + - uses: actions/upload-artifact@v4 # upload test results if: success() || failure() # run this step even if previous step failed with: name: ${{ github.event.inputs.network }}-${{ github.event.inputs.deployment }}-verify-args diff --git a/.github/workflows/enact-migration.yaml b/.github/workflows/enact-migration.yaml index f3a5e4524..cf1310a8f 100644 --- a/.github/workflows/enact-migration.yaml +++ b/.github/workflows/enact-migration.yaml @@ -85,9 +85,9 @@ jobs: if: github.event.inputs.eth_pk == '' && env.GOV_NETWORK != '' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' @@ -100,7 +100,7 @@ jobs: - name: Check types run: yarn tsc - - uses: dawidd6/action-download-artifact@v2 + - uses: dawidd6/action-download-artifact@v4 with: workflow: prepare-migration.yml run_id: ${{ github.event.inputs.run_id }} diff --git a/.github/workflows/prepare-migration.yaml b/.github/workflows/prepare-migration.yaml index c27bc569e..9d6206a18 100644 --- a/.github/workflows/prepare-migration.yaml +++ b/.github/workflows/prepare-migration.yaml @@ -53,9 +53,9 @@ jobs: if: github.event.inputs.eth_pk == '' - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' @@ -77,7 +77,7 @@ jobs: NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8585"]')[github.event.inputs.eth_pk == ''] }} REMOTE_ACCOUNTS: ${{ fromJSON('["", "true"]')[github.event.inputs.eth_pk == ''] }} - - uses: actions/upload-artifact@v2 # upload test results + - uses: actions/upload-artifact@v4 # upload test results if: success() || failure() # run this step even if previous step failed with: name: ${{ github.event.inputs.network }}-${{ github.event.inputs.deployment }}-${{ github.event.inputs.migration }} diff --git a/.github/workflows/run-contract-linter.yaml b/.github/workflows/run-contract-linter.yaml index b027b58fb..2513cc18c 100644 --- a/.github/workflows/run-contract-linter.yaml +++ b/.github/workflows/run-contract-linter.yaml @@ -15,11 +15,11 @@ jobs: LINEASCAN_KEY: ${{ secrets.LINEASCAN_KEY }} OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-coverage.yaml b/.github/workflows/run-coverage.yaml index e2272a9d5..b28829b56 100644 --- a/.github/workflows/run-coverage.yaml +++ b/.github/workflows/run-coverage.yaml @@ -18,9 +18,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: cache: 'yarn' node-version: '16' diff --git a/.github/workflows/run-eslint.yaml b/.github/workflows/run-eslint.yaml index 9763d45d4..1961fec4c 100644 --- a/.github/workflows/run-eslint.yaml +++ b/.github/workflows/run-eslint.yaml @@ -16,9 +16,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: cache: 'yarn' node-version: '16' diff --git a/.github/workflows/run-forge-tests.yaml b/.github/workflows/run-forge-tests.yaml index 069a30bdb..6a10f7523 100644 --- a/.github/workflows/run-forge-tests.yaml +++ b/.github/workflows/run-forge-tests.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/run-gas-profiler.yaml b/.github/workflows/run-gas-profiler.yaml index d2418ad42..d49ba9152 100644 --- a/.github/workflows/run-gas-profiler.yaml +++ b/.github/workflows/run-gas-profiler.yaml @@ -17,9 +17,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-scenarios.yaml b/.github/workflows/run-scenarios.yaml index 0fecdd98c..c2b7adcce 100644 --- a/.github/workflows/run-scenarios.yaml +++ b/.github/workflows/run-scenarios.yaml @@ -22,17 +22,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: cache: 'yarn' node-version: '16' - name: Cache Deployments - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: | deployments/*/.contracts @@ -54,10 +54,10 @@ jobs: - name: Run scenarios run: yarn scenario --bases ${{ matrix.bases }} - - uses: actions/upload-artifact@v2 # upload scenario results + - uses: actions/upload-artifact@v4 # upload scenario results if: success() || failure() # run this step even if previous step failed with: - name: scenario-results + name: scenario-results-${{ matrix.bases }} path: scenario-results.json - uses: dorny/test-reporter@v1 diff --git a/.github/workflows/run-slither.yaml b/.github/workflows/run-slither.yaml index 3c80df49e..2ca5a871d 100644 --- a/.github/workflows/run-slither.yaml +++ b/.github/workflows/run-slither.yaml @@ -8,9 +8,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' diff --git a/.github/workflows/run-unit-tests.yaml b/.github/workflows/run-unit-tests.yaml index d198e156e..49779a40f 100644 --- a/.github/workflows/run-unit-tests.yaml +++ b/.github/workflows/run-unit-tests.yaml @@ -16,9 +16,9 @@ jobs: OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }} steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-node@v2 + - uses: actions/setup-node@v4 with: node-version: '16' @@ -34,7 +34,7 @@ jobs: - name: Run tests run: yarn test - - uses: actions/upload-artifact@v2 # upload test results + - uses: actions/upload-artifact@v4 # upload test results if: success() || failure() # run this step even if previous step failed with: name: test-results diff --git a/deployments/optimism/weth/relations.ts b/deployments/optimism/weth/relations.ts index e88708f5d..45457356a 100644 --- a/deployments/optimism/weth/relations.ts +++ b/deployments/optimism/weth/relations.ts @@ -56,14 +56,4 @@ export default { WBTC: { artifact: 'contracts/ERC20.sol:ERC20' }, - - // weETH - TransparentUpgradeableProxy: { - artifact: 'contracts/ERC20.sol:ERC20', - delegates: { - field: { - slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' - } - } - }, }; From 279e0345ab8572e7a88dc718ec492794d310bd1f Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Thu, 26 Sep 2024 13:28:01 +0300 Subject: [PATCH 08/12] feat: contracts --- .../pricefeeds/METHExchangeRatePriceFeed.sol | 99 +++++++++++++++++++ contracts/vendor/mantle/IRateProvider.sol | 6 ++ 2 files changed, 105 insertions(+) create mode 100644 contracts/pricefeeds/METHExchangeRatePriceFeed.sol create mode 100644 contracts/vendor/mantle/IRateProvider.sol diff --git a/contracts/pricefeeds/METHExchangeRatePriceFeed.sol b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol new file mode 100644 index 000000000..f8868ca9c --- /dev/null +++ b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.15; + +import "../vendor/mantle/IRateProvider.sol"; +import "../IPriceFeed.sol"; + +/** + * @title mETH Scaling price feed + * @notice A custom price feed that scales up or down the price received from an underlying Renzo mETH / ETH exchange rate price feed and returns the result + * @author Compound + */ +contract METHExchangeRatePriceFeed is IPriceFeed { + /** Custom errors **/ + error InvalidInt256(); + error BadDecimals(); + + /// @notice Version of the price feed + uint public constant VERSION = 1; + + /// @notice Description of the price feed + string public description; + + /// @notice Number of decimals for returned prices + uint8 public immutable override decimals; + + /// @notice mETH price feed where prices are fetched from + address public immutable underlyingPriceFeed; + + /// @notice Whether or not the price should be upscaled + bool internal immutable shouldUpscale; + + /// @notice The amount to upscale or downscale the price by + int256 internal immutable rescaleFactor; + + /** + * @notice Construct a new mETH scaling price feed + * @param mETHRateProvider The address of the underlying price feed to fetch prices from + * @param decimals_ The number of decimals for the returned prices + **/ + constructor(address mETHRateProvider, uint8 decimals_, string memory description_) { + underlyingPriceFeed = mETHRateProvider; + if (decimals_ > 18) revert BadDecimals(); + decimals = decimals_; + description = description_; + + uint8 mETHRateProviderDecimals = 18; + // Note: Solidity does not allow setting immutables in if/else statements + shouldUpscale = mETHRateProviderDecimals < decimals_ ? true : false; + rescaleFactor = (shouldUpscale + ? signed256(10 ** (decimals_ - mETHRateProviderDecimals)) + : signed256(10 ** (mETHRateProviderDecimals - decimals_)) + ); + } + + /** + * @notice Price for the latest round + * @return roundId Round id from the underlying price feed + * @return answer Latest price for the asset in terms of ETH + * @return startedAt Timestamp when the round was started; passed on from underlying price feed + * @return updatedAt Timestamp when the round was last updated; passed on from underlying price feed + * @return answeredInRound Round id in which the answer was computed; passed on from underlying price feed + **/ + function latestRoundData() override external view returns ( + uint80 roundId, + int256 answer, + uint256 startedAt, + uint256 updatedAt, + uint80 answeredInRound + ) { + // https://etherscan.io/address/0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f#readProxyContract#F19 + // rate = 1 mETH in ETH + uint256 rate = IRateProvider(underlyingPriceFeed).mETHToETH(1e18); + // protocol uses only the answer value. Other data fields are not provided by the underlying pricefeed and are not used in Comet protocol + return (1, scalePrice(signed256(rate)), block.timestamp, block.timestamp, 1); + } + + function signed256(uint256 n) internal pure returns (int256) { + if (n > uint256(type(int256).max)) revert InvalidInt256(); + return int256(n); + } + + function scalePrice(int256 price) internal view returns (int256) { + int256 scaledPrice; + if (shouldUpscale) { + scaledPrice = price * rescaleFactor; + } else { + scaledPrice = price / rescaleFactor; + } + return scaledPrice; + } + + /** + * @notice Price for the latest round + * @return The version of the price feed contract + **/ + function version() external pure returns (uint256) { + return VERSION; + } +} diff --git a/contracts/vendor/mantle/IRateProvider.sol b/contracts/vendor/mantle/IRateProvider.sol new file mode 100644 index 000000000..d6e994837 --- /dev/null +++ b/contracts/vendor/mantle/IRateProvider.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity 0.8.15; + +interface IRateProvider { + function mETHToETH(uint256) external view returns (uint256); +} From 3cff00db694b92dfe34cf68a35baa854288cbde3 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Tue, 12 Nov 2024 17:17:14 +0200 Subject: [PATCH 09/12] fix: audit --- contracts/pricefeeds/METHExchangeRatePriceFeed.sol | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/contracts/pricefeeds/METHExchangeRatePriceFeed.sol b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol index f8868ca9c..61b264aff 100644 --- a/contracts/pricefeeds/METHExchangeRatePriceFeed.sol +++ b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol @@ -15,7 +15,7 @@ contract METHExchangeRatePriceFeed is IPriceFeed { error BadDecimals(); /// @notice Version of the price feed - uint public constant VERSION = 1; + uint internal constant VERSION = 1; /// @notice Description of the price feed string public description; @@ -67,7 +67,6 @@ contract METHExchangeRatePriceFeed is IPriceFeed { uint256 updatedAt, uint80 answeredInRound ) { - // https://etherscan.io/address/0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f#readProxyContract#F19 // rate = 1 mETH in ETH uint256 rate = IRateProvider(underlyingPriceFeed).mETHToETH(1e18); // protocol uses only the answer value. Other data fields are not provided by the underlying pricefeed and are not used in Comet protocol @@ -90,7 +89,7 @@ contract METHExchangeRatePriceFeed is IPriceFeed { } /** - * @notice Price for the latest round + * @notice Get the version of the price feed contract * @return The version of the price feed contract **/ function version() external pure returns (uint256) { From 4d8684f5e282485e15ba2d37dd246bb0291d717e Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Tue, 12 Nov 2024 18:13:53 +0200 Subject: [PATCH 10/12] fix: update --- deployments/mainnet/usdt/relations.ts | 8 ++++++++ deployments/relations.ts | 9 ++++++++- scenario/SupplyScenario.ts | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/deployments/mainnet/usdt/relations.ts b/deployments/mainnet/usdt/relations.ts index 59fabbc80..a695b4b3a 100644 --- a/deployments/mainnet/usdt/relations.ts +++ b/deployments/mainnet/usdt/relations.ts @@ -21,6 +21,14 @@ export default { artifact: 'contracts/ERC20.sol:ERC20', }, 'TransparentUpgradeableProxy': { + artifact: 'contracts/ERC20.sol:ERC20', + delegates: { + field: { + slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' + } + }, + }, + 'ERC1967Proxy': { artifact: 'contracts/ERC20.sol:ERC20', delegates: { field: { diff --git a/deployments/relations.ts b/deployments/relations.ts index f0ea7c6ca..de0b1d381 100644 --- a/deployments/relations.ts +++ b/deployments/relations.ts @@ -31,7 +31,14 @@ const relationConfigMap: RelationConfigMap = { }) ); }, - alias: async (token) => token.symbol(), + alias: async (token) =>{ + try { + return token.symbol(); + } + catch (e) { + throw new Error(`failed to get symbol for token ${token.address} with error: ${e}`); + } + }, }, assetPriceFeeds: { field: async (comet) => { diff --git a/scenario/SupplyScenario.ts b/scenario/SupplyScenario.ts index 7082f87a6..a1b012390 100644 --- a/scenario/SupplyScenario.ts +++ b/scenario/SupplyScenario.ts @@ -300,7 +300,7 @@ scenario( const utilization = await comet.getUtilization(); const borrowRate = (await comet.getBorrowRate(utilization)).toBigInt(); - expectApproximately(await albert.getCometBaseBalance(), -999n * scale, getInterest(999n * scale, borrowRate, 1n) + 2n); + expectApproximately(await albert.getCometBaseBalance(), -999n * scale, getInterest(999n * scale, borrowRate, 4n) + 2n); // Albert repays 1000 units of base borrow await baseAsset.approve(albert, comet.address); From 05bc49c0d8a8aa687536752016835683a777e3d0 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Wed, 13 Nov 2024 10:51:02 +0200 Subject: [PATCH 11/12] fix: comment fix --- contracts/pricefeeds/METHExchangeRatePriceFeed.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/pricefeeds/METHExchangeRatePriceFeed.sol b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol index 61b264aff..b97f475d6 100644 --- a/contracts/pricefeeds/METHExchangeRatePriceFeed.sol +++ b/contracts/pricefeeds/METHExchangeRatePriceFeed.sol @@ -6,7 +6,7 @@ import "../IPriceFeed.sol"; /** * @title mETH Scaling price feed - * @notice A custom price feed that scales up or down the price received from an underlying Renzo mETH / ETH exchange rate price feed and returns the result + * @notice A custom price feed that scales up or down the price received from an underlying Mantle mETH / ETH exchange rate price feed and returns the result * @author Compound */ contract METHExchangeRatePriceFeed is IPriceFeed { From 5c21c7f5808b7f2c42840fb33381b4d35107f503 Mon Sep 17 00:00:00 2001 From: Dmitriy Babenko <159453675+dmitriy-woof-software@users.noreply.github.com> Date: Tue, 26 Nov 2024 13:33:55 -0600 Subject: [PATCH 12/12] Update 1726138937_add_meth_collateral.ts --- .../usdt/migrations/1726138937_add_meth_collateral.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts b/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts index 692359fe6..46f449f36 100644 --- a/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts +++ b/deployments/mainnet/usdt/migrations/1726138937_add_meth_collateral.ts @@ -16,7 +16,8 @@ export default migration('1726138937_add_meth_collateral', { METH_EXCHANGE_RATE_PROVIDER_ADDRESS, // mETH / ETH price feed 8, // decimals 'mETH/ETH exchange rate', // description - ] + ], + true ); const ethToUSDPriceFeed = await deploymentManager.fromDep('WETH:priceFeed', 'mainnet', 'usdt'); @@ -27,8 +28,9 @@ export default migration('1726138937_add_meth_collateral', { _mETHToETHPriceFeed.address, // mETH / ETH price feed ethToUSDPriceFeed.address, // ETH / USD price feed 8, // decimals - 'wstETH / ETH price feed' // description - ] + 'mETH / USD price feed' // description + ], + true ); return { mETHPriceFeedAddress: _mETHPriceFeed.address }; },