Skip to content

Latest commit

 

History

History
73 lines (58 loc) · 2.55 KB

subgraph.md

File metadata and controls

73 lines (58 loc) · 2.55 KB
description
Developers > Yield Tranches > Subgraph

Subgraph

Idle uses a subgraph for indexing and organizing data from the Yield Tranches IdleCDO smart contract. This subgraph can be found on The Graph hosted service and can be used to query Idle YTs data:

Useful entities

  • TrancheInfos: contains the data of each YTs tranche (type, apr, virtualPrice, totalSupply) updated every hour
  • Tranche: all deployed YTs tranches (id, type)

Querying YTs

{% hint style="info" %} Subgraph is case-sensitive. Remember to use all lowercase when inputting tranches' addresses. {% endhint %}

Example 1

To obtain the latest TrancheInfos you can use the following query

{ 
    trancheInfos(orderBy:"timeStamp", orderDirection:"desc") { 
        id
        apr
        Tranche { 
            id 
        }
        timeStamp
        blockNumber
        totalSupply
        virtualPrice
    }
}

Example 2

To obtain the latest TrancheInfos for a specific tranche add a where filter. Let's query for example the Clearpool Portofino DAI Senior tranche 0xfc96989b3df087c96c806318436b16e44c697102

{ 
    trancheInfos(orderBy:"timeStamp", orderDirection:"desc", 
                 where:{ Tranche:"0xfc96989b3df087c96c806318436b16e44c697102" }) { 
        id
        apr
        Tranche { 
            id 
            CDO {
              id
            }
        }
        timeStamp
        blockNumber
        totalSupply
        virtualPrice
    }
}

For more info about GraphQL API, check TheGraph Documentation.