Secured Finance Docs
HomeBlogGitHubCommunityStablecoin ↗Fixed Income ↗
  • Introduction
    • ⚜️About Secured Finance
    • 🎏Vision & Mission
    • 🌍Ecosystem Overview
    • 🏁Roadmap
      • Roadmap 2024
      • Roadmap 2023
    • 📚DeFi Starter Guide
      • 🔄DeFi vs CeFi
      • 👛Wallet Setup
      • ⛽Gas Fees
      • 🤝DApps
      • 🏦DEX
      • 📝Smart Contracts
      • 🪙Governance Tokens
      • 🏛️DAOs
  • USDFC Stablecoin
    • 📢Overview
    • 🧙Getting Started
      • ⛽Creating Your First Trove
      • 👛Minting USDFC Step-by-Step
      • 🤝Managing Collateral Effectively
      • 🏦Monitoring Your Position
      • 🏊Using the Stability Pool
      • 💸Redeeming USDFC
    • 🔦Core Mechanics
      • 🏗️System Overview
      • ✏️The Trove System
      • 💰Mint & Borrow
      • 🚰Liquidation
      • 💸Redemption
      • 🧀Protocol Fees
    • 🎓Advanced Topics
      • 🚨Recovery Mode
    • 📔Contracts and Security
    • ❓FAQs
  • Fixed-Rate Lending
    • 📢Overview
      • 📖White Paper
      • 🎓Concept Paper
    • 🧙‍♂️Getting Started
      • 💵Lending Assets
      • 🏦Borrowing Assets
      • 📈Managing Positions
      • 🎮Platform Guide
        • 💰Trading
          • 💲Supported Currencies
        • 📈Markets
        • 🐋Portfolio
        • Bridge
        • 🚀Points
        • 📣Campaign
    • 🔦Core Mechanics
      • 🧩Order Book System
        • 🆎Order Type
        • 🪃Order Life Cycle
          • 💫Case Study: Order Status & Transition
      • 📐Standardization
        • 💠Zero-Coupon Bonds
        • ⏳Fixed Maturity
      • 🏋️Collateralization
      • 🪙Tokenization
      • 🚰Liquidation
        • ⚖️Mark to Market
        • 👮‍♂️Liquidators
          • ✏️How Liquidation Works
        • 📋Liquidation Case Study
      • 🧀Protocol Fees
    • 🎓Advanced Topics
      • 📈APR vs APY
      • ➗ZC Bond Price to APR
      • 📉Discount Factor
      • 🏋️‍♀️ZC Bond Collateral
        • 🏍️ZC Collateral Case Study
      • 🧬Market Dynamics
        • ♻️Auto-Rolling
          • 💰Price Discovery for Auto-Rolling
        • 🗓️New Market Listing and Delisting
          • 🤝Itayose - Fair Price Discovery
      • 🛡️Safety Measures
        • 🚦Circuit Breaker
          • 🛑Price Range Limits
        • 🪄Base Price Adjustment
        • 🌎Emergency Global Settlement
      • ⛓️Orderbook Deep Dive
        • 🎡Orderbook Rotation
        • 🎋Red Black Tree
        • ⏯️Lazy Evaluation
        • ⏮️Genesis Value
        • 🔄Compound Factor
    • 📔Contracts and Security
    • ❓FAQs
  • Developer Portal
    • 🧑‍💻Introduction
    • 🔌API Reference
      • 📈Fixed-Rate Lending Subgraph
        • 🔍Query Examples
    • 📦SDK Reference
      • ⛽Fixed-Rate Lending SDK
      • 👛USDFC SDK
    • 🐛Bug Bounty
  • Community
    • 🤝Overview
    • 🏛️Governance
    • 🪙Tokenomics
      • 🔵Secured Finance Coin (SFC)
      • 🔶Secured Finance Points (SFP) v2
        • 🔶Secured Finance Points (SFP) v1
    • 🎗️Support & Contacts
  • Resources
    • 🖼️Media Kit
      • 🖼️Secured Finance Logo
      • 💲USDFC Logo
    • ⚖️Legal
      • 📜Terms of Use
      • 🔒Privacy Policy
      • ⚠️Risk Disclaimer
Powered by GitBook
On this page
  • Tips and Guidelines:
  • Order Entity
  • Transfer Entity
  • Liquidation Entity
  • Transaction Entity
  • User Entity

Was this helpful?

Edit on GitHub
Export as PDF
  1. Developer Portal
  2. API Reference
  3. Fixed-Rate Lending Subgraph

Query Examples

Example queries for the Fixed-Rate Lending Subgraph

PreviousFixed-Rate Lending SubgraphNextSDK Reference

Last updated 28 days ago

Was this helpful?

The Graph uses the GraphQL language to query the subgraphs. This doc will teach you how to query the Secured Finance Subgraphs by writing the GraphQL queries. You can copy and paste these queries into the .

Tips and Guidelines:

  • Ensure that all address values (used for id) are in lowercase format.

  • Be aware of the units for each asset while querying. These fields will be returned in the decimals of the asset itself(e.g., 10^18 for Ether, 10^6 for USDC).

  • Each results page defaults to returning 100 entries. If needed, you can increase this limit to a maximum of 1000 entries per page by passing the first parameter.

  • To query for groups of entities in the middle of a collection, use the skip parameter in conjunction with the first parameter to skip a specified number of entities starting at the beginning of the collection.

  • For large datasets, consider optimising queries by fetching only the necessary fields and using pagination effectively.

  • Use the orderBy parameter to sort by a specific attribute and the orderDirection for ascending (asc) or descending(desc) direction.

  • Use the where parameter to filter for specific properties.

Order Entity

When a user places an order on our protocol, it is stored in the Order entity. You can check the order entity .

{
  orders(where: {user: "0xe477f1adcd3b4a2e1e152f79105a18e5368f0d33"}) {
    orderId
    user {
      id
    }
    side
    currency
    maturity
    status
    filledAmount
    inputAmount
    inputUnitPrice
    type
    isPreOrder
  }
}

Transfer Entity

{
  transfers(where: {user: "0xe477f1adcd3b4a2e1e152f79105a18e5368f0d33"}) {
    user {
      id
    }
    currency
    amount
    transferType
    timestamp
    blockNumber
    txHash
  }
}

Liquidation Entity

{
  liquidations(where: {user: "0xe477f1adcd3b4a2e1e152f79105a18e5368f0d33"}) {
    user {
      id
    }
    collateralCurrency
    debtCurrency
    debtMaturity
    debtAmount
    timestamp
    blockNumber
    txHash
  }
}

Transaction Entity

{
  transactions(where: {user: "0xe477f1adcd3b4a2e1e152f79105a18e5368f0d33"}) {
    user {
      id
    }
    currency
    maturity
    side
    executionPrice
    executionType
    futureValue
    amount
    feeInFV
    averagePrice
    lendingMarket {
      id
    }
    order {
      id
      orderId
    }
    createdAt
    blockNumber
    txHash
  }
}

User Entity

{
  user (id: "0xe477f1adcd3b4a2e1e152f79105a18e5368f0d33") {
    id
    createdAt
    transactionCount
    orderCount
    liquidationCount
    transferCount
    orders (orderBy: orderId, orderDirection: asc) {
      orderId
      currency
      maturity
      status
      inputAmount
      inputUnitPrice
    }
    transactions (skip: 20, first: 20) {
      currency
      maturity
      amount
      executionType
    }
    liquidations (where: {debtCurrency: "0x4554480000000000000000000000000000000000000000000000000000000000"}, orderBy: debtAmount, orderDirection: desc) {
      debtCurrency
      debtMaturity
      debtAmount
    }
    transfers (where: {transferType: Deposit}) {
      currency
      amount
      transferType
    }
    deposits {
      currency
      amount
    }
    takerVolumesByCurrency {
      currency
      totalVolume
    }
  }
}

You can also add nested filtering in the queries. The below query will fetch the users and their orders list where orderId is 1.

{
  users (where: { orders_: {orderId: 1}}) {
    id
    orders (where: {orderId: 1}) {
      orderId
      currency
      maturity
      status
      inputAmount
      inputUnitPrice
      type
      isPreOrder
    }
  }
}

When a user deposits or withdraws assets, it is stored in the Transfer entity. You can check the Transfer entity .

When a user is liquidated, it is stored in the Liquidation entity. You can check the Liquidation entity .

When a user takes an order or its order is taken, it is stored in the Transaction entity. You can check the Transaction entity .

All users' information for their orders, transactions, transfers, liquidations etc. are stored in the User entity. You can check the User entity .

🔌
📈
🔍
here
here
here
here
here
Subgraph endpoints