Commit afe38a2d authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: tick before returning quote (#3598)

parent d28607a1
import 'setimmediate'
import { Protocol } from '@uniswap/router-sdk' import { Protocol } from '@uniswap/router-sdk'
import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core' import { Currency, CurrencyAmount, TradeType } from '@uniswap/sdk-core'
import { ChainId } from '@uniswap/smart-order-router' import { ChainId } from '@uniswap/smart-order-router'
...@@ -75,7 +77,11 @@ export default function useClientSideSmartOrderRouterTrade<TTradeType extends Tr ...@@ -75,7 +77,11 @@ export default function useClientSideSmartOrderRouterTrade<TTradeType extends Tr
if (wrapType !== WrapType.NONE) return { error: undefined } if (wrapType !== WrapType.NONE) return { error: undefined }
if (!queryArgs || !params) return { error: undefined } if (!queryArgs || !params) return { error: undefined }
try { try {
return await getClientSideQuote(queryArgs, params, config) const quoteResult = await getClientSideQuote(queryArgs, params, config)
// There is significant post-fetch processing, so delay a tick to prevent dropped frames.
// This is only important in the context of integrations - if we control the whole site,
// then we can afford to drop a few frames.
return new Promise((resolve) => setImmediate(() => resolve(quoteResult)))
} catch { } catch {
return { error: true } return { error: true }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment