From 8c7bcce0796a5496941fdec5e19a1bad9859bab8 Mon Sep 17 00:00:00 2001 From: tomjeatt <40243778+tomjeatt@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:14:31 +0000 Subject: [PATCH] [release] Interlay 2.41.2 (#1625) --- api/market_data.js | 27 +++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/api/market_data.js b/api/market_data.js index 59f3664ce..9fe7fae94 100644 --- a/api/market_data.js +++ b/api/market_data.js @@ -34,12 +34,38 @@ const dia_assets = { "wrapped-bitcoin": "/Ethereum/0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599" } +// Coingecko to Dia XLSD tickers +const dia_xlsd = { + "voucher-ksm": "vKSM", + "voucher-dot": "vDOT", +} + +// retrieve Dia XLSD fair prices +const fetchDiaXLSD = async () => { + const url = 'https://api.diadata.org/xlsd' + const resp = await fetch(url, { headers: { "accept": "application/json" } }) + if (!resp.ok) { + throw new Error(resp.status) + } + const json = await resp.json() + return new Map(json.map(x => [x.Token, x])) +} + const fetchDiaAsset = async (asset) => { try { if (!dia_assets[asset]) { console.log('Missing DIA asset: ', asset) return coingecko({ ids: [asset], vs_currencies: ["usd"] }) } + if (asset in dia_xlsd) { + const prices = await fetchDiaXLSD(); + return { + [asset]: { + 'usd': prices.get(dia_xlsd[asset]).FairPrice + } + } + } + const url = 'https://api.diadata.org/v1/assetQuotation' + dia_assets[asset] const response = await fetch(url, { headers: { "accept": "application/json" } }) if (!response.ok) { @@ -56,6 +82,7 @@ const fetchDiaAsset = async (asset) => { } } catch (error) { console.log(error) + throw error; } } diff --git a/package.json b/package.json index 6315d7685..113cf973c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "interbtc-ui", - "version": "2.41.1", + "version": "2.41.2", "private": true, "dependencies": { "@craco/craco": "^6.1.1",