-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LM Optimism L1 to L2 bridge interface (#840)
This PR adds the Optimism bridge interface for L1 to L2 transfers. Some important things to note: - The Optimism L1 bridge adapter increments a nonce with each transfer and each time `sendERC20` is called. This nonce is included in multiple events throughout the transfer's lifecycle and is how we "match" and link events together to confirm they've reached the various states. - The `GetTransfers()` function makes use of this nonce and implements the matching logic to link these 3 events together and partition transfers into categories: - L1's LiquidityManager `LiquidityTransferred.bridgeReturnData`, which should equal - OP's StandardBridge event `ERC20BridgeFinalized.extraData` which should equal - L2's LiquidityManager `LiquidityTransferred.bridgeSpecificData` - See the `TODO: Applying the 1.2x gas...` comment on how we should think about adjusting the gas limit appropriately to account for how OP's native bridge dynamically burns gas
- Loading branch information
1 parent
2b4df02
commit 3211e83
Showing
35 changed files
with
3,646 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
contracts/src/v0.8/liquiditymanager/interfaces/optimism/IOptimismL1StandardBridge.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copied from https://github.com/ethereum-optimism/optimism/blob/f707883038d527cbf1e9f8ea513fe33255deadbc/packages/contracts-bedrock/src/L1/L1StandardBridge.sol | ||
pragma solidity ^0.8.0; | ||
|
||
interface IOptimismL1StandardBridge { | ||
/// @custom:legacy | ||
/// @notice Deposits some amount of ETH into a target account on L2. | ||
/// Note that if ETH is sent to a contract on L2 and the call fails, then that ETH will | ||
/// be locked in the L2StandardBridge. ETH may be recoverable if the call can be | ||
/// successfully replayed by increasing the amount of gas supplied to the call. If the | ||
/// call will fail for any amount of gas, then the ETH will be locked permanently. | ||
/// @param _to Address of the recipient on L2. | ||
/// @param _minGasLimit Minimum gas limit for the deposit message on L2. | ||
/// @param _extraData Optional data to forward to L2. | ||
/// Data supplied here will not be used to execute any code on L2 and is | ||
/// only emitted as extra data for the convenience of off-chain tooling. | ||
function depositETHTo(address _to, uint32 _minGasLimit, bytes calldata _extraData) external payable; | ||
} |
40 changes: 40 additions & 0 deletions
40
contracts/src/v0.8/liquiditymanager/interfaces/optimism/IOptimismStandardBridge.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: MIT | ||
// Copied from https://github.com/ethereum-optimism/optimism/blob/f707883038d527cbf1e9f8ea513fe33255deadbc/packages/contracts-bedrock/src/universal/StandardBridge.sol#L88 | ||
pragma solidity ^0.8.0; | ||
|
||
interface IOptimismStandardBridge { | ||
/// @notice Emitted when an ERC20 bridge is finalized on this chain. | ||
/// @param localToken Address of the ERC20 on this chain. | ||
/// @param remoteToken Address of the ERC20 on the remote chain. | ||
/// @param from Address of the sender. | ||
/// @param to Address of the receiver. | ||
/// @param amount Amount of the ERC20 sent. | ||
/// @param extraData Extra data sent with the transaction. | ||
event ERC20BridgeFinalized( | ||
address indexed localToken, | ||
address indexed remoteToken, | ||
address indexed from, | ||
address to, | ||
uint256 amount, | ||
bytes extraData | ||
); | ||
|
||
/// @notice Finalizes an ERC20 bridge on this chain. Can only be triggered by the other | ||
/// StandardBridge contract on the remote chain. | ||
/// @param _localToken Address of the ERC20 on this chain. | ||
/// @param _remoteToken Address of the corresponding token on the remote chain. | ||
/// @param _from Address of the sender. | ||
/// @param _to Address of the receiver. | ||
/// @param _amount Amount of the ERC20 being bridged. | ||
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will | ||
/// not be triggered with this data, but it will be emitted and can be used | ||
/// to identify the transaction. | ||
function finalizeBridgeERC20( | ||
address _localToken, | ||
address _remoteToken, | ||
address _from, | ||
address _to, | ||
uint256 _amount, | ||
bytes calldata _extraData | ||
) external; | ||
} |
16 changes: 15 additions & 1 deletion
16
...iditymanager/generated/optimism_cross_domain_messenger/optimism_cross_domain_messenger.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
173 changes: 173 additions & 0 deletions
173
...ers/liquiditymanager/generated/optimism_l1_standard_bridge/optimism_l1_standard_bridge.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.