Skip to content
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
42 changes: 23 additions & 19 deletions contracts/chain-adapters/ZkStack_CustomGasToken_Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface, CircleCCTPAdapter {
uint256 amount,
address to
) external payable override {
// The Hub Pool will always bridge via CCTP to a ZkStack network if CCTP is enabled for that network. Therefore, we can short-circuit ZkStack-specific logic
// like pulling custom gas or getting the shared bridge address if CCTP is enabled and we are bridging USDC.
if (l1Token == address(usdcToken) && _isCCTPEnabled()) {
_transferUsdc(to, amount);
emit TokensRelayed(l1Token, l2Token, amount, to);
return;
}
// A bypass proxy seems to no longer be needed to avoid deposit limits. The tracking of these limits seems to be deprecated.
// See: https://github.com/matter-labs/era-contracts/blob/bce4b2d0f34bd87f1aaadd291772935afb1c3bd6/l1-contracts/contracts/bridge/L1ERC20Bridge.sol#L54-L55
uint256 txBaseCost = _pullCustomGas(L2_GAS_LIMIT);
Expand Down Expand Up @@ -224,25 +231,22 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface, CircleCCTPAdapter {
})
);
} else if (l1Token == address(usdcToken)) {
if (_isCCTPEnabled()) {
_transferUsdc(to, amount);
} else {
IERC20(CUSTOM_GAS_TOKEN).forceApprove(USDC_SHARED_BRIDGE, txBaseCost);
IERC20(l1Token).forceApprove(USDC_SHARED_BRIDGE, amount);
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
mintValue: txBaseCost,
l2Value: 0,
l2GasLimit: L2_GAS_LIMIT,
l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,
refundRecipient: L2_REFUND_ADDRESS,
secondBridgeAddress: USDC_SHARED_BRIDGE,
secondBridgeValue: 0,
secondBridgeCalldata: _secondBridgeCalldata(to, l1Token, amount)
})
);
}
// Since we already checked if we are bridging USDC via CCTP, if this conditional is hit, then we must be bridging USDC via the `USDC_SHARED_BRIDGE`.
IERC20(CUSTOM_GAS_TOKEN).forceApprove(USDC_SHARED_BRIDGE, txBaseCost);
IERC20(l1Token).forceApprove(USDC_SHARED_BRIDGE, amount);
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
mintValue: txBaseCost,
l2Value: 0,
l2GasLimit: L2_GAS_LIMIT,
l2GasPerPubdataByteLimit: L1_GAS_TO_L2_GAS_PER_PUB_DATA_LIMIT,
refundRecipient: L2_REFUND_ADDRESS,
secondBridgeAddress: USDC_SHARED_BRIDGE,
secondBridgeValue: 0,
secondBridgeCalldata: _secondBridgeCalldata(to, l1Token, amount)
})
);
} else {
// An ERC20 that is not WETH and not the custom gas token.
IERC20(CUSTOM_GAS_TOKEN).forceApprove(sharedBridge, txBaseCost);
Expand Down
Loading