Skip to content

Commit

Permalink
fix investor tx report
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Nov 1, 2023
1 parent 3ae0643 commit 46d8ba4
Showing 1 changed file with 20 additions and 28 deletions.
48 changes: 20 additions & 28 deletions centrifuge-js/src/modules/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2121,35 +2121,27 @@ export function getPoolsModule(inst: Centrifuge) {
}
)

return $api.pipe(
switchMap((api) =>
combineLatest([$query, api.query.poolSystem.pool(poolId).pipe(take(1)), getCurrencies()]).pipe(
switchMap(([queryData, poolValue, currencies]) => {
const pool = poolValue.toHuman() as unknown as PoolDetailsData
const currency = findCurrency(currencies, pool.currency)!
const currencyDecimals = currency.decimals
return combineLatest([$query, getPoolCurrency([poolId])]).pipe(
switchMap(([queryData, currency]) => {
const currencyDecimals = currency.decimals

return [
queryData?.investorTransactions.nodes.map((tx) => {
return {
id: tx.id,
timestamp: new Date(tx.timestamp),
accountId: tx.accountId,
trancheId: tx.trancheId,
epochNumber: tx.epochNumber,
type: tx.type as InvestorTransactionType,
currencyAmount: tx.currencyAmount
? new CurrencyBalance(tx.currencyAmount, currencyDecimals)
: undefined,
tokenAmount: tx.tokenAmount ? new CurrencyBalance(tx.tokenAmount, currencyDecimals) : undefined,
tokenPrice: tx.tokenPrice ? new Price(tx.tokenPrice) : undefined,
transactionFee: tx.transactionFee ? new CurrencyBalance(tx.transactionFee, 18) : undefined, // native tokenks are always denominated in 18
}
}) as unknown as InvestorTransaction[],
]
})
)
)
return [
queryData?.investorTransactions.nodes.map((tx) => {
return {
id: tx.id,
timestamp: new Date(tx.timestamp),
accountId: tx.accountId,
trancheId: tx.trancheId,
epochNumber: tx.epochNumber,
type: tx.type as InvestorTransactionType,
currencyAmount: tx.currencyAmount ? new CurrencyBalance(tx.currencyAmount, currencyDecimals) : undefined,
tokenAmount: tx.tokenAmount ? new CurrencyBalance(tx.tokenAmount, currencyDecimals) : undefined,
tokenPrice: tx.tokenPrice ? new Price(tx.tokenPrice) : undefined,
transactionFee: tx.transactionFee ? new CurrencyBalance(tx.transactionFee, 18) : undefined, // native tokenks are always denominated in 18
}
}) as unknown as InvestorTransaction[],
]
})
)
}

Expand Down

0 comments on commit 46d8ba4

Please sign in to comment.