@exodus/fiat-balances 13.2.1 → 13.3.0

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.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.2.1...@exodus/fiat-balances@13.3.0) (2025-03-17)
7
+
8
+ ### Features
9
+
10
+ - feat: improve fiat balance perf (#11796)
11
+
6
12
  ## [13.2.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.2.0...@exodus/fiat-balances@13.2.1) (2025-03-13)
7
13
 
8
14
  ### Bug Fixes
@@ -3,7 +3,6 @@ import { isNumberUnit } from '@exodus/currency'
3
3
  import { cloneDeepWith, isEqual } from 'lodash'
4
4
  import fiatCurrencies from '@exodus/fiat-currencies'
5
5
  import { combine } from '@exodus/atoms'
6
- import { getCreateConversion } from '../shared/get-create-conversion.js'
7
6
 
8
7
  // not super efficient, so we're assuming small objects, like { [walletAccount]: xyz }
9
8
  const areKeysSame = (a, b) => isEqual(Object.keys(a).sort(), Object.keys(b).sort())
@@ -70,17 +69,22 @@ class FiatBalances {
70
69
  )
71
70
  }
72
71
 
73
- // seems cheap, worth memoizing?
74
- #getCreateConversion = ({ assetName }) => {
72
+ #convertToFiat = ({ assetName, value }) => {
75
73
  const fiatCurrency = fiatCurrencies[this.#fiatCurrency]
74
+ if (value.isZero) return fiatCurrency.ZERO
76
75
  const rates = this.#cachedRates[this.#fiatCurrency]
77
76
  const asset = this.#assetsModule.getAsset(assetName)
77
+ let fiatRate
78
+ // HACK: Super hacky, terrible, the rates state object should have the prices split up by sub-objects per fiat
79
+ if (fiatCurrency.defaultUnit.unitName === 'USD') {
80
+ fiatRate = rates?.[asset.ticker]?.priceUSD || 0
81
+ } else {
82
+ fiatRate = rates?.[asset.ticker]?.price || 0
83
+ }
78
84
 
79
- return getCreateConversion(fiatCurrency, rates)(asset)
80
- }
85
+ if (fiatRate === 0) return fiatCurrency.ZERO
81
86
 
82
- #convertToFiat = ({ assetName, value }) => {
83
- return this.#getCreateConversion({ assetName })(value)
87
+ return fiatCurrency.defaultUnit(value.mul(fiatRate).toDefaultNumber())
84
88
  }
85
89
 
86
90
  #maybeRecompute = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "13.2.1",
3
+ "version": "13.3.0",
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",
@@ -48,7 +48,7 @@
48
48
  "@exodus/assets-feature": "^7.0.2",
49
49
  "@exodus/available-assets": "^8.7.0",
50
50
  "@exodus/balances": "^13.7.1",
51
- "@exodus/blockchain-metadata": "^15.9.1",
51
+ "@exodus/blockchain-metadata": "^15.9.2",
52
52
  "@exodus/combined-assets-meta": "^1.3.0",
53
53
  "@exodus/enabled-assets": "^10.9.1",
54
54
  "@exodus/favorite-assets": "^2.5.0",
@@ -58,12 +58,12 @@
58
58
  "@exodus/redux-dependency-injection": "^4.1.1",
59
59
  "@exodus/solana-meta": "^1.0.4",
60
60
  "@exodus/storage-memory": "^2.2.2",
61
- "@exodus/wallet-accounts": "^17.4.0",
61
+ "@exodus/wallet-accounts": "^17.4.1",
62
62
  "events": "^3.3.0",
63
63
  "redux": "^4.2.1"
64
64
  },
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "1fb48d23119fd45dd450a2d52b31dae958671d86"
68
+ "gitHead": "f00623d1c43d51091b3606039839640762dbe348"
69
69
  }