chore: merge main

Took 3 minutes
This commit is contained in:
TAMARA LIPOWSKI
2025-04-03 17:52:11 +02:00
committed by Diana Carvalho
51 changed files with 1444 additions and 299 deletions

View File

@@ -0,0 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
import {IFlashAccountant} from "./IFlashAccountant.sol";
import {EkuboPoolKey} from "../types/poolKey.sol";
import {SqrtRatio} from "../types/sqrtRatio.sol";
interface ICore is IFlashAccountant {
function swap_611415377(
EkuboPoolKey memory poolKey,
int128 amount,
bool isToken1,
SqrtRatio sqrtRatioLimit,
uint256 skipAhead
) external payable returns (int128 delta0, int128 delta1);
}

View File

@@ -0,0 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
interface ILocker {
function locked(uint256 id) external;
}
interface IPayer {
function payCallback(uint256 id, address token) external;
}
interface IFlashAccountant {
// 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;
}

View File

@@ -0,0 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
// We use this address to represent the native token within the protocol
address constant NATIVE_TOKEN_ADDRESS = address(0);

View File

@@ -0,0 +1,12 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
// 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 {
address token0;
address token1;
Config config;
}

View File

@@ -0,0 +1,9 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.26;
type SqrtRatio is uint96;
uint96 constant MIN_SQRT_RATIO_RAW = 4611797791050542631;
SqrtRatio constant MIN_SQRT_RATIO = SqrtRatio.wrap(MIN_SQRT_RATIO_RAW);
uint96 constant MAX_SQRT_RATIO_RAW = 79227682466138141934206691491;
SqrtRatio constant MAX_SQRT_RATIO = SqrtRatio.wrap(MAX_SQRT_RATIO_RAW);

1
foundry/lib/solady Submodule

Submodule foundry/lib/solady added at c9e079c0ca

View File

@@ -1,41 +0,0 @@
// Updated v3 lib to solidity >=0.7.6
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.7.6;
import "./PoolAddressV2.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
/// @notice Provides validation for callbacks from Uniswap V3 Pools
library CallbackValidationV2 {
/// @notice Returns the address of a valid Uniswap V3 Pool
/// @param factory The contract address of the Uniswap V3 factory
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @return pool The V3 pool contract address
function verifyCallback(
address factory,
address tokenA,
address tokenB,
uint24 fee
) internal view returns (IUniswapV3Pool pool) {
return
verifyCallback(
factory,
PoolAddressV2.getPoolKey(tokenA, tokenB, fee)
);
}
/// @notice Returns the address of a valid Uniswap V3 Pool
/// @param factory The contract address of the Uniswap V3 factory
/// @param poolKey The identifying key of the V3 pool
/// @return pool The V3 pool contract address
function verifyCallback(
address factory,
PoolAddressV2.PoolKey memory poolKey
) internal view returns (IUniswapV3Pool pool) {
pool = IUniswapV3Pool(PoolAddressV2.computeAddress(factory, poolKey));
require(msg.sender == address(pool), "CV");
}
}

View File

@@ -1,59 +0,0 @@
// Updated v3 lib to solidity >=0.7.6
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Provides functions for deriving a pool address from the factory, tokens, and the fee
library PoolAddressV2 {
bytes32 internal constant POOL_INIT_CODE_HASH =
0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54;
/// @notice The identifying key of the pool
struct PoolKey {
address token0;
address token1;
uint24 fee;
}
/// @notice Returns PoolKey: the ordered tokens with the matched fee levels
/// @param tokenA The first token of a pool, unsorted
/// @param tokenB The second token of a pool, unsorted
/// @param fee The fee level of the pool
/// @return Poolkey The pool details with ordered token0 and token1 assignments
function getPoolKey(address tokenA, address tokenB, uint24 fee)
internal
pure
returns (PoolKey memory)
{
if (tokenA > tokenB) (tokenA, tokenB) = (tokenB, tokenA);
return PoolKey({token0: tokenA, token1: tokenB, fee: fee});
}
/// @notice Deterministically computes the pool address given the factory and PoolKey
/// @param factory The Uniswap V3 factory contract address
/// @param key The PoolKey
/// @return pool The contract address of the V3 pool
function computeAddress(address factory, PoolKey memory key)
internal
pure
returns (address pool)
{
require(key.token0 < key.token1);
pool = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
hex"ff",
factory,
keccak256(
abi.encode(key.token0, key.token1, key.fee)
),
POOL_INIT_CODE_HASH
)
)
)
)
);
}
}