Skip to content

Commit

Permalink
[release] Interlay 2.41.2 (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjeatt authored Jan 4, 2024
1 parent bf14483 commit 8c7bcce
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions api/market_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -56,6 +82,7 @@ const fetchDiaAsset = async (asset) => {
}
} catch (error) {
console.log(error)
throw error;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "interbtc-ui",
"version": "2.41.1",
"version": "2.41.2",
"private": true,
"dependencies": {
"@craco/craco": "^6.1.1",
Expand Down

1 comment on commit 8c7bcce

@vercel
Copy link

@vercel vercel bot commented on 8c7bcce Jan 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.