Skip to content
Winning submission for The Graph+CoinList online hackathon
TypeScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
abis
build Getting ready for tuple support to beef up market entities Jun 15, 2019
generated
src
.gitignore
README.md
package.json
schema.graphql Getting ready for tuple function support Jun 2, 2019
subgraph.yaml
yarn.lock Getting ready for tuple support to beef up market entities Jun 15, 2019

README.md

dydx-subgraph

Winning submission for The Graph + CoinList online hackathon.

Overview

View your Long and Short positions on the dYdX protocol, and view basic Market information.

Entities

The following entities are available as a part of the subgraph:

Market

  • id - Unique ID for a market
  • tokenAddress - Contract address for the market token
  • tokenSymbol - Symbol for the market token
  • borrowIndex - Amount of borrow interest accrued
  • supplyIndex - Amount of supply interest accrued
  • lastIndexUpdate - Time of last index update

Long & Short

  • id - Unique ID for a position
  • accountOwner - Position owner's address
  • accountNumber - Position account number
  • takerMarketId - ID of the taker market
  • makerMarketId - ID of the maker market
  • market - String representation of position market
  • exchangeWrapper - Contract address for the dYdX exchange wrapper
  • timestamp - Time the position was opened
  • amount - Current position amount
  • marginDeposit - Initial deposit amount
  • leverage - Initial leverage
  • expires - Time the position expires
  • openPrice - Price the position opened at
  • status - Can be "Open", "Closed" or "Liquidated"

Queries

Here are some example queries:

Display all markets

{
  markets {
    id
    tokenAddress
    tokenSymbol
  }
}

Display long positions for given account

{
  longs(where: { accountOwner: "..." }) {
    id
    market
    timestamp
    amount
    marginDeposit
    leverage
    expires
    openPrice
    status
  }
}

Display closed short positions for given account

{
  shorts(where: { accountOwner: "...", status: "Closed" }) {
    id
    market
    timestamp
    amount
    marginDeposit
    leverage
    expires
    openPrice
  }
}

Display open long positions which expire on a given day

{
  longs(where: { expires: "...", status: "Open" }) {
    id
    market
    timestamp
    amount
    marginDeposit
    leverage
    expires
    openPrice
  }
}
You can’t perform that action at this time.