chore: fix _getActualFilledTakerAmount return value

This commit is contained in:
pedrobergamini
2025-06-18 13:08:50 -03:00
parent 033a4bfe9f
commit 4c7f33d81b
2 changed files with 15 additions and 2 deletions

View File

@@ -144,7 +144,7 @@ contract BebopExecutor is IExecutor, IExecutorErrors, RestrictTransferFrom {
* @dev Determines the actual taker amount to be filled for a Bebop order
* @notice This function handles two scenarios:
* 1. When filledTakerAmount is 0: Uses the full order amount if givenAmount is sufficient,
* otherwise returns 0 to indicate the order cannot be filled
* otherwise returns givenAmount to partially fill the order
* 2. When filledTakerAmount > 0: Caps the fill at the minimum of filledTakerAmount and givenAmount
* to ensure we don't attempt to fill more than available
* @param givenAmount The amount of tokens available from the router for this swap
@@ -158,7 +158,7 @@ contract BebopExecutor is IExecutor, IExecutorErrors, RestrictTransferFrom {
uint256 filledTakerAmount
) internal pure returns (uint256 actualFilledTakerAmount) {
actualFilledTakerAmount = filledTakerAmount == 0
? (givenAmount >= orderTakerAmount ? orderTakerAmount : 0)
? (givenAmount >= orderTakerAmount ? orderTakerAmount : givenAmount)
: (filledTakerAmount > givenAmount ? givenAmount : filledTakerAmount);
}

View File

@@ -54,6 +54,19 @@ contract BebopExecutorHarness is BebopExecutor, Test {
return _decodeData(data);
}
// Expose the internal getActualFilledTakerAmount function for testing
function exposed_getActualFilledTakerAmount(
uint256 givenAmount,
uint256 orderTakerAmount,
uint256 filledTakerAmount
) external pure returns (uint256 actualFilledTakerAmount) {
return _getActualFilledTakerAmount(
givenAmount,
orderTakerAmount,
filledTakerAmount
);
}
// Override to prank the taker address before calling the real settlement
function _executeSingleRFQ(
address tokenIn,