make sure prices are queried only once

This commit is contained in:
juan 2021-03-12 15:36:35 -05:00
parent 3bf9eaad7a
commit 227937ab46
2 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import { EventEmitter } from '@oyster/common';
import React, { useContext, useEffect, useState } from 'react';
import { MarketsContextState } from './market';
export const COINGECKO_POOL_INTERVAL = 10000; // 2 min
export const COINGECKO_POOL_INTERVAL = 1000 * 30; // 30 sec
export const COINGECKO_API = 'https://api.coingecko.com/api/v3/';
export const COINGECKO_COIN_LIST_API = `${COINGECKO_API}coins/list`;
export const COINGECKO_COIN_PRICE_API = `${COINGECKO_API}simple/price`;

View File

@ -362,14 +362,14 @@ export const useWormholeAccounts = () => {
}, [externalAssets, setAmountInUSD]);
useEffect(() => {
if (externalAssets && coinList) {
if (externalAssets && coinList && !loading) {
dataSourcePriceQuery();
}
return () => {
window.clearTimeout(coingeckoTimer.current);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [externalAssets, coinList, dataSourcePriceQuery]);
}, [externalAssets, coinList, loading]);
return {
loading,