Skip to content

Commit 421cf9b

Browse files
committed
fix: amount per token
1 parent 4409111 commit 421cf9b

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/FeeCollector.sol

+13-15
Original file line numberDiff line numberDiff line change
@@ -12,33 +12,31 @@ contract FeeCollector is Owned, IFeeCollector {
1212

1313
error CallFailed();
1414

15-
struct Call {
16-
address to;
17-
bytes data;
18-
}
19-
2015
address public feeRecipient;
21-
uin256 public feeTokenAmount;
16+
/// @notice the amount of fee token that must be paid per token
17+
uint256 public feeTokenAmount;
18+
/// @notice the token to receive fees in
2219
ERC20 private immutable feeToken;
2320

2421
constructor(address _owner, address _feeToken, uint256 _feeTokenAmount) Owned(_owner) {
2522
feeToken = ERC20(_feeToken);
2623
feeTokenAmount = _feeTokenAmount;
2724
}
2825

29-
/// @notice allow anyone to make any arbitrary calls from this address
30-
/// @dev as long as they pay `feeTokenAmount` to the `feeRecipient`
26+
/// @notice allow anyone to take the full balance of any arbitrary tokens
27+
/// @dev as long as they pay `feeTokenAmount` per token taken to the `feeRecipient`
3128
/// this creates a competitive auction as the balances of this contract increase
3229
/// to find the optimal path for the swap
33-
function swapBalances(Call[] calldata calls) external {
34-
for (uint256 i = 0; i < calls.length; i++) {
35-
(bool success, ) = calls[i].to.call(calls[i].data);
36-
if (!success) {
37-
revert CallFailed();
38-
}
30+
function swapBalances(ERC20[] memory tokens, bytes calldata call) external {
31+
for (uint256 i = 0; i < tokens.length; i++) {
32+
tokens[i].safeTransferFrom(msg.sender, address(this), tokens[i].balanceOf(address(this)));
33+
}
34+
(bool success,) = msg.sender.call(call);
35+
if (!success) {
36+
revert CallFailed();
3937
}
4038

41-
feeToken.safeTransferFrom(msg.sender, feeRecipient, feeTokenAmount);
39+
feeToken.safeTransferFrom(msg.sender, feeRecipient, feeTokenAmount * tokens.length);
4240
}
4341

4442
function setFeeRecipient(address _feeRecipient) external onlyOwner {

0 commit comments

Comments
 (0)