Feat/asset balance decimals fix (#1474)

* feat: positions tab asset balance decimals

* feat: positions tab asset balance decimals
This commit is contained in:
Bartłomiej Głownia 2022-09-26 15:33:01 +02:00 committed by GitHub
parent 195e234f16
commit 3f6bd066f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,19 +17,16 @@ export const AssetBalance = ({ partyId, assetSymbol }: AssetBalanceProps) => {
variables, variables,
}); });
if (data && data.length) { if (data && data.length) {
let decimals = 0;
const totalBalance = data.reduce((a, c) => { const totalBalance = data.reduce((a, c) => {
if (c.asset.symbol === assetSymbol) { if (c.asset.symbol === assetSymbol) {
decimals = c.asset.decimals;
return a + BigInt(c.balance); return a + BigInt(c.balance);
} }
return a; return a;
}, BigInt(0)); }, BigInt(0));
return ( return (
<span> <span>{addDecimalsFormatNumber(totalBalance.toString(), decimals)}</span>
{addDecimalsFormatNumber(
totalBalance.toString(),
data[0].asset.decimals
)}
</span>
); );
} }
return null; return null;