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
  • Overview
  • How It Works
  • Subgraph Endpoints
  • Key Entities
  • Transaction
  • User
  • Order
  • LendingMarket
  • Liquidation
  • Transfer
  • Deposit
  • DailyVolume
  • Protocol
  • ProtocolVolumeByCurrency
  • TakerVolumeByCurrency
  • TransactionCandleStick
  • TakerVolumeByIntervalAndCurrency
  • Examples
  • Interactive Documentation
  • FAQ
  • How do I query all active orders for a specific market?
  • How can I monitor new lending markets?
  • How do I calculate APR from unit prices?
  • Related Resources

Was this helpful?

Edit on GitHub
Export as PDF
  1. Developer Portal
  2. API Reference

Fixed-Rate Lending Subgraph

Documentation for querying the Fixed-Rate Lending Subgraph

PreviousAPI ReferenceNextQuery Examples

Last updated 28 days ago

Was this helpful?

The Fixed-Rate Lending Subgraph indexes data from the Secured Finance Fixed-Rate Lending protocol, enabling developers to query historical and current data using GraphQL.

Overview

The Fixed-Rate Lending protocol provides a platform for fixed-rate lending and borrowing through an order book system. The subgraph allows you to query information about orders, lending markets, transactions, positions, and other protocol activities.

How It Works

The Fixed-Rate Lending Subgraph continuously indexes events emitted by the Fixed-Rate Lending smart contracts. This data is organized into entities that can be queried using GraphQL, providing real-time access to protocol data without requiring direct interaction with the blockchain.

Subgraph Endpoints

For the complete list of subgraph endpoints, please refer to the page.

You can access the Fixed-Rate Lending Subgraph through these endpoints:

  • Ethereum Mainnet:

  • Ethereum Sepolia:

  • Arbitrum One:

  • Arbitrum Sepolia:

Note: The Filecoin subgraph endpoints are currently under development. Please check back later for updated URLs.

Key Entities

The Fixed-Rate Lending Subgraph schema includes these primary entities:

Transaction

Represents a transaction on the Fixed-Rate Lending protocol.

type Transaction @entity {
  id: ID!
  currency: Bytes!
  maturity: BigInt!
  side: Int!
  executionPrice: BigInt!
  user: User!
  executionType: TransactionExecutionType!
  futureValue: BigInt!
  amount: BigInt!
  feeInFV: BigInt!
  averagePrice: BigDecimal!
  lendingMarket: LendingMarket!
  order: Order!
  createdAt: BigInt!
  blockNumber: BigInt!
  txHash: Bytes!
}

enum TransactionExecutionType {
  Maker
  Taker
}

User

Represents users who interact with the Fixed-Rate Lending protocol.

type User @entity {
  id: ID! # wallet address
  createdAt: BigInt!
  transactionCount: BigInt!
  transactions: [Transaction!]! @derivedFrom(field: "user")
  orderCount: BigInt!
  orders: [Order!]! @derivedFrom(field: "user")
  liquidationCount: BigInt!
  liquidations: [Liquidation!]! @derivedFrom(field: "user")
  transferCount: BigInt!
  transfers: [Transfer!]! @derivedFrom(field: "user")
  deposits: [Deposit!]! @derivedFrom(field: "user")
  takerVolumesByCurrency: [TakerVolumeByCurrency!]! @derivedFrom(field: "user")
}

Order

Represents an order in the order book.

type Order @entity {
  id: ID!
  orderId: BigInt!
  user: User!
  currency: Bytes!
  side: Int!
  maturity: BigInt!
  inputUnitPrice: BigInt!
  inputAmount: BigInt!
  filledAmount: BigInt!
  status: OrderStatus!
  statusUpdatedAt: BigInt!
  lendingMarket: LendingMarket!
  isPreOrder: Boolean!
  type: OrderType!
  transactions: [Transaction!]! @derivedFrom(field: "order")
  isCircuitBreakerTriggered: Boolean!
  createdAt: BigInt!
  blockNumber: BigInt!
  txHash: Bytes!
}

enum OrderType {
  Market
  Limit
  Unwind
}

enum OrderStatus {
  Open
  PartiallyFilled
  Filled
  Killed
  Cancelled
}

LendingMarket

Represents a lending market for a specific currency and maturity.

type LendingMarket @entity {
  id: ID!
  currency: Bytes!
  maturity: BigInt!
  isActive: Boolean!
  transactions: [Transaction!]! @derivedFrom(field: "lendingMarket")
  orders: [Order!]! @derivedFrom(field: "lendingMarket")
  volume: BigInt!
  dailyVolume: [DailyVolume!]! @derivedFrom(field: "lendingMarket")
  openingUnitPrice: BigInt!
  lastLendUnitPrice: BigInt!
  lastBorrowUnitPrice: BigInt!
  offsetAmount: BigInt!
}

Liquidation

Records details of a liquidation event.

type Liquidation @entity {
  id: ID!
  collateralCurrency: Bytes!
  debtCurrency: Bytes!
  debtMaturity: BigInt!
  debtAmount: BigInt!
  user: User!
  timestamp: BigInt!
  blockNumber: BigInt!
  txHash: Bytes!
}

Transfer

Records details of a deposit or withdrawal.

type Transfer @entity {
  id: ID!
  user: User!
  currency: Bytes!
  amount: BigInt!
  transferType: TransferType!
  timestamp: BigInt!
  blockNumber: BigInt!
  txHash: Bytes!
}

enum TransferType {
  Deposit
  Withdraw
}

Deposit

Records details of a user's deposit.

type Deposit @entity {
  id: ID!
  user: User!
  currency: Bytes!
  amount: BigInt!
}

DailyVolume

Records daily trading volume for a lending market.

type DailyVolume @entity {
  id: ID! # currency-maturity-date(yyyy-mm-dd)
  currency: Bytes!
  maturity: BigInt!
  day: String! # dd-mm-yyyy
  volume: BigInt!
  timestamp: BigInt!
  lendingMarket: LendingMarket!
}

Protocol

Records protocol-wide statistics.

type Protocol @entity {
  id: ID! # 1
  totalUsers: BigInt!
  volumesByCurrency: [ProtocolVolumeByCurrency!]! @derivedFrom(field: "protocol")
}

ProtocolVolumeByCurrency

Records total volume by currency for the protocol.

type ProtocolVolumeByCurrency @entity {
  id: ID! # currency
  protocol: Protocol!
  currency: Bytes!
  totalVolume: BigInt!
}

TakerVolumeByCurrency

Records taker volume by currency for a user.

type TakerVolumeByCurrency @entity {
  id: ID! # user-currency
  user: User!
  currency: Bytes!
  totalVolume: BigInt!
  totalVolumesByInterval: [TakerVolumeByIntervalAndCurrency!]! @derivedFrom(field: "takerVolumesByCurrency")
}

TransactionCandleStick

Records price candles for transactions.

type TransactionCandleStick @entity {
  id: ID! # A composite ID, e.g., "currency-maturity-interval-epochTime"
  interval: BigInt! # interval in seconds
  currency: Bytes!
  maturity: BigInt!
  timestamp: BigInt! # The start time of the interval
  open: BigInt!
  close: BigInt!
  high: BigInt!
  low: BigInt!
  average: BigDecimal!
  volume: BigInt!
  volumeInFV: BigInt!
  lendingMarket: LendingMarket!
}

TakerVolumeByIntervalAndCurrency

Records taker volume by interval and currency.

type TakerVolumeByIntervalAndCurrency @entity {
  id: ID! # Composite ID, e.g., "user-currency-interval-createdAt"
  takerVolumesByCurrency: TakerVolumeByCurrency!
  currency: Bytes!
  interval: BigInt!
  createdAt: BigInt! # The start time of the interval
  volume: BigInt! # Total transaction volume for the interval
  updatedAt: BigInt! # Timestamp when the record was last updated
}

Examples

Interactive Documentation

You can interact with the Fixed-Rate Lending Subgraph directly through GraphQL using The Graph's Playground by visiting the subgraph endpoints listed above.

FAQ

How do I query all active orders for a specific market?

Use the orders entity with filters:

{
  orders(
    where: {
      lendingMarket: "0x123...",
      status_in: [Open, PartiallyFilled]
    }
  ) {
    id
    user { id }
    side
    inputAmount
    inputUnitPrice
    status
  }
}

How can I monitor new lending markets?

Subscribe to lending market events:

subscription {
  lendingMarket(orderBy: maturity, orderDirection: desc) {
    id
    currency
    maturity
    isActive
    lastLendUnitPrice
    lastBorrowUnitPrice
  }
}

How do I calculate APR from unit prices?

The unit price in the Fixed-Rate Lending protocol represents a percentage of par value. To convert to APR:

APR=(10000unitPrice−1)×365daysToMaturity×100%APR = \left(\frac{10000}{unitPrice} - 1\right) \times \frac{365}{daysToMaturity} \times 100\%APR=(unitPrice10000​−1)×daysToMaturity365​×100%

Related Resources

See the page for sample queries to get started.

For interactive API documentation embedded directly in this documentation, please refer to the page.

🔌
📈
Query Examples
Fixed-Rate Lending Protocol Documentation
Fixed-Rate Lending SDK Documentation
GitHub Repository
https://api.studio.thegraph.com/query/64582/sf-prd-mainnet/version/latest
https://api.studio.thegraph.com/query/64582/sf-prd-sepolia/version/latest
https://api.studio.thegraph.com/query/64582/sf-prd-arbitrum-one/version/latest
https://api.studio.thegraph.com/query/64582/sf-prd-arbitrum-sepolia/version/latest
API Reference
API Reference