@talismn/token-rates 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -214,17 +214,20 @@ async function fetchTokenRates(tokens, currencyIds = ALL_CURRENCY_IDS, config =
|
|
214
214
|
const effectiveTaoIndex = effectiveCoingeckoIds.indexOf("bittensor");
|
215
215
|
const effectiveUsdIndex = effectiveCurrencyIds.indexOf("usd");
|
216
216
|
const taoUsdRate = rawTokenRates[effectiveTaoIndex]?.[effectiveUsdIndex]?.[0];
|
217
|
+
const taoUsdChange24h = rawTokenRates[effectiveTaoIndex]?.[effectiveUsdIndex]?.[2];
|
217
218
|
|
218
219
|
// insert TOKEN<>TAO rate (calculated based on TAO<>USD rate and TOKEN<>USD rate) into each TOKEN
|
219
220
|
const taoIndex = currencyIds.indexOf("tao");
|
220
221
|
rawTokenRates.forEach(rates => {
|
221
222
|
// get TOKEN<>USD rate
|
222
|
-
const
|
223
|
+
const tokenUsdRate = rates?.[effectiveUsdIndex]?.[0];
|
223
224
|
// calculate TOKEN<>TAO rate
|
224
|
-
const
|
225
|
+
const tokenTaoRate = typeof tokenUsdRate === "number" && typeof taoUsdRate === "number" && taoUsdRate !== 0 ? tokenUsdRate / taoUsdRate : null;
|
226
|
+
const tokenUsdChange24h = rates?.[effectiveUsdIndex]?.[2];
|
227
|
+
const tokenTaoChange24h = typeof taoUsdChange24h === "number" && typeof tokenUsdChange24h === "number" ? (1 + tokenUsdChange24h) / (1 + taoUsdChange24h) - 1 : null;
|
225
228
|
|
226
229
|
// insert at the correct location (based on the index of `tao` in `currencyIds`)
|
227
|
-
rates?.splice(taoIndex, 0, [
|
230
|
+
rates?.splice(taoIndex, 0, [tokenTaoRate, null, tokenTaoChange24h]);
|
228
231
|
});
|
229
232
|
}
|
230
233
|
const tokenRates = parseTokenRatesFromApi(rawTokenRates, coingeckoIds, currencyIds);
|
@@ -214,17 +214,20 @@ async function fetchTokenRates(tokens, currencyIds = ALL_CURRENCY_IDS, config =
|
|
214
214
|
const effectiveTaoIndex = effectiveCoingeckoIds.indexOf("bittensor");
|
215
215
|
const effectiveUsdIndex = effectiveCurrencyIds.indexOf("usd");
|
216
216
|
const taoUsdRate = rawTokenRates[effectiveTaoIndex]?.[effectiveUsdIndex]?.[0];
|
217
|
+
const taoUsdChange24h = rawTokenRates[effectiveTaoIndex]?.[effectiveUsdIndex]?.[2];
|
217
218
|
|
218
219
|
// insert TOKEN<>TAO rate (calculated based on TAO<>USD rate and TOKEN<>USD rate) into each TOKEN
|
219
220
|
const taoIndex = currencyIds.indexOf("tao");
|
220
221
|
rawTokenRates.forEach(rates => {
|
221
222
|
// get TOKEN<>USD rate
|
222
|
-
const
|
223
|
+
const tokenUsdRate = rates?.[effectiveUsdIndex]?.[0];
|
223
224
|
// calculate TOKEN<>TAO rate
|
224
|
-
const
|
225
|
+
const tokenTaoRate = typeof tokenUsdRate === "number" && typeof taoUsdRate === "number" && taoUsdRate !== 0 ? tokenUsdRate / taoUsdRate : null;
|
226
|
+
const tokenUsdChange24h = rates?.[effectiveUsdIndex]?.[2];
|
227
|
+
const tokenTaoChange24h = typeof taoUsdChange24h === "number" && typeof tokenUsdChange24h === "number" ? (1 + tokenUsdChange24h) / (1 + taoUsdChange24h) - 1 : null;
|
225
228
|
|
226
229
|
// insert at the correct location (based on the index of `tao` in `currencyIds`)
|
227
|
-
rates?.splice(taoIndex, 0, [
|
230
|
+
rates?.splice(taoIndex, 0, [tokenTaoRate, null, tokenTaoChange24h]);
|
228
231
|
});
|
229
232
|
}
|
230
233
|
const tokenRates = parseTokenRatesFromApi(rawTokenRates, coingeckoIds, currencyIds);
|
@@ -212,17 +212,20 @@ async function fetchTokenRates(tokens, currencyIds = ALL_CURRENCY_IDS, config =
|
|
212
212
|
const effectiveTaoIndex = effectiveCoingeckoIds.indexOf("bittensor");
|
213
213
|
const effectiveUsdIndex = effectiveCurrencyIds.indexOf("usd");
|
214
214
|
const taoUsdRate = rawTokenRates[effectiveTaoIndex]?.[effectiveUsdIndex]?.[0];
|
215
|
+
const taoUsdChange24h = rawTokenRates[effectiveTaoIndex]?.[effectiveUsdIndex]?.[2];
|
215
216
|
|
216
217
|
// insert TOKEN<>TAO rate (calculated based on TAO<>USD rate and TOKEN<>USD rate) into each TOKEN
|
217
218
|
const taoIndex = currencyIds.indexOf("tao");
|
218
219
|
rawTokenRates.forEach(rates => {
|
219
220
|
// get TOKEN<>USD rate
|
220
|
-
const
|
221
|
+
const tokenUsdRate = rates?.[effectiveUsdIndex]?.[0];
|
221
222
|
// calculate TOKEN<>TAO rate
|
222
|
-
const
|
223
|
+
const tokenTaoRate = typeof tokenUsdRate === "number" && typeof taoUsdRate === "number" && taoUsdRate !== 0 ? tokenUsdRate / taoUsdRate : null;
|
224
|
+
const tokenUsdChange24h = rates?.[effectiveUsdIndex]?.[2];
|
225
|
+
const tokenTaoChange24h = typeof taoUsdChange24h === "number" && typeof tokenUsdChange24h === "number" ? (1 + tokenUsdChange24h) / (1 + taoUsdChange24h) - 1 : null;
|
223
226
|
|
224
227
|
// insert at the correct location (based on the index of `tao` in `currencyIds`)
|
225
|
-
rates?.splice(taoIndex, 0, [
|
228
|
+
rates?.splice(taoIndex, 0, [tokenTaoRate, null, tokenTaoChange24h]);
|
226
229
|
});
|
227
230
|
}
|
228
231
|
const tokenRates = parseTokenRatesFromApi(rawTokenRates, coingeckoIds, currencyIds);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/token-rates",
|
3
|
-
"version": "2.0.
|
3
|
+
"version": "2.0.6",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -22,7 +22,7 @@
|
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
24
|
"dexie": "^4.0.9",
|
25
|
-
"@talismn/chaindata-provider": "0.10.
|
25
|
+
"@talismn/chaindata-provider": "0.10.5"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@types/jest": "^29.5.14",
|