@@ -12,33 +12,31 @@ contract FeeCollector is Owned, IFeeCollector {
12
12
13
13
error CallFailed ();
14
14
15
- struct Call {
16
- address to;
17
- bytes data;
18
- }
19
-
20
15
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
22
19
ERC20 private immutable feeToken;
23
20
24
21
constructor (address _owner , address _feeToken , uint256 _feeTokenAmount ) Owned (_owner) {
25
22
feeToken = ERC20 (_feeToken);
26
23
feeTokenAmount = _feeTokenAmount;
27
24
}
28
25
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`
31
28
/// this creates a competitive auction as the balances of this contract increase
32
29
/// 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 ();
39
37
}
40
38
41
- feeToken.safeTransferFrom (msg .sender , feeRecipient, feeTokenAmount);
39
+ feeToken.safeTransferFrom (msg .sender , feeRecipient, feeTokenAmount * tokens. length );
42
40
}
43
41
44
42
function setFeeRecipient (address _feeRecipient ) external onlyOwner {
0 commit comments