@@ -5,58 +5,54 @@ import {SettlerBase} from "../../SettlerBase.sol";
55
66import {IERC20 } from "@forge-std/interfaces/IERC20.sol " ;
77import {FreeMemory} from "../../utils/FreeMemory.sol " ;
8- import {SafeTransferLib} from "../../vendor/SafeTransferLib.sol " ;
9- import {Ternary} from "../../utils/Ternary.sol " ;
8+
9+ import {UniswapV4} from "../../core/UniswapV4.sol " ;
10+ import {IPoolManager} from "../../core/UniswapV4Types.sol " ;
1011
1112import {ISettlerActions} from "../../ISettlerActions.sol " ;
1213import {ISignatureTransfer} from "@permit2/interfaces/ISignatureTransfer.sol " ;
1314import {revertUnknownForkId} from "../../core/SettlerErrors.sol " ;
1415
16+ import {
17+ uniswapV3TempoFactory,
18+ uniswapV3InitHash,
19+ uniswapV3ForkId,
20+ IUniswapV3Callback
21+ } from "../../core/univ3forks/UniswapV3.sol " ;
22+
23+ import {TEMPO_POOL_MANAGER} from "../../core/UniswapV4Addresses.sol " ;
24+
1525// Solidity inheritance is stupid
1626import {SettlerSwapAbstract} from "../../SettlerAbstract.sol " ;
1727import {Permit2PaymentAbstract} from "../../core/Permit2PaymentAbstract.sol " ;
1828
19- abstract contract TempoMixin is FreeMemory , SettlerBase {
20- using Ternary for bool ;
21- using SafeTransferLib for IERC20 ;
22- using SafeTransferLib for address payable ;
23-
29+ abstract contract TempoMixin is FreeMemory , SettlerBase , UniswapV4 {
2430 constructor () {
2531 assert (block .chainid == 4217 || block .chainid == 31337 );
2632 }
2733
2834 function _dispatch (uint256 i , uint256 action , bytes calldata data , AllowedSlippage memory slippage )
2935 internal
3036 virtual
31- override (/* SettlerSwapAbstract, */ SettlerBase)
37+ override (SettlerSwapAbstract, SettlerBase)
3238 DANGEROUS_freeMemory
3339 returns (bool )
3440 {
35- // This does not make use of `super._dispatch`. This chain's Settler is extremely
36- // stripped-down and has almost no capabilities
37- if (action == uint32 (ISettlerActions.BASIC.selector )) {
38- (IERC20 sellToken , uint256 bps , address pool , uint256 offset , bytes memory _data ) =
39- abi.decode (data, (IERC20 , uint256 , address , uint256 , bytes ));
41+ if (super ._dispatch (i, action, data, slippage)) {
42+ return true ;
43+ } else if (action == uint32 (ISettlerActions.UNISWAPV4.selector )) {
44+ (
45+ address recipient ,
46+ IERC20 sellToken ,
47+ uint256 bps ,
48+ bool feeOnTransfer ,
49+ uint256 hashMul ,
50+ uint256 hashMod ,
51+ bytes memory fills ,
52+ uint256 amountOutMin
53+ ) = abi.decode (data, (address , IERC20 , uint256 , bool , uint256 , uint256 , bytes , uint256 ));
4054
41- basicSellToPool (sellToken, bps, pool, offset, _data);
42- } else if (action == uint32 (ISettlerActions.POSITIVE_SLIPPAGE.selector )) {
43- (address payable recipient , IERC20 token , uint256 expectedAmount , uint256 maxBps ) =
44- abi.decode (data, (address , IERC20 , uint256 , uint256 ));
45- bool isETH = (token == ETH_ADDRESS);
46- uint256 balance = isETH ? address (this ).balance : token.fastBalanceOf (address (this ));
47- if (balance > expectedAmount) {
48- uint256 cap;
49- unchecked {
50- cap = balance * maxBps / BASIS;
51- balance -= expectedAmount;
52- }
53- balance = (balance > cap).ternary (cap, balance);
54- if (isETH) {
55- recipient.safeTransferETH (balance);
56- } else {
57- token.safeTransfer (recipient, balance);
58- }
59- }
55+ sellToUniswapV4 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills, amountOutMin);
6056 } else {
6157 return false ;
6258 }
@@ -69,14 +65,24 @@ abstract contract TempoMixin is FreeMemory, SettlerBase {
6965 override
7066 returns (address factory , bytes32 initHash , uint32 callbackSelector )
7167 {
72- revertUnknownForkId (forkId);
68+ if (forkId == uniswapV3ForkId) {
69+ factory = uniswapV3TempoFactory;
70+ initHash = uniswapV3InitHash;
71+ callbackSelector = uint32 (IUniswapV3Callback.uniswapV3SwapCallback.selector );
72+ } else {
73+ revertUnknownForkId (forkId);
74+ }
75+ }
76+
77+ function _POOL_MANAGER () internal pure override returns (IPoolManager) {
78+ return TEMPO_POOL_MANAGER;
7379 }
7480
7581 // I hate Solidity inheritance
7682 function _fallback (bytes calldata data )
7783 internal
7884 virtual
79- override (Permit2PaymentAbstract)
85+ override (Permit2PaymentAbstract, UniswapV4 )
8086 returns (bool success , bytes memory returndata )
8187 {
8288 return super ._fallback (data);
0 commit comments