Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tom/fix prices #1571

Merged
merged 13 commits into from
Sep 27, 2023
5 changes: 4 additions & 1 deletion api/market_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const tickers = {
"Dai Stablecoin": "dai",
"Ether": "ethereum",
"USD Coin": "usd-coin",
"tBTC v2": "tbtc"
"tBTC v2": "tbtc",
"Voucher Dot": "voucher-dot",
"Voucher KSM": "voucher-ksm"
}

// Coingecko to Dia asset ids
Expand All @@ -22,6 +24,7 @@ const dia_assets = {
"karura": "/Bifrost/518",
"tether": "/Ethereum/0xdAC17F958D2ee523a2206206994597C13D831ec7",
"voucher-dot": "/Bifrost-polkadot/2304",
"voucher-ksm": "/Bifrost/260",
"binancecoin": "/Ethereum/0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
"bnb": "/Ethereum/0xB8c77482e45F1F44dE1745F52C74426C631bDD52",
"tbtc": "/Ethereum/0x18084fbA666a33d37592fA2633fD49a74DD93a88",
Expand Down
13 changes: 12 additions & 1 deletion src/hooks/api/use-get-prices.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ import { useGetCurrencies } from './use-get-currencies';
// MEMO: Returns `undefined` for currencies without coingecko ID.
const getCoingeckoId = (currency: CurrencyExt) => {
if (isForeignAsset(currency)) {
return currency.foreignAsset.coingeckoId;
// TODO: This is a temporary fix to force V[DOT/KSM] prices. We need to refactor the lib to return an id
// even when a CoinGecko id doesn't exist. We also need to remove references to CoinGecko ids; this
// doesn't make sense/is very confusing now that we use DIA as our primary price source.
switch (currency.ticker) {
case 'VDOT':
return 'voucher-dot';
case 'VKSM':
return 'voucher-ksm';
default:
return currency.foreignAsset.coingeckoId;
}
}
return COINGECKO_ID_BY_CURRENCY_TICKER[currency.ticker];
};

const composeIds = (currencies: CurrencyExt[]): string =>
currencies.reduce((acc, currency) => {
const coingeckoId = getCoingeckoId(currency);
console.log('coingeckoId', coingeckoId);
if (!coingeckoId) {
return acc;
}
Expand Down
Loading