From a76d85a125076e20721abe24aa391acdfbb65c3d Mon Sep 17 00:00:00 2001 From: Zack McClary Date: Thu, 13 Apr 2023 16:56:48 -0500 Subject: [PATCH] add currencies and slippage to callback --- src/components/Swap/SwapActionButton/SwapButton.tsx | 5 +++-- src/state/swap/index.ts | 6 +++++- yarn.lock | 9 --------- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/components/Swap/SwapActionButton/SwapButton.tsx b/src/components/Swap/SwapActionButton/SwapButton.tsx index e40f92c1e..f39a927ca 100644 --- a/src/components/Swap/SwapActionButton/SwapButton.tsx +++ b/src/components/Swap/SwapActionButton/SwapButton.tsx @@ -7,6 +7,7 @@ import { useSwapCallback } from 'hooks/swap/useSwapCallback' import { useConditionalHandler } from 'hooks/useConditionalHandler' import { useSetOldestValidBlock } from 'hooks/useIsValidBlock' import { AllowanceState } from 'hooks/usePermit2Allowance' +import { formatSlippage } from 'hooks/useSlippage' import { usePermit2 as usePermit2Enabled } from 'hooks/useSyncFlags' import useTokenColorExtraction from 'hooks/useTokenColorExtraction' import useTransactionDeadline from 'hooks/useTransactionDeadline' @@ -104,8 +105,8 @@ export default function SwapButton({ disabled }: { disabled: boolean }) { const collapseToolbar = useCollapseToolbar() const onClick = useCallback(async () => { collapseToolbar() - setOpen(await onReviewSwapClick()) - }, [onReviewSwapClick, collapseToolbar]) + setOpen(await onReviewSwapClick(inputCurrency, outputCurrency, formatSlippage(slippage))) + }, [collapseToolbar, onReviewSwapClick, inputCurrency, outputCurrency, slippage]) return ( <> diff --git a/src/state/swap/index.ts b/src/state/swap/index.ts index 4092d0027..1a3ce5129 100644 --- a/src/state/swap/index.ts +++ b/src/state/swap/index.ts @@ -79,7 +79,11 @@ export type OnExpandSwapDetails = () => void * An integration hook called when the user clicks 'Review swap'. * If the hook resolves to false or rejects, the review dialog will not open. */ -export type OnReviewSwapClick = () => void | boolean | Promise +export type OnReviewSwapClick = ( + inputToken: Currency | undefined, + outputToken: Currency | undefined, + slippage: string +) => void | boolean | Promise interface InputEventHandlers { onTokenChange?: OnTokenChange diff --git a/yarn.lock b/yarn.lock index 85edf2d5b..8e182d460 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3655,15 +3655,6 @@ bignumber.js "^9.0.2" ethers "^5.3.1" -"@uniswap/universal-router@1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@uniswap/universal-router/-/universal-router-1.2.1.tgz#5fe4aa21d6bc89314d99f26407f28154f8e16f42" - integrity sha512-F3S1wKylncuvIG2qwC1ciXXc1z1QmKsalo4p6H2A90LSRylEEhNp7ITxs7qCcnfRh+ZNkGJ0yQ0zmuVJSBezOQ== - dependencies: - "@openzeppelin/contracts" "4.7.0" - "@uniswap/v2-core" "1.0.1" - "@uniswap/v3-core" "1.0.0" - "@uniswap/universal-router@1.3.1", "@uniswap/universal-router@^1.0.1": version "1.3.1" resolved "https://registry.yarnpkg.com/@uniswap/universal-router/-/universal-router-1.3.1.tgz#cf0bf662e3056336c5bb5804e353dc5fd34a24a1"