Winning submission for The Graph + CoinList online hackathon.
View your Long and Short positions on the dYdX protocol, and view basic Market information.
The following entities are available as a part of the subgraph:
id- Unique ID for a markettokenAddress- Contract address for the market tokentokenSymbol- Symbol for the market tokenborrowIndex- Amount of borrow interest accruedsupplyIndex- Amount of supply interest accruedlastIndexUpdate- Time of last index update
id- Unique ID for a positionaccountOwner- Position owner's addressaccountNumber- Position account numbertakerMarketId- ID of the taker marketmakerMarketId- ID of the maker marketmarket- String representation of position marketexchangeWrapper- Contract address for the dYdX exchange wrappertimestamp- Time the position was openedamount- Current position amountmarginDeposit- Initial deposit amountleverage- Initial leverageexpires- Time the position expiresopenPrice- Price the position opened atstatus- Can be "Open", "Closed" or "Liquidated"
Here are some example queries:
{
markets {
id
tokenAddress
tokenSymbol
}
}
{
longs(where: { accountOwner: "..." }) {
id
market
timestamp
amount
marginDeposit
leverage
expires
openPrice
status
}
}
{
shorts(where: { accountOwner: "...", status: "Closed" }) {
id
market
timestamp
amount
marginDeposit
leverage
expires
openPrice
}
}
{
longs(where: { expires: "...", status: "Open" }) {
id
market
timestamp
amount
marginDeposit
leverage
expires
openPrice
}
}