From 6ca09e44eb2f9783d0ce922a7a1a0ed56a21aa9c Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 19 Sep 2024 12:55:36 -0400 Subject: [PATCH] need aggslippage check --- sdks/universal-router-sdk/src/entities/actions/uniswap.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts index 0ad6ac57e..2e44ef669 100644 --- a/sdks/universal-router-sdk/src/entities/actions/uniswap.ts +++ b/sdks/universal-router-sdk/src/entities/actions/uniswap.ts @@ -96,7 +96,7 @@ export class UniswapTrade implements Command { addV3Swap(planner, swap, this.trade.tradeType, this.options, this.payerIsUser, routerMustCustody) break case Protocol.V4: - addV4Swap(planner, swap, this.trade.tradeType, this.options, this.payerIsUser, routerMustCustody) + addV4Swap(planner, swap, this.trade.tradeType, this.options, this.payerIsUser, routerMustCustody, performAggregatedSlippageCheck) break case Protocol.MIXED: addMixedSwap(planner, swap, this.trade.tradeType, this.options, this.payerIsUser, routerMustCustody) @@ -248,7 +248,8 @@ function addV4Swap( tradeType: TradeType, options: SwapOptions, payerIsUser: boolean, - routerMustCustody: boolean + routerMustCustody: boolean, + performAggregatedSlippageCheck: boolean ): void { const trade = V4Trade.createUncheckedTrade({ route: route as RouteV4, @@ -257,7 +258,8 @@ function addV4Swap( tradeType, }) - const v4Calldata = new V4Planner().addTrade(trade, routerMustCustody ? 0 : options.slippageTolerance).finalize() + const slippageToleranceOnSwap = performAggregatedSlippageCheck ? undefined : options.slippageTolerance + const v4Calldata = new V4Planner().addTrade(trade, slippageToleranceOnSwap).finalize() planner.addCommand(CommandType.V4_SWAP, [v4Calldata]) }