Querying SILO

You can build your own queries using a GraphQL Explorer and enter your endpoint to limit the data to exactly what you need.

Each entity has a plural version and a singular version. When querying for a single record response (e.g. account), you will need to supply the id for the entity. When querying for a list of responses (e.g. accounts), you may add filters using the 'where' clause.

Below are some sample queries you can use to gather information from the SILO contracts.

Main Market

fragment rates on Market {
  rates {
    side
    rate
    token {
      id
    }
  }
}

query Markets {
  lendingProtocols(block: { number: 18642057 }) {
    totalValueLockedUSD
  }
  markets(
    first: 5
    orderBy: totalValueLockedUSD
    orderDirection: desc
    where: { inputToken_: { activeOracle_not: "null" } }
    block: { number: 18642057 }
  ) {
    id
    name
    isActive
    archived
    marketAssets {
      asset {
        id
        symbol
        name
        decimals
        lastPriceUSD
      }
      balance
    }
    inputToken {
      id
    }
    outputToken {
      id
    }
    ...rates
  }
}

Basic Market

query BasicMarkets {
  silos(first: 5) {
    id
    archived
    baseAsset {
      id
    }
    bridgeAsset {
      id
    }
    market {
      inputToken {
        id
        name
        symbol
        decimals
      }
      sToken {
        id
      }
      spToken {
        id
      }
      dToken {
        id
      }
    }
  }
}

Most at risk of liquidation - V3 ONLY

fragment positionFields on Position {
  marketAsset: market {
    inputToken {
      id
    }
  }
  snapshots(first: 1, orderBy: blockNumber, orderDirection: desc) {
    blockNumber
    hash
  }
}

query QueryPositions {
  siloPositions(
    first: 5
    skip: 0
    where: { dTokenBalance_gt: 0, silo_: { id_not_in: [""] } }
    orderBy: riskFactor
    orderDirection: desc
    block: { number_gte: 19112526 }
  ) {
    id
    account {
      id
    }
    silo {
      id
      baseAsset {
        id
      }
      bridgeAsset {
        id
      }
      marketAssets: market {
        inputToken {
          id
          symbol
          decimals
          lastPriceUSD
        }
        liquidationThreshold
      }
    }
    totalCollateralValue
    totalBorrowValue
    riskFactor
    riskScore
    collateralPositions: positions(where: { sTokenBalance_gt: 0 }) {
      sTokenBalance
      sToken {
        derivativeConversion
      }
      ...positionFields
    }
    collateralOnlyPositions: positions(where: { spTokenBalance_gt: 0 }) {
      spTokenBalance
      ...positionFields
    }
    debtPositions: positions(where: { dTokenBalance_gt: 0 }) {
      dTokenBalance
      dToken {
        derivativeConversion
      }
      ...positionFields
    }
  }
}

Interest rate example, can also be applied to InterestRateHourly

{
  market(id: "0xa8897b4552c075e884bdb8e7b704eb10db29bf0d") {
    id
    name
    rates {
      side
      token {
        id
        symbol
      }
      interestRateDaily(first: 10, orderBy: day, orderDirection: desc) {
        day
        timestamp
        rateHigh
        rateLow
        rateAvg
        rateLast
      }
    }
  }
}

Activity feed for a market

query ActivityFeedBySilo(
  $Market: String = "0xac3333401e69574d433307b31f43a7826eb6f8fd"
) {
  events(
    first: 10
    orderBy: blockNumber
    orderDirection: desc
    where: { silo: $Market }
  ) {
    timestamp
    hash
    logIndex
    blockNumber
    id
    silo {
      id
    }
    asset {
      id
      symbol
    }
    amount
    amountUSD
    account {
      id
    }
    ... on Borrow {
      __typename
    }
    ... on Deposit {
      __typename
    }
    ... on Liquidate {
      __typename
    }
    ... on Repay {
      __typename
    }
    ... on Withdraw {
      __typename
    }
  }
}

Week of metrics for a market

query GetSiloMetricsWeek($silo: String = "CRV") {
  markets(where: { name: $silo }) {
    name
    dailySnapshots(orderBy: blockNumber, orderDirection: desc, first: 7) {
      dailyBorrowUSD
      dailyDepositUSD
      dailyLiquidateUSD
      dailyRepayUSD
      dailyWithdrawUSD
      timestamp
      totalBorrowBalanceUSD
      totalDepositBalanceUSD
      totalValueLockedUSD
    }
  }
}

Account based position info

query QueryAccountPositions(
  $account: String = "0xc255e0a1be0a4b7b8bf5ebe8d0aba162cf75bae2"
) {
  positions(orderDirection: desc, where: { account: $account }) {
    account {
      id
    }
    depositCount
    balance
    blockNumberClosed
    blockNumberOpened
    borrowCount
    isCollateral
    liquidationCount
    repayCount
    side
    timestampClosed
    timestampOpened
    withdrawCount
  }
}

Last updated