Skip to content

infinityswap/optimism-dai-bridge

This branch is 211 commits behind makerdao/optimism-dai-bridge:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

c8b5f2d · Mar 28, 2021

History

90 Commits
Mar 28, 2021
Mar 28, 2021
Mar 21, 2021
Mar 25, 2021
Mar 17, 2021
Mar 28, 2021
Mar 8, 2021
Mar 17, 2021
Feb 15, 2021
Mar 15, 2021
Feb 15, 2021
Mar 11, 2021
Mar 24, 2021
Mar 28, 2021
Mar 15, 2021
Mar 8, 2021
Mar 25, 2021
Mar 17, 2021
Mar 25, 2021

Repository files navigation

Optimism Dai Bridge

Optimism Dai and upgradable token bridge

Contracts

  • l2/dai.sol - Improved DAI contract
  • l1/L1ERC20Gateway.sol - L1 side of the bridge. Escrows L1 DAI in a specified address. Unlocks L1 DAI upon withdrawal message from L2DepositedToken
  • l2/L2DepositedToken.sol - L2 side of the bridge. Mints new L2 DAI after receiving message from L1ERC20Gateway. Burns L2 DAI tokens when withdrawals happens

Upgrade guide

Deploying new token bridge

This bridge stores funds in an external escrow account rather than on the bridge address itself. To upgrade, deploy new bridge independently and connect to the same escrow. Thanks to this, no bridge will ever run out of funds.

Closing bridge

After deploying a new bridge you might consider closing the old one. Procedure is slightly complicated due to async messages like finalizeDeposit and finalizeWithdraw that can be in progress.

An owner calls L2DepositedToken.close() and L1ERC20Gateway.close() so no new async messages can be sent to the other part of the bridge. After all async messages are done processing (can take up to 1 week) bridge is effectively closed. Now, you can consider revoking approval to access funds from escrow on L1 and token minting rights on L2.

Running

yarn
yarn build
yarn test  # runs unit tests

Running E2E tests

# start optimism-integration
git clone https://github.com/ethereum-optimism/optimism-integration.git
cd optimism-integration
./up.sh

# in other terminal window run this project
yarn build
yarn test-e2e  # runs unit tests

Development

Run yarn test:fix to run linting in fix mode, auto-formatting and unit tests.

Running yarn test makes sure that contracts are compiled. Running yarn test-e2e doesn't.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 80.3%
  • Solidity 17.8%
  • JavaScript 1.9%