From a09d648f3c50f87b392c7c5eb14af07307c5ccea Mon Sep 17 00:00:00 2001 From: adrian Date: Tue, 19 Aug 2025 16:05:51 +0200 Subject: [PATCH] fix: in HashflowExecutor, _balanceOf must use `trader` address instead of the executor's to get the balance --- foundry/src/executors/HashflowExecutor.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/foundry/src/executors/HashflowExecutor.sol b/foundry/src/executors/HashflowExecutor.sol index 1ee9847..60d4f72 100644 --- a/foundry/src/executors/HashflowExecutor.sol +++ b/foundry/src/executors/HashflowExecutor.sol @@ -79,9 +79,9 @@ contract HashflowExecutor is IExecutor, RestrictTransferFrom { _transfer( address(this), transferType, address(quote.baseToken), givenAmount ); - uint256 balanceBefore = _balanceOf(quote.quoteToken); + uint256 balanceBefore = _balanceOf(quote.trader, quote.quoteToken); IHashflowRouter(hashflowRouter).tradeRFQT{value: ethValue}(quote); - uint256 balanceAfter = _balanceOf(quote.quoteToken); + uint256 balanceAfter = _balanceOf(quote.trader, quote.quoteToken); calculatedAmount = balanceAfter - balanceBefore; } @@ -116,13 +116,13 @@ contract HashflowExecutor is IExecutor, RestrictTransferFrom { quote.signature = data[282:347]; } - function _balanceOf(address token) + function _balanceOf(address trader, address token) internal view returns (uint256 balance) { balance = token == NATIVE_TOKEN - ? address(this).balance - : IERC20(token).balanceOf(address(this)); + ? trader.balance + : IERC20(token).balanceOf(trader); } }