From 87622d9cc2331ddecac71f611ed07c302fd3eee0 Mon Sep 17 00:00:00 2001 From: Geoffrey Hayes Date: Mon, 11 Mar 2024 03:55:25 -0700 Subject: [PATCH] Standard Bridger This patch adds a simple Legend Script for pushing ERC20 assets over the standard Optimism/Base bridge. The real bridge seems to use a mix of CCIP and CCTP bridges, as well, but this is a good starting point for understanding cross-chain actions. --- src/legend-scripts/src/StandardBridger.sol | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/legend-scripts/src/StandardBridger.sol diff --git a/src/legend-scripts/src/StandardBridger.sol b/src/legend-scripts/src/StandardBridger.sol new file mode 100644 index 00000000..c5f895ea --- /dev/null +++ b/src/legend-scripts/src/StandardBridger.sol @@ -0,0 +1,35 @@ +pragma solidity 0.8.23; + +import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol"; + +interface StandardBridge { + function bridgeERC20To( + address _localToken, + address _remoteToken, + address _to, + uint256 _amount, + uint32 _minGasLimit, + bytes calldata _extraData + ) external; +} + +contract StandardBridger { + StandardBridge immutable bridge; + + constructor(StandardBridge bridge_) { + bridge = bridge_; + } + + /** + * @notice Bridge token over standard bridge. + */ + function bridgeToken(address localToken, + address remoteToken, + address to, + uint256 amount, + uint32 minGasLimit, + bytes calldata extraData) external { + IERC20(localToken).approve(address(bridge), amount); + bridge.bridgeERC20To(localToken, remoteToken, to, amount, minGasLimit, extraData); + } +}