Skip to content

Commit

Permalink
Add SwapX Algebra-style UniV3 fork on Sonic
Browse files Browse the repository at this point in the history
  • Loading branch information
duncancmt committed Dec 28, 2024
1 parent e39296a commit 907d1db
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Master list of UniV3 forks:
26. Swapr (Algebra-like)
27. SpookySwap
28. Wagmi
29. SwapX (Algebra-like)

---

Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/chains/Mode/Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/chains/Sonic/Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions src/chains/Taiko/Common.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/core/univ3forks/Algebra.sol
Original file line number Diff line number Diff line change
@@ -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;
}
1 change: 0 additions & 1 deletion src/core/univ3forks/Kim.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
pragma solidity ^0.8.25;

address constant kimFactory = 0x6414A461B19726410E52488d9D5ff33682701635;
bytes32 constant kimInitHash = 0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d;
uint8 constant kimForkId = 22;
1 change: 0 additions & 1 deletion src/core/univ3forks/Swapsicle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
pragma solidity ^0.8.25;

address constant swapsicleFactory = 0xb68b27a1c93A52d698EecA5a759E2E4469432C09;
bytes32 constant swapsicleInitHash = 0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d;
uint8 constant swapsicleForkId = 24;

0 comments on commit 907d1db

Please sign in to comment.