@exodus/fiat-balances 1.0.3 → 1.0.4

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.
Files changed (3) hide show
  1. package/README.md +64 -0
  2. package/index.js +2 -2
  3. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @exodus/fiat-balances
2
+
3
+ This module tracks fiat balances for different networks (assets + their tokens) and portfolios.
4
+
5
+ ## WARNING: no asset specifics!
6
+
7
+ If you introduce any asset specifics like `if (assetName === 'dogicorn') balance = balance.mul(2)`, you will be fired immediately. This is a safety measure to save you from @feri42's wrath.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ yarn add @exodus/fiat-balances
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```js
18
+ import createFiatBalances from '@exodus/fiat-balances'
19
+
20
+ const fiatBalances = createFiatBalances({
21
+ // see #/assets-module in exodus-browser or tests for the API
22
+ assetsModule,
23
+ // @exodus/balances instance
24
+ balances,
25
+ // instance of https://github.com/ExodusMovement/exodus-browser/blob/c74cfb08b39f90675c5574707d8162b9472fdeb4/src/_local_modules/monitors/rates/index.js
26
+ ratesMonitor,
27
+ // @exodus/enabled-assets instance
28
+ enabledAssets,
29
+ // only 'balance' is supported for now
30
+ balanceFields: ['balance'],
31
+ // see ../modules/module/src/logger.js for API
32
+ logger,
33
+ })
34
+
35
+ fiatBalances.on('fiat-balances', ({ balances }) => {
36
+ // `balances`
37
+ // {
38
+ // totals: {
39
+ // [balanceField]: NumberUnit,
40
+ // },
41
+ // byWalletAccount: {
42
+ // [walletAccount]: {
43
+ // [balanceField]: NumberUnit,
44
+ // }
45
+ // },
46
+ // byAssetSource: {
47
+ // [walletAccount]: {
48
+ // [assetName]: {
49
+ // [balanceField]: NumberUnit
50
+ // }
51
+ // }
52
+ // },
53
+ // byBaseAssetSource: {
54
+ // [walletAccount]: {
55
+ // [assetName]: {
56
+ // [balanceField]: NumberUnit
57
+ // }
58
+ // }
59
+ // }
60
+ // }
61
+ })
62
+
63
+ fiatBalances.sync() // forces 'fiat-balances' event emission
64
+ ```
package/index.js CHANGED
@@ -143,14 +143,14 @@ class FiatBalances extends ExodusModule {
143
143
 
144
144
  //
145
145
  ;[
146
- ({
146
+ {
147
147
  byAssetSource,
148
148
  assetName,
149
149
  },
150
150
  {
151
151
  byAssetSource: byBaseAssetSource,
152
152
  assetName: baseAssetName,
153
- }),
153
+ },
154
154
  ].forEach(({ byAssetSource, assetName }) => {
155
155
  if (!byAssetSource[walletAccount][assetName][field]) {
156
156
  set(byAssetSource, [walletAccount, assetName, field], this.#fiatCurrency.ZERO)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/fiat-balances",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "module to track fiat balances based on changes in crypto balances and fiat currency",
5
5
  "author": "Exodus Movement Inc",
6
6
  "license": "UNLICENSED",
@@ -35,5 +35,5 @@
35
35
  "@exodus/models": "^8.9.0",
36
36
  "@exodus/storage-memory": "^1.0.0"
37
37
  },
38
- "gitHead": "cbca7f075af27af557d498dc6dc74f61909434ad"
38
+ "gitHead": "1d4de17f736b26087180ced4564e7897c7d1ef95"
39
39
  }