Querying data

You can follow the official GraphQL guide here to learn more about GraphQL, how it works, and how to use it:

  • There are libraries to help you implement GraphQL in your application.
  • For an in-depth learning experience with practical tutorials, see How to GraphQL.
  • Check out the free online course, Exploring GraphQL: A Query Language for APIs.

Endpoints

Sample Queries

Queries can be tested in a dedicated SubQL Sandbox. The SubQL documentation provides some insights on how to perform queries in their SubQuery explorer.

Here some important hints and common pitfalls that can save you some time when working woth our data:

  • Currencies and Token amounts are expressed in fixed decimal precision

    As pools have different reference currencies, the amount this precision can vary. For this matter we reference the Currency entity in Pools, so that the correct amount of decimals can be queried together with each pool.

  • Queries return a maximum of 100 entries per page by default

    This can be increased to a maximum of 1000 entries per page in production environments. Sanbox environments are limited to 100 results.

  • Entities ids are not necessarily the same as on chain ids Therefore, when querying an entity, always refer to the GraphQL data model to verify how the id is composed.

Get net portfolio valuation and active loans for all Centrifuge Pools

1{
2 pools {
3 nodes {
4 id
5 currency {
6 id
7 decimals
8 }
9 portfolioValuation
10 sumNumberOfActiveLoans
11 }
12 }
13}

Get balances and last investor transactions for an account

1{
2 account(id: "kALNreUp6oBmtfG87fe7MakWR8BnmQ4SmKjjfG27iVd3nuTue") {
3 id
4 outstandingOrders {
5 nodes {
6 investAmount
7 redeemAmount
8 trancheId
9 }
10 }
11 investorTransactions(last: 2) {
12 nodes {
13 type
14 currencyAmount
15 tokenAmount
16 }
17 }
18 currencyBalances {
19 nodes {
20 amount
21 }
22 }
23 trancheBalances {
24 nodes {
25 trancheId
26 sumInvestOrderedAmount
27 sumInvestCollectedAmount
28 sumInvestUncollectedAmount
29 }
30 }
31 }
32}

Get outstanding debt information for loans belongig to a pool

1{
2 pool(id: "2825130900") {
3 id
4 currency {
5 id
6 decimals
7 }
8 loans {
9 nodes {
10 id
11 outstandingDebt
12 }
13 }
14 }
15}

Get historical token price and token supply evolution for a given tranche token

1{
2 trancheSnapshots(
3 orderBy: TIMESTAMP_ASC
4 filter: {
5 trancheId: { equalTo: "1873519631-0xb05f8e95eaf6ffc940ab4b4fbcb6324b" }
6 }
7 ) {
8 nodes {
9 id
10 timestamp
11 tokenPrice
12 tokenSupply
13 }
14 }
15}

Get TVL for single pools or for the entire ecosystem

The TVL for each pool can be obtained with the following query:

1{
2 pools {
3 nodes {
4 value
5 }
6 }
7}

The total for the entire CFG ecosystem is obtained by summing across all results.

Contributors