Skip to content

Commit

Permalink
add to (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-carroll authored Aug 1, 2024
1 parent 37f386a commit 6a1dc9a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
18 changes: 9 additions & 9 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
OrderOriginPermit2Test:test_fillPermit2() (gas: 225289)
OrderOriginPermit2Test:test_fillPermit2_multi() (gas: 1019134)
OrderOriginPermit2Test:test_initiatePermit2() (gas: 235752)
OrderOriginPermit2Test:test_initiatePermit2_multi() (gas: 989274)
OrdersTest:test_fill_ERC20() (gas: 70537)
OrdersTest:test_fill_ETH() (gas: 68498)
OrdersTest:test_fill_both() (gas: 166773)
OrdersTest:test_fill_multiETH() (gas: 132119)
OrdersTest:test_fill_underflowETH() (gas: 115403)
OrderOriginPermit2Test:test_initiatePermit2() (gas: 235774)
OrderOriginPermit2Test:test_initiatePermit2_multi() (gas: 992096)
OrdersTest:test_fill_ERC20() (gas: 70559)
OrdersTest:test_fill_ETH() (gas: 68520)
OrdersTest:test_fill_both() (gas: 166795)
OrdersTest:test_fill_multiETH() (gas: 132141)
OrdersTest:test_fill_underflowETH() (gas: 115425)
OrdersTest:test_initiate_ERC20() (gas: 81636)
OrdersTest:test_initiate_ETH() (gas: 45150)
OrdersTest:test_initiate_both() (gas: 118911)
OrdersTest:test_initiate_multiERC20() (gas: 722642)
OrdersTest:test_initiate_multiETH() (gas: 75538)
OrdersTest:test_orderExpired() (gas: 28106)
OrdersTest:test_sweepERC20() (gas: 60491)
OrdersTest:test_sweepETH() (gas: 82186)
OrdersTest:test_sweepERC20() (gas: 59721)
OrdersTest:test_sweepETH() (gas: 82348)
OrdersTest:test_underflowETH() (gas: 63690)
PassagePermit2Test:test_disallowedEnterPermit2() (gas: 699630)
PassagePermit2Test:test_enterTokenPermit2() (gas: 145449)
Expand Down
11 changes: 4 additions & 7 deletions src/orders/OrderOrigin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,14 @@ abstract contract OrderOrigin is IOrders, OrdersPermit2 {
/// @param token - The token to transfer.
/// @custom:emits Sweep
/// @custom:reverts OnlyBuilder if called by non-block builder
function sweep(address recipient, address token) external {
function sweep(address recipient, address token, uint256 amount) external {
// send ETH or tokens
uint256 balance;
if (token == address(0)) {
balance = address(this).balance;
payable(recipient).transfer(balance);
payable(recipient).transfer(amount);
} else {
balance = IERC20(token).balanceOf(address(this));
IERC20(token).transfer(recipient, balance);
IERC20(token).transfer(recipient, amount);
}
emit Sweep(recipient, token, balance);
emit Sweep(recipient, token, amount);
}

/// @notice Transfer the Order inputs to this contract, where they can be collected by the Order filler via `sweep`.
Expand Down
4 changes: 2 additions & 2 deletions test/Orders.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ contract OrdersTest is Test {
// sweep ETH
vm.expectEmit();
emit Sweep(recipient, address(0), amount);
target.sweep(recipient, address(0));
target.sweep(recipient, address(0), amount);

assertEq(recipient.balance, amount);
}
Expand All @@ -173,7 +173,7 @@ contract OrdersTest is Test {
vm.expectEmit();
emit Sweep(recipient, token, amount);
vm.expectCall(token, abi.encodeWithSelector(ERC20.transfer.selector, recipient, amount));
target.sweep(recipient, token);
target.sweep(recipient, token, amount);
}

function test_fill_ETH() public {
Expand Down

0 comments on commit 6a1dc9a

Please sign in to comment.