chore: update account, fills and orders subscriptions in data providers

This commit is contained in:
Bartłomiej Głownia 2022-09-13 13:03:57 +02:00
parent a08f63c7d8
commit 434df13079
9 changed files with 191 additions and 291 deletions

View File

@ -20,13 +20,30 @@ query Accounts($partyId: ID!) {
party(id: $partyId) { party(id: $partyId) {
id id
accounts { accounts {
...AccountFields type
balance
market {
id
tradableInstrument {
instrument {
name
}
}
}
asset {
id
symbol
decimals
}
} }
} }
} }
subscription AccountEvents($partyId: ID!) { subscription AccountEvents($partyId: ID!) {
accounts(partyId: $partyId) { accounts(partyId: $partyId) {
...AccountFields type
balance
assetId
marketId
} }
} }

View File

@ -1,4 +1,4 @@
import { Schema as Types } from '@vegaprotocol/types'; import * as Types from '@vegaprotocol/types';
import { gql } from '@apollo/client'; import { gql } from '@apollo/client';
import * as Apollo from '@apollo/client'; import * as Apollo from '@apollo/client';
@ -17,7 +17,7 @@ export type AccountEventsSubscriptionVariables = Types.Exact<{
}>; }>;
export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: { __typename?: 'Account', type: Types.AccountType, balance: string, market?: { __typename?: 'Market', id: string, tradableInstrument: { __typename?: 'TradableInstrument', instrument: { __typename?: 'Instrument', name: string } } } | null, asset: { __typename?: 'Asset', id: string, symbol: string, decimals: number } } }; export type AccountEventsSubscription = { __typename?: 'Subscription', accounts: Array<{ __typename?: 'AccountUpdate', type: Types.AccountType, balance: string, assetId: string, marketId?: string | null }> };
export const AccountFieldsFragmentDoc = gql` export const AccountFieldsFragmentDoc = gql`
fragment AccountFields on Account { fragment AccountFields on Account {
@ -43,11 +43,25 @@ export const AccountsDocument = gql`
party(id: $partyId) { party(id: $partyId) {
id id
accounts { accounts {
...AccountFields type
balance
market {
id
tradableInstrument {
instrument {
name
}
}
}
asset {
id
symbol
decimals
}
} }
} }
} }
${AccountFieldsFragmentDoc}`; `;
/** /**
* __useAccountsQuery__ * __useAccountsQuery__
@ -79,10 +93,13 @@ export type AccountsQueryResult = Apollo.QueryResult<AccountsQuery, AccountsQuer
export const AccountEventsDocument = gql` export const AccountEventsDocument = gql`
subscription AccountEvents($partyId: ID!) { subscription AccountEvents($partyId: ID!) {
accounts(partyId: $partyId) { accounts(partyId: $partyId) {
...AccountFields type
balance
assetId
marketId
} }
} }
${AccountFieldsFragmentDoc}`; `;
/** /**
* __useAccountEventsSubscription__ * __useAccountEventsSubscription__

View File

@ -229,7 +229,7 @@ export interface Fills_party {
* Party identifier * Party identifier
*/ */
id: string; id: string;
tradesConnection: Fills_party_tradesConnection; tradesConnection: Fills_party_tradesConnection | null;
} }
export interface Fills { export interface Fills {

View File

@ -3,28 +3,12 @@
// @generated // @generated
// This file was automatically generated and should not be edited. // This file was automatically generated and should not be edited.
import { Side } from "@vegaprotocol/types"; import { Side, TradeType } from "@vegaprotocol/types";
// ==================================================== // ====================================================
// GraphQL subscription operation: FillsSub // GraphQL subscription operation: FillsSub
// ==================================================== // ====================================================
export interface FillsSub_trades_buyer {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface FillsSub_trades_seller {
__typename: "Party";
/**
* Party identifier
*/
id: string;
}
export interface FillsSub_trades_buyerFee { export interface FillsSub_trades_buyerFee {
__typename: "TradeFee"; __typename: "TradeFee";
/** /**
@ -57,112 +41,16 @@ export interface FillsSub_trades_sellerFee {
liquidityFee: string; liquidityFee: string;
} }
export interface FillsSub_trades_market_tradableInstrument_instrument_product_settlementAsset {
__typename: "Asset";
/**
* The ID of the asset
*/
id: string;
/**
* The symbol of the asset (e.g: GBP)
*/
symbol: string;
/**
* The precision of the asset. Should match the decimal precision of the asset on its native chain, e.g: for ERC20 assets, it is often 18
*/
decimals: number;
}
export interface FillsSub_trades_market_tradableInstrument_instrument_product {
__typename: "Future";
/**
* The name of the asset (string)
*/
settlementAsset: FillsSub_trades_market_tradableInstrument_instrument_product_settlementAsset;
}
export interface FillsSub_trades_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
/**
* A reference to or instance of a fully specified product, including all required product parameters for that product (Product union)
*/
product: FillsSub_trades_market_tradableInstrument_instrument_product;
}
export interface FillsSub_trades_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: FillsSub_trades_market_tradableInstrument_instrument;
}
export interface FillsSub_trades_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
* number denominated in the currency of the market. (uint64)
*
* Examples:
* Currency Balance decimalPlaces Real Balance
* GBP 100 0 GBP 100
* GBP 100 2 GBP 1.00
* GBP 100 4 GBP 0.01
* GBP 1 4 GBP 0.0001 ( 0.01p )
*
* GBX (pence) 100 0 GBP 1.00 (100p )
* GBX (pence) 100 2 GBP 0.01 ( 1p )
* GBX (pence) 100 4 GBP 0.0001 ( 0.01p )
* GBX (pence) 1 4 GBP 0.000001 ( 0.0001p)
*/
decimalPlaces: number;
/**
* positionDecimalPlaces indicates the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
* This sets how big the smallest order / position on the market can be.
*/
positionDecimalPlaces: number;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: FillsSub_trades_market_tradableInstrument;
}
export interface FillsSub_trades { export interface FillsSub_trades {
__typename: "Trade"; __typename: "TradeUpdate";
/** /**
* The hash of the trade data * The hash of the trade data
*/ */
id: string; id: string;
/** /**
* RFC3339Nano time for when the trade occurred * The market the trade occurred on
*/ */
createdAt: string; marketId: string;
/**
* The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
*/
price: string;
/**
* The number of contracts trades, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/
size: string;
/** /**
* The order that bought * The order that bought
*/ */
@ -171,18 +59,34 @@ export interface FillsSub_trades {
* The order that sold * The order that sold
*/ */
sellOrder: string; sellOrder: string;
/**
* The party that bought
*/
buyerId: string;
/**
* The party that sold
*/
sellerId: string;
/** /**
* The aggressor indicates whether this trade was related to a BUY or SELL * The aggressor indicates whether this trade was related to a BUY or SELL
*/ */
aggressor: Side; aggressor: Side;
/** /**
* The party that bought * The price of the trade (probably initially the passive order price, other determination algorithms are possible though) (uint64)
*/ */
buyer: FillsSub_trades_buyer; price: string;
/** /**
* The party that sold * The number of units traded, will always be <= the remaining size of both orders immediately before the trade (uint64)
*/ */
seller: FillsSub_trades_seller; size: string;
/**
* RFC3339Nano time for when the trade occurred
*/
createdAt: string;
/**
* The type of trade
*/
type: TradeType;
/** /**
* The fee paid by the buyer side of the trade * The fee paid by the buyer side of the trade
*/ */
@ -192,9 +96,13 @@ export interface FillsSub_trades {
*/ */
sellerFee: FillsSub_trades_sellerFee; sellerFee: FillsSub_trades_sellerFee;
/** /**
* The market the trade occurred on * The batch in which the buyer order was submitted (applies only for auction modes)
*/ */
market: FillsSub_trades_market; buyerAuctionBatch: number | null;
/**
* The batch in which the seller order was submitted (applies only for auction modes)
*/
sellerAuctionBatch: number | null;
} }
export interface FillsSub { export interface FillsSub {

View File

@ -14,64 +14,57 @@ import type {
} from './__generated__/Fills'; } from './__generated__/Fills';
import type { FillsSub } from './__generated__/FillsSub'; import type { FillsSub } from './__generated__/FillsSub';
const FILL_FRAGMENT = gql`
fragment FillFields on Trade {
id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
}
`;
export const FILLS_QUERY = gql` export const FILLS_QUERY = gql`
${FILL_FRAGMENT}
query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) { query Fills($partyId: ID!, $marketId: ID, $pagination: Pagination) {
party(id: $partyId) { party(id: $partyId) {
id id
tradesConnection(marketId: $marketId, pagination: $pagination) { tradesConnection(marketId: $marketId, pagination: $pagination) {
edges { edges {
node { node {
...FillFields id
createdAt
price
size
buyOrder
sellOrder
aggressor
buyer {
id
}
seller {
id
}
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
product {
... on Future {
settlementAsset {
id
symbol
decimals
}
}
}
}
}
}
} }
cursor cursor
} }
@ -87,10 +80,31 @@ export const FILLS_QUERY = gql`
`; `;
export const FILLS_SUB = gql` export const FILLS_SUB = gql`
${FILL_FRAGMENT}
subscription FillsSub($partyId: ID!) { subscription FillsSub($partyId: ID!) {
trades(partyId: $partyId) { trades(partyId: $partyId) {
...FillFields id
marketId
buyOrder
sellOrder
buyerId
sellerId
aggressor
price
size
createdAt
type
buyerFee {
makerFee
infrastructureFee
liquidityFee
}
sellerFee {
makerFee
infrastructureFee
liquidityFee
}
buyerAuctionBatch
sellerAuctionBatch
} }
} }
`; `;

View File

@ -9,68 +9,8 @@ import { OrderType, Side, OrderStatus, OrderRejectionReason, OrderTimeInForce }
// GraphQL subscription operation: OrderSub // GraphQL subscription operation: OrderSub
// ==================================================== // ====================================================
export interface OrderSub_orders_market_tradableInstrument_instrument {
__typename: "Instrument";
/**
* Uniquely identify an instrument across all instruments available on Vega (string)
*/
id: string;
/**
* A short non necessarily unique code used to easily describe the instrument (e.g: FX:BTCUSD/DEC18) (string)
*/
code: string;
/**
* Full and fairly descriptive name for the instrument
*/
name: string;
}
export interface OrderSub_orders_market_tradableInstrument {
__typename: "TradableInstrument";
/**
* An instance of, or reference to, a fully specified instrument.
*/
instrument: OrderSub_orders_market_tradableInstrument_instrument;
}
export interface OrderSub_orders_market {
__typename: "Market";
/**
* Market ID
*/
id: string;
/**
* decimalPlaces indicates the number of decimal places that an integer must be shifted by in order to get a correct
* number denominated in the currency of the market. (uint64)
*
* Examples:
* Currency Balance decimalPlaces Real Balance
* GBP 100 0 GBP 100
* GBP 100 2 GBP 1.00
* GBP 100 4 GBP 0.01
* GBP 1 4 GBP 0.0001 ( 0.01p )
*
* GBX (pence) 100 0 GBP 1.00 (100p )
* GBX (pence) 100 2 GBP 0.01 ( 1p )
* GBX (pence) 100 4 GBP 0.0001 ( 0.01p )
* GBX (pence) 1 4 GBP 0.000001 ( 0.0001p)
*/
decimalPlaces: number;
/**
* positionDecimalPlaces indicates the number of decimal places that an integer must be shifted in order to get a correct size (uint64).
* i.e. 0 means there are no fractional orders for the market, and order sizes are always whole sizes.
* 2 means sizes given as 10^2 * desired size, e.g. a desired size of 1.23 is represented as 123 in this market.
* This sets how big the smallest order / position on the market can be.
*/
positionDecimalPlaces: number;
/**
* An instance of, or reference to, a tradable instrument.
*/
tradableInstrument: OrderSub_orders_market_tradableInstrument;
}
export interface OrderSub_orders { export interface OrderSub_orders {
__typename: "Order"; __typename: "OrderUpdate";
/** /**
* Hash of the order data * Hash of the order data
*/ */
@ -78,9 +18,9 @@ export interface OrderSub_orders {
/** /**
* The market the order is trading on (probably stored internally as a hash of the market details) * The market the order is trading on (probably stored internally as a hash of the market details)
*/ */
market: OrderSub_orders_market; marketId: string;
/** /**
* Type the order type (defaults to PARTY) * The order type
*/ */
type: OrderType | null; type: OrderType | null;
/** /**
@ -88,7 +28,7 @@ export interface OrderSub_orders {
*/ */
side: Side; side: Side;
/** /**
* Total number of contracts that may be bought or sold (immutable) (uint64) * Total number of units that may be bought or sold (immutable) (uint64)
*/ */
size: string; size: string;
/** /**
@ -96,7 +36,7 @@ export interface OrderSub_orders {
*/ */
status: OrderStatus; status: OrderStatus;
/** /**
* Reason for the order to be rejected * Why the order was rejected
*/ */
rejectionReason: OrderRejectionReason | null; rejectionReason: OrderRejectionReason | null;
/** /**
@ -108,7 +48,7 @@ export interface OrderSub_orders {
*/ */
timeInForce: OrderTimeInForce; timeInForce: OrderTimeInForce;
/** /**
* Number of contracts remaining of the total that have not yet been bought or sold (uint64) * Number of units remaining of the total that have not yet been bought or sold (uint64)
*/ */
remaining: string; remaining: string;
/** /**

View File

@ -80,7 +80,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
market: Orders_party_ordersConnection_edges_node_market; market: Orders_party_ordersConnection_edges_node_market;
/** /**
* Type the order type (defaults to PARTY) * The order type
*/ */
type: OrderType | null; type: OrderType | null;
/** /**
@ -88,7 +88,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
side: Side; side: Side;
/** /**
* Total number of contracts that may be bought or sold (immutable) (uint64) * Total number of units that may be bought or sold (immutable) (uint64)
*/ */
size: string; size: string;
/** /**
@ -96,7 +96,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
status: OrderStatus; status: OrderStatus;
/** /**
* Reason for the order to be rejected * Why the order was rejected
*/ */
rejectionReason: OrderRejectionReason | null; rejectionReason: OrderRejectionReason | null;
/** /**
@ -108,7 +108,7 @@ export interface Orders_party_ordersConnection_edges_node {
*/ */
timeInForce: OrderTimeInForce; timeInForce: OrderTimeInForce;
/** /**
* Number of contracts remaining of the total that have not yet been bought or sold (uint64) * Number of units remaining of the total that have not yet been bought or sold (uint64)
*/ */
remaining: string; remaining: string;
/** /**
@ -160,7 +160,7 @@ export interface Orders_party {
/** /**
* Orders relating to a party * Orders relating to a party
*/ */
ordersConnection: Orders_party_ordersConnection; ordersConnection: Orders_party_ordersConnection | null;
} }
export interface Orders { export interface Orders {

View File

@ -14,44 +14,37 @@ import type {
OrderFields, OrderFields,
} from '../'; } from '../';
const ORDER_FRAGMENT = gql`
fragment OrderFields on Order {
id
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
}
}
}
type
side
size
status
rejectionReason
price
timeInForce
remaining
expiresAt
createdAt
updatedAt
}
`;
export const ORDERS_QUERY = gql` export const ORDERS_QUERY = gql`
${ORDER_FRAGMENT}
query Orders($partyId: ID!, $pagination: Pagination) { query Orders($partyId: ID!, $pagination: Pagination) {
party(id: $partyId) { party(id: $partyId) {
id id
ordersConnection(pagination: $pagination) { ordersConnection(pagination: $pagination) {
edges { edges {
node { node {
...OrderFields id
market {
id
decimalPlaces
positionDecimalPlaces
tradableInstrument {
instrument {
id
code
name
}
}
}
type
side
size
status
rejectionReason
price
timeInForce
remaining
expiresAt
createdAt
updatedAt
} }
cursor cursor
} }
@ -67,10 +60,21 @@ export const ORDERS_QUERY = gql`
`; `;
export const ORDERS_SUB = gql` export const ORDERS_SUB = gql`
${ORDER_FRAGMENT}
subscription OrderSub($partyId: ID!) { subscription OrderSub($partyId: ID!) {
orders(partyId: $partyId) { orders(partyId: $partyId) {
...OrderFields id
marketId
type
side
size
status
rejectionReason
price
timeInForce
remaining
expiresAt
createdAt
updatedAt
} }
} }
`; `;

View File

@ -68,7 +68,7 @@ export interface OrderEvent_busEvents_event_Order_market {
export interface OrderEvent_busEvents_event_Order { export interface OrderEvent_busEvents_event_Order {
__typename: "Order"; __typename: "Order";
/** /**
* Type the order type (defaults to PARTY) * The order type
*/ */
type: OrderType | null; type: OrderType | null;
/** /**
@ -80,7 +80,7 @@ export interface OrderEvent_busEvents_event_Order {
*/ */
status: OrderStatus; status: OrderStatus;
/** /**
* Reason for the order to be rejected * Why the order was rejected
*/ */
rejectionReason: OrderRejectionReason | null; rejectionReason: OrderRejectionReason | null;
/** /**
@ -88,7 +88,7 @@ export interface OrderEvent_busEvents_event_Order {
*/ */
createdAt: string; createdAt: string;
/** /**
* Total number of contracts that may be bought or sold (immutable) (uint64) * Total number of units that may be bought or sold (immutable) (uint64)
*/ */
size: string; size: string;
/** /**