You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
* @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
-
addressto,
34
-
uint256l2CallValue,
35
-
uint256maxSubmissionCost,
36
-
addressexcessFeeRefundAddress,
37
-
addresscallValueRefundAddress,
38
-
uint256gasLimit,
39
-
uint256maxFeePerGas,
40
-
bytescalldatadata
41
-
) externalpayablereturns (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
-
addressto,
62
-
uint256l2CallValue,
63
-
uint256maxSubmissionCost,
64
-
addressexcessFeeRefundAddress,
65
-
addresscallValueRefundAddress,
66
-
uint256gasLimit,
67
-
uint256maxFeePerGas,
68
-
bytescalldatadata
69
-
) externalpayablereturns (uint256);
70
-
}
71
-
72
-
/**
73
-
* @notice Layer 1 Gateway contract for bridging standard ERC20s to Arbitrum.
74
-
*/
75
-
interfaceArbitrumL1ERC20GatewayLike {
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
-
bytescalldata_data
97
-
) externalpayablereturns (bytesmemory);
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
-
bytescalldata_data
125
-
) externalpayablereturns (bytesmemory);
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) externalviewreturns (address);
133
-
}
10
+
import { ArbitrumInboxLike as ArbitrumL1InboxLike, ArbitrumL1ERC20GatewayLike } from"../interfaces/ArbitrumBridge.sol";
134
11
135
12
/**
136
13
* @notice Contract containing logic to send messages from L1 to Arbitrum.
import { ArbitrumERC20Bridge as ArbitrumL1ERC20Bridge, ArbitrumCustomGasTokenInbox as ArbitrumL1InboxLike, ArbitrumL1ERC20GatewayLike } from"../interfaces/ArbitrumBridge.sol";
10
11
11
12
/**
12
13
* @notice Interface for funder contract that this contract pulls from to pay for relayMessage()/relayTokens()
@@ -23,118 +24,6 @@ interface FunderInterface {
23
24
function withdraw(IERC20token, uint256amount) external;
24
25
}
25
26
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
-
interfaceArbitrumL1ERC20Bridge {
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() externalviewreturns (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() externalviewreturns (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
-
interfaceArbitrumL1InboxLike {
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() externalviewreturns (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
-
addressto,
87
-
uint256l2CallValue,
88
-
uint256maxSubmissionCost,
89
-
addressexcessFeeRefundAddress,
90
-
addresscallValueRefundAddress,
91
-
uint256gasLimit,
92
-
uint256maxFeePerGas,
93
-
uint256tokenTotalFeeAmount,
94
-
bytescalldatadata
95
-
) externalreturns (uint256);
96
-
}
97
-
98
-
/**
99
-
* @notice Layer 1 Gateway contract for bridging standard ERC20s to Arbitrum.
100
-
*/
101
-
interfaceArbitrumL1ERC20GatewayLike {
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
-
bytescalldata_data
128
-
) externalpayablereturns (bytesmemory);
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) externalviewreturns (address);
136
-
}
137
-
138
27
/**
139
28
* @notice Contract containing logic to send messages from L1 to Arbitrum.
140
29
* @dev Public functions calling external contracts do not guard against reentrancy because they are expected to be
0 commit comments