Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@centrifuge/sdk",
"version": "0.40.1",
"version": "0.40.2",
"description": "",
"homepage": "https://github.com/centrifuge/sdk/tree/main#readme",
"author": "",
Expand Down
46 changes: 26 additions & 20 deletions src/entities/Investor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Centrifuge } from '../Centrifuge.js'
import type { HexString } from '../types/index.js'
import { AssetId, PoolId, ShareClassId } from '../utils/types.js'
import { Entity } from './Entity.js'
import { Balance } from '../utils/BigInt.js'
import { Balance, Price } from '../utils/BigInt.js'

export class Investor extends Entity {
address: HexString
Expand Down Expand Up @@ -131,8 +131,9 @@ export class Investor extends Entity {
id: string
address: string
} | null
token: { name: string; symbol: string; decimals: string }
tokenAmount: string
token: { name: string; symbol: string; decimals: string } | null
tokenAmount: string | null
tokenPrice: string | null
centrifugeId: string
poolId: string
}[]
Expand All @@ -141,10 +142,10 @@ export class Investor extends Entity {
}>(
`query ($address: String!, $poolId: BigInt!, $limit: Int!, $offset: Int!) {
investorTransactions(
where: {
where: {
account: $address,
poolId: $poolId
}
}
limit: $limit
offset: $offset
) {
Expand All @@ -162,6 +163,7 @@ export class Investor extends Entity {
}
token { name symbol decimals }
tokenAmount
tokenPrice
centrifugeId
poolId
}
Expand All @@ -181,29 +183,33 @@ export class Investor extends Entity {

return {
transactions: investorTransactions.items
.filter((item) => item.poolId === poolId.toString() && item.currencyAsset !== null)
.filter((item) => item.poolId === poolId.toString())
.map((item) => {
const chainId = chainsById.get(item.centrifugeId)
if (!chainId) return null
if (!item.currencyAsset) return null

return {
type: item.type,
txHash: item.txHash,
createdAt: item.createdAt,
currency: {
amount: new Balance(item.currencyAmount, item.currencyAsset.decimals),
symbol: item.currencyAsset.symbol,
decimals: item.currencyAsset.decimals,
id: item.currencyAsset.id,
address: item.currencyAsset.address,
},
token: {
name: item.token.name,
symbol: item.token.symbol,
decimals: Number(item.token.decimals),
amount: new Balance(item.tokenAmount, Number(item.token.decimals)),
},
currency: item.currencyAsset
? {
amount: new Balance(item.currencyAmount, item.currencyAsset.decimals),
symbol: item.currencyAsset.symbol,
decimals: item.currencyAsset.decimals,
id: item.currencyAsset.id,
address: item.currencyAsset.address,
}
: undefined,
token: item.token && item.tokenAmount
? {
name: item.token.name,
symbol: item.token.symbol,
decimals: Number(item.token.decimals),
amount: new Balance(item.tokenAmount, Number(item.token.decimals)),
}
: undefined,
tokenPrice: item.tokenPrice ? new Price(item.tokenPrice) : undefined,
chainId: Number(chainId),
poolId: item.poolId,
}
Expand Down
Loading