@exodus/fiat-balances 13.7.1 → 13.7.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,18 @@
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.7.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.7.2...@exodus/fiat-balances@13.7.3) (2026-03-05)
7
+
8
+ ### Performance
9
+
10
+ - perf(fiat-balances): optimize cloneBalances with structure-aware shallow clone (#15481)
11
+
12
+ ## [13.7.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.7.1...@exodus/fiat-balances@13.7.2) (2026-02-25)
13
+
14
+ ### Performance
15
+
16
+ - perf(fiat-balances): remove dead isEqual deep comparison from flush (#15352)
17
+
6
18
  ## [13.7.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/fiat-balances@13.7.0...@exodus/fiat-balances@13.7.1) (2026-02-03)
7
19
 
8
20
  ### Performance
@@ -1,26 +1,52 @@
1
1
  import { set } from '@exodus/basic-utils'
2
- import { isNumberUnit } from '@exodus/currency'
3
- // eslint-disable-next-line no-restricted-imports -- TODO: Fix this the next time the file is edited.
4
- import lodash from 'lodash'
5
2
  import fiatCurrencies from '@exodus/fiat-currencies'
6
3
  import { combine } from '@exodus/atoms'
7
4
 
8
- const { isEqual } = lodash
5
+ const areKeysSame = (a, b) => {
6
+ const keysA = Object.keys(a)
7
+ const keysB = Object.keys(b)
8
+ if (keysA.length !== keysB.length) return false
9
+ const aKeySet = new Set(keysA)
10
+ return keysB.every((key) => aKeySet.has(key))
11
+ }
9
12
 
10
- // not super efficient, so we're assuming small objects, like { [walletAccount]: xyz }
11
- const areKeysSame = (a, b) => isEqual(Object.keys(a).sort(), Object.keys(b).sort())
13
+ const shallowClone = (obj) => ({ ...obj })
12
14
 
13
- export const cloneBalances = (balances) => {
14
- if (isNumberUnit(balances)) {
15
- return balances
15
+ const clone2Levels = (obj) => {
16
+ const result = Object.create(null)
17
+ for (const key of Object.keys(obj)) {
18
+ result[key] = { ...obj[key] }
16
19
  }
17
20
 
18
- const cloned = Object.create(Object.getPrototypeOf(balances))
19
- for (const key in balances) {
20
- cloned[key] = cloneBalances(balances[key])
21
+ return result
22
+ }
23
+
24
+ const clone3Levels = (obj) => {
25
+ const result = Object.create(null)
26
+ for (const key1 of Object.keys(obj)) {
27
+ const level1 = obj[key1]
28
+ const clonedLevel1 = Object.create(null)
29
+ for (const key2 of Object.keys(level1)) {
30
+ clonedLevel1[key2] = { ...level1[key2] }
31
+ }
32
+
33
+ result[key1] = clonedLevel1
21
34
  }
22
35
 
23
- return cloned
36
+ return result
37
+ }
38
+
39
+ export const cloneBalances = (wrapper) => {
40
+ const balances = wrapper.balances
41
+ return {
42
+ balances: {
43
+ totals: shallowClone(balances.totals),
44
+ byWalletAccount: clone2Levels(balances.byWalletAccount),
45
+ byAssetSource: clone3Levels(balances.byAssetSource),
46
+ byBaseAssetSource: clone3Levels(balances.byBaseAssetSource),
47
+ byAsset: clone2Levels(balances.byAsset),
48
+ },
49
+ }
24
50
  }
25
51
 
26
52
  class FiatBalances {
@@ -290,8 +316,7 @@ class FiatBalances {
290
316
 
291
317
  #flush = () => {
292
318
  this.#logger.log('fiat balances updated')
293
- const data = cloneBalances({ balances: this.#balances })
294
- this.#fiatBalancesAtom.set((current) => (isEqual(current, data) ? current : data))
319
+ this.#fiatBalancesAtom.set(cloneBalances({ balances: this.#balances }))
295
320
  }
296
321
 
297
322
  stop = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "13.7.1",
3
+ "version": "13.7.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",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@exodus/atoms": "^9.0.0",
38
- "@exodus/basic-utils": "^3.0.1",
38
+ "@exodus/basic-utils": "^3.7.3",
39
39
  "@exodus/currency": "^5.0.2",
40
40
  "@exodus/fiat-currencies": "^1.2.3",
41
41
  "@exodus/formatting": "^9.0.0",
@@ -46,15 +46,15 @@
46
46
  "devDependencies": {
47
47
  "@exodus/assets": "^11.0.0",
48
48
  "@exodus/assets-base": "^10.0.0",
49
- "@exodus/assets-feature": "^8.8.0",
50
- "@exodus/available-assets": "^8.10.1",
51
- "@exodus/balances": "^13.15.1",
49
+ "@exodus/assets-feature": "^9.0.1",
50
+ "@exodus/available-assets": "^8.11.0",
51
+ "@exodus/balances": "^13.15.2",
52
52
  "@exodus/blockchain-metadata": "^17.1.0",
53
53
  "@exodus/combined-assets-meta": "^3.3.2",
54
54
  "@exodus/enabled-assets": "^10.11.0",
55
55
  "@exodus/favorite-assets": "^2.6.0",
56
- "@exodus/fee-data-monitors": "^5.0.4",
57
- "@exodus/models": "^12.19.0",
56
+ "@exodus/fee-data-monitors": "^5.0.5",
57
+ "@exodus/models": "^12.19.1",
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",
@@ -67,5 +67,5 @@
67
67
  "access": "public",
68
68
  "provenance": false
69
69
  },
70
- "gitHead": "08c1bde4a68356e37503376e64d8484115eab442"
70
+ "gitHead": "d234e06c7b4a7e49eb7b8e3082a28c4fab19c0ce"
71
71
  }