Add support for Ekubo MEV-resist extension

This commit is contained in:
die-herdplatte
2025-06-17 11:02:37 +02:00
parent 1a7f29e69d
commit 58ce241c63
6 changed files with 214 additions and 62 deletions

View File

@@ -2,15 +2,15 @@
pragma solidity ^0.8.26;
import {IFlashAccountant} from "./IFlashAccountant.sol";
import {EkuboPoolKey} from "../types/poolKey.sol";
import {PoolKey} from "../types/poolKey.sol";
import {SqrtRatio} from "../types/sqrtRatio.sol";
interface ICore is IFlashAccountant {
function swap_611415377(
EkuboPoolKey memory poolKey,
PoolKey memory poolKey,
int128 amount,
bool isToken1,
SqrtRatio sqrtRatioLimit,
uint256 skipAhead
) external payable returns (int128 delta0, int128 delta1);
}
}

View File

@@ -10,7 +10,17 @@ interface IPayer {
}
interface IFlashAccountant {
// Forward the lock from the current locker to the given address
// Any additional calldata is also passed through to the forwardee, with no additional encoding
// In addition, any data returned from IForwardee#forwarded is also returned from this function exactly as is, i.e. with no additional encoding or decoding
// Reverts are also bubbled up
function forward(address to) external;
// Withdraws a token amount from the accountant to the given recipient.
// The contract must be locked, as it tracks the withdrawn amount against the current locker's delta.
function withdraw(address token, address recipient, uint128 amount) external;
function withdraw(
address token,
address recipient,
uint128 amount
) external;
}

View File

@@ -1,12 +1,20 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
using {extension} for Config global;
// address (20 bytes) | fee (8 bytes) | tickSpacing (4 bytes)
type Config is bytes32;
// Each pool has its own state associated with this key
struct EkuboPoolKey {
struct PoolKey {
address token0;
address token1;
Config config;
}
function extension(Config config) pure returns (address e) {
assembly ("memory-safe") {
e := shr(96, config)
}
}