11import lodash from 'lodash'
22import { ReactNode , useCallback , useEffect , useMemo , useRef , useState } from 'react'
33import { ethAddress } from 'viem'
4+ import { useConfig } from 'wagmi'
45import ChipInpHelper from '@/dex/components/ChipInpHelper'
56import DetailInfoEstGas from '@/dex/components/DetailInfoEstGas'
67import FieldHelperUsdRate from '@/dex/components/FieldHelperUsdRate'
@@ -131,6 +132,7 @@ const QuickSwap = ({
131132 const fromToken = tokens . find ( ( x ) => x . address . toLocaleLowerCase ( ) == fromAddress )
132133 const toToken = tokens . find ( ( x ) => x . address . toLocaleLowerCase ( ) == toAddress )
133134
135+ const config = useConfig ( )
134136 const updateFormValues = useCallback (
135137 (
136138 updatedFormValues : Partial < FormValues > ,
@@ -143,6 +145,7 @@ const QuickSwap = ({
143145 setConfirmedLoss ( false )
144146
145147 void setFormValues (
148+ config ,
146149 pageLoaded ? curve : null ,
147150 updatedFormValues ,
148151 searchedParams ,
@@ -152,7 +155,7 @@ const QuickSwap = ({
152155 isRefetch ,
153156 )
154157 } ,
155- [ curve , storeMaxSlippage , pageLoaded , searchedParams , setFormValues ] ,
158+ [ config , curve , storeMaxSlippage , pageLoaded , searchedParams , setFormValues ] ,
156159 )
157160
158161 const handleBtnClickSwap = useCallback (
@@ -175,7 +178,7 @@ const QuickSwap = ({
175178 const { dismiss } = notify ( `Please confirm ${ notifyMessage } ` , 'pending' )
176179 setTxInfoBar ( < AlertBox alertType = "info" > Pending { notifyMessage } </ AlertBox > )
177180
178- const resp = await fetchStepSwap ( actionActiveKey , curve , formValues , searchedParams , maxSlippage )
181+ const resp = await fetchStepSwap ( actionActiveKey , config , curve , formValues , searchedParams , maxSlippage )
179182
180183 if ( isSubscribed . current && resp && resp . hash && resp . activeKey === activeKey && ! resp . error && network ) {
181184 const txMessage = t `Transaction complete. Received ${ resp . swappedAmount } ${ toSymbol } .`
@@ -190,7 +193,7 @@ const QuickSwap = ({
190193 if ( resp ?. error ) setTxInfoBar ( null )
191194 if ( typeof dismiss === 'function' ) dismiss ( )
192195 } ,
193- [ activeKey , fetchStepSwap , updateFormValues , network ] ,
196+ [ activeKey , config , fetchStepSwap , updateFormValues , network ] ,
194197 )
195198
196199 const getSteps = useCallback (
@@ -222,7 +225,7 @@ const QuickSwap = ({
222225 onClick : async ( ) => {
223226 const notifyMessage = t `Please approve spending your ${ fromSymbol } .`
224227 const { dismiss } = notify ( notifyMessage , 'pending' )
225- await fetchStepApprove ( activeKey , curve , formValues , searchedParams , storeMaxSlippage )
228+ await fetchStepApprove ( activeKey , config , curve , formValues , searchedParams , storeMaxSlippage )
226229 if ( typeof dismiss === 'function' ) dismiss ( )
227230 } ,
228231 } ,
@@ -300,7 +303,15 @@ const QuickSwap = ({
300303
301304 return stepsKey . map ( ( key ) => stepsObj [ key ] )
302305 } ,
303- [ confirmedLoss , fetchStepApprove , storeMaxSlippage , handleBtnClickSwap , slippageImpact ?. isExpectedToAmount , steps ] ,
306+ [
307+ config ,
308+ confirmedLoss ,
309+ fetchStepApprove ,
310+ storeMaxSlippage ,
311+ handleBtnClickSwap ,
312+ slippageImpact ?. isExpectedToAmount ,
313+ steps ,
314+ ] ,
304315 )
305316
306317 const fetchData = useCallback ( ( ) => {
@@ -343,9 +354,9 @@ const QuickSwap = ({
343354 useEffect ( ( ) => fetchData ( ) , [ tokensMapperStr , searchedParams . fromAddress , searchedParams . toAddress ] )
344355
345356 useEffect ( ( ) => {
346- void updateTokenList ( isReady ? curve : null , tokensMapper )
357+ void updateTokenList ( config , isReady ? curve : null , tokensMapper )
347358 // eslint-disable-next-line react-hooks/exhaustive-deps
348- } , [ isReady , tokensMapperStr , curve ?. signerAddress ] )
359+ } , [ config , isReady , tokensMapperStr , curve ?. signerAddress ] )
349360
350361 // re-fetch data
351362 usePageVisibleInterval ( fetchData , REFRESH_INTERVAL [ '15s' ] )
0 commit comments