Skip to content

Commit

Permalink
Centrifuge App: Fix token price formatting (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser authored Sep 11, 2023
1 parent 82ddcd8 commit f89ccc0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions centrifuge-app/src/utils/formatting.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { CurrencyBalance, CurrencyMetadata, Perquintill, Price, TokenBalance } from '@centrifuge/centrifuge-js'
import { CurrencyBalance, CurrencyMetadata, Perquintill, Price, Rate, TokenBalance } from '@centrifuge/centrifuge-js'
import Decimal from 'decimal.js-light'

export function formatBalance(
amount: CurrencyBalance | TokenBalance | Price | Decimal | number,
amount: CurrencyBalance | TokenBalance | Price | Rate | Decimal | number,
currency?: string | CurrencyMetadata,
precision = 0,
minPrecision = precision
) {
const formattedAmount = (
amount instanceof TokenBalance || amount instanceof CurrencyBalance || amount instanceof Price
amount instanceof TokenBalance ||
amount instanceof CurrencyBalance ||
amount instanceof Price ||
amount instanceof Rate
? amount.toFloat()
: amount instanceof Decimal
? amount.toNumber()
Expand Down

0 comments on commit f89ccc0

Please sign in to comment.