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

Add rswETH as collateral to WETH market on Mainnet #36

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b7fdb34
feat: custom feeds
MishaShWoof Jun 24, 2024
228b6e4
feat: add 'for example'
MishaShWoof Jun 24, 2024
36cde41
feat: add ezETH to weth mainnet
MishaShWoof Jun 25, 2024
51e63e5
feat: new pricefeeds
MishaShWoof Jul 1, 2024
2c33985
fix: rename
MishaShWoof Jul 1, 2024
20b340a
Merge branch 'main' of github.com:woof-software/comet into woof-softw…
MishaShWoof Jul 5, 2024
2971a1b
fix: correct pr link and remove deploy action mention
MishaShWoof Jul 5, 2024
df7bab0
fix: audit fixes
MishaShWoof Jul 8, 2024
2553a7d
fix: upper case fix
MishaShWoof Jul 8, 2024
d3d435a
Merge branch 'new-custom-feeds' of github.com:woof-software/comet int…
dmitriy-woof-software Jul 8, 2024
a22991a
merge main
dmitriy-woof-software Jul 8, 2024
80f08d1
fix: post audit fixes
MishaShWoof Jul 9, 2024
2ef7c83
feat: add rswETH to mainnet-weth
MishaShWoof Jul 11, 2024
36c789a
Merge branch 'woof-software/add-ezETH-to-weth-mainnet' of github.com:…
MishaShWoof Jul 11, 2024
1ffd201
fix: working migration
MishaShWoof Jul 11, 2024
7fa46d7
Merge branch 'main' of github.com:woof-software/comet into woof-softw…
MishaShWoof Aug 5, 2024
00034ba
feat: add new price feed
MishaShWoof Aug 5, 2024
8ce39b4
Merge branch 'woof-software/custom-price-feed-for-rsweth-on-mainnet' …
MishaShWoof Aug 5, 2024
b791d32
feat: update price feed
MishaShWoof Aug 5, 2024
3927bf6
Merge branch 'woof-software/add-two-new-pricefeed' of github.com:woof…
MishaShWoof Aug 5, 2024
280a617
fix: update price feed
MishaShWoof Aug 5, 2024
d23517a
fix: remove unused interface
MishaShWoof Aug 8, 2024
fa0bd06
Merge branch 'main' of github.com:woof-software/comet into woof-softw…
MishaShWoof Aug 23, 2024
e9dbb89
fix: clean up
MishaShWoof Aug 23, 2024
99dd1f3
fix: change description for the price feed
MishaShWoof Aug 23, 2024
8abb8f2
Merge branch 'main' of github.com:woof-software/comet into woof-softw…
MishaShWoof Sep 25, 2024
8fbea59
set enacted true
MishaShWoof Sep 26, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
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 RSWETH_ADDRESS = '0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0';
let newPriceFeedAddress: string;

export default migration('1722853005_add_rsweth_as_collateral', {
async prepare(deploymentManager: DeploymentManager) {
const _rswETHPriceFeed = await deploymentManager.deploy(
'rswETH:priceFeed',
'pricefeeds/RateBasedScalingPriceFeed.sol',
[
RSWETH_ADDRESS, // rswETH / ETH price feed
8, // decimals
18, // oracleDecimals
'rswETH/ETH exchange rate price feed', // description
]
);
return { rswETHPriceFeed: _rswETHPriceFeed.address };
},

async enact(deploymentManager: DeploymentManager, _, { rswETHPriceFeed }) {

const trace = deploymentManager.tracer();

const rswETH = await deploymentManager.existing(
'rswETH',
RSWETH_ADDRESS,
'mainnet',
'contracts/ERC20.sol:ERC20'
);
const rswEthPricefeed = await deploymentManager.existing(
'rswETH:priceFeed',
rswETHPriceFeed,
'mainnet'
);

newPriceFeedAddress = rswEthPricefeed.address;

const {
governor,
comet,
cometAdmin,
configurator,
} = await deploymentManager.getContracts();

const rswETHAssetConfig = {
asset: rswETH.address,
priceFeed: rswEthPricefeed.address,
decimals: await rswETH.decimals(),
borrowCollateralFactor: exp(0.80, 18),
liquidateCollateralFactor: exp(0.85, 18),
liquidationFactor: exp(0.9, 18),
supplyCap: exp(1_000, 18),
};

const mainnetActions = [
// 1. Add rswETH as asset
{
contract: configurator,
signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))',
args: [comet.address, rswETHAssetConfig],
},
// 2. Deploy and upgrade to a new version of Comet
{
contract: cometAdmin,
signature: 'deployAndUpgradeTo(address,address)',
args: [configurator.address, comet.address],
},
];

const description = '# Add rswETH as collateral into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add rswETH 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](https://www.comp.xyz/t/add-rsweth-as-collateral-to-eth-market-on-mainnet/5308/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/885) and [forum discussion](https://www.comp.xyz/t/add-rsweth-as-collateral-to-eth-market-on-mainnet/5308).\n\n\n## Proposal Actions\n\nThe first proposal action adds rswETH 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<boolean> {
return true;
},

async verify(deploymentManager: DeploymentManager) {
const { comet, configurator } = await deploymentManager.getContracts();

const rswETHAssetIndex = Number(await comet.numAssets()) - 1;

const rswETH = await deploymentManager.existing(
'rswETH',
RSWETH_ADDRESS,
'mainnet',
'contracts/ERC20.sol:ERC20'
);

const rswETHAssetConfig = {
asset: rswETH.address,
priceFeed: newPriceFeedAddress,
decimals: await rswETH.decimals(),
borrowCollateralFactor: exp(0.80, 18),
liquidateCollateralFactor: exp(0.85, 18),
liquidationFactor: exp(0.9, 18),
supplyCap: exp(1_000, 18),
};

// 1. Compare rswETH asset config with Comet and Configurator asset info
const cometRswETHAssetInfo = await comet.getAssetInfoByAddress(RSWETH_ADDRESS);
expect(rswETHAssetIndex).to.be.equal(cometRswETHAssetInfo.offset);
expect(rswETHAssetConfig.asset).to.be.equal(cometRswETHAssetInfo.asset);
expect(exp(1, rswETHAssetConfig.decimals)).to.be.equal(cometRswETHAssetInfo.scale);
expect(rswETHAssetConfig.borrowCollateralFactor).to.be.equal(cometRswETHAssetInfo.borrowCollateralFactor);
expect(rswETHAssetConfig.liquidateCollateralFactor).to.be.equal(cometRswETHAssetInfo.liquidateCollateralFactor);
expect(rswETHAssetConfig.liquidationFactor).to.be.equal(cometRswETHAssetInfo.liquidationFactor);
expect(rswETHAssetConfig.supplyCap).to.be.equal(cometRswETHAssetInfo.supplyCap);

const configuratorRswETHAssetConfig = (await configurator.getConfiguration(comet.address)).assetConfigs[rswETHAssetIndex];
expect(rswETHAssetConfig.asset).to.be.equal(configuratorRswETHAssetConfig.asset);
expect(rswETHAssetConfig.decimals).to.be.equal(configuratorRswETHAssetConfig.decimals);
expect(rswETHAssetConfig.borrowCollateralFactor).to.be.equal(configuratorRswETHAssetConfig.borrowCollateralFactor);
expect(rswETHAssetConfig.liquidateCollateralFactor).to.be.equal(configuratorRswETHAssetConfig.liquidateCollateralFactor);
expect(rswETHAssetConfig.liquidationFactor).to.be.equal(configuratorRswETHAssetConfig.liquidationFactor);
expect(rswETHAssetConfig.supplyCap).to.be.equal(configuratorRswETHAssetConfig.supplyCap);
},
});
Loading