-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
broker-client.ts
158 lines (141 loc) · 3.87 KB
/
broker-client.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import {
APIResponse,
BrokerProductType,
BrokerSubAPIKeyModifyRequest,
BrokerSubListRequest,
BrokerSubWithdrawalRequest,
} from './types';
import { REST_CLIENT_TYPE_ENUM } from './util';
import BaseRestClient from './util/BaseRestClient';
/**
* REST API client for the V1 bitget Broker APIs. These are the previous generation of Bitget's APIs and should be considered deprecated.
* These will be removed in a future release, once Bitget formally deprecates them.
*
* @deprecated use RestClientV2 instead
*/
export class BrokerClient extends BaseRestClient {
getClientType() {
return REST_CLIENT_TYPE_ENUM.broker;
}
/**
*
* Sub Account Interface
*
*/
/** Get Broker Info */
getBrokerInfo(): Promise<APIResponse<any>> {
return this.getPrivate('/api/broker/v1/account/info');
}
/** Create Sub Account */
createSubAccount(
subName: string,
remark?: string,
): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/account/sub-create', {
subName,
remark,
});
}
/** Get Sub List */
getSubAccounts(params?: BrokerSubListRequest): Promise<APIResponse<any>> {
return this.getPrivate('/api/broker/v1/account/sub-list', params);
}
/** Modify Sub Account */
modifySubAccount(
subUid: string,
perm: string,
status: 'normal' | 'freeze' | 'del',
): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/account/sub-modify', {
subUid,
perm,
status,
});
}
/** Modify Sub Email */
modifySubEmail(subUid: string, subEmail: string): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/account/sub-modify-email', {
subUid,
subEmail,
});
}
/** Get Sub Email */
getSubEmail(subUid: string): Promise<APIResponse<any>> {
return this.getPrivate('/api/broker/v1/account/sub-email', { subUid });
}
/** Get Sub Spot Assets */
getSubSpotAssets(subUid: string): Promise<APIResponse<any>> {
return this.getPrivate('/api/broker/v1/account/sub-spot-assets', {
subUid,
});
}
/** Get Sub Future Assets */
getSubFutureAssets(
subUid: string,
productType: BrokerProductType,
): Promise<APIResponse<any>> {
return this.getPrivate('/api/broker/v1/account/sub-future-assets', {
subUid,
productType,
});
}
/** Get Sub Deposit Address (Only Broker) */
getSubDepositAddress(
subUid: string,
coin: string,
chain?: string,
): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/account/sub-address', {
subUid,
coin,
chain,
});
}
/** Sub Withdrawal (Only Broker) */
subWithdrawal(params: BrokerSubWithdrawalRequest): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/account/sub-withdrawal', params);
}
/** Sub Deposit Auto Transfer (Only Broker) */
setSubDepositAutoTransfer(
subUid: string,
coin: string,
toAccountType: 'spot' | 'mix_usdt' | 'mix_usd' | 'mix_usdc',
): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/account/sub-auto-transfer', {
subUid,
coin,
toAccountType,
});
}
/**
*
* Sub API Interface
*
*/
/** Create Sub ApiKey (Only Broker) */
createSubAPIKey(
subUid: string,
passphrase: string,
remark: string,
ip: string,
perm?: string,
): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/manage/sub-api-create', {
subUid,
passphrase,
remark,
ip,
perm,
});
}
/** Get Sub ApiKey List */
getSubAPIKeys(subUid: string): Promise<APIResponse<any>> {
return this.getPrivate('/api/broker/v1/manage/sub-api-list', { subUid });
}
/** Modify Sub ApiKey (Only Broker) */
modifySubAPIKey(
params: BrokerSubAPIKeyModifyRequest,
): Promise<APIResponse<any>> {
return this.postPrivate('/api/broker/v1/manage/sub-api-modify', params);
}
}