Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On-chain add rsETH collateral into WETH Mainnet market #870

Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/enact-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down
177 changes: 177 additions & 0 deletions deployments/mainnet/weth/migrations/1718972942_add_rseth_collateral.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
return true;
},

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());
},
});
10 changes: 9 additions & 1 deletion deployments/mainnet/weth/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@ export default {
},
'AppProxyUpgradeable': {
artifact: 'contracts/ERC20.sol:ERC20',
}
},
TransparentUpgradeableProxy: {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
};
2 changes: 1 addition & 1 deletion scenario/LiquidationBotScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ scenario(
const assetAmounts = {
mainnet: {
usdc: ' == 5000', // COMP
weth: ' == 10000', // CB_ETH
weth: ' == 7000', // CB_ETH
},
};

Expand Down
Loading