-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSwapModal.ts
More file actions
36 lines (29 loc) · 850 Bytes
/
SwapModal.ts
File metadata and controls
36 lines (29 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use client'
import type { Hex } from 'viem'
import { createGenericContext } from './genericContext'
interface Transaction {
to: Hex
data?: Hex
value?: bigint
}
export interface SwapModalSettings {
chainId: number
toTokenAddress: string
toTokenAmount: string
slippageBps?: number
title?: string
description?: string
disableMainCurrency?: boolean
postSwapTransactions?: Transaction[]
blockConfirmations?: number
customSwapErrorMessage?: string
onSuccess?: (txHash: string) => void
}
type SwapModalContext = {
isSwapModalOpen: boolean
openSwapModal: (settings: SwapModalSettings) => void
closeSwapModal: () => void
swapModalSettings?: SwapModalSettings
}
const [useSwapModalContext, SwapModalContextProvider] = createGenericContext<SwapModalContext>()
export { SwapModalContextProvider, useSwapModalContext }