@exodus/fiat-balances 13.6.2 → 13.6.3

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [13.6.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.6.2...@exodus/fiat-balances@13.6.3) (2025-11-24)
7
+
8
+ ### Bug Fixes
9
+
10
+ - fix(fiat-balances): convert analytic values in other currencies to USD before reporting (#14437)
11
+
6
12
  ## [13.6.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.6.1...@exodus/fiat-balances@13.6.2) (2025-10-27)
7
13
 
8
14
  **Note:** Version bump only for package @exodus/fiat-balances
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "13.6.2",
3
+ "version": "13.6.3",
4
4
  "description": "Track asset and portfolio fiat balances based on changes in crypto balances and the user's preferred fiat currency",
5
5
  "author": "Exodus Movement, Inc.",
6
6
  "license": "MIT",
@@ -54,12 +54,12 @@
54
54
  "@exodus/enabled-assets": "^10.10.4",
55
55
  "@exodus/favorite-assets": "^2.6.0",
56
56
  "@exodus/fee-data-monitors": "^5.0.4",
57
- "@exodus/models": "^12.17.1",
57
+ "@exodus/models": "^12.18.0",
58
58
  "@exodus/rates-monitor": "^4.14.7",
59
59
  "@exodus/redux-dependency-injection": "^4.1.2",
60
60
  "@exodus/solana-meta": "^2.0.0",
61
61
  "@exodus/storage-memory": "^2.3.0",
62
- "@exodus/wallet-accounts": "^20.1.0",
62
+ "@exodus/wallet-accounts": "^20.2.1",
63
63
  "events": "^3.3.0",
64
64
  "redux": "^4.2.1"
65
65
  },
@@ -67,5 +67,5 @@
67
67
  "access": "public",
68
68
  "provenance": false
69
69
  },
70
- "gitHead": "30137851a6c221e970e9bc85a704403124632c62"
70
+ "gitHead": "f406cd4a8690ac1ce645f43abd03ae5769aa5ef0"
71
71
  }
@@ -1,31 +1,48 @@
1
1
  const createFiatBalancesAnalyticsPlugin = ({
2
2
  analytics,
3
- fiatBalancesAtom,
3
+ assetsTotalWalletAmountsAtom,
4
+ fiatRateConverter,
4
5
  config: { assetsToTrackForBalances },
5
6
  }) => {
6
7
  let subscriptions = []
7
8
 
8
- const setBalanceProperties = (balances) => {
9
- const assetFiatBalances = assetsToTrackForBalances.reduce((acc, obj) => {
10
- // Always set a value, default to 0 if balance doesn't exist
11
- acc[obj.analyticsName] = balances?.byAsset[obj.assetName]?.balance.toDefaultNumber() ?? 0
12
- return acc
13
- }, Object.create(null))
9
+ const setBalanceProperties = async (cryptoBalancesByAsset) => {
10
+ if (!cryptoBalancesByAsset) {
11
+ return
12
+ }
13
+
14
+ // Convert each asset's total crypto balance to USD
15
+ const assetFiatBalances = Object.fromEntries(
16
+ await Promise.all(
17
+ assetsToTrackForBalances.map(async ({ assetName, analyticsName }) => {
18
+ const cryptoBalance = cryptoBalancesByAsset.get(assetName)
19
+ if (cryptoBalance) {
20
+ const balanceUSD = await fiatRateConverter.toFiatCurrency({
21
+ amount: cryptoBalance,
22
+ currency: 'USD',
23
+ })
24
+ return [analyticsName, balanceUSD.toDefaultNumber()]
25
+ }
26
+
27
+ return [analyticsName, 0]
28
+ })
29
+ )
30
+ )
31
+
32
+ const totalBalanceUsd = Object.values(assetFiatBalances).reduce((sum, value) => sum + value, 0)
33
+
14
34
  analytics.setDefaultEventProperties({
15
35
  ...assetFiatBalances,
16
- // Always set totalBalanceUsd, default to 0 if not available
17
- totalBalanceUsd: balances?.totals?.balance?.toDefaultNumber() ?? 0,
36
+ totalBalanceUsd,
18
37
  })
19
38
  }
20
39
 
21
40
  const onStart = () => {
22
- setBalanceProperties(undefined)
23
-
24
- const unsubscribeBalancesAtom = fiatBalancesAtom.observe(({ balances }) => {
25
- setBalanceProperties(balances)
41
+ const unsubscribe = assetsTotalWalletAmountsAtom.observe((cryptoBalancesByAsset) => {
42
+ setBalanceProperties(cryptoBalancesByAsset)
26
43
  })
27
44
 
28
- subscriptions = [unsubscribeBalancesAtom]
45
+ subscriptions = [unsubscribe]
29
46
  }
30
47
 
31
48
  const onStop = () => {
@@ -39,7 +56,7 @@ const fiatBalancesAnalyticsPluginDefinition = {
39
56
  id: 'fiatBalancesAnalyticsPlugin',
40
57
  type: 'plugin',
41
58
  factory: createFiatBalancesAnalyticsPlugin,
42
- dependencies: ['analytics', 'fiatBalancesAtom', 'config?'],
59
+ dependencies: ['analytics', 'assetsTotalWalletAmountsAtom', 'fiatRateConverter', 'config?'],
43
60
  public: true,
44
61
  }
45
62