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

Add deUSD to cUSDCv3 on Mainnet #990

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

Open
wants to merge 8 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
121 changes: 121 additions & 0 deletions deployments/mainnet/usdc/migrations/1750088604_add_deusd_collateral.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
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 DEUSD_ADDRESS = '0x15700B564Ca08D9439C58cA5053166E8317aa138';
const DEUSD_TO_USD_ADDRESS = '0x471a6299C027Bd81ed4D66069dc510Bd0569f4F8';

export default migration('1750088604_add_deusd_collateral', {
async prepare() {
return {};
},

async enact(deploymentManager: DeploymentManager) {
const trace = deploymentManager.tracer();

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

const deUSDPriceFeed = await deploymentManager.existing(
'deUSD:priceFeed',
DEUSD_TO_USD_ADDRESS,
'mainnet'
);

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

const deUSDAssetConfig = {
asset: deUSD.address,
priceFeed: deUSDPriceFeed.address,
decimals: await deUSD.decimals(),
borrowCollateralFactor: exp(0.88, 18),
liquidateCollateralFactor: exp(0.90, 18),
liquidationFactor: exp(0.96, 18),
supplyCap: exp(8_000_000, 18),
};

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

const description = '# Add deUSD as collateral into cUSDCv3 on Mainnet\n\n## Proposal summary\n\nWOOF! proposes to add deUSD 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/990) 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 deUSD asset as collateral with corresponding configura 10000 tions.\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 deUSDAssetIndex = Number(await comet.numAssets()) - 1;

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

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

const configuratorDeUSDAssetConfig = (await configurator.getConfiguration(comet.address)).assetConfigs[deUSDAssetIndex];
expect(deUSDAssetConfig.asset).to.be.equal(configuratorDeUSDAssetConfig.asset);
expect(deUSDAssetConfig.priceFeed).to.be.equal(configuratorDeUSDAssetConfig.priceFeed);
expect(deUSDAssetConfig.decimals).to.be.equal(configuratorDeUSDAssetConfig.decimals);
expect(deUSDAssetConfig.borrowCollateralFactor).to.be.equal(configuratorDeUSDAssetConfig.borrowCollateralFactor);
expect(deUSDAssetConfig.liquidateCollateralFactor).to.be.equal(configuratorDeUSDAssetConfig.liquidateCollateralFactor);
expect(deUSDAssetConfig.liquidationFactor).to.be.equal(configuratorDeUSDAssetConfig.liquidationFactor);
expect(deUSDAssetConfig.supplyCap).to.be.equal(configuratorDeUSDAssetConfig.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
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