2022-06-30 07:52:25 +00:00
|
|
|
import merge from 'lodash/merge';
|
|
|
|
import type { PartialDeep } from 'type-fest';
|
|
|
|
import type {
|
|
|
|
Fills,
|
2022-07-15 10:12:20 +00:00
|
|
|
Fills_party_tradesConnection_edges_node,
|
2022-06-30 07:52:25 +00:00
|
|
|
} from './__generated__/Fills';
|
2022-07-15 10:12:20 +00:00
|
|
|
import { Side } from '@vegaprotocol/types';
|
2022-06-30 07:52:25 +00:00
|
|
|
|
|
|
|
export const generateFills = (override?: PartialDeep<Fills>): Fills => {
|
2022-07-15 10:12:20 +00:00
|
|
|
const fills: Fills_party_tradesConnection_edges_node[] = [
|
2022-06-30 07:52:25 +00:00
|
|
|
generateFill({
|
|
|
|
buyer: {
|
|
|
|
id: 'party-id',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
generateFill({
|
|
|
|
id: '1',
|
|
|
|
seller: {
|
|
|
|
id: 'party-id',
|
|
|
|
},
|
2022-08-22 22:50:13 +00:00
|
|
|
aggressor: Side.SIDE_SELL,
|
2022-06-30 07:52:25 +00:00
|
|
|
buyerFee: {
|
|
|
|
infrastructureFee: '5000',
|
|
|
|
},
|
|
|
|
market: {
|
|
|
|
name: 'Apples Daily v3',
|
|
|
|
positionDecimalPlaces: 2,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
generateFill({
|
|
|
|
id: '2',
|
|
|
|
seller: {
|
|
|
|
id: 'party-id',
|
|
|
|
},
|
2022-08-22 22:50:13 +00:00
|
|
|
aggressor: Side.SIDE_BUY,
|
2022-06-30 07:52:25 +00:00
|
|
|
}),
|
|
|
|
generateFill({
|
|
|
|
id: '3',
|
2022-08-22 22:50:13 +00:00
|
|
|
aggressor: Side.SIDE_SELL,
|
2022-06-30 07:52:25 +00:00
|
|
|
market: {
|
|
|
|
name: 'ETHBTC Quarterly (30 Jun 2022)',
|
|
|
|
},
|
|
|
|
buyer: {
|
|
|
|
id: 'party-id',
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
];
|
|
|
|
|
|
|
|
const defaultResult: Fills = {
|
|
|
|
party: {
|
|
|
|
id: 'buyer-id',
|
2022-07-15 10:12:20 +00:00
|
|
|
tradesConnection: {
|
2022-06-30 07:52:25 +00:00
|
|
|
__typename: 'TradeConnection',
|
|
|
|
edges: fills.map((f) => {
|
|
|
|
return {
|
|
|
|
__typename: 'TradeEdge',
|
|
|
|
node: f,
|
|
|
|
cursor: '3',
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
pageInfo: {
|
|
|
|
__typename: 'PageInfo',
|
|
|
|
startCursor: '1',
|
|
|
|
endCursor: '2',
|
2022-07-20 09:37:28 +00:00
|
|
|
hasNextPage: false,
|
|
|
|
hasPreviousPage: false,
|
2022-06-30 07:52:25 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
__typename: 'Party',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return merge(defaultResult, override);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const generateFill = (
|
2022-07-15 10:12:20 +00:00
|
|
|
override?: PartialDeep<Fills_party_tradesConnection_edges_node>
|
2022-06-30 07:52:25 +00:00
|
|
|
) => {
|
2022-07-15 10:12:20 +00:00
|
|
|
const defaultFill: Fills_party_tradesConnection_edges_node = {
|
2022-06-30 07:52:25 +00:00
|
|
|
__typename: 'Trade',
|
|
|
|
id: '0',
|
2022-07-20 09:37:28 +00:00
|
|
|
createdAt: '2005-04-02T19:37:00.000Z',
|
2022-06-30 07:52:25 +00:00
|
|
|
price: '10000000',
|
|
|
|
size: '50000',
|
|
|
|
buyOrder: 'buy-order',
|
|
|
|
sellOrder: 'sell-order',
|
2022-08-22 22:50:13 +00:00
|
|
|
aggressor: Side.SIDE_BUY,
|
2022-06-30 07:52:25 +00:00
|
|
|
buyer: {
|
|
|
|
__typename: 'Party',
|
|
|
|
id: 'buyer-id',
|
|
|
|
},
|
|
|
|
seller: {
|
|
|
|
__typename: 'Party',
|
|
|
|
id: 'seller-id',
|
|
|
|
},
|
|
|
|
buyerFee: {
|
|
|
|
__typename: 'TradeFee',
|
|
|
|
makerFee: '100',
|
|
|
|
infrastructureFee: '100',
|
|
|
|
liquidityFee: '100',
|
|
|
|
},
|
|
|
|
sellerFee: {
|
|
|
|
__typename: 'TradeFee',
|
|
|
|
makerFee: '200',
|
|
|
|
infrastructureFee: '200',
|
|
|
|
liquidityFee: '200',
|
|
|
|
},
|
|
|
|
market: {
|
|
|
|
__typename: 'Market',
|
|
|
|
id: 'market-id',
|
|
|
|
name: 'UNIDAI Monthly (30 Jun 2022)',
|
|
|
|
positionDecimalPlaces: 0,
|
|
|
|
decimalPlaces: 5,
|
|
|
|
tradableInstrument: {
|
|
|
|
__typename: 'TradableInstrument',
|
|
|
|
instrument: {
|
|
|
|
__typename: 'Instrument',
|
|
|
|
id: 'instrument-id',
|
|
|
|
code: 'instrument-code',
|
|
|
|
product: {
|
|
|
|
__typename: 'Future',
|
|
|
|
settlementAsset: {
|
|
|
|
__typename: 'Asset',
|
|
|
|
id: 'asset-id',
|
|
|
|
symbol: 'SYM',
|
|
|
|
decimals: 18,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return merge(defaultFill, override);
|
|
|
|
};
|