diff --git a/foundry/src/executors/BebopExecutor.sol b/foundry/src/executors/BebopExecutor.sol index 5387ac8..121435e 100644 --- a/foundry/src/executors/BebopExecutor.sol +++ b/foundry/src/executors/BebopExecutor.sol @@ -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); } diff --git a/foundry/test/executors/BebopExecutor.t.sol b/foundry/test/executors/BebopExecutor.t.sol index 35209a1..3540772 100644 --- a/foundry/test/executors/BebopExecutor.t.sol +++ b/foundry/test/executors/BebopExecutor.t.sol @@ -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,