Skip to content

Commit 27b03da

Browse files
committed
fix: sweep only callable by block builder
1 parent 54e6793 commit 27b03da

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Orders.sol

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ abstract contract OrderOrigin {
7575
/// @notice Thrown when an Order is submitted with a deadline that has passed.
7676
error OrderExpired();
7777

78+
/// @notice Thrown when trying to call `sweep` if not the Builder of the block.
79+
error OnlyBuilder();
80+
7881
/// @notice Emitted when an Order is submitted for fulfillment.
7982
event Order(uint256 deadline, Input[] inputs, Output[] outputs);
8083

@@ -123,10 +126,14 @@ abstract contract OrderOrigin {
123126
/// @notice Transfer the entire balance of ERC20 tokens to the recipient.
124127
/// @dev Called by the Builder within the same block as users' `initiate` transactions
125128
/// to claim the `inputs`.
126-
/// @dev Builder MUST ensure that no other account calls `sweep` before them.
129+
/// @dev Builder MUST call `sweep` atomically with `fill` (claim Inputs atomically with sending Outputs).
127130
/// @param recipient - The address to receive the tokens.
128131
/// @param token - The token to transfer.
132+
/// @custom:emits Sweep
133+
/// @custom:reverts OnlyBuilder if called by non-block builder
129134
function sweep(address recipient, address token) public {
135+
if (msg.sender != block.coinbase) revert OnlyBuilder();
136+
// send ETH or tokens
130137
uint256 balance;
131138
if (token == address(0)) {
132139
balance = address(this).balance;

0 commit comments

Comments
 (0)