Skip to content

Commit

Permalink
make targetToCheck contract-specific
Browse files Browse the repository at this point in the history
  • Loading branch information
ZumZoom committed Sep 4, 2024
1 parent 4f0281f commit 214864a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 8 additions & 4 deletions contracts/BalanceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ abstract contract BalanceManager is IERC1271, IBalanceManager {
uint256[] calldata values,
uint256 minReturn
) public payable {
uint256 balanceBefore = msg.sender.balance;
address target = targetToCheck();
uint256 balanceBefore = target.balance;
arbitraryCalls(targets, arguments, values);
if (msg.sender.balance - balanceBefore < minReturn) revert NotEnoughProfit();
if (target.balance - balanceBefore < minReturn) revert NotEnoughProfit();
}

/**
Expand Down Expand Up @@ -109,9 +110,10 @@ abstract contract BalanceManager is IERC1271, IBalanceManager {
IERC20 token,
uint256 minReturn
) public payable {
uint256 balanceBefore = token.balanceOf(msg.sender);
address target = targetToCheck();
uint256 balanceBefore = token.balanceOf(target);
arbitraryCalls(targets, arguments, values);
if (token.balanceOf(msg.sender) - balanceBefore < minReturn) revert NotEnoughProfit();
if (token.balanceOf(target) - balanceBefore < minReturn) revert NotEnoughProfit();
}

/**
Expand Down Expand Up @@ -201,6 +203,8 @@ abstract contract BalanceManager is IERC1271, IBalanceManager {
(bool success, ) = payable(msg.sender).call{value: address(this).balance}("");
if (!success) revert ETHTransferFailed();
}

function targetToCheck() internal view virtual returns (address);

Check failure on line 207 in contracts/BalanceManager.sol

View workflow job for this annotation

GitHub Actions / lint

'targetToCheck' should start with _
}

/* solhint-enable avoid-low-level-calls */
4 changes: 4 additions & 0 deletions contracts/LeftoverExchanger.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ contract LeftoverExchanger is BalanceManager {
function isValidSignature(bytes32 hash, bytes calldata signature) external view override returns (bytes4 magicValue) {
if (ECDSA.recover(hash, signature) == _OWNER) magicValue = this.isValidSignature.selector;
}

function targetToCheck() internal view override returns(address) {

Check failure on line 77 in contracts/LeftoverExchanger.sol

View workflow job for this annotation

GitHub Actions / lint

'targetToCheck' should start with _
return msg.sender;
}
}

/* solhint-enable avoid-low-level-calls */

0 comments on commit 214864a

Please sign in to comment.