Skip to content

Commit

Permalink
fix: remove number conversion in sumMoney utility
Browse files Browse the repository at this point in the history
  • Loading branch information
alexp3y committed Dec 9, 2024
1 parent af7f990 commit 2193733
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/utils/src/money/calculate-money.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BigNumber } from 'bignumber.js';
import { type MarketData, type Money, type NumType, formatMarketPair } from '@leather.io/models';

import { isNumber } from '..';
import { initBigNumber, sumNumbers } from '../math/helpers';
import { initBigNumber } from '../math/helpers';
import { createMoney, formatMoney } from './format-money';
import { isMoney } from './is-money';

Expand Down Expand Up @@ -53,6 +53,6 @@ export function sumMoney(moneysArr: Money[]) {
if (moneysArr.some(item => item.symbol !== moneysArr[0].symbol))
throw new Error('Cannot sum different currencies');

const sum = sumNumbers(moneysArr.map(item => item.amount.toNumber()));
const sum = moneysArr.reduce((acc, item) => acc.plus(item.amount), new BigNumber(0));
return createMoney(sum, moneysArr[0].symbol, moneysArr[0].decimals);
}

0 comments on commit 2193733

Please sign in to comment.