8000 Add sdeUSD to cUSDCv3 on Mainnet by MishaShWoof · Pull Request #163 · woof-software/comet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add sdeUSD to cUSDCv3 on Mainnet #163

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

8000
Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/enact-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ 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 != '' && github.event.inputs.with_deploy == 'false'
if: github.event.inputs.impersonateAccount != '' && github.event.inputs.with_deploy == 'false' && github.event.inputs.run_id == ''
- name: Commit changes
if: ${{ github.event.inputs.simulate == 'false' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/prepare-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
OPTIMISMSCAN_KEY: ${{ secrets.OPTIMISMSCAN_KEY }}
MANTLESCAN_KEY: ${{ secrets.MANTLESCAN_KEY }}
SCROLLSCAN_KEY: ${{ secrets.SCROLLSCAN_KEY }}
UNICHAIN_QUICKNODE_KEY: ${{ secrets.UNICHAIN_QUICKNODE_KEY }}
steps:
- name: Seacrest
uses: hayesgm/seacrest@af229b0a00b73cb6fa9940a836a62fa3b918fd77
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
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 SDEUSD_ADDRESS = '0x5C5b196aBE0d54485975D1Ec29617D42D9198326';
const DEUSD_TO_USD_PRICE_FEED = '0x471a6299C027Bd81ed4D66069dc510Bd0569f4F8';

let newPriceFeedAddress: string;

export default migration('1750166348_add_sdeusd_collateral', {
async prepare(deploymentManager: DeploymentManager) {
const sdeUSDMultiplicativePriceFeed = await deploymentManager.deploy(
'sdeUSD:priceFeed',
'pricefeeds/PriceFeedWith4626Support.sol',
[
SDEUSD_ADDRESS, // sdeUSD / deUSD price f 10000 eed
DEUSD_TO_USD_PRICE_FEED, // deUSD / USD price feed
8, // decimals
'sdeUSD / USD price feed', // description
],
true
);
return { sdeUSDPriceFeedAddress: sdeUSDMultiplicativePriceFeed.address };
},

async enact(deploymentManager: DeploymentManager, _, { sdeUSDPriceFeedAddress }) {
const trace = deploymentManager.tracer();
newPriceFeedAddress = sdeUSDPriceFeedAddress;

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

const sdeUSDPriceFeed = await deploymentManager.existing(
'sdeUSD:priceFeed',
sdeUSDPriceFeedAddress,
'mainnet'
);

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

const sdeUSDAssetConfig = {
asset: sdeUSD.address,
priceFeed: sdeUSDPriceFeed.address,
decimals: await sdeUSD.decimals(),
borrowCollateralFactor: exp(0.88, 18),
liquidateCollateralFactor: exp(0.90, 18),
liquidationFactor: exp(0.96, 18),
supplyCap: exp(5_000_000, 18),
};

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

const description = '# Add sdeUSD as collateral into cUSDCv3 on Mainnet\n\n## Proposal summary\n\nWOOF! proposes to add sdeUSD into cUSDCv3 on Ethereum network. This proposal takes the governance steps recommended and necessary to update a Compound III USDC 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-collateral-deusd-sdeusd-staked-on-usdc-usds-usdt-on-mainnet/6112/6).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/991) and [forum discussion](https://www.comp.xyz/t/add-collateral-deusd-sdeusd-staked-on-usdc-usds-usdt-on-mainnet/6112).\n\n\n## Proposal Actions\n\nThe first action adds sdeUSD 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(deploymentManager: DeploymentManager): Promise<boolean> {
return true;
},

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

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

const sdeUSD = await deploymentManager.existing(
'sdeUSD',
SDEUSD_ADDRESS,
'mainnet',
'contracts/ERC20.sol:ERC20'
);
const deUSDAssetConfig = {
asset: sdeUSD.address,
priceFeed: newPriceFeedAddress,
decimals: 18n,
borrowCollateralFactor: exp(0.88, 18),
liquidateCollateralFactor: exp(0.90, 18),
liquidationFactor: exp(0.96, 18),
supplyCap: exp(5_000_000, 18),
};

// 1. Compare sdeUSD asset config with Comet and Configurator asset info
const cometSdeUSDAssetInfo = await comet.getAssetInfoByAddress(SDEUSD_ADDRESS);
expect(sdeUSDAssetIndex).to.be.equal(cometSdeUSDAssetInfo.offset);
expect(deUSDAssetConfig.asset).to.be.equal(cometSdeUSDAssetInfo.asset);
expect(deUSDAssetConfig.priceFeed).to.be.equal(cometSdeUSDAssetInfo.priceFeed);
expect(exp(1, deUSDAssetConfig.decimals)).to.be.equal(cometSdeUSDAssetInfo.scale);
expect(deUSDAssetConfig.borrowCollateralFactor).to.be.equal(cometSdeUSDAssetInfo.borrowCollateralFactor);
expect(deUSDAssetConfig.liquidateCollateralFactor).to.be.equal(cometSdeUSDAssetInfo.liquidateCollateralFactor);
expect(deUSDAssetConfig.liquidationFactor).to.be.equal(cometSdeUSDAssetInfo.liquidationFactor);
expect(deUSDAssetConfig.supplyCap).to.be.equal(cometSdeUSDAssetInfo.supplyCap);

const configuratorSdeUSDAssetConfig = (await configurator.getConfiguration(comet.address)).assetConfigs[sdeUSDAssetIndex];
expect(deUSDAssetConfig.asset).to.be.equal(configuratorSdeUSDAssetConfig.asset);
expect(deUSDAssetConfig.priceFeed).to.be.equal(configuratorSdeUSDAssetConfig.priceFeed);
expect(deUSDAssetConfig.decimals).to.be.equal(configuratorSdeUSDAssetConfig.decimals);
expect(deUSDAssetConfig.borrowCollateralFactor).to.be.equal(configuratorSdeUSDAssetConfig.borrowCollateralFactor);
expect(deUSDAssetConfig.liquidateCollateralFactor).to.be.equal(configuratorSdeUSDAssetConfig.liquidateCollateralFactor);
expect(deUSDAssetConfig.liquidationFactor).to.be.equal(configuratorSdeUSDAssetConfig.liquidationFactor);
expect(deUSDAssetConfig.supplyCap).to.be.equal(configuratorSdeUSDAssetConfig.supplyCap);
},
});
22 changes: 15 additions & 7 deletions deployments/mainnet/usdc/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,32 @@ export default {
}
}
},
'AppProxyUpgradeable': {
UUPSProxy: {
artifact: 'contracts/ERC20.sol:ERC20',
},
fxRoot: {
relations: {
stateSender: {
field: async (fxRoot) => fxRoot.stateSender()
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
UUPSProxy: {
'ERC1967Proxy': {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
field: {
slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc'
}
}
},
'AppProxyUpgradeable': {
artifact: 'contracts/ERC20.sol:ERC20',
},
fxRoot: {
relations: {
stateSender: {
field: async (fxRoot) => fxRoot.stateSender()
}
}
},
arbitrumInbox: {
delegates: {
field: {
Expand Down
50 changes: 25 additions & 25 deletions deployments/mainnet/usdc/roots.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
{
"l1TokenAdminRegistry": "0xb22764f98dD05c789929716D677382Df22C05Cb6",
"comptrollerV2": "0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b",
"comet": "0xc3d688B66703497DAA19211EEdff47f25384cdc3",
"configurator": "0x316f9708bB98af7dA9c68C1C3b5e79039cD336E3",
"rewards": "0x1B0e765F6224C21223AeA2af16c1C46E38885a40",
"bulker": "0xa397a8C2086C554B531c02E29f3291c9704B00c7",
"fxRoot": "0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2",
"arbitrumInbox": "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
"arbitrumL1GatewayRouter": "0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef",
"CCTPTokenMessenger": "0xbd3fa81b58ba92a82136038b25adec7066af3155",
"CCTPMessageTransmitter": "0x0a992d191deec32afe36203ad87d7d289a738f81",
"baseL1CrossDomainMessenger": "0x866E82a600A1414e583f7F13623F1aC5d58b0Afa",
"baseL1StandardBridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
"baseL1USDSBridge": "0xA5874756416Fa632257eEA380CAbd2E87cED352A",
"opL1CrossDomainMessenger": "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1",
"opL1StandardBridge": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1",
"mantleL1CrossDomainMessenger": "0x676A795fe6E43C17c668de16730c3F690FEB7120",
"mantleL1StandardBridge": "0x95fC37A27a2f68e3A647CDc081F0A89bb47c3012",
"unichainL1CrossDomainMessenger": "0x9A3D64E386C18Cb1d6d5179a9596A4B5736e98A6",
"unichainL1StandardBridge": "0x81014F44b0a345033bB2b3B21C7a1A308B35fEeA",
"scrollMessenger": "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367",
"scrollL1USDCGateway": "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B",
"l1CCIPRouter": "0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D",
"roninl1CCIPOnRamp": "0xdC5b578ff3AFcC4A4a6E149892b9472390b50844",
"roninl1NativeBridge": "0x64192819Ac13Ef72bF6b5AE239AC672B43a9AF08"
"l1TokenAdminRegistry": "0xb22764f98dD05c789929716D677382Df22C05Cb6",
"comptrollerV2": "0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b",
"comet": "0xc3d688B66703497DAA19211EEdff47f25384cdc3",
"configurator": "0x316f9708bB98af7dA9c68C1C3b5e79039cD336E3",
"rewards": "0x1B0e765F6224C21223AeA2af16c1C46E38885a40",
"bulker": "0xa397a8C2086C554B531c02E29f3291c9704B00c7",
"fxRoot": "0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2",
"arbitrumInbox": "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
"arbitrumL1GatewayRouter": "0x72Ce9c846789fdB6fC1f34aC4AD25Dd9ef7031ef",
"CCTPTokenMessenger": "0xbd3fa81b58ba92a82136038b25adec7066af3155",
"CCTPMessageTransmitter": "0x0a992d191deec32afe36203ad87d7d289a738f81",
"baseL1CrossDomainMessenger": "0x866E82a600A1414e583f7F13623F1aC5d58b0Afa",
"baseL1StandardBridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35",
"baseL1USDSBridge": "0xA5874756416Fa632257eEA380CAbd2E87cED352A",
"opL1CrossDomainMessenger": "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1",
"opL1StandardBridge": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1",
"mantleL1CrossDomainMessenger": "0x676A795fe6E43C17c668de16730c3F690FEB7120",
"mantleL1StandardBridge": "0x95fC37A27a2f68e3A647CDc081F0A89bb47c3012",
"unichainL1CrossDomainMessenger": "0x9A3D64E386C18Cb1d6d5179a9596A4B5736e98A6",
"unichainL1StandardBridge": "0x81014F44b0a345033bB2b3B21C7a1A308B35fEeA",
"scrollMessenger": "0x6774Bcbd5ceCeF1336b5300fb5186a12DDD8b367",
"scrollL1USDCGateway": "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B",
"l1CCIPRouter": "0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D",
"roninl1CCIPOnRamp": "0xdC5b578ff3AFcC4A4a6E149892b9472390b50844",
"roninl1NativeBridge": "0x64192819Ac13Ef72bF6b5AE239AC672B43a9AF08"
}
4 changes: 2 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const {
SCROLLSCAN_KEY,
ANKR_KEY,
_TENDERLY_KEY_RONIN,
MNEMONIC = 'myth like bonus scare over problem client lizard pioneer submit female collect',
MNEMONIC = 'myth like woof scare over problem client lizard pioneer submit female collect',
REPORT_GAS = 'false',
NETWORK_PROVIDER = '',
GOV_NETWORK_PROVIDER = '',
Expand Down Expand Up @@ -111,7 +111,7 @@ interface NetworkConfig {
gasPrice?: number | 'auto';
}

const networkConfigs: NetworkConfig[] = [
export const networkConfigs: NetworkConfig[] = [
{
network: 'mainnet',
chainId: 1,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,6 @@
"repository": "git@github.com:compound-finance/comet.git",
"resolutions": {
"mocha": "^9.1.3"
}
}
},
"packageManager": "yarn@1.22.22"
}
48 changes: 31 additions & 17 deletions plugins/import/etherscan.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,47 @@
import axios from 'axios';
import { networkConfigs } from '../../hardhat.config';

export interface Result {
status: string;
message: string;
result: string;
}

// Updated because of Etherscan V2 update. Not tested and could lead to issues
export function getEtherscanApiUrl(network: string): string {
let host = {
rinkeby: 'api-rinkeby.etherscan.io',
ropsten: 'api-ropsten.etherscan.io',
sepolia: 'api-sepolia.etherscan.io',
mainnet: 'api.etherscan.io',
fuji: 'api-testnet.snowtrace.io',
avalanche: 'api.snowtrace.io',
polygon: 'api.polygonscan.com',
arbitrum: 'api.arbiscan.io',
base: 'api.basescan.org',
optimism: 'api-optimistic.etherscan.io',
mantle: 'api.mantlescan.xyz',
'ronin': 'explorer-kintsugi.roninchain.com/v2/2020',
scroll: 'api.scrollscan.com'
}[network];
// let host = {
// rinkeby: 'api-rinkeby.etherscan.io',
// ropsten: 'api-ropsten.etherscan.io',
// sepolia: 'api-sepolia.etherscan.io',
// mainnet: 'api.etherscan.io',
// fuji: 'api-testnet.snowtrace.io',
// avalanche: 'api.snowtrace.io',
// polygon: 'api.polygonscan.com',
// arbitrum: 'api.arbiscan.io',
// base: 'api.basescan.org',
// optimism: 'api-optimistic.etherscan.io',
// mantle: 'api.mantlescan.xyz',
// 'ronin': 'explorer-kintsugi.roninchain.com/v2/2020',
// scroll: 'api.scrollscan.com'
// }[network];

if (!host) {
// if (!host) {
// throw new Error(`Unknown etherscan API host for network ${network}`);
// }

const chainId = networkConfigs.find(config => config.network.toLowerCase() === network.toLowerCase())?.chainId;

if (!chainId) {
throw new Error(`Unknown etherscan API host for network ${network}`);
}

return `https://${host}/api`;
if (network === 'avalanche') {
return `https://api.snowtrace.io/api`;
} else if (network === 'fuji') {
return `https://api-testnet.snowtrace.io/api`;
}

return `https://api.etherscan.io/v2/api?chainid=${chainId}`;
}

export function getEtherscanUrl(network: string): string {
Expand Down
8 changes: 4 additions & 4 deletions plugins/import/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ async function scrapeContractCreationCodeFromEtherscanApi(network: string, addre
address,
apikey: getEtherscanApiKey(network)
};
const url = `${getEtherscanApiUrl(network)}?${paramString(params)}`;
const debugUrl = `${getEtherscanApiUrl(network)}?${paramString({ ...params, ...{ apikey: '[API_KEY]' } })}`;
const url = `${getEtherscanApiUrl(network)}&${paramString(params)}`;
const debugUrl = `${getEtherscanApiUrl(network)}&${paramString({ ...params, ...{ apikey: '[API_KEY]' } })}`;

debug(`Attempting to pull Contract Creation code from API at ${debugUrl}`);
const result = await get(url, {});
Expand Down Expand Up @@ -328,8 +328,8 @@ async function pullFirstTransactionForContractFromEtherscan(network: string, add
sort: 'asc',
apikey: getEtherscanApiKey(network)
};
const url = `${getEtherscanApiUrl(network)}?${paramString(params)}`;
const debugUrl = `${getEtherscanApiUrl(network)}?${paramString({ ...params, ...{ apikey: '[API_KEY]' } })}`;
const url = `${getEtherscanApiUrl(network)}&${paramString(params)}`;
const debugUrl = `${getEtherscanApiUrl(network)}&${paramString({ ...params, ...{ apikey: '[API_KEY]' } })}`;

debug(`Attempting to pull Contract Creation code from first tx at ${debugUrl}`);
const result = await get(url, {});
Expand Down
0