Skip to content

Commit

Permalink
address most comments. Still wip
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Feb 20, 2024
1 parent be4e42d commit cf70fee
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 91 deletions.
12 changes: 6 additions & 6 deletions deployments/base/usdc/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"storeFrontPriceFactor": 0.6,
"targetReserves": "5000000e6",
"rates": {
"supplyKink": 0.8,
"supplySlopeLow": 0.0325,
"supplySlopeHigh": 0.4,
"supplyKink": 0.85,
"supplySlopeLow": 0.048,
"supplySlopeHigh": 1.6,
"supplyBase": 0,
"borrowKink": 0.8,
"borrowSlopeLow": 0.035,
"borrowSlopeHigh": 0.25,
"borrowKink": 0.85,
"borrowSlopeLow": 0.053,
"borrowSlopeHigh": 1.8,
"borrowBase": 0.015
},
"tracking": {
Expand Down
109 changes: 25 additions & 84 deletions deployments/base/usdc/migrations/1689892563_configurate_and_ens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import { expect } from 'chai';

const ENSName = 'compound-community-licenses.eth';
const ENSResolverAddress = '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41';
const ENSRegistryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e';
const ENSSubdomainLabel = 'v3-additional-grants';
const ENSSubdomain = `${ENSSubdomainLabel}.${ENSName}`;
const ENSTextRecordKey = 'v3-official-markets';
const baseCOMPAddress = '0x9e1028F5F1D5eDE59748FFceE5532509976840E0';

const cUSDCAddress = '0x39AA39c021dfbaE8faC545936693aC917d5E7563';

export default migration('1689892563_configurate_and_ens', {
prepare: async (deploymentManager: DeploymentManager) => {
Expand All @@ -35,11 +31,7 @@ export default migration('1689892563_configurate_and_ens', {

const {
baseL1CrossDomainMessenger,
baseL1StandardBridge,
governor,
comptrollerV2,
COMP: mainnetCOMP,
USDC: mainnetUSDC
} = await govDeploymentManager.getContracts();

// ENS Setup
Expand All @@ -64,27 +56,19 @@ export default migration('1689892563_configurate_and_ens', {
['address', 'address'],
[configurator.address, comet.address]
);
const setRewardConfigCalldata = utils.defaultAbiCoder.encode(
['address', 'address'],
[comet.address, baseCOMPAddress]
);
const l2ProposalData = utils.defaultAbiCoder.encode(
['address[]', 'uint256[]', 'string[]', 'bytes[]'],
[
[configurator.address, cometAdmin.address, rewards.address],
[0, 0, 0],
[configurator.address, cometAdmin.address],
[0, 0],
[
'setConfiguration(address,(address,address,address,address,address,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint104,uint104,uint104,(address,address,uint8,uint64,uint64,uint64,uint128)[]))',
'deployAndUpgradeTo(address,address)',
'setRewardConfig(address,address)'
'deployAndUpgradeTo(address,address)'
],
[setConfigurationCalldata, deployAndUpgradeToCalldata, setRewardConfigCalldata]
[setConfigurationCalldata, deployAndUpgradeToCalldata]
]
);

const COMPAmountToBridge = exp(12_500, 18);
const USDCAmountToBridge = exp(10_000, 6);

const actions = [
// 1. Set Comet configuration + deployAndUpgradeTo new Comet and set reward config on Base.
{
Expand All @@ -93,35 +77,7 @@ export default migration('1689892563_configurate_and_ens', {
args: [bridgeReceiver.address, l2ProposalData, 2_500_000]
},

// 2. Approve Ethereum's L1StandardBridge to take Timelock's USDC (for bridging)
{
contract: mainnetUSDC,
signature: 'approve(address,uint256)',
args: [baseL1StandardBridge.address, USDCAmountToBridge]
},
// 3. Bridge USDC from Ethereum to Base Comet using L1StandardBridge
{
contract: baseL1StandardBridge,
// function depositERC20To(address _l1Token, address _l2Token, address _to, uint256 _amount, uint32 _l2Gas,bytes calldata _data)
signature: 'depositERC20To(address,address,address,uint256,uint32,bytes)',
args: [mainnetUSDC.address, USDC.address, comet.address, USDCAmountToBridge, 200_000, '0x']
},

// 4. Approve Ethereum's L1StandardBridge to take Timelock's COMP (for bridging)
{
contract: mainnetCOMP,
signature: 'approve(address,uint256)',
args: [baseL1StandardBridge.address, COMPAmountToBridge]
},
// 5. Bridge COMP from Ethereum to Base Rewards using L1StandardBridge
{
contract: baseL1StandardBridge,
// function depositERC20To(address _l1Token, address _l2Token, address _to, uint256 _amount, uint32 _l2Gas,bytes calldata _data)
signature: 'depositERC20To(address,address,address,uint256,uint32,bytes)',
args: [mainnetCOMP.address, baseCOMPAddress, rewards.address, COMPAmountToBridge, 200_000, '0x']
},

// 6. Update the list of official markets
// 2. Update the list of official markets
{
target: ENSResolverAddress,
signature: 'setText(bytes32,string,string)',
Expand All @@ -130,20 +86,9 @@ export default migration('1689892563_configurate_and_ens', {
[subdomainHash, ENSTextRecordKey, JSON.stringify(officialMarketsJSON)]
)
},

// 7. Displace v2 USDC COMP rewards
{
contract: comptrollerV2,
signature: '_setCompSpeeds(address[],uint256[],uint256[])',
args: [
[cUSDCAddress],
[9194444444444444n],
[15444444444444444n],
],
},
];

const description = "# Initialize cUSDCv3 on Base\n\nThis proposal takes the governance steps recommended and necessary to initialize a Compound III USDbC (bridged version of USDC on Base) market on Base; upon execution, cUSDbCv3 will be ready for use. 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). Although real tests have also been run over the Goerli/Base Goerli bridge, this will be the first proposal to actually bridge from Ethereum mainnet to Base mainnet, and therefore includes risks not present in previous proposals.\n\nAlthough the proposal sets the entire configuration in the Configurator, the initial deployment already has most of these same parameters already set. The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet](https://www.comp.xyz/t/deploy-compound-iii-on-base/4402/2). Finally, the parameters include a modest reallocation of some of the v2 USDC supply-side COMP incentives to users in the new market.\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/792) and [forum discussion](https://www.comp.xyz/t/deploy-compound-iii-on-base/4402).\n\n\n## Proposal Actions\n\nThe first proposal action sets the Comet configuration and deploys a new Comet implementation on Base. This sends the encoded `setConfiguration` and `deployAndUpgradeTo` calls across the bridge to the governance receiver on Base. It also calls `setRewardConfig` on the Base rewards contract, to establish Base’s bridged version of COMP as the reward token for the deployment and set the initial supply speed to be 30 COMP/day and borrow speed to be 15 COMP/day.\n\nThe second action approves Base’s [L1StandardBridge](https://etherscan.io/address/0x3154Cf16ccdb4C6d922629664174b904d80F2C35) to take the Timelock's USDC, in order to seed the market reserves through the bridge.\n\nThe third action deposits 10K USDC from mainnet to the Base L1StandardBridge contract to bridge to Comet.\n\nThe fourth action approves Base’s [L1StandardBridge](https://etherscan.io/address/0x3154Cf16ccdb4C6d922629664174b904d80F2C35) to take Timelock's COMP, in order to seed the rewards contract through the bridge.\n\nThe fifth action deposits 12.5K COMP from mainnet to the Base L1StandardBridge contract to bridge to CometRewards.\n\nThe sixth action updates the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, updating the official markets JSON to include the new Base cUSDbCv3 market.\n\nThe seventh action reduces the COMP distribution to v2 cUSDC suppliers by 45 COMP/day, so as to keep the total COMP distribution constant.";
const description = "# Initialize cUSDCv3 on Base\n\nThis proposal takes the governance steps recommended and necessary to initialize a Compound III USDC market on Base; upon execution, cUSDCv3 will be ready for use. 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). Although real tests have also been run over the Goerli/Base Goerli bridge, this will be the first proposal to actually bridge from Ethereum mainnet to Base mainnet, and therefore includes risks not present in previous proposals.\n\nAlthough the proposal sets the entire configuration in the Configurator, the initial deployment already has most of these same parameters already set. The new parameters include setting the risk parameters based off of the [recommendations from Gauntlet](https://www.comp.xyz/t/deploy-compound-iii-on-base/4402/2). Finally, the parameters include a modest reallocation of some of the v2 USDC supply-side COMP incentives to users in the new market.\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/792) and [forum discussion](https://www.comp.xyz/t/deploy-compound-iii-on-base/4402).\n\n\n## Proposal Actions\n\nThe first proposal action sets the Comet configuration and deploys a new Comet implementation on Base. This sends the encoded `setConfiguration` and `deployAndUpgradeTo` calls across the bridge to the governance receiver on Base. It also calls `setRewardConfig` on the Base rewards contract, to establish Base’s bridged version of COMP as the reward token for the deployment and set the initial supply speed to be 30 COMP/day and borrow speed to be 15 COMP/day.\n\nThe second action approves Base’s [L1StandardBridge](https://etherscan.io/address/0x3154Cf16ccdb4C6d922629664174b904d80F2C35) to take the Timelock's USDC, in order to seed the market reserves through the bridge.\n\nThe third action deposits 10K USDC from mainnet to the Base L1StandardBridge contract to bridge to Comet.\n\nThe fourth action approves Base’s [L1StandardBridge](https://etherscan.io/address/0x3154Cf16ccdb4C6d922629664174b904d80F2C35) to take Timelock's COMP, in order to seed the rewards contract through the bridge.\n\nThe fifth action deposits 12.5K COMP from mainnet to the Base L1StandardBridge contract to bridge to CometRewards.\n\nThe sixth action updates the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, updating the official markets JSON to include the new Base cUSDbCv3 market.\n\nThe seventh action reduces the COMP distribution to v2 cUSDC suppliers by 45 COMP/day, so as to keep the total COMP distribution constant.";
const txn = await govDeploymentManager.retry(async () =>
trace(await governor.propose(...(await proposal(actions, description))))
);
Expand All @@ -169,10 +114,6 @@ export default migration('1689892563_configurate_and_ens', {
USDC
} = await deploymentManager.getContracts();

const {
comptrollerV2,
} = await govDeploymentManager.getContracts();

// 1.
const stateChanges = await diffState(comet, getCometConfig, preMigrationBlockNumber);
expect(stateChanges).to.deep.equal({
Expand All @@ -184,20 +125,15 @@ export default migration('1689892563_configurate_and_ens', {
cbETH: {
supplyCap: exp(7500, 18)
}
})

const config = await rewards.rewardConfig(comet.address);
expect(config.token).to.be.equal(COMP.address);
expect(config.rescaleFactor).to.be.equal(exp(1, 12));
expect(config.shouldUpscale).to.be.equal(true);

// 2. & 3.
expect(await USDC.balanceOf(comet.address)).to.be.equal(exp(10_000, 6));

// 4. & 5.
expect(await COMP.balanceOf(rewards.address)).to.be.equal(exp(12_500, 18));

// 6.
});

// TODO: Validate the reward config
// const config = await rewards.rewardConfig(comet.address);
// expect(config.token).to.be.equal(COMP.address);
// expect(config.rescaleFactor).to.be.equal(exp(1, 12));
// expect(config.shouldUpscale).to.be.equal(true);

// 2.
const ENSResolver = await govDeploymentManager.existing('ENSResolver', ENSResolverAddress);
const subdomainHash = ethers.utils.namehash(ENSSubdomain);
const officialMarketsJSON = await ENSResolver.text(subdomainHash, ENSTextRecordKey);
Expand All @@ -221,21 +157,26 @@ export default migration('1689892563_configurate_and_ens', {
],
42161: [
{
baseSymbol: 'USDC',
baseSymbol: 'USDC.e',
cometAddress: '0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA',
},
{
baseSymbol: 'USDC',
cometAddress:'0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
}
],
8453: [
{
baseSymbol: 'USDbC',
cometAddress: comet.address,
cometAddress: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
},
{
baseSymbol: 'WETH',
cometAddress: '0x46e6b214b524310239732D51387075E0e70970bf',
}
],
});

// 7.
expect(await comptrollerV2.compSupplySpeeds(cUSDCAddress)).to.be.equal(9194444444444444n); // 66.2 COMP/day
expect(await comptrollerV2.compBorrowSpeeds(cUSDCAddress)).to.be.equal(15444444444444444n); // 111.2 COMP/day
expect(await comet.baseTrackingSupplySpeed()).to.be.equal(exp(30 / 86400, 15, 18));
expect(await comet.baseTrackingBorrowSpeed()).to.be.equal(exp(15 / 86400, 15, 18));
}
Expand Down
19 changes: 18 additions & 1 deletion deployments/goerli/usdc/roots.json
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
{}
{
"timelock": "0x8Fa336EB4bF58Cfc508dEA1B0aeC7336f55B1399",
"fauceteer": "0x75442Ac771a7243433e033F3F8EaB2631e22938f",
"comet": "0x3EE77595A8459e93C2888b13aDB354017B198188",
"configurator": "0xB28495db3eC65A0e3558F040BC4f98A0d588Ae60",
"rewards": "0xef9e070044d62C38D2e316146dDe92AD02CF2c2c",
"bulker": "0x69dD076105977c55dC2835951d287f82D54606b4",
"fxRoot": "0x3d1d3E34f7fB6D26245E6640E1c50710eFFf15bA",
"arbitrumInbox": "0x6BEbC4925716945D46F0Ec336D5C2564F419682C",
"arbitrumL1GatewayRouter": "0x4c7708168395aEa569453Fc36862D2ffcDaC588c",
"baseL1CrossDomainMessenger": "0x8e5693140eA606bcEB98761d9beB1BC87383706D",
"baseL1StandardBridge": "0xfA6D8Ee5BE770F84FC001D098C4bD604Fe01284a",
"lineaMessageService": "0x70BaD09280FD342D02fe64119779BC1f0791BAC2",
"lineaL1TokenBridge": "0xaA012D038E6440535Ec66eDf2DA592F4F8398133",
"lineaL1usdcBridge": "0x9c556D2cCfb6157E4A6305aa9963EdD6ca5047cB",
"CCTPTokenMessenger": "0xd0c3da58f55358142b8d3e06c1c30c5c6114efe8",
"CCTPMessageTransmitter": "0x26413e8157cd32011e726065a5462e97dd4d03d9"
}

0 comments on commit cf70fee

Please sign in to comment.