chore: fix _getActualFilledTakerAmount return value
This commit is contained in:
@@ -144,7 +144,7 @@ contract BebopExecutor is IExecutor, IExecutorErrors, RestrictTransferFrom {
|
|||||||
* @dev Determines the actual taker amount to be filled for a Bebop order
|
* @dev Determines the actual taker amount to be filled for a Bebop order
|
||||||
* @notice This function handles two scenarios:
|
* @notice This function handles two scenarios:
|
||||||
* 1. When filledTakerAmount is 0: Uses the full order amount if givenAmount is sufficient,
|
* 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
|
* 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
|
* to ensure we don't attempt to fill more than available
|
||||||
* @param givenAmount The amount of tokens available from the router for this swap
|
* @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
|
uint256 filledTakerAmount
|
||||||
) internal pure returns (uint256 actualFilledTakerAmount) {
|
) internal pure returns (uint256 actualFilledTakerAmount) {
|
||||||
actualFilledTakerAmount = filledTakerAmount == 0
|
actualFilledTakerAmount = filledTakerAmount == 0
|
||||||
? (givenAmount >= orderTakerAmount ? orderTakerAmount : 0)
|
? (givenAmount >= orderTakerAmount ? orderTakerAmount : givenAmount)
|
||||||
: (filledTakerAmount > givenAmount ? givenAmount : filledTakerAmount);
|
: (filledTakerAmount > givenAmount ? givenAmount : filledTakerAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,6 +54,19 @@ contract BebopExecutorHarness is BebopExecutor, Test {
|
|||||||
return _decodeData(data);
|
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
|
// Override to prank the taker address before calling the real settlement
|
||||||
function _executeSingleRFQ(
|
function _executeSingleRFQ(
|
||||||
address tokenIn,
|
address tokenIn,
|
||||||
|
|||||||
Reference in New Issue
Block a user