forge fmt
This commit is contained in:
@@ -10,7 +10,11 @@ import {NATIVE_TOKEN_ADDRESS} from "@ekubo/math/constants.sol";
|
||||
import {SafeTransferLib} from "@solady/utils/SafeTransferLib.sol";
|
||||
import {LibBytes} from "@solady/utils/LibBytes.sol";
|
||||
import {Config, PoolKey} from "@ekubo/types/poolKey.sol";
|
||||
import {MAX_SQRT_RATIO, MIN_SQRT_RATIO, SqrtRatio} from "@ekubo/types/sqrtRatio.sol";
|
||||
import {
|
||||
MAX_SQRT_RATIO,
|
||||
MIN_SQRT_RATIO,
|
||||
SqrtRatio
|
||||
} from "@ekubo/types/sqrtRatio.sol";
|
||||
import {RestrictTransferFrom} from "../RestrictTransferFrom.sol";
|
||||
import "@openzeppelin/contracts/utils/Address.sol";
|
||||
|
||||
@@ -39,11 +43,9 @@ contract EkuboExecutor is
|
||||
|
||||
using SafeERC20 for IERC20;
|
||||
|
||||
constructor(
|
||||
address _core,
|
||||
address _mevResist,
|
||||
address _permit2
|
||||
) RestrictTransferFrom(_permit2) {
|
||||
constructor(address _core, address _mevResist, address _permit2)
|
||||
RestrictTransferFrom(_permit2)
|
||||
{
|
||||
core = ICore(_core);
|
||||
|
||||
if (_mevResist == address(0)) {
|
||||
@@ -52,21 +54,22 @@ contract EkuboExecutor is
|
||||
mevResist = _mevResist;
|
||||
}
|
||||
|
||||
function swap(
|
||||
uint256 amountIn,
|
||||
bytes calldata data
|
||||
) external payable returns (uint256 calculatedAmount) {
|
||||
function swap(uint256 amountIn, bytes calldata data)
|
||||
external
|
||||
payable
|
||||
returns (uint256 calculatedAmount)
|
||||
{
|
||||
if (data.length < 92) revert EkuboExecutor__InvalidDataLength();
|
||||
|
||||
// amountIn must be at most type(int128).MAX
|
||||
calculatedAmount = uint256(
|
||||
_lock(bytes.concat(bytes16(uint128(amountIn)), data))
|
||||
);
|
||||
calculatedAmount =
|
||||
uint256(_lock(bytes.concat(bytes16(uint128(amountIn)), data)));
|
||||
}
|
||||
|
||||
function handleCallback(
|
||||
bytes calldata raw
|
||||
) external returns (bytes memory) {
|
||||
function handleCallback(bytes calldata raw)
|
||||
external
|
||||
returns (bytes memory)
|
||||
{
|
||||
verifyCallback(raw);
|
||||
|
||||
// Without selector and locker id
|
||||
@@ -104,7 +107,10 @@ contract EkuboExecutor is
|
||||
_payCallback(msg.data[36:]);
|
||||
}
|
||||
|
||||
function _lock(bytes memory data) internal returns (uint128 swappedAmount) {
|
||||
function _lock(bytes memory data)
|
||||
internal
|
||||
returns (uint128 swappedAmount)
|
||||
{
|
||||
address target = address(core);
|
||||
|
||||
// slither-disable-next-line assembly
|
||||
@@ -138,18 +144,15 @@ contract EkuboExecutor is
|
||||
|
||||
address nextTokenIn = tokenIn;
|
||||
|
||||
uint256 hopsLength = (swapData.length - POOL_DATA_OFFSET) /
|
||||
HOP_BYTE_LEN;
|
||||
uint256 hopsLength = (swapData.length - POOL_DATA_OFFSET) / HOP_BYTE_LEN;
|
||||
|
||||
uint256 offset = POOL_DATA_OFFSET;
|
||||
|
||||
for (uint256 i = 0; i < hopsLength; i++) {
|
||||
address nextTokenOut = address(
|
||||
bytes20(LibBytes.loadCalldata(swapData, offset))
|
||||
);
|
||||
Config poolConfig = Config.wrap(
|
||||
LibBytes.loadCalldata(swapData, offset + 20)
|
||||
);
|
||||
address nextTokenOut =
|
||||
address(bytes20(LibBytes.loadCalldata(swapData, offset)));
|
||||
Config poolConfig =
|
||||
Config.wrap(LibBytes.loadCalldata(swapData, offset + 20));
|
||||
|
||||
(
|
||||
address token0,
|
||||
@@ -182,11 +185,7 @@ contract EkuboExecutor is
|
||||
} else {
|
||||
// slither-disable-next-line calls-loop
|
||||
(delta0, delta1) = core.swap_611415377(
|
||||
pk,
|
||||
nextAmountIn,
|
||||
isToken1,
|
||||
sqrtRatioLimit,
|
||||
SKIP_AHEAD
|
||||
pk, nextAmountIn, isToken1, sqrtRatioLimit, SKIP_AHEAD
|
||||
);
|
||||
}
|
||||
|
||||
@@ -201,10 +200,10 @@ contract EkuboExecutor is
|
||||
return nextAmountIn;
|
||||
}
|
||||
|
||||
function _forward(
|
||||
address to,
|
||||
bytes memory data
|
||||
) internal returns (bytes memory result) {
|
||||
function _forward(address to, bytes memory data)
|
||||
internal
|
||||
returns (bytes memory result)
|
||||
{
|
||||
address target = address(core);
|
||||
|
||||
// slither-disable-next-line assembly
|
||||
@@ -240,11 +239,9 @@ contract EkuboExecutor is
|
||||
}
|
||||
}
|
||||
|
||||
function _pay(
|
||||
address token,
|
||||
uint128 amount,
|
||||
TransferType transferType
|
||||
) internal {
|
||||
function _pay(address token, uint128 amount, TransferType transferType)
|
||||
internal
|
||||
{
|
||||
address target = address(core);
|
||||
|
||||
if (token == NATIVE_TOKEN_ADDRESS) {
|
||||
|
||||
@@ -128,11 +128,8 @@ contract TychoRouterTestSetup is Constants, Permit2TestHelper, TestUtils {
|
||||
factoryPancakeV3, initCodePancakeV3, PERMIT2_ADDRESS
|
||||
);
|
||||
balancerv2Executor = new BalancerV2Executor(PERMIT2_ADDRESS);
|
||||
ekuboExecutor = new EkuboExecutor(
|
||||
ekuboCore,
|
||||
ekuboMevResist,
|
||||
PERMIT2_ADDRESS
|
||||
);
|
||||
ekuboExecutor =
|
||||
new EkuboExecutor(ekuboCore, ekuboMevResist, PERMIT2_ADDRESS);
|
||||
curveExecutor = new CurveExecutor(ETH_ADDR_FOR_CURVE, PERMIT2_ADDRESS);
|
||||
maverickv2Executor =
|
||||
new MaverickV2Executor(MAVERICK_V2_FACTORY, PERMIT2_ADDRESS);
|
||||
|
||||
@@ -66,14 +66,10 @@ contract EkuboExecutorTest is Constants, TestUtils {
|
||||
console.log(amountOut);
|
||||
|
||||
assertEq(CORE_ADDRESS.balance, ethBalanceBeforeCore + amountIn);
|
||||
assertEq(
|
||||
address(executor).balance,
|
||||
ethBalanceBeforeExecutor - amountIn
|
||||
);
|
||||
assertEq(address(executor).balance, ethBalanceBeforeExecutor - amountIn);
|
||||
|
||||
assertEq(
|
||||
USDC.balanceOf(CORE_ADDRESS),
|
||||
usdcBalanceBeforeCore - amountOut
|
||||
USDC.balanceOf(CORE_ADDRESS), usdcBalanceBeforeCore - amountOut
|
||||
);
|
||||
assertEq(
|
||||
USDC.balanceOf(address(executor)),
|
||||
@@ -106,10 +102,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
|
||||
|
||||
console.log(amountOut);
|
||||
|
||||
assertEq(
|
||||
USDC.balanceOf(CORE_ADDRESS),
|
||||
usdcBalanceBeforeCore + amountIn
|
||||
);
|
||||
assertEq(USDC.balanceOf(CORE_ADDRESS), usdcBalanceBeforeCore + amountIn);
|
||||
assertEq(
|
||||
USDC.balanceOf(address(executor)),
|
||||
usdcBalanceBeforeExecutor - amountIn
|
||||
@@ -117,8 +110,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
|
||||
|
||||
assertEq(CORE_ADDRESS.balance, ethBalanceBeforeCore - amountOut);
|
||||
assertEq(
|
||||
address(executor).balance,
|
||||
ethBalanceBeforeExecutor + amountOut
|
||||
address(executor).balance, ethBalanceBeforeExecutor + amountOut
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,10 +139,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
|
||||
|
||||
console.log(amountOut);
|
||||
|
||||
assertEq(
|
||||
USDC.balanceOf(CORE_ADDRESS),
|
||||
usdcBalanceBeforeCore + amountIn
|
||||
);
|
||||
assertEq(USDC.balanceOf(CORE_ADDRESS), usdcBalanceBeforeCore + amountIn);
|
||||
assertEq(
|
||||
USDC.balanceOf(address(executor)),
|
||||
usdcBalanceBeforeExecutor - amountIn
|
||||
@@ -158,8 +147,7 @@ contract EkuboExecutorTest is Constants, TestUtils {
|
||||
|
||||
assertEq(CORE_ADDRESS.balance, ethBalanceBeforeCore - amountOut);
|
||||
assertEq(
|
||||
address(executor).balance,
|
||||
ethBalanceBeforeExecutor + amountOut
|
||||
address(executor).balance, ethBalanceBeforeExecutor + amountOut
|
||||
);
|
||||
}
|
||||
|
||||
@@ -182,14 +170,10 @@ contract EkuboExecutorTest is Constants, TestUtils {
|
||||
console.log(amountOut);
|
||||
|
||||
assertEq(CORE_ADDRESS.balance, ethBalanceBeforeCore + amountIn);
|
||||
assertEq(
|
||||
address(executor).balance,
|
||||
ethBalanceBeforeExecutor - amountIn
|
||||
);
|
||||
assertEq(address(executor).balance, ethBalanceBeforeExecutor - amountIn);
|
||||
|
||||
assertEq(
|
||||
USDT.balanceOf(CORE_ADDRESS),
|
||||
usdtBalanceBeforeCore - amountOut
|
||||
USDT.balanceOf(CORE_ADDRESS), usdtBalanceBeforeCore - amountOut
|
||||
);
|
||||
assertEq(
|
||||
USDT.balanceOf(address(executor)),
|
||||
|
||||
Reference in New Issue
Block a user