@0xmonaco/types 1.0.72 → 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.
@@ -5,7 +5,7 @@
5
5
  * per-trade revenue share.
6
6
  */
7
7
  import type { BaseAPI } from "../api";
8
- import type { ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, GetBuildercodePayoutSummaryResponse, GetBuildercodeRewardsBalanceResponse, GetBuildercodesConfigResponse, ListBuildercodePayoutsParams, ListBuildercodePayoutsResponse } from "./responses";
8
+ import type { ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, GetBuildercodePayoutSummaryResponse, GetBuildercodeRewardsBalanceResponse, GetBuildercodesConfigResponse, ListBuildercodePayoutsParams, ListBuildercodePayoutsResponse, ListBuilderFeeChangesParams, ListBuilderFeeChangesResponse, SetBuilderFeeParams, SetBuilderFeeResponse } from "./responses";
9
9
  /**
10
10
  * BuilderCodes payout API interface.
11
11
  *
@@ -18,6 +18,10 @@ import type { ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, Ge
18
18
  export interface BuildercodesAPI extends BaseAPI {
19
19
  /** Read this authenticated frontend's enrollment, payout address, and live budget. */
20
20
  getConfig(): Promise<GetBuildercodesConfigResponse>;
21
+ /** Set this frontend's stored builder fee in basis points. */
22
+ setBuilderFee(params: SetBuilderFeeParams): Promise<SetBuilderFeeResponse>;
23
+ /** List this frontend's builder-fee audit log, newest first. */
24
+ listBuilderFeeChanges(params?: ListBuilderFeeChangesParams): Promise<ListBuilderFeeChangesResponse>;
21
25
  /** List this authenticated frontend's per-trade BuilderCodes credits, optionally of one payout `kind`. */
22
26
  listPayouts(params?: ListBuildercodePayoutsParams): Promise<ListBuildercodePayoutsResponse>;
23
27
  /** Summarize this authenticated frontend's BuilderCodes credits by token, and by token and payout kind. */
@@ -67,5 +71,5 @@ export interface BuildercodesAPI extends BaseAPI {
67
71
  */
68
72
  claimBuildercodeRewards(params: ClaimBuildercodeRewardsParams): Promise<ClaimBuildercodeRewardsResponse>;
69
73
  }
70
- export type { BuildercodePayout, BuildercodePayoutKind, BuildercodePayoutTokenKindTotal, BuildercodePayoutTokenTotal, BuildercodeRewardsBalance, ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, GetBuildercodePayoutSummaryResponse, GetBuildercodeRewardsBalanceResponse, GetBuildercodesConfigResponse, ListBuildercodePayoutsParams, ListBuildercodePayoutsResponse, } from "./responses";
71
- export { BuildercodePayoutKindSchema, BuildercodePayoutSchema, BuildercodePayoutTokenKindTotalSchema, BuildercodePayoutTokenTotalSchema, BuildercodeRewardsBalanceSchema, ClaimBuildercodeRewardsParamsSchema, ClaimBuildercodeRewardsResponseSchema, GetBuildercodePayoutSummaryResponseSchema, GetBuildercodeRewardsBalanceResponseSchema, GetBuildercodesConfigResponseSchema, ListBuildercodePayoutsParamsSchema, ListBuildercodePayoutsResponseSchema, } from "./responses";
74
+ export type { BuildercodePayout, BuildercodePayoutKind, BuildercodePayoutTokenKindTotal, BuildercodePayoutTokenTotal, BuildercodeRewardsBalance, BuilderFeeActorType, BuilderFeeChange, ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, GetBuildercodePayoutSummaryResponse, GetBuildercodeRewardsBalanceResponse, GetBuildercodesConfigResponse, ListBuildercodePayoutsParams, ListBuildercodePayoutsResponse, ListBuilderFeeChangesParams, ListBuilderFeeChangesResponse, SetBuilderFeeParams, SetBuilderFeeResponse, } from "./responses";
75
+ export { BuildercodePayoutKindSchema, BuildercodePayoutSchema, BuildercodePayoutTokenKindTotalSchema, BuildercodePayoutTokenTotalSchema, BuildercodeRewardsBalanceSchema, BuilderFeeActorTypeSchema, BuilderFeeChangeSchema, ClaimBuildercodeRewardsParamsSchema, ClaimBuildercodeRewardsResponseSchema, GetBuildercodePayoutSummaryResponseSchema, GetBuildercodeRewardsBalanceResponseSchema, GetBuildercodesConfigResponseSchema, ListBuildercodePayoutsParamsSchema, ListBuildercodePayoutsResponseSchema, ListBuilderFeeChangesParamsSchema, ListBuilderFeeChangesResponseSchema, SetBuilderFeeParamsSchema, SetBuilderFeeResponseSchema, } from "./responses";
@@ -4,4 +4,4 @@
4
4
  * Types for the BuilderCodes API: reading and claiming an enrolled frontend's
5
5
  * per-trade revenue share.
6
6
  */
7
- export { BuildercodePayoutKindSchema, BuildercodePayoutSchema, BuildercodePayoutTokenKindTotalSchema, BuildercodePayoutTokenTotalSchema, BuildercodeRewardsBalanceSchema, ClaimBuildercodeRewardsParamsSchema, ClaimBuildercodeRewardsResponseSchema, GetBuildercodePayoutSummaryResponseSchema, GetBuildercodeRewardsBalanceResponseSchema, GetBuildercodesConfigResponseSchema, ListBuildercodePayoutsParamsSchema, ListBuildercodePayoutsResponseSchema, } from "./responses";
7
+ export { BuildercodePayoutKindSchema, BuildercodePayoutSchema, BuildercodePayoutTokenKindTotalSchema, BuildercodePayoutTokenTotalSchema, BuildercodeRewardsBalanceSchema, BuilderFeeActorTypeSchema, BuilderFeeChangeSchema, ClaimBuildercodeRewardsParamsSchema, ClaimBuildercodeRewardsResponseSchema, GetBuildercodePayoutSummaryResponseSchema, GetBuildercodeRewardsBalanceResponseSchema, GetBuildercodesConfigResponseSchema, ListBuildercodePayoutsParamsSchema, ListBuildercodePayoutsResponseSchema, ListBuilderFeeChangesParamsSchema, ListBuilderFeeChangesResponseSchema, SetBuilderFeeParamsSchema, SetBuilderFeeResponseSchema, } from "./responses";
@@ -12,11 +12,61 @@ export declare const GetBuildercodesConfigResponseSchema: z.ZodObject<{
12
12
  payoutAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
13
  buildercodesEnabled: z.ZodBoolean;
14
14
  buildercodesBudgetBps: z.ZodNumber;
15
+ builderFeeEnabled: z.ZodBoolean;
16
+ builderFeeBps: z.ZodNumber;
17
+ builderFeeCapBps: z.ZodNumber;
18
+ changesRemaining: z.ZodNumber;
19
+ nextChangeAllowedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
+ }, z.core.$strip>;
21
+ /** Schema for changing this frontend's builder fee. */
22
+ export declare const SetBuilderFeeParamsSchema: z.ZodObject<{
23
+ bps: z.ZodNumber;
24
+ }, z.core.$strip>;
25
+ /** Schema returned after setting this frontend's builder fee. */
26
+ export declare const SetBuilderFeeResponseSchema: z.ZodObject<{
27
+ builderFeeBps: z.ZodNumber;
28
+ previousBuilderFeeBps: z.ZodNumber;
29
+ changesRemaining: z.ZodNumber;
30
+ nextChangeAllowedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ }, z.core.$strip>;
32
+ /** Builder-fee change actor exposed by the audit log. */
33
+ export declare const BuilderFeeActorTypeSchema: z.ZodEnum<{
34
+ BUILDER: "BUILDER";
35
+ ADMIN: "ADMIN";
36
+ }>;
37
+ /** One builder-fee audit-log entry. */
38
+ export declare const BuilderFeeChangeSchema: z.ZodObject<{
39
+ actorType: z.ZodEnum<{
40
+ BUILDER: "BUILDER";
41
+ ADMIN: "ADMIN";
42
+ }>;
43
+ actor: z.ZodString;
44
+ oldBps: z.ZodNumber;
45
+ newBps: z.ZodNumber;
46
+ createdAt: z.ZodString;
47
+ }, z.core.$strip>;
48
+ /** Cursor pagination accepted by the builder-fee change log. */
49
+ export declare const ListBuilderFeeChangesParamsSchema: z.ZodObject<{
50
+ pageSize: z.ZodOptional<z.ZodNumber>;
51
+ pageToken: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$strip>;
53
+ /** Schema for one page of builder-fee changes, newest first. */
54
+ export declare const ListBuilderFeeChangesResponseSchema: z.ZodObject<{
55
+ changes: z.ZodArray<z.ZodObject<{
56
+ actorType: z.ZodEnum<{
57
+ BUILDER: "BUILDER";
58
+ ADMIN: "ADMIN";
59
+ }>;
60
+ actor: z.ZodString;
61
+ oldBps: z.ZodNumber;
62
+ newBps: z.ZodNumber;
63
+ createdAt: z.ZodString;
64
+ }, z.core.$strip>>;
65
+ nextPageToken: z.ZodString;
15
66
  }, z.core.$strip>;
16
67
  /**
17
- * The payout stream a BuilderCodes credit belongs to. `REVENUE_SHARE` is the
18
- * frontend's share of Monaco's fee; `BUILDER_FEE` is the frontend's own builder
19
- * fee, paid by the taker. Both land in the same claimable balance.
68
+ * The payout stream a BuilderCodes credit belongs to. `REVENUE_SHARE` records
69
+ * Monaco revenue share; `BUILDER_FEE` records builder fees charged to takers.
20
70
  */
21
71
  export declare const BuildercodePayoutKindSchema: z.ZodEnum<{
22
72
  REVENUE_SHARE: "REVENUE_SHARE";
@@ -127,6 +177,12 @@ export declare const ClaimBuildercodeRewardsResponseSchema: z.ZodObject<{
127
177
  export type ClaimBuildercodeRewardsParams = z.infer<typeof ClaimBuildercodeRewardsParamsSchema>;
128
178
  export type ClaimBuildercodeRewardsResponse = z.infer<typeof ClaimBuildercodeRewardsResponseSchema>;
129
179
  export type GetBuildercodesConfigResponse = z.infer<typeof GetBuildercodesConfigResponseSchema>;
180
+ export type SetBuilderFeeParams = z.infer<typeof SetBuilderFeeParamsSchema>;
181
+ export type SetBuilderFeeResponse = z.infer<typeof SetBuilderFeeResponseSchema>;
182
+ export type BuilderFeeActorType = z.infer<typeof BuilderFeeActorTypeSchema>;
183
+ export type BuilderFeeChange = z.infer<typeof BuilderFeeChangeSchema>;
184
+ export type ListBuilderFeeChangesParams = z.infer<typeof ListBuilderFeeChangesParamsSchema>;
185
+ export type ListBuilderFeeChangesResponse = z.infer<typeof ListBuilderFeeChangesResponseSchema>;
130
186
  export type ListBuildercodePayoutsParams = z.infer<typeof ListBuildercodePayoutsParamsSchema>;
131
187
  export type BuildercodePayoutKind = z.infer<typeof BuildercodePayoutKindSchema>;
132
188
  export type BuildercodePayout = z.infer<typeof BuildercodePayoutSchema>;
@@ -16,11 +16,46 @@ export const GetBuildercodesConfigResponseSchema = z.object({
16
16
  payoutAddress: z.string().nullable().optional(),
17
17
  buildercodesEnabled: z.boolean(),
18
18
  buildercodesBudgetBps: z.number().int().min(0).max(10_000),
19
+ builderFeeEnabled: z.boolean(),
20
+ builderFeeBps: z.number().int().min(0).max(100),
21
+ builderFeeCapBps: z.number().int().min(0).max(100),
22
+ changesRemaining: z.number().int().min(0).max(2),
23
+ nextChangeAllowedAt: z.string().nullable().optional(),
24
+ });
25
+ /** Schema for changing this frontend's builder fee. */
26
+ export const SetBuilderFeeParamsSchema = z.object({
27
+ bps: z.number().int().min(0).max(100),
28
+ });
29
+ /** Schema returned after setting this frontend's builder fee. */
30
+ export const SetBuilderFeeResponseSchema = z.object({
31
+ builderFeeBps: z.number().int().min(0).max(100),
32
+ previousBuilderFeeBps: z.number().int().min(0).max(100),
33
+ changesRemaining: z.number().int().min(0).max(2),
34
+ nextChangeAllowedAt: z.string().nullable().optional(),
35
+ });
36
+ /** Builder-fee change actor exposed by the audit log. */
37
+ export const BuilderFeeActorTypeSchema = z.enum(["BUILDER", "ADMIN"]);
38
+ /** One builder-fee audit-log entry. */
39
+ export const BuilderFeeChangeSchema = z.object({
40
+ actorType: BuilderFeeActorTypeSchema,
41
+ actor: z.string(),
42
+ oldBps: z.number().int().min(0).max(100),
43
+ newBps: z.number().int().min(0).max(100),
44
+ createdAt: z.string(),
45
+ });
46
+ /** Cursor pagination accepted by the builder-fee change log. */
47
+ export const ListBuilderFeeChangesParamsSchema = z.object({
48
+ pageSize: z.number().int().min(1).max(100).optional(),
49
+ pageToken: z.string().optional(),
50
+ });
51
+ /** Schema for one page of builder-fee changes, newest first. */
52
+ export const ListBuilderFeeChangesResponseSchema = z.object({
53
+ changes: z.array(BuilderFeeChangeSchema),
54
+ nextPageToken: z.string(),
19
55
  });
20
56
  /**
21
- * The payout stream a BuilderCodes credit belongs to. `REVENUE_SHARE` is the
22
- * frontend's share of Monaco's fee; `BUILDER_FEE` is the frontend's own builder
23
- * fee, paid by the taker. Both land in the same claimable balance.
57
+ * The payout stream a BuilderCodes credit belongs to. `REVENUE_SHARE` records
58
+ * Monaco revenue share; `BUILDER_FEE` records builder fees charged to takers.
24
59
  */
25
60
  export const BuildercodePayoutKindSchema = z.enum(["REVENUE_SHARE", "BUILDER_FEE"]);
26
61
  /** Pagination and filter accepted by the per-trade payout history endpoint. */
@@ -65,8 +65,9 @@ export interface CopyTradingAPI extends BaseAPI {
65
65
  upsertFollow(params: UpsertFollowParams): Promise<UpsertFollowResponse>;
66
66
  /**
67
67
  * Stop one of your follows: the leader's fills stop being mirrored. An exit
68
- * is never gated beyond ownership, except that a delegated agent session
69
- * cannot stop a follow (403).
68
+ * is never refused for the state of the account or the platform. Only
69
+ * ownership applies, a delegated agent session cannot stop a follow (403),
70
+ * and stops have a rate limit of their own (429 past it).
70
71
  */
71
72
  stopFollow(followId: string): Promise<StopFollowResponse>;
72
73
  /**
@@ -106,11 +107,10 @@ export interface CopyTradingAPI extends BaseAPI {
106
107
  *
107
108
  * Master account sessions only (a delegated agent or a sub-account gets
108
109
  * 403); 404 for a follow that is not yours; 409 while the follow is
109
- * stopping or once it is stopped, or `COPY_TRADING_UNAVAILABLE` when copy
110
- * trading is not available on the platform; 400 `COPY_TRADING_REJECTED`
111
- * when the engine refuses (no isolated copy position on the pair, the
112
- * position or the margin account is being liquidated, the position has
113
- * lost more than its margin, more than the copy account can put in); 429
110
+ * stopping or once it is stopped; 400 `COPY_TRADING_REJECTED` when the add
111
+ * is refused (no isolated copy position on the pair, the copy position is
112
+ * being liquidated or is in bad debt, more than the copy account can put
113
+ * in); 429
114
114
  * over the movement budget withdrawals and collateral transfers share.
115
115
  *
116
116
  * Not idempotent: a retry after a timeout whose first attempt landed adds
@@ -1,16 +1,22 @@
1
1
  import type { Address } from "viem";
2
2
  import type { BaseAPI } from "../api";
3
- export type DelegatedAgentAction = "CREATE_ORDER" | "CANCEL_ORDER" | "REPLACE_ORDER" | "create_order" | "cancel_order" | "replace_order";
3
+ export type DelegatedAgentAction = "CREATE_ORDER" | "CANCEL_ORDER" | "REPLACE_ORDER" | "READ" | "MANAGE_RISK_BUCKETS" | "create_order" | "cancel_order" | "replace_order" | "read" | "manage_risk_buckets";
4
4
  export interface UpsertDelegatedAgentRequest {
5
5
  agentAddress: string;
6
6
  name?: string;
7
- /** Delegation expiry (ISO 8601); ends reads, trading, and session refresh. */
7
+ /** Delegation expiry (ISO 8601); ends reads, trading, and session refresh. Omit for the default of 14 days from now; at most 180 days ahead. */
8
8
  expiresAt?: string;
9
- /** Required. An empty list permits no actions. */
9
+ /**
10
+ * Required. An empty list permits no order actions. Every delegated session may read the owner's
11
+ * data, so a list of only `READ` (or none) is a read-only key.
12
+ */
10
13
  allowedActions: DelegatedAgentAction[];
11
- /** Required. A matching market OR account permits an order; both scopes empty deny all orders. */
14
+ /** Required. Each listed scope must match: a listed market AND a listed account. Both empty deny all orders. */
12
15
  allowedTradingPairIds: string[];
13
- /** Additional account scope. Omit or send [] for market-only scope, not access to every account. */
16
+ /**
17
+ * The margin accounts the agent is bound to (a sub-account's own key). Omit or send [] to leave the
18
+ * account unrestricted.
19
+ */
14
20
  allowedMarginAccountIds?: string[];
15
21
  /** Omit or send [] for unrestricted order types. */
16
22
  allowedOrderTypes?: Array<"LIMIT" | "MARKET">;
@@ -20,6 +26,8 @@ export interface UpsertDelegatedAgentRequest {
20
26
  maxOrderNotional?: string;
21
27
  /** @deprecated Unsupported: setting this field causes the server to reject the request. */
22
28
  maxOpenOrders?: number;
29
+ /** Up to 20 IP addresses or CIDR ranges the agent may create its delegated session from. Omit for any. */
30
+ ipAllowlist?: string[];
23
31
  }
24
32
  export interface DelegatedAgent {
25
33
  id: string;
@@ -38,6 +46,8 @@ export interface DelegatedAgent {
38
46
  maxOrderNotional?: string;
39
47
  /** @deprecated Legacy data only; no concurrent open-order cap is enforced. */
40
48
  maxOpenOrders?: number;
49
+ /** Normalized IP addresses and CIDR ranges; empty allows any address. */
50
+ ipAllowlist?: string[];
41
51
  }
42
52
  export interface ListDelegatedAgentsResponse {
43
53
  agents: DelegatedAgent[];
@@ -9,7 +9,17 @@ export interface MarginAccountSummary {
9
9
  selectedTradingPairIds?: string[];
10
10
  tradingPairId?: string;
11
11
  strategyKey?: string;
12
- accountState: string;
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 realized PnL, accrued funding and mark-to-market gains
23
- * that are not principal a transfer can move — so the two can differ
24
- * without limit. An unrealized gain never counts toward this figure.
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 capped by the bucket's allocated collateral;
27
- * for a parent margin account, by deposited collateral that no risk bucket
28
- * has earmarked. Size transfers against this field, not `freeCollateral`.
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 (principal not earmarked by risk buckets) as well
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
- * principal through the same gate this field measures, so size those from
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
  /**
@@ -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 direct (L1) referrer, total earned,
96
- * and most recent reward rows.
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";
@@ -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. Only the direct referrer is exposed.
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
+ });