From b1f0ec471506cf1c2121ce8d77db7c5bf4dad8b2 Mon Sep 17 00:00:00 2001 From: Onno Visser Date: Thu, 7 Sep 2023 17:37:18 +0200 Subject: [PATCH] CentrifugeJS: Change Price decimals (#1567) --- centrifuge-app/src/utils/tinlake/useTinlakePools.ts | 2 +- centrifuge-js/src/modules/pools.ts | 2 +- centrifuge-js/src/utils/BN.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/centrifuge-app/src/utils/tinlake/useTinlakePools.ts b/centrifuge-app/src/utils/tinlake/useTinlakePools.ts index 86b68334e5..a79d6a64bf 100644 --- a/centrifuge-app/src/utils/tinlake/useTinlakePools.ts +++ b/centrifuge-app/src/utils/tinlake/useTinlakePools.ts @@ -403,7 +403,7 @@ async function getPools(pools: IpfsPools): Promise<{ pools: TinlakePool[] }> { const toCurrencyBalance = (val: BigNumber) => new CurrencyBalance(val.toString(), 18) const toTokenBalance = (val: BigNumber) => new TokenBalance(val.toString(), 18) const toRate = (val: BigNumber) => new Rate(val.toString()) - const toPrice = (val: BigNumber) => new Price(val.toString()) + const toPrice = (val: BigNumber) => new Rate(val.toString()) const calls: Call[] = [] pools.active.forEach((pool) => { diff --git a/centrifuge-js/src/modules/pools.ts b/centrifuge-js/src/modules/pools.ts index 99e1be6718..a06e58b82e 100644 --- a/centrifuge-js/src/modules/pools.ts +++ b/centrifuge-js/src/modules/pools.ts @@ -26,7 +26,7 @@ import { CurrencyBalance, Perquintill, Price, Rate, TokenBalance } from '../util import { Dec } from '../utils/Decimal' const PerquintillBN = new BN(10).pow(new BN(18)) -const PriceBN = new BN(10).pow(new BN(27)) +const PriceBN = new BN(10).pow(new BN(18)) const MaxU128 = '340282366920938463463374607431768211455' const SEC_PER_DAY = 24 * 60 * 60 diff --git a/centrifuge-js/src/utils/BN.ts b/centrifuge-js/src/utils/BN.ts index ba6612a650..8f915234c4 100644 --- a/centrifuge-js/src/utils/BN.ts +++ b/centrifuge-js/src/utils/BN.ts @@ -55,7 +55,7 @@ export class TokenBalance extends CurrencyBalance { } export class Price extends BNSubType { - static decimals = 27 + static decimals = 18 static fromFloat(number: Numeric) { return Price._fromFloat(number) }