@0xmonaco/core 1.0.73 → 1.0.74-develop.367860f
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 +0 -5
- package/dist/api/applications/api.d.ts +53 -22
- package/dist/api/applications/api.js +88 -22
- package/dist/api/auth/api.d.ts +1 -3
- package/dist/api/auth/api.js +1 -3
- package/dist/api/base.d.ts +0 -35
- package/dist/api/base.js +0 -54
- package/dist/api/buildercodes/api.d.ts +6 -7
- package/dist/api/buildercodes/api.js +9 -10
- package/dist/api/delegated-agents/api.js +1 -0
- package/dist/api/managed-markets/index.js +4 -2
- package/dist/api/margin-accounts/api.d.ts +7 -1
- package/dist/api/margin-accounts/api.js +48 -2
- package/dist/api/market/api.js +3 -1
- package/dist/api/perp/routes.d.ts +23 -12
- package/dist/api/perp/routes.js +6 -0
- package/dist/api/pitpass/api.d.ts +19 -8
- package/dist/api/pitpass/api.js +49 -11
- package/dist/api/portfolio/api.d.ts +2 -2
- package/dist/api/portfolio/api.js +11 -2
- package/dist/api/positions/api.d.ts +20 -8
- package/dist/api/positions/api.js +20 -8
- package/dist/api/profile/api.d.ts +55 -18
- package/dist/api/profile/api.js +77 -28
- package/dist/api/trades/api.d.ts +38 -7
- package/dist/api/trades/api.js +38 -11
- package/dist/api/trading/api.d.ts +6 -11
- package/dist/api/trading/api.js +6 -11
- package/dist/api/websocket/websocket.js +140 -26
- package/dist/api/withdrawals/api.js +3 -1
- package/dist/coverage.d.ts +7 -0
- package/dist/coverage.js +7 -0
- package/dist/sdk.d.ts +0 -18
- package/dist/sdk.js +0 -42
- package/package.json +3 -3
|
@@ -1,15 +1,59 @@
|
|
|
1
|
-
import { GetAvailableCollateralSchema, GetMarginAccountMovementsSchema, GetMarginAccountSummarySchema, GetParentMarginAccountMovementsSchema, GetParentMarginAccountSummarySchema, ListMarginAccountsSchema, SimulateOrderRiskSchema, SimulateParentMarginOrderRiskSchema, SimulateRiskBucketOrderRiskSchema, TransferCollateralFromParentMarginAccountSchema, TransferCollateralSchema, TransferCollateralToParentMarginAccountSchema, TransferCollateralToRiskBucketSchema, validate, } from "@0xmonaco/types";
|
|
1
|
+
import { CloseMarginSubAccountSchema, CreateMarginSubAccountSchema, GetAvailableCollateralSchema, GetMarginAccountMovementsSchema, GetMarginAccountPnlSchema, GetMarginAccountSummarySchema, GetParentMarginAccountMovementsSchema, GetParentMarginAccountSummarySchema, ListMarginAccountsSchema, SimulateOrderRiskSchema, SimulateParentMarginOrderRiskSchema, SimulateRiskBucketOrderRiskSchema, SubAccountCollateralTransferSchema, TransferCollateralFromParentMarginAccountSchema, TransferCollateralSchema, TransferCollateralToParentMarginAccountSchema, TransferCollateralToRiskBucketSchema, TransferMarginCollateralSchema, validate, } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class MarginAccountsAPIImpl extends BaseAPI {
|
|
5
|
+
async createMarginSubAccount(request) {
|
|
6
|
+
validate(CreateMarginSubAccountSchema, { request });
|
|
7
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.createSubAccount(), {
|
|
8
|
+
method: "POST",
|
|
9
|
+
body: JSON.stringify({ subaccountKey: request.subaccountKey, label: request.label }),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async closeMarginSubAccount(marginAccountId) {
|
|
13
|
+
validate(CloseMarginSubAccountSchema, { marginAccountId });
|
|
14
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.closeSubAccount(marginAccountId), {
|
|
15
|
+
method: "POST",
|
|
16
|
+
body: JSON.stringify({}),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async getMarginAccountPnl(marginAccountId) {
|
|
20
|
+
validate(GetMarginAccountPnlSchema, { marginAccountId });
|
|
21
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.pnl(marginAccountId));
|
|
22
|
+
}
|
|
23
|
+
async transferMarginCollateral(request) {
|
|
24
|
+
validate(TransferMarginCollateralSchema, { request });
|
|
25
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.transferCollateral(), {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
asset: request.asset,
|
|
29
|
+
amount: request.amount,
|
|
30
|
+
from: request.from,
|
|
31
|
+
to: request.to,
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async transferCollateralToSubAccount(marginAccountId, amount) {
|
|
36
|
+
validate(SubAccountCollateralTransferSchema, { marginAccountId, amount });
|
|
37
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.subAccountTransferIn(marginAccountId), {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: JSON.stringify({ amount }),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async transferCollateralFromSubAccount(marginAccountId, amount) {
|
|
43
|
+
validate(SubAccountCollateralTransferSchema, { marginAccountId, amount });
|
|
44
|
+
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.subAccountTransferOut(marginAccountId), {
|
|
45
|
+
method: "POST",
|
|
46
|
+
body: JSON.stringify({ amount }),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
5
49
|
async listMarginAccounts(params) {
|
|
6
50
|
if (params) {
|
|
7
51
|
validate(ListMarginAccountsSchema, params);
|
|
8
52
|
}
|
|
9
53
|
return await this.makeAuthenticatedRequest(perpRoutes.marginAccounts.list(params
|
|
10
54
|
? {
|
|
11
|
-
page: params.page,
|
|
12
55
|
pageSize: params.pageSize,
|
|
56
|
+
pageToken: params.pageToken,
|
|
13
57
|
state: params.state,
|
|
14
58
|
tradingPairId: params.tradingPairId,
|
|
15
59
|
}
|
|
@@ -69,6 +113,7 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
69
113
|
tradingPairId: request.tradingPairId,
|
|
70
114
|
strategyKey: request.strategyKey,
|
|
71
115
|
marginMode: request.marginMode,
|
|
116
|
+
marginAccountId: request.marginAccountId,
|
|
72
117
|
// No selectedTradingPairIds: cross scope is derived from trading, and
|
|
73
118
|
// the server ignores the deprecated field. Not sending it keeps a
|
|
74
119
|
// pre-upgrade caller's stale list from reaching the wire at all.
|
|
@@ -152,6 +197,7 @@ export class MarginAccountsAPIImpl extends BaseAPI {
|
|
|
152
197
|
tradingPairId: request.tradingPairId,
|
|
153
198
|
strategyKey: request.strategyKey,
|
|
154
199
|
marginMode: request.marginMode,
|
|
200
|
+
marginAccountId: request.marginAccountId,
|
|
155
201
|
// No selectedTradingPairIds: cross scope is derived from trading, and
|
|
156
202
|
// the server ignores the deprecated field. Not sending it keeps a
|
|
157
203
|
// pre-upgrade caller's stale list from reaching the wire at all.
|
package/dist/api/market/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GetCandlesticksByPairIdSchema, GetMarketMetadataSchema, validate } from "@0xmonaco/types";
|
|
1
|
+
import { GetCandlesticksByPairIdSchema, GetMarketMetadataSchema, ListAllFundingHistorySchema, ListFundingHistorySchema, validate } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
/**
|
|
@@ -102,9 +102,11 @@ export class MarketAPIImpl extends BaseAPI {
|
|
|
102
102
|
}
|
|
103
103
|
async listFundingHistory(tradingPairId, params) {
|
|
104
104
|
validate(GetMarketMetadataSchema, { tradingPairId });
|
|
105
|
+
validate(ListFundingHistorySchema, params ?? {});
|
|
105
106
|
return await this.makePublicRequest(perpRoutes.market.listFundingHistory(tradingPairId, params));
|
|
106
107
|
}
|
|
107
108
|
async listAllFundingHistory(params) {
|
|
109
|
+
validate(ListAllFundingHistorySchema, params ?? {});
|
|
108
110
|
return await this.makePublicRequest(perpRoutes.market.listAllFundingHistory(params));
|
|
109
111
|
}
|
|
110
112
|
async getOpenInterest(tradingPairId) {
|
|
@@ -47,8 +47,8 @@ export declare const perpRoutes: {
|
|
|
47
47
|
readonly initiate: () => string;
|
|
48
48
|
readonly byIndex: (withdrawalIndex: number) => string;
|
|
49
49
|
readonly list: (params?: {
|
|
50
|
-
page?: number;
|
|
51
50
|
pageSize?: number;
|
|
51
|
+
pageToken?: string;
|
|
52
52
|
}) => string;
|
|
53
53
|
};
|
|
54
54
|
readonly market: {
|
|
@@ -75,15 +75,15 @@ export declare const perpRoutes: {
|
|
|
75
75
|
readonly listFundingHistory: (tradingPairId: string, params?: {
|
|
76
76
|
startTime?: string;
|
|
77
77
|
endTime?: string;
|
|
78
|
-
page?: number;
|
|
79
78
|
pageSize?: number;
|
|
79
|
+
pageToken?: string;
|
|
80
80
|
orderBy?: string;
|
|
81
81
|
}) => string;
|
|
82
82
|
readonly listAllFundingHistory: (params?: {
|
|
83
83
|
startTime?: string;
|
|
84
84
|
endTime?: string;
|
|
85
|
-
page?: number;
|
|
86
85
|
pageSize?: number;
|
|
86
|
+
pageToken?: string;
|
|
87
87
|
orderBy?: string;
|
|
88
88
|
}) => string;
|
|
89
89
|
readonly getOpenInterest: (tradingPairId: string) => string;
|
|
@@ -119,8 +119,9 @@ export declare const perpRoutes: {
|
|
|
119
119
|
};
|
|
120
120
|
readonly applications: {
|
|
121
121
|
readonly orders: (params?: {
|
|
122
|
-
|
|
122
|
+
clientId?: string;
|
|
123
123
|
pageSize?: number;
|
|
124
|
+
pageToken?: string;
|
|
124
125
|
status?: string;
|
|
125
126
|
userId?: string;
|
|
126
127
|
tradingPairId?: string;
|
|
@@ -128,27 +129,31 @@ export declare const perpRoutes: {
|
|
|
128
129
|
orderType?: string;
|
|
129
130
|
}) => string;
|
|
130
131
|
readonly users: (params?: {
|
|
131
|
-
|
|
132
|
+
clientId?: string;
|
|
132
133
|
pageSize?: number;
|
|
134
|
+
pageToken?: string;
|
|
133
135
|
isActive?: boolean;
|
|
134
136
|
accountType?: string;
|
|
135
137
|
address?: string;
|
|
136
138
|
}) => string;
|
|
137
139
|
readonly movements: (params?: {
|
|
138
|
-
|
|
140
|
+
clientId?: string;
|
|
139
141
|
pageSize?: number;
|
|
142
|
+
pageToken?: string;
|
|
140
143
|
userId?: string;
|
|
141
144
|
transactionType?: string;
|
|
142
145
|
entryType?: string;
|
|
143
146
|
assetId?: string;
|
|
144
147
|
}) => string;
|
|
145
148
|
readonly balances: (params?: {
|
|
146
|
-
|
|
149
|
+
clientId?: string;
|
|
147
150
|
pageSize?: number;
|
|
151
|
+
pageToken?: string;
|
|
148
152
|
userId?: string;
|
|
149
153
|
assetId?: string;
|
|
150
154
|
}) => string;
|
|
151
155
|
readonly stats: (params?: {
|
|
156
|
+
clientId?: string;
|
|
152
157
|
since?: string;
|
|
153
158
|
}) => string;
|
|
154
159
|
};
|
|
@@ -174,8 +179,8 @@ export declare const perpRoutes: {
|
|
|
174
179
|
marginAccountId?: string;
|
|
175
180
|
tradingPairId?: string;
|
|
176
181
|
status?: string;
|
|
177
|
-
page?: number;
|
|
178
182
|
pageSize?: number;
|
|
183
|
+
pageToken?: string;
|
|
179
184
|
}) => string;
|
|
180
185
|
readonly get: (positionId: string) => string;
|
|
181
186
|
readonly close: (positionId: string) => string;
|
|
@@ -186,8 +191,8 @@ export declare const perpRoutes: {
|
|
|
186
191
|
positionId?: string;
|
|
187
192
|
marginAccountId?: string;
|
|
188
193
|
tradingPairId?: string;
|
|
189
|
-
page?: number;
|
|
190
194
|
pageSize?: number;
|
|
195
|
+
pageToken?: string;
|
|
191
196
|
reductionOnly?: boolean;
|
|
192
197
|
}) => string;
|
|
193
198
|
readonly pnlHistory: (positionId: string, params: {
|
|
@@ -198,8 +203,8 @@ export declare const perpRoutes: {
|
|
|
198
203
|
};
|
|
199
204
|
readonly marginAccounts: {
|
|
200
205
|
readonly list: (params?: {
|
|
201
|
-
page?: number;
|
|
202
206
|
pageSize?: number;
|
|
207
|
+
pageToken?: string;
|
|
203
208
|
state?: string;
|
|
204
209
|
tradingPairId?: string;
|
|
205
210
|
}) => string;
|
|
@@ -219,17 +224,23 @@ export declare const perpRoutes: {
|
|
|
219
224
|
readonly transferOutParent: () => string;
|
|
220
225
|
readonly movements: (marginAccountId: string, params?: {
|
|
221
226
|
movementType?: string;
|
|
222
|
-
page?: number;
|
|
223
227
|
pageSize?: number;
|
|
228
|
+
pageToken?: string;
|
|
224
229
|
}) => string;
|
|
225
230
|
readonly parentMovements: (params?: {
|
|
226
231
|
movementType?: string;
|
|
227
|
-
page?: number;
|
|
228
232
|
pageSize?: number;
|
|
233
|
+
pageToken?: string;
|
|
229
234
|
}) => string;
|
|
230
235
|
readonly simulateParentMarginOrderRisk: () => string;
|
|
231
236
|
readonly simulateOrderRisk: (marginAccountId: string) => string;
|
|
232
237
|
readonly simulateRiskBucketOrderRisk: () => string;
|
|
238
|
+
readonly createSubAccount: () => string;
|
|
239
|
+
readonly closeSubAccount: (marginAccountId: string) => string;
|
|
240
|
+
readonly subAccountTransferIn: (marginAccountId: string) => string;
|
|
241
|
+
readonly subAccountTransferOut: (marginAccountId: string) => string;
|
|
242
|
+
readonly pnl: (marginAccountId: string) => string;
|
|
243
|
+
readonly transferCollateral: () => string;
|
|
233
244
|
};
|
|
234
245
|
readonly streams: {
|
|
235
246
|
readonly orderbook: () => string;
|
package/dist/api/perp/routes.js
CHANGED
|
@@ -119,6 +119,12 @@ export const perpRoutes = {
|
|
|
119
119
|
simulateParentMarginOrderRisk: () => `${API_V1}/margin/parent-margin-account/simulate-order-risk`,
|
|
120
120
|
simulateOrderRisk: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/simulate-order-risk`,
|
|
121
121
|
simulateRiskBucketOrderRisk: () => `${API_V1}/margin/risk-buckets/simulate-order-risk`,
|
|
122
|
+
createSubAccount: () => `${API_V1}/margin/sub-accounts`,
|
|
123
|
+
closeSubAccount: (marginAccountId) => `${API_V1}/margin/sub-accounts/${encodeSegment(marginAccountId)}/close`,
|
|
124
|
+
subAccountTransferIn: (marginAccountId) => `${API_V1}/margin/sub-accounts/${encodeSegment(marginAccountId)}/collateral/transfer-in`,
|
|
125
|
+
subAccountTransferOut: (marginAccountId) => `${API_V1}/margin/sub-accounts/${encodeSegment(marginAccountId)}/collateral/transfer-out`,
|
|
126
|
+
pnl: (marginAccountId) => `${API_V1}/margin/accounts/${encodeSegment(marginAccountId)}/pnl`,
|
|
127
|
+
transferCollateral: () => `${API_V1}/margin/collateral/transfer`,
|
|
122
128
|
},
|
|
123
129
|
streams: {
|
|
124
130
|
orderbook: () => `${API_V1}/streaming/orderbook`,
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* console.log(`Rewards remaining: ${result.rewardsBalance}`);
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
import type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetRewardsBalanceResponse, PitpassAPI, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
|
|
36
|
+
import type { GetMyReferralDownlineParams, GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, PitpassAPI, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
|
|
37
37
|
import { BaseAPI } from "../base";
|
|
38
38
|
export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
|
|
39
39
|
/**
|
|
@@ -77,15 +77,26 @@ export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
|
|
|
77
77
|
*/
|
|
78
78
|
transferRewards(params: TransferRewardsParams): Promise<TransferRewardsResponse>;
|
|
79
79
|
/**
|
|
80
|
-
* Read the caller's own referral position: their L1
|
|
81
|
-
* and recent rewards. Self-scoped — no id is sent,
|
|
82
|
-
* your own chain. `referrer` is ""
|
|
80
|
+
* Read the caller's own referral position: their upline (L1, L2, ...), their
|
|
81
|
+
* L1 referrer, total earned, and recent rewards. Self-scoped — no id is sent,
|
|
82
|
+
* so it can only ever return your own chain. `referrer` is "" and `upline` is
|
|
83
|
+
* empty when you were not referred.
|
|
83
84
|
*/
|
|
84
85
|
getMyReferralPosition(): Promise<GetMyReferralPositionResponse>;
|
|
85
86
|
/**
|
|
86
|
-
* Read the caller's own downline: earnings by source across
|
|
87
|
-
*
|
|
88
|
-
* per-level earnings summary
|
|
87
|
+
* Read the caller's own downline: one page of earnings by source across
|
|
88
|
+
* every reward level (largest first), the L1 direct-referee roster
|
|
89
|
+
* (including referees who haven't traded), and a per-level earnings summary
|
|
90
|
+
* covering every level and source. Without paging params the server returns
|
|
91
|
+
* the first page (100 rows); follow `nextPageToken` until it is empty.
|
|
92
|
+
* Self-scoped, read-only.
|
|
89
93
|
*/
|
|
90
|
-
getMyReferralDownline(): Promise<GetMyReferralDownlineResponse>;
|
|
94
|
+
getMyReferralDownline(params?: GetMyReferralDownlineParams): Promise<GetMyReferralDownlineResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Read one level of the caller's own referral tree: the wallets `parent`
|
|
97
|
+
* directly referred (the caller when omitted), a page at a time, newest
|
|
98
|
+
* first. `parent` must be the caller or one of their own referees above the
|
|
99
|
+
* deepest rewarded level; any other wallet is a 404.
|
|
100
|
+
*/
|
|
101
|
+
getMyReferralTree(params?: GetMyReferralTreeParams): Promise<GetMyReferralTreeResponse>;
|
|
91
102
|
}
|
package/dist/api/pitpass/api.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* console.log(`Rewards remaining: ${result.rewardsBalance}`);
|
|
34
34
|
* ```
|
|
35
35
|
*/
|
|
36
|
-
import { SetTraderCodeParamsSchema, TransferRewardsParamsSchema, validate } from "@0xmonaco/types";
|
|
36
|
+
import { GetMyReferralDownlineParamsSchema, GetMyReferralTreeParamsSchema, SetTraderCodeParamsSchema, TransferRewardsParamsSchema, validate, } from "@0xmonaco/types";
|
|
37
37
|
import { BaseAPI } from "../base";
|
|
38
38
|
export class PitpassAPIImpl extends BaseAPI {
|
|
39
39
|
/**
|
|
@@ -109,9 +109,10 @@ export class PitpassAPIImpl extends BaseAPI {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
|
-
* Read the caller's own referral position: their L1
|
|
113
|
-
* and recent rewards. Self-scoped — no id is sent,
|
|
114
|
-
* your own chain. `referrer` is ""
|
|
112
|
+
* Read the caller's own referral position: their upline (L1, L2, ...), their
|
|
113
|
+
* L1 referrer, total earned, and recent rewards. Self-scoped — no id is sent,
|
|
114
|
+
* so it can only ever return your own chain. `referrer` is "" and `upline` is
|
|
115
|
+
* empty when you were not referred.
|
|
115
116
|
*/
|
|
116
117
|
async getMyReferralPosition() {
|
|
117
118
|
return await this.makeAuthenticatedRequest("/api/v1/pitpass/referrals/me", {
|
|
@@ -119,13 +120,50 @@ export class PitpassAPIImpl extends BaseAPI {
|
|
|
119
120
|
});
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
|
-
* Read the caller's own downline: earnings by source across
|
|
123
|
-
*
|
|
124
|
-
* per-level earnings summary
|
|
123
|
+
* Read the caller's own downline: one page of earnings by source across
|
|
124
|
+
* every reward level (largest first), the L1 direct-referee roster
|
|
125
|
+
* (including referees who haven't traded), and a per-level earnings summary
|
|
126
|
+
* covering every level and source. Without paging params the server returns
|
|
127
|
+
* the first page (100 rows); follow `nextPageToken` until it is empty.
|
|
128
|
+
* Self-scoped, read-only.
|
|
125
129
|
*/
|
|
126
|
-
async getMyReferralDownline() {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
+
async getMyReferralDownline(params) {
|
|
131
|
+
if (params) {
|
|
132
|
+
validate(GetMyReferralDownlineParamsSchema, params);
|
|
133
|
+
}
|
|
134
|
+
const searchParams = new URLSearchParams();
|
|
135
|
+
if (params?.pageSize !== undefined) {
|
|
136
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
137
|
+
}
|
|
138
|
+
if (params?.pageToken !== undefined) {
|
|
139
|
+
searchParams.append("pageToken", params.pageToken);
|
|
140
|
+
}
|
|
141
|
+
const query = searchParams.toString();
|
|
142
|
+
const path = query ? `/api/v1/pitpass/referrals/me/downline?${query}` : "/api/v1/pitpass/referrals/me/downline";
|
|
143
|
+
return await this.makeAuthenticatedRequest(path, { method: "GET" });
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Read one level of the caller's own referral tree: the wallets `parent`
|
|
147
|
+
* directly referred (the caller when omitted), a page at a time, newest
|
|
148
|
+
* first. `parent` must be the caller or one of their own referees above the
|
|
149
|
+
* deepest rewarded level; any other wallet is a 404.
|
|
150
|
+
*/
|
|
151
|
+
async getMyReferralTree(params) {
|
|
152
|
+
if (params) {
|
|
153
|
+
validate(GetMyReferralTreeParamsSchema, params);
|
|
154
|
+
}
|
|
155
|
+
const searchParams = new URLSearchParams();
|
|
156
|
+
if (params?.parent !== undefined) {
|
|
157
|
+
searchParams.append("parent", params.parent);
|
|
158
|
+
}
|
|
159
|
+
if (params?.pageSize !== undefined) {
|
|
160
|
+
searchParams.append("pageSize", params.pageSize.toString());
|
|
161
|
+
}
|
|
162
|
+
if (params?.pageToken !== undefined) {
|
|
163
|
+
searchParams.append("pageToken", params.pageToken);
|
|
164
|
+
}
|
|
165
|
+
const query = searchParams.toString();
|
|
166
|
+
const path = query ? `/api/v1/pitpass/referrals/me/tree?${query}` : "/api/v1/pitpass/referrals/me/tree";
|
|
167
|
+
return await this.makeAuthenticatedRequest(path, { method: "GET" });
|
|
130
168
|
}
|
|
131
169
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { PortfolioAPI, PortfolioAssets, PortfolioMargin, PortfolioPerformance, PortfolioPeriodParams, PortfolioRealizedPnl, PortfolioSummary } from "@0xmonaco/types";
|
|
1
|
+
import type { PortfolioAPI, PortfolioAssets, PortfolioMargin, PortfolioMarginParams, PortfolioPerformance, PortfolioPeriodParams, PortfolioRealizedPnl, PortfolioSummary } from "@0xmonaco/types";
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
export declare class PortfolioAPIImpl extends BaseAPI implements PortfolioAPI {
|
|
4
4
|
getSummary(params?: PortfolioPeriodParams): Promise<PortfolioSummary>;
|
|
5
5
|
getPerformance(params?: PortfolioPeriodParams): Promise<PortfolioPerformance>;
|
|
6
6
|
getRealizedPnl(params?: PortfolioPeriodParams): Promise<PortfolioRealizedPnl>;
|
|
7
7
|
getAssets(params?: PortfolioPeriodParams): Promise<PortfolioAssets>;
|
|
8
|
-
getMargin(): Promise<PortfolioMargin>;
|
|
8
|
+
getMargin(params?: PortfolioMarginParams): Promise<PortfolioMargin>;
|
|
9
9
|
}
|
|
@@ -19,7 +19,16 @@ export class PortfolioAPIImpl extends BaseAPI {
|
|
|
19
19
|
async getAssets(params) {
|
|
20
20
|
return await this.makeAuthenticatedRequest(withPeriod(`${BASE_PATH}/assets`, params));
|
|
21
21
|
}
|
|
22
|
-
async getMargin() {
|
|
23
|
-
|
|
22
|
+
async getMargin(params) {
|
|
23
|
+
const query = new URLSearchParams();
|
|
24
|
+
if (params?.marginAccountId) {
|
|
25
|
+
query.set("marginAccountId", params.marginAccountId);
|
|
26
|
+
}
|
|
27
|
+
if (params?.includeAccounts !== undefined) {
|
|
28
|
+
query.set("includeAccounts", String(params.includeAccounts));
|
|
29
|
+
}
|
|
30
|
+
const search = query.toString();
|
|
31
|
+
const suffix = search ? `?${search}` : "";
|
|
32
|
+
return await this.makeAuthenticatedRequest(`${BASE_PATH}/margin${suffix}`);
|
|
24
33
|
}
|
|
25
34
|
}
|
|
@@ -2,10 +2,19 @@ import type { AttachPositionTpSlRequest, AttachPositionTpSlResponse, BatchCloseA
|
|
|
2
2
|
import { BaseAPI } from "../base";
|
|
3
3
|
export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
|
|
4
4
|
/**
|
|
5
|
-
* List the caller's positions
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* List the caller's positions, cursor paged (0XM-2788): omit `pageToken` or
|
|
6
|
+
* pass `""` to start, then follow `nextPageToken` until it comes back
|
|
7
|
+
* empty. There is no `page` — sending one is a `400`.
|
|
8
|
+
*
|
|
9
|
+
* `total` is bounded by the server count ceiling; `totalCapped` is `true`
|
|
10
|
+
* when more than that matched, so it is a lower bound. Do not drive a
|
|
11
|
+
* paging loop off it — follow `nextPageToken`.
|
|
12
|
+
*
|
|
13
|
+
* Order depends on the filter: `status: "OPEN"` is served from the engine's
|
|
14
|
+
* live view in `(marginAccountId, tradingPairId, positionId)` order, every
|
|
15
|
+
* other filter from persisted rows newest-opened first. The two are
|
|
16
|
+
* separate cursor spaces, so a token is only valid in the one that minted
|
|
17
|
+
* it.
|
|
9
18
|
*/
|
|
10
19
|
listPositions(params?: ListPositionsParams): Promise<ListPositionsResponse>;
|
|
11
20
|
getPosition(positionId: string): Promise<GetPositionResponse>;
|
|
@@ -14,10 +23,13 @@ export declare class PositionsAPIImpl extends BaseAPI implements PositionsAPI {
|
|
|
14
23
|
getPositionRisk(positionId: string): Promise<PositionRisk>;
|
|
15
24
|
attachPositionTpSl(positionId: string, request: AttachPositionTpSlRequest): Promise<AttachPositionTpSlResponse>;
|
|
16
25
|
/**
|
|
17
|
-
* List the caller's position-history events
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
26
|
+
* List the caller's position-history events, cursor paged (0XM-2788): omit
|
|
27
|
+
* `pageToken` or pass `""` to start, then follow `nextPageToken` until it
|
|
28
|
+
* comes back empty. There is no `page` — sending one is a `400`.
|
|
29
|
+
*
|
|
30
|
+
* The response carries no item count: this listing spans the hot table and
|
|
31
|
+
* the archive, so counting behind a filter would walk the caller's whole
|
|
32
|
+
* lifetime prefix on every page.
|
|
21
33
|
*/
|
|
22
34
|
listPositionHistory(params?: ListPositionHistoryParams): Promise<ListPositionHistoryResponse>;
|
|
23
35
|
getPositionPnlHistory(positionId: string, params: GetPositionPnlHistoryParams): Promise<GetPositionPnlHistoryResponse>;
|
|
@@ -3,10 +3,19 @@ import { BaseAPI } from "../base";
|
|
|
3
3
|
import { perpRoutes } from "../perp";
|
|
4
4
|
export class PositionsAPIImpl extends BaseAPI {
|
|
5
5
|
/**
|
|
6
|
-
* List the caller's positions
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* List the caller's positions, cursor paged (0XM-2788): omit `pageToken` or
|
|
7
|
+
* pass `""` to start, then follow `nextPageToken` until it comes back
|
|
8
|
+
* empty. There is no `page` — sending one is a `400`.
|
|
9
|
+
*
|
|
10
|
+
* `total` is bounded by the server count ceiling; `totalCapped` is `true`
|
|
11
|
+
* when more than that matched, so it is a lower bound. Do not drive a
|
|
12
|
+
* paging loop off it — follow `nextPageToken`.
|
|
13
|
+
*
|
|
14
|
+
* Order depends on the filter: `status: "OPEN"` is served from the engine's
|
|
15
|
+
* live view in `(marginAccountId, tradingPairId, positionId)` order, every
|
|
16
|
+
* other filter from persisted rows newest-opened first. The two are
|
|
17
|
+
* separate cursor spaces, so a token is only valid in the one that minted
|
|
18
|
+
* it.
|
|
10
19
|
*/
|
|
11
20
|
async listPositions(params) {
|
|
12
21
|
if (params) {
|
|
@@ -90,10 +99,13 @@ export class PositionsAPIImpl extends BaseAPI {
|
|
|
90
99
|
});
|
|
91
100
|
}
|
|
92
101
|
/**
|
|
93
|
-
* List the caller's position-history events
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
102
|
+
* List the caller's position-history events, cursor paged (0XM-2788): omit
|
|
103
|
+
* `pageToken` or pass `""` to start, then follow `nextPageToken` until it
|
|
104
|
+
* comes back empty. There is no `page` — sending one is a `400`.
|
|
105
|
+
*
|
|
106
|
+
* The response carries no item count: this listing spans the hot table and
|
|
107
|
+
* the archive, so counting behind a filter would walk the caller's whole
|
|
108
|
+
* lifetime prefix on every page.
|
|
97
109
|
*/
|
|
98
110
|
async listPositionHistory(params) {
|
|
99
111
|
if (params) {
|
|
@@ -50,14 +50,19 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
50
50
|
* Fetches the user's transaction history from the /api/v1/accounts/movements endpoint.
|
|
51
51
|
* Requires a valid access token to be set.
|
|
52
52
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
53
|
+
* Cursor paged (0XM-2788/0XM-2820): omit `pageToken` or pass `""` to start,
|
|
54
|
+
* then follow `nextPageToken` from each response until it comes back empty.
|
|
55
|
+
* There is no `page` — sending one is a `400`.
|
|
56
|
+
*
|
|
57
|
+
* The response `total` and `totalPages` are bounded by the server count
|
|
58
|
+
* ceiling; `totalCapped` is `true` when more than that matched, so `total`
|
|
59
|
+
* is a lower bound. Do not drive a paging loop off `total`: a user past the
|
|
60
|
+
* ceiling would stop early. Follow `nextPageToken`.
|
|
57
61
|
*
|
|
58
62
|
* @param params - Optional query parameters for pagination and filtering
|
|
59
|
-
* @param params.
|
|
60
|
-
* @param params.
|
|
63
|
+
* @param params.pageToken - Cursor from a previous response's `nextPageToken`
|
|
64
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 1000)
|
|
65
|
+
* @param params.orderBy - Sort direction for `createdAt` (default: `"DESC"`)
|
|
61
66
|
* @param params.entryType - Filter by entry type (CREDIT, DEBIT, LOCK, UNLOCK, FEE)
|
|
62
67
|
* @param params.transactionType - Filter by transaction type (DEPOSIT, WITHDRAWAL, TRADE, FEE, FUNDING, LIQUIDATION, INTEREST, REWARD)
|
|
63
68
|
* @param params.assetId - Filter by asset ID (UUID)
|
|
@@ -70,9 +75,14 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
70
75
|
* const movements = await profileAPI.getPaginatedUserMovements();
|
|
71
76
|
* console.log(`Total movements: ${movements.total}`);
|
|
72
77
|
*
|
|
73
|
-
* //
|
|
74
|
-
*
|
|
75
|
-
*
|
|
78
|
+
* // Walk every page
|
|
79
|
+
* let pageToken = "";
|
|
80
|
+
* for (;;) {
|
|
81
|
+
* const page = await profileAPI.getPaginatedUserMovements({ pageToken, pageSize: 50 });
|
|
82
|
+
* console.log(page.movements.length);
|
|
83
|
+
* if (page.nextPageToken === "") break;
|
|
84
|
+
* pageToken = page.nextPageToken;
|
|
85
|
+
* }
|
|
76
86
|
*
|
|
77
87
|
* // Filter by entry type and transaction type
|
|
78
88
|
* const deposits = await profileAPI.getPaginatedUserMovements({ entryType: "CREDIT", transactionType: "DEPOSIT" });
|
|
@@ -88,9 +98,13 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
88
98
|
* Fetches the user's token balances from the /api/v1/accounts/balances endpoint.
|
|
89
99
|
* Requires a valid access token to be set.
|
|
90
100
|
*
|
|
101
|
+
* Cursor paged (0XM-2788/0XM-2821): omit `pageToken` or pass `""` to start,
|
|
102
|
+
* then follow `nextPageToken` until it comes back empty. There is no `page`
|
|
103
|
+
* — sending one is a `400`.
|
|
104
|
+
*
|
|
91
105
|
* @param params - Optional query parameters for pagination
|
|
92
|
-
* @param params.
|
|
93
|
-
* @param params.pageSize - Number of items per page (default: 20, max:
|
|
106
|
+
* @param params.pageToken - Cursor from a previous response's `nextPageToken`
|
|
107
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 1000)
|
|
94
108
|
* @returns Promise resolving to paginated balances response
|
|
95
109
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
96
110
|
*
|
|
@@ -103,9 +117,14 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
103
117
|
* console.log(`${balance.symbol}: ${balance.availableBalance}`);
|
|
104
118
|
* });
|
|
105
119
|
*
|
|
106
|
-
* //
|
|
107
|
-
*
|
|
108
|
-
*
|
|
120
|
+
* // Walk every page
|
|
121
|
+
* let pageToken = "";
|
|
122
|
+
* for (;;) {
|
|
123
|
+
* const page = await profileAPI.getUserBalances({ pageToken, pageSize: 50 });
|
|
124
|
+
* console.log(page.balances.length);
|
|
125
|
+
* if (page.nextPageToken === "") break;
|
|
126
|
+
* pageToken = page.nextPageToken;
|
|
127
|
+
* }
|
|
109
128
|
* ```
|
|
110
129
|
*/
|
|
111
130
|
getUserBalances(params?: GetUserBalancesParams): Promise<GetUserBalancesResponse>;
|
|
@@ -233,12 +252,21 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
233
252
|
* Fetches funding payments from the /api/v1/accounts/funding-payments endpoint.
|
|
234
253
|
* Requires a valid access token to be set.
|
|
235
254
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
255
|
+
* Cursor paged (0XM-2788/0XM-2818): omit `pageToken` or pass `""` to start,
|
|
256
|
+
* then follow `nextPageToken` from each response until it comes back empty.
|
|
257
|
+
* There is no `page` — sending one is a `400`.
|
|
258
|
+
*
|
|
259
|
+
* The response `total` and `totalPages` are bounded by the server count
|
|
260
|
+
* ceiling; `totalCapped` is `true` when more than that matched, so `total`
|
|
261
|
+
* is a lower bound. Do not drive a paging loop off `total`: a user past the
|
|
262
|
+
* ceiling would stop early. Follow `nextPageToken`.
|
|
240
263
|
*
|
|
241
264
|
* @param params - Optional query parameters for pagination and filtering
|
|
265
|
+
* @param params.pageToken - Cursor from a previous response's `nextPageToken`
|
|
266
|
+
* @param params.pageSize - Number of items per page (default: 20, max: 1000)
|
|
267
|
+
* @param params.tradingPairId - Filter by trading pair ID (UUID)
|
|
268
|
+
* @param params.positionId - Filter by margin position ID (UUID)
|
|
269
|
+
* @param params.marginAccountId - Filter by margin account ID (UUID)
|
|
242
270
|
* @returns Promise resolving to paginated funding payments response
|
|
243
271
|
* @throws {APIError} When the request fails or user is not authenticated
|
|
244
272
|
*
|
|
@@ -246,6 +274,15 @@ export declare class ProfileAPIImpl extends BaseAPI implements ProfileAPI {
|
|
|
246
274
|
* ```typescript
|
|
247
275
|
* const funding = await profileAPI.listFundingPayments({ tradingPairId: "550e8400-e29b-41d4-a716-446655440000" });
|
|
248
276
|
* console.log(`Total funding payments: ${funding.total}`);
|
|
277
|
+
*
|
|
278
|
+
* // Walk every page
|
|
279
|
+
* let pageToken = "";
|
|
280
|
+
* for (;;) {
|
|
281
|
+
* const page = await profileAPI.listFundingPayments({ pageToken, pageSize: 100 });
|
|
282
|
+
* console.log(page.records.length);
|
|
283
|
+
* if (page.nextPageToken === "") break;
|
|
284
|
+
* pageToken = page.nextPageToken;
|
|
285
|
+
* }
|
|
249
286
|
* ```
|
|
250
287
|
*/
|
|
251
288
|
listFundingPayments(params?: ListFundingPaymentsParams): Promise<ListFundingPaymentsResponse>;
|