Skip to content

Commit

Permalink
Parse hex to BN to fix demo pools
Browse files Browse the repository at this point in the history
  • Loading branch information
sophialittlejohn committed Feb 22, 2024
1 parent e518891 commit 3be1570
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import { SolverResult, calculateOptimalSolution } from '..'
import { Centrifuge } from '../Centrifuge'
import { Account, TransactionOptions } from '../types'
import {
BorrowerTransactionType,
InvestorTransactionType,
SubqueryBorrowerTransaction,
SubqueryCurrencyBalances,
SubqueryInvestorTransaction,
SubqueryPoolSnapshot,
SubqueryTrancheBalances,
SubqueryTrancheSnapshot,
BorrowerTransactionType,
InvestorTransactionType,
SubqueryBorrowerTransaction,
SubqueryCurrencyBalances,
SubqueryInvestorTransaction,
SubqueryPoolSnapshot,
SubqueryTrancheBalances,
SubqueryTrancheSnapshot,
} from '../types/subquery'
import {
addressToHex,
computeTrancheId,
getDateMonthsFromNow,
getDateYearsFromNow,
getRandomUint,
isSameAddress,
addressToHex,
computeTrancheId,
getDateMonthsFromNow,
getDateYearsFromNow,
getRandomUint,
isSameAddress,
} from '../utils'
import { CurrencyBalance, Perquintill, Price, Rate, TokenBalance } from '../utils/BN'
import { Dec } from '../utils/Decimal'
Expand Down Expand Up @@ -957,16 +957,18 @@ export function getPoolsModule(inst: Centrifuge) {
status: 'open',
listed: metadata.listed ?? true,
poolFees: metadata.poolFees,
reports: metadata.poolReport ? [
{
author: {
name: metadata.poolReport.authorName,
title: metadata.poolReport.authorTitle,
avatar: metadata.poolReport.authorAvatar
},
uri: metadata.poolReport.url
}
] : undefined
reports: metadata.poolReport
? [
{
author: {
name: metadata.poolReport.authorName,
title: metadata.poolReport.authorTitle,
avatar: metadata.poolReport.authorAvatar,
},
uri: metadata.poolReport.url,
},
]
: undefined,
},
pod: {
node: metadata.podEndpoint ?? null,
Expand Down Expand Up @@ -2018,8 +2020,8 @@ export function getPoolsModule(inst: Centrifuge) {
const lastUpdatedNav = new Date((portfolioValuationData?.lastUpdated ?? 0) * 1000).toISOString()
// @ts-expect-error
const rawNav = rawNavs && rawNavs[poolIndex]?.toJSON()
const totalNavAum = rawNav?.navAum
? new CurrencyBalance(rawNav.navAum, currency.decimals)
const totalNavAum = rawNav?.navAum
? new CurrencyBalance(hexToBN(rawNav.navAum), currency.decimals)
: new CurrencyBalance(0, currency.decimals)

const mappedPool: Pool = {
Expand Down Expand Up @@ -2130,7 +2132,7 @@ export function getPoolsModule(inst: Centrifuge) {
lastUpdated: lastUpdatedNav,
},
value: rawNav?.total
? new CurrencyBalance(rawNav.total, currency.decimals)
? new CurrencyBalance(hexToBN(rawNav.total), currency.decimals)
: new CurrencyBalance(0, currency.decimals),
}

Expand Down

0 comments on commit 3be1570

Please sign in to comment.