fix: in HashflowExecutor, _balanceOf must use trader address instead of the executor's to get the balance
This commit is contained in:
@@ -79,9 +79,9 @@ contract HashflowExecutor is IExecutor, RestrictTransferFrom {
|
|||||||
_transfer(
|
_transfer(
|
||||||
address(this), transferType, address(quote.baseToken), givenAmount
|
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);
|
IHashflowRouter(hashflowRouter).tradeRFQT{value: ethValue}(quote);
|
||||||
uint256 balanceAfter = _balanceOf(quote.quoteToken);
|
uint256 balanceAfter = _balanceOf(quote.trader, quote.quoteToken);
|
||||||
calculatedAmount = balanceAfter - balanceBefore;
|
calculatedAmount = balanceAfter - balanceBefore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,13 +116,13 @@ contract HashflowExecutor is IExecutor, RestrictTransferFrom {
|
|||||||
quote.signature = data[282:347];
|
quote.signature = data[282:347];
|
||||||
}
|
}
|
||||||
|
|
||||||
function _balanceOf(address token)
|
function _balanceOf(address trader, address token)
|
||||||
internal
|
internal
|
||||||
view
|
view
|
||||||
returns (uint256 balance)
|
returns (uint256 balance)
|
||||||
{
|
{
|
||||||
balance = token == NATIVE_TOKEN
|
balance = token == NATIVE_TOKEN
|
||||||
? address(this).balance
|
? trader.balance
|
||||||
: IERC20(token).balanceOf(address(this));
|
: IERC20(token).balanceOf(trader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user