feat: Pancakeswap V3 support

This commit is contained in:
TAMARA LIPOWSKI
2025-03-21 11:26:41 -04:00
parent 59a5a558f5
commit d582543057
7 changed files with 82 additions and 12 deletions

View File

@@ -518,6 +518,25 @@ contract TychoRouter is AccessControl, Dispatcher, Pausable, ReentrancyGuard {
_handleCallback(fullData);
}
/**
* @dev Called by PancakeV3 pool when swapping on it.
*/
function pancakeV3SwapCallback(
int256, /* amount0Delta */
int256, /* amount1Delta */
bytes calldata data
) external {
if (data.length < 24) revert TychoRouter__InvalidDataLength();
// We are taking advantage of the fact that the data we need is already encoded in the correct format inside msg.data
// This way we preserve the bytes calldata (and don't need to convert it to bytes memory)
uint256 dataOffset = 4 + 32 + 32 + 32; // Skip selector + 2 ints + data_offset
uint256 dataLength =
uint256(bytes32(msg.data[dataOffset:dataOffset + 32]));
bytes calldata fullData = msg.data[4:dataOffset + 32 + dataLength];
_handleCallback(fullData);
}
/**
* @dev Called by UniswapV4 pool manager after achieving unlock state.
*/

View File

@@ -107,7 +107,9 @@ contract UniswapV3Executor is IExecutor, ICallback {
uint24 poolFee = uint24(bytes3(data[40:43]));
// slither-disable-next-line unused-return
CallbackValidationV2.verifyCallback(factory, tokenIn, tokenOut, poolFee);
CallbackValidationV2.verifyCallback(
factory, tokenIn, tokenOut, poolFee, initCode
);
}
function uniswapV3SwapCallback(