Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ COINGECKO_BASE_URL=http://pricing-proxy:8080/coingecko
# own key) or to the public host anonymously.
# COINGECKO_API_KEY=

# GeckoTerminal Configuration.
#
# GECKOTERMINAL_BASE_URL: required. The origin used for GeckoTerminal token
# price calls. Recommended is the in-cluster pricing-proxy
# (https://github.com/DFXswiss/pricing-proxy), which gives cache, coalescing
# and validation on top of the shared free-tier 30 req/min quota. Anything
# GeckoTerminal-compatible works (api.geckoterminal.com directly is fine for
# single-consumer setups, but the free-tier quota is shared across the whole
# host IP).
GECKOTERMINAL_BASE_URL=http://pricing-proxy:8080/geckoterminal

# Telegram Bot Configuration (optional)
# TELEGRAM_BOT_TOKEN=5123456789:ABCdefGHIjklMNOpqrsTUVwxyz
# Path to the persisted subscribers file. Each operator subscribes themselves by
Expand Down
4 changes: 4 additions & 0 deletions src/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ export class AppConfigService {
return this.monitoringConfig.coingeckoBaseUrl || undefined;
}

get geckoTerminalBaseUrl(): string | undefined {
return this.monitoringConfig.geckoTerminalBaseUrl || undefined;
}

get environment(): string | undefined {
return this.monitoringConfig.environment;
}
Expand Down
5 changes: 5 additions & 0 deletions src/config/monitoring.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export class MonitoringConfig {
@IsString()
coingeckoApiKey?: string;

@IsOptional()
@IsString()
geckoTerminalBaseUrl?: string;

@IsOptional()
@IsString()
environment?: string;
Expand Down Expand Up @@ -105,6 +109,7 @@ export default registerAs('monitoring', () => {
config.alertTimeframeHours = parseInt(process.env.ALERT_TIMEFRAME_HOURS || '12');
config.coingeckoBaseUrl = process.env.COINGECKO_BASE_URL || '';
config.coingeckoApiKey = process.env.COINGECKO_API_KEY || '';
config.geckoTerminalBaseUrl = process.env.GECKOTERMINAL_BASE_URL || '';
config.environment = process.env.ENVIRONMENT?.toLowerCase();
config.chain = process.env.CHAIN;

Expand Down
7 changes: 6 additions & 1 deletion src/monitoringV2/price.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class PriceService {
if (!this.appConfigService.coingeckoBaseUrl) {
throw new Error('COINGECKO_BASE_URL is not set');
}
if (!this.appConfigService.geckoTerminalBaseUrl) {
throw new Error('GECKOTERMINAL_BASE_URL is not set');
}
}

registerWcbtcAddress(address: string): void {
Expand Down Expand Up @@ -225,9 +228,11 @@ export class PriceService {
const remaining = addresses.filter((addr) => !cached[addr]);
if (remaining.length === 0) return cached;

const baseUrl = this.appConfigService.geckoTerminalBaseUrl;

try {
const response = await axios.get<TokenPrice>(
`https://api.geckoterminal.com/api/v2/simple/networks/citrea/token_price/${remaining.map((a) => a.toLowerCase()).join(',')}`,
`${baseUrl}/api/v2/simple/networks/citrea/token_price/${remaining.map((a) => a.toLowerCase()).join(',')}`,
{
headers: { accept: 'application/json' },
timeout: 10000,
Expand Down
Loading