Skip to content

Commit a2afefe

Browse files
authored
refactor: move all Arbitrum interfaces to a single location (#624)
* refactor: move all Arbitrum interfaces to a single location Signed-off-by: bennett <[email protected]> --------- Signed-off-by: bennett <[email protected]>
1 parent 80f20a3 commit a2afefe

File tree

4 files changed

+224
-246
lines changed

4 files changed

+224
-246
lines changed

contracts/Arbitrum_SpokePool.sol

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,7 @@ pragma solidity ^0.8.19;
66

77
import "./SpokePool.sol";
88
import "./libraries/CircleCCTPAdapter.sol";
9-
10-
interface StandardBridgeLike {
11-
function outboundTransfer(
12-
address _l1Token,
13-
address _to,
14-
uint256 _amount,
15-
bytes calldata _data
16-
) external payable returns (bytes memory);
17-
}
9+
import { ArbitrumL2ERC20GatewayLike } from "./interfaces/ArbitrumBridge.sol";
1810

1911
/**
2012
* @notice AVM specific SpokePool. Uses AVM cross-domain-enabled logic to implement admin only access to functions.
@@ -100,7 +92,7 @@ contract Arbitrum_SpokePool is SpokePool, CircleCCTPAdapter {
10092
address ethereumTokenToBridge = whitelistedTokens[l2TokenAddress];
10193
require(ethereumTokenToBridge != address(0), "Uninitialized mainnet token");
10294
//slither-disable-next-line unused-return
103-
StandardBridgeLike(l2GatewayRouter).outboundTransfer(
95+
ArbitrumL2ERC20GatewayLike(l2GatewayRouter).outboundTransfer(
10496
ethereumTokenToBridge, // _l1Token. Address of the L1 token to bridge over.
10597
hubPool, // _to. Withdraw, over the bridge, to the l1 hub pool contract.
10698
amountToReturn, // _amount.

contracts/chain-adapters/Arbitrum_Adapter.sol

Lines changed: 1 addition & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -7,130 +7,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
77
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
88
import "../external/interfaces/CCTPInterfaces.sol";
99
import "../libraries/CircleCCTPAdapter.sol";
10-
11-
/**
12-
* @notice Interface for Arbitrum's L1 Inbox contract used to send messages to Arbitrum.
13-
* @custom:security-contact [email protected]
14-
*/
15-
interface ArbitrumL1InboxLike {
16-
/**
17-
* @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
18-
* @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
19-
* @dev Caller must set msg.value equal to at least `maxSubmissionCost + maxGas * gasPriceBid`.
20-
* all msg.value will deposited to callValueRefundAddress on L2
21-
* @dev More details can be found here: https://developer.arbitrum.io/arbos/l1-to-l2-messaging
22-
* @param to destination L2 contract address
23-
* @param l2CallValue call value for retryable L2 message
24-
* @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
25-
* @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance
26-
* @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
27-
* @param gasLimit Max gas deducted from user's L2 balance to cover L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
28-
* @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
29-
* @param data ABI encoded data of L2 message
30-
* @return unique message number of the retryable transaction
31-
*/
32-
function createRetryableTicket(
33-
address to,
34-
uint256 l2CallValue,
35-
uint256 maxSubmissionCost,
36-
address excessFeeRefundAddress,
37-
address callValueRefundAddress,
38-
uint256 gasLimit,
39-
uint256 maxFeePerGas,
40-
bytes calldata data
41-
) external payable returns (uint256);
42-
43-
/**
44-
* @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
45-
* @dev Same as createRetryableTicket, but does not guarantee that submission will succeed by requiring the needed
46-
* funds come from the deposit alone, rather than falling back on the user's L2 balance
47-
* @dev Advanced usage only (does not rewrite aliases for excessFeeRefundAddress and callValueRefundAddress).
48-
* createRetryableTicket method is the recommended standard.
49-
* @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
50-
* @param to destination L2 contract address
51-
* @param l2CallValue call value for retryable L2 message
52-
* @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
53-
* @param excessFeeRefundAddress gasLimit x maxFeePerGas - execution cost gets credited here on L2 balance
54-
* @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled
55-
* @param gasLimit Max gas deducted from user's L2 balance to cover L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
56-
* @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
57-
* @param data ABI encoded data of L2 message
58-
* @return unique message number of the retryable transaction
59-
*/
60-
function unsafeCreateRetryableTicket(
61-
address to,
62-
uint256 l2CallValue,
63-
uint256 maxSubmissionCost,
64-
address excessFeeRefundAddress,
65-
address callValueRefundAddress,
66-
uint256 gasLimit,
67-
uint256 maxFeePerGas,
68-
bytes calldata data
69-
) external payable returns (uint256);
70-
}
71-
72-
/**
73-
* @notice Layer 1 Gateway contract for bridging standard ERC20s to Arbitrum.
74-
*/
75-
interface ArbitrumL1ERC20GatewayLike {
76-
/**
77-
* @notice Deprecated in favor of outboundTransferCustomRefund but still used in custom bridges
78-
* like the DAI bridge.
79-
* @dev Refunded to aliased L2 address of sender if sender has code on L1, otherwise to to sender's EOA on L2.
80-
* @param _l1Token L1 address of ERC20
81-
* @param _to Account to be credited with the tokens in the L2 (can be the user's L2 account or a contract),
82-
* not subject to L2 aliasing. This account, or its L2 alias if it have code in L1, will also be able to
83-
* cancel the retryable ticket and receive callvalue refund
84-
* @param _amount Token Amount
85-
* @param _maxGas Max gas deducted from user's L2 balance to cover L2 execution
86-
* @param _gasPriceBid Gas price for L2 execution
87-
* @param _data encoded data from router and user
88-
* @return res abi encoded inbox sequence number
89-
*/
90-
function outboundTransfer(
91-
address _l1Token,
92-
address _to,
93-
uint256 _amount,
94-
uint256 _maxGas,
95-
uint256 _gasPriceBid,
96-
bytes calldata _data
97-
) external payable returns (bytes memory);
98-
99-
/**
100-
* @notice Deposit ERC20 token from Ethereum into Arbitrum.
101-
* @dev L2 address alias will not be applied to the following types of addresses on L1:
102-
* - an externally-owned account
103-
* - a contract in construction
104-
* - an address where a contract will be created
105-
* - an address where a contract lived, but was destroyed
106-
* @param _l1Token L1 address of ERC20
107-
* @param _refundTo Account, or its L2 alias if it have code in L1, to be credited with excess gas refund in L2
108-
* @param _to Account to be credited with the tokens in the L2 (can be the user's L2 account or a contract),
109-
* not subject to L2 aliasing. This account, or its L2 alias if it have code in L1, will also be able to
110-
* cancel the retryable ticket and receive callvalue refund
111-
* @param _amount Token Amount
112-
* @param _maxGas Max gas deducted from user's L2 balance to cover L2 execution
113-
* @param _gasPriceBid Gas price for L2 execution
114-
* @param _data encoded data from router and user
115-
* @return res abi encoded inbox sequence number
116-
*/
117-
function outboundTransferCustomRefund(
118-
address _l1Token,
119-
address _refundTo,
120-
address _to,
121-
uint256 _amount,
122-
uint256 _maxGas,
123-
uint256 _gasPriceBid,
124-
bytes calldata _data
125-
) external payable returns (bytes memory);
126-
127-
/**
128-
* @notice get ERC20 gateway for token.
129-
* @param _token ERC20 address.
130-
* @return address of ERC20 gateway.
131-
*/
132-
function getGateway(address _token) external view returns (address);
133-
}
10+
import { ArbitrumInboxLike as ArbitrumL1InboxLike, ArbitrumL1ERC20GatewayLike } from "../interfaces/ArbitrumBridge.sol";
13411

13512
/**
13613
* @notice Contract containing logic to send messages from L1 to Arbitrum.

contracts/chain-adapters/Arbitrum_CustomGasToken_Adapter.sol

Lines changed: 1 addition & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
77
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
88
import { ITokenMessenger as ICCTPTokenMessenger } from "../external/interfaces/CCTPInterfaces.sol";
99
import { CircleCCTPAdapter, CircleDomainIds } from "../libraries/CircleCCTPAdapter.sol";
10+
import { ArbitrumERC20Bridge as ArbitrumL1ERC20Bridge, ArbitrumCustomGasTokenInbox as ArbitrumL1InboxLike, ArbitrumL1ERC20GatewayLike } from "../interfaces/ArbitrumBridge.sol";
1011

1112
/**
1213
* @notice Interface for funder contract that this contract pulls from to pay for relayMessage()/relayTokens()
@@ -23,118 +24,6 @@ interface FunderInterface {
2324
function withdraw(IERC20 token, uint256 amount) external;
2425
}
2526

26-
/**
27-
* @title Staging ground for incoming and outgoing messages
28-
* @notice Unlike the standard Eth bridge, native token bridge escrows the custom ERC20 token which is
29-
* used as native currency on L2.
30-
* @dev Fees are paid in this token. There are certain restrictions on the native token:
31-
* - The token can't be rebasing or have a transfer fee
32-
* - The token must only be transferrable via a call to the token address itself
33-
* - The token must only be able to set allowance via a call to the token address itself
34-
* - The token must not have a callback on transfer, and more generally a user must not be able to make a transfer to themselves revert
35-
* - The token must have a max of 2^256 - 1 wei total supply unscaled
36-
* - The token must have a max of 2^256 - 1 wei total supply when scaled to 18 decimals
37-
*/
38-
interface ArbitrumL1ERC20Bridge {
39-
/**
40-
* @notice Returns token that is escrowed in bridge on L1 side and minted on L2 as native currency.
41-
* @dev This function doesn't exist on the generic Bridge interface.
42-
* @return address of the native token.
43-
*/
44-
function nativeToken() external view returns (address);
45-
46-
/**
47-
* @dev number of decimals used by the native token
48-
* This is set on bridge initialization using nativeToken.decimals()
49-
* If the token does not have decimals() method, we assume it have 0 decimals
50-
*/
51-
function nativeTokenDecimals() external view returns (uint8);
52-
}
53-
54-
/**
55-
* @title Inbox for user and contract originated messages
56-
* @notice Messages created via this inbox are enqueued in the delayed accumulator
57-
* to await inclusion in the SequencerInbox
58-
*/
59-
interface ArbitrumL1InboxLike {
60-
/**
61-
* @dev we only use this function to check the native token used by the bridge, so we hardcode the interface
62-
* to return an ArbitrumL1ERC20Bridge instead of a more generic Bridge interface.
63-
* @return address of the bridge.
64-
*/
65-
function bridge() external view returns (ArbitrumL1ERC20Bridge);
66-
67-
/**
68-
* @notice Put a message in the L2 inbox that can be reexecuted for some fixed amount of time if it reverts
69-
* @notice Overloads the `createRetryableTicket` function but is not payable, and should only be called when paying
70-
* for L1 to L2 message using a custom gas token.
71-
* @dev all tokenTotalFeeAmount will be deposited to callValueRefundAddress on L2
72-
* @dev Gas limit and maxFeePerGas should not be set to 1 as that is used to trigger the RetryableData error
73-
* @dev In case of native token having non-18 decimals: tokenTotalFeeAmount is denominated in native token's decimals. All other value params - l2CallValue, maxSubmissionCost and maxFeePerGas are denominated in child chain's native 18 decimals.
74-
* @param to destination L2 contract address
75-
* @param l2CallValue call value for retryable L2 message
76-
* @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee
77-
* @param excessFeeRefundAddress the address which receives the difference between execution fee paid and the actual execution cost. In case this address is a contract, funds will be received in its alias on L2.
78-
* @param callValueRefundAddress l2Callvalue gets credited here on L2 if retryable txn times out or gets cancelled. In case this address is a contract, funds will be received in its alias on L2.
79-
* @param gasLimit Max gas deducted from user's L2 balance to cover L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
80-
* @param maxFeePerGas price bid for L2 execution. Should not be set to 1 (magic value used to trigger the RetryableData error)
81-
* @param tokenTotalFeeAmount amount of fees to be deposited in native token to cover for retryable ticket cost
82-
* @param data ABI encoded data of L2 message
83-
* @return unique message number of the retryable transaction
84-
*/
85-
function createRetryableTicket(
86-
address to,
87-
uint256 l2CallValue,
88-
uint256 maxSubmissionCost,
89-
address excessFeeRefundAddress,
90-
address callValueRefundAddress,
91-
uint256 gasLimit,
92-
uint256 maxFeePerGas,
93-
uint256 tokenTotalFeeAmount,
94-
bytes calldata data
95-
) external returns (uint256);
96-
}
97-
98-
/**
99-
* @notice Layer 1 Gateway contract for bridging standard ERC20s to Arbitrum.
100-
*/
101-
interface ArbitrumL1ERC20GatewayLike {
102-
/**
103-
* @notice Deposit ERC20 token from Ethereum into Arbitrum.
104-
* @dev L2 address alias will not be applied to the following types of addresses on L1:
105-
* - an externally-owned account
106-
* - a contract in construction
107-
* - an address where a contract will be created
108-
* - an address where a contract lived, but was destroyed
109-
* @param _l1Token L1 address of ERC20
110-
* @param _refundTo Account, or its L2 alias if it have code in L1, to be credited with excess gas refund in L2
111-
* @param _to Account to be credited with the tokens in the L2 (can be the user's L2 account or a contract),
112-
* not subject to L2 aliasing. This account, or its L2 alias if it have code in L1, will also be able to
113-
* cancel the retryable ticket and receive callvalue refund
114-
* @param _amount Token Amount
115-
* @param _maxGas Max gas deducted from user's L2 balance to cover L2 execution
116-
* @param _gasPriceBid Gas price for L2 execution
117-
* @param _data encoded data from router and user
118-
* @return res abi encoded inbox sequence number
119-
*/
120-
function outboundTransferCustomRefund(
121-
address _l1Token,
122-
address _refundTo,
123-
address _to,
124-
uint256 _amount,
125-
uint256 _maxGas,
126-
uint256 _gasPriceBid,
127-
bytes calldata _data
128-
) external payable returns (bytes memory);
129-
130-
/**
131-
* @notice get ERC20 gateway for token.
132-
* @param _token ERC20 address.
133-
* @return address of ERC20 gateway.
134-
*/
135-
function getGateway(address _token) external view returns (address);
136-
}
137-
13827
/**
13928
* @notice Contract containing logic to send messages from L1 to Arbitrum.
14029
* @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be

0 commit comments

Comments
 (0)