diff --git a/CHANGELOG.md b/CHANGELOG.md index 39d1e26b..26e9a4fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Master list of UniV3 forks: 26. Swapr (Algebra-like) 27. SpookySwap 28. Wagmi + 29. SwapX (Algebra-like) --- @@ -59,6 +60,7 @@ Master list of UniV3 forks: * Add `rebateClaimer()(address)` function on Mainnet Settlers for gas rebate program * Add SolidlyV3 UniV3 fork to Sonic * Add Wagmi UniV3 fork to Sonic +* Add SwapX UniV3 (Algebra style) fork to Sonic ## 2024-12-18 diff --git a/src/chains/Mode/Common.sol b/src/chains/Mode/Common.sol index b13c1efa..30adbc7c 100644 --- a/src/chains/Mode/Common.sol +++ b/src/chains/Mode/Common.sol @@ -14,8 +14,8 @@ import { supSwapV3ForkId, ISupSwapV3Callback } from "../../core/univ3forks/SupSwapV3.sol"; -import {kimFactory, kimInitHash, kimForkId} from "../../core/univ3forks/Kim.sol"; -import {IAlgebraCallback} from "../../core/univ3forks/Algebra.sol"; +import {kimFactory, kimForkId} from "../../core/univ3forks/Kim.sol"; +import {algebraV4InitHash, IAlgebraCallback} from "../../core/univ3forks/Algebra.sol"; import {swapModeV3Factory, swapModeV3InitHash, swapModeV3ForkId} from "../../core/univ3forks/SwapModeV3.sol"; import {IUniswapV3Callback} from "../../core/univ3forks/UniswapV3.sol"; @@ -63,7 +63,7 @@ abstract contract ModeMixin is FreeMemory, SettlerBase { callbackSelector = uint32(ISupSwapV3Callback.supV3SwapCallback.selector); } else if (forkId == kimForkId) { factory = kimFactory; - initHash = kimInitHash; + initHash = algebraV4InitHash; callbackSelector = uint32(IAlgebraCallback.algebraSwapCallback.selector); } else if (forkId == swapModeV3ForkId) { factory = swapModeV3Factory; diff --git a/src/chains/Sonic/Common.sol b/src/chains/Sonic/Common.sol index 11695e1c..63c3cceb 100644 --- a/src/chains/Sonic/Common.sol +++ b/src/chains/Sonic/Common.sol @@ -24,6 +24,8 @@ import { } from "../../core/univ3forks/SolidlyV3.sol"; import {spookySwapFactory, spookySwapForkId} from "../../core/univ3forks/SpookySwap.sol"; import {wagmiFactory, wagmiInitHash, wagmiForkId} from "../../core/univ3forks/Wagmi.sol"; +import {swapXFactory, swapXForkId} from "../../core/univ3forks/SwapX.sol"; +import {algebraV4InitHash, IAlgebraCallback} from "../../core/univ3forks/Algebra.sol"; // Solidity inheritance is stupid import {SettlerAbstract} from "../../SettlerAbstract.sol"; @@ -70,6 +72,10 @@ abstract contract SonicMixin is FreeMemory, SettlerBase { factory = wagmiFactory; initHash = wagmiInitHash; callbackSelector = uint32(IUniswapV3Callback.uniswapV3SwapCallback.selector); + } else if (forkId == swapXForkId) { + factory = swapXFactory; + initHash = algebraV4InitHash; + callbackSelector = uint32(IAlgebraCallback.algebraSwapCallback.selector); } else { revert UnknownForkId(forkId); } diff --git a/src/chains/Taiko/Common.sol b/src/chains/Taiko/Common.sol index a8cb30f4..2cfb2114 100644 --- a/src/chains/Taiko/Common.sol +++ b/src/chains/Taiko/Common.sol @@ -16,8 +16,8 @@ import { uniswapV3ForkId, IUniswapV3Callback } from "../../core/univ3forks/UniswapV3.sol"; -import {swapsicleFactory, swapsicleInitHash, swapsicleForkId} from "../../core/univ3forks/Swapsicle.sol"; -import {IAlgebraCallback} from "../../core/univ3forks/Algebra.sol"; +import {swapsicleFactory, swapsicleForkId} from "../../core/univ3forks/Swapsicle.sol"; +import {algebraV4InitHash, IAlgebraCallback} from "../../core/univ3forks/Algebra.sol"; import {pankoFactory, pankoInitHash, pankoForkId} from "../../core/univ3forks/Panko.sol"; import {IPancakeSwapV3Callback} from "../../core/univ3forks/PancakeSwapV3.sol"; @@ -53,7 +53,7 @@ abstract contract TaikoMixin is FreeMemory, SettlerBase { callbackSelector = uint32(IUniswapV3Callback.uniswapV3SwapCallback.selector); } else if (forkId == swapsicleForkId) { factory = swapsicleFactory; - initHash = swapsicleInitHash; + initHash = algebraV4InitHash; callbackSelector = uint32(IAlgebraCallback.algebraSwapCallback.selector); } else if (forkId == pankoForkId) { factory = pankoFactory; diff --git a/src/core/univ3forks/Algebra.sol b/src/core/univ3forks/Algebra.sol index f2522aa3..35bfb39c 100644 --- a/src/core/univ3forks/Algebra.sol +++ b/src/core/univ3forks/Algebra.sol @@ -1,6 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; +bytes32 constant algebraV4InitHash = 0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d; + interface IAlgebraCallback { function algebraSwapCallback(int256 amount0Delta, int256 amount1Delta, bytes calldata data) external; } diff --git a/src/core/univ3forks/Kim.sol b/src/core/univ3forks/Kim.sol index 037293bc..adbdbb56 100644 --- a/src/core/univ3forks/Kim.sol +++ b/src/core/univ3forks/Kim.sol @@ -2,5 +2,4 @@ pragma solidity ^0.8.25; address constant kimFactory = 0x6414A461B19726410E52488d9D5ff33682701635; -bytes32 constant kimInitHash = 0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d; uint8 constant kimForkId = 22; diff --git a/src/core/univ3forks/Swapsicle.sol b/src/core/univ3forks/Swapsicle.sol index ce9d5bc0..fd462b49 100644 --- a/src/core/univ3forks/Swapsicle.sol +++ b/src/core/univ3forks/Swapsicle.sol @@ -2,5 +2,4 @@ pragma solidity ^0.8.25; address constant swapsicleFactory = 0xb68b27a1c93A52d698EecA5a759E2E4469432C09; -bytes32 constant swapsicleInitHash = 0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d; uint8 constant swapsicleForkId = 24;