Merge pull request #186 from mempool/simon/update-pricefeed
Replace opennode usd price source with wiz api.
This commit is contained in:
		
						commit
						fdf9cf7977
					
				| @ -2,10 +2,8 @@ import logger from '../logger'; | |||||||
| import axios from 'axios'; | import axios from 'axios'; | ||||||
| 
 | 
 | ||||||
| class FiatConversion { | class FiatConversion { | ||||||
|   private tickers = { |   private conversionRates = { | ||||||
|     'BTCUSD': { |     'USD': 0 | ||||||
|       'USD': 4110.78 |  | ||||||
|     }, |  | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   constructor() { } |   constructor() { } | ||||||
| @ -16,16 +14,19 @@ class FiatConversion { | |||||||
|     this.updateCurrency(); |     this.updateCurrency(); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   public getTickers() { |   public getConversionRates() { | ||||||
|     return this.tickers; |     return this.conversionRates; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   private async updateCurrency(): Promise<void> { |   private async updateCurrency(): Promise<void> { | ||||||
|     try { |     try { | ||||||
|       const response = await axios.get('https://api.opennode.co/v1/rates'); |       const response = await axios.get('https://price.bisq.wiz.biz/getAllMarketPrices'); | ||||||
|       this.tickers = response.data.data; |       const usd = response.data.data.find((item: any) => item.currencyCode === 'USD'); | ||||||
|  |       this.conversionRates = { | ||||||
|  |         'USD': usd.price, | ||||||
|  |       }; | ||||||
|     } catch (e) { |     } catch (e) { | ||||||
|       logger.err('Error updating currency from OpenNode: ' + e); |       logger.err('Error updating fiat conversion rates: ' + e); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -126,7 +126,7 @@ class WebsocketHandler { | |||||||
|       'vBytesPerSecond': memPool.getVBytesPerSecond(), |       'vBytesPerSecond': memPool.getVBytesPerSecond(), | ||||||
|       'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(), |       'lastDifficultyAdjustment': blocks.getLastDifficultyAdjustmentTime(), | ||||||
|       'blocks': _blocks, |       'blocks': _blocks, | ||||||
|       'conversions': fiatConversion.getTickers()['BTCUSD'], |       'conversions': fiatConversion.getConversionRates(), | ||||||
|       'mempool-blocks': mempoolBlocks.getMempoolBlocks(), |       'mempool-blocks': mempoolBlocks.getMempoolBlocks(), | ||||||
|       'transactions': memPool.getLatestTransactions(), |       'transactions': memPool.getLatestTransactions(), | ||||||
|       'git-commit': backendInfo.gitCommitHash, |       'git-commit': backendInfo.gitCommitHash, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user