@0xmonaco/types 1.0.58 → 1.0.60

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.
@@ -31,10 +31,24 @@ export interface AuthAPI extends BaseAPI {
31
31
  /**
32
32
  * Signs a challenge message using the wallet client.
33
33
  *
34
- * Signs the provided message using the wallet's private key.
35
- * This is used in the authentication flow to prove ownership of the wallet.
34
+ * Asks the connected wallet to authorize the message, proving control of the
35
+ * address. An EOA signs it with its private key (EIP-191 `personal_sign`). A
36
+ * smart-contract wallet such as a Safe has no private key and returns a
37
+ * signature its own contract will accept, which the server checks under
38
+ * EIP-1271; the wallet client handles that difference, and the returned value
39
+ * is submitted unchanged either way.
36
40
  *
37
- * @param message - The message to sign
41
+ * The returned signature is therefore not guaranteed to be 65 bytes — a
42
+ * contract signature is usually longer — so callers must not assume the
43
+ * EOA shape.
44
+ *
45
+ * Note the scope. Server-side EIP-1271 verification is deliberately narrow:
46
+ * it is offered only to a wallet holding a BuilderCodes payout bucket, on a
47
+ * deployment with the contract-wallet flag on and a chain RPC endpoint
48
+ * configured. An ordinary smart-contract trading account is not covered — it
49
+ * still takes the recovery path, which it cannot satisfy.
50
+ *
51
+ * @param message - The message to authorize
38
52
  * @returns Promise resolving to the signature
39
53
  */
40
54
  signChallenge(message: string): Promise<string>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * BuilderCodes Types
3
+ *
4
+ * Types for the BuilderCodes API: reading and claiming an enrolled frontend's
5
+ * per-trade revenue share.
6
+ */
7
+ import type { BaseAPI } from "../api";
8
+ import type { ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, GetBuildercodePayoutSummaryResponse, GetBuildercodeRewardsBalanceResponse, GetBuildercodesConfigResponse, ListBuildercodePayoutsParams, ListBuildercodePayoutsResponse } from "./responses";
9
+ /**
10
+ * BuilderCodes payout API interface.
11
+ *
12
+ * BuilderCodes is Monaco's per-trade frontend revenue share: an enrolled
13
+ * frontend earns a configured share of the net take on every fill its users
14
+ * generate, accruing to a reserved payout bucket owned by the frontend's
15
+ * configured payout wallet. Accrual is internal accounting only — this API is
16
+ * how that balance is claimed into a tradeable (and then withdrawable) balance.
17
+ */
18
+ export interface BuildercodesAPI extends BaseAPI {
19
+ /** Read this authenticated frontend's enrollment, payout address, and live budget. */
20
+ getConfig(): Promise<GetBuildercodesConfigResponse>;
21
+ /** List this authenticated frontend's per-trade BuilderCodes credits. */
22
+ listPayouts(params?: ListBuildercodePayoutsParams): Promise<ListBuildercodePayoutsResponse>;
23
+ /** Summarize this authenticated frontend's BuilderCodes credits by token. */
24
+ getPayoutSummary(): Promise<GetBuildercodePayoutSummaryResponse>;
25
+ /** Read the authenticated wallet's available reserved reward balances. */
26
+ getRewardsBalance(): Promise<GetBuildercodeRewardsBalanceResponse>;
27
+ /**
28
+ * Claim accrued BuilderCodes payout balance into a trading balance.
29
+ *
30
+ * Moves the specified amount of a payout token out of the authenticated
31
+ * caller's reserved payout bucket and into their trading balance under the
32
+ * authenticated application, from where the ordinary withdrawal flow applies.
33
+ * Ledger-only — no on-chain transaction and no gas, and the funds are
34
+ * immediately tradeable.
35
+ *
36
+ * The payout wallet may be an EOA or a smart-contract wallet. An EOA answers
37
+ * the signature challenge directly; a multisig such as a Safe authenticates by
38
+ * EIP-1271 contract signature instead. That path is offered only to a wallet
39
+ * holding a BuilderCodes payout bucket, only while `contract_wallet_auth_enabled`
40
+ * is on, and only where the deployment has a chain RPC endpoint configured —
41
+ * otherwise login is EOA-only and a contract payout wallet can neither call
42
+ * this endpoint nor withdraw afterwards.
43
+ *
44
+ * The bucket is resolved from the authenticated caller's own wallet address,
45
+ * so a caller can only ever claim their own accrued balance. A wallet that
46
+ * has never been an enrolled frontend's payout address has nothing to claim.
47
+ * A wallet that *used to be* a payout address keeps what it accrued back then
48
+ * and can still claim it — payout-address changes are not retroactive.
49
+ *
50
+ * Throws 403 when the caller is refused: BuilderCodes is not enabled, or
51
+ * the session is a delegated agent — which is rejected before the feature is
52
+ * checked, so it is a permanent restriction on that session type, not a
53
+ * rollout state. Throws 409 when the payout balance is insufficient for the
54
+ * requested amount. Throws 503 when the matching engine is unreachable,
55
+ * restarting, or slow to answer — an UNKNOWN outcome, not a rejection: the
56
+ * claim is admitted to the sequencer before its reply is sent, so it may
57
+ * still commit, and with no idempotency key a blind retry can claim twice.
58
+ * Do not retry automatically: a balance read cannot settle it, because an
59
+ * admitted claim may still be queued. Ambiguous failures are thrown
60
+ * with `retryable: false` so retry logic driven off that flag cannot claim
61
+ * twice. Two pre-admission rejections stay retryable because they committed
62
+ * nothing: a maintenance block (`OPERATIONS_BLOCKED`) and a sequencer
63
+ * overload (`OVERLOADED`).
64
+ *
65
+ * @param params - Payout token address and raw-unit amount to claim
66
+ * @returns Promise resolving to the post-claim payout and trading balances
67
+ */
68
+ claimBuildercodeRewards(params: ClaimBuildercodeRewardsParams): Promise<ClaimBuildercodeRewardsResponse>;
69
+ }
70
+ export type { BuildercodePayout, BuildercodePayoutTokenTotal, BuildercodeRewardsBalance, ClaimBuildercodeRewardsParams, ClaimBuildercodeRewardsResponse, GetBuildercodePayoutSummaryResponse, GetBuildercodeRewardsBalanceResponse, GetBuildercodesConfigResponse, ListBuildercodePayoutsParams, ListBuildercodePayoutsResponse, } from "./responses";
71
+ export { BuildercodePayoutSchema, BuildercodePayoutTokenTotalSchema, BuildercodeRewardsBalanceSchema, ClaimBuildercodeRewardsParamsSchema, ClaimBuildercodeRewardsResponseSchema, GetBuildercodePayoutSummaryResponseSchema, GetBuildercodeRewardsBalanceResponseSchema, GetBuildercodesConfigResponseSchema, ListBuildercodePayoutsParamsSchema, ListBuildercodePayoutsResponseSchema, } from "./responses";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * BuilderCodes Types
3
+ *
4
+ * Types for the BuilderCodes API: reading and claiming an enrolled frontend's
5
+ * per-trade revenue share.
6
+ */
7
+ export { BuildercodePayoutSchema, BuildercodePayoutTokenTotalSchema, BuildercodeRewardsBalanceSchema, ClaimBuildercodeRewardsParamsSchema, ClaimBuildercodeRewardsResponseSchema, GetBuildercodePayoutSummaryResponseSchema, GetBuildercodeRewardsBalanceResponseSchema, GetBuildercodesConfigResponseSchema, ListBuildercodePayoutsParamsSchema, ListBuildercodePayoutsResponseSchema, } from "./responses";
@@ -0,0 +1,94 @@
1
+ /**
2
+ * BuilderCodes Response Types
3
+ *
4
+ * Types for the BuilderCodes earnings and payout API responses and requests.
5
+ * All types are derived from Zod schemas for runtime validation.
6
+ */
7
+ import { z } from "zod";
8
+ /** Schema for this frontend's current BuilderCodes program state. */
9
+ export declare const GetBuildercodesConfigResponseSchema: z.ZodObject<{
10
+ applicationId: z.ZodString;
11
+ enrolled: z.ZodBoolean;
12
+ payoutAddress: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ buildercodesEnabled: z.ZodBoolean;
14
+ buildercodesBudgetBps: z.ZodNumber;
15
+ }, z.core.$strip>;
16
+ /** Pagination accepted by the per-trade payout history endpoint. */
17
+ export declare const ListBuildercodePayoutsParamsSchema: z.ZodObject<{
18
+ page: z.ZodOptional<z.ZodNumber>;
19
+ pageSize: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strip>;
21
+ /** One per-trade BuilderCodes credit. Amounts are RAW atomic units. */
22
+ export declare const BuildercodePayoutSchema: z.ZodObject<{
23
+ tradeId: z.ZodString;
24
+ payoutAddress: z.ZodString;
25
+ token: z.ZodString;
26
+ amount: z.ZodString;
27
+ appliedBps: z.ZodNumber;
28
+ createdAt: z.ZodString;
29
+ }, z.core.$strip>;
30
+ /** Schema for the paginated per-trade payout history. */
31
+ export declare const ListBuildercodePayoutsResponseSchema: z.ZodObject<{
32
+ payouts: z.ZodArray<z.ZodObject<{
33
+ tradeId: z.ZodString;
34
+ payoutAddress: z.ZodString;
35
+ token: z.ZodString;
36
+ amount: z.ZodString;
37
+ appliedBps: z.ZodNumber;
38
+ createdAt: z.ZodString;
39
+ }, z.core.$strip>>;
40
+ total: z.ZodNumber;
41
+ page: z.ZodNumber;
42
+ pageSize: z.ZodNumber;
43
+ totalPages: z.ZodNumber;
44
+ }, z.core.$strip>;
45
+ /** One token-denominated BuilderCodes earnings total. */
46
+ export declare const BuildercodePayoutTokenTotalSchema: z.ZodObject<{
47
+ token: z.ZodString;
48
+ totalAmount: z.ZodString;
49
+ payoutCount: z.ZodNumber;
50
+ lastCreditedAt: z.ZodString;
51
+ }, z.core.$strip>;
52
+ /** Schema for this frontend's payout summary. */
53
+ export declare const GetBuildercodePayoutSummaryResponseSchema: z.ZodObject<{
54
+ totalPayouts: z.ZodNumber;
55
+ lastCreditedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
56
+ byToken: z.ZodArray<z.ZodObject<{
57
+ token: z.ZodString;
58
+ totalAmount: z.ZodString;
59
+ payoutCount: z.ZodNumber;
60
+ lastCreditedAt: z.ZodString;
61
+ }, z.core.$strip>>;
62
+ }, z.core.$strip>;
63
+ /** One available balance in the reserved BuilderCodes reward bucket. */
64
+ export declare const BuildercodeRewardsBalanceSchema: z.ZodObject<{
65
+ token: z.ZodString;
66
+ available: z.ZodString;
67
+ }, z.core.$strip>;
68
+ /** Schema for the caller wallet's reserved BuilderCodes balances. */
69
+ export declare const GetBuildercodeRewardsBalanceResponseSchema: z.ZodObject<{
70
+ balances: z.ZodArray<z.ZodObject<{
71
+ token: z.ZodString;
72
+ available: z.ZodString;
73
+ }, z.core.$strip>>;
74
+ }, z.core.$strip>;
75
+ /** Schema for the claim-BuilderCodes-rewards request body. */
76
+ export declare const ClaimBuildercodeRewardsParamsSchema: z.ZodObject<{
77
+ token: z.ZodString;
78
+ amount: z.ZodString;
79
+ }, z.core.$strip>;
80
+ /** Schema for the claim-BuilderCodes-rewards response. */
81
+ export declare const ClaimBuildercodeRewardsResponseSchema: z.ZodObject<{
82
+ payoutBalance: z.ZodString;
83
+ tradingBalance: z.ZodString;
84
+ }, z.core.$strip>;
85
+ export type ClaimBuildercodeRewardsParams = z.infer<typeof ClaimBuildercodeRewardsParamsSchema>;
86
+ export type ClaimBuildercodeRewardsResponse = z.infer<typeof ClaimBuildercodeRewardsResponseSchema>;
87
+ export type GetBuildercodesConfigResponse = z.infer<typeof GetBuildercodesConfigResponseSchema>;
88
+ export type ListBuildercodePayoutsParams = z.infer<typeof ListBuildercodePayoutsParamsSchema>;
89
+ export type BuildercodePayout = z.infer<typeof BuildercodePayoutSchema>;
90
+ export type ListBuildercodePayoutsResponse = z.infer<typeof ListBuildercodePayoutsResponseSchema>;
91
+ export type BuildercodePayoutTokenTotal = z.infer<typeof BuildercodePayoutTokenTotalSchema>;
92
+ export type GetBuildercodePayoutSummaryResponse = z.infer<typeof GetBuildercodePayoutSummaryResponseSchema>;
93
+ export type BuildercodeRewardsBalance = z.infer<typeof BuildercodeRewardsBalanceSchema>;
94
+ export type GetBuildercodeRewardsBalanceResponse = z.infer<typeof GetBuildercodeRewardsBalanceResponseSchema>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * BuilderCodes Response Types
3
+ *
4
+ * Types for the BuilderCodes earnings and payout API responses and requests.
5
+ * All types are derived from Zod schemas for runtime validation.
6
+ */
7
+ import { z } from "zod";
8
+ /** Schema for this frontend's current BuilderCodes program state. */
9
+ export const GetBuildercodesConfigResponseSchema = z.object({
10
+ applicationId: z.string().uuid(),
11
+ enrolled: z.boolean(),
12
+ // Nullable, not merely absent: `payout_address` is an `optional` proto field
13
+ // with no skip-serializing, so the server sends an explicit `null` when no
14
+ // address is configured. `.optional()` alone accepts `undefined` and would
15
+ // throw on that valid response. Matches `lastCreditedAt` below.
16
+ payoutAddress: z.string().nullable().optional(),
17
+ buildercodesEnabled: z.boolean(),
18
+ buildercodesBudgetBps: z.number().int().min(0).max(10_000),
19
+ });
20
+ /** Pagination accepted by the per-trade payout history endpoint. */
21
+ export const ListBuildercodePayoutsParamsSchema = z.object({
22
+ page: z.number().int().min(1).max(10_000).optional(),
23
+ pageSize: z.number().int().min(1).max(100).optional(),
24
+ });
25
+ /** One per-trade BuilderCodes credit. Amounts are RAW atomic units. */
26
+ export const BuildercodePayoutSchema = z.object({
27
+ tradeId: z.string().uuid(),
28
+ payoutAddress: z.string(),
29
+ token: z.string(),
30
+ amount: z.string(),
31
+ appliedBps: z.number().int(),
32
+ createdAt: z.string(),
33
+ });
34
+ /** Schema for the paginated per-trade payout history. */
35
+ export const ListBuildercodePayoutsResponseSchema = z.object({
36
+ payouts: z.array(BuildercodePayoutSchema),
37
+ total: z.number().int().nonnegative(),
38
+ page: z.number().int().positive(),
39
+ pageSize: z.number().int().positive(),
40
+ totalPages: z.number().int().nonnegative(),
41
+ });
42
+ /** One token-denominated BuilderCodes earnings total. */
43
+ export const BuildercodePayoutTokenTotalSchema = z.object({
44
+ token: z.string(),
45
+ totalAmount: z.string(),
46
+ payoutCount: z.number().int().nonnegative(),
47
+ lastCreditedAt: z.string(),
48
+ });
49
+ /** Schema for this frontend's payout summary. */
50
+ export const GetBuildercodePayoutSummaryResponseSchema = z.object({
51
+ totalPayouts: z.number().int().nonnegative(),
52
+ lastCreditedAt: z.string().nullable().optional(),
53
+ byToken: z.array(BuildercodePayoutTokenTotalSchema),
54
+ });
55
+ /** One available balance in the reserved BuilderCodes reward bucket. */
56
+ export const BuildercodeRewardsBalanceSchema = z.object({
57
+ token: z.string(),
58
+ available: z.string(),
59
+ });
60
+ /** Schema for the caller wallet's reserved BuilderCodes balances. */
61
+ export const GetBuildercodeRewardsBalanceResponseSchema = z.object({
62
+ balances: z.array(BuildercodeRewardsBalanceSchema),
63
+ });
64
+ /** Schema for the claim-BuilderCodes-rewards request body. */
65
+ export const ClaimBuildercodeRewardsParamsSchema = z.object({
66
+ /**
67
+ * Payout token contract address (0x-prefixed) to claim. BuilderCodes shares
68
+ * accrue in the quote token of the traded pair.
69
+ */
70
+ token: z
71
+ .string()
72
+ .trim()
73
+ .min(1, "token is required")
74
+ .regex(/^0x[0-9a-fA-F]{40}$/, "token must be a 0x-prefixed EVM address"),
75
+ /**
76
+ * Amount to claim, in RAW atomic units of the token. Must be a positive
77
+ * integer string and no greater than the accrued payout balance — the server
78
+ * rejects an over-claim with 409 rather than moving a partial amount.
79
+ */
80
+ amount: z
81
+ .string()
82
+ .trim()
83
+ .min(1, "amount is required")
84
+ .refine((v) => /^\d+$/.test(v) && BigInt(v) > 0n, "amount must be a positive integer string"),
85
+ });
86
+ /** Schema for the claim-BuilderCodes-rewards response. */
87
+ export const ClaimBuildercodeRewardsResponseSchema = z.object({
88
+ /** Your BuilderCodes payout-bucket balance after the claim, RAW atomic units. */
89
+ payoutBalance: z.string(),
90
+ /** Your trading balance for the token after the claim, RAW atomic units. */
91
+ tradingBalance: z.string(),
92
+ });
package/dist/index.d.ts CHANGED
@@ -7,10 +7,12 @@
7
7
  export * from "./api";
8
8
  export * from "./applications";
9
9
  export * from "./auth";
10
+ export * from "./buildercodes";
10
11
  export * from "./contracts";
11
12
  export * from "./delegated-agents";
12
13
  export * from "./faucet";
13
14
  export * from "./fees";
15
+ export * from "./managed-markets";
14
16
  export * from "./margin-accounts";
15
17
  export * from "./market";
16
18
  export * from "./pitpass";
package/dist/index.js CHANGED
@@ -8,10 +8,12 @@
8
8
  export * from "./api";
9
9
  export * from "./applications";
10
10
  export * from "./auth";
11
+ export * from "./buildercodes";
11
12
  export * from "./contracts";
12
13
  export * from "./delegated-agents";
13
14
  export * from "./faucet";
14
15
  export * from "./fees";
16
+ export * from "./managed-markets";
15
17
  export * from "./margin-accounts";
16
18
  export * from "./market";
17
19
  export * from "./pitpass";
@@ -0,0 +1,63 @@
1
+ import type { BaseAPI } from "../api";
2
+ /** Exact uint64 decimal text. Never convert generation or revision through Number. */
3
+ export type ManagedMarketFence = string;
4
+ export type ManagedMarketPhase = "pending" | "validating" | "registering" | "warming" | "activating" | "live" | "failed" | (string & {});
5
+ export interface ManagedMarketLease {
6
+ launchId: string;
7
+ ownerId: string;
8
+ generation: ManagedMarketFence;
9
+ quoteRevision: ManagedMarketFence;
10
+ expiresAt: string;
11
+ refreshIntervalMs: number;
12
+ phase: ManagedMarketPhase;
13
+ }
14
+ export interface ManagedMarketAssignment {
15
+ launchId: string;
16
+ tradingPairId: string;
17
+ symbol: string;
18
+ phase: ManagedMarketPhase;
19
+ refreshIntervalMs: number;
20
+ allocationUsdc: string;
21
+ lease?: ManagedMarketLease;
22
+ /** False assignments remain expected inventory but cannot claim or quote. */
23
+ quoteEnabled: boolean;
24
+ }
25
+ export interface ListManagedMarketAssignmentsRequest {
26
+ page?: number;
27
+ pageSize?: number;
28
+ }
29
+ export interface ListManagedMarketAssignmentsResponse {
30
+ items: ManagedMarketAssignment[];
31
+ total: number;
32
+ page: number;
33
+ pageSize: number;
34
+ inventoryObservedAt: string;
35
+ }
36
+ export interface ClaimManagedMarketLeaseRequest {
37
+ ownerId: string;
38
+ /** Required for renewal; omit for initial claim or after expiry. */
39
+ expectedGeneration?: ManagedMarketFence;
40
+ }
41
+ export interface RefreshManagedMarketQuotesRequest {
42
+ ownerId: string;
43
+ generation: ManagedMarketFence;
44
+ quoteRevision: ManagedMarketFence;
45
+ }
46
+ export interface ManagedMarketQuoteStatus {
47
+ launchId: string;
48
+ generation: ManagedMarketFence;
49
+ quoteRevision: ManagedMarketFence;
50
+ phase: ManagedMarketPhase;
51
+ bidNotional: string;
52
+ askNotional: string;
53
+ oracleReady: boolean;
54
+ readyToActivate: boolean;
55
+ observedAt: string;
56
+ }
57
+ /** Wallet session identity selects assignments; delegated sessions are unsupported. ownerId only fences processes. */
58
+ export interface ManagedMarketsAPI extends BaseAPI {
59
+ listAssignments(request?: ListManagedMarketAssignmentsRequest): Promise<ListManagedMarketAssignmentsResponse>;
60
+ claimLease(launchId: string, request: ClaimManagedMarketLeaseRequest): Promise<ManagedMarketLease>;
61
+ /** On an unknown outcome, reconcile through claimLease before advancing revision. */
62
+ refreshQuotes(launchId: string, request: RefreshManagedMarketQuotesRequest): Promise<ManagedMarketQuoteStatus>;
63
+ }
File without changes
@@ -251,9 +251,25 @@ export type SimulateIsolatedRiskBucketOrderRiskRequest = SimulateOrderRiskReques
251
251
  strategyKey?: string;
252
252
  selectedTradingPairIds?: never;
253
253
  };
254
+ /**
255
+ * Preview an order against the account's cross risk bucket, or the
256
+ * deterministic bucket a first cross order would create. A cross preview names
257
+ * no pairs: cross scope is derived from trading — a pair joins the bucket when
258
+ * a cross order on it succeeds and, once its positions close, stays listed
259
+ * until a later successful cross order on another pair reconciles the bucket —
260
+ * so the previewed pair is in scope by construction. Read the derived scope
261
+ * the preview ran against from the response's `selectedTradingPairIds`.
262
+ */
254
263
  export type SimulateCrossRiskBucketOrderRiskRequest = SimulateOrderRiskRequest & {
255
264
  marginMode: "CROSS";
256
- selectedTradingPairIds: string[];
265
+ /**
266
+ * Removed. This used to declare the scope the preview ran against (required,
267
+ * containing `tradingPairId`, covering every open cross position) while the
268
+ * server never priced anything from it. The server now ignores the wire
269
+ * field; the SDK no longer sends it and rejects it here so a caller learns at
270
+ * compile time that it does nothing.
271
+ */
272
+ selectedTradingPairIds?: never;
257
273
  strategyKey?: never;
258
274
  };
259
275
  export type SimulateRiskBucketOrderRiskRequest = SimulateIsolatedRiskBucketOrderRiskRequest | SimulateCrossRiskBucketOrderRiskRequest;
@@ -264,6 +280,16 @@ export interface SimulateOrderRiskResponse {
264
280
  strategyKey?: string;
265
281
  riskBucketId?: string;
266
282
  marginMode?: MarginMode;
283
+ /**
284
+ * The cross scope the preview ran against; absent for isolated previews and
285
+ * never a caller's list. From `simulateRiskBucketOrderRisk` in CROSS mode it
286
+ * is the DERIVED scope: the active cross bucket's recorded pairs (a pair
287
+ * whose positions have closed stays recorded until a later cross order on
288
+ * another pair reconciles the bucket), every pair with an open position in
289
+ * that bucket, and the previewed pair — the previewed pair alone before the
290
+ * first cross order. `simulateOrderRisk` and `simulateParentMarginOrderRisk`
291
+ * report the recorded pairs plus the previewed pair.
292
+ */
267
293
  selectedTradingPairIds?: string[];
268
294
  equityAfter: string;
269
295
  initialMarginRequiredAfter: string;
@@ -107,6 +107,38 @@ export interface Position {
107
107
  * an understated partial.
108
108
  */
109
109
  cumFees?: string;
110
+ /**
111
+ * Opaque, non-negative producer-owned row version for this position
112
+ * (0XM-2673). Compare only within the same `positionId`; higher is newer.
113
+ *
114
+ * The same number the WebSocket `positions` snapshot and a RANKED live
115
+ * `position_update` frame carry, so this read can be ranked against them.
116
+ * Some live frames are deliberately unranked and omit `version` even when
117
+ * their state matches this row.
118
+ * `0` is the unranked legacy sentinel and never participates in ordering:
119
+ * treat it exactly as an absent version and fall back to a full field
120
+ * comparison rather than ranking it as oldest.
121
+ *
122
+ * The merge rule is PER FIELD GROUP, never per payload. On an EQUAL version
123
+ * skip the versioned fields as an idempotent redelivery — EXCEPT
124
+ * `isolatedMargin`, which the WebSocket positions snapshot overlays from an
125
+ * independent live matching-engine read rather than from the versioned row,
126
+ * so it can reflect a later command than the version names and must be
127
+ * taken from the newer payload. Also still take
128
+ * `markPrice`, `unrealizedPnl`, `liquidationPrice`, `leverage`,
129
+ * `maintenanceMarginRequired` and `initialMarginRequired` from the newer
130
+ * payload: those six are re-derived on every read rather than served from
131
+ * the versioned row, carry no version, and the version does not advance for
132
+ * them. Five move with the oracle mark; `leverage` does not, but the live
133
+ * surfaces derive it while the persisted row serves its stored column, so it
134
+ * can still disagree at an unchanged version.
135
+ * Discarding a whole payload on an equal version freezes displayed PnL
136
+ * until the position's next real mutation.
137
+ *
138
+ * A response served from live matching-engine state reports `0`: the engine
139
+ * holds the state but not the version, so it cannot rank itself.
140
+ */
141
+ version?: number;
110
142
  }
111
143
  export interface ListPositionsParams {
112
144
  marginAccountId?: string;
@@ -1,9 +1,11 @@
1
1
  import type { Address, PublicClient, TransactionReceipt, WalletClient } from "viem";
2
2
  import type { ApplicationsAPI } from "../applications";
3
3
  import type { AuthAPI, AuthState } from "../auth/index";
4
+ import type { BuildercodesAPI } from "../buildercodes";
4
5
  import type { DelegatedAgentsAPI } from "../delegated-agents";
5
6
  import type { FaucetAPI } from "../faucet";
6
7
  import type { FeesAPI } from "../fees";
8
+ import type { ManagedMarketsAPI } from "../managed-markets";
7
9
  import type { MarginAccountsAPI } from "../margin-accounts";
8
10
  import type { MarketAPI } from "../market";
9
11
  import type { PitpassAPI } from "../pitpass";
@@ -111,10 +113,13 @@ export interface MonacoSDK {
111
113
  subAccounts: SubAccountsAPI;
112
114
  /** PitPass TraderCode referral and rewards API */
113
115
  pitpass: PitpassAPI;
116
+ /** BuilderCodes frontend revenue-share payout API */
117
+ buildercodes: BuildercodesAPI;
114
118
  /** Testnet faucet API */
115
119
  faucet: FaucetAPI;
116
120
  /** Deposit-address registration (sweeper) API; requires a session */
117
121
  sweeper: SweeperAPI;
122
+ managedMarkets: ManagedMarketsAPI;
118
123
  /** Public whitelist (waitlist) submission API */
119
124
  whitelist: WhitelistAPI;
120
125
  /** Profile operations API */
@@ -260,4 +260,4 @@ export interface TradingAPI extends BaseAPI {
260
260
  }
261
261
  export type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, ListedOrderType, Order, OrderRole, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState, } from "./orders";
262
262
  export { ORDER_STATUS_VALUES } from "./orders";
263
- export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ReplaceOrderResponse, TwapOrder, UpdatedFields, } from "./responses";
263
+ export type { BatchCancelError, BatchCancelOrdersResponse, BatchCancelResult, BatchCreateOrderParams, BatchCreateOrdersResponse, BatchCreateResult, BatchError, BatchReplaceOrderParams, BatchReplaceOrdersResponse, BatchReplaceResult, CancelConditionalOrderResponse, CancelOrderResponse, CancelTwapOrderResponse, ConditionalOrder, CreateOrderResponse, CreateTwapOrderOptions, CreateTwapOrderResponse, GetOrderResponse, GetPaginatedOrdersParams, GetPaginatedOrdersResponse, GetTwapOrderTcaResponse, ListConditionalOrdersParams, ListConditionalOrdersResponse, ListTwapOrdersParams, ListTwapOrdersResponse, MatchResult, ParentTpSlLegParams, ReplaceOrderResponse, TriggeredOrderSummary, TwapOrder, UpdatedFields, } from "./responses";
@@ -112,6 +112,19 @@ export interface Order {
112
112
  conditional?: ConditionalOrder;
113
113
  /** Stable cause when status is CANCELLED */
114
114
  terminalReason?: OrderTerminalReason;
115
+ /**
116
+ * Present only on an order the engine placed for a take-profit or
117
+ * stop-loss trigger: the conditional order that fired it — the reverse of
118
+ * `ConditionalOrder.triggeredOrderId`, so a close in order history can be
119
+ * attributed to the TP/SL that produced it without scanning the
120
+ * conditional list (0XM-2745).
121
+ *
122
+ * Absent on every order you placed yourself, on TWAP slice children (those
123
+ * carry `parentOrderId` on the wire), and on triggered closes written before
124
+ * the field existed — there is no backfill, so a missing value on an older
125
+ * close means unknown, not "placed by hand". Wire: `conditionalOrderId`.
126
+ */
127
+ conditionalOrderId?: string;
115
128
  /**
116
129
  * Opaque, compare-only revision counter for this order's state: a strictly
117
130
  * higher value is strictly newer state for that order, and equal values
@@ -4,7 +4,7 @@
4
4
  * Response types for trading operations.
5
5
  */
6
6
  import type { MarginMode } from "../margin-accounts";
7
- import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderSide, OrderStatus, OrderStatusFilter, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState } from "./orders";
7
+ import type { ConditionalOrderConditionType, ConditionalOrderState, ConditionalOrderTriggerSource, Order, OrderSide, OrderStatus, OrderStatusFilter, OrderTerminalReason, OrderType, PositionSide, SelfTradePreventionMode, TimeInForce, TradingMode, TwapExecutionStyle, TwapOrderState } from "./orders";
8
8
  /**
9
9
  * Match result information for order execution.
10
10
  * Contains detailed information about trades, fills, and execution quality.
@@ -446,6 +446,46 @@ export interface ListConditionalOrdersParams {
446
446
  page?: number;
447
447
  pageSize?: number;
448
448
  }
449
+ /**
450
+ * What the order a conditional fired into has done so far — a projection of
451
+ * that order's own row, read at request time (0XM-2744).
452
+ *
453
+ * Trigger price and fill price are different numbers: the trigger fires on the
454
+ * mark, the leg then trades against the book, so a MARKET leg fills at least
455
+ * the half-spread (plus its own impact) away from `triggerPrice`, and a LIMIT
456
+ * leg may rest or fill only partly. Every value here is numerically equal to
457
+ * what `getOrder` returns for the same order, but the printed decimal scale
458
+ * can differ between the two reads (this summary is served from the database,
459
+ * `getOrder` from the cache), so compare numerically rather than byte for byte.
460
+ */
461
+ export interface TriggeredOrderSummary {
462
+ /** The triggered order's id — the same value as the parent's `triggeredOrderId`. */
463
+ orderId: string;
464
+ /**
465
+ * The triggered order's CURRENT status: `SETTLED` for a leg that filled in
466
+ * full (a fully filled order is written as `SETTLED`, so `FILLED` does not
467
+ * appear here); `SUBMITTED` / `PARTIALLY_FILLED` for a LIMIT leg still
468
+ * resting; `CANCELLED` when the protective band left nothing fillable (see
469
+ * `terminalReason`); `EXPIRED` for a LIMIT leg that lapsed. Never
470
+ * `REJECTED`: a close the engine refused leaves the conditional `FAILED`
471
+ * with no `triggeredOrderId`, so no summary exists for it.
472
+ */
473
+ status: OrderStatus;
474
+ /** Quantity filled so far, in base units; `"0"` until it fills. */
475
+ filledQuantity: string;
476
+ /**
477
+ * Volume-weighted average fill price. Compare with the parent's
478
+ * `triggerPrice`: the gap is the half-spread plus the order's own market
479
+ * impact. Absent until the first fill.
480
+ */
481
+ averageFillPrice?: string;
482
+ /** Total taker fees paid, in quote units. Absent until it fills. */
483
+ totalTakerFees?: string;
484
+ /** When the order reached FILLED (ISO 8601). Absent otherwise. */
485
+ filledAt?: string;
486
+ /** Stable cause when `status` is `CANCELLED`, same vocabulary as `Order.terminalReason`. */
487
+ terminalReason?: OrderTerminalReason;
488
+ }
449
489
  export interface ConditionalOrder {
450
490
  conditionalOrderId: string;
451
491
  tradingPairId: string;
@@ -496,6 +536,17 @@ export interface ConditionalOrder {
496
536
  * zero. Wire: `version`.
497
537
  */
498
538
  version?: number;
539
+ /**
540
+ * The execution outcome of the order this conditional fired into
541
+ * (`triggeredOrderId`) — status, filled quantity, average fill price, fees
542
+ * and fill time — read from that order at request time (0XM-2744).
543
+ *
544
+ * Present only when `state` is `TRIGGERED` and the triggered order could be
545
+ * read. Absent while waiting on the trigger, on the `conditional_orders`
546
+ * WebSocket frames (snapshot and live), and in the rare case the close
547
+ * cannot be read. Wire: `triggeredOrder`.
548
+ */
549
+ triggeredOrder?: TriggeredOrderSummary;
499
550
  }
500
551
  export interface ListConditionalOrdersResponse {
501
552
  orders: ConditionalOrder[];
@@ -124,7 +124,13 @@ export declare const SimulateParentMarginOrderRiskSchema: z.ZodObject<{
124
124
  }, z.core.$strict>;
125
125
  }, z.core.$strip>;
126
126
  export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
127
- request: z.ZodUnion<readonly [z.ZodObject<{
127
+ request: z.ZodPipe<z.ZodObject<{
128
+ marginMode: z.ZodOptional<z.ZodEnum<{
129
+ ISOLATED: "ISOLATED";
130
+ CROSS: "CROSS";
131
+ }>>;
132
+ selectedTradingPairIds: z.ZodOptional<z.ZodUnknown>;
133
+ }, z.core.$loose>, z.ZodUnion<readonly [z.ZodObject<{
128
134
  side: z.ZodEnum<{
129
135
  BUY: "BUY";
130
136
  SELL: "SELL";
@@ -167,7 +173,7 @@ export declare const SimulateRiskBucketOrderRiskSchema: z.ZodObject<{
167
173
  leverage: z.ZodOptional<z.ZodString>;
168
174
  reduceOnly: z.ZodOptional<z.ZodBoolean>;
169
175
  marginMode: z.ZodLiteral<"CROSS">;
170
- selectedTradingPairIds: z.ZodArray<z.ZodUUID>;
176
+ selectedTradingPairIds: z.ZodOptional<z.ZodNever>;
171
177
  strategyKey: z.ZodOptional<z.ZodNever>;
172
- }, z.core.$strict>]>;
178
+ }, z.core.$strict>]>>;
173
179
  }, z.core.$strip>;