diff --git a/.env.dist b/.env.dist index 32c3803..2b50f2b 100644 --- a/.env.dist +++ b/.env.dist @@ -10,4 +10,3 @@ THREE_ROUTE_API_AUTH_TOKEN= REDIS_URL= ADD_NOTIFICATION_USERNAME= ADD_NOTIFICATION_PASSWORD= -TZPRO_API_KEY= diff --git a/src/config.ts b/src/config.ts index 81ec1d8..4cfd913 100644 --- a/src/config.ts +++ b/src/config.ts @@ -12,8 +12,7 @@ export const EnvVars = { THREE_ROUTE_API_AUTH_TOKEN: getEnv('THREE_ROUTE_API_AUTH_TOKEN'), REDIS_URL: getEnv('REDIS_URL'), ADD_NOTIFICATION_USERNAME: getEnv('ADD_NOTIFICATION_USERNAME'), - ADD_NOTIFICATION_PASSWORD: getEnv('ADD_NOTIFICATION_PASSWORD'), - TZPRO_API_KEY: getEnv('TZPRO_API_KEY') + ADD_NOTIFICATION_PASSWORD: getEnv('ADD_NOTIFICATION_PASSWORD') }; for (const name in EnvVars) { diff --git a/src/interfaces/ticker.interface.ts b/src/interfaces/ticker.interface.ts index 0658fae..15010cd 100644 --- a/src/interfaces/ticker.interface.ts +++ b/src/interfaces/ticker.interface.ts @@ -1,16 +1,4 @@ export interface ITicker { - pair: string; - base: string; - quote: string; - exchange: string; - open: number; - high: number; - low: number; - last: number; - change: number; - vwap: number; - n_trades: number; - volume_base: number; - volume_quote: number; - timestamp: string; + symbol: string; + price: string; } diff --git a/src/utils/tezos.ts b/src/utils/tezos.ts index 669ee3f..f8b87a7 100644 --- a/src/utils/tezos.ts +++ b/src/utils/tezos.ts @@ -3,7 +3,6 @@ import { tzip12 } from '@taquito/tzip12'; import { tzip16 } from '@taquito/tzip16'; import memoizee from 'memoizee'; -import { EnvVars } from '../config'; import { ITicker } from '../interfaces/ticker.interface'; import fetch from './fetch'; import SingleQueryDataProvider from './SingleQueryDataProvider'; @@ -54,18 +53,12 @@ export const getStorage = memoizee( ); const getTezExchangeRate = async () => { - const marketTickers = await fetch>( - `https://api.tzpro.io/markets/tickers?api_key=${EnvVars.TZPRO_API_KEY}` - ); - const usdTickers = marketTickers.filter(e => e.quote === 'USD' && e.base === 'XTZ'); - // price index: use all USD ticker last prices with equal weight - const vol = usdTickers.reduce((s, t) => s + t.volume_base, 0) || null; - const price = vol === null ? 1 : usdTickers.reduce((s, t) => s + (t.last * t.volume_base) / vol, 0); - - return price; + const { price: rawPrice } = await fetch('https://api.binance.com/api/v3/ticker/price?symbol=XTZUSDT'); + + return Number(rawPrice); }; -export const tezExchangeRateProvider = new SingleQueryDataProvider(30000, getTezExchangeRate); +export const tezExchangeRateProvider = new SingleQueryDataProvider(60000, getTezExchangeRate); export class MetadataParseError extends Error {}