Merge remote-tracking branch 'upstream/main' into ekubo

This commit is contained in:
die-herdplatte
2025-03-26 08:25:37 +01:00
15 changed files with 176 additions and 38 deletions

View File

@@ -8,21 +8,24 @@ import "@uniswap-v2/contracts/interfaces/IUniswapV2Pair.sol";
error UniswapV2Executor__InvalidDataLength();
error UniswapV2Executor__InvalidTarget();
error UniswapV2Executor__InvalidFactory();
error UniswapV2Executor__InvalidInitCode();
contract UniswapV2Executor is IExecutor {
using SafeERC20 for IERC20;
bytes32 internal constant POOL_INIT_CODE_HASH =
0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f;
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 UniswapV2Executor__InvalidFactory();
}
if (_initCode == bytes32(0)) {
revert UniswapV2Executor__InvalidInitCode();
}
factory = _factory;
initCode = _initCode;
self = address(this);
}
@@ -102,9 +105,7 @@ contract UniswapV2Executor is IExecutor {
uint160(
uint256(
keccak256(
abi.encodePacked(
hex"ff", factory, salt, POOL_INIT_CODE_HASH
)
abi.encodePacked(hex"ff", factory, salt, initCode)
)
)
)

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
)
)
)