Skip to content

Optimism deployment#613

Open
scott-silver wants to merge 4 commits intomainfrom
silver/optimism-deployment
Open

Optimism deployment#613
scott-silver wants to merge 4 commits intomainfrom
silver/optimism-deployment

Conversation

@scott-silver
Copy link
Copy Markdown
Contributor

@scott-silver scott-silver commented Nov 3, 2022

Work-in-progress Optimism deployment

  • return Supply Caps to 0
  • decide on actual assets to use
  • determine the actual configuration params
  • deploy hard-code the new mainnet/USDC root
  • deploy the new Optimism/USDC roots
  • launch an Optimism liquidation bot
    • confirm that there are exchanges for WBTC, WETH and OP
    • update Liquidation Bot scenarios to run on Optimism deployment
    • add Optimism liquidationThreshold value
    • create Pulumi config for bot
  • add a rewardTokenAddress
    • create a bridged version of COMP?
    • request an Optimism COMP price feed from ChainLink
  • add a pauseGuardian
  • add token bridging to Optimism relayer
  • create Optimism testnet instance
  • create proposal branch
  • lower baseMinForRewards

@scott-silver scott-silver force-pushed the silver/optimism-deployment branch from 4510c34 to 40cb1d8 Compare November 3, 2022 23:30
@jflatow jflatow added deployment This PR contains a new deployment needs audit These changes will need an audit labels Jan 5, 2023
@scott-silver scott-silver force-pushed the silver/optimism-deployment branch from 51cecd7 to 3033151 Compare January 17, 2023 18:06
@jflatow jflatow force-pushed the silver/optimism-deployment branch 2 times, most recently from 5643713 to 37f15fb Compare February 28, 2023 18:53
@scott-silver scott-silver changed the base branch from main to silver/polygon-deploy-proposal February 28, 2023 21:21
@jflatow jflatow force-pushed the silver/optimism-deployment branch from 37f15fb to 6695f95 Compare March 8, 2023 19:12
@jflatow jflatow added audited These changes have been audited and removed needs audit These changes will need an audit labels Mar 8, 2023
@jflatow jflatow changed the base branch from silver/polygon-deploy-proposal to main March 8, 2023 19:26
@jflatow jflatow marked this pull request as ready for review March 8, 2023 19:26
@jflatow jflatow changed the title [Draft] Optimism deployment Optimism deployment Mar 8, 2023
return `0x${(BigInt(address) + offset).toString(16)}`;
}

export default async function relayOptimismMessage(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to test the Optimism proposal (that we will eventually write), we need to add token bridging to this function like the Polygon relayer.

Copy link
Copy Markdown
Contributor

@kevincheng96 kevincheng96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work on this!

"indexScale": "1e15",
"baseSupplySpeed": "0e15",
"baseBorrowSpeed": "0e15",
"baseMinForRewards": "1000000e6"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we'll lower this to 10,000.

Comment on lines +27 to +53
"OP": {
"address": "0x4200000000000000000000000000000000000042",
"priceFeed": "0x0D276FC14719f9292D5C1eA2198673d1f4269246",
"decimals": "18",
"borrowCF": 0.65,
"liquidateCF": 0.70,
"liquidationFactor": 0.93,
"supplyCap": "0e18"
},
"WETH": {
"address": "0x4200000000000000000000000000000000000006",
"priceFeed": "0x13e3Ee699D1909E989722E753853AE30b17e08c5",
"decimals": "18",
"borrowCF": 0.775,
"liquidateCF": 0.825,
"liquidationFactor": 0.95,
"supplyCap": "0e18"
},
"WBTC": {
"address": "0x68f180fcCe6836688e9084f035309E29Bf0A2095",
"priceFeed": "0x718A5788b89454aAE3A028AE9c111A29Be6c2a6F",
"decimals": "8",
"borrowCF": 0.70,
"liquidateCF": 0.75,
"liquidationFactor": 0.95,
"supplyCap": "0e18"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note that we still need to get risk parameters from Gauntlet.


const secondsPerDay = 24 * 60 * 60;

const CROSS_DOMAIN_MESSENGER = "0x4200000000000000000000000000000000000007";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: single quotes

const secondsPerDay = 24 * 60 * 60;

const CROSS_DOMAIN_MESSENGER = "0x4200000000000000000000000000000000000007";
const MAINNET_TIMELOCK = '0x6d903f6003cca6255d85cca4d3b5e5146dc33925';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pull this in using dm.fromDep.

Comment on lines +40 to +41
2 * secondsPerDay, // delay
14 * secondsPerDay, // grace period
2 * secondsPerDay, // minimum delay
30 * secondsPerDay // maxiumum delay
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should use the same values as we did for the Polygon deploy. And we could name the constants the same as we did there (DAY/HOUR).

// Deploy Bulker
const bulker = await deploymentManager.deploy(
'bulker',
'bulkers/BaseBulker.sol',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to use the MainnetTimelock to have wstETH support since I think Lido is making a push on Optimism. We could also switch the Bulker when/if we do a ETH deploy.

Comment on lines +18 to +34
case 'optimism': {
const governor = await governanceDeploymentManager.getContractOrThrow('governor');
const optimismL1CrossDomainMessenger = await governanceDeploymentManager.getContractOrThrow('optimismL1CrossDomainMessenger');
const { targets } = await governor.getActions(openProposal.id);
return targets.includes(optimismL1CrossDomainMessenger.address);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also support token bridging, which would call into the L1StandardBridge.

Comment on lines +31 to +37
// listen on events on the OptimismL1CrossDomainMessenger
const sentMessageListenerPromise = new Promise((resolve, reject) => {
const filter = {
address: optimismL1CrossDomainMessenger.address,
topics: [functionIdentifier('SentMessage(address,address,bytes,uint256,uint256)')]
};

governanceDeploymentManager.hre.ethers.provider.on(filter, (log) => {
resolve(log);
});

setTimeout(() => {
reject(new Error('OptimismL1CrossDomainMessenger.SentMessage event listener timed out'));
}, EVENT_LISTENER_TIMEOUT);
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use ethers.provider.getLogs to avoid the complexities of setting up our own listener with a timeout. Similar to how we do it for relaying Polygon messages.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed; the Polygon version is much improved over this iteration. we should rework this to incorporate those improvements

return `0x${(BigInt(address) + offset).toString(16)}`;
}

export default async function relayOptimismMessage(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@kevincheng96
Copy link
Copy Markdown
Contributor

Here's our PR for adding COMP to Optimism (only to Optimism-goerli for now, we still have to deploy the token on Optimism mainnet): ethereum-optimism/ethereum-optimism.github.io#294


const sendMessageCalldata = utils.defaultAbiCoder.encode(
['address', 'bytes', 'uint32'],
[bridgeReceiver.address, l2ProposalData, 1000000]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be careful about calculating the gasLimit param and make sure that it's sufficient for the L2 txn. Also, I wonder what happens if the gasLimit we set is too low. Logically, the L2 transaction would fail but I don't see it covered in the docs.

@kevincheng96 kevincheng96 force-pushed the silver/optimism-deployment branch 2 times, most recently from 85703cf to 476908a Compare March 21, 2023 18:25
@kevincheng96 kevincheng96 force-pushed the silver/optimism-deployment branch 2 times, most recently from 3362bdf to c41ed35 Compare April 4, 2023 17:07
@kevincheng96
Copy link
Copy Markdown
Contributor

Merged the testnet branch #710 into this branch since testnet has been deployed and initialized and is ready to be used.

@scott-silver scott-silver mentioned this pull request Apr 10, 2023
21 tasks
"rewardTokenAddress": "0x6AF3cb766D6cd37449bfD321D961A61B0515c1BC",
"assets": {
"OP": {
"priceFeed": "0xE882831E58eec48B7f304482771F67e6b846733D",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to populating infos into c3-api to start supporting optimism. But it seems we're missing OP's address here 🤔 ? Is it '0x4200000000000000000000000000000000000042' ?
(Just checked on testnet, it seems it's also this address, but wanted to double check :) )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes "0x4200000000000000000000000000000000000042" is the official address for OP on both Optimism testnet and mainnet. However, on testnet, we've deployed our own OP token because there doesn't seem to be a public faucet for it and it would make using the testnet easier if we controlled the token supply. Our testnet OP token address is "0x32719c5e2e35909C8f42167315445e349e749E05".

Btw, if you are unsure which addresses we use on each chain for each deployment, you can use Spider to programmatically pull in all the relevant addresses for a deployment. See https://github.com/compound-finance/comet/tree/main#spider

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it thank you so much!! 🙏


const secondsPerDay = 24 * 60 * 60;

const GOERLI_TIMELOCK = '0x8Fa336EB4bF58Cfc508dEA1B0aeC7336f55B1399';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious if local timelock on optimism-goerli should be 'https://goerli-optimism.etherscan.io/address/0x4c8011724f2ece7b6ce4b13c90fe5036c9e1eb2d' instead of 0x8Fa336EB4bF58Cfc508dEA1B0aeC7336f55B1399 ? 🤔

Went to check 0x8Fa336EB4bF58Cfc508dEA1B0aeC7336f55B1399, but it got empty address.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the Ethereum Goerli timelock, not the Optimism Goerli timelock 😃

We hardcode it here because it is provided as a constructor arg to the BridgeReceiver, which needs to know what L1 contract messages should be coming from.

scott-silver and others added 4 commits May 22, 2023 16:17
base configuration.json

add optimism values to etherscan.ts

relations

base relayPolygonMessage

add isBridgeProposal

rename to relayOptimismMessage

add optimismL1CrossDomainMessenger to mainnet/usdc deploy

partial relayOptimismMessage impl

relayOptimismMessage impl cont'd

optimism deploy script

complete relayOptimismMessage impl

bump supply caps

rename iface

applyL1ToL2Alias helper

bridge receiver contract

add crossDomainMessenger arg to constructor in deplooy.ts

add scenario, matchesDeployment helper

reuse CROSS_DOMAIN_MESSENGER

lint

update Github Actions

update asset information
update comment in Optimism deploy script

update Bulker path

I for Interface

Optimism deployment misc fixes (#701)

* WETH whale

* add optimismL1CrossDomainManager to roots
* Optimism testnet deploy

* WIP

* Allow `existing` to merge into a proxy and use for optimism-goerli

* Fix cross-chain scenario by passing in gasLimit from the L1 txn

* Update deploy and bump hardhat

* Fix Optimism scenarios (#721)

* Add logs when executing a bridged proposal

* Add new regex to custom error checker

* Use separate Etherscan API key for optimism

* Add USDC whale for optimism-goerli

* Add revert error message for WETH

* More scenario fixes

* Fix remaining scenario errors

* Add case for optimism-goerli to createCrossChainProposal

* Add optimism etherscan key to forge test job

* Update collateral assets and deploy script

* Update WBTC supply cap decimals

* Deploy Comet to Optimism-Goerli and upload VerifyArgs when deploy fails (#728)

We deploy Comet to Optimism-Goerli and update the roots in this PR. This PR also improves the deploy step by allowing us to recover the `VerifyArgs` if a deploy job fails mid-deploy. This also includes a fix for verifying contracts in Optimism-Goerli.

---------

Co-authored-by: GitHub Actions Bot <>
Co-authored-by: Jared Flatow <jflatow@gmail.com>

* Update timelock constructor params in deploy script

* Remove roots for re-deploy

* Modified deployment roots from GitHub Actions

* Optimism-Goerli proposal (#726)

This PR creates the Optimism-Goerli migration script for launching cUSDCv3. This PR also updates the Optimism message-passing bridge relayer logic in our scenarios so we can test token bridging using scenarios.

Proposal 70 created and executed: https://goerli.etherscan.io/tx/0x6defeea621b4778cfab509ea5ed5ce2ed4da78535dc75e787312b78413e88aaf

Execution of proposal on Optimism Goerli: https://goerli-optimism.etherscan.io/tx/0x465b0e6863afeb1640336b6843b4b03ce51a13b01cae51f04638cd4054a41392

---------

Co-authored-by: GitHub Actions Bot <>

---------

Co-authored-by: Jared Flatow <jflatow@gmail.com>
Co-authored-by: kevincheng96 <kevincheng96@hotmail.com>
Co-authored-by: GitHub Actions Bot <>
@kevincheng96 kevincheng96 force-pushed the silver/optimism-deployment branch from c91bffc to 290aa30 Compare May 22, 2023 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audited These changes have been audited deployment This PR contains a new deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants