@0xmonaco/core 0.8.7-develop.0e951a5 → 0.8.7-develop.0f12336
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -12
- package/dist/api/applications/api.d.ts +61 -8
- package/dist/api/applications/api.js +75 -11
- package/dist/api/auth/api.d.ts +8 -27
- package/dist/api/auth/api.js +16 -52
- package/dist/api/base.d.ts +37 -2
- package/dist/api/base.js +62 -2
- package/dist/api/delegated-agents/api.d.ts +2 -1
- package/dist/api/delegated-agents/api.js +15 -11
- package/dist/api/faucet/api.d.ts +25 -0
- package/dist/api/faucet/api.js +29 -0
- package/dist/api/faucet/index.d.ts +1 -0
- package/dist/api/faucet/index.js +1 -0
- package/dist/api/fees/api.d.ts +13 -13
- package/dist/api/fees/api.js +18 -18
- package/dist/api/index.d.ts +4 -0
- package/dist/api/index.js +4 -0
- package/dist/api/margin-accounts/api.d.ts +9 -5
- package/dist/api/margin-accounts/api.js +70 -33
- package/dist/api/market/api.d.ts +5 -2
- package/dist/api/market/api.js +32 -16
- package/dist/api/orderbook/api.js +13 -13
- package/dist/api/perp/routes.d.ts +113 -37
- package/dist/api/perp/routes.js +37 -6
- package/dist/api/positions/api.d.ts +2 -1
- package/dist/api/positions/api.js +30 -18
- package/dist/api/profile/api.d.ts +40 -23
- package/dist/api/profile/api.js +78 -38
- package/dist/api/sub-accounts/api.d.ts +62 -0
- package/dist/api/sub-accounts/api.js +80 -0
- package/dist/api/sub-accounts/index.d.ts +1 -0
- package/dist/api/sub-accounts/index.js +1 -0
- package/dist/api/trades/api.d.ts +21 -10
- package/dist/api/trades/api.js +22 -10
- package/dist/api/trading/api.d.ts +11 -8
- package/dist/api/trading/api.js +70 -87
- package/dist/api/vault/api.d.ts +96 -29
- package/dist/api/vault/api.js +172 -43
- package/dist/api/vault/index.d.ts +1 -1
- package/dist/api/vault/index.js +1 -1
- package/dist/api/whitelist/api.d.ts +27 -0
- package/dist/api/whitelist/api.js +32 -0
- package/dist/api/whitelist/index.d.ts +1 -0
- package/dist/api/whitelist/index.js +1 -0
- package/dist/api/withdrawals/api.d.ts +18 -0
- package/dist/api/withdrawals/api.js +35 -0
- package/dist/api/withdrawals/index.d.ts +1 -0
- package/dist/api/withdrawals/index.js +1 -0
- package/dist/coverage.d.ts +93 -0
- package/dist/coverage.js +93 -0
- package/dist/sdk.d.ts +34 -3
- package/dist/sdk.js +88 -0
- package/package.json +3 -3
|
@@ -3,11 +3,11 @@ export declare const perpRoutes: {
|
|
|
3
3
|
readonly create: () => string;
|
|
4
4
|
readonly list: (params?: {
|
|
5
5
|
page?: number;
|
|
6
|
-
|
|
6
|
+
pageSize?: number;
|
|
7
7
|
status?: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
tradingPair?: string;
|
|
9
|
+
tradingMode?: string;
|
|
10
|
+
marginAccountId?: string;
|
|
11
11
|
}) => string;
|
|
12
12
|
readonly get: (orderId: string) => string;
|
|
13
13
|
readonly replace: (orderId: string) => string;
|
|
@@ -17,34 +17,42 @@ export declare const perpRoutes: {
|
|
|
17
17
|
readonly batchCancelAllByPair: (tradingPairId: string) => string;
|
|
18
18
|
readonly batchCreate: () => string;
|
|
19
19
|
readonly batchReplace: () => string;
|
|
20
|
-
readonly createConditional: () => string;
|
|
21
20
|
readonly listConditional: (params?: {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
marginAccountId?: string;
|
|
22
|
+
tradingPairId?: string;
|
|
24
23
|
state?: string;
|
|
25
24
|
page?: number;
|
|
26
|
-
|
|
25
|
+
pageSize?: number;
|
|
27
26
|
}) => string;
|
|
28
27
|
readonly cancelConditional: (conditionalOrderId: string) => string;
|
|
29
28
|
};
|
|
30
29
|
readonly delegatedAgents: {
|
|
31
30
|
readonly list: () => string;
|
|
31
|
+
readonly owners: () => string;
|
|
32
32
|
readonly byId: (delegatedAgentId: string) => string;
|
|
33
33
|
readonly sessions: () => string;
|
|
34
34
|
};
|
|
35
|
+
readonly withdrawals: {
|
|
36
|
+
readonly initiate: () => string;
|
|
37
|
+
readonly byIndex: (withdrawalIndex: number) => string;
|
|
38
|
+
readonly list: (params?: {
|
|
39
|
+
page?: number;
|
|
40
|
+
pageSize?: number;
|
|
41
|
+
}) => string;
|
|
42
|
+
};
|
|
35
43
|
readonly market: {
|
|
36
44
|
readonly listTradingPairs: (params?: {
|
|
37
45
|
page?: number;
|
|
38
46
|
limit?: number;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
marketType?: string;
|
|
48
|
+
baseToken?: string;
|
|
49
|
+
quoteToken?: string;
|
|
50
|
+
isActive?: boolean;
|
|
43
51
|
}) => string;
|
|
44
52
|
readonly getTradingPair: (tradingPairId: string) => string;
|
|
45
53
|
readonly getCandles: (tradingPairId: string, interval: string, params?: {
|
|
46
|
-
|
|
47
|
-
|
|
54
|
+
startTime?: number;
|
|
55
|
+
endTime?: number;
|
|
48
56
|
limit?: number;
|
|
49
57
|
}) => string;
|
|
50
58
|
readonly getMarketMetadata: (tradingPairId: string) => string;
|
|
@@ -54,17 +62,25 @@ export declare const perpRoutes: {
|
|
|
54
62
|
readonly getIndexPrice: (tradingPairId: string) => string;
|
|
55
63
|
readonly getFundingState: (tradingPairId: string) => string;
|
|
56
64
|
readonly listFundingHistory: (tradingPairId: string, params?: {
|
|
57
|
-
|
|
58
|
-
|
|
65
|
+
startTime?: string;
|
|
66
|
+
endTime?: string;
|
|
59
67
|
page?: number;
|
|
60
|
-
|
|
68
|
+
pageSize?: number;
|
|
61
69
|
}) => string;
|
|
62
70
|
readonly getOpenInterest: (tradingPairId: string) => string;
|
|
71
|
+
readonly getScreener: (params?: {
|
|
72
|
+
page?: number;
|
|
73
|
+
pageSize?: number;
|
|
74
|
+
marketType?: string;
|
|
75
|
+
isActive?: boolean;
|
|
76
|
+
category?: string;
|
|
77
|
+
}) => string;
|
|
78
|
+
readonly getMarketStats: () => string;
|
|
63
79
|
};
|
|
64
80
|
readonly orderbook: {
|
|
65
81
|
readonly get: (tradingPairId: string, params?: {
|
|
66
82
|
levels?: number;
|
|
67
|
-
|
|
83
|
+
tradingMode?: string;
|
|
68
84
|
magnitude?: string | number;
|
|
69
85
|
denomination?: string;
|
|
70
86
|
}) => string;
|
|
@@ -74,57 +90,118 @@ export declare const perpRoutes: {
|
|
|
74
90
|
skip?: number;
|
|
75
91
|
limit?: number;
|
|
76
92
|
}) => string;
|
|
93
|
+
readonly byId: (tradeId: string) => string;
|
|
77
94
|
readonly user: (params?: {
|
|
78
|
-
|
|
79
|
-
|
|
95
|
+
marginAccountId?: string;
|
|
96
|
+
tradingPairId?: string;
|
|
97
|
+
page?: number;
|
|
98
|
+
pageSize?: number;
|
|
99
|
+
}) => string;
|
|
100
|
+
};
|
|
101
|
+
readonly applications: {
|
|
102
|
+
readonly orders: (params?: {
|
|
103
|
+
page?: number;
|
|
104
|
+
pageSize?: number;
|
|
105
|
+
status?: string;
|
|
106
|
+
userId?: string;
|
|
107
|
+
tradingPairId?: string;
|
|
108
|
+
side?: string;
|
|
109
|
+
orderType?: string;
|
|
110
|
+
}) => string;
|
|
111
|
+
readonly users: (params?: {
|
|
112
|
+
page?: number;
|
|
113
|
+
pageSize?: number;
|
|
114
|
+
isActive?: boolean;
|
|
115
|
+
accountType?: string;
|
|
116
|
+
address?: string;
|
|
117
|
+
}) => string;
|
|
118
|
+
readonly movements: (params?: {
|
|
119
|
+
page?: number;
|
|
120
|
+
pageSize?: number;
|
|
121
|
+
userId?: string;
|
|
122
|
+
transactionType?: string;
|
|
123
|
+
entryType?: string;
|
|
124
|
+
assetId?: string;
|
|
125
|
+
}) => string;
|
|
126
|
+
readonly balances: (params?: {
|
|
80
127
|
page?: number;
|
|
81
|
-
|
|
128
|
+
pageSize?: number;
|
|
129
|
+
userId?: string;
|
|
130
|
+
assetId?: string;
|
|
131
|
+
}) => string;
|
|
132
|
+
readonly stats: (params?: {
|
|
133
|
+
since?: string;
|
|
82
134
|
}) => string;
|
|
83
135
|
};
|
|
136
|
+
readonly subAccounts: {
|
|
137
|
+
readonly list: () => string;
|
|
138
|
+
readonly createLimit: () => string;
|
|
139
|
+
readonly getLimits: (subAccountId: string) => string;
|
|
140
|
+
readonly limit: (subAccountId: string, assetId: string) => string;
|
|
141
|
+
};
|
|
142
|
+
readonly faucet: {
|
|
143
|
+
readonly mint: () => string;
|
|
144
|
+
};
|
|
145
|
+
readonly whitelist: {
|
|
146
|
+
readonly submit: () => string;
|
|
147
|
+
};
|
|
84
148
|
readonly positions: {
|
|
85
149
|
readonly list: (params?: {
|
|
86
|
-
|
|
87
|
-
|
|
150
|
+
marginAccountId?: string;
|
|
151
|
+
tradingPairId?: string;
|
|
88
152
|
status?: string;
|
|
89
153
|
page?: number;
|
|
90
|
-
|
|
154
|
+
pageSize?: number;
|
|
91
155
|
}) => string;
|
|
92
156
|
readonly get: (positionId: string) => string;
|
|
93
157
|
readonly close: (positionId: string) => string;
|
|
158
|
+
readonly batchCloseAll: () => string;
|
|
94
159
|
readonly risk: (positionId: string) => string;
|
|
95
160
|
readonly addMargin: (positionId: string) => string;
|
|
96
161
|
readonly reduceMargin: (positionId: string) => string;
|
|
97
162
|
readonly attachTpSl: (positionId: string) => string;
|
|
98
163
|
readonly history: (params?: {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
164
|
+
positionId?: string;
|
|
165
|
+
marginAccountId?: string;
|
|
166
|
+
tradingPairId?: string;
|
|
102
167
|
page?: number;
|
|
103
|
-
|
|
168
|
+
pageSize?: number;
|
|
104
169
|
}) => string;
|
|
105
170
|
};
|
|
106
171
|
readonly marginAccounts: {
|
|
107
172
|
readonly list: (params?: {
|
|
108
173
|
page?: number;
|
|
109
|
-
|
|
174
|
+
pageSize?: number;
|
|
110
175
|
state?: string;
|
|
111
|
-
|
|
176
|
+
tradingPairId?: string;
|
|
177
|
+
}) => string;
|
|
178
|
+
readonly parentSummary: (params?: {
|
|
179
|
+
tradingPairId?: string;
|
|
180
|
+
}) => string;
|
|
181
|
+
readonly summary: (marginAccountId: string, params?: {
|
|
182
|
+
tradingPairId?: string;
|
|
112
183
|
}) => string;
|
|
113
|
-
readonly create: () => string;
|
|
114
|
-
readonly summary: (marginAccountId: string) => string;
|
|
115
184
|
readonly availableCollateral: (params?: {
|
|
116
185
|
asset?: string;
|
|
117
186
|
}) => string;
|
|
118
187
|
readonly transferIn: (marginAccountId: string) => string;
|
|
119
|
-
readonly
|
|
188
|
+
readonly transferInParent: () => string;
|
|
189
|
+
readonly transferInRiskBucket: () => string;
|
|
120
190
|
readonly transferOut: (marginAccountId: string) => string;
|
|
191
|
+
readonly transferOutParent: () => string;
|
|
121
192
|
readonly movements: (marginAccountId: string, params?: {
|
|
122
|
-
|
|
193
|
+
movementType?: string;
|
|
194
|
+
page?: number;
|
|
195
|
+
pageSize?: number;
|
|
196
|
+
}) => string;
|
|
197
|
+
readonly parentMovements: (params?: {
|
|
198
|
+
movementType?: string;
|
|
123
199
|
page?: number;
|
|
124
|
-
|
|
200
|
+
pageSize?: number;
|
|
125
201
|
}) => string;
|
|
202
|
+
readonly simulateParentMarginOrderRisk: () => string;
|
|
126
203
|
readonly simulateOrderRisk: (marginAccountId: string) => string;
|
|
127
|
-
readonly
|
|
204
|
+
readonly simulateRiskBucketOrderRisk: () => string;
|
|
128
205
|
};
|
|
129
206
|
readonly streams: {
|
|
130
207
|
readonly orderbook: () => string;
|
|
@@ -134,7 +211,6 @@ export declare const perpRoutes: {
|
|
|
134
211
|
readonly privateTrades: () => string;
|
|
135
212
|
readonly orders: () => string;
|
|
136
213
|
readonly positions: () => string;
|
|
137
|
-
readonly marginAccount: () => string;
|
|
138
214
|
readonly funding: () => string;
|
|
139
215
|
readonly liquidationAlerts: () => string;
|
|
140
216
|
};
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -26,15 +26,20 @@ export const perpRoutes = {
|
|
|
26
26
|
batchCancelAllByPair: (tradingPairId) => `${API_V1}/orders/batch-cancel-all/${encodeSegment(tradingPairId)}`,
|
|
27
27
|
batchCreate: () => `${API_V1}/orders/batch-create`,
|
|
28
28
|
batchReplace: () => `${API_V1}/orders/batch-replace`,
|
|
29
|
-
createConditional: () => `${API_V1}/orders/conditional`,
|
|
30
29
|
listConditional: (params) => withQuery(`${API_V1}/orders/conditional`, params),
|
|
31
30
|
cancelConditional: (conditionalOrderId) => `${API_V1}/orders/conditional/${encodeSegment(conditionalOrderId)}`,
|
|
32
31
|
},
|
|
33
32
|
delegatedAgents: {
|
|
34
33
|
list: () => `${API_V1}/delegated-agents`,
|
|
34
|
+
owners: () => `${API_V1}/delegated-agents/owners`,
|
|
35
35
|
byId: (delegatedAgentId) => `${API_V1}/delegated-agents/${encodeSegment(delegatedAgentId)}`,
|
|
36
36
|
sessions: () => `${API_V1}/delegated-agents/sessions`,
|
|
37
37
|
},
|
|
38
|
+
withdrawals: {
|
|
39
|
+
initiate: () => `${API_V1}/withdrawals`,
|
|
40
|
+
byIndex: (withdrawalIndex) => `${API_V1}/withdrawals/${encodeSegment(String(withdrawalIndex))}`,
|
|
41
|
+
list: (params) => withQuery(`${API_V1}/withdrawals`, params),
|
|
42
|
+
},
|
|
38
43
|
market: {
|
|
39
44
|
listTradingPairs: (params) => withQuery(`${API_V1}/market/pairs`, params),
|
|
40
45
|
getTradingPair: (tradingPairId) => `${API_V1}/market/pairs/${encodeSegment(tradingPairId)}`,
|
|
@@ -47,18 +52,41 @@ export const perpRoutes = {
|
|
|
47
52
|
getFundingState: (tradingPairId) => `${API_V1}/market/pairs/${encodeSegment(tradingPairId)}/funding`,
|
|
48
53
|
listFundingHistory: (tradingPairId, params) => withQuery(`${API_V1}/market/pairs/${encodeSegment(tradingPairId)}/funding/history`, params),
|
|
49
54
|
getOpenInterest: (tradingPairId) => `${API_V1}/market/pairs/${encodeSegment(tradingPairId)}/open-interest`,
|
|
55
|
+
getScreener: (params) => withQuery(`${API_V1}/market/screener`, params),
|
|
56
|
+
getMarketStats: () => `${API_V1}/market/stats`,
|
|
50
57
|
},
|
|
51
58
|
orderbook: {
|
|
52
59
|
get: (tradingPairId, params) => withQuery(`${API_V1}/orderbook/${encodeSegment(tradingPairId)}`, params),
|
|
53
60
|
},
|
|
54
61
|
trades: {
|
|
55
62
|
publicByPair: (tradingPairId, params) => withQuery(`${API_V1}/trades/${encodeSegment(tradingPairId)}`, params),
|
|
63
|
+
byId: (tradeId) => `${API_V1}/trades/by-id/${encodeSegment(tradeId)}`,
|
|
56
64
|
user: (params) => withQuery(`${API_V1}/accounts/trades`, params),
|
|
57
65
|
},
|
|
66
|
+
applications: {
|
|
67
|
+
orders: (params) => withQuery(`${API_V1}/applications/orders`, params),
|
|
68
|
+
users: (params) => withQuery(`${API_V1}/applications/users`, params),
|
|
69
|
+
movements: (params) => withQuery(`${API_V1}/applications/movements`, params),
|
|
70
|
+
balances: (params) => withQuery(`${API_V1}/applications/balances`, params),
|
|
71
|
+
stats: (params) => withQuery(`${API_V1}/applications/stats`, params),
|
|
72
|
+
},
|
|
73
|
+
subAccounts: {
|
|
74
|
+
list: () => `${API_V1}/accounts/sub-accounts`,
|
|
75
|
+
createLimit: () => `${API_V1}/accounts/sub-accounts/limits`,
|
|
76
|
+
getLimits: (subAccountId) => `${API_V1}/accounts/sub-accounts/${encodeSegment(subAccountId)}/limits`,
|
|
77
|
+
limit: (subAccountId, assetId) => `${API_V1}/accounts/sub-accounts/${encodeSegment(subAccountId)}/limits/${encodeSegment(assetId)}`,
|
|
78
|
+
},
|
|
79
|
+
faucet: {
|
|
80
|
+
mint: () => `${API_V1}/faucet/mint`,
|
|
81
|
+
},
|
|
82
|
+
whitelist: {
|
|
83
|
+
submit: () => `${API_V1}/whitelist`,
|
|
84
|
+
},
|
|
58
85
|
positions: {
|
|
59
86
|
list: (params) => withQuery(`${API_V1}/positions`, params),
|
|
60
87
|
get: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}`,
|
|
61
88
|
close: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/close`,
|
|
89
|
+
batchCloseAll: () => `${API_V1}/positions/batch-close-all`,
|
|
62
90
|
risk: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/risk`,
|
|
63
91
|
addMargin: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/margin/add`,
|
|
64
92
|
reduceMargin: (positionId) => `${API_V1}/positions/${encodeSegment(positionId)}/margin/reduce`,
|
|
@@ -67,15 +95,19 @@ export const perpRoutes = {
|
|
|
67
95
|
},
|
|
68
96
|
marginAccounts: {
|
|
69
97
|
list: (params) => withQuery(`${API_V1}/margin/accounts`, params),
|
|
70
|
-
|
|
71
|
-
summary: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}`,
|
|
98
|
+
parentSummary: (params) => withQuery(`${API_V1}/margin/parent-margin-account`, params),
|
|
99
|
+
summary: (marginAccountId, params) => withQuery(`${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}`, params),
|
|
72
100
|
availableCollateral: (params) => withQuery(`${API_V1}/margin/collateral/available`, params),
|
|
73
101
|
transferIn: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/collateral/transfer-in`,
|
|
74
|
-
|
|
102
|
+
transferInParent: () => `${API_V1}/margin/parent-margin-account/collateral/transfer-in`,
|
|
103
|
+
transferInRiskBucket: () => `${API_V1}/margin/risk-buckets/collateral/transfer-in`,
|
|
75
104
|
transferOut: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/collateral/transfer-out`,
|
|
105
|
+
transferOutParent: () => `${API_V1}/margin/parent-margin-account/collateral/transfer-out`,
|
|
76
106
|
movements: (marginAccountId, params) => withQuery(`${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/movements`, params),
|
|
107
|
+
parentMovements: (params) => withQuery(`${API_V1}/margin/parent-margin-account/movements`, params),
|
|
108
|
+
simulateParentMarginOrderRisk: () => `${API_V1}/margin/parent-margin-account/simulate-order-risk`,
|
|
77
109
|
simulateOrderRisk: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/simulate-order-risk`,
|
|
78
|
-
|
|
110
|
+
simulateRiskBucketOrderRisk: () => `${API_V1}/margin/risk-buckets/simulate-order-risk`,
|
|
79
111
|
},
|
|
80
112
|
streams: {
|
|
81
113
|
orderbook: () => `${API_V1}/streaming/orderbook`,
|
|
@@ -85,7 +117,6 @@ export const perpRoutes = {
|
|
|
85
117
|
privateTrades: () => `${API_V1}/streaming/private-trades`,
|
|
86
118
|
orders: () => `${API_V1}/streaming/orders`,
|
|
87
119
|
positions: () => `${API_V1}/streaming/positions`,
|
|
88
|
-
marginAccount: () => `${API_V1}/streaming/margin-account`,
|
|
89
120
|
funding: () => `${API_V1}/streaming/funding`,
|
|
90
121
|
liquidationAlerts: () => `${API_V1}/streaming/liquidation-alerts`,
|
|
91
122
|
},
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, PositionsAPI, ReducePositionMarginRequest } from "@0xmonaco/types";
|
|
1
|
+
import type { AddPositionMarginRequest, AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseAllRequest, BatchCloseAllResponse, ClosePositionRequest, ClosePositionResponse, GetPositionResponse, ListPositionHistoryParams, ListPositionHistoryResponse, ListPositionsParams, ListPositionsResponse, PositionMarginResponse, PositionRisk, PositionsAPI, ReducePositionMarginRequest } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
|
|
4
4
|
listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
|
|
5
5
|
getPosition(positionId: string): Promise<GetPositionResponse>;
|
|
6
6
|
closePosition(positionId: string, request: ClosePositionRequest): Promise<ClosePositionResponse>;
|
|
7
|
+
batchCloseAllPositions(request?: BatchCloseAllRequest): Promise<BatchCloseAllResponse>;
|
|
7
8
|
getPositionRisk(positionId: string): Promise<PositionRisk>;
|
|
8
9
|
addPositionMargin(positionId: string, request: AddPositionMarginRequest): Promise<PositionMarginResponse>;
|
|
9
10
|
reducePositionMargin(positionId: string, request: ReducePositionMarginRequest): Promise<PositionMarginResponse>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AddPositionMarginSchema, AttachPositionTpSlSchema, ClosePositionSchema, GetPositionRiskSchema, GetPositionSchema, ListPositionHistorySchema, ListPositionsSchema, ReducePositionMarginSchema, validate, } from "@0xmonaco/types";
|
|
1
|
+
import { AddPositionMarginSchema, AttachPositionTpSlSchema, BatchCloseAllSchema, ClosePositionSchema, GetPositionRiskSchema, GetPositionSchema, ListPositionHistorySchema, ListPositionsSchema, ReducePositionMarginSchema, validate, } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class PositionsAPIImpl extends BaseAPI {
|
|
@@ -17,13 +17,25 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
17
17
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.close(positionId), {
|
|
18
18
|
method: "POST",
|
|
19
19
|
body: JSON.stringify({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
closeType: request.closeType,
|
|
21
|
+
limitPrice: request.limitPrice,
|
|
22
|
+
slippageToleranceBps: request.slippageToleranceBps,
|
|
23
23
|
quantity: request.quantity,
|
|
24
24
|
}),
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
+
async batchCloseAllPositions(request) {
|
|
28
|
+
if (request) {
|
|
29
|
+
validate(BatchCloseAllSchema, request);
|
|
30
|
+
}
|
|
31
|
+
return await this.makeAuthenticatedRequest(perpRoutes.positions.batchCloseAll(), {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify({
|
|
34
|
+
tradingPairId: request?.tradingPairId,
|
|
35
|
+
slippageToleranceBps: request?.slippageToleranceBps,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
27
39
|
async getPositionRisk(positionId) {
|
|
28
40
|
validate(GetPositionRiskSchema, { positionId });
|
|
29
41
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.risk(positionId));
|
|
@@ -52,26 +64,26 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
52
64
|
return await this.makeAuthenticatedRequest(perpRoutes.positions.attachTpSl(positionId), {
|
|
53
65
|
method: "POST",
|
|
54
66
|
body: JSON.stringify({
|
|
55
|
-
|
|
67
|
+
takeProfit: request.takeProfit
|
|
56
68
|
? {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
triggerPrice: request.takeProfit.triggerPrice,
|
|
70
|
+
orderType: request.takeProfit.orderType,
|
|
71
|
+
limitPrice: request.takeProfit.limitPrice,
|
|
60
72
|
quantity: request.takeProfit.quantity,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
timeInForce: request.takeProfit.timeInForce,
|
|
74
|
+
slippageToleranceBps: request.takeProfit.slippageToleranceBps,
|
|
75
|
+
expiresAt: request.takeProfit.expiresAt,
|
|
64
76
|
}
|
|
65
77
|
: undefined,
|
|
66
|
-
|
|
78
|
+
stopLoss: request.stopLoss
|
|
67
79
|
? {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
triggerPrice: request.stopLoss.triggerPrice,
|
|
81
|
+
orderType: request.stopLoss.orderType,
|
|
82
|
+
limitPrice: request.stopLoss.limitPrice,
|
|
71
83
|
quantity: request.stopLoss.quantity,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
84
|
+
timeInForce: request.stopLoss.timeInForce,
|
|
85
|
+
slippageToleranceBps: request.stopLoss.slippageToleranceBps,
|
|
86
|
+
expiresAt: request.stopLoss.expiresAt,
|
|
75
87
|
}
|
|
76
88
|
: undefined,
|
|
77
89
|
}),
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* console.log(`User: ${profile.username} (${profile.address})`);
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
import type { AccountBalance, GetPaginatedUserMovementsResponse, GetUserBalancesParams, GetUserBalancesResponse, GetUserMovementsParams, GetUserTradesParams, GetUserTradesResponse, PortfolioChartResponse, PortfolioMetric, PortfolioPeriod, PortfolioStats, ProfileAPI, UserProfile } from "@0xmonaco/types";
|
|
20
|
+
import type { AccountBalance, GetPaginatedUserMovementsResponse, GetUserBalancesParams, GetUserBalancesResponse, GetUserMovementsParams, GetUserTradesParams, GetUserTradesResponse, ListFundingPaymentsParams, ListFundingPaymentsResponse, PortfolioChartResponse, PortfolioMetric, PortfolioPeriod, PortfolioStats, ProfileAPI, UserProfile } from "@0xmonaco/types";
|
|
21
21
|
import { BaseAPI } from "../base";
|
|
22
22
|
export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
23
23
|
/**
|
|
@@ -39,8 +39,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
39
39
|
* console.log(`User ID: ${profile.id}`);
|
|
40
40
|
* console.log(`Address: ${profile.address}`);
|
|
41
41
|
* console.log(`Username: ${profile.username}`);
|
|
42
|
-
* console.log(`Account type: ${profile.
|
|
43
|
-
* console.log(`Can withdraw: ${profile.
|
|
42
|
+
* console.log(`Account type: ${profile.accountType}`);
|
|
43
|
+
* console.log(`Can withdraw: ${profile.canWithdraw}`);
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
46
|
getProfile(): Promise<UserProfile>;
|
|
@@ -53,27 +53,27 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
53
53
|
* @param params - Optional query parameters for pagination and filtering
|
|
54
54
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
55
55
|
* @param params.limit - Number of items per page (default: 20, max: 100)
|
|
56
|
-
* @param params.
|
|
57
|
-
* @param params.
|
|
58
|
-
* @param params.
|
|
56
|
+
* @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
|
|
57
|
+
* @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
|
|
58
|
+
* @param params.assetId - Filter by asset ID (UUID)
|
|
59
59
|
* @returns Promise resolving to paginated movements response
|
|
60
60
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
64
|
-
* // Get first page with default
|
|
64
|
+
* // Get first page with default pageSize (20)
|
|
65
65
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
66
66
|
* console.log(`Total movements: ${movements.total}`);
|
|
67
67
|
*
|
|
68
|
-
* // Get second page with custom
|
|
69
|
-
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2,
|
|
70
|
-
* console.log(`Page ${page2.page} of ${page2.
|
|
68
|
+
* // Get second page with custom pageSize
|
|
69
|
+
* const page2 = await profileAPI.getPaginatedUserMovements({ page: 2, pageSize: 50 });
|
|
70
|
+
* console.log(`Page ${page2.page} of ${page2.totalPages}`);
|
|
71
71
|
*
|
|
72
72
|
* // Filter by entry type and transaction type
|
|
73
|
-
* const deposits = await profileAPI.getPaginatedUserMovements({
|
|
73
|
+
* const deposits = await profileAPI.getPaginatedUserMovements({ entryType: "CREDIT", transactionType: "DEPOSIT" });
|
|
74
74
|
*
|
|
75
75
|
* // Filter by asset
|
|
76
|
-
* const usdcMovements = await profileAPI.getPaginatedUserMovements({
|
|
76
|
+
* const usdcMovements = await profileAPI.getPaginatedUserMovements({ assetId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
getPaginatedUserMovements(params?: GetUserMovementsParams): Promise<GetPaginatedUserMovementsResponse>;
|
|
@@ -85,7 +85,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
85
85
|
*
|
|
86
86
|
* @param params - Optional query parameters for pagination
|
|
87
87
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
88
|
-
* @param params.
|
|
88
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 100)
|
|
89
89
|
* @returns Promise resolving to paginated balances response
|
|
90
90
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
91
91
|
*
|
|
@@ -95,11 +95,11 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
95
95
|
* const balances = await profileAPI.getUserBalances();
|
|
96
96
|
* console.log(`Total balances: ${balances.total}`);
|
|
97
97
|
* balances.balances.forEach(balance => {
|
|
98
|
-
* console.log(`${balance.symbol}: ${balance.
|
|
98
|
+
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
99
99
|
* });
|
|
100
100
|
*
|
|
101
101
|
* // Get page 2 with 50 items per page
|
|
102
|
-
* const nextBalances = await profileAPI.getUserBalances({ page: 2,
|
|
102
|
+
* const nextBalances = await profileAPI.getUserBalances({ page: 2, pageSize: 50 });
|
|
103
103
|
* console.log(`Returned ${nextBalances.balances.length} balances`);
|
|
104
104
|
* ```
|
|
105
105
|
*/
|
|
@@ -107,7 +107,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
107
107
|
/**
|
|
108
108
|
* Get the current user's balance for a specific asset.
|
|
109
109
|
*
|
|
110
|
-
* Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{
|
|
110
|
+
* Fetches the user's balance for a specific asset from the /api/v1/accounts/balances/{assetId} endpoint.
|
|
111
111
|
* Requires a valid access token to be set. If no balance exists for a valid asset, returns zero balances.
|
|
112
112
|
*
|
|
113
113
|
* @param assetId - The asset identifier (UUID)
|
|
@@ -118,9 +118,9 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
118
118
|
* ```typescript
|
|
119
119
|
* // Get balance for a specific asset
|
|
120
120
|
* const balance = await profileAPI.getUserBalanceByAssetId('123e4567-e89b-12d3-a456-426614174000');
|
|
121
|
-
* console.log(`${balance.symbol}: ${balance.
|
|
122
|
-
* console.log(`Locked: ${balance.
|
|
123
|
-
* console.log(`Total: ${balance.
|
|
121
|
+
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
122
|
+
* console.log(`Locked: ${balance.lockedBalance}`);
|
|
123
|
+
* console.log(`Total: ${balance.totalBalance}`);
|
|
124
124
|
* ```
|
|
125
125
|
*/
|
|
126
126
|
getUserBalanceByAssetId(assetId: string): Promise<AccountBalance>;
|
|
@@ -139,7 +139,7 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
139
139
|
* const stats = await profileAPI.getPortfolioStats("30d");
|
|
140
140
|
* console.log(`PnL: ${stats.pnl}`);
|
|
141
141
|
* console.log(`Volume: ${stats.volume}`);
|
|
142
|
-
* console.log(`Total equity: ${stats.
|
|
142
|
+
* console.log(`Total equity: ${stats.totalEquity}`);
|
|
143
143
|
* ```
|
|
144
144
|
*/
|
|
145
145
|
getPortfolioStats(period: PortfolioPeriod): Promise<PortfolioStats>;
|
|
@@ -171,8 +171,8 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
171
171
|
*
|
|
172
172
|
* @param params - Optional query parameters for pagination and filtering
|
|
173
173
|
* @param params.page - Page number (starts from 1, default: 1)
|
|
174
|
-
* @param params.
|
|
175
|
-
* @param params.
|
|
174
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 100)
|
|
175
|
+
* @param params.tradingPairId - Filter by trading pair ID (UUID)
|
|
176
176
|
* @returns Promise resolving to paginated trades response
|
|
177
177
|
* @throws {ValidationError} When the provided params fail client-side validation
|
|
178
178
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
@@ -184,8 +184,25 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
184
184
|
* console.log(`Total trades: ${trades.total}`);
|
|
185
185
|
*
|
|
186
186
|
* // Filter by trading pair
|
|
187
|
-
* const pairTrades = await profileAPI.getUserTrades({
|
|
187
|
+
* const pairTrades = await profileAPI.getUserTrades({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
188
188
|
* ```
|
|
189
189
|
*/
|
|
190
190
|
getUserTrades(params?: GetUserTradesParams): Promise<GetUserTradesResponse>;
|
|
191
|
+
/**
|
|
192
|
+
* List the current user's funding payment history with pagination and filters.
|
|
193
|
+
*
|
|
194
|
+
* Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
|
|
195
|
+
* Requires a valid access token to be set.
|
|
196
|
+
*
|
|
197
|
+
* @param params - Optional query parameters for pagination and filtering
|
|
198
|
+
* @returns Promise resolving to paginated funding payments response
|
|
199
|
+
* @throws {APIError} When the request fails or user is not authenticated
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const funding = await profileAPI.listFundingPayments({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
204
|
+
* console.log(`Total funding payments: ${funding.total}`);
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
|
|
191
208
|
}
|