feat: Support Pancakeswap v3 on ethereum

- Needed to take pool code init hash as input param for executors
- Added tests for ethereum. Will test base on-chain.
- Important note: Pancakeswap uses their deployer instead of their factory (this is a different address) for target verification.
This commit is contained in:
TAMARA LIPOWSKI
2025-03-19 15:30:58 -04:00
parent 0a8a34be03
commit 2a4ee88cad
7 changed files with 78 additions and 28 deletions

View File

@@ -10,24 +10,28 @@ import "@interfaces/ICallback.sol";
error UniswapV3Executor__InvalidDataLength();
error UniswapV3Executor__InvalidFactory();
error UniswapV3Executor__InvalidTarget();
error UniswapV3Executor__InvalidInitCode();
contract UniswapV3Executor is IExecutor, ICallback {
using SafeERC20 for IERC20;
bytes32 internal constant POOL_INIT_CODE_HASH =
0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;
uint160 private constant MIN_SQRT_RATIO = 4295128739;
uint160 private constant MAX_SQRT_RATIO =
1461446703485210103287273052203988822378723970342;
address public immutable factory;
bytes32 public immutable initCode;
address private immutable self;
constructor(address _factory) {
constructor(address _factory, bytes32 _initCode) {
if (_factory == address(0)) {
revert UniswapV3Executor__InvalidFactory();
}
if (_initCode == bytes32(0)) {
revert UniswapV3Executor__InvalidInitCode();
}
factory = _factory;
initCode = _initCode;
self = address(this);
}
@@ -167,7 +171,7 @@ contract UniswapV3Executor is IExecutor, ICallback {
hex"ff",
factory,
keccak256(abi.encode(token0, token1, fee)),
POOL_INIT_CODE_HASH
initCode
)
)
)