Skip to content

Commit

Permalink
Merge pull request #126 from madfish-solutions/TW-1194-try-coingecko
Browse files Browse the repository at this point in the history
TW-1194 Try coingecko for getting TEZ exchange rate
  • Loading branch information
lourenc authored Nov 27, 2023
2 parents fb5f64d + 5fa39bb commit 3c546e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/interfaces/ticker.interface.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/utils/tezos.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { compose, MichelCodecPacker, Signer, TezosToolkit } from '@taquito/taquito';
import { tzip12 } from '@taquito/tzip12';
import { tzip16 } from '@taquito/tzip16';
import axios, { AxiosError } from 'axios';
import { AxiosError } from 'axios';
import memoizee from 'memoizee';

import { ITicker } from '../interfaces/ticker.interface';
import { getMarketsBySymbols } from './coingecko';
import { isDefined } from './helpers';
import logger from './logger';
import SingleQueryDataProvider from './SingleQueryDataProvider';
Expand Down Expand Up @@ -56,9 +56,9 @@ export const getStorage = memoizee(

const getTezExchangeRate = async () => {
try {
const { data } = await axios.get<ITicker>('https://api.binance.com/api/v3/ticker/price?symbol=XTZUSDT');
const [xtzMarket] = await getMarketsBySymbols(['xtz']);

return Number(data.price);
return xtzMarket.current_price;
} catch (e) {
if (!(e instanceof AxiosError)) {
logger.error('Request for TEZ exchange rate failed with unknown error');
Expand Down

0 comments on commit 3c546e0

Please sign in to comment.