hop-protocol / contracts

🐰 Hop Protocol v1 smart contracts
https://hop.exchange
238 stars 98 forks source link

contracts: Add ETH support #23

Closed cwhinfrey closed 3 years ago

cwhinfrey commented 3 years ago

Allows the L1_Bridge and L2_Bridge to support ETH directly.

The L1_Bridge implements this using inheritance. Either L1_ETH_Bridge or L1_ERC20_Bridge should be deployed.

The L2_Bridge uses a flag l2CanonicalTokenIsWeth. If set true, the bridge will wrap incoming ETH in WETH and unwrap outgoing WETH to distribute as ETH.

The reason for handling it in two different ways involves a few reasons but it's mostly because we already use inheritance to implement the L2 bridge for arbitrum, optimism, ect. Adding another split in the tree for eth/erc20 would mean we need two L2_Bridge contracts for each network and a complicated inheritance structure to keep the code DRY.

@shanefontaine All broken tests should be fixed by using L1_ERC20_Bridge instead of L1_Bridge and passing in false to the L2_Bridge constructor for l2CanonicalTokenIsWeth. I didn't make these changes to avoid merge conflicts.

cwhinfrey commented 3 years ago

Back to you @shanefontaine