-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config refactor avoiding circular dep issues
- Loading branch information
Showing
39 changed files
with
2,050 additions
and
1,657 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { JsonRpcProvider } from '@ethersproject/providers'; | ||
import { data } from './data'; | ||
import { workerJobs } from './workers'; | ||
import { createServices } from './services'; | ||
|
||
let services: ReturnType<typeof createServices>; | ||
|
||
export class arbitrumNetworkConfig { | ||
static data = data; | ||
static workerJobs = workerJobs; | ||
static provider = new JsonRpcProvider({ url: data.rpcUrl, timeout: 60000 }) | ||
|
||
static get contentService() { | ||
if (!services) services = createServices(); | ||
|
||
return services.contentService; | ||
} | ||
|
||
static get poolAprServices() { | ||
if (!services) services = createServices(); | ||
|
||
return services.poolAprServices; | ||
} | ||
|
||
static get poolStakingServices() { | ||
if (!services) services = createServices(); | ||
|
||
return services.poolStakingServices; | ||
} | ||
|
||
static get tokenPriceHandlers() { | ||
if (!services) services = createServices(); | ||
|
||
return services.tokenPriceHandlers; | ||
} | ||
|
||
static get userStakedBalanceServices() { | ||
if (!services) services = createServices(); | ||
|
||
return services.userStakedBalanceServices; | ||
} | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { tokenService } from '../../token/token.service'; | ||
import { PhantomStableAprService } from '../../pool/lib/apr-data-sources/phantom-stable-apr.service'; | ||
import { BoostedPoolAprService } from '../../pool/lib/apr-data-sources/boosted-pool-apr.service'; | ||
import { SwapFeeAprService } from '../../pool/lib/apr-data-sources/swap-fee-apr.service'; | ||
import { GaugeAprService } from '../../pool/lib/apr-data-sources/ve-bal-gauge-apr.service'; | ||
import { GaugeStakingService } from '../../pool/lib/staking/gauge-staking.service'; | ||
import { BptPriceHandlerService } from '../../token/lib/token-price-handlers/bpt-price-handler.service'; | ||
import { LinearWrappedTokenPriceHandlerService } from '../../token/lib/token-price-handlers/linear-wrapped-token-price-handler.service'; | ||
import { SwapsPriceHandlerService } from '../../token/lib/token-price-handlers/swaps-price-handler.service'; | ||
import { UserSyncGaugeBalanceService } from '../../user/lib/user-sync-gauge-balance.service'; | ||
import { GithubContentService } from '../../content/github-content.service'; | ||
import { gaugeSubgraphService } from '../../subgraphs/gauge-subgraph/gauge-subgraph.service'; | ||
import { CoingeckoPriceHandlerService } from '../../token/lib/token-price-handlers/coingecko-price-handler.service'; | ||
import { coingeckoService } from '../../coingecko/coingecko.service'; | ||
import { IbTokensAprService } from '../../pool/lib/apr-data-sources/ib-tokens-apr.service'; | ||
import { data } from './data'; | ||
|
||
export const createServices = () => ({ | ||
contentService: new GithubContentService(), | ||
poolAprServices: [ | ||
new IbTokensAprService(data.ibAprConfig), | ||
new PhantomStableAprService(), | ||
new BoostedPoolAprService(), | ||
new SwapFeeAprService(data.balancer.swapProtocolFeePercentage), | ||
new GaugeAprService(tokenService, [data.bal!.address]), | ||
], | ||
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, data.bal!.address)], | ||
tokenPriceHandlers: [ | ||
new CoingeckoPriceHandlerService(coingeckoService), | ||
new BptPriceHandlerService(), | ||
new LinearWrappedTokenPriceHandlerService(), | ||
new SwapsPriceHandlerService(), | ||
], | ||
userStakedBalanceServices: [new UserSyncGaugeBalanceService()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import { every } from '../../../worker/intervals'; | ||
import { env } from '../../../app/env'; | ||
import { DeploymentEnv } from '../network-config-types'; | ||
|
||
/* | ||
For sub-minute jobs we set the alarmEvaluationPeriod and alarmDatapointsToAlarm to 1 instead of the default 3. | ||
This is needed because the minimum alarm period is 1 minute and we want the alarm to trigger already after 1 minute instead of 3. | ||
For every 1 days jobs we set the alarmEvaluationPeriod and alarmDatapointsToAlarm to 1 instead of the default 3. | ||
This is needed because the maximum alarm evaluation period is 1 day (period * evaluationPeriod). | ||
*/ | ||
export const workerJobs = [ | ||
{ | ||
name: 'update-token-prices', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(2, 'minutes'), | ||
}, | ||
{ | ||
name: 'update-liquidity-for-inactive-pools', | ||
interval: every(1, 'days'), | ||
alarmEvaluationPeriod: 1, | ||
alarmDatapointsToAlarm: 1, | ||
}, | ||
{ | ||
name: 'update-liquidity-for-active-pools', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'), | ||
}, | ||
{ | ||
name: 'update-pool-apr', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'), | ||
}, | ||
{ | ||
name: 'load-on-chain-data-for-pools-with-active-updates', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(4, 'minutes') : every(1, 'minutes'), | ||
}, | ||
{ | ||
name: 'sync-new-pools-from-subgraph', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(6, 'minutes') : every(2, 'minutes'), | ||
}, | ||
{ | ||
name: 'sync-tokens-from-pool-tokens', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'), | ||
}, | ||
{ | ||
name: 'update-liquidity-24h-ago-for-all-pools', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'), | ||
}, | ||
{ | ||
name: 'cache-average-block-time', | ||
interval: every(1, 'hours'), | ||
}, | ||
{ | ||
name: 'sync-staking-for-pools', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'), | ||
}, | ||
{ | ||
name: 'sync-latest-snapshots-for-all-pools', | ||
interval: every(1, 'hours'), | ||
}, | ||
{ | ||
name: 'update-lifetime-values-for-all-pools', | ||
interval: every(30, 'minutes'), | ||
}, | ||
{ | ||
name: 'sync-changed-pools', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(2, 'minutes') : every(20, 'seconds'), | ||
alarmEvaluationPeriod: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1, | ||
alarmDatapointsToAlarm: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? 3 : 1, | ||
}, | ||
{ | ||
name: 'user-sync-wallet-balances-for-all-pools', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(30, 'minutes') : every(10, 'minutes'), | ||
}, | ||
{ | ||
name: 'user-sync-staked-balances', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(30, 'minutes') : every(10, 'minutes'), | ||
}, | ||
{ | ||
name: 'sync-coingecko-coinids', | ||
interval: every(2, 'hours'), | ||
}, | ||
{ | ||
name: 'purge-old-tokenprices', | ||
interval: every(1, 'days'), | ||
alarmEvaluationPeriod: 1, | ||
alarmDatapointsToAlarm: 1, | ||
}, | ||
{ | ||
name: 'update-fee-volume-yield-all-pools', | ||
interval: every(1, 'hours'), | ||
}, | ||
{ | ||
name: 'sync-vebal-balances', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(9, 'minutes') : every(3, 'minutes'), | ||
}, | ||
{ | ||
name: 'sync-vebal-totalSupply', | ||
interval: (env.DEPLOYMENT_ENV as DeploymentEnv) === 'canary' ? every(10, 'minutes') : every(5, 'minutes'), | ||
}, | ||
]; |
Oops, something went wrong.