Skip to content

Instantly share code, notes, and snippets.

@wnz99
Last active April 12, 2022 08:30
Show Gist options
  • Save wnz99/888977c7bd954c5377be9f1eca6b6eab to your computer and use it in GitHub Desktop.
Save wnz99/888977c7bd954c5377be9f1eca6b6eab to your computer and use it in GitHub Desktop.
Graphql queries for trade service

Trading

Market are define as a pair of assets such as ETH-GBP. ETH is the base asset, while GBP is the quote asset.

Prices are expressed in quote asset values.

Price quotation:

  enum Markets {
    ETH_GBP
  }

  type PriceQuote {
    price: String!
    quoteId: String!
    fee: Float
    expiration: Int!
  }

  type Query {
    priceQuote(market: Markets!): PriceQuote!
  }

Where $market equal to ETH-GBP

Orders

  enum OrderStatus {
    OK
  }

  enum OrderSide {
    BUY
    SELL
  }

Exchange GBP for ETH:

  type Mutation {
    createOrder(order: CreateOrderInput!): OrderStatus!
  }

Where OrderInput equals to:

  input CreateOrderInput {
    market: Markets!
    price: Float!
    priceQuoteId: String
    side: OrderSide!
    quoteAmount: String # Amount in GBP
  }

Exchange ETH for GBP:

  type Mutation {
    createOrder(order: CreateOrderInput!): OrderStatus!
  }

Where OrderInput equal:

input CreateOrderInput {
  market: Markets!
  price: String
  priceQuoteId: String
  side: OrderSide!
  baseAmount: String # Amount in ETH
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment