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AA,EAAAA,KAAAA,EAAAA,EAAMtG,YAAY,GAAI,CACxBA,aAAcsG,EAAKtG,YAAY,CAChC,CACH,GAEF+D,EAAiB,GAAW,EAC1ByB,iBAAkBc,EAAKd,gBAAgB,CACvCX,SAAUyB,EAAKzB,QAAQ,CACvByJ,WAAYhI,EAAKgI,UAAU,CAC3B,GAAGlN,EACDmC,EAAKlC,WAAW,CAChBkC,EAAKjC,WAAW,CAChBoX,EACD,CACH,GACAzC,GACF,EAEA,OAAOrI,EACL,GAAArH,EAAAC,GAAA,EAACmS,EAAAA,EAAgBA,CAAAA,CACftb,OAAQA,EACR8Q,eAAgBA,EAChBzK,iBAAkBA,EAClB1F,YAAaZ,EAASY,WAAW,CACjC2S,cAAeA,EACftD,WAAYA,EACZ4D,OAAQlC,EACR2B,SAAU9D,IAGZ,GAAArG,EAAAC,GAAA,EAACoS,EAAAA,GAAqBA,CAAAA,CACpBvb,OAAQA,EACRiC,QAASsN,EACTyE,OAAQ4E,GAEX,AACH","sources":["webpack://_N_E/./hooks/useOnCondition.ts","webpack://_N_E/./views/Strategy/Edit/utils.ts","webpack://_N_E/./views/Strategy/Edit/Context.tsx","webpack://_N_E/./views/Strategy/Edit/AdvancedSettings.tsx","webpack://_N_E/./views/Strategy/Edit/ButtonGroups.tsx","webpack://_N_E/./views/Strategy/Edit/EditTriggerCondition.tsx","webpack://_N_E/./views/Strategy/Edit/Edit.tsx","webpack://_N_E/./views/Strategy/Edit/PositionInfoCard.tsx","webpack://_N_E/./views/Strategy/Edit/TriggerCondition.tsx","webpack://_N_E/./views/Strategy/Edit/index.ts","webpack://_N_E/<anon>"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useEventCallback } from \"./useEventCallback\";\n\nexport const useOnCondition = (condition: boolean, callback: () => void) => {\n  const cb = useEventCallback(callback);\n  useEffect(() => {\n    if (condition) {\n      cb();\n    }\n  }, [cb, condition]);\n};\n","import { useGlobalSlippage } from \"@/components/GlobalStore\";\nimport { IPositionDetails } from \"@/config/position/positionConfig\";\nimport {\n  offsetTickToPercentage,\n  percentageToOffsetTick,\n} from \"@/helper/liquiditySelectorHelper\";\nimport { DEFAULT_REBALANCE_SLIPPAGE } from \"@/utils/helper\";\nimport { ITokenPair } from \"@aperture/types\";\nimport {\n  ITransactionSettingsForm,\n  StrategyDefaultAction,\n  TriggerType,\n  trimNumber,\n} from \"@aperture/uikit\";\nimport {\n  ActionTypeEnum,\n  ApertureSupportedChainId,\n  RecurringAction,\n  RecurringCondition,\n  RecurringConditionTypeEnum,\n  RecurringDualAction,\n  RecurringPriceCondition,\n  RecurringRatioCondition,\n  parsePrice,\n  priceToClosestUsableTick,\n  priceToSqrtRatioX96,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { IDualTriggerState } from \"@ui/components/Strategy\";\nimport { Token } from \"@uniswap/sdk-core\";\nimport Big from \"big.js\";\nimport bigDecimal from \"js-big-decimal\";\nimport { useCallback, useState } from \"react\";\n\nexport function useTransactionSettingForms() {\n  const { globalSlippage } = useGlobalSlippage();\n  const init = {\n    slippage: globalSlippage ?? DEFAULT_REBALANCE_SLIPPAGE,\n    deadline: \"30\",\n  };\n  const [txnSetting, setTxnSetting] = useState<ITransactionSettingsForm>(init);\n\n  return {\n    txnSetting,\n    setTxnSetting,\n    resetTxnSetting: useCallback(() => setTxnSetting(init), []),\n  };\n}\n\nexport function getDefaultStrategyAction(\n  networkId: ApertureSupportedChainId,\n  position: IPositionDetails,\n  tokens: ITokenPair,\n  tokenMarketPrice0: string\n): StrategyDefaultAction {\n  const tickCurrent = priceToClosestUsableTick(\n    parsePrice(\n      new Token(\n        networkId,\n        tokens[0].address,\n        tokens[0].decimals,\n        tokens[0].ticker,\n        tokens[0].name\n      ),\n      new Token(\n        networkId,\n        tokens[1].address,\n        tokens[1].decimals,\n        tokens[1].ticker,\n        tokens[1].name\n      ),\n      tokenMarketPrice0\n    ),\n    undefined,\n    position.tickSpacing\n  );\n  let actionTickLower = position.tickLower;\n  let actionTickUpper = position.tickUpper;\n  const rangeWidth = position.tickUpper - position.tickLower;\n  // Handle position out of range\n  // Set the default out of range tick to curent tick, and keep the range width\n  if (actionTickLower > tickCurrent) {\n    actionTickLower = tickCurrent;\n    actionTickUpper = tickCurrent + rangeWidth;\n  } else if (actionTickUpper < tickCurrent) {\n    actionTickLower = tickCurrent - rangeWidth;\n    actionTickUpper = tickCurrent;\n  }\n  const percentLower = offsetTickToPercentage(actionTickLower - tickCurrent);\n  const percentUpper = offsetTickToPercentage(actionTickUpper - tickCurrent);\n  const priceLower = bigDecimal.subtract(\n    bigDecimal.divide(\n      bigDecimal.multiply(tokenMarketPrice0, 100 + Number(percentLower)),\n      100,\n      18\n    ),\n    tokenMarketPrice0\n  );\n  const priceUpper = bigDecimal.subtract(\n    bigDecimal.divide(\n      bigDecimal.multiply(tokenMarketPrice0, 100 + Number(percentUpper)),\n      100,\n      18\n    ),\n    tokenMarketPrice0\n  );\n  const token0USDAmount = bigDecimal.multiply(\n    tokens[0].amount,\n    tokens[0].price\n  );\n  const token1USDAmount = bigDecimal.multiply(\n    tokens[1].amount,\n    tokens[1].price\n  );\n  const ratioDemonimator = Number(token0USDAmount) + Number(token1USDAmount);\n  const ratioLower = (\n    ratioDemonimator === 0\n      ? 50\n      : (Number(token0USDAmount) / ratioDemonimator) * 100\n  ).toString();\n  const ratioUpper = bigDecimal.subtract(100, ratioLower);\n\n  return {\n    percentLower,\n    percentUpper,\n    priceLower,\n    priceUpper,\n    ratioLower,\n    ratioUpper,\n    rangeWidth: rangeWidth.toString(),\n  };\n}\n\nexport function convertClientToTriggerCondition(\n  trigger: IDualTriggerState,\n  position: IPositionDetails\n): RecurringCondition {\n  const {\n    baseToken,\n    triggerType,\n    timeBuffer,\n    above,\n    below,\n    timeBufferChecked,\n    aboveChecked,\n    belowChecked,\n  } = trigger;\n\n  const common = {\n    sqrtPriceX96: priceToSqrtRatioX96(\n      new Big(position.tokenA.price)\n    ).toString(),\n    ...(timeBufferChecked && {\n      durationSec: parseFloat(bigDecimal.multiply(timeBuffer, 3600)),\n    }),\n  };\n\n  const gteEnabled =\n    (aboveChecked && baseToken === 0) || (belowChecked && baseToken === 1);\n  const lteEnabled =\n    (belowChecked && baseToken === 0) || (aboveChecked && baseToken === 1);\n\n  if (triggerType === TriggerType.PRICE_PERCENTAGE) {\n    return {\n      ...common,\n      type: \"RecurringPercentage\",\n      gteTickOffset: gteEnabled\n        ? baseToken === 0\n          ? percentageToOffsetTick(Number(above), 0)\n          : -percentageToOffsetTick(-Number(below), -100, 0)\n        : undefined,\n      lteTickOffset: lteEnabled\n        ? baseToken === 0\n          ? percentageToOffsetTick(-Number(below), -100, 0)\n          : -percentageToOffsetTick(Number(above), 0)\n        : undefined,\n    };\n  } else if (triggerType === TriggerType.PRICE) {\n    return {\n      ...common,\n      type: \"RecurringPrice\",\n      baseToken,\n      gtePriceOffset: gteEnabled ? above : undefined,\n      ltePriceOffset: lteEnabled ? bigDecimal.negate(below) : undefined,\n    } as RecurringPriceCondition;\n  } else if (triggerType === TriggerType.RATIO) {\n    const token0RatioAbove = (\n      (baseToken ? 100 - parseFloat(below) : parseFloat(above)) / 100\n    ).toFixed(4);\n    const token0RatioBelow = (\n      (baseToken ? 100 - parseFloat(above) : parseFloat(below)) / 100\n    ).toFixed(4);\n    return {\n      ...common,\n      type: \"RecurringRatio\",\n      gteToken0ValueProportion: gteEnabled ? token0RatioAbove : undefined,\n      lteToken0ValueProportion: lteEnabled ? token0RatioBelow : undefined,\n    } as RecurringRatioCondition;\n  }\n  return null;\n}\n\nexport function convertTriggerConditionToClient(\n  condition: RecurringCondition\n): IDualTriggerState {\n  if (!condition) return null;\n\n  const { durationSec } = condition;\n\n  const common = {\n    timeBufferChecked: durationSec !== undefined,\n    timeBuffer: durationSec\n      ? trimNumber(bigDecimal.divide(durationSec, 3600, 8))\n      : \"0\",\n  };\n\n  if (\n    condition.type === RecurringConditionTypeEnum.Values.RecurringPercentage\n  ) {\n    const { gteTickOffset, lteTickOffset } = condition;\n    return {\n      ...common,\n      triggerType: TriggerType.PRICE_PERCENTAGE,\n      baseToken: 0,\n      aboveChecked: gteTickOffset !== undefined,\n      belowChecked: lteTickOffset !== undefined,\n      below: `${\n        lteTickOffset ? offsetTickToPercentage(lteTickOffset, true) : 0\n      }`,\n      above: `${\n        gteTickOffset ? offsetTickToPercentage(gteTickOffset, true) : 0\n      }`,\n    };\n  }\n  if (condition.type === RecurringConditionTypeEnum.Values.RecurringPrice) {\n    const { gtePriceOffset, ltePriceOffset } = condition;\n\n    return {\n      ...common,\n      triggerType: TriggerType.PRICE,\n      baseToken: condition.baseToken,\n      aboveChecked: gtePriceOffset !== undefined,\n      belowChecked: ltePriceOffset !== undefined,\n      below: `${ltePriceOffset ? bigDecimal.negate(ltePriceOffset) : 0}`,\n      above: `${gtePriceOffset ?? 0}`,\n    };\n  }\n  if (condition.type === RecurringConditionTypeEnum.Values.RecurringRatio) {\n    const { gteToken0ValueProportion, lteToken0ValueProportion } = condition;\n    return {\n      ...common,\n      triggerType: TriggerType.RATIO,\n      baseToken: 0,\n      aboveChecked: gteToken0ValueProportion !== undefined,\n      belowChecked: lteToken0ValueProportion !== undefined,\n      below: `${\n        lteToken0ValueProportion\n          ? Math.floor(parseFloat(lteToken0ValueProportion) * 10000) / 100\n          : 0\n      }`,\n      above: `${\n        gteToken0ValueProportion\n          ? Math.floor(parseFloat(gteToken0ValueProportion) * 10000) / 100\n          : 0\n      }`,\n    };\n  }\n}\n\nexport function convertToTriggerAction(\n  aboveAction?: RecurringAction,\n  belowAction?: RecurringAction,\n  swapLteGte?: boolean\n) {\n  if (aboveAction && belowAction) {\n    const lteAction = getDualAction(swapLteGte ? aboveAction : belowAction);\n    const gteAction = getDualAction(swapLteGte ? belowAction : aboveAction);\n    return {\n      type: ActionTypeEnum.Values.RecurringDualAction,\n      lteAction,\n      gteAction,\n    };\n  } else if (aboveAction) {\n    return aboveAction;\n  } else if (belowAction) {\n    return belowAction;\n  }\n}\n\nfunction getDualAction(action: RecurringAction) {\n  const common = [\"slippage\", \"maxGasProportion\", \"strategyId\", \"type\"];\n  return Object.entries(action).reduce((acc, [key, value]) => {\n    if (!common.includes(key)) {\n      acc[key] = value;\n    }\n    return acc;\n  }, {} as RecurringDualAction[\"gteAction\"] | RecurringDualAction[\"lteAction\"]);\n}\n","import { useGlobalSlippage } from \"@/components/GlobalStore\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { IPositionDetails } from \"@/config/position/positionConfig\";\nimport { getTriggerDeadline } from \"@/helper/deadlineHelper\";\nimport { useCurrentChainToken } from \"@/hooks/globalState/useCurrentChainToken\";\nimport {\n  usePositionAutoCompound,\n  usePositionStrategy,\n} from \"@/hooks/trigger/usePositionTrigger\";\nimport { useEventCallback } from \"@/hooks/useEventCallback\";\nimport { TokenPriceMap } from \"@/hooks/useFetchAllChainsTokensPrice\";\nimport { useFetchCurrentChainMarketPrice } from \"@/hooks/useFetchMarketPrice\";\nimport {\n  DEFAULT_SLIPPAGE,\n  gasCeilingButtonError,\n  getGasCeiling,\n} from \"@/utils/helper\";\nimport { ITokenPair } from \"@aperture/types\";\nimport { ITransactionSettingsForm } from \"@aperture/uikit\";\nimport {\n  ApertureSupportedChainId,\n  CreateTriggerPayload,\n  RecurringAction,\n  RecurringCondition,\n  TriggerItem,\n  UpdateTriggerPayload,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport _ from \"lodash\";\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { useAccount } from \"wagmi\";\nimport { useTransactionSettingForms } from \"./utils\";\n\ntype AutoCompoundPayload = Pick<TriggerItem, \"condition\" | \"action\">;\n\nexport interface IStrategyContext {\n  position: IPositionDetails;\n  triggerCondition: RecurringCondition;\n  triggerAction: RecurringAction;\n  autoCompoundExists: boolean;\n  autoCompoundError: string;\n  autoCompound: AutoCompoundPayload;\n  tokens: ITokenPair;\n  tokenMarketPrice: {\n    tokenA: string;\n    tokenB: string;\n  };\n  txnSetting: ITransactionSettingsForm;\n  enableAutoCompound: boolean;\n  isStrategyNotChanged: boolean;\n  isTriggerLoaded: boolean;\n  taskId: number;\n  useInit: () => void;\n  getTriggerPayload: (\n    isCreate?: boolean\n  ) => CreateTriggerPayload | UpdateTriggerPayload;\n  setEnableAutoCompound: React.Dispatch<React.SetStateAction<boolean>>;\n  setTriggerCondition: React.Dispatch<React.SetStateAction<RecurringCondition>>;\n  setTriggerAction: React.Dispatch<React.SetStateAction<RecurringAction>>;\n  setAutoCompound: React.Dispatch<React.SetStateAction<AutoCompoundPayload>>;\n  setTxnSetting: React.Dispatch<React.SetStateAction<ITransactionSettingsForm>>;\n}\n\nconst StrategyContext = React.createContext<IStrategyContext>(null as any);\n\ninterface StrategyProviderProps {\n  position: IPositionDetails;\n}\n\nexport const StrategyProvider: React.FC<\n  React.PropsWithChildren<StrategyProviderProps>\n> = ({ children, position, ...props }) => {\n  const initRef = useRef<{ trigger: TriggerItem; autoCompound: TriggerItem }>({\n    trigger: null as any,\n    autoCompound: null as any,\n  });\n\n  const { ammEnum, networkId } = useNetwork();\n  const { address } = useAccount();\n  const { currentTokenPrice: tokenPriceList } = useCurrentChainToken(networkId);\n\n  const tokens = useMemo(\n    () => getTokensWithPrice(position, tokenPriceList),\n    [position, tokenPriceList]\n  );\n\n  const poolKey =\n    ammEnum === \"SLIPSTREAM\" ? position.tickSpacing : position.feeTier;\n  const { data: marketPrice } = useFetchCurrentChainMarketPrice(\n    tokens[0].address,\n    tokens[1].address,\n    [poolKey]\n  );\n\n  const tokenMarketPrice = useMemo(() => {\n    return (\n      marketPrice?.[poolKey] ?? {\n        tokenA: \"0\",\n        tokenB: \"0\",\n      }\n    );\n  }, [marketPrice, poolKey]);\n\n  const [triggerCondition, setTriggerCondition] =\n    useState<RecurringCondition>(null);\n  const [triggerAction, setTriggerAction] = useState<RecurringAction>(null);\n  const { globalSlippage } = useGlobalSlippage();\n  const [autoCompoundPayload, setAutoCompoundPayload] =\n    useState<AutoCompoundPayload>(\n      getInitAutoCompoundPayload(networkId, position.liquidity, globalSlippage)\n    );\n\n  const [enableAutoCompound, setEnableAutoCompound] = useState<boolean>(false);\n  const { txnSetting, setTxnSetting, resetTxnSetting } =\n    useTransactionSettingForms();\n  const _triggerAction = useMemo(() => {\n    return {\n      ...triggerAction,\n      slippage: txnSetting.slippage,\n    };\n  }, [triggerAction, txnSetting.slippage]);\n\n  const isConditionNotChanged = useMemo(() => {\n    return _.isEqual(triggerCondition, initRef.current.trigger?.condition);\n  }, [triggerCondition]);\n\n  const isActionNotChanged = useMemo(() => {\n    return _.isEqual(_triggerAction, initRef.current.trigger?.action);\n  }, [_triggerAction]);\n\n  const autoCompoundError = useMemo(\n    () =>\n      (triggerAction &&\n        gasCeilingButtonError(\n          networkId,\n          triggerAction.maxGasProportion,\n          position.liquidity\n        )) ||\n      (!initRef.current.autoCompound &&\n        enableAutoCompound &&\n        gasCeilingButtonError(\n          networkId,\n          autoCompoundPayload.action.maxGasProportion,\n          position.liquidity\n        )),\n    [\n      autoCompoundPayload,\n      enableAutoCompound,\n      networkId,\n      position.liquidity,\n      triggerAction,\n    ]\n  );\n\n  const getTriggerPayload = useEventCallback((isCreate: boolean) => {\n    const common = {\n      ownerAddr: address!,\n      chainId: networkId,\n      condition: triggerCondition,\n      action: _triggerAction,\n      expiration: getTriggerDeadline(),\n    };\n\n    if (isCreate) {\n      return {\n        ...common,\n        ...(enableAutoCompound &&\n          !initRef.current.autoCompound && {\n            autoCompound: autoCompoundPayload,\n          }),\n        amm: ammEnum,\n        nftId: position.positionId,\n      } as CreateTriggerPayload;\n    }\n\n    const payload: UpdateTriggerPayload = {\n      ...common,\n      taskId: initRef.current.trigger?.taskId,\n    };\n\n    if (isConditionNotChanged) {\n      payload.condition = undefined;\n    }\n\n    if (isActionNotChanged) {\n      payload.action = undefined;\n    }\n\n    return payload;\n  });\n\n  const useInit = () => {\n    const { trigger, autoCompound } = useFetch(\n      position.positionId,\n      position.chainId\n    );\n\n    useEffect(() => {\n      // reset form\n      return () => {\n        setTriggerCondition(null);\n        setTriggerAction(null);\n        setEnableAutoCompound(false);\n        setAutoCompoundPayload(\n          getInitAutoCompoundPayload(\n            networkId,\n            position.liquidity,\n            globalSlippage\n          )\n        );\n        resetTxnSetting();\n      };\n    }, []);\n\n    useEffect(() => {\n      if (trigger) {\n        initRef.current.trigger = trigger;\n        const action = trigger.action as RecurringAction;\n        setTriggerCondition(trigger.condition as RecurringCondition);\n        setTriggerAction(action);\n        setTxnSetting((prev) => ({\n          ...prev,\n          slippage: action?.slippage,\n        }));\n      }\n    }, [trigger]);\n\n    useEffect(() => {\n      if (autoCompound) {\n        initRef.current.autoCompound = autoCompound;\n        setAutoCompoundPayload(_.pick(autoCompound, [\"condition\", \"action\"]));\n        setEnableAutoCompound(true);\n      }\n    }, [autoCompound]);\n  };\n\n  return (\n    <StrategyContext.Provider\n      value={{\n        tokens,\n        tokenMarketPrice,\n        triggerCondition,\n        setTriggerCondition,\n        triggerAction: _triggerAction,\n        setTriggerAction,\n        autoCompoundExists: !!initRef.current.autoCompound,\n        autoCompoundError: autoCompoundError,\n        autoCompound: autoCompoundPayload,\n        setAutoCompound: setAutoCompoundPayload,\n        position: position,\n        txnSetting,\n        setTxnSetting,\n        enableAutoCompound,\n        setEnableAutoCompound,\n        getTriggerPayload,\n        isTriggerLoaded: !!(triggerCondition && triggerAction),\n        isStrategyNotChanged: isConditionNotChanged && isActionNotChanged, // TODO: add isAutoCompoundChanged\n        useInit,\n        taskId: initRef.current.trigger?.taskId,\n        ...props,\n      }}\n    >\n      {children}\n    </StrategyContext.Provider>\n  );\n};\n\nexport const useEditStrategyContext = () => {\n  return React.useContext(StrategyContext);\n};\n\nfunction getTokensWithPrice(\n  position: IPositionDetails,\n  tokenPriceList: TokenPriceMap\n): ITokenPair {\n  return [\n    {\n      ...position.tokenA,\n      price: tokenPriceList?.[position.tokenA.address]?.price || \"0\",\n    },\n    {\n      ...position.tokenB,\n      price: tokenPriceList?.[position.tokenB.address]?.price || \"0\",\n    },\n  ];\n}\n\nconst useFetch = (positionId: string, chainId: ApertureSupportedChainId) => {\n  const trigger = usePositionStrategy(positionId, chainId);\n  const autoCompound = usePositionAutoCompound(positionId, chainId);\n\n  return {\n    trigger,\n    autoCompound,\n  };\n};\n\nconst getInitAutoCompoundPayload = (\n  networkId: ApertureSupportedChainId,\n  liquidity: string,\n  globalSlippage?: number\n) =>\n  ({\n    condition: {\n      feeToPrincipalRatioThreshold: 0.05,\n      type: \"AccruedFees\",\n    },\n    action: {\n      maxGasProportion: getGasCeiling(networkId, liquidity),\n      slippage: globalSlippage ?? DEFAULT_SLIPPAGE,\n      type: \"Reinvest\",\n    },\n  } as AutoCompoundPayload);\n","import { useGlobalSlippage } from \"@/components/GlobalStore\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useOnCondition } from \"@/hooks/useOnCondition\";\nimport {\n  DEFAULT_SLIPPAGE,\n  WARNING_SLIPPAGE,\n  gasCeilingInputError,\n  getGasCeiling,\n} from \"@/utils/helper\";\nimport { StrategyAdvancedSettings } from \"@aperture/uikit\";\nimport {\n  AccruedFeesCondition,\n  ReinvestAction,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport { useCallback, useState } from \"react\";\nimport { useEditStrategyContext } from \"./Context\";\n\nexport const AdvancedSettings: React.FC<{\n  isCreate?: boolean;\n  bg?: string;\n}> = ({ isCreate, bg }) => {\n  const {\n    position,\n    triggerAction,\n    setTriggerAction,\n    autoCompound,\n    autoCompoundExists,\n    setAutoCompound,\n    enableAutoCompound,\n    setEnableAutoCompound,\n    autoCompoundError,\n  } = useEditStrategyContext();\n\n  const { networkId } = useNetwork();\n  const { globalSlippage, setGlobalSlippage } = useGlobalSlippage();\n  const [applyGlobally, setApplyGlobally] = useState(false);\n\n  const gasCeiling = triggerAction?.maxGasProportion;\n\n  const minFees = (autoCompound.condition as AccruedFeesCondition)\n    .feeToPrincipalRatioThreshold;\n  const maxGasFee = (autoCompound.action as ReinvestAction).maxGasProportion;\n  const slippage = (autoCompound.action as ReinvestAction).slippage;\n\n  useOnCondition(isCreate, () => {\n    handleGasCeilingChange(getGasCeiling(networkId, position.liquidity));\n  });\n\n  const handleAutoCompoundChange = () => {\n    setEnableAutoCompound(!enableAutoCompound);\n  };\n  const handleGasCeilingChange = useCallback(\n    (percentage: number) => {\n      setTriggerAction((prev) => ({\n        ...prev,\n        maxGasProportion: percentage,\n      }));\n    },\n    [setTriggerAction]\n  );\n  const handleAcGasCeilingChange = useCallback(\n    (percentage: number) => {\n      setAutoCompound((prev) => ({\n        ...prev,\n        condition: {\n          ...prev.condition,\n          feeToPrincipalRatioThreshold: percentage,\n        },\n      }));\n    },\n    [setAutoCompound]\n  );\n  const handleAcMaxGasChange = useCallback(\n    (percentage: number) => {\n      setAutoCompound((prev) => ({\n        ...prev,\n        action: {\n          ...prev.action,\n          maxGasProportion: percentage,\n        },\n      }));\n    },\n    [setAutoCompound]\n  );\n  const handleAcSlippageChange = useCallback(\n    (percentage: number) => {\n      setAutoCompound((prev) => ({\n        ...prev,\n        action: {\n          ...prev.action,\n          slippage: percentage,\n        },\n      }));\n    },\n    [setAutoCompound]\n  );\n  const handleOnError = useCallback(\n    (percentage: number) =>\n      gasCeilingInputError(networkId, percentage, position.liquidity),\n    [networkId, position.liquidity]\n  );\n\n  return (\n    <StrategyAdvancedSettings\n      bg={bg}\n      isCreate={isCreate}\n      expanded={!!autoCompoundError}\n      hideAutoCompound={!isCreate && !enableAutoCompound}\n      disableAutoCompound={!isCreate || autoCompoundExists}\n      autoCompound={enableAutoCompound}\n      handleAutoCompoundChange={handleAutoCompoundChange}\n      gasCeiling={{\n        amount: position.liquidity,\n        percentage: gasCeiling,\n        onChange: handleGasCeilingChange,\n        onError: handleOnError,\n      }}\n      acGasCeiling={{\n        amount: position.liquidity,\n        percentage: minFees,\n        onChange: handleAcGasCeilingChange,\n      }}\n      acMaxGasFee={{\n        amount: position.liquidity,\n        percentage: maxGasFee,\n        onChange: handleAcMaxGasChange,\n        onError: handleOnError,\n      }}\n      acSlippage={{\n        defaultValue: DEFAULT_SLIPPAGE,\n        globalValue: globalSlippage,\n        warningValue: WARNING_SLIPPAGE,\n        value: slippage,\n        onSlippageChange: handleAcSlippageChange,\n        applyGlobally,\n        onApplyGlobally: (checked) => {\n          setApplyGlobally(checked);\n          checked &&\n            setGlobalSlippage((prev) => ({ ...prev, [networkId]: slippage }));\n        },\n      }}\n    />\n  );\n};\n","import { Button } from \"@aperture/uikit\";\nimport styled from \"styled-components\";\n\ninterface ButtonsGroupProps {\n  cancelText?: string;\n  confirmText?: string | React.ReactNode;\n  addConfirmWrapper?: boolean;\n  disableConfirm?: boolean;\n  width?: string;\n  minWidth?: string;\n  onCancel: () => void;\n  onConfirm: () => void;\n}\n\nconst ButtonItem = styled(Button)<{ black?: boolean }>`\n  font-weight: 500;\n  color: ${({ theme, black }) =>\n    black ? theme.colors.global.text.T1 : theme.colors.global.textAlt.T1};\n  background-color: ${({ theme, black }) =>\n    black ? theme.colors.global.background.BG3 : theme.colors.global.primary};\n  :hover {\n    background-color: ${({ theme, black }) =>\n      black ? theme.colors.global.background.BG4 : theme.colors.global.primary};\n  }\n`;\n\nexport const ButtonsGroup: React.FC<ButtonsGroupProps> = ({\n  cancelText = \"Cancel\",\n  confirmText = \"Confirm\",\n  addConfirmWrapper = true,\n  disableConfirm,\n  width,\n  minWidth,\n  onCancel,\n  onConfirm,\n}) => {\n  return (\n    <>\n      <ButtonItem\n        black\n        size=\"lg\"\n        variant=\"contained\"\n        width={width}\n        minWidth={minWidth}\n        onClick={onCancel}\n      >\n        {cancelText}\n      </ButtonItem>\n      {addConfirmWrapper ? (\n        <ButtonItem\n          variant=\"contained\"\n          color=\"primary\"\n          size=\"lg\"\n          width={width}\n          minWidth={minWidth}\n          disabled={disableConfirm}\n          onClick={onConfirm}\n        >\n          {confirmText}\n        </ButtonItem>\n      ) : (\n        confirmText\n      )}\n    </>\n  );\n};\n","import { DeleteStrategyModal } from \"@/components/Modal/DeleteStrategyModal\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { useEventCallback } from \"@/hooks/useEventCallback\";\nimport { useOnCondition } from \"@/hooks/useOnCondition\";\nimport {\n  DualTriggerContent,\n  E_StrategyModalType,\n  Flex,\n  FlexColumn,\n  getTriggerNotification,\n  notificationVariants,\n  TriggerType,\n  useClickOutside,\n} from \"@aperture/uikit\";\nimport { E_ModalKey, Modal, useModal } from \"@aperture/uikitv2\";\nimport {\n  ActionTypeEnum,\n  RecurringAction,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport {\n  EditTrigger,\n  EditTriggerDetail,\n  IDualTriggerState,\n  IEditTriggerState,\n  StrategyTriggerEditType,\n} from \"@ui/components/Strategy\";\nimport {\n  StyledInputWithTicker,\n  StyledNotification,\n  StyledQuestionPopover,\n} from \"@ui/components/Strategy/DualTriggerSetup/style\";\nimport {\n  emptyDualTriggerForm,\n  getDefaultCacheForm,\n  MAX_TIME_BUFFER,\n} from \"@ui/components/Strategy/utils\";\nimport { getActionType } from \"@ui/components/TriggerList/getStrategyInfo\";\nimport bigDecimal from \"js-big-decimal\";\nimport {\n  Dispatch,\n  SetStateAction,\n  useCallback,\n  useEffect,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\";\nimport styled from \"styled-components\";\nimport { useEditStrategyContext } from \"./Context\";\nimport {\n  convertClientToTriggerCondition,\n  convertToTriggerAction,\n  convertTriggerConditionToClient,\n  getDefaultStrategyAction,\n} from \"./utils\";\n\nconst strings = {\n  timeBufferLabel: \"TWAP Duration\",\n  timeBufferPopover:\n    \"Enabling TWAP (time-weight average price) on your trigger means the average price or ratio based trigger between past specified time and now must be met before the trigger executes. This helps prevent potential price manipulation and examples are for rebalancing if 1) average ETH goes above $3,500 for past 30+ mins or 2) average pool above 80% USDC for past 2+ hrs.\",\n};\n\nconst Wrapper = styled.div`\n  padding: ${({ theme }) => theme.spacing.lg};\n  border-radius: ${({ theme }) => theme.radii.md2};\n  border: 1px solid ${({ theme }) => theme.colors.global.line.Line2};\n`;\nconst Title = styled.div`\n  font-size: 14px;\n  line-height: 16px;\n  font-weight: 400;\n  color: ${({ theme }) => theme.colors.global.text.T1};\n`;\n\ninterface EditTriggerConditionProps {\n  editMode: StrategyTriggerEditType;\n  setEditMode: Dispatch<SetStateAction<StrategyTriggerEditType>>;\n  onDeleteStrategy: () => void;\n}\ntype TriggerList = (RecurringAction & { id: StrategyTriggerEditType })[];\n\nexport const EditTriggerCondition: React.FC<EditTriggerConditionProps> = ({\n  editMode,\n  setEditMode,\n  onDeleteStrategy,\n}) => {\n  const { networkId } = useNetwork();\n  const {\n    triggerCondition,\n    triggerAction,\n    tokens,\n    tokenMarketPrice,\n    position,\n    isTriggerLoaded,\n    taskId,\n    setTriggerCondition,\n    setTriggerAction,\n  } = useEditStrategyContext();\n  const { state, setModalState } = useModal();\n  const modalRef = useRef<HTMLDivElement>(null);\n  const { isOpen: isDeleteStrategyModalOpen } = state.DELETE_STRATEGY_MODAL;\n  const { isOpen: isDeleteTriggerModalOpen } = state.DELETE_TRIGGER_MODAL;\n  const { isOpen: isDiscardEditModalOpen } = state.DISCARD_TRIGGER_EDIT_MODAL;\n  const [clientTrigger, setClientTrigger] = useState<IDualTriggerState>(null);\n  const [data, setData] = useState<IDualTriggerState>(null);\n  const [triggerList, setTriggerList] = useState<TriggerList>();\n  const [addTrigger, setAddTrigger] = useState<StrategyTriggerEditType>();\n  const [triggerId, setTriggerId] = useState<StrategyTriggerEditType>();\n  const tokenRatio = useMemo(\n    () => Math.floor(tokens[0].getTokenValueProportion().mul(10000).toNumber()),\n    [tokens]\n  );\n  const ref = useRef<HTMLDivElement>(null);\n  const isEditing = editMode !== undefined || addTrigger !== undefined;\n\n  useOnCondition(isTriggerLoaded, () => {\n    setClientTrigger(convertTriggerConditionToClient(triggerCondition));\n  });\n\n  const isAboveEdit = editMode === StrategyTriggerEditType.ABOVE;\n  const [tokenSpotPrice, setTokenSpotPrice] =\n    useState<[string, string]>(undefined);\n\n  useEffect(() => {\n    if (tokenSpotPrice) return;\n    if (tokenMarketPrice.tokenA !== \"0\" && tokenMarketPrice.tokenB !== \"0\") {\n      setTokenSpotPrice([tokenMarketPrice.tokenA, tokenMarketPrice.tokenB]);\n    }\n  }, [tokenMarketPrice.tokenA, tokenMarketPrice.tokenB, tokenSpotPrice]);\n\n  useEffect(() => {\n    if (!isTriggerLoaded || !clientTrigger) return;\n\n    const isDualAction =\n      clientTrigger.aboveChecked &&\n      clientTrigger.belowChecked &&\n      triggerAction.type === ActionTypeEnum.Values.RecurringDualAction;\n    const { slippage, maxGasProportion, strategyId } = triggerAction;\n\n    const init = {\n      ...clientTrigger,\n      aboveAction: clientTrigger.aboveChecked\n        ? isDualAction\n          ? //@ts-ignore\n            getActionType({\n              ...triggerAction.gteAction,\n              strategyId,\n              slippage,\n              maxGasProportion,\n            })\n          : triggerAction\n        : undefined,\n      belowAction: clientTrigger.belowChecked\n        ? isDualAction\n          ? getActionType({\n              ...triggerAction.lteAction,\n              strategyId,\n              slippage,\n              maxGasProportion,\n            })\n          : triggerAction\n        : undefined,\n    };\n\n    //@ts-ignore\n    setData(init);\n    //@ts-ignore\n    setTriggerList(generateTriggerList(init));\n  }, [isTriggerLoaded, clientTrigger]);\n\n  const defaultForm: IDualTriggerState = useMemo(() => {\n    let triggerType = TriggerType.PRICE;\n    if (triggerCondition?.type === \"RecurringPercentage\")\n      triggerType = TriggerType.PRICE_PERCENTAGE;\n    if (triggerCondition?.type === \"RecurringRatio\")\n      triggerType = TriggerType.RATIO;\n    return {\n      ...emptyDualTriggerForm,\n      ...getDefaultCacheForm(\n        tokenRatio,\n        tokenSpotPrice ? tokenSpotPrice[0] : \"0\",\n        tokens[1].decimals,\n        true\n      )[triggerType],\n    };\n  }, [tokenSpotPrice, tokens]);\n\n  const handleSave = useEventCallback((t: IEditTriggerState) => {\n    const timeBufferInvalid =\n      t.timeBufferChecked && parseFloat(t.timeBuffer || \"0\") === 0;\n    const editedData = {\n      ...data,\n      [isAboveEdit ? \"above\" : \"below\"]: isAboveEdit ? t.above : t.below,\n      [isAboveEdit ? \"aboveAction\" : \"belowAction\"]: isAboveEdit\n        ? t.aboveAction\n        : t.belowAction,\n      timeBufferChecked: timeBufferInvalid ? false : t.timeBufferChecked,\n      timeBuffer: t.timeBuffer,\n    };\n    setData(editedData);\n\n    const converted = convertClientToTriggerCondition(editedData, position);\n    setTriggerCondition((prev) => {\n      return {\n        ...converted,\n        ...(prev?.sqrtPriceX96 && {\n          sqrtPriceX96: prev.sqrtPriceX96,\n        }),\n      };\n    });\n    setTriggerAction((prev) => ({\n      maxGasProportion: prev.maxGasProportion,\n      slippage: prev.slippage,\n      strategyId: prev.strategyId,\n      ...convertToTriggerAction(editedData.aboveAction, editedData.belowAction),\n    }));\n    const updatedList = triggerList?.map((trigger) => {\n      if (trigger.id === editMode) {\n        return {\n          id: trigger.id,\n          ...(isAboveEdit ? t.aboveAction : t.belowAction),\n        };\n      } else {\n        return trigger;\n      }\n    });\n    setTriggerList(updatedList);\n    setEditMode(undefined);\n    setAddTrigger(undefined);\n  });\n\n  const handleDelete = useCallback(\n    (id: StrategyTriggerEditType) => {\n      const isAbove = id === StrategyTriggerEditType.ABOVE;\n      const updatedData = {\n        ...data,\n        [isAbove ? \"above\" : \"below\"]: defaultForm[id],\n        [isAbove ? \"aboveChecked\" : \"belowChecked\"]: false,\n        [isAbove ? \"aboveAction\" : \"belowAction\"]: undefined,\n      };\n      setData(updatedData);\n\n      const converted = convertClientToTriggerCondition(updatedData, position);\n      setTriggerCondition((prev) => {\n        return {\n          ...converted,\n          ...(prev?.sqrtPriceX96 && {\n            sqrtPriceX96: prev.sqrtPriceX96,\n          }),\n        };\n      });\n      setTriggerAction((prev) => ({\n        maxGasProportion: prev.maxGasProportion,\n        slippage: prev.slippage,\n        strategyId: prev.strategyId,\n        ...convertToTriggerAction(\n          updatedData.aboveAction,\n          updatedData.belowAction\n        ),\n      }));\n\n      const updatedList = triggerList.filter((trigger) => trigger.id !== id);\n      setTriggerList(updatedList);\n      setEditMode(undefined);\n      setAddTrigger(undefined);\n    },\n    [data, triggerList, defaultForm]\n  );\n\n  const handleEdit = useCallback((id: StrategyTriggerEditType) => {\n    setEditMode(id);\n  }, []);\n\n  const handleAddTrigger = useCallback(\n    (id: StrategyTriggerEditType) => {\n      const isAbove = id === StrategyTriggerEditType.ABOVE;\n      const updatedData = {\n        ...data,\n        [isAbove ? \"aboveChecked\" : \"belowChecked\"]: true,\n        [isAbove ? \"above\" : \"below\"]: defaultForm[id],\n      };\n      const updatedList = [\n        ...triggerList,\n        {\n          id,\n          ...defaultForm[isAbove ? \"aboveAction\" : \"belowAction\"],\n        },\n      ];\n\n      setData(updatedData);\n      setAddTrigger(id);\n      setTriggerList(updatedList);\n      setEditMode(id);\n    },\n    [data, triggerList, defaultForm]\n  );\n\n  const toggleDeleteStartegyModal = (open: boolean) => {\n    setModalState(E_ModalKey.DELETE_STRATEGY_MODAL, open);\n  };\n  const toggleDeleteTriggerModal = (open: boolean) => {\n    !open && setTriggerId(undefined);\n    setModalState(E_ModalKey.DELETE_TRIGGER_MODAL, open);\n  };\n  const toggleDiscardEditModal = (open: boolean) => {\n    setModalState(E_ModalKey.DISCARD_TRIGGER_EDIT_MODAL, open);\n  };\n\n  const handleDeleteTrigger = useCallback(\n    (id: StrategyTriggerEditType) => {\n      const isLastTrigger = triggerList.length === 1;\n      setTriggerId(id);\n      isLastTrigger\n        ? toggleDeleteStartegyModal(true)\n        : toggleDeleteTriggerModal(true);\n    },\n    [handleDelete]\n  );\n\n  const handleClickOutside = (event: MouseEvent) => {\n    if (modalRef.current && modalRef.current.contains(event.target as Node)) {\n      return;\n    }\n    event.stopPropagation();\n    toggleDiscardEditModal(true);\n  };\n  useClickOutside([ref], handleClickOutside);\n\n  const initForm = useMemo(() => {\n    return {\n      ...data,\n      [isAboveEdit ? \"belowChecked\" : \"aboveChecked\"]: false,\n      [isAboveEdit ? \"belowAction\" : \"aboveAction\"]: undefined,\n      [isAboveEdit ? \"below\" : \"above\"]:\n        defaultForm[isAboveEdit ? \"below\" : \"above\"],\n    };\n  }, [data, defaultForm, editMode]);\n\n  const defaultAction = useMemo(\n    () =>\n      getDefaultStrategyAction(\n        networkId,\n        position,\n        tokens,\n        tokenMarketPrice.tokenA\n      ),\n    [networkId, position, tokens, tokenMarketPrice]\n  );\n\n  return (\n    <>\n      <FlexColumn gap=\"lg\">\n        <Title>Trigger Setup</Title>\n        {triggerList?.map(\n          (trigger, idx) =>\n            trigger !== undefined &&\n            (editMode === trigger.id ? (\n              <Wrapper key={trigger.id} ref={ref}>\n                <EditTrigger\n                  triggerIdx={idx + 1}\n                  tokens={tokens}\n                  tokenSpotPrice={tokenSpotPrice}\n                  tokenRatio={tokenRatio}\n                  tickSpacing={position.tickSpacing}\n                  defaultAction={defaultAction}\n                  initForm={initForm}\n                  onSave={handleSave}\n                  onDiscard={() => toggleDiscardEditModal(true)}\n                  isAddTrigger={!!addTrigger}\n                />\n              </Wrapper>\n            ) : (\n              <EditTriggerDetail\n                key={trigger.id}\n                disabled={isEditing}\n                type={trigger.id}\n                triggerIdx={idx + 1}\n                tokens={tokens}\n                trigger={data}\n                onEdit={() => handleEdit(trigger.id)}\n                onDelete={() => handleDeleteTrigger(trigger.id)}\n                onAddTrigger={() =>\n                  handleAddTrigger(\n                    triggerList[0].id === StrategyTriggerEditType.ABOVE\n                      ? StrategyTriggerEditType.BELOW\n                      : StrategyTriggerEditType.ABOVE\n                  )\n                }\n              />\n            ))\n        )}\n        <Flex alignItems=\"center\" justifyContent=\"space-between\">\n          <Flex alignItems=\"center\">\n            <Title>{strings.timeBufferLabel}</Title>\n            <StyledQuestionPopover\n              content={strings.timeBufferPopover}\n              defaultSize={{ width: 500 }}\n              defaultPosition={{ left: -90, bottom: 20 }}\n            />\n          </Flex>\n          <StyledInputWithTicker\n            align=\"left\"\n            type=\"number\"\n            placeholder=\"0\"\n            defaultValue={data?.timeBuffer?.toString() ?? \"0\"}\n            disabled={isEditing}\n            onChange={(value) =>\n              handleSave({\n                ...data,\n                timeBufferChecked: true,\n                timeBuffer: value,\n              })\n            }\n            onBlur={() => {\n              if (bigDecimal.compareTo(data?.timeBuffer, MAX_TIME_BUFFER) > 0)\n                handleSave({\n                  ...data,\n                  timeBufferChecked: true,\n                  timeBuffer: MAX_TIME_BUFFER.toString(),\n                });\n            }}\n            ticker={\n              bigDecimal.compareTo(data?.timeBuffer, 1) > 0 ? \"hrs\" : \"hr\"\n            }\n            width={200}\n            height={36}\n          />\n        </Flex>\n        {bigDecimal.compareTo(data?.timeBuffer, 0) > 0 && (\n          <StyledNotification\n            variant={notificationVariants.WARNING}\n            text={getTriggerNotification()}\n          />\n        )}\n      </FlexColumn>\n      <Modal\n        padding={16}\n        isModalOpen={isDeleteStrategyModalOpen}\n        onClose={() => toggleDeleteStartegyModal(false)}\n      >\n        <DeleteStrategyModal\n          taskId={taskId}\n          isDeletingLastTrigger={true}\n          onClose={() => toggleDeleteStartegyModal(false)}\n          onDelete={() => onDeleteStrategy()}\n        />\n      </Modal>\n      <Modal\n        padding={16}\n        isModalOpen={isDeleteTriggerModalOpen}\n        onClose={() => toggleDeleteTriggerModal(false)}\n      >\n        {triggerId && (\n          <DualTriggerContent\n            {...{\n              type: E_StrategyModalType.Delete_Trigger,\n              onCancel: () => toggleDeleteTriggerModal(false),\n              onConfirm: () => {\n                toggleDeleteTriggerModal(false);\n                handleDelete(triggerId);\n              },\n            }}\n          />\n        )}\n      </Modal>\n      <Modal\n        ref={modalRef}\n        padding={16}\n        isModalOpen={isDiscardEditModalOpen}\n        onClose={() => toggleDiscardEditModal(false)}\n      >\n        <DualTriggerContent\n          {...{\n            type: E_StrategyModalType.Discard_Trigger_Edit,\n            onCancel: () => toggleDiscardEditModal(false),\n            onConfirm: () => {\n              toggleDiscardEditModal(false);\n              addTrigger ? handleDelete(addTrigger) : handleSave(data);\n            },\n          }}\n        />\n      </Modal>\n    </>\n  );\n};\n\nfunction generateTriggerList(data: IEditTriggerState | null): TriggerList {\n  const triggers = [];\n  if (data?.belowChecked && data?.belowAction) {\n    triggers.push({ ...data.belowAction, id: StrategyTriggerEditType.BELOW });\n  }\n  if (data?.aboveChecked && data?.aboveAction) {\n    triggers.push({ ...data.aboveAction, id: StrategyTriggerEditType.ABOVE });\n  }\n  return triggers;\n}\n","import { UnstakePositionBtn } from \"@/components/Button/StakePositionBtn\";\nimport { useUnstakePositionContext } from \"@/components/Context/UnstakePositionContext\";\nimport { useAOStore, useGlobalSlippage } from \"@/components/GlobalStore\";\nimport { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\n\nimport { useOnNetworkAccountChange } from \"@/hooks/globalState/useOnNetworkAccountChange\";\nimport { useSignAndCUDTrigger } from \"@/hooks/trigger/useSignAndCUDTrigger\";\nimport { useEventCallback } from \"@/hooks/useEventCallback\";\nimport { useFetchAllChainUserTriggers } from \"@/hooks/useFetchAllChainUserTriggers\";\nimport { useFetchStakePositionsIds } from \"@/hooks/useFetchStakePositionsIds\";\nimport {\n  DEFAULT_APERTURE_FLAT_FEE,\n  DEFAULT_APERTURE_REBALANCE_FEE,\n  DEFAULT_APERTURE_REINVEST_FEE,\n  DEFAULT_REBALANCE_SLIPPAGE,\n  WARNING_SLIPPAGE,\n} from \"@/utils/helper\";\nimport {\n  DRAWER_CONTENT_WIDTH,\n  Flex,\n  FlexColumn,\n  RecurringRebalanceFeePopover,\n  Spinner,\n  StrategyTriggerEditType,\n  TransactionSettings,\n} from \"@aperture/uikit\";\nimport { darkColors } from \"@aperture/uikitv2\";\nimport {\n  CreateTriggerPayload,\n  UpdateTriggerPayload,\n} from \"@aperture_finance/uniswap-v3-automation-sdk\";\nimport bigDecimal from \"js-big-decimal\";\nimport { useCallback, useMemo, useState } from \"react\";\nimport styled from \"styled-components\";\nimport {\n  AdvancedSettings,\n  ButtonsGroup,\n  PositionInfoCard,\n  TriggerCondition,\n  useEditStrategyContext,\n} from \".\";\nimport { EditTriggerCondition } from \"./EditTriggerCondition\";\n\ninterface EditStrategyProps {\n  isCreate?: boolean;\n  onSave: () => void;\n  onCancel: () => void;\n  navBack?: () => void;\n}\n\nconst FlexColumnBox = styled(FlexColumn)`\n  padding-bottom: 120px;\n`;\nconst EditContentWrapper = styled.div<{\n  isCreate: boolean;\n}>`\n  height: ${({ isCreate }) => (isCreate ? \"100%\" : \"calc(100vh - 220px)\")};\n  overflow-y: scroll;\n  scrollbar-width: none;\n`;\nconst Content = styled(FlexColumn)<{\n  isCreate: boolean;\n}>`\n  width: ${({ isCreate }) => (isCreate ? \"100%\" : DRAWER_CONTENT_WIDTH)};\n`;\n\nconst StrategyFooter = styled(Flex)<{ isCreate: boolean }>`\n  padding-top: ${({ isCreate }) => (isCreate ? \"8px\" : \"20px\")};\n  display: flex;\n  align-items: center;\n  width: ${({ isCreate }) => (isCreate ? \"100%\" : DRAWER_CONTENT_WIDTH)};\n  justify-content: flex-end;\n  box-sizing: border-box;\n  gap: 18px;\n`;\nconst HR = styled.hr`\n  width: 100%;\n  margin: 0;\n  border-bottom: none;\n  border: 1px solid ${({ theme }) => theme.colors.global.line.Line1};\n`;\n\nexport const EditStrategy: React.FC<EditStrategyProps> = ({\n  isCreate,\n  onSave,\n  onCancel,\n  navBack,\n}) => {\n  const {\n    position,\n    autoCompoundError,\n    txnSetting,\n    isStrategyNotChanged,\n    setTxnSetting,\n    getTriggerPayload,\n    useInit,\n  } = useEditStrategyContext();\n  const { networkId } = useNetwork();\n  const { globalSlippage, setGlobalSlippage } = useGlobalSlippage();\n\n  const { mutate } = useFetchAllChainUserTriggers();\n  useInit();\n\n  useOnNetworkAccountChange(() => {\n    onCancel();\n  });\n\n  const {\n    ifAuthorized,\n    isAOStatusLoading: isAOLoading,\n    safeToggleAOStatus: enableAO,\n  } = useAOStore();\n  const {\n    isLoading: isRequesting,\n    signAndCreateTrigger,\n    signAndUpdateTrigger,\n  } = useSignAndCUDTrigger();\n  const [isEditingTrigger, setIsEditingTrigger] = useState(true); //create trigger\n  const [editMode, setEditMode] = useState<StrategyTriggerEditType>(); //edit trigger\n  const { mutate: mutateStakePositionIds } = useFetchStakePositionsIds();\n  const { stakePool, staked, setStaked } = useUnstakePositionContext();\n\n  const handleClickConfirm = useEventCallback(async () => {\n    if (!ifAuthorized) {\n      enableAO();\n      return;\n    }\n    const payload = getTriggerPayload(isCreate);\n    try {\n      if (isCreate) {\n        await signAndCreateTrigger({\n          payload: payload as CreateTriggerPayload,\n          successTip: `You have successfully set up a recurring rebalance strategy for your ${position.tokenA.ticker}-${position.tokenB.ticker} position.`,\n        });\n      } else {\n        await signAndUpdateTrigger({\n          payload: payload as UpdateTriggerPayload,\n          successTip: `You have successfully updated a recurring rebalance strategy for your ${position.tokenA.ticker}-${position.tokenB.ticker} position.`,\n        });\n      }\n\n      mutate();\n      onSave();\n    } catch (err) {\n      console.log(err);\n    }\n  });\n  const onDeleteStrategy = useCallback(() => navBack(), [navBack]);\n\n  const showLoading = isAOLoading || isRequesting;\n\n  const confirmButtonLabel = useMemo(() => {\n    if (showLoading) {\n      return <Spinner />;\n    }\n    if (isCreate ? isEditingTrigger : !!editMode) {\n      return \"You need to save trigger to rebalance\";\n    }\n    if (autoCompoundError) {\n      return autoCompoundError;\n    }\n    if (!ifAuthorized) {\n      return \"Authorize Operator\";\n    }\n\n    return isCreate ? (\n      <>\n        Create Strategy\n        <RecurringRebalanceFeePopover\n          hint={`Aperture charges $${DEFAULT_APERTURE_FLAT_FEE} + ${bigDecimal.multiply(\n            DEFAULT_APERTURE_REBALANCE_FEE,\n            100\n          )}% of the swapped amount + ${\n            DEFAULT_APERTURE_REINVEST_FEE * 100\n          }% of the reinvested amount for each rebalance.`}\n          defaultPosition={{ right: -24, bottom: 36 }}\n        />\n      </>\n    ) : (\n      \"Update Strategy\"\n    );\n  }, [\n    showLoading,\n    isEditingTrigger,\n    editMode,\n    autoCompoundError,\n    ifAuthorized,\n    isCreate,\n  ]);\n\n  const disableConfirm =\n    (isCreate ? isEditingTrigger : !!editMode) ||\n    showLoading ||\n    !!autoCompoundError ||\n    (isStrategyNotChanged && ifAuthorized);\n\n  return (\n    <FlexColumnBox>\n      <EditContentWrapper isCreate={isCreate}>\n        <Content gap=\"xl\" isCreate={isCreate}>\n          <PositionInfoCard isCreate={isCreate} />\n          <HR />\n          {isCreate ? (\n            <TriggerCondition\n              isEditing={isEditingTrigger}\n              toggleEdit={() => setIsEditingTrigger(!isEditingTrigger)}\n            />\n          ) : (\n            <EditTriggerCondition\n              editMode={editMode}\n              setEditMode={setEditMode}\n              onDeleteStrategy={onDeleteStrategy}\n            />\n          )}\n          <HR />\n          <AdvancedSettings\n            isCreate={isCreate}\n            bg={darkColors.global.background.BG2}\n          />\n        </Content>\n      </EditContentWrapper>\n      <StrategyFooter isCreate={isCreate}>\n        <TransactionSettings\n          defaultSlippage={DEFAULT_REBALANCE_SLIPPAGE}\n          globalSlippage={globalSlippage}\n          warningSlippage={WARNING_SLIPPAGE}\n          dropdownPosition=\"topRight\"\n          buttonSize={\"small\"}\n          settingsForm={txnSetting}\n          onFormChange={setTxnSetting}\n          setGlobalSlippage={(value) =>\n            setGlobalSlippage((prev) => ({ ...prev, [networkId]: value }))\n          }\n        />\n        <ButtonsGroup\n          width={isCreate ? \"250px\" : \"100%\"}\n          disableConfirm={disableConfirm}\n          addConfirmWrapper={!(stakePool && staked)}\n          confirmText={\n            stakePool && staked ? (\n              <UnstakePositionBtn\n                key={position.positionId}\n                width={isCreate ? \"250px\" : \"100%\"}\n                atStake={staked}\n                gaugeAddress={stakePool.gaugeAddress}\n                positionId={position.positionIdBN}\n                handleTxSuccess={() => {\n                  setStaked(false);\n                  mutateStakePositionIds();\n                }}\n              />\n            ) : (\n              confirmButtonLabel\n            )\n          }\n          onConfirm={handleClickConfirm}\n          onCancel={onCancel}\n        />\n      </StrategyFooter>\n    </FlexColumnBox>\n  );\n};\n","import { usePage } from \"@/components/PageContext/PageContext\";\nimport { IPositionDetails } from \"@/config/position/positionConfig\";\nimport { getTokenPercentages } from \"@/helper/tokenHelper\";\nimport { CommonQueryKey } from \"@/utils/browserHistory\";\nimport { getFormattedPriceRange } from \"@/views/ActivePositions/getPositionCardProps\";\nimport { ITokenPair } from \"@aperture/types\";\nimport {\n  CurrentPositionInfoCard,\n  CurrentPositionInfoCardProps,\n} from \"@aperture/uikit\";\nimport { NextRouter, useRouter } from \"next/router\";\nimport { useMemo } from \"react\";\nimport { useEditStrategyContext } from \"./Context\";\n\nexport const PositionInfoCard: React.FC<{\n  isCreate?: boolean;\n}> = ({ isCreate }) => {\n  const router = useRouter();\n  const { setPositionPage } = usePage();\n  const { tokens, position } = useEditStrategyContext();\n  const positionProps = useMemo(\n    () => ({\n      ...convertPositionToProps(position, tokens, isCreate),\n      goToDetail: () =>\n        navToPositionDetail(\n          router,\n          `${position.chainId}-${position.positionId}`\n        ),\n      addLiquidity: () => {\n        setPositionPage(\"addLP\");\n        navToPositionDetail(\n          router,\n          `${position.chainId}-${position.positionId}`\n        );\n      },\n      // TODO: Add notification\n    }),\n    [isCreate, position, router, setPositionPage, tokens]\n  );\n\n  return <CurrentPositionInfoCard {...positionProps} />;\n};\n\nfunction convertPositionToProps(\n  position: IPositionDetails,\n  tokens: ITokenPair,\n  lite?: boolean\n): CurrentPositionInfoCardProps {\n  const tokenPercentages = getTokenPercentages(\n    tokens[0].amount,\n    tokens[1].amount,\n    tokens[0].price,\n    tokens[1].price\n  );\n\n  return {\n    lite,\n    id: position.positionId,\n    tokens: tokens,\n    feeTier: position?.feeTier,\n    priceRange: getFormattedPriceRange(position.minPrice, position.maxPrice),\n    liquidity: !lite ? position.liquidity : undefined,\n    liquidityDetails: lite\n      ? {\n          amounts: [tokens[0].amount, tokens[1].amount],\n          percentages: [\n            tokenPercentages.token0Percent,\n            tokenPercentages.token1Percent,\n          ],\n        }\n      : undefined,\n  };\n}\n\nfunction navToPositionDetail(router: NextRouter, pid: string) {\n  router.push({\n    pathname: \"/liquidity-management\",\n    query: {\n      [CommonQueryKey.PID]: pid,\n    },\n  });\n}\n","import { useNetwork } from \"@/components/NetworkContext/NetworkContext\";\nimport { StrategyTriggerDetail, TriggerType } from \"@aperture/uikit\";\nimport { DualTriggerSetup, IDualTriggerState } from \"@ui/components/Strategy\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useEditStrategyContext } from \"./Context\";\nimport {\n  convertClientToTriggerCondition,\n  convertToTriggerAction,\n  getDefaultStrategyAction,\n} from \"./utils\";\n\ninterface TriggerConditionProps {\n  isEditing: boolean;\n  toggleEdit: () => void;\n}\n\nexport const TriggerCondition: React.FC<TriggerConditionProps> = ({\n  isEditing,\n  toggleEdit,\n}) => {\n  const { networkId } = useNetwork();\n  const {\n    setTriggerCondition,\n    setTriggerAction,\n    tokens,\n    tokenMarketPrice,\n    position,\n  } = useEditStrategyContext();\n  const [clientTrigger, setClientTrigger] = useState<IDualTriggerState>(null);\n  const [tokenSpotPrice, setTokenSpotPrice] =\n    useState<[string, string]>(undefined);\n\n  const defaultAction = useMemo(\n    () =>\n      getDefaultStrategyAction(\n        networkId,\n        position,\n        tokens,\n        tokenMarketPrice.tokenA\n      ),\n    [networkId, position, tokens, tokenMarketPrice]\n  );\n\n  useEffect(() => {\n    if (tokenSpotPrice) return;\n\n    if (tokenMarketPrice.tokenA !== \"0\" && tokenMarketPrice.tokenB !== \"0\") {\n      setTokenSpotPrice([tokenMarketPrice.tokenA, tokenMarketPrice.tokenB]);\n    }\n  }, [tokenMarketPrice.tokenA, tokenMarketPrice.tokenB, tokenSpotPrice]);\n\n  const tokenRatio = useMemo(\n    () => Math.floor(tokens[0].getTokenValueProportion().mul(10000).toNumber()),\n    [tokens]\n  );\n\n  const handleSave = (data: IDualTriggerState) => {\n    const timeBufferInvalid =\n      data.timeBufferChecked && parseFloat(data.timeBuffer || \"0\") === 0;\n    const validatedData = {\n      ...data,\n      timeBufferChecked: timeBufferInvalid ? false : data.timeBufferChecked,\n    };\n    setClientTrigger(validatedData);\n\n    const swapLteGteActions =\n      data.baseToken === 1 && data.triggerType !== TriggerType.PRICE;\n    const converted = convertClientToTriggerCondition(validatedData, position);\n    setTriggerCondition((prev) => {\n      return {\n        ...converted,\n        ...(prev?.sqrtPriceX96 && {\n          sqrtPriceX96: prev.sqrtPriceX96, //should only set sqrtPriceX96 when create?\n        }),\n      };\n    });\n    setTriggerAction((prev) => ({\n      maxGasProportion: prev.maxGasProportion,\n      slippage: prev.slippage,\n      strategyId: prev.strategyId,\n      ...convertToTriggerAction(\n        data.aboveAction,\n        data.belowAction,\n        swapLteGteActions\n      ),\n    }));\n    toggleEdit();\n  };\n\n  return isEditing ? (\n    <DualTriggerSetup\n      tokens={tokens}\n      tokenSpotPrice={tokenSpotPrice}\n      tokenMarketPrice={tokenMarketPrice}\n      tickSpacing={position.tickSpacing}\n      defaultAction={defaultAction}\n      tokenRatio={tokenRatio}\n      onSave={handleSave}\n      initForm={clientTrigger}\n    />\n  ) : (\n    <StrategyTriggerDetail\n      tokens={tokens}\n      trigger={clientTrigger}\n      onEdit={toggleEdit}\n    />\n  );\n};\n","export * from \"./AdvancedSettings\";\nexport * from \"./ButtonGroups\";\nexport * from \"./Context\";\nexport * from \"./Edit\";\nexport * from \"./PositionInfoCard\";\nexport * from \"./TriggerCondition\";\nexport * from \"./utils\";\n"],"names":["useOnCondition","condition","callback","cb","useEventCallback","useEffect","getDefaultStrategyAction","networkId","position","tokens","tokenMarketPrice0","tickCurrent","priceToClosestUsableTick","parsePrice","Token","address","decimals","ticker","name","undefined","tickSpacing","actionTickLower","tickLower","actionTickUpper","tickUpper","rangeWidth","percentLower","offsetTickToPercentage","percentUpper","priceLower","bigDecimal","Number","priceUpper","token0USDAmount","amount","price","token1USDAmount","ratioDemonimator","ratioLower","toString","ratioUpper","convertClientToTriggerCondition","trigger","baseToken","triggerType","timeBuffer","above","below","timeBufferChecked","aboveChecked","belowChecked","common","sqrtPriceX96","priceToSqrtRatioX96","Big","tokenA","durationSec","parseFloat","gteEnabled","lteEnabled","TriggerType","type","gteTickOffset","percentageToOffsetTick","lteTickOffset","gtePriceOffset","ltePriceOffset","token0RatioAbove","toFixed","token0RatioBelow","gteToken0ValueProportion","lteToken0ValueProportion","convertToTriggerAction","aboveAction","belowAction","swapLteGte","lteAction","getDualAction","gteAction","ActionTypeEnum","action","Object","entries","reduce","acc","key","value","param","includes","StrategyContext","React","StrategyProvider","initRef","children","props","useRef","autoCompound","ammEnum","useNetwork","useAccount","currentTokenPrice","tokenPriceList","useCurrentChainToken","useMemo","tokenB","poolKey","feeTier","data","marketPrice","useFetchCurrentChainMarketPrice","tokenMarketPrice","triggerCondition","setTriggerCondition","useState","triggerAction","setTriggerAction","globalSlippage","useGlobalSlippage","autoCompoundPayload","setAutoCompoundPayload","getInitAutoCompoundPayload","liquidity","enableAutoCompound","setEnableAutoCompound","txnSetting","setTxnSetting","resetTxnSetting","useTransactionSettingForms","init","slippage","DEFAULT_REBALANCE_SLIPPAGE","deadline","useCallback","_triggerAction","isConditionNotChanged","_","current","isActionNotChanged","autoCompoundError","gasCeilingButtonError","maxGasProportion","getTriggerPayload","ownerAddr","chainId","expiration","getTriggerDeadline","isCreate","amm","nftId","positionId","payload","taskId","useInit","useFetch","prev","jsx_runtime","jsx","Provider","autoCompoundExists","setAutoCompound","isTriggerLoaded","isStrategyNotChanged","useEditStrategyContext","usePositionStrategy","usePositionAutoCompound","feeToPrincipalRatioThreshold","getGasCeiling","DEFAULT_SLIPPAGE","AdvancedSettings","bg","setGlobalSlippage","applyGlobally","setApplyGlobally","gasCeiling","minFees","maxGasFee","handleGasCeilingChange","handleAutoCompoundChange","percentage","handleAcGasCeilingChange","handleAcMaxGasChange","handleAcSlippageChange","handleOnError","gasCeilingInputError","StrategyAdvancedSettings","expanded","hideAutoCompound","disableAutoCompound","onChange","onError","acGasCeiling","acMaxGasFee","acSlippage","defaultValue","globalValue","warningValue","WARNING_SLIPPAGE","onSlippageChange","onApplyGlobally","checked","ButtonItem","styled","Button","black","theme","colors","global","text","T1","textAlt","background","BG3","primary","BG4","ButtonsGroup","cancelText","confirmText","addConfirmWrapper","disableConfirm","width","minWidth","onCancel","onConfirm","jsxs","Fragment","size","variant","onClick","color","disabled","strings","timeBufferLabel","timeBufferPopover","Wrapper","spacing","lg","radii","md2","line","Line2","Title","EditTriggerCondition","editMode","setEditMode","onDeleteStrategy","state","setModalState","useModal","modalRef","isOpen","isDeleteStrategyModalOpen","DELETE_STRATEGY_MODAL","isDeleteTriggerModalOpen","DELETE_TRIGGER_MODAL","isDiscardEditModalOpen","DISCARD_TRIGGER_EDIT_MODAL","clientTrigger","setClientTrigger","setData","triggerList","setTriggerList","addTrigger","setAddTrigger","triggerId","setTriggerId","tokenRatio","Math","floor","getTokenValueProportion","mul","toNumber","ref","isEditing","convertTriggerConditionToClient","trimNumber","RecurringConditionTypeEnum","concat","isAboveEdit","StrategyTriggerEditType","tokenSpotPrice","setTokenSpotPrice","isDualAction","strategyId","getActionType","generateTriggerList","triggers","push","id","defaultForm","emptyDualTriggerForm","getDefaultCacheForm","handleSave","timeBufferInvalid","t","editedData","converted","updatedList","map","handleDelete","isAbove","updatedData","filter","handleEdit","handleAddTrigger","toggleDeleteStartegyModal","E_ModalKey","open","toggleDeleteTriggerModal","toggleDiscardEditModal","handleDeleteTrigger","isLastTrigger","length","handleClickOutside","contains","event","target","stopPropagation","useClickOutside","initForm","defaultAction","FlexColumn","gap","idx","EditTrigger","triggerIdx","onSave","onDiscard","isAddTrigger","EditTriggerDetail","onEdit","onDelete","onAddTrigger","Flex","alignItems","justifyContent","StyledQuestionPopover","content","defaultSize","defaultPosition","left","bottom","StyledInputWithTicker","align","placeholder","onBlur","MAX_TIME_BUFFER","height","StyledNotification","notificationVariants","getTriggerNotification","Modal","padding","isModalOpen","onClose","DeleteStrategyModal","isDeletingLastTrigger","DualTriggerContent","E_StrategyModalType","FlexColumnBox","EditContentWrapper","Content","DRAWER_CONTENT_WIDTH","StrategyFooter","HR","Line1","EditStrategy","navBack","mutate","useFetchAllChainUserTriggers","useOnNetworkAccountChange","ifAuthorized","isAOStatusLoading","isAOLoading","safeToggleAOStatus","enableAO","useAOStore","isLoading","isRequesting","signAndCreateTrigger","signAndUpdateTrigger","useSignAndCUDTrigger","isEditingTrigger","setIsEditingTrigger","mutateStakePositionIds","useFetchStakePositionsIds","stakePool","staked","setStaked","useUnstakePositionContext","handleClickConfirm","successTip","err","console","log","showLoading","confirmButtonLabel","Spinner","RecurringRebalanceFeePopover","hint","DEFAULT_APERTURE_FLAT_FEE","DEFAULT_APERTURE_REINVEST_FEE","DEFAULT_APERTURE_REBALANCE_FEE","right","PositionInfoCard","TriggerCondition","toggleEdit","darkColors","TransactionSettings","defaultSlippage","warningSlippage","dropdownPosition","buttonSize","settingsForm","onFormChange","UnstakePositionBtn","atStake","gaugeAddress","positionIdBN","handleTxSuccess","router","useRouter","setPositionPage","usePage","positionProps","convertPositionToProps","lite","tokenPercentages","getTokenPercentages","priceRange","getFormattedPriceRange","minPrice","maxPrice","liquidityDetails","amounts","percentages","token0Percent","token1Percent","goToDetail","navToPositionDetail","addLiquidity","CurrentPositionInfoCard","pid","pathname","query","CommonQueryKey","validatedData","swapLteGteActions","DualTriggerSetup","StrategyTriggerDetail"],"sourceRoot":""}