@@ -70,19 +70,15 @@ contract Passage {
70
70
emit Enter (rollupChainId, token, rollupRecipient, amount);
71
71
}
72
72
73
- /// @notice Allows the admin to withdraw ETH from the contract.
74
- /// @dev Only the admin can call this function.
75
- function withdrawEth (address recipient , uint256 amount ) external {
76
- if (msg .sender != withdrawalAdmin) revert OnlyWithdrawalAdmin ();
77
- payable (recipient).transfer (amount);
78
- emit Withdrawal (address (0 ), recipient, amount);
79
- }
80
-
81
- /// @notice Allows the admin to withdraw ERC20 tokens from the contract.
73
+ /// @notice Allows the admin to withdraw ETH or ERC20 tokens from the contract.
82
74
/// @dev Only the admin can call this function.
83
75
function withdraw (address token , address recipient , uint256 amount ) external {
84
76
if (msg .sender != withdrawalAdmin) revert OnlyWithdrawalAdmin ();
85
- IERC20 (token).transfer (recipient, amount);
77
+ if (token == address (0 )) {
78
+ payable (recipient).transfer (amount);
79
+ } else {
80
+ IERC20 (token).transfer (recipient, amount);
81
+ }
86
82
emit Withdrawal (token, recipient, amount);
87
83
}
88
84
@@ -97,20 +93,15 @@ contract Passage {
97
93
/// Corresponds to recipient_H in the RollupPassage contract.
98
94
/// @param amount - The amount of the token to be transferred to the recipient.
99
95
/// Corresponds to one or more amountOutMinimum_H in the RollupPassage contract.
100
- function fulfillExit (uint256 rollupChainId , address token , address recipient , uint256 amount ) external {
101
- IERC20 (token).transferFrom (msg .sender , recipient, amount);
96
+ function fulfillExit (uint256 rollupChainId , address token , address recipient , uint256 amount ) external payable {
97
+ if (token == address (0 )) {
98
+ require (amount == msg .value );
99
+ payable (recipient).transfer (msg .value );
100
+ } else {
101
+ IERC20 (token).transferFrom (msg .sender , recipient, amount);
102
+ }
102
103
emit ExitFulfilled (rollupChainId, token, recipient, amount);
103
104
}
104
-
105
- /// @notice Fulfill a rollup Exit order
106
- /// The user calls `exit` on Rollup; the Builder calls `fulfillExit` on Host.
107
- /// @custom:emits ExitFilled
108
- /// @param recipient - The recipient of the token on host.
109
- /// Corresponds to recipient_H in the RollupPassage contract.
110
- function fulfillExitEth (uint256 rollupChainId , address recipient ) external payable {
111
- payable (recipient).transfer (msg .value );
112
- emit ExitFulfilled (rollupChainId, address (0 ), recipient, msg .value );
113
- }
114
105
}
115
106
116
107
/// @notice A contract deployed to the Rollup that allows users to atomically exchange tokens on the Rollup for tokens on the Host.
@@ -161,57 +152,35 @@ contract RollupPassage {
161
152
uint256 deadline ,
162
153
uint256 amountIn_RU ,
163
154
uint256 amountOutMinimum_H
164
- ) external {
155
+ ) external payable {
165
156
// check that the deadline hasn't passed
166
157
if (block .timestamp >= deadline) revert OrderExpired ();
167
158
168
- IERC20 (tokenIn_RU).transferFrom (msg .sender , address (this ), amountIn_RU);
159
+ if (tokenIn_RU == address (0 )) {
160
+ require (amountIn_RU == msg .value );
161
+ } else {
162
+ IERC20 (tokenIn_RU).transferFrom (msg .sender , address (this ), amountIn_RU);
163
+ }
169
164
170
165
// emit the exit event
171
166
emit Exit (tokenIn_RU, tokenOut_H, recipient_H, deadline, amountIn_RU, amountOutMinimum_H);
172
167
}
173
168
174
- /// @notice Request exit the rollup with native Ether.
175
- /// @dev See `exit` docs above for dev details on exits.
176
- /// @dev tokenIn_RU is set to address(0), native rollup Ether.
177
- /// amountIn_RU is set to msg.value.
178
- /// @param tokenOut_H - The address of the token the user expects to receive on host.
179
- /// @param recipient_H - The address of the recipient of tokenOut_H on host.
180
- /// @param deadline - The deadline by which the exit order must be fulfilled.
181
- /// @param amountOutMinimum_H - The minimum amount of tokenOut_H the user expects to receive on host.
182
- /// @custom:reverts Expired if the deadline has passed.
183
- /// @custom:emits Exit if the exit transaction succeeds.
184
- function exitEth (address tokenOut_H , address recipient_H , uint256 deadline , uint256 amountOutMinimum_H )
185
- external
186
- payable
187
- {
188
- // check that the deadline hasn't passed
189
- if (block .timestamp >= deadline) revert OrderExpired ();
190
-
191
- // emit the exit event
192
- emit Exit (address (0 ), tokenOut_H, recipient_H, deadline, msg .value , amountOutMinimum_H);
193
- }
194
-
195
169
/// @notice Transfer the entire balance of ERC20 tokens to the recipient.
196
- /// @dev Called by the Builder within the same block as users' `exit ` transactions
170
+ /// @dev Called by the Builder within the same block as users' `swap ` transactions
197
171
/// to claim the amounts of `tokenIn`.
198
172
/// @dev Builder MUST ensure that no other account calls `sweep` before them.
199
173
/// @param token - The token to transfer.
200
174
/// @param recipient - The address to receive the tokens.
201
175
function sweep (address token , address recipient ) public {
202
- uint256 balance = IERC20 (token).balanceOf (address (this ));
203
- IERC20 (token).transfer (recipient, balance);
176
+ uint256 balance;
177
+ if (token == address (0 )) {
178
+ balance = address (this ).balance;
179
+ payable (recipient).transfer (balance);
180
+ } else {
181
+ balance = IERC20 (token).balanceOf (address (this ));
182
+ IERC20 (token).transfer (recipient, balance);
183
+ }
204
184
emit Sweep (token, recipient, balance);
205
185
}
206
-
207
- /// @notice Transfer the entire balance of native Ether to the recipient.
208
- /// @dev Called by the Builder within the same block as users' `exit` transactions
209
- /// to claim the amounts of native Ether.
210
- /// @dev Builder MUST ensure that no other account calls `sweepETH` before them.
211
- /// @param recipient - The address to receive the native Ether.
212
- function sweepEth (address payable recipient ) public {
213
- uint256 balance = address (this ).balance;
214
- recipient.transfer (balance);
215
- emit Sweep (address (0 ), recipient, balance);
216
- }
217
186
}
0 commit comments