Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add swap summary info to OnReviewSwapClick #578

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/components/Swap/SwapActionButton/SwapButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 (
<>
Expand Down
6 changes: 5 additions & 1 deletion src/state/swap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>
export type OnReviewSwapClick = (
inputToken: Currency | undefined,
outputToken: Currency | undefined,
slippage: string
) => void | boolean | Promise<boolean>

interface InputEventHandlers {
onTokenChange?: OnTokenChange
Expand Down
9 changes: 0 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3655,15 +3655,6 @@
bignumber.js "^9.0.2"
ethers "^5.3.1"

"@uniswap/[email protected]":
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/[email protected]", "@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"
Expand Down