Euler Finance
  • Welcome
  • Getting Started
    • Introduction
    • White Paper
    • Quick Links
  • App
    • Getting Started
      • Common Errors
    • How To
      • Connect a Wallet
      • Deposit
      • Withdraw
      • Borrow
      • Repay
      • Mint
      • Burn
      • Sub-Accounts
      • Transfer
      • Swap
      • Short/Long
      • Protected Collateral
      • Transaction Builder
      • Wrap
      • Activate
      • Allowances
      • Retrieve Browser Errors
      • Lending and Borrowing
    • FAQ
  • Euler Protocol
    • Getting Started
      • Risk Methodology
        • Asset Tiers
        • Collateral and Borrow Factor
        • Ranking Assets
        • Oracle Rating
      • Simulation Environment
    • Addresses
    • Parameters
      • Interest Rates
      • Risk Factors
  • Euler Governance
    • Getting Started
      • Phases
    • How To
      • Delegate Voting Power
      • Write a Proposal
      • Create a Tally (On-Chain) Proposal
        • Create a Snapshot (Off-Chain) Proposal
      • Vote on Tally (On-Chain)
      • Vote on Snapshot (Off-Chain)
      • Join the Forum
    • Treasury
    • Grants
    • Addresses
    • Parameters
  • EUL
    • About
    • Distribution
    • Epochs
    • Gauges
    • Staking
  • Developers
    • Getting Started
      • Contract Integration Guide
      • Contract Reference
      • Architecture
    • Proxy Protocol
    • Numeric Limits
    • SDK
    • Subgraph
  • Security
    • Audits
    • Bug Bounty
    • Insurance
  • Languages
    • White Paper (ENG-CHN)
    • Community Translations
  • Legal
    • Terms and Conditions
    • Privacy Policy
Powered by GitBook
On this page
  • Links
  • Mainnet
  • About
  • Entities
  • Asset
  • Account
  • TopLevelAccount
  • EulerMarketStore
  • EulerOverview
  • Liquidation
  • Governance
  • Hourly/Daily/MonthlyAssetSnapshot
  • Hourly/Daily/MonthlyAssetStatus
  • Hourly/Daily/MonthlyRepay
  • Hourly/Daily/MonthlyDeposit
  • Hourly/Daily/MonthlyWithdraw
  • Hourly/Daily/MonthlyBorrow
  • Querying time based aggregates
  • Examples
  • Fetch the 5 biggest markets by total borrowed in USD
  • Fetch historical interest rate, supply and borrow balances of a given market
  • Get the current balances of an account
  • Get the transaction history of an account
  • Get USD amount borrowed on February 10th 2022
  • Last 30 days of deposit amounts
  • All transactions between February 1st 2022 and February 3rd 2022
  • Querying time based aggregates
  • Examples
  • Fetch the 5 biggest markets by total borrowed in USD
  • Get the current balances of an account
  • Get the transaction history of an account
  • Get USD amount borrowed on February 10th 2022
  • Last 30 days of deposit amounts
  • All transactions between February 1st 2022 and February 3rd 2022

Was this helpful?

Export as PDF
  1. Developers

Subgraph

Subgraph

PreviousSDKNextAudits

Last updated 2 years ago

Was this helpful?

Links

  • Querying the subgraph: https://thegraph.com/docs/en/developer/query-the-graph/

Mainnet

  • The Graph: https://thegraph.com/hosted-service/subgraph/euler-xyz/euler-mainnet

  • API: https://api.thegraph.com/subgraphs/name/euler-xyz/euler-mainnet

About

  • All amounts have a fixed decimal precision of 1e18.

  • Are timestamps are represented as .

  • USD and ETH exchange rates of all assets are pulled through Euler directly

  • All ratios have a fixed decimal precision of 1e27.

Entities

Asset

Contains information about all Euler markets, pulled from EulerGeneralView contract.

type Asset @entity {
  "asset_address"
  id: ID!
  "Block hash at which asset was created"
  blockHash: Bytes!
  "Block number at which asset was created"
  blockNumber: Int!
  "Timestamp at which asset was created"
  timestamp: Int!
  "Block hash at which asset was last updated"
  updatedBlockHash: Bytes!
  "Block number at which asset was last updated"
  updatedBlockNumber: Int!
  "Timestamp at which asset was last updated"
  updatedTimestamp: Int!
  "Tx hash at which asset was created"
  transactionHash: Bytes!
  "Tx origin at which asset was created"
  transactionOrigin: Bytes!
  dTokenAddress: Bytes!
  eTokenAddress: Bytes!
  pTokenAddress: Bytes!
  symbol: String!
  name: String!
  decimals: BigInt!
  totalSupply: BigInt!
  totalBalances: BigInt!
  totalBalancesUsd: BigInt!
  totalBalancesEth: BigInt!
  totalBorrows: BigInt!
  totalBorrowsUsd: BigInt!
  totalBorrowsEth: BigInt!
  reserveBalance: BigInt!
  reserveBalanceEth: BigInt!
  reserveBalanceUsd: BigInt!
  reserveFee: BigInt!
  borrowAPY: BigInt!
  supplyAPY: BigInt!
  twap: BigInt!
  twapUsd: BigDecimal!
  "Deprecated in favor of twapUsd. Do not use."
  twapPrice: BigDecimal!
  twapPeriod: BigInt!
  currPrice: BigInt!
  currPriceUsd: BigInt!
  pricingType: Int!
  pricingParameters: BigInt!
  pricingForwarded: Bytes!
  collateralValue: BigInt!
  liabilityValue: BigInt!
  numBorrows: BigInt!
  borrowIsolated: Boolean!
  poolSize: BigInt!
  interestRate: BigInt!
  interestAccumulator: BigInt!
  config: AssetConfig
}

Sometimes, gouvernance will manually set asset configuration, it is displayed in the AssetConfig entity. If an asset has a null AssetConfig, it is safe to assume that it was never explicitly set and is isolated.

borrowFactor and collateralFactor can be transformed in a decimal fraction by dividing by 4e9.

type AssetConfig @entity {
  "asset_address"
  id: ID!
  twapWindowInSeconds: Int!
  borrowFactor: BigInt!
  borrowIsolated: Boolean!
  collateralFactor: BigInt!
  tier: String!
}

Account

Account that transacts on Euler. Could be a sub-account or a main account.

type Account @entity {
  "account_address"
  id: ID!
  createdTimestamp: Int!
  topLevelAccount: TopLevelAccount!
  balances: [Balance!]
  balanceChanges: [BalanceChange!]
  balanceChangesCount: Int!
}

A Balance represents the current amount of each assets held by an account.

type Balance @entity {
  "account_address:underlying"
  id: ID!
  account: Account!
  amount: BigInt!
  asset: Asset!
}

A BalanceChange is a transaction within the platform. type can be one of the following values:

  • borrow

  • deposit

  • withdraw

  • repay

type BalanceChange @entity {
  "transaction_hash:event_log_index"
  id: ID!
  transactionHash: Bytes!
  type: String!
  account: Account!
  topLevelAccount: TopLevelAccount!
  amount: BigInt!
  amountUsd: BigDecimal!
  timestamp: Int!
  asset: Asset!

TopLevelAccount

Aggregate of the sub-accounts associated with a wallet. TopLevelAccount id corresponds to main sub-account id.

type TopLevelAccount @entity {
  "account_address"
  id: ID!
  createdTimestamp: Int!
  accounts: [Account!]
  balances: [TopLevelAccountBalance!]
  balanceChanges: [BalanceChange!]
  balanceChangesCount: Int!
}
type TopLevelAccountBalance @entity {
  "top_level_account_address:underlying"
  id: ID!
  topLevelAccount: TopLevelAccount!
  amount: BigInt!
  asset: Asset!
}

EulerMarketStore

Contains list of all active markets on Euler.

type EulerMarketStore @entity {
  id: ID!
  markets: [Asset!]
}

EulerOverview

Aggregated metrics for all markets as a whole.

type EulerOverview @entity {
  id: ID!
  reserveBalanceUsd: BigInt!
  reserveBalanceEth: BigInt!
  totalBalancesUsd: BigInt!
  totalBalancesEth: BigInt!
  totalBorrowsUsd: BigInt!
  totalBorrowsEth: BigInt!
}

Liquidation

Contains all liquidation transactions.

liquidator and violator fields correspond to account addresses.

type Liquidation @entity {
  "transaction_hash:event_log_index"
  id: ID!
  timestamp: Int!
  transactionHash: Bytes!
  liquidator: Bytes!
  violator: Bytes!
  asset: Asset!
  collateralAsset: Asset!
  repay: BigInt!
  repayUsd: BigDecimal!
  harvest: BigInt!
  yieldUsd: BigDecimal!
  healthScore: BigInt!
  discount: BigInt!
  baseDiscount: BigInt!
}

Governance

GovConvertReserve and GovSetReserveFee contain all on-chain information about governance.

type GovConvertReserve @entity {
  "transaction_hash:event_log_index"
  id: ID!
  timestamp: Int!
  blockNumber: Int!
  transactionHash: Bytes!
  amount: BigInt!
  amountUsd: BigDecimal!
  asset: Asset!
  recipient: Bytes!
}
type GovSetReserveFee @entity {
  "transaction_hash:event_log_index"
  id: ID!
  timestamp: Int!
  blockNumber: Int!
  transactionHash: Bytes!
  reserveFee: Int!
  asset: Asset!
}

Hourly/Daily/MonthlyAssetSnapshot

Snapshot of Asset entity at the end of every hour, day and month.

Useful for querying historical data on markets.

type HourlyAssetSnapshot @entity {
  "start_of_hour_timestamp:asset_address"
  id: ID!
  asset: Asset!
  "Block number at which snapshot was created"
  blockHash: Bytes!
  "Block hash at which snapshot was created"
  blockNumber: Int!
  "Timestamp at which snapshot was created"
  timestamp: Int!
  "Tx hash at which asset was created"
  transactionHash: Bytes!
  "Tx origin at which asset was created"
  transactionOrigin: Bytes!
  totalSupply: BigInt!
  totalBalances: BigInt!
  totalBalancesUsd: BigInt!
  totalBalancesEth: BigInt!
  totalBorrows: BigInt!
  totalBorrowsUsd: BigInt!
  totalBorrowsEth: BigInt!
  reserveBalance: BigInt!
  reserveBalanceEth: BigInt!
  reserveBalanceUsd: BigInt!
  reserveFee: BigInt!
  borrowAPY: BigInt!
  supplyAPY: BigInt!
  twap: BigInt!
  twapUsd: BigDecimal!
  twapPeriod: BigInt!
  currPrice: BigInt!
  currPriceUsd: BigInt!
  pricingType: Int!
  pricingParameters: BigInt!
  pricingForwarded: Bytes!
  collateralValue: BigInt!
  liabilityValue: BigInt!
  numBorrows: BigInt!
  borrowIsolated: Boolean!
  poolSize: BigInt!
  interestAccumulator: BigInt!
  interestRate: BigInt!
}

Hourly/Daily/MonthlyAssetStatus

This entity has been deprecated in favor of Hourly/Daily/MonthlyAssetSnapshot

Aggregated metrics of a specific market over hourly, daily and monthly time period.

type HourlyAssetStatus @entity {
  "start_of_hour_timestamp:asset_address"
  id: ID!
  timestamp: Int!
  totalBalances: BigInt!
  totalBorrows: BigInt!
  reserveBalance: BigInt!
  poolSize: BigInt!
  interestAccumulator: BigInt!
  interestRate: BigInt!
  twapPrice: BigDecimal!
  twapUsd: BigDecimal!
  asset: Asset!
}

Hourly/Daily/MonthlyRepay

Aggregated metrics for repay transactions over hourly, daily and monthly time period.

type HourlyRepay @entity {
  "start_of_hour_timestamp"
  id: ID!
  timestamp: Int!
  count: Int!
  totalAmount: BigInt!
  totalUsdAmount: BigDecimal!
}

Hourly/Daily/MonthlyDeposit

Aggregated metrics for deposits over hourly, daily and monthly time period.

type HourlyDeposit @entity {
  "start_of_hour_timestamp"
  id: ID!
  timestamp: Int!
  count: Int!
  totalAmount: BigInt!
  totalUsdAmount: BigDecimal!
}

Hourly/Daily/MonthlyWithdraw

Aggregated metrics for withdrawals over hourly, daily and monthly time period.

type HourlyWithdraw @entity {
  "start_of_hour_timestamp"
  id: ID!
  timestamp: Int!
  count: Int!
  totalAmount: BigInt!
  totalUsdAmount: BigDecimal!
}

Hourly/Daily/MonthlyBorrow

Aggregated for borrow transactions over hourly, daily and monthly time period.

type HourlyBorrow @entity {
  "start_of_hour_timestamp"
  id: ID!
  timestamp: Int!
  count: Int!
  totalAmount: BigInt!
  totalUsdAmount: BigDecimal!
}

Querying time based aggregates

Every entity that has hourly, daily or monthly in its name can be queried by its ID. The documentation for those is located within each entity. Below lies the rules used to create the required timestamps.

Parameter
Value

start_of_hour_timestamp

unix timestamp at minute 0

start_of_day_timestamp

unix timestamp at hour 0, minute 0

start_of_month_timestamp

unix timestamp at first day of the month, hour 0, minute 0

Examples

Fetch the 5 biggest markets by total borrowed in USD

{
  assets(first: 5, orderBy: totalBorrowsUsd, orderDirection: desc) {
    symbol
    totalBorrows
    totalBorrowsUsd
    currPriceUsd
  }
}

Fetch historical interest rate, supply and borrow balances of a given market

{
  hourlyAssetSnapshots(where: {asset: "0x03ab458634910aad20ef5f1c8ee96f1d6ac54919"}, orderBy: timestamp, orderDirection: desc, first: 1000) {
    id
    supplyAPY
    borrowAPY
    totalBorrowsUsd
    totalBalancesUsd
  }
}

Get the current balances of an account

{
  account(id: "0x0000000002732779240fe05873611dc4203dfb71") {
    balances {
      amount
      asset {
        symbol
      }
    }
  }
}

Get the transaction history of an account

{
  account(id: "0x0000000002732779240fe05873611dc4203dfb71") {
    balanceChanges {
      type
      timestamp
      amount
      amountUsd
      asset {
        symbol
      }
    }
  }
}

Get USD amount borrowed on February 10th 2022

{
  dailyBorrow(id: "1644451200") {
  	count
    totalUsdAmount
  }
}

Last 30 days of deposit amounts

{
  dailyDeposits(first: 30, orderBy: timestamp, orderDirection: desc) {
    id
    timestamp
    totalUsdAmount
  }
}

All transactions between February 1st 2022 and February 3rd 2022

{
  balanceChanges(orderBy: timestamp, orderDirection: asc, where: {timestamp_gte: 1643673600, timestamp_lte: 1643932799}) {
    timestamp
    type
    amount
    amountUsd
  	account {
      id
    }
    asset {
      symbol
    }
  }
}

Querying time based aggregates

Every entity that has hourly, daily or monthly in its name can be queried by its ID. The documentation for those is located within each entity. Below lies the rules used to create the required timestamps.

Parameter
Value

start_of_hour_timestamp

unix timestamp at minute 0

start_of_day_timestamp

unix timestamp at hour 0, minute 0

start_of_month_timestamp

unix timestamp at first day of the month, hour 0, minute 0

Examples

Fetch the 5 biggest markets by total borrowed in USD

{
  assets(first: 5, orderBy: totalBorrowsUsd, orderDirection: desc) {
    symbol
    totalBorrows
    totalBorrowsUsd
    currPriceUsd
  }
}

Get the current balances of an account

{
  account(id: "0x0000000002732779240fe05873611dc4203dfb71") {
    balances {
      amount
      asset {
        symbol
      }
    }
  }
}

Get the transaction history of an account

{
  account(id: "0x0000000002732779240fe05873611dc4203dfb71") {
    balanceChanges {
      type
      timestamp
      amount
      amountUsd
      asset {
        symbol
      }
    }
  }
}

Get USD amount borrowed on February 10th 2022

{
  dailyBorrow(id: "1644451200") {
  	count
    totalUsdAmount
  }
}

Last 30 days of deposit amounts

{
  dailyDeposits(first: 30, orderBy: timestamp, orderDirection: desc) {
    id
    timestamp
    totalUsdAmount
  }
}

All transactions between February 1st 2022 and February 3rd 2022

{
  balanceChanges(orderBy: timestamp, orderDirection: asc, where: {timestamp_gte: 1643673600, timestamp_lte: 1643932799}) {
    timestamp
    type
    amount
    amountUsd
  	account {
      id
    }
    asset {
      symbol
    }
  }
}

For further tier information, refer to .

First we need to create our ID using the parameters define in the section. In this case, February 10th 2020 = 1644451200.

First we need to create our ID using the parameters define in the section. In this case, February 10th 2020 = 1644451200.

unix timestamps
Tier Methodology
Querying time based aggregates
Querying time based aggregates