Skip to content

Commit

Permalink
refresh rate after 10s
Browse files Browse the repository at this point in the history
  • Loading branch information
viet-nv committed Nov 3, 2023
1 parent 14c3770 commit 762aedd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/hooks/elasticZap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function useZapInPoolResult(params?: {

const [loadingAggregator, setLoadingAggregator] = useState(false)
const [getRoute] = useLazyGetRouteQuery()
const [slippage] = useUserSlippageTolerance()

const { aggregatorDomain } = useKyberswapGlobalConfig()
const url = `${aggregatorDomain}/${NETWORKS_INFO[chainId].aggregatorRoute}${AGGREGATOR_API_PATHS.GET_ROUTE}`
Expand All @@ -67,7 +68,11 @@ export function useZapInPoolResult(params?: {
const [aggregatorOutputs, setAggregatorOutputs] = useState<Array<RouteSummary>>([])

const { tokenIn, tokenOut, poolAddress } = params || {}
useEffect(() => {

const getRoutes = useCallback(() => {
if (slippage) {
// added to refresh rate when slippage change, aggregator dont need this
}
if (tokenIn && tokenOut && poolAddress) {
setAggregatorOutputs([])
if (useAggregatorForZap) {
Expand Down Expand Up @@ -96,7 +101,15 @@ export function useZapInPoolResult(params?: {
})
}
}
}, [tokenIn, tokenOut, poolAddress, splitedAmount, getRoute, url, useAggregatorForZap])
}, [tokenIn, tokenOut, poolAddress, splitedAmount, getRoute, url, useAggregatorForZap, slippage])

useEffect(() => {
getRoutes()
const i = setInterval(() => {
getRoutes()
}, 10_000)
return () => i && clearInterval(i)
}, [getRoutes])

const callParams = useMemo(
() =>
Expand Down

0 comments on commit 762aedd

Please sign in to comment.