@exodus/fiat-balances 1.0.1 → 1.0.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/index.js +31 -3
- package/package.json +5 -4
package/index.js
CHANGED
|
@@ -125,16 +125,44 @@ class FiatBalances extends ExodusModule {
|
|
|
125
125
|
delete this.#balances.byWalletAccount[walletAccount]
|
|
126
126
|
})
|
|
127
127
|
|
|
128
|
+
const { byWalletAccount, byAssetSource, byBaseAssetSource } = this.#balances
|
|
128
129
|
Object.entries(changes).forEach(([walletAccount, walletAccountBalancesChanges]) => {
|
|
129
|
-
const walletAccountBalances =
|
|
130
|
+
const walletAccountBalances = byWalletAccount[walletAccount]
|
|
130
131
|
Object.entries(walletAccountBalancesChanges).forEach(
|
|
131
132
|
([assetName, assetSourceBalancesChanges]) => {
|
|
133
|
+
const baseAssetName = this.#assetsModule.getAsset(assetName).baseAsset.name
|
|
132
134
|
this.#balanceFields.forEach((field) => {
|
|
133
135
|
const { from, to } = assetSourceBalancesChanges[field]
|
|
134
136
|
walletAccountBalances[field] = walletAccountBalances[field] || this.#fiatCurrency.ZERO
|
|
137
|
+
|
|
138
|
+
const fromFiatValue = this.#convertToFiat({ assetName, value: from })
|
|
139
|
+
const toFiatValue = this.#convertToFiat({ assetName, value: to })
|
|
135
140
|
walletAccountBalances[field] = walletAccountBalances[field]
|
|
136
|
-
.sub(
|
|
137
|
-
.add(
|
|
141
|
+
.sub(fromFiatValue)
|
|
142
|
+
.add(toFiatValue)
|
|
143
|
+
|
|
144
|
+
//
|
|
145
|
+
;[
|
|
146
|
+
({
|
|
147
|
+
byAssetSource,
|
|
148
|
+
assetName,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
byAssetSource: byBaseAssetSource,
|
|
152
|
+
assetName: baseAssetName,
|
|
153
|
+
}),
|
|
154
|
+
].forEach(({ byAssetSource, assetName }) => {
|
|
155
|
+
if (!byAssetSource[walletAccount][assetName][field]) {
|
|
156
|
+
set(byAssetSource, [walletAccount, assetName, field], this.#fiatCurrency.ZERO)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// eslint-disable-next-line @exodus/mutable/no-param-reassign-prop-only
|
|
160
|
+
byAssetSource[walletAccount][assetName][field] = byAssetSource[walletAccount][
|
|
161
|
+
assetName
|
|
162
|
+
][field]
|
|
163
|
+
.sub(fromFiatValue)
|
|
164
|
+
.add(toFiatValue)
|
|
165
|
+
})
|
|
138
166
|
})
|
|
139
167
|
}
|
|
140
168
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/fiat-balances",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@exodus/atoms": "^1.0.0",
|
|
31
|
-
"@exodus/balances": "^1.
|
|
32
|
-
"@exodus/basic-utils": "^0.
|
|
31
|
+
"@exodus/balances": "^1.1.1",
|
|
32
|
+
"@exodus/basic-utils": "^1.0.0",
|
|
33
33
|
"@exodus/blockchain-metadata": "^2.2.0",
|
|
34
34
|
"@exodus/enabled-assets": "^1.0.0",
|
|
35
35
|
"@exodus/models": "^8.9.0",
|
|
36
36
|
"@exodus/storage-memory": "^1.0.0"
|
|
37
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "cbca7f075af27af557d498dc6dc74f61909434ad"
|
|
38
39
|
}
|