-
Notifications
You must be signed in to change notification settings - Fork 1
/
getOrdersHistory.ts
56 lines (49 loc) · 1.17 KB
/
getOrdersHistory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {invariant} from '@spinfi/shared';
import {nanoid} from 'nanoid';
import {OrderInfo} from './listenAccountOrders';
import {websocketErrorMessage} from './messages';
import {createSocket} from '../../utils/createSocket';
/**
* @category getOrdersHistory
*/
export type GetOrdersHistoryResponse = OrderInfo[];
/**
* @category getOrdersHistory
*/
export interface GetOrdersHistoryRequest {
/**
* Market ID
*/
marketId: number;
/**
* Account ID
*/
accountId: string;
/**
* Limit
*/
limit: number;
/**
* Offset
*/
offset: number;
}
const METHOD_NAME = 'get_orders_history';
export const getOrdersHistory = createSocket(({methodify}) => {
const createMethod = methodify<GetOrdersHistoryRequest, GetOrdersHistoryResponse>((config) => {
return (request, methodConfig) => {
invariant(config.websocket, websocketErrorMessage('getOrdersHistory'));
return config.websocket.sendMethod(
{
method: METHOD_NAME,
id: nanoid(),
params: [request.marketId, request.accountId, request.limit, request.offset],
},
methodConfig,
);
};
});
return {
createMethod,
};
});