Skip to content

Commit b1224b5

Browse files
committed
debug: add log to calculate the time to get quotes
1 parent 4baf83c commit b1224b5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

apps/kyberswap-interface/src/pages/CrossChainSwap/hooks/useCrossChainSwap.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ export const CrossChainSwapRegistryProvider = ({ children }: { children: React.R
609609
setLoading(true)
610610
setAllLoading(true)
611611

612+
// Track quote fetching time
613+
const quoteStartTime = performance.now()
614+
console.log('[Quote Timing] Starting to fetch quotes...')
615+
612616
const getQuotesWithCancellation = async (params: QuoteParams | NearQuoteParams) => {
613617
const quotes: Quote[] = []
614618

@@ -925,6 +929,18 @@ export const CrossChainSwapRegistryProvider = ({ children }: { children: React.R
925929
} finally {
926930
setLoading(false)
927931
setAllLoading(false)
932+
933+
// Log total time taken to fetch all quotes
934+
const quoteEndTime = performance.now()
935+
const totalTime = quoteEndTime - quoteStartTime
936+
const tokenInSymbol = (currencyIn as any)?.symbol || (currencyIn as any)?.wrapped?.symbol || 'Unknown'
937+
const tokenOutSymbol = (currencyOut as any)?.symbol || (currencyOut as any)?.wrapped?.symbol || 'Unknown'
938+
console.log(
939+
`[Quote Timing] All quotes fetched and processed. ${amount} ${tokenInSymbol} -> ${tokenOutSymbol}. Total time: ${totalTime.toFixed(
940+
2,
941+
)}ms (${(totalTime / 1000).toFixed(2)}s)`,
942+
)
943+
console.log(`[Quote Timing] Number of quotes received: ${quotes.length}`)
928944
}
929945
}, [
930946
sender,

0 commit comments

Comments
 (0)