@@ -7,9 +7,7 @@ import { tradeMachineAtom } from '@/app/store/trade-machine'
7
7
import { formatQuoteAnalytics , useAnalytics } from '@/lib/hooks/use-analytics'
8
8
import { type QuoteResult , QuoteType } from '@/lib/hooks/use-best-quote/types'
9
9
import { getFlashMintQuote } from '@/lib/hooks/use-best-quote/utils/flashmint'
10
- import { getIndexQuote } from '@/lib/hooks/use-best-quote/utils/index-quote'
11
- import { getBestYieldQuote } from '@/lib/hooks/use-quote-result/best-quote'
12
- import { getTokenPrice , useNativeTokenPrice } from '@/lib/hooks/use-token-price'
10
+ import { getTokenPrice } from '@/lib/hooks/use-token-price'
13
11
14
12
import type { Token } from '@/constants/tokens'
15
13
@@ -36,7 +34,6 @@ export function useQuoteResult(request: QuoteRequest) {
36
34
slippage,
37
35
} = request
38
36
const indexToken = isMinting ? outputToken : inputToken
39
- const nativeTokenPrice = useNativeTokenPrice ( chainId )
40
37
const publicClient = usePublicClient ( { chainId } )
41
38
const { logEvent } = useAnalytics ( )
42
39
const sendTradeEvent = useSetAtom ( tradeMachineAtom )
@@ -72,30 +69,6 @@ export function useQuoteResult(request: QuoteRequest) {
72
69
} )
73
70
}
74
71
75
- const fetchSwapQuote = async ( ) => {
76
- if ( ! address ) return null
77
- if ( ! chainId ) return null
78
- if ( ! publicClient ) return null
79
- if ( inputTokenAmount <= 0 ) return null
80
- if ( ! indexToken ) return null
81
- const [ inputTokenPrice , outputTokenPrice ] = await Promise . all ( [
82
- getTokenPrice ( inputToken , chainId ) ,
83
- getTokenPrice ( outputToken , chainId ) ,
84
- ] )
85
- return await getIndexQuote ( {
86
- isMinting,
87
- chainId,
88
- address,
89
- inputToken,
90
- inputTokenAmount : inputValue ,
91
- inputTokenPrice,
92
- outputToken,
93
- outputTokenPrice,
94
- nativeTokenPrice,
95
- slippage : 0.1 ,
96
- } )
97
- }
98
-
99
72
const resetQuote = ( ) => {
100
73
setQuoteResult ( {
101
74
type : QuoteType . flashmint ,
@@ -129,55 +102,30 @@ export function useQuoteResult(request: QuoteRequest) {
129
102
refetchOnWindowFocus : false ,
130
103
} )
131
104
132
- const { data : swapQuote , isFetching : isFetchingSwapQuote } = useQuery ( {
133
- queryKey : [
134
- 'swap-quote' ,
135
- {
136
- address,
137
- chainId,
138
- inputToken,
139
- outputToken,
140
- inputTokenAmount : inputTokenAmount . toString ( ) ,
141
- publicClient,
142
- } ,
143
- ] ,
144
- queryFn : fetchSwapQuote ,
145
- enabled :
146
- ! ! address &&
147
- ! ! chainId &&
148
- ! ! publicClient &&
149
- ! ! inputToken &&
150
- ! ! outputToken &&
151
- inputTokenAmount > 0 ,
152
- } )
153
-
154
105
useEffect ( ( ) => {
155
- const bestQuote = getBestYieldQuote (
156
- flashmintQuote ?? null ,
157
- swapQuote ?? null ,
158
- chainId ?? - 1 ,
159
- )
160
- if ( bestQuote ) {
161
- logEvent ( 'Quote Received' , formatQuoteAnalytics ( bestQuote ) )
106
+ if ( flashmintQuote ) {
107
+ logEvent ( 'Quote Received' , formatQuoteAnalytics ( flashmintQuote ) )
162
108
}
163
109
110
+ if ( flashmintQuote === undefined ) return
111
+
164
112
const quoteResult = {
165
- type : bestQuote ?. type ?? QuoteType . flashmint ,
113
+ type : flashmintQuote ?. type ?? QuoteType . flashmint ,
166
114
isAvailable : true ,
167
- quote : bestQuote ,
115
+ quote : flashmintQuote ,
168
116
error : null ,
169
117
}
170
118
171
119
setQuoteResult ( quoteResult )
172
120
sendTradeEvent ( {
173
121
type : 'QUOTE' ,
174
122
quoteResult,
175
- quoteType : bestQuote ?. type ?? QuoteType . flashmint ,
123
+ quoteType : flashmintQuote ?. type ?? QuoteType . flashmint ,
176
124
} )
177
- } , [ chainId , flashmintQuote , logEvent , swapQuote , sendTradeEvent ] )
125
+ } , [ chainId , flashmintQuote , logEvent , sendTradeEvent ] )
178
126
179
127
return {
180
- isFetchingQuote : isFetchingFlashMintQuote || isFetchingSwapQuote ,
128
+ isFetchingQuote : isFetchingFlashMintQuote ,
181
129
quoteResult,
182
130
resetQuote,
183
131
}
0 commit comments