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:
@@ -14,18 +14,18 @@ contract UniswapV2Executor is IExecutor {
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
address public immutable factory;
|
||||
bytes32 public immutable init_code;
|
||||
bytes32 public immutable initCode;
|
||||
address private immutable self;
|
||||
|
||||
constructor(address _factory, bytes32 _init_code) {
|
||||
constructor(address _factory, bytes32 _initCode) {
|
||||
if (_factory == address(0)) {
|
||||
revert UniswapV2Executor__InvalidFactory();
|
||||
}
|
||||
if (_init_code == bytes32(0)) {
|
||||
if (_initCode == bytes32(0)) {
|
||||
revert UniswapV2Executor__InvalidInitCode();
|
||||
}
|
||||
factory = _factory;
|
||||
init_code = _init_code;
|
||||
initCode = _initCode;
|
||||
self = address(this);
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ contract UniswapV2Executor is IExecutor {
|
||||
uint160(
|
||||
uint256(
|
||||
keccak256(
|
||||
abi.encodePacked(hex"ff", factory, salt, init_code)
|
||||
abi.encodePacked(hex"ff", factory, salt, initCode)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user