Skip to content
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

Bridged usdc custom gateway #87

Merged
merged 118 commits into from
Aug 19, 2024
Merged

Bridged usdc custom gateway #87

merged 118 commits into from
Aug 19, 2024

Conversation

gvladika
Copy link
Contributor

@gvladika gvladika commented May 23, 2024

Custom USDC gateway (for parent and child chain), complying with Bridged USDC Standard. These contracts can be used by new Orbit chains which want to provide USDC bridging solution and keep the possibility to upgrade to native USDC at some point later. This solution will NOT be used in existing Arbitrum chains.

Reference to the Circle's Bridged USDC: https://github.com/circlefin/stablecoin-evm/blob/master/doc/bridged_USDC_standard.md

Expected flow of actions on a fresh Orbit chain could look like this:

  • chain owner deploys upgradeable USDC token on parent chain, or uses canonical USDC if there is one
  • chain owner deploys upgradeable USDC token on child chain, to be used ad bridged USDC, and inits the contract
  • chain owner deploys upgradeable USDC custom gateway on parent and child chain
    • chain owner inits those gateways
  • chain owner registers USDC gateway in router for USDC token
  • chain owner assigns minter role to the child chain gateway along with max mint allowance
  • now USDC can be bridged in both directions
  • once transition to native USDC is agreed on, chain owner pauses deposits on parent chain
  • chain owner then pauses withdrawals on child chain
  • chain owner removes the minter role from the child chain gateway
    • there should be no in-flight deposits when minter role is revoked. If there are any, they should be executed (can be done by anyone by claiming the failed retryable ticket which does the USDC depositing).
    • if minter role is revoked before in-flight deposits are claimed, those funds can’t be minted. One option is to leave the gateway’s minter role, but decrease the allowance to match the total amount of unclaimed deposits
  • chain owner sets Circle as burner on the parent chain gateway using setBurner(address) function
  • chain owner reads the total supply of USDC on child chains. Then, he invokes setBurnAmount(uint256) on the parent child gateway where the amount matches the total supply
    • in case there are unclaimed deposits, their total amount should be added to the supply as those tokens shall eventually be minted by child chain gateway
  • USDC masterMinter gives minter role with 0 allowance to parent chain gateway, so the burn can be executed
  • on the child chain, gateway owner calls the setUsdcOwnershipTransferrer(address) to set the account (provided and controlled by Circle) which will be able to transfer the bridged USDC ownership and proxy admin
  • if not already owned by gateway, bridged USDC owner transfers ownership to gateway, and proxy admin transfers admin rights to gateway
  • Circle uses usdcOwnershipTransferrer account to trigger transferUSDCRoles(address) which will set caller as USDC proxy admin and will transfer USDC ownership to the provided address (according to standard [requirements](https://github.com/circlefin/stablecoin-evm/blob/master/doc/bridged_USDC_standard.md#token-roles))
  • Circle calls burnLockedUSDC() on the L1 USDC gateway using burner account to burn the burnAmount of USDC
    • remaining USDC will be cleared off when remaining in-flight USDC withdrawals are executed, if any
  • USDC token contract on the child chain is considered native now. Circle has ownership of the contract and can set minter, blacklister and other roles

PR containts USDC gateway implementation for parent chain and child chain, Foundry unit tests and Hardhat e2e test.

@cla-bot cla-bot bot added the cla-signed label May 23, 2024
Copy link
Member

@gzeoneth gzeoneth left a comment

Choose a reason for hiding this comment

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

lgtm, some comments
also new contracts can be added into storage test

@gzeoneth gzeoneth changed the base branch from main to develop July 8, 2024 16:11
Base automatically changed from develop to main July 9, 2024 14:43
@gvladika gvladika requested a review from gzeoneth July 11, 2024 08:06
* Deployer script draft

* Deploy bridged usdc

* Init gateways

* Add env.example

* Add register gateway script draft

* Load upg executor

* Add registration logic

* Add env examples

* Do registration in the same script

* Remove separate script for registration

* Add env var check

* Get rollup address from inbox

* Init logic to dummy values

* Use SDK estimations instead of hard-coding retryable params

* If owner is multisig print TX data to a file

* Make gw registration work for fee token chains

* Deploy orbit gateway when fee token used

* Make ROLLUP_OWNER_KEY optional

* Set minter role to L2 gateway

* Refactor

* Check initialization

* Add yarn action

* Add readme for deployment

* Deploy master minter

* Use MasterMinter contract

* Update readme with usdc upgrade procedure

* Add comment

* Add fee transfer logic to list of TXs stored into a file

* Do scaling in case of non-18 decimals fee token

* Add more docs

* Update slither db

* Readme clarifications
@gzeoneth gzeoneth changed the base branch from main to develop August 19, 2024 13:57
@gzeoneth gzeoneth changed the base branch from develop to main August 19, 2024 13:59
@gzeoneth gzeoneth changed the base branch from main to develop August 19, 2024 14:05
@gzeoneth gzeoneth merged commit fd2d31b into develop Aug 19, 2024
9 checks passed
@gzeoneth gzeoneth deleted the bridged-usdc-gw branch August 19, 2024 14:06
@gzeoneth gzeoneth mentioned this pull request Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants