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

fix(BlastAdapter): Bridging DAI uses BlastBridge which doesn't contain depositERC20To #518

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions contracts/chain-adapters/Blast_Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,37 @@
// @dev Use local modified CrossDomainEnabled contract instead of one exported by eth-optimism because we need
// this contract's state variables to be `immutable` because of the delegateCall call.
import "./CrossDomainEnabled.sol";
import "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol";
import "@eth-optimism/contracts/L1/messaging/IL1ERC20Bridge.sol";
import { IL1StandardBridge } from "@eth-optimism/contracts/L1/messaging/IL1StandardBridge.sol";

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

import "../libraries/CircleCCTPAdapter.sol";
import "../external/interfaces/CCTPInterfaces.sol";

interface IL1ERC20Bridge {
/// @notice Sends ERC20 tokens to a receiver's address on the other chain. Note that if the
/// ERC20 token on the other chain does not recognize the local token as the correct
/// pair token, the ERC20 bridge will fail and the tokens will be returned to sender on
/// this chain.
/// @param _localToken Address of the ERC20 on this chain.
/// @param _remoteToken Address of the corresponding token on the remote chain.
/// @param _to Address of the receiver.
/// @param _amount Amount of local tokens to deposit.
/// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
/// @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 bridgeERC20To(
address _localToken,
address _remoteToken,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;
}

/**
* @notice Contract containing logic to send messages from L1 to Blast. This is a modified version of the Optimism adapter
* that excludes the custom bridging logic. It differs from the Base Adapter in that it uses a special
Expand All @@ -25,15 +47,15 @@
// solhint-disable-next-line contract-name-camelcase
contract Blast_Adapter is CrossDomainEnabled, AdapterInterface, CircleCCTPAdapter {
using SafeERC20 for IERC20;
uint32 public immutable L2_GAS_LIMIT; // 200,000 is a reasonable default.

Check warning on line 50 in contracts/chain-adapters/Blast_Adapter.sol

View workflow job for this annotation

GitHub Actions / Solhint (16)

Variable name must be in mixedCase

WETH9Interface public immutable L1_WETH;

Check warning on line 52 in contracts/chain-adapters/Blast_Adapter.sol

View workflow job for this annotation

GitHub Actions / Solhint (16)

Variable name must be in mixedCase

IL1StandardBridge public immutable L1_STANDARD_BRIDGE;
IL1StandardBridge public immutable L1_STANDARD_BRIDGE; // 0x697402166Fbf2F22E970df8a6486Ef171dbfc524

Check warning on line 54 in contracts/chain-adapters/Blast_Adapter.sol

View workflow job for this annotation

GitHub Actions / Solhint (16)

Variable name must be in mixedCase

// Bridge used to get yielding version of ERC20's on L2.
IL1ERC20Bridge public immutable L1_BLAST_BRIDGE; // 0x3a05E5d33d7Ab3864D53aaEc93c8301C1Fa49115 on mainnet.

Check warning on line 57 in contracts/chain-adapters/Blast_Adapter.sol

View workflow job for this annotation

GitHub Actions / Solhint (16)

Variable name must be in mixedCase
address public immutable L1_DAI; // 0x6B175474E89094C44Da98b954EedeAC495271d0F on mainnet.

Check warning on line 58 in contracts/chain-adapters/Blast_Adapter.sol

View workflow job for this annotation

GitHub Actions / Solhint (16)

Variable name must be in mixedCase

/**
* @notice Constructs new Adapter.
Expand All @@ -49,7 +71,7 @@
IL1StandardBridge _l1StandardBridge,
IERC20 _l1Usdc,
ITokenMessenger _cctpTokenMessenger,
IL1StandardBridge l1BlastBridge,
IL1ERC20Bridge l1BlastBridge,
address l1Dai,
uint32 l2GasLimit
) CrossDomainEnabled(_crossDomainMessenger) CircleCCTPAdapter(_l1Usdc, _cctpTokenMessenger, CircleDomainIds.Base) {
Expand Down Expand Up @@ -95,7 +117,7 @@
// Check if this token is DAI, then use the L1 Blast Bridge
else if (l1Token == L1_DAI) {
IERC20(l1Token).safeIncreaseAllowance(address(L1_BLAST_BRIDGE), amount);
IL1ERC20Bridge(L1_BLAST_BRIDGE).depositERC20To(l1Token, l2Token, to, amount, L2_GAS_LIMIT, "");
IL1ERC20Bridge(L1_BLAST_BRIDGE).bridgeERC20To(l1Token, l2Token, to, amount, L2_GAS_LIMIT, "");
} else {
IL1StandardBridge _l1StandardBridge = L1_STANDARD_BRIDGE;

Expand Down
Loading