Skip to content

Commit

Permalink
feat: add osETH
Browse files Browse the repository at this point in the history
  • Loading branch information
EviLord032 committed Jun 3, 2024
1 parent 10a5502 commit 6c6a1b8
Showing 1 changed file with 142 additions and 35 deletions.
177 changes: 142 additions & 35 deletions deployments/mainnet/weth/migrations/1716798961_add_rseth_and_weeth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ const RSETH_PRICE_FEED_ADDRESS = '0x03c68933f7a3F76875C0bc670a58e69294cDFD01';
const WEETH_ADDRESS = '0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee';
const WEETH_PRICE_FEED_ADDRESS = '0x5c9C449BbC9a6075A2c061dF312a35fd1E05fF22';

const OSETH_ADDRESS = '0xf1C9acDc66974dFB6dEcB12aA385b9cD01190E38';
const OSETH_PRICE_FEED_ADDRESS = '0x66ac817f997Efd114EDFcccdce99F3268557B32C';

let rsETHScalingPriceFeed = '';
let weETHScalingPriceFeed = '';
let osETHScalingPriceFeed = '';
export default migration('1716798961_add_rseth_and_weeth', {
prepare: async (deploymentManager: DeploymentManager) => {
const _rsETHScalingPriceFeed = await deploymentManager.deploy(
Expand All @@ -30,8 +34,17 @@ export default migration('1716798961_add_rseth_and_weeth', {
8 // decimals
]
);
const _osETHScalingPriceFeed = await deploymentManager.deploy(
'osETH:priceFeed',
'pricefeeds/ScalingPriceFeed.sol',
[
OSETH_PRICE_FEED_ADDRESS, // osETH / ETH price feed
8 // decimals
]
);
rsETHScalingPriceFeed = _rsETHScalingPriceFeed.address;
weETHScalingPriceFeed = _weETHScalingPriceFeed.address;
osETHScalingPriceFeed = _osETHScalingPriceFeed.address;
return { };
},

Expand Down Expand Up @@ -63,6 +76,18 @@ export default migration('1716798961_add_rseth_and_weeth', {
'mainnet'
);

const osETH = await deploymentManager.existing(
'osETH',
OSETH_ADDRESS,
'mainnet',
'contracts/ERC20.sol:ERC20'
);
const osEthPricefeed = await deploymentManager.existing(
'osETH:priceFeed',
osETHScalingPriceFeed,
'mainnet'
);

const {
governor,
comet,
Expand Down Expand Up @@ -90,6 +115,16 @@ export default migration('1716798961_add_rseth_and_weeth', {
supplyCap: exp(22_500, 18),
};

const osETHAssetConfig = {
asset: osETH.address,
priceFeed: osEthPricefeed.address,
decimals: await osETH.decimals(),
borrowCollateralFactor: exp(0.80, 18),
liquidateCollateralFactor: exp(0.85, 18),
liquidationFactor: exp(0.9, 18),
supplyCap: exp(10_000, 18),
};

const mainnetActions = [
// 1. Add rsETH as asset
{
Expand All @@ -103,7 +138,13 @@ export default migration('1716798961_add_rseth_and_weeth', {
signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))',
args: [comet.address, weETHAssetConfig],
},
// 3. Set new Annual Supply Interest Rate Slope High to 100%
// 3. Add osETH as asset
{
contract: configurator,
signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))',
args: [comet.address, osETHAssetConfig],
},
// 4. Set new Annual Supply Interest Rate Slope High to 100%
{
contract: configurator,
signature: 'setSupplyPerYearInterestRateSlopeHigh(address,uint64)',
Expand All @@ -112,7 +153,7 @@ export default migration('1716798961_add_rseth_and_weeth', {
exp(1, 18) // newSupplyPerYearInterestRateSlopeHigh
],
},
// 4. Set new Annual Borrow Interest Rate Slope High to 115%
// 5. Set new Annual Borrow Interest Rate Slope High to 115%
{
contract: configurator,
signature: 'setBorrowPerYearInterestRateSlopeHigh(address,uint64)',
Expand All @@ -121,15 +162,15 @@ export default migration('1716798961_add_rseth_and_weeth', {
exp(1.15, 18) // newBorrowPerYearInterestRateSlopeHigh
],
},
// 5. Deploy and upgrade to a new version of Comet
// 6. Deploy and upgrade to a new version of Comet
{
contract: cometAdmin,
signature: 'deployAndUpgradeTo(address,address)',
args: [configurator.address, comet.address],
},
];

const description = '# Add rsETH and weETH as collaterals into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add rsETH and 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) and [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/857), [deploy market GitHub action run]() and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179) 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 adds weETH asset as collateral with corresponding configurations.\n\nThe third action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe fourth action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe fifth action deploys and upgrades Comet to a new version.\n';
const description = '# Add rsETH, weETH and osETH as collaterals into cWETHv3 on Mainnet\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to add rsETH, weETH and osETH 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), [recommendations from Gauntlet rsETH](https://www.comp.xyz/t/add-rseth-market-on-ethereum-mainnet/5118/8) and [recommendations from Gauntlet osETH](https://www.comp.xyz/t/add-oseth-as-a-collateral-on-ethereum-mainnet/5272/2).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/854), [deploy market GitHub action run]() and [forum discussion weETH](https://www.comp.xyz/t/add-weeth-market-on-ethereum/5179), [forum discussion rsETH](https://www.comp.xyz/t/add-rseth-market-on-ethereum-mainnet/5118) and [forum discussion osETH](https://www.comp.xyz/t/add-oseth-as-a-collateral-on-ethereum-mainnet/5272).\n\n\n## Proposal Actions\n\nThe first proposal action adds rsETH asset as collateral with corresponding configurations.\n\nThe second action adds weETH asset as collateral with corresponding configurations.\n\nThe third action adds osETH asset as collateral with corresponding configurations.\n\nThe fourth action sets new Annual Supply Interest Rate Slope High to 100%.\n\nThe fifth action sets new Annual Borrow Interest Rate Slope High to 115%.\n\nThe sixth action deploys and upgrades Comet to a new version.';
const txn = await deploymentManager.retry(async () =>
trace(
await governor.propose(...(await proposal(mainnetActions, description)))
Expand All @@ -150,8 +191,9 @@ export default migration('1716798961_add_rseth_and_weeth', {
async verify(deploymentManager: DeploymentManager) {
const { comet, configurator } = await deploymentManager.getContracts();

const rsETHAssetIndex = Number(await comet.numAssets()) - 2;
const weETHAssetIndex = Number(await comet.numAssets()) - 1;
const rsETHAssetIndex = Number(await comet.numAssets()) - 3;
const weETHAssetIndex = Number(await comet.numAssets()) - 2;
const osETHAssetIndex = Number(await comet.numAssets()) - 1;

const rsETH = await deploymentManager.existing(
'rsETH',
Expand All @@ -165,6 +207,12 @@ export default migration('1716798961_add_rseth_and_weeth', {
'mainnet',
'contracts/ERC20.sol:ERC20'
);
const osETH = await deploymentManager.existing(
'osETH',
OSETH_ADDRESS,
'mainnet',
'contracts/ERC20.sol:ERC20'
);

const rsETHAssetConfig = {
asset: rsETH.address,
Expand All @@ -186,7 +234,17 @@ export default migration('1716798961_add_rseth_and_weeth', {
supplyCap: exp(22_500, 18), // 22_500
};

// 1. Compare proposed asset config with Comet asset info
const osETHAssetConfig = {
asset: osETH.address,
priceFeed: osETHScalingPriceFeed,
decimals: await osETH.decimals(),
borrowCollateralFactor: exp(0.80, 18),
liquidateCollateralFactor: exp(0.85, 18),
liquidationFactor: exp(0.9, 18),
supplyCap: exp(10_000, 18), // 10_000
};

// 1. Compare rsETH asset config with Comet and Configurator asset info
const cometRsETHAssetInfo = await comet.getAssetInfoByAddress(
RSETH_ADDRESS
);
Expand All @@ -210,32 +268,6 @@ export default migration('1716798961_add_rseth_and_weeth', {
expect(rsETHAssetConfig.supplyCap).to.be.equal(
cometRsETHAssetInfo.supplyCap
);

const cometWeETHAssetInfo = await comet.getAssetInfoByAddress(
WEETH_ADDRESS
);
expect(weETHAssetIndex).to.be.equal(cometWeETHAssetInfo.offset);
expect(weETHAssetConfig.asset).to.be.equal(cometWeETHAssetInfo.asset);
expect(weETHAssetConfig.priceFeed).to.be.equal(
cometWeETHAssetInfo.priceFeed
);
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
);

// 2. Compare proposed asset config with Configurator asset config
const configuratorRsETHAssetConfig = (
await configurator.getConfiguration(comet.address)
).assetConfigs[rsETHAssetIndex];
Expand All @@ -261,6 +293,31 @@ export default migration('1716798961_add_rseth_and_weeth', {
configuratorRsETHAssetConfig.supplyCap
);

// 2. 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(weETHAssetConfig.priceFeed).to.be.equal(
cometWeETHAssetInfo.priceFeed
);
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];
Expand All @@ -286,10 +343,60 @@ export default migration('1716798961_add_rseth_and_weeth', {
configuratorWeETHAssetConfig.supplyCap
);

// 3. Check new Annual Supply Interest Rate Slope High
// 3. Compare osETH asset config with Comet and Configurator asset info
const cometOsETHAssetInfo = await comet.getAssetInfoByAddress(
OSETH_ADDRESS
);
expect(osETHAssetIndex).to.be.equal(cometOsETHAssetInfo.offset);
expect(osETHAssetConfig.asset).to.be.equal(cometOsETHAssetInfo.asset);
expect(osETHAssetConfig.priceFeed).to.be.equal(
cometOsETHAssetInfo.priceFeed
);
expect(exp(1, osETHAssetConfig.decimals)).to.be.equal(
cometOsETHAssetInfo.scale
);
expect(osETHAssetConfig.borrowCollateralFactor).to.be.equal(
cometOsETHAssetInfo.borrowCollateralFactor
);
expect(osETHAssetConfig.liquidateCollateralFactor).to.be.equal(
cometOsETHAssetInfo.liquidateCollateralFactor
);
expect(osETHAssetConfig.liquidationFactor).to.be.equal(
cometOsETHAssetInfo.liquidationFactor
);
expect(osETHAssetConfig.supplyCap).to.be.equal(
cometOsETHAssetInfo.supplyCap
);

const configuratorOsETHAssetConfig = (
await configurator.getConfiguration(comet.address)
).assetConfigs[osETHAssetIndex];
expect(osETHAssetConfig.asset).to.be.equal(
configuratorOsETHAssetConfig.asset
);
expect(osETHAssetConfig.priceFeed).to.be.equal(
configuratorOsETHAssetConfig.priceFeed
);
expect(osETHAssetConfig.decimals).to.be.equal(
configuratorOsETHAssetConfig.decimals
);
expect(osETHAssetConfig.borrowCollateralFactor).to.be.equal(
configuratorOsETHAssetConfig.borrowCollateralFactor
);
expect(osETHAssetConfig.liquidateCollateralFactor).to.be.equal(
configuratorOsETHAssetConfig.liquidateCollateralFactor
);
expect(osETHAssetConfig.liquidationFactor).to.be.equal(
configuratorOsETHAssetConfig.liquidationFactor
);
expect(osETHAssetConfig.supplyCap).to.be.equal(
configuratorOsETHAssetConfig.supplyCap
);

// 4. Check new Annual Supply Interest Rate Slope High
expect(exp(1, 18) / BigInt(31_536_000)).to.be.equal(await comet.supplyPerSecondInterestRateSlopeHigh());

// 4. Check new Annual Borrow Interest Rate Slope High
// 5. Check new Annual Borrow Interest Rate Slope High
expect(exp(1.15, 18) / BigInt(31_536_000)).to.be.equal(await comet.borrowPerSecondInterestRateSlopeHigh());
},
});

0 comments on commit 6c6a1b8

Please sign in to comment.