Skip to content

Commit

Permalink
Merge branch 'master' into release/interlay/2.41.2
Browse files Browse the repository at this point in the history
# Conflicts:
#	api/market_data.js
#	package.json
  • Loading branch information
tomjeatt committed Jan 4, 2024
2 parents bf14483 + 9115ca0 commit 6e5ecd3
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

0 comments on commit 6e5ecd3

Please sign in to comment.