@0xmonaco/types 1.0.70 → 1.0.73-develop.af0f5d0
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/dist/auth/index.d.ts +4 -2
- package/dist/auth/responses.d.ts +3 -1
- package/dist/buildercodes/index.d.ts +7 -3
- package/dist/buildercodes/index.js +1 -1
- package/dist/buildercodes/responses.d.ts +59 -3
- package/dist/buildercodes/responses.js +38 -3
- package/dist/copy-trading/index.d.ts +54 -6
- package/dist/copy-trading/index.js +1 -1
- package/dist/copy-trading/responses.d.ts +43 -0
- package/dist/copy-trading/responses.js +49 -0
- package/dist/delegated-agents/index.d.ts +16 -4
- package/dist/fees/index.d.ts +3 -0
- package/dist/fees/responses.js +4 -4
- package/dist/margin-accounts/index.d.ts +114 -10
- package/dist/pitpass/index.d.ts +21 -6
- package/dist/pitpass/index.js +1 -1
- package/dist/pitpass/responses.d.ts +46 -0
- package/dist/pitpass/responses.js +56 -1
- package/dist/portfolio/index.d.ts +36 -14
- package/dist/trading/orders.d.ts +1 -1
- package/dist/trading/responses.d.ts +18 -6
- package/dist/validation/copy-trading.d.ts +11 -0
- package/dist/validation/copy-trading.js +15 -0
- package/dist/validation/margin-accounts.d.ts +34 -0
- package/dist/validation/margin-accounts.js +40 -0
- package/dist/websocket/events/liquidation-events.d.ts +3 -3
- package/dist/websocket/events/orders-events.d.ts +6 -0
- package/dist/websocket/events/position-events.d.ts +24 -17
- package/dist/websocket/events/twap-order-events.d.ts +7 -0
- package/dist/wire/operations.d.ts +1 -1
- package/dist/wire/operations.js +10 -0
- package/dist/wire/schema.d.ts +1446 -105
- package/package.json +2 -2
|
@@ -9,7 +9,17 @@ export interface MarginAccountSummary {
|
|
|
9
9
|
selectedTradingPairIds?: string[];
|
|
10
10
|
tradingPairId?: string;
|
|
11
11
|
strategyKey?: string;
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The risk bucket's lifecycle state: `NORMAL`, `PENDING_LIQUIDATION`,
|
|
14
|
+
* `LIQUIDATING`, `BAD_DEBT` or `CLOSED`. Present only on risk-bucket rows —
|
|
15
|
+
* a parent margin account has no lifecycle of its own; liquidation and bad
|
|
16
|
+
* debt live in its risk buckets.
|
|
17
|
+
*/
|
|
18
|
+
riskBucketState?: string;
|
|
19
|
+
/** The margin account's sub-account key; `default` is the default margin account. */
|
|
20
|
+
subaccountKey?: string;
|
|
21
|
+
/** The margin account's state: `ACTIVE`, or `CLOSED` for a closed sub-account. */
|
|
22
|
+
marginAccountState?: string;
|
|
13
23
|
equity: string;
|
|
14
24
|
initialMarginRequired: string;
|
|
15
25
|
maintenanceMarginRequired: string;
|
|
@@ -19,13 +29,20 @@ export interface MarginAccountSummary {
|
|
|
19
29
|
* The largest amount a transfer-out of this scope will actually accept.
|
|
20
30
|
*
|
|
21
31
|
* Not a clamped `freeCollateral`. Free collateral is equity headroom, and
|
|
22
|
-
* equity includes
|
|
23
|
-
*
|
|
24
|
-
*
|
|
32
|
+
* equity includes mark-to-market gains that a transfer cannot move — so the
|
|
33
|
+
* two can differ without limit. An unrealized gain never counts toward this
|
|
34
|
+
* figure.
|
|
25
35
|
*
|
|
26
|
-
* For a risk bucket this is
|
|
27
|
-
*
|
|
28
|
-
*
|
|
36
|
+
* For a risk bucket this is the bucket's allocated collateral plus its
|
|
37
|
+
* realized PnL, less what its positions and resting orders require (the
|
|
38
|
+
* bucket's allocation may go negative, which is how realized profit leaves
|
|
39
|
+
* a live bucket); for a parent margin account, net deposits plus settled
|
|
40
|
+
* realized PnL that no risk bucket has allocated. Every smaller amount is
|
|
41
|
+
* accepted too. It is zero on a risk bucket that is not `NORMAL` (under
|
|
42
|
+
* liquidation or frozen as bad debt) and on one whose realized loss has used
|
|
43
|
+
* up its allocation; the parent margin account is charged at most a risk
|
|
44
|
+
* bucket's allocation. Size transfers against this field, not
|
|
45
|
+
* `freeCollateral`.
|
|
29
46
|
*/
|
|
30
47
|
withdrawableCollateral: string;
|
|
31
48
|
totalPositionNotional: string;
|
|
@@ -90,6 +107,11 @@ export interface MarginAccountSummary {
|
|
|
90
107
|
export interface ListMarginAccountsParams {
|
|
91
108
|
page?: number;
|
|
92
109
|
pageSize?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Keep only risk-bucket rows in this state (see
|
|
112
|
+
* {@link MarginAccountSummary.riskBucketState}). A parent margin account row
|
|
113
|
+
* has no state, so any filter excludes it.
|
|
114
|
+
*/
|
|
93
115
|
state?: string;
|
|
94
116
|
tradingPairId?: string;
|
|
95
117
|
}
|
|
@@ -118,13 +140,13 @@ export interface GetAvailableCollateralResponse {
|
|
|
118
140
|
* margin account yet.
|
|
119
141
|
*
|
|
120
142
|
* This is **not** trading headroom for existing cross exposure. It is
|
|
121
|
-
* bounded by allocation (
|
|
122
|
-
* as by margin requirements, and an unrealized gain does not raise it: a
|
|
143
|
+
* bounded by allocation (net deposits plus settled realized PnL not
|
|
144
|
+
* allocated to risk buckets) as well as by margin requirements, and an unrealized gain does not raise it: a
|
|
123
145
|
* mark-to-market gain is initial margin against existing cross exposure but
|
|
124
146
|
* may not fund an exit. `MarginAccountSummary.freeCollateral` credits that
|
|
125
147
|
* gain in full and remains the trading-margin headroom for existing cross
|
|
126
148
|
* exposure — but a **new** isolated or first-use position allocates
|
|
127
|
-
*
|
|
149
|
+
* collateral through the same gate this field measures, so size those from
|
|
128
150
|
* this field.
|
|
129
151
|
*
|
|
130
152
|
* Note the two `margin*` fields answer opposite questions:
|
|
@@ -158,6 +180,8 @@ export interface TransferCollateralToParentMarginAccountRequest {
|
|
|
158
180
|
*/
|
|
159
181
|
export interface TransferCollateralToIsolatedRiskBucketRequest extends TransferCollateralToParentMarginAccountRequest {
|
|
160
182
|
marginMode?: "ISOLATED";
|
|
183
|
+
/** The margin account whose bucket is funded: omit for the default account, or name an open sub-account. */
|
|
184
|
+
marginAccountId?: string;
|
|
161
185
|
tradingPairId: string;
|
|
162
186
|
strategyKey?: string;
|
|
163
187
|
selectedTradingPairIds?: never;
|
|
@@ -192,6 +216,8 @@ export interface TransferCollateralToIsolatedRiskBucketRequest extends TransferC
|
|
|
192
216
|
*/
|
|
193
217
|
export interface TransferCollateralToCrossRiskBucketRequest extends TransferCollateralToParentMarginAccountRequest {
|
|
194
218
|
marginMode: "CROSS";
|
|
219
|
+
/** The margin account whose cross bucket is funded: omit for the default account, or name an open sub-account. */
|
|
220
|
+
marginAccountId?: string;
|
|
195
221
|
/**
|
|
196
222
|
* Removed. This used to declare — and on every top-up REPLACE — the cross
|
|
197
223
|
* bucket's scope, which let a partial list silently evict every flat pair it
|
|
@@ -291,6 +317,8 @@ export interface SimulateOrderRiskRequest {
|
|
|
291
317
|
}
|
|
292
318
|
export type SimulateIsolatedRiskBucketOrderRiskRequest = SimulateOrderRiskRequest & {
|
|
293
319
|
marginMode?: "ISOLATED";
|
|
320
|
+
/** The margin account previewed: omit for the default account, or name an open sub-account. */
|
|
321
|
+
marginAccountId?: string;
|
|
294
322
|
strategyKey?: string;
|
|
295
323
|
selectedTradingPairIds?: never;
|
|
296
324
|
};
|
|
@@ -305,6 +333,8 @@ export type SimulateIsolatedRiskBucketOrderRiskRequest = SimulateOrderRiskReques
|
|
|
305
333
|
*/
|
|
306
334
|
export type SimulateCrossRiskBucketOrderRiskRequest = SimulateOrderRiskRequest & {
|
|
307
335
|
marginMode: "CROSS";
|
|
336
|
+
/** The margin account previewed: omit for the default account, or name an open sub-account. */
|
|
337
|
+
marginAccountId?: string;
|
|
308
338
|
/**
|
|
309
339
|
* Removed. This used to declare the scope the preview ran against (required,
|
|
310
340
|
* containing `tradingPairId`, covering every open cross position) while the
|
|
@@ -416,7 +446,81 @@ export interface SimulateOrderRiskResponse {
|
|
|
416
446
|
*/
|
|
417
447
|
referencePrice?: string;
|
|
418
448
|
}
|
|
449
|
+
/**
|
|
450
|
+
* Open a margin sub-account: another margin account of the caller, keyed by
|
|
451
|
+
* `subaccountKey`, with its own collateral and risk buckets. Keys are up to 64
|
|
452
|
+
* letters, digits, `_`, `-`, `.` or `:`; `copy:` keys are reserved and
|
|
453
|
+
* `default` names the default margin account. Re-creating the key of a closed
|
|
454
|
+
* sub-account re-opens it.
|
|
455
|
+
*/
|
|
456
|
+
export interface CreateMarginSubAccountRequest {
|
|
457
|
+
subaccountKey: string;
|
|
458
|
+
label?: string;
|
|
459
|
+
}
|
|
460
|
+
export interface CreateMarginSubAccountResponse {
|
|
461
|
+
marginAccountId: string;
|
|
462
|
+
subaccountKey: string;
|
|
463
|
+
marginAccountState: string;
|
|
464
|
+
label?: string;
|
|
465
|
+
}
|
|
466
|
+
/** One margin account's own PnL (default or sub-account); the owner's accounts sum to the owner-wide figure. */
|
|
467
|
+
export interface MarginAccountPnl {
|
|
468
|
+
marginAccountId: string;
|
|
469
|
+
/** Settled on the account plus still held in its open risk buckets. */
|
|
470
|
+
realizedPnl: string;
|
|
471
|
+
/** The account's open positions repriced at the latest risk marks. */
|
|
472
|
+
unrealizedPnl: string;
|
|
473
|
+
}
|
|
474
|
+
export interface CloseMarginSubAccountResponse {
|
|
475
|
+
marginAccountId: string;
|
|
476
|
+
/** The default margin account that received the remaining collateral. */
|
|
477
|
+
defaultMarginAccountId: string;
|
|
478
|
+
/** Collateral moved to the default margin account. */
|
|
479
|
+
amount: string;
|
|
480
|
+
}
|
|
481
|
+
/** One side of a collateral transfer: the spot wallet, or a margin account. */
|
|
482
|
+
export type CollateralTransferEndpoint = {
|
|
483
|
+
wallet: true;
|
|
484
|
+
marginAccountId?: never;
|
|
485
|
+
riskBucketId?: never;
|
|
486
|
+
} | {
|
|
487
|
+
wallet?: never;
|
|
488
|
+
marginAccountId: string;
|
|
489
|
+
riskBucketId?: string;
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* Move collateral between the spot wallet and the caller's margin accounts.
|
|
493
|
+
* Supported: wallet to the default margin account and back, and margin
|
|
494
|
+
* account to margin account.
|
|
495
|
+
*/
|
|
496
|
+
export interface TransferMarginCollateralRequest {
|
|
497
|
+
asset: string;
|
|
498
|
+
amount: string;
|
|
499
|
+
from: CollateralTransferEndpoint;
|
|
500
|
+
to: CollateralTransferEndpoint;
|
|
501
|
+
}
|
|
502
|
+
export interface TransferMarginCollateralResponse {
|
|
503
|
+
movementId: string;
|
|
504
|
+
amount: string;
|
|
505
|
+
fromMarginAccountId?: string;
|
|
506
|
+
toMarginAccountId?: string;
|
|
507
|
+
toRiskBucketId?: string;
|
|
508
|
+
}
|
|
419
509
|
export interface MarginAccountsAPI extends BaseAPI {
|
|
510
|
+
/**
|
|
511
|
+
* Open a margin sub-account. Refused past the owner's cap on open sub-accounts (10 at the
|
|
512
|
+
* first volume tier, up to 50, or an admin override); copy-trading sub-accounts do not count.
|
|
513
|
+
*/
|
|
514
|
+
createMarginSubAccount(request: CreateMarginSubAccountRequest): Promise<CreateMarginSubAccountResponse>;
|
|
515
|
+
/**
|
|
516
|
+
* Close a flat margin sub-account in one call: its flat, solvent risk buckets close and all of
|
|
517
|
+
* its collateral moves to the default margin account. A risk bucket in liquidation or bad debt
|
|
518
|
+
* refuses the close.
|
|
519
|
+
*/
|
|
520
|
+
closeMarginSubAccount(marginAccountId: string): Promise<CloseMarginSubAccountResponse>;
|
|
521
|
+
/** One of the caller's margin accounts' own realized and unrealized PnL. */
|
|
522
|
+
getMarginAccountPnl(marginAccountId: string): Promise<MarginAccountPnl>;
|
|
523
|
+
transferMarginCollateral(request: TransferMarginCollateralRequest): Promise<TransferMarginCollateralResponse>;
|
|
420
524
|
listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
|
|
421
525
|
getParentMarginAccountSummary(params?: GetMarginAccountSummaryParams): Promise<MarginAccountSummary>;
|
|
422
526
|
/**
|
package/dist/pitpass/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Types for PitPass TraderCode API: code lookup, rewards balance, and transfer.
|
|
5
5
|
*/
|
|
6
6
|
import type { BaseAPI } from "../api";
|
|
7
|
-
import type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetRewardsBalanceResponse, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "./responses";
|
|
7
|
+
import type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "./responses";
|
|
8
8
|
/**
|
|
9
9
|
* PitPass TraderCode API interface.
|
|
10
10
|
*
|
|
@@ -92,8 +92,9 @@ export interface PitpassAPI extends BaseAPI {
|
|
|
92
92
|
*/
|
|
93
93
|
transferRewards(params: TransferRewardsParams): Promise<TransferRewardsResponse>;
|
|
94
94
|
/**
|
|
95
|
-
* Read your own referral position: your
|
|
96
|
-
* and most recent
|
|
95
|
+
* Read your own referral position: your referral chain upward (`upline`, L1
|
|
96
|
+
* then L2 then L3), your direct referrer, total earned, and most recent
|
|
97
|
+
* reward rows.
|
|
97
98
|
*
|
|
98
99
|
* Self-scoped — the server derives your identity from the session, so you can
|
|
99
100
|
* only ever read your own chain. `referrer` is the empty string when you were
|
|
@@ -101,7 +102,7 @@ export interface PitpassAPI extends BaseAPI {
|
|
|
101
102
|
* identified by their public wallet address (with a `display` handle-or-wallet
|
|
102
103
|
* variant), never an internal id.
|
|
103
104
|
*
|
|
104
|
-
* @returns Promise resolving to your referrer, total earned, and recent rewards
|
|
105
|
+
* @returns Promise resolving to your upline, referrer, total earned, and recent rewards
|
|
105
106
|
*/
|
|
106
107
|
getMyReferralPosition(): Promise<GetMyReferralPositionResponse>;
|
|
107
108
|
/**
|
|
@@ -115,6 +116,20 @@ export interface PitpassAPI extends BaseAPI {
|
|
|
115
116
|
* @returns Promise resolving to earnings-by-source, the direct-referee roster, and a summary
|
|
116
117
|
*/
|
|
117
118
|
getMyReferralDownline(): Promise<GetMyReferralDownlineResponse>;
|
|
119
|
+
/**
|
|
120
|
+
* Read one level of your own referral tree: the wallets `parent` directly
|
|
121
|
+
* referred (yourself when `parent` is omitted), a page at a time, newest
|
|
122
|
+
* first. Expand a node by calling again with `parent` set to its wallet;
|
|
123
|
+
* nodes with `refereeCount > 0` are expandable, down to level 3.
|
|
124
|
+
*
|
|
125
|
+
* Self-scoped: `parent` must be you or one of your own L1/L2 referees — any
|
|
126
|
+
* other wallet is a 404. Each wallet appears once, under the referrer that
|
|
127
|
+
* earns from it.
|
|
128
|
+
*
|
|
129
|
+
* @param params - Optional `parent` wallet, `pageSize` (1-200), and `pageToken`
|
|
130
|
+
* @returns Promise resolving to the page of nodes and the next page token
|
|
131
|
+
*/
|
|
132
|
+
getMyReferralTree(params?: GetMyReferralTreeParams): Promise<GetMyReferralTreeResponse>;
|
|
118
133
|
}
|
|
119
|
-
export type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetRewardsBalanceResponse, ReferralDirectReferee, ReferralEarningsSource, ReferralEarningsSummary, ReferralRewardEntry, RewardsBalanceEntry, SetTraderCodeParams, TraderCodeAvailabilityReason, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse, } from "./responses";
|
|
120
|
-
export { GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetRewardsBalanceResponseSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
|
|
134
|
+
export type { GetMyReferralDownlineResponse, GetMyReferralPositionResponse, GetMyReferralTreeParams, GetMyReferralTreeResponse, GetRewardsBalanceResponse, ReferralDirectReferee, ReferralEarningsSource, ReferralEarningsSummary, ReferralRewardEntry, ReferralTreeNode, ReferralUplineEntry, RewardsBalanceEntry, SetTraderCodeParams, TraderCodeAvailabilityReason, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse, } from "./responses";
|
|
135
|
+
export { GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetMyReferralTreeParamsSchema, GetMyReferralTreeResponseSchema, GetRewardsBalanceResponseSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, ReferralTreeNodeSchema, ReferralUplineEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
|
package/dist/pitpass/index.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Types for PitPass TraderCode API: code lookup, rewards balance, and transfer.
|
|
5
5
|
*/
|
|
6
|
-
export { GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetRewardsBalanceResponseSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
|
|
6
|
+
export { GetMyReferralDownlineResponseSchema, GetMyReferralPositionResponseSchema, GetMyReferralTreeParamsSchema, GetMyReferralTreeResponseSchema, GetRewardsBalanceResponseSchema, ReferralDirectRefereeSchema, ReferralEarningsSourceSchema, ReferralEarningsSummarySchema, ReferralRewardEntrySchema, ReferralTreeNodeSchema, ReferralUplineEntrySchema, RewardsBalanceEntrySchema, SetTraderCodeParamsSchema, TraderCodeAvailabilityReasonSchema, TraderCodeAvailabilityResponseSchema, TraderCodeInfoResponseSchema, TraderCodeResponseSchema, TransferRewardsParamsSchema, TransferRewardsResponseSchema, } from "./responses";
|
|
@@ -77,6 +77,12 @@ export declare const ReferralRewardEntrySchema: z.ZodObject<{
|
|
|
77
77
|
rateApplied: z.ZodString;
|
|
78
78
|
createdAt: z.ZodString;
|
|
79
79
|
}, z.core.$strip>;
|
|
80
|
+
/** One ancestor in the caller's referral chain. */
|
|
81
|
+
export declare const ReferralUplineEntrySchema: z.ZodObject<{
|
|
82
|
+
wallet: z.ZodString;
|
|
83
|
+
display: z.ZodString;
|
|
84
|
+
level: z.ZodNumber;
|
|
85
|
+
}, z.core.$strip>;
|
|
80
86
|
/** The caller's own referral position: who referred them and what they've earned. */
|
|
81
87
|
export declare const GetMyReferralPositionResponseSchema: z.ZodObject<{
|
|
82
88
|
referrer: z.ZodString;
|
|
@@ -91,6 +97,11 @@ export declare const GetMyReferralPositionResponseSchema: z.ZodObject<{
|
|
|
91
97
|
rateApplied: z.ZodString;
|
|
92
98
|
createdAt: z.ZodString;
|
|
93
99
|
}, z.core.$strip>>;
|
|
100
|
+
upline: z.ZodArray<z.ZodObject<{
|
|
101
|
+
wallet: z.ZodString;
|
|
102
|
+
display: z.ZodString;
|
|
103
|
+
level: z.ZodNumber;
|
|
104
|
+
}, z.core.$strip>>;
|
|
94
105
|
}, z.core.$strip>;
|
|
95
106
|
/** One aggregated earnings row per (source trader, level, token) the caller earns from. */
|
|
96
107
|
export declare const ReferralEarningsSourceSchema: z.ZodObject<{
|
|
@@ -136,6 +147,37 @@ export declare const GetMyReferralDownlineResponseSchema: z.ZodObject<{
|
|
|
136
147
|
level3Earned: z.ZodString;
|
|
137
148
|
}, z.core.$strip>;
|
|
138
149
|
}, z.core.$strip>;
|
|
150
|
+
/** Query parameters for reading one level of the caller's referral tree. */
|
|
151
|
+
export declare const GetMyReferralTreeParamsSchema: z.ZodObject<{
|
|
152
|
+
parent: z.ZodOptional<z.ZodString>;
|
|
153
|
+
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
154
|
+
pageToken: z.ZodOptional<z.ZodString>;
|
|
155
|
+
}, z.core.$strip>;
|
|
156
|
+
/** One wallet in the caller's referral tree. */
|
|
157
|
+
export declare const ReferralTreeNodeSchema: z.ZodObject<{
|
|
158
|
+
wallet: z.ZodString;
|
|
159
|
+
display: z.ZodString;
|
|
160
|
+
level: z.ZodNumber;
|
|
161
|
+
parent: z.ZodString;
|
|
162
|
+
referredAt: z.ZodString;
|
|
163
|
+
refereeCount: z.ZodNumber;
|
|
164
|
+
totalEarned: z.ZodString;
|
|
165
|
+
}, z.core.$strip>;
|
|
166
|
+
/** One page of one level of the caller's referral tree. */
|
|
167
|
+
export declare const GetMyReferralTreeResponseSchema: z.ZodObject<{
|
|
168
|
+
parent: z.ZodString;
|
|
169
|
+
parentLevel: z.ZodNumber;
|
|
170
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
171
|
+
wallet: z.ZodString;
|
|
172
|
+
display: z.ZodString;
|
|
173
|
+
level: z.ZodNumber;
|
|
174
|
+
parent: z.ZodString;
|
|
175
|
+
referredAt: z.ZodString;
|
|
176
|
+
refereeCount: z.ZodNumber;
|
|
177
|
+
totalEarned: z.ZodString;
|
|
178
|
+
}, z.core.$strip>>;
|
|
179
|
+
nextPageToken: z.ZodString;
|
|
180
|
+
}, z.core.$strip>;
|
|
139
181
|
export type RewardsBalanceEntry = z.infer<typeof RewardsBalanceEntrySchema>;
|
|
140
182
|
export type GetRewardsBalanceResponse = z.infer<typeof GetRewardsBalanceResponseSchema>;
|
|
141
183
|
export type TraderCodeResponse = z.infer<typeof TraderCodeResponseSchema>;
|
|
@@ -151,3 +193,7 @@ export type ReferralEarningsSource = z.infer<typeof ReferralEarningsSourceSchema
|
|
|
151
193
|
export type ReferralDirectReferee = z.infer<typeof ReferralDirectRefereeSchema>;
|
|
152
194
|
export type ReferralEarningsSummary = z.infer<typeof ReferralEarningsSummarySchema>;
|
|
153
195
|
export type GetMyReferralDownlineResponse = z.infer<typeof GetMyReferralDownlineResponseSchema>;
|
|
196
|
+
export type ReferralUplineEntry = z.infer<typeof ReferralUplineEntrySchema>;
|
|
197
|
+
export type GetMyReferralTreeParams = z.infer<typeof GetMyReferralTreeParamsSchema>;
|
|
198
|
+
export type ReferralTreeNode = z.infer<typeof ReferralTreeNodeSchema>;
|
|
199
|
+
export type GetMyReferralTreeResponse = z.infer<typeof GetMyReferralTreeResponseSchema>;
|
|
@@ -118,11 +118,20 @@ export const ReferralRewardEntrySchema = z.object({
|
|
|
118
118
|
/** RFC 3339 timestamp when the reward row was recorded. */
|
|
119
119
|
createdAt: z.string(),
|
|
120
120
|
});
|
|
121
|
+
/** One ancestor in the caller's referral chain. */
|
|
122
|
+
export const ReferralUplineEntrySchema = z.object({
|
|
123
|
+
/** Public wallet address of the ancestor. */
|
|
124
|
+
wallet: z.string(),
|
|
125
|
+
/** Human-facing name for the ancestor: their custom handle if claimed, else the wallet. */
|
|
126
|
+
display: z.string(),
|
|
127
|
+
/** How far above the caller this ancestor is: 1 (direct referrer), 2, or 3. */
|
|
128
|
+
level: z.number(),
|
|
129
|
+
});
|
|
121
130
|
/** The caller's own referral position: who referred them and what they've earned. */
|
|
122
131
|
export const GetMyReferralPositionResponseSchema = z.object({
|
|
123
132
|
/**
|
|
124
133
|
* Public wallet address of the caller's direct (L1) referrer. Empty string
|
|
125
|
-
* when the caller was not referred.
|
|
134
|
+
* when the caller was not referred. Same wallet as the first `upline` entry.
|
|
126
135
|
*/
|
|
127
136
|
referrer: z.string(),
|
|
128
137
|
/** Human-facing name for the referrer: their custom handle if claimed, else the wallet (empty when not referred). */
|
|
@@ -131,6 +140,12 @@ export const GetMyReferralPositionResponseSchema = z.object({
|
|
|
131
140
|
totalEarned: z.string(),
|
|
132
141
|
/** The caller's most recent reward rows, newest first (bounded server-side). */
|
|
133
142
|
rewards: z.array(ReferralRewardEntrySchema),
|
|
143
|
+
/**
|
|
144
|
+
* The caller's referral chain upward, nearest first: L1, L2, then L3. At most
|
|
145
|
+
* three entries; empty when the caller was not referred. These are the
|
|
146
|
+
* wallets the caller's own trades pay referral rewards to.
|
|
147
|
+
*/
|
|
148
|
+
upline: z.array(ReferralUplineEntrySchema),
|
|
134
149
|
});
|
|
135
150
|
/** One aggregated earnings row per (source trader, level, token) the caller earns from. */
|
|
136
151
|
export const ReferralEarningsSourceSchema = z.object({
|
|
@@ -179,3 +194,43 @@ export const GetMyReferralDownlineResponseSchema = z.object({
|
|
|
179
194
|
*/
|
|
180
195
|
summary: ReferralEarningsSummarySchema,
|
|
181
196
|
});
|
|
197
|
+
/** Query parameters for reading one level of the caller's referral tree. */
|
|
198
|
+
export const GetMyReferralTreeParamsSchema = z.object({
|
|
199
|
+
/**
|
|
200
|
+
* Wallet whose direct referees to list. Omit for your own L1 referees; set to
|
|
201
|
+
* one of your L1 or L2 referees to expand that node.
|
|
202
|
+
*/
|
|
203
|
+
parent: z.string().optional(),
|
|
204
|
+
/** Nodes per page (1-200, default 50). */
|
|
205
|
+
pageSize: z.number().int().min(1).max(200).optional(),
|
|
206
|
+
/** Opaque cursor from a previous response's `nextPageToken`. Only valid with the same `parent`. */
|
|
207
|
+
pageToken: z.string().optional(),
|
|
208
|
+
});
|
|
209
|
+
/** One wallet in the caller's referral tree. */
|
|
210
|
+
export const ReferralTreeNodeSchema = z.object({
|
|
211
|
+
/** Public wallet address of this referee. */
|
|
212
|
+
wallet: z.string(),
|
|
213
|
+
/** Human-facing name: their custom handle if claimed, else the wallet. */
|
|
214
|
+
display: z.string(),
|
|
215
|
+
/** Depth below the caller: 1 (you referred them), 2, or 3. */
|
|
216
|
+
level: z.number(),
|
|
217
|
+
/** Wallet address of this node's referrer — your own wallet for a level-1 node. */
|
|
218
|
+
parent: z.string(),
|
|
219
|
+
/** RFC 3339 time this wallet signed up under its parent. */
|
|
220
|
+
referredAt: z.string(),
|
|
221
|
+
/** How many wallets this node has referred. Expandable when above 0; always 0 at level 3. */
|
|
222
|
+
refereeCount: z.number(),
|
|
223
|
+
/** What you have earned from this wallet's own trades, RAW atomic units. `0` if they haven't traded. */
|
|
224
|
+
totalEarned: z.string(),
|
|
225
|
+
});
|
|
226
|
+
/** One page of one level of the caller's referral tree. */
|
|
227
|
+
export const GetMyReferralTreeResponseSchema = z.object({
|
|
228
|
+
/** Wallet whose referees `nodes` lists — your own wallet when `parent` was omitted. */
|
|
229
|
+
parent: z.string(),
|
|
230
|
+
/** Depth of `parent` below you: 0 for yourself, 1 or 2 for an expanded referee. */
|
|
231
|
+
parentLevel: z.number(),
|
|
232
|
+
/** The wallets `parent` referred, newest first. */
|
|
233
|
+
nodes: z.array(ReferralTreeNodeSchema),
|
|
234
|
+
/** Cursor for the next page; empty when there are no more. */
|
|
235
|
+
nextPageToken: z.string(),
|
|
236
|
+
});
|
|
@@ -166,15 +166,15 @@ export interface PortfolioMarginTotal {
|
|
|
166
166
|
* bound the engine enforces on transfers-out and withdrawals, and therefore
|
|
167
167
|
* also the effective ceiling on funding new isolated or first-use order
|
|
168
168
|
* capacity (allocating collateral to a risk bucket passes through the same
|
|
169
|
-
*
|
|
169
|
+
* capacity-gated door).
|
|
170
170
|
*
|
|
171
171
|
* NOT a clamped `parentAvailableCollateral`: that is an equity figure which
|
|
172
|
-
* credits
|
|
173
|
-
* transfer-out cannot move. This bound never
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
* the bound
|
|
172
|
+
* credits unrealized gains and realized PnL still held in open risk
|
|
173
|
+
* buckets, which a transfer-out of the parent cannot move. This bound never
|
|
174
|
+
* credits an unrealized gain; it counts net deposits plus the account's
|
|
175
|
+
* settled realized PnL and funding, less what risk buckets have allocated —
|
|
176
|
+
* `min(net deposits + settled realized PnL - bucket allocations, freeCollateral - max(unrealizedPnl, 0))`,
|
|
177
|
+
* floored at zero. This is the bound the engine's gates actually enforce. Size transfers-out, withdrawals, and
|
|
178
178
|
* new isolated or first-use positions from this field;
|
|
179
179
|
* `parentAvailableCollateral` remains the trading-margin headroom for
|
|
180
180
|
* existing cross exposure.
|
|
@@ -196,12 +196,14 @@ export interface PortfolioRiskBucket {
|
|
|
196
196
|
positionCount: number;
|
|
197
197
|
/**
|
|
198
198
|
* The largest transfer-out of this risk bucket the engine will actually
|
|
199
|
-
* accept. NOT a clamped `freeCollateral`:
|
|
200
|
-
*
|
|
201
|
-
* and
|
|
202
|
-
*
|
|
203
|
-
* an
|
|
204
|
-
*
|
|
199
|
+
* accept. NOT a clamped `freeCollateral`: the bucket's allocated
|
|
200
|
+
* collateral plus its realized PnL, less funding paid, unrealized losses
|
|
201
|
+
* and the margin its positions and resting orders require. Realized profit
|
|
202
|
+
* can leave a live bucket this way (the bucket's allocation may go
|
|
203
|
+
* negative); an unrealized gain never raises it. This is the largest
|
|
204
|
+
* accepted transfer-out, and every smaller amount is accepted too. It is
|
|
205
|
+
* zero on a risk bucket that is not `NORMAL` and on one whose realized loss
|
|
206
|
+
* has used up its allocation.
|
|
205
207
|
*/
|
|
206
208
|
withdrawableCollateral: string;
|
|
207
209
|
/**
|
|
@@ -267,11 +269,31 @@ export interface PortfolioRiskBucket {
|
|
|
267
269
|
*/
|
|
268
270
|
tradingPairId?: string;
|
|
269
271
|
}
|
|
272
|
+
/** One of the caller's open margin accounts in the owner rollup. */
|
|
273
|
+
export interface PortfolioMarginAccount {
|
|
274
|
+
marginAccountId: string;
|
|
275
|
+
/** `default` for the default margin account, else the sub-account's key. */
|
|
276
|
+
subaccountKey: string;
|
|
277
|
+
/** The account's totals; `withdrawableCollateral` is the persisted reconstruction of the engine's bound. */
|
|
278
|
+
total: PortfolioMarginTotal;
|
|
279
|
+
}
|
|
270
280
|
export interface PortfolioMargin {
|
|
271
281
|
asOf: string;
|
|
272
282
|
total: PortfolioMarginTotal;
|
|
273
283
|
positions: PortfolioMarginPositionCounts;
|
|
274
284
|
riskBuckets: PortfolioRiskBucket[];
|
|
285
|
+
/** The margin account `total`, `positions` and `riskBuckets` describe; absent before the first margin account. */
|
|
286
|
+
marginAccountId?: string;
|
|
287
|
+
/** With `includeAccounts`: every open margin account, the default one first. */
|
|
288
|
+
accounts?: PortfolioMarginAccount[];
|
|
289
|
+
/** With `includeAccounts`: the sum of `accounts`' totals (the owner rollup). */
|
|
290
|
+
ownerTotal?: PortfolioMarginTotal;
|
|
291
|
+
}
|
|
292
|
+
export interface PortfolioMarginParams {
|
|
293
|
+
/** One of your margin accounts (default or a sub-account) to describe instead of the default one. */
|
|
294
|
+
marginAccountId?: string;
|
|
295
|
+
/** Also return every open margin account's totals and their sum. */
|
|
296
|
+
includeAccounts?: boolean;
|
|
275
297
|
}
|
|
276
298
|
/** Authoritative, application-scoped portfolio analytics. */
|
|
277
299
|
export interface PortfolioAPI extends BaseAPI {
|
|
@@ -279,5 +301,5 @@ export interface PortfolioAPI extends BaseAPI {
|
|
|
279
301
|
getPerformance(params?: PortfolioPeriodParams): Promise<PortfolioPerformance>;
|
|
280
302
|
getRealizedPnl(params?: PortfolioPeriodParams): Promise<PortfolioRealizedPnl>;
|
|
281
303
|
getAssets(params?: PortfolioPeriodParams): Promise<PortfolioAssets>;
|
|
282
|
-
getMargin(): Promise<PortfolioMargin>;
|
|
304
|
+
getMargin(params?: PortfolioMarginParams): Promise<PortfolioMargin>;
|
|
283
305
|
}
|
package/dist/trading/orders.d.ts
CHANGED
|
@@ -178,7 +178,7 @@ export interface Order {
|
|
|
178
178
|
version?: number;
|
|
179
179
|
}
|
|
180
180
|
/** Stable terminal causes for accepted orders that end as CANCELLED. */
|
|
181
|
-
export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SELF_TRADE_PREVENTION" | "SYSTEM";
|
|
181
|
+
export type OrderTerminalReason = "USER_REQUESTED" | "REPLACED" | "LIQUIDATION" | "INSUFFICIENT_MARGIN" | "REDUCE_ONLY_EXHAUSTED" | "POSITION_CLOSED" | "OCO_SIBLING_TRIGGERED" | "SELF_TRADE_PREVENTION" | "AUTO_DELEVERAGING" | "SYSTEM";
|
|
182
182
|
/**
|
|
183
183
|
* Role of the creator or order
|
|
184
184
|
*/
|
|
@@ -159,7 +159,7 @@ export interface ReplaceOrderResponse {
|
|
|
159
159
|
status: "SUCCESS" | "FAILED";
|
|
160
160
|
/** Operation message */
|
|
161
161
|
message: string;
|
|
162
|
-
/**
|
|
162
|
+
/** The replacement's price and total quantity (see {@link UpdatedFields}) */
|
|
163
163
|
updatedFields: UpdatedFields;
|
|
164
164
|
/** Original order identifier that was replaced */
|
|
165
165
|
originalOrderId?: string;
|
|
@@ -167,12 +167,19 @@ export interface ReplaceOrderResponse {
|
|
|
167
167
|
matchResult?: MatchResult;
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
170
|
-
*
|
|
170
|
+
* The replacement's price and quantity, as the replace operation placed them
|
|
171
171
|
*/
|
|
172
172
|
export interface UpdatedFields {
|
|
173
|
-
/**
|
|
173
|
+
/** The replacement's price: the requested price, or the original order's when omitted */
|
|
174
174
|
price?: string;
|
|
175
|
-
/**
|
|
175
|
+
/**
|
|
176
|
+
* The replacement's TOTAL quantity, not its resting size: the requested
|
|
177
|
+
* quantity, or the original order's total when omitted. A 100-lot with 60
|
|
178
|
+
* filled reports "100" and rests 40; read the order's `remainingQuantity`
|
|
179
|
+
* for the resting size. For a margin reduce-only replacement it is the close
|
|
180
|
+
* size placed (the requested quantity, or the original's remaining quantity
|
|
181
|
+
* when omitted).
|
|
182
|
+
*/
|
|
176
183
|
quantity?: string;
|
|
177
184
|
}
|
|
178
185
|
/**
|
|
@@ -336,7 +343,7 @@ export interface BatchReplaceResult {
|
|
|
336
343
|
originalOrderId: string;
|
|
337
344
|
/** New order identifier (if successful) */
|
|
338
345
|
newOrderId?: string;
|
|
339
|
-
/**
|
|
346
|
+
/** The replacement's price and total quantity, if successful (see {@link UpdatedFields}) */
|
|
340
347
|
updatedFields?: UpdatedFields;
|
|
341
348
|
/** Match result information if the new order was processed */
|
|
342
349
|
matchResult?: MatchResult;
|
|
@@ -435,7 +442,12 @@ export interface BatchReplaceOrderParams {
|
|
|
435
442
|
orderId: string;
|
|
436
443
|
/** New order price (optional) */
|
|
437
444
|
price?: string;
|
|
438
|
-
/**
|
|
445
|
+
/**
|
|
446
|
+
* New TOTAL order quantity (optional): the replacement rests this total
|
|
447
|
+
* minus the already-filled amount, so it must exceed the filled amount.
|
|
448
|
+
* Omitted, the order keeps its total. A margin reduce-only quantity is a
|
|
449
|
+
* close size, placed as given.
|
|
450
|
+
*/
|
|
439
451
|
quantity?: string;
|
|
440
452
|
/** For sub-accounts: use master's balance (optional) */
|
|
441
453
|
useMasterBalance?: boolean;
|
|
@@ -70,6 +70,16 @@ export declare const PreviewFollowSchema: z.ZodObject<{
|
|
|
70
70
|
allocation: z.ZodString;
|
|
71
71
|
tradingPairIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
|
|
72
72
|
}, z.core.$strict>;
|
|
73
|
+
/**
|
|
74
|
+
* Params for adding margin to one of your copy positions: `amount` moves from
|
|
75
|
+
* the follow's copy account into the margin of its isolated copy position on
|
|
76
|
+
* `tradingPairId`. The follow id is sent in the path, the rest in the body.
|
|
77
|
+
*/
|
|
78
|
+
export declare const AddFollowPositionMarginSchema: z.ZodObject<{
|
|
79
|
+
followId: z.ZodUUID;
|
|
80
|
+
tradingPairId: z.ZodUUID;
|
|
81
|
+
amount: z.ZodString;
|
|
82
|
+
}, z.core.$strict>;
|
|
73
83
|
/** Params for the public leaderboard. */
|
|
74
84
|
export declare const ListLeadTradersSchema: z.ZodObject<{
|
|
75
85
|
pageSize: z.ZodOptional<z.ZodNumber>;
|
|
@@ -107,6 +117,7 @@ export declare const ListMyFollowersSchema: z.ZodObject<{
|
|
|
107
117
|
export type UpsertLeadTraderParams = z.input<typeof UpsertLeadTraderSchema>;
|
|
108
118
|
export type UpsertFollowParams = z.input<typeof UpsertFollowSchema>;
|
|
109
119
|
export type PreviewFollowParams = z.input<typeof PreviewFollowSchema>;
|
|
120
|
+
export type AddFollowPositionMarginParams = z.input<typeof AddFollowPositionMarginSchema>;
|
|
110
121
|
export type ListLeadTradersParams = z.input<typeof ListLeadTradersSchema>;
|
|
111
122
|
export type ListLeadTraderClosedTradesParams = z.input<typeof ListLeadTraderClosedTradesSchema>;
|
|
112
123
|
export type ListMyFollowsParams = z.input<typeof ListMyFollowsSchema>;
|
|
@@ -123,6 +123,21 @@ export const PreviewFollowSchema = z
|
|
|
123
123
|
})
|
|
124
124
|
.strict()
|
|
125
125
|
.superRefine((params, ctx) => termRules(params, ctx));
|
|
126
|
+
/**
|
|
127
|
+
* Params for adding margin to one of your copy positions: `amount` moves from
|
|
128
|
+
* the follow's copy account into the margin of its isolated copy position on
|
|
129
|
+
* `tradingPairId`. The follow id is sent in the path, the rest in the body.
|
|
130
|
+
*/
|
|
131
|
+
export const AddFollowPositionMarginSchema = z
|
|
132
|
+
.object({
|
|
133
|
+
/** The follow's id. */
|
|
134
|
+
followId: UUIDSchema,
|
|
135
|
+
/** Trading pair of the copy position to add margin to. */
|
|
136
|
+
tradingPairId: UUIDSchema,
|
|
137
|
+
/** Margin to add, in quote units, taken from the follow's copy account. */
|
|
138
|
+
amount: PositiveDecimalStringSchema,
|
|
139
|
+
})
|
|
140
|
+
.strict();
|
|
126
141
|
/** Params for the public leaderboard. */
|
|
127
142
|
export const ListLeadTradersSchema = z
|
|
128
143
|
.object({
|