Skip to content

Commit

Permalink
Fix/offchain service 2 (#1534)
Browse files Browse the repository at this point in the history
* fix: init offchain service

* offchain rewards: fix null cache
boost aprs: wait for vaults to laod first
  • Loading branch information
ReflectiveChimp authored Aug 12, 2024
1 parent 70b87a8 commit f8d70a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/api/offchain-rewards/OffchainRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/api/stats/getApys.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -154,6 +155,7 @@ const initApyService = async () => {
boostAprs = cachedBoostAprs ?? {};

setTimeout(updateApys, INIT_DELAY);
await serviceEventBus.waitForFirstEvent('vaults/updated');
setTimeout(updateBoostAprs, BOOST_APR_INIT_DELAY);
};

Expand Down
2 changes: 1 addition & 1 deletion src/api/stats/getBoostAprs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit f8d70a6

Please sign in to comment.