@@ -137,34 +137,7 @@ abstract contract MainnetMixin is
137137 token.safeTransfer (recipient, balance);
138138 }
139139 }
140- } else if (action == uint32 (ISettlerActions.NATIVE_CHECK.selector )) {
141- uint256 deadline;
142- uint256 msgValue;
143- assembly ("memory-safe" ) {
144- deadline := calldataload (data.offset)
145- msgValue := calldataload (add (data.offset, 0x20 ))
146- }
147- if (block .timestamp > deadline) {
148- assembly ("memory-safe" ) {
149- mstore (0x00 , 0xcd21db4f ) // selector for `SignatureExpired(uint256)`
150- mstore (0x20 , deadline)
151- revert (0x1c , 0x24 )
152- }
153- }
154- if (msg .value > msgValue) {
155- assembly ("memory-safe" ) {
156- mstore (0x00 , 0x4a094431 ) // selector for `MsgValueMismatch(uint256,uint256)`
157- mstore (0x20 , msgValue)
158- mstore (0x40 , callvalue ())
159- revert (0x1c , 0x44 )
160- }
161- }
162- } else if (
163- action == uint32 (ISettlerActions.UNISWAPV4.selector )
164- || action == uint32 (ISettlerActions.BALANCERV3.selector )
165- || action == uint32 (ISettlerActions.EKUBO.selector )
166- || action == uint32 (ISettlerActions.EKUBOV3.selector )
167- ) {
140+ } else if (action == uint32 (ISettlerActions.UNISWAPV4.selector )) {
168141 (
169142 address payable recipient ,
170143 IERC20 sellToken ,
@@ -176,18 +149,8 @@ abstract contract MainnetMixin is
176149 uint256 minAmountOut
177150 ) = abi.decode (data, (address , IERC20 , uint256 , bool , uint256 , uint256 , bytes , uint256 ));
178151 IERC20 buyToken;
179- IERC20 actualBuyToken;
180- uint256 actualAmountOut;
181152 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
182- if (action == uint32 (ISettlerActions.UNISWAPV4.selector )) {
183- (actualBuyToken, actualAmountOut) = sellToUniswapV4 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills);
184- } else if (action == uint32 (ISettlerActions.BALANCERV3.selector )) {
185- (actualBuyToken, actualAmountOut) = sellToBalancerV3 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills);
186- } else if (action == uint32 (ISettlerActions.EKUBO.selector )) {
187- (actualBuyToken, actualAmountOut) = sellToEkuboV2 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills);
188- } else {
189- (actualBuyToken, actualAmountOut) = sellToEkuboV3 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills);
190- }
153+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToUniswapV4 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills);
191154 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
192155 } else if (action == uint32 (ISettlerActions.MAKERPSM.selector )) {
193156 (address payable recipient , uint256 bps , bool buyGem , uint256 minAmountOut , IPSM psm , IERC20 dai ) =
@@ -203,125 +166,93 @@ abstract contract MainnetMixin is
203166 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
204167 (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToEulerSwap (recipient, sellToken, bps, pool, zeroForOne);
205168 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
206- } else if (action == uint32 (ISettlerActions.MAVERICKV2 .selector )) {
169+ } else if (action == uint32 (ISettlerActions.BALANCERV3 .selector )) {
207170 (
208171 address payable recipient ,
209172 IERC20 sellToken ,
210173 uint256 bps ,
211- IMaverickV2Pool pool ,
212- bool tokenAIn ,
213- int32 tickLimit ,
174+ bool feeOnTransfer ,
175+ uint256 hashMul ,
176+ uint256 hashMod ,
177+ bytes memory fills ,
214178 uint256 minAmountOut
215- ) = abi.decode (data, (address , IERC20 , uint256 , IMaverickV2Pool, bool , int32 , uint256 ));
179+ ) = abi.decode (data, (address , IERC20 , uint256 , bool , uint256 , uint256 , bytes , uint256 ));
216180 IERC20 buyToken;
217181 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
218- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToMaverickV2 (recipient, sellToken, bps, pool, tokenAIn, tickLimit );
182+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToBalancerV3 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills );
219183 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
220- } else if (action == uint32 (ISettlerActions.BEBOP .selector )) {
184+ } else if (action == uint32 (ISettlerActions.MAVERICKV2 .selector )) {
221185 (
222186 address payable recipient ,
223187 IERC20 sellToken ,
224- ISettlerActions.BebopOrder memory order ,
225- ISettlerActions.BebopMakerSignature memory makerSignature ,
188+ uint256 bps ,
189+ IMaverickV2Pool pool ,
190+ bool tokenAIn ,
191+ int32 tickLimit ,
226192 uint256 minAmountOut
227- ) = abi.decode (
228- data, (address , IERC20 , ISettlerActions.BebopOrder, ISettlerActions.BebopMakerSignature, uint256 )
229- );
230- IERC20 buyToken;
231- (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
232- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToBebop (recipient, sellToken, order, makerSignature);
233- _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
234- } else if (action == uint32 (ISettlerActions.DODOV2.selector )) {
235- (address payable recipient , IERC20 sellToken , uint256 bps , IDodoV2 dodo , bool quoteForBase , uint256 minAmountOut ) =
236- abi.decode (data, (address , IERC20 , uint256 , IDodoV2, bool , uint256 ));
193+ ) = abi.decode (data, (address , IERC20 , uint256 , IMaverickV2Pool, bool , int32 , uint256 ));
237194 IERC20 buyToken;
238195 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
239- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToDodoV2 (recipient, sellToken, bps, dodo, quoteForBase );
196+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToMaverickV2 (recipient, sellToken, bps, pool, tokenAIn, tickLimit );
240197 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
241- } else if (action == uint32 (ISettlerActions.DODOV1.selector )) {
242- (IERC20 sellToken , uint256 bps , IDodoV1 dodo , bool quoteForBase , uint256 minAmountOut ) =
243- abi.decode (data, (IERC20 , uint256 , IDodoV1, bool , uint256 ));
244-
245- sellToDodoV1 (sellToken, bps, dodo, quoteForBase, minAmountOut);
246- } else if (action == uint32 (ISettlerActions.CHECK_SLIPPAGE.selector )) {
247- _checkSlippageAndTransfer (slippage, abi.decode (data, (bool )));
248- } else {
249- return false ;
250- }
251- return true ;
252- }
253-
254- function _dispatchVIP (uint256 action , bytes calldata data , AllowedSlippage memory slippage )
255- internal
256- virtual
257- DANGEROUS_freeMemory
258- returns (bool )
259- {
260- if (action == uint32 (ISettlerActions.UNISWAPV4_VIP.selector )) {
198+ } else if (action == uint32 (ISettlerActions.EKUBO.selector )) {
261199 (
262200 address payable recipient ,
263- ISignatureTransfer.PermitTransferFrom memory permit ,
201+ IERC20 sellToken ,
202+ uint256 bps ,
264203 bool feeOnTransfer ,
265204 uint256 hashMul ,
266205 uint256 hashMod ,
267206 bytes memory fills ,
268- bytes memory sig ,
269207 uint256 minAmountOut
270- ) = abi.decode (
271- data, (address , ISignatureTransfer.PermitTransferFrom, bool , uint256 , uint256 , bytes , bytes , uint256 )
272- );
208+ ) = abi.decode (data, (address , IERC20 , uint256 , bool , uint256 , uint256 , bytes , uint256 ));
273209 IERC20 buyToken;
274210 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
275- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToUniswapV4VIP (recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig );
211+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToEkuboV2 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills );
276212 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
277- } else if (action == uint32 (ISettlerActions.BALANCERV3_VIP .selector )) {
213+ } else if (action == uint32 (ISettlerActions.EKUBOV3 .selector )) {
278214 (
279215 address payable recipient ,
280- ISignatureTransfer.PermitTransferFrom memory permit ,
216+ IERC20 sellToken ,
217+ uint256 bps ,
281218 bool feeOnTransfer ,
282219 uint256 hashMul ,
283220 uint256 hashMod ,
284221 bytes memory fills ,
285- bytes memory sig ,
286222 uint256 minAmountOut
287- ) = abi.decode (
288- data, (address , ISignatureTransfer.PermitTransferFrom, bool , uint256 , uint256 , bytes , bytes , uint256 )
289- );
223+ ) = abi.decode (data, (address , IERC20 , uint256 , bool , uint256 , uint256 , bytes , uint256 ));
290224 IERC20 buyToken;
291225 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
292- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToBalancerV3VIP (recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig );
226+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToEkuboV3 (recipient, sellToken, bps, feeOnTransfer, hashMul, hashMod, fills );
293227 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
294- } else if (action == uint32 (ISettlerActions.MAVERICKV2_VIP .selector )) {
228+ } else if (action == uint32 (ISettlerActions.BEBOP .selector )) {
295229 (
296230 address payable recipient ,
297- ISignatureTransfer.PermitTransferFrom memory permit ,
298- bytes32 salt ,
299- bool tokenAIn ,
300- bytes memory sig ,
301- int32 tickLimit ,
231+ IERC20 sellToken ,
232+ ISettlerActions.BebopOrder memory order ,
233+ ISettlerActions.BebopMakerSignature memory makerSignature ,
302234 uint256 minAmountOut
303- ) = abi.decode (data, (address , ISignatureTransfer.PermitTransferFrom, bytes32 , bool , bytes , int32 , uint256 ));
235+ ) = abi.decode (
236+ data, (address , IERC20 , ISettlerActions.BebopOrder, ISettlerActions.BebopMakerSignature, uint256 )
237+ );
304238 IERC20 buyToken;
305239 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
306- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToMaverickV2VIP (recipient, salt, tokenAIn, permit, sig, tickLimit );
240+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToBebop (recipient, sellToken, order, makerSignature );
307241 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
308- } else if (action == uint32 (ISettlerActions.EKUBOV3_VIP.selector )) {
309- (
310- address payable recipient ,
311- ISignatureTransfer.PermitTransferFrom memory permit ,
312- bool feeOnTransfer ,
313- uint256 hashMul ,
314- uint256 hashMod ,
315- bytes memory fills ,
316- bytes memory sig ,
317- uint256 minAmountOut
318- ) = abi.decode (
319- data, (address , ISignatureTransfer.PermitTransferFrom, bool , uint256 , uint256 , bytes , bytes , uint256 )
320- );
242+ } else if (action == uint32 (ISettlerActions.DODOV2.selector )) {
243+ (address payable recipient , IERC20 sellToken , uint256 bps , IDodoV2 dodo , bool quoteForBase , uint256 minAmountOut ) =
244+ abi.decode (data, (address , IERC20 , uint256 , IDodoV2, bool , uint256 ));
321245 IERC20 buyToken;
322246 (recipient, buyToken, minAmountOut) = _maybeSetSlippage (slippage, recipient, minAmountOut);
323- (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToEkuboV3VIP (recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig );
247+ (IERC20 actualBuyToken , uint256 actualAmountOut ) = sellToDodoV2 (recipient, sellToken, bps, dodo, quoteForBase );
324248 _checkSlippage (buyToken, minAmountOut, actualBuyToken, actualAmountOut);
249+ } else if (action == uint32 (ISettlerActions.DODOV1.selector )) {
250+ (IERC20 sellToken , uint256 bps , IDodoV1 dodo , bool quoteForBase , uint256 minAmountOut ) =
251+ abi.decode (data, (IERC20 , uint256 , IDodoV1, bool , uint256 ));
252+
253+ sellToDodoV1 (sellToken, bps, dodo, quoteForBase, minAmountOut);
254+ } else if (action == uint32 (ISettlerActions.CHECK_SLIPPAGE.selector )) {
255+ _checkSlippageAndTransfer (slippage, abi.decode (data, (bool )));
325256 } else {
326257 return false ;
327258 }
0 commit comments