diff --git a/src/chains/Unichain/Common.sol b/src/chains/Unichain/Common.sol index 634d748b..904e2178 100644 --- a/src/chains/Unichain/Common.sol +++ b/src/chains/Unichain/Common.sol @@ -4,6 +4,7 @@ pragma solidity =0.8.25; import {SettlerBase} from "../../SettlerBase.sol"; import {IERC20} from "@forge-std/interfaces/IERC20.sol"; +import {UniswapV4} from "../../core/UniswapV4.sol"; import {FreeMemory} from "../../utils/FreeMemory.sol"; import {ISettlerActions} from "../../ISettlerActions.sol"; @@ -18,9 +19,9 @@ import { } from "../../core/univ3forks/UniswapV3.sol"; // Solidity inheritance is stupid -//import {SettlerAbstract} from "../../SettlerAbstract.sol"; +import {SettlerAbstract} from "../../SettlerAbstract.sol"; -abstract contract UnichainMixin is FreeMemory, SettlerBase { +abstract contract UnichainMixin is FreeMemory, SettlerBase, UniswapV4 { constructor() { assert(block.chainid == 0 || block.chainid == 31337); // TODO: } @@ -28,12 +29,25 @@ abstract contract UnichainMixin is FreeMemory, SettlerBase { function _dispatch(uint256 i, uint256 action, bytes calldata data) internal virtual - override(/* SettlerAbstract, */SettlerBase) + override(SettlerAbstract, SettlerBase) DANGEROUS_freeMemory returns (bool) { if (super._dispatch(i, action, data)) { return true; + } else if (action == uint32(ISettlerActions.UNISWAPV4.selector)) { + ( + address recipient, + IERC20 sellToken, + uint256 bps, + bool feeOnTransfer, + uint256 hashMul, + uint256 hashMod, + bytes memory fills, + uint256 amountOutMin + ) = abi.decode(data, (address, IERC20, uint256, bool, uint256, uint256, bytes, uint256)); + + sellToUniswapV4(recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills, amountOutMin); } else { return false; } diff --git a/src/chains/Unichain/MetaTxn.sol b/src/chains/Unichain/MetaTxn.sol index 39fd7272..7622f203 100644 --- a/src/chains/Unichain/MetaTxn.sol +++ b/src/chains/Unichain/MetaTxn.sol @@ -25,6 +25,20 @@ contract UnichainSettlerMetaTxn is SettlerMetaTxn, UnichainMixin { { if (super._dispatchVIP(action, data, sig)) { return true; + } else if (action == uint32(ISettlerActions.METATXN_UNISWAPV4_VIP.selector)) { + ( + address recipient, + bool feeOnTransfer, + uint256 hashMul, + uint256 hashMod, + bytes memory fills, + ISignatureTransfer.PermitTransferFrom memory permit, + uint256 amountOutMin + ) = abi.decode( + data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, uint256) + ); + + sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin); } else { return false; } diff --git a/src/chains/Unichain/TakerSubmitted.sol b/src/chains/Unichain/TakerSubmitted.sol index b85ae905..cc1570fc 100644 --- a/src/chains/Unichain/TakerSubmitted.sol +++ b/src/chains/Unichain/TakerSubmitted.sol @@ -21,6 +21,21 @@ contract UnichainSettler is Settler, UnichainMixin { function _dispatchVIP(uint256 action, bytes calldata data) internal override DANGEROUS_freeMemory returns (bool) { if (super._dispatchVIP(action, data)) { return true; + } else if (action == uint32(ISettlerActions.UNISWAPV4_VIP.selector)) { + ( + address recipient, + bool feeOnTransfer, + uint256 hashMul, + uint256 hashMod, + bytes memory fills, + ISignatureTransfer.PermitTransferFrom memory permit, + bytes memory sig, + uint256 amountOutMin + ) = abi.decode( + data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, bytes, uint256) + ); + + sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin); } else { return false; }