fragment FillFields on Trade {
  id
  market {
    id
  }
  createdAt
  price
  size
  buyOrder
  sellOrder
  aggressor
  buyer {
    id
  }
  seller {
    id
  }
  buyerFee {
    makerFee
    infrastructureFee
    liquidityFee
  }
  sellerFee {
    makerFee
    infrastructureFee
    liquidityFee
  }
}

fragment FillEdge on TradeEdge {
  node {
    ...FillFields
  }
  cursor
}

query Fills($filter: TradesFilter, $pagination: Pagination) {
  trades(filter: $filter, pagination: $pagination) {
    edges {
      ...FillEdge
    }
    pageInfo {
      startCursor
      endCursor
      hasNextPage
      hasPreviousPage
    }
  }
}

fragment FillUpdateFields on TradeUpdate {
  id
  marketId
  buyOrder
  sellOrder
  buyerId
  sellerId
  aggressor
  price
  size
  createdAt
  type
  buyerFee {
    makerFee
    infrastructureFee
    liquidityFee
  }
  sellerFee {
    makerFee
    infrastructureFee
    liquidityFee
  }
}

subscription FillsEvent($filter: TradesSubscriptionFilter!) {
  tradesStream(filter: $filter) {
    ...FillUpdateFields
  }
}
