diff --git a/src/api/offchain-rewards/OffchainRewards.ts b/src/api/offchain-rewards/OffchainRewards.ts index 913c79f25..92642486c 100644 --- a/src/api/offchain-rewards/OffchainRewards.ts +++ b/src/api/offchain-rewards/OffchainRewards.ts @@ -105,6 +105,7 @@ export class OffchainRewards { >(cacheKey); const cachedValues: CachedByProvider | undefined = typeof maybeCache === 'object' && + maybeCache !== null && maybeCache.type === CACHE_TYPE && maybeCache.version === CACHE_VERSION ? maybeCache.data diff --git a/src/api/stats/getApys.js b/src/api/stats/getApys.js index c82b65387..5f9edae04 100644 --- a/src/api/stats/getApys.js +++ b/src/api/stats/getApys.js @@ -28,9 +28,10 @@ const { getRealApys } = require('./real'); const { getSeiApys } = require('./sei'); const { getKey, setKey } = require('../../utils/cache'); const { fetchBoostAprs, BOOST_APR_EXPIRED } = require('./getBoostAprs'); +const { serviceEventBus } = require('../../utils/ServiceEventBus'); const INIT_DELAY = process.env.INIT_DELAY || 30 * 1000; -const BOOST_APR_INIT_DELAY = 30 * 1000; +const BOOST_APR_INIT_DELAY = 5 * 1000; var REFRESH_INTERVAL = 15 * 60 * 1000; const BOOST_REFRESH_INTERVAL = 2 * 60 * 1000; @@ -154,6 +155,7 @@ const initApyService = async () => { boostAprs = cachedBoostAprs ?? {}; setTimeout(updateApys, INIT_DELAY); + await serviceEventBus.waitForFirstEvent('vaults/updated'); setTimeout(updateBoostAprs, BOOST_APR_INIT_DELAY); }; diff --git a/src/api/stats/getBoostAprs.ts b/src/api/stats/getBoostAprs.ts index d117500c9..608f561fe 100644 --- a/src/api/stats/getBoostAprs.ts +++ b/src/api/stats/getBoostAprs.ts @@ -99,7 +99,7 @@ const updateBoostV1AprsForChain = async (chain: ApiChain, boosts: Boost[]) => { rewardRate[i], periodFinish[i] ); - if (!isNaN(parseFloat(apr.toString()))) { + if (isFiniteNumber(apr)) { boostAprs[boosts[i].id] = apr; } }