@0xmonaco/types 0.8.5 → 0.8.7-develop.0f12336

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +5 -3
  2. package/dist/api/index.d.ts +13 -5
  3. package/dist/api/index.js +1 -1
  4. package/dist/applications/index.d.ts +47 -5
  5. package/dist/applications/index.js +2 -1
  6. package/dist/applications/requests.d.ts +78 -0
  7. package/dist/applications/requests.js +7 -0
  8. package/dist/applications/responses.d.ts +213 -2
  9. package/dist/applications/responses.js +3 -1
  10. package/dist/auth/index.d.ts +29 -31
  11. package/dist/auth/index.js +2 -2
  12. package/dist/auth/responses.d.ts +25 -21
  13. package/dist/contracts/balances.d.ts +1 -1
  14. package/dist/delegated-agents/index.d.ts +35 -18
  15. package/dist/faucet/index.d.ts +54 -0
  16. package/dist/faucet/index.js +10 -0
  17. package/dist/fees/index.d.ts +4 -4
  18. package/dist/fees/responses.d.ts +17 -17
  19. package/dist/fees/responses.js +20 -20
  20. package/dist/index.d.ts +4 -0
  21. package/dist/index.js +4 -0
  22. package/dist/margin-accounts/index.d.ts +91 -55
  23. package/dist/market/index.d.ts +214 -94
  24. package/dist/positions/index.d.ts +67 -44
  25. package/dist/profile/index.d.ts +157 -67
  26. package/dist/sdk/index.d.ts +43 -5
  27. package/dist/sub-accounts/index.d.ts +146 -0
  28. package/dist/sub-accounts/index.js +9 -0
  29. package/dist/trading/index.d.ts +8 -8
  30. package/dist/trading/orders.d.ts +20 -20
  31. package/dist/trading/responses.d.ts +82 -101
  32. package/dist/validation/margin-accounts.d.ts +53 -13
  33. package/dist/validation/margin-accounts.js +38 -14
  34. package/dist/validation/market.d.ts +1 -1
  35. package/dist/validation/market.js +1 -1
  36. package/dist/validation/positions.d.ts +11 -7
  37. package/dist/validation/positions.js +10 -6
  38. package/dist/validation/profile.d.ts +13 -6
  39. package/dist/validation/profile.js +13 -6
  40. package/dist/validation/trading.d.ts +17 -42
  41. package/dist/validation/trading.js +51 -42
  42. package/dist/validation/vault.d.ts +8 -0
  43. package/dist/validation/vault.js +3 -0
  44. package/dist/vault/index.d.ts +46 -13
  45. package/dist/vault/responses.d.ts +50 -12
  46. package/dist/websocket/events/balance-events.d.ts +2 -1
  47. package/dist/websocket/events/movement-events.d.ts +2 -1
  48. package/dist/whitelist/index.d.ts +44 -0
  49. package/dist/whitelist/index.js +10 -0
  50. package/dist/wire/assert.d.ts +54 -0
  51. package/dist/wire/assert.js +0 -0
  52. package/dist/wire/audit.d.ts +47 -0
  53. package/dist/wire/audit.js +43 -0
  54. package/dist/wire/coverage.d.ts +1 -0
  55. package/dist/wire/coverage.js +0 -0
  56. package/dist/wire/index.d.ts +21 -0
  57. package/dist/wire/index.js +2 -0
  58. package/dist/wire/operations.d.ts +15 -0
  59. package/dist/wire/operations.js +101 -0
  60. package/dist/wire/schema.d.ts +8930 -0
  61. package/dist/wire/schema.js +4 -0
  62. package/dist/withdrawals/index.d.ts +114 -0
  63. package/dist/withdrawals/index.js +0 -0
  64. package/package.json +6 -2
@@ -3,8 +3,25 @@
3
3
  *
4
4
  * Types for vault operations including deposits, withdrawals, and balance management.
5
5
  */
6
+ import type { Address } from "viem";
6
7
  import type { BaseAPI } from "../api/index";
7
- import type { Balance, TransactionResult, WithdrawResult } from "./responses";
8
+ import type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult } from "./responses";
9
+ /**
10
+ * Destination ledger for a deposit.
11
+ * - `"spot"` (default): credit the spot/main wallet — unchanged behavior.
12
+ * - `"margin"`: route the deposit straight into the parent margin account's
13
+ * collateral (auto-creating the account if it does not exist yet). A deposit
14
+ * that cannot be routed to margin (unsupported asset, etc.) safely falls back
15
+ * to spot — funds are never lost.
16
+ */
17
+ export type DepositTarget = "spot" | "margin";
18
+ /**
19
+ * Source ledger for an external withdrawal.
20
+ * - `"spot"` (default): withdraw from the spot/main wallet.
21
+ * - `"margin"`: directly withdraw from the parent margin account's
22
+ * withdrawable collateral.
23
+ */
24
+ export type WithdrawalSource = "spot" | "margin";
8
25
  /**
9
26
  * Vault API interface.
10
27
  * Provides methods for managing token deposits and withdrawals.
@@ -24,31 +41,47 @@ export interface VaultAPI extends BaseAPI {
24
41
  * @param assetId - Asset identifier (UUID) to deposit
25
42
  * @param amount - Amount to deposit
26
43
  * @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
44
+ * @param target - Destination ledger: `"spot"` (default) or `"margin"` to
45
+ * route the deposit into the parent margin account's collateral. Margin
46
+ * deposits that cannot be routed fall back to spot.
27
47
  * @returns Promise resolving to the transaction result
28
48
  */
29
- deposit(assetId: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
49
+ deposit(assetId: string, amount: bigint, autoWait?: boolean, target?: DepositTarget): Promise<TransactionResult>;
30
50
  /**
31
- * Initiates a withdrawal: allocates a `withdrawalIndex` via the API Gateway,
32
- * receives pre-signed calldata for `executeSignedWithdrawal(...)`, and
33
- * submits it on-chain through the connected wallet.
51
+ * Initiates a withdrawal and submits its `executeWithdrawal(...)` calldata
52
+ * on-chain through the connected wallet.
53
+ *
54
+ * The API Gateway allocates a `withdrawalIndex` and debits the balance, but
55
+ * the executable calldata requires the withdrawal's merkle proof, which only
56
+ * exists once its root is confirmed on-chain (a process that can take a
57
+ * while). This method polls `GET /withdrawals/{index}` until the calldata is
58
+ * available — retrying while the gateway reports it is not yet confirmed —
59
+ * then submits it.
34
60
  *
35
61
  * @param assetId - Asset identifier (UUID) to withdraw
36
62
  * @param amount - Raw token amount (smallest unit, as bigint)
37
63
  * @param autoWait - Whether to await on-chain confirmation (defaults to true)
64
+ * @param source - Source ledger: `"spot"` (default) or `"margin"` to source
65
+ * funds directly from the parent margin account's withdrawable collateral
66
+ * @param retry - Polling cadence/timeout while waiting for the proof
38
67
  * @returns Promise resolving to `{ withdrawalIndex, transaction }`
39
68
  */
40
- withdraw(assetId: string, amount: bigint, autoWait?: boolean): Promise<WithdrawResult>;
69
+ withdraw(assetId: string, amount: bigint, autoWait?: boolean, source?: WithdrawalSource, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
70
+ withdraw(assetId: string, amount: bigint, autoWait?: boolean, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
41
71
  /**
42
- * Retries a previously-initiated withdrawal whose on-chain submission never
43
- * landed (wallet rejected, page reloaded before receipt, stuck mempool).
44
- * Re-fetches the same signed calldata and resubmits via the connected wallet
45
- * does NOT initiate a new withdrawal.
72
+ * Submits (or resubmits) a previously-initiated withdrawal on-chain. Polls
73
+ * for the `executeWithdrawal` calldata the same way as `withdraw` — useful
74
+ * when the original submission never landed (wallet rejected, page reloaded
75
+ * before receipt, stuck mempool) or when the proof was not yet available at
76
+ * the time of the original `withdraw()` call. Does NOT initiate a new
77
+ * withdrawal.
46
78
  *
47
79
  * @param withdrawalIndex - Index returned by the original `withdraw()` call
48
80
  * @param autoWait - Whether to await on-chain confirmation (defaults to true)
81
+ * @param retry - Polling cadence/timeout while waiting for the proof
49
82
  * @returns Promise resolving to `{ withdrawalIndex, ...transaction }`
50
83
  */
51
- retryWithdrawal(withdrawalIndex: number, autoWait?: boolean): Promise<WithdrawResult>;
84
+ retryWithdrawal(withdrawalIndex: number, autoWait?: boolean, retry?: WithdrawalRetryOptions): Promise<WithdrawResult>;
52
85
  /**
53
86
  * Gets the balance of a token in the vault.
54
87
  * @param assetId - Asset identifier (UUID) to check
@@ -73,7 +106,7 @@ export interface VaultAPI extends BaseAPI {
73
106
  * Gets the address of the vault.
74
107
  * @returns Promise resolving to the address of the vault
75
108
  */
76
- getVaultAddress(): Promise<string>;
109
+ getVaultAddress(): Promise<Address>;
77
110
  /**
78
111
  * Sets the wallet client for signing transactions.
79
112
  * Used when the wallet becomes available after SDK initialization.
@@ -81,4 +114,4 @@ export interface VaultAPI extends BaseAPI {
81
114
  */
82
115
  setWalletClient(walletClient: unknown): void;
83
116
  }
84
- export type { Balance, TransactionResult, WithdrawResult } from "./responses";
117
+ export type { Balance, TransactionResult, WithdrawalRetryOptions, WithdrawResult } from "./responses";
@@ -3,6 +3,7 @@
3
3
  *
4
4
  * Response types for vault operations.
5
5
  */
6
+ import type { Address } from "viem";
6
7
  /**
7
8
  * Response from a transaction.
8
9
  */
@@ -17,29 +18,66 @@ export interface TransactionResult {
17
18
  receipt?: import("viem").TransactionReceipt;
18
19
  }
19
20
  /**
20
- * Result of initiating a withdrawal.
21
+ * Result of a withdrawal.
21
22
  *
22
23
  * The API gateway allocates a `withdrawalIndex` via the matching engine and
23
- * returns pre-signed calldata for the vault contract's
24
- * `executeSignedWithdrawal(...)` function. The SDK submits that calldata on
25
- * behalf of the connected wallet the user is the on-chain caller, but the
26
- * `WITHDRAWAL_SIGNER` signature embedded in the calldata is what the contract
27
- * authenticates against.
24
+ * debits the balance immediately. The executable `executeWithdrawal(...)`
25
+ * calldata only exists once the withdrawal's root is confirmed on-chain and its
26
+ * merkle proof is persisted; the SDK polls for it and submits it through the
27
+ * connected wallet.
28
28
  *
29
- * Extends [`TransactionResult`] so callers can read `hash`, `status`, `nonce`
30
- * (and `receipt` when `autoWait` is true) directly off the result, just like
31
- * `approve` / `deposit`.
29
+ * `withdrawalIndex` is therefore ALWAYS present even when the proof did not
30
+ * become available within the poll window. In that case `status` is
31
+ * `"awaiting_proof"` and no transaction was submitted (`hash`, `nonce`, and
32
+ * `receipt` are absent); the caller keeps `withdrawalIndex` and finishes the
33
+ * withdrawal later with `retryWithdrawal(withdrawalIndex)`. This is why the
34
+ * transaction fields are optional rather than inherited as required from
35
+ * [`TransactionResult`]: a debited-but-unproven withdrawal must never strand the
36
+ * index inside a thrown error.
32
37
  */
33
- export interface WithdrawResult extends TransactionResult {
34
- /** Allocated withdrawal index — matches `executeSignedWithdrawal.index`. */
38
+ export interface WithdrawResult {
39
+ /** Allocated withdrawal index — matches `executeWithdrawal.index`. Always present. */
35
40
  withdrawalIndex: number;
41
+ /**
42
+ * Outcome of the withdrawal:
43
+ * - `"awaiting_proof"` — index allocated and balance debited, but the merkle
44
+ * proof was not available within the poll window, so nothing was submitted
45
+ * on-chain. Call `retryWithdrawal(withdrawalIndex)` once the root confirms.
46
+ * - `"pending" | "confirmed" | "failed"` — the calldata was submitted on-chain;
47
+ * semantics match [`TransactionResult.status`].
48
+ */
49
+ status: TransactionResult["status"] | "awaiting_proof";
50
+ /** Transaction hash — absent when `status === "awaiting_proof"`. */
51
+ hash?: string;
52
+ /** Nonce used for the on-chain submission — absent when `status === "awaiting_proof"`. */
53
+ nonce?: bigint;
54
+ /** Transaction receipt (only when `autoWait` is enabled and the tx was submitted). */
55
+ receipt?: import("viem").TransactionReceipt;
56
+ }
57
+ /**
58
+ * Controls how the SDK polls for a withdrawal's `executeWithdrawal` calldata
59
+ * while its merkle proof is not yet available (the withdrawal root has not been
60
+ * confirmed on-chain). The gateway returns 404 (row not persisted yet) or 409
61
+ * (proof not confirmed yet) until ready; the SDK retries on both.
62
+ */
63
+ export interface WithdrawalRetryOptions {
64
+ /** Delay between polls, in milliseconds. Defaults to 5000. */
65
+ pollIntervalMs?: number;
66
+ /**
67
+ * Maximum total time to wait for the proof, in milliseconds. Defaults to
68
+ * 300_000 (5 minutes). On timeout the SDK does not throw — `withdraw` /
69
+ * `retryWithdrawal` return `{ status: "awaiting_proof", withdrawalIndex }` so
70
+ * the caller can retry later. Pass `Infinity` to poll indefinitely until the
71
+ * proof is available.
72
+ */
73
+ timeoutMs?: number;
36
74
  }
37
75
  /**
38
76
  * Token balance information.
39
77
  */
40
78
  export interface Balance {
41
79
  /** Token address */
42
- token: string;
80
+ token: Address;
43
81
  /** Balance amount */
44
82
  amount: bigint;
45
83
  /** Formatted balance string */
@@ -4,6 +4,7 @@
4
4
  * Types for real-time user balance update events.
5
5
  * This is an authenticated channel - requires JWT token.
6
6
  */
7
+ import type { Address } from "viem";
7
8
  /**
8
9
  * Reason for the balance update
9
10
  */
@@ -13,7 +14,7 @@ export type BalanceUpdateReason = "lock" | "unlock" | "deposit" | "withdrawal" |
13
14
  */
14
15
  export interface UserBalanceEventData {
15
16
  /** Token contract address */
16
- tokenAddress: string;
17
+ tokenAddress: Address;
17
18
  /** Token symbol */
18
19
  tokenSymbol: string | null;
19
20
  /** Available balance for trading (normalized) */
@@ -4,6 +4,7 @@
4
4
  * Types for real-time user ledger movement events (deposits, withdrawals, transfers).
5
5
  * This is an authenticated channel - requires JWT token.
6
6
  */
7
+ import type { Address } from "viem";
7
8
  /**
8
9
  * User movement event data containing ledger entry details
9
10
  */
@@ -15,7 +16,7 @@ export interface UserMovementEventData {
15
16
  /** Transaction type (e.g., "deposit", "withdrawal", "trade") */
16
17
  transactionType: string;
17
18
  /** Token contract address */
18
- tokenAddress: string;
19
+ tokenAddress: Address;
19
20
  /** Token symbol */
20
21
  symbol?: string;
21
22
  /** Token decimals */
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Whitelist Types
3
+ *
4
+ * Types for the public whitelist (waitlist) application endpoint. Wire shapes
5
+ * are snake_case.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and creates an inactive
8
+ * user pending manual approval — it is an onboarding/waitlist submission, not a
9
+ * trading operation.
10
+ */
11
+ import type { BaseAPI } from "../api";
12
+ /** Body for a whitelist application. */
13
+ export interface SubmitWhitelistRequest {
14
+ /** Applicant wallet address (0x-prefixed, 40 hex chars) */
15
+ walletAddress: string;
16
+ /** Applicant email address */
17
+ email: string;
18
+ /** Applicant Twitter/X username (1-15 chars) */
19
+ twitterUsername?: string;
20
+ /** Applicant Telegram username (5-32 chars) */
21
+ telegramUsername?: string;
22
+ }
23
+ /** Response to a whitelist application. */
24
+ export interface SubmitWhitelistResponse {
25
+ /** Human-readable status message */
26
+ message: string;
27
+ /** Created user UUID (pending approval) */
28
+ userId: string | null;
29
+ }
30
+ /**
31
+ * Whitelist API interface. The submit endpoint is public (no auth required).
32
+ */
33
+ export interface WhitelistAPI extends BaseAPI {
34
+ /**
35
+ * Submits a whitelist (waitlist) application.
36
+ *
37
+ * Public/unauthenticated. The server validates and de-duplicates by wallet
38
+ * address and email, creating an inactive user pending approval.
39
+ *
40
+ * @param body - Applicant details
41
+ * @returns Promise resolving to the status message and created user id
42
+ */
43
+ submit(body: SubmitWhitelistRequest): Promise<SubmitWhitelistResponse>;
44
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Whitelist Types
3
+ *
4
+ * Types for the public whitelist (waitlist) application endpoint. Wire shapes
5
+ * are snake_case.
6
+ *
7
+ * NOTE: This endpoint is **public (unauthenticated)** and creates an inactive
8
+ * user pending manual approval — it is an onboarding/waitlist submission, not a
9
+ * trading operation.
10
+ */
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Compile-time helpers that tie the hand-written ergonomic SDK types to the
3
+ * generated wire schema in `./schema.ts`.
4
+ *
5
+ * Everything here lives purely at the type level — there is no runtime output —
6
+ * so a field the OpenAPI spec gains but an ergonomic type forgot to declare
7
+ * becomes a `tsc` error. This is the type-checking half of the MON-1476 drift
8
+ * tripwire (the other half is the CI fail-on-diff check on the generated
9
+ * `schema.ts`). See `./README.md` for how to register a new type.
10
+ */
11
+ import type { components } from "./schema";
12
+ /** All schema component types generated from the OpenAPI spec. */
13
+ export type WireSchemas = components["schemas"];
14
+ /** A single generated wire schema, addressed by its OpenAPI component name. */
15
+ export type WireSchema<K extends keyof WireSchemas> = WireSchemas[K];
16
+ /** Strip every `_` from a string-literal type: `a_b_c` -> `abc`. */
17
+ type StripUnderscores<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${StripUnderscores<Tail>}` : S;
18
+ /**
19
+ * Canonical form of a field name: lower-cased and underscore-free, so that
20
+ * snake_case (`available_balance`) and camelCase (`availableBalance`) names
21
+ * collapse to the same key. This lets the coverage check ignore the casing
22
+ * convention a given ergonomic domain happens to use.
23
+ *
24
+ * Caveat: names that differ only by case (e.g. `T` vs `t`) collapse together —
25
+ * do not register types that rely on such a distinction.
26
+ */
27
+ type CanonicalKey<S extends string> = Lowercase<StripUnderscores<S>>;
28
+ /** Re-key an object type by the canonical form of each of its string keys. */
29
+ type CanonicalKeys<T> = {
30
+ [K in keyof T as K extends string ? CanonicalKey<K> : never]: true;
31
+ };
32
+ /** Canonical wire field names that the ergonomic type `Ergo` does not declare. */
33
+ export type MissingWireFields<Ergo, Wire> = Exclude<keyof CanonicalKeys<Wire>, keyof CanonicalKeys<Ergo>>;
34
+ /**
35
+ * Resolves to `true` when `Ergo` declares every field the wire schema `Wire`
36
+ * has (comparing canonical names, so casing/underscore style is irrelevant and
37
+ * ergonomic enrichments — extra fields, bigint/branded value types — are
38
+ * allowed). Otherwise resolves to an error object naming the missing fields, so
39
+ * a failing {@link Expect} points straight at the drift.
40
+ */
41
+ export type WireCovered<Ergo, Wire> = [MissingWireFields<Ergo, Wire>] extends [never] ? true : {
42
+ __MISSING_WIRE_FIELDS__: MissingWireFields<Ergo, Wire>;
43
+ };
44
+ /**
45
+ * Assertion sink. `Expect<WireCovered<Ergo, Wire>>` is a type alias that only
46
+ * type-checks when its argument is exactly `true`, emitting no runtime code:
47
+ *
48
+ * type _Balance = Expect<WireCovered<AccountBalance, WireSchema<"AccountBalance">>>;
49
+ *
50
+ * If `WireCovered` resolves to the error object, `T extends true` fails and
51
+ * `tsc` reports the missing wire fields at this line.
52
+ */
53
+ export type Expect<T extends true> = T;
54
+ export {};
File without changes
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Endpoint-coverage audit (MON-1489 gate logic).
3
+ *
4
+ * Each hand-written SDK surface (`@0xmonaco/core`, `@0xmonaco/react`,
5
+ * `@0xmonaco/mcp-server`) maintains a `coverage.ts` with two registries: a
6
+ * `COVERED` map (operationId → the ergonomic method/hook/tool that implements
7
+ * it) and an `INTENTIONALLY_EXCLUDED` map (operationId → reason it is
8
+ * deliberately not surfaced). {@link auditSurface} checks those two registries
9
+ * against the full {@link OPERATION_IDS} list and reports any operationId that
10
+ * is left unclassified (in neither), double-classified (in both), or stale (a
11
+ * registry key that is no longer a real operationId).
12
+ *
13
+ * This is the runtime counterpart to the `satisfies Partial<Record<keyof
14
+ * operations, string>>` constraint each registry already carries: that
15
+ * constraint makes every *key* a compile-time-checked operationId, while this
16
+ * audit makes the *set* of keys provably exhaustive. A new proto REST endpoint
17
+ * forces a new operationId into the generated `OPERATION_IDS`, and the surface
18
+ * build/CI fails here until a developer either implements it or excludes it
19
+ * with a reason — mirroring the MON-1475 route↔spec allowlist UX.
20
+ */
21
+ import { type OperationId } from "./operations";
22
+ import type { operations } from "./schema";
23
+ /** A surface's coverage registries (the two maps exported by its `coverage.ts`). */
24
+ export interface SurfaceClassification {
25
+ /** operationId → the SDK symbol (method/hook/tool) that covers it. */
26
+ covered: Partial<Record<keyof operations, string>>;
27
+ /** operationId → the reason it is intentionally not covered. */
28
+ excluded: Partial<Record<keyof operations, string>>;
29
+ }
30
+ /** Result of auditing one surface's classification against the spec. */
31
+ export interface CoverageAudit {
32
+ /** operationIds in the spec that appear in neither `covered` nor `excluded`. */
33
+ unclassified: OperationId[];
34
+ /** operationIds listed in BOTH `covered` and `excluded`. */
35
+ duplicated: string[];
36
+ /** Registry keys that are not (or no longer) real operationIds. */
37
+ unknown: string[];
38
+ /** True when the surface classifies every operationId exactly once. */
39
+ ok: boolean;
40
+ }
41
+ /**
42
+ * Audit one surface: assert `covered ∪ excluded == operationIds` and that the
43
+ * two sets are disjoint and free of stale keys. `operationIds` defaults to the
44
+ * generated {@link OPERATION_IDS}; it is injectable so the gate's own tests can
45
+ * exercise synthetic op sets.
46
+ */
47
+ export declare function auditSurface(classification: SurfaceClassification, operationIds?: readonly string[]): CoverageAudit;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Endpoint-coverage audit (MON-1489 gate logic).
3
+ *
4
+ * Each hand-written SDK surface (`@0xmonaco/core`, `@0xmonaco/react`,
5
+ * `@0xmonaco/mcp-server`) maintains a `coverage.ts` with two registries: a
6
+ * `COVERED` map (operationId → the ergonomic method/hook/tool that implements
7
+ * it) and an `INTENTIONALLY_EXCLUDED` map (operationId → reason it is
8
+ * deliberately not surfaced). {@link auditSurface} checks those two registries
9
+ * against the full {@link OPERATION_IDS} list and reports any operationId that
10
+ * is left unclassified (in neither), double-classified (in both), or stale (a
11
+ * registry key that is no longer a real operationId).
12
+ *
13
+ * This is the runtime counterpart to the `satisfies Partial<Record<keyof
14
+ * operations, string>>` constraint each registry already carries: that
15
+ * constraint makes every *key* a compile-time-checked operationId, while this
16
+ * audit makes the *set* of keys provably exhaustive. A new proto REST endpoint
17
+ * forces a new operationId into the generated `OPERATION_IDS`, and the surface
18
+ * build/CI fails here until a developer either implements it or excludes it
19
+ * with a reason — mirroring the MON-1475 route↔spec allowlist UX.
20
+ */
21
+ import { OPERATION_IDS } from "./operations";
22
+ /**
23
+ * Audit one surface: assert `covered ∪ excluded == operationIds` and that the
24
+ * two sets are disjoint and free of stale keys. `operationIds` defaults to the
25
+ * generated {@link OPERATION_IDS}; it is injectable so the gate's own tests can
26
+ * exercise synthetic op sets.
27
+ */
28
+ export function auditSurface(classification, operationIds = OPERATION_IDS) {
29
+ const covered = Object.keys(classification.covered);
30
+ const excluded = Object.keys(classification.excluded);
31
+ const all = new Set(operationIds);
32
+ const classified = new Set([...covered, ...excluded]);
33
+ const excludedSet = new Set(excluded);
34
+ const unclassified = operationIds.filter((op) => !classified.has(op));
35
+ const duplicated = covered.filter((op) => excludedSet.has(op)).sort();
36
+ const unknown = [...new Set([...covered, ...excluded].filter((op) => !all.has(op)))].sort();
37
+ return {
38
+ unclassified: unclassified,
39
+ duplicated,
40
+ unknown,
41
+ ok: unclassified.length === 0 && duplicated.length === 0 && unknown.length === 0,
42
+ };
43
+ }
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Generated wire-types layer (MON-1476 drift tripwire).
3
+ *
4
+ * `schema.ts` is generated from `docs/src/proto-openapi/api/openapi.yaml` by
5
+ * `make ts-wire-gen` — do not edit it by hand. This barrel re-exports the
6
+ * generated `paths` / `components` / `operations` interfaces plus the
7
+ * {@link WireSchema} / {@link WireCovered} helpers the ergonomic types use to
8
+ * stay in sync with the spec.
9
+ *
10
+ * Consumers import the raw spec types from the `@0xmonaco/types/wire` subpath;
11
+ * the ergonomic types in the rest of the package are the supported surface.
12
+ *
13
+ * It also exports the generated runtime `OPERATION_IDS` list and the
14
+ * `auditSurface` helper that power the MON-1489 endpoint-coverage gate.
15
+ */
16
+ export type { Expect, MissingWireFields, WireCovered, WireSchema, WireSchemas } from "./assert";
17
+ export type { CoverageAudit, SurfaceClassification } from "./audit";
18
+ export { auditSurface } from "./audit";
19
+ export type { OperationId } from "./operations";
20
+ export { OPERATION_IDS } from "./operations";
21
+ export type { components, operations, paths } from "./schema";
@@ -0,0 +1,2 @@
1
+ export { auditSurface } from "./audit";
2
+ export { OPERATION_IDS } from "./operations";
@@ -0,0 +1,15 @@
1
+ /**
2
+ * GENERATED — DO NOT EDIT BY HAND.
3
+ *
4
+ * Runtime list of every OpenAPI operationId in the canonical spec
5
+ * (docs/src/proto-openapi/api/openapi.yaml), emitted by `make ts-wire-gen`
6
+ * (scripts/gen-operation-ids.ts) alongside the type-only `schema.ts`.
7
+ *
8
+ * The MON-1489 endpoint-coverage gate iterates this list to assert that every
9
+ * operationId is classified (covered or intentionally excluded) on each
10
+ * hand-written SDK surface. CI regenerates it and fails on a diff, identical to
11
+ * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
+ */
13
+ export declare const OPERATION_IDS: readonly ["add_position_margin", "attach_position_tp_sl", "authenticate_backend", "batch_cancel_all", "batch_cancel_all_by_pair", "batch_cancel_orders", "batch_close_all_positions", "batch_create_orders", "batch_replace_orders", "cancel_conditional_order", "cancel_order", "close_position", "create_challenge", "create_delegated_session", "create_order", "create_sub_account_limit", "delete_sub_account_limit", "get_application_config", "get_application_stats", "get_available_collateral", "get_candles", "get_funding_state", "get_index_price", "get_margin_account_movements", "get_margin_account_summary", "get_mark_price", "get_market_metadata", "get_market_stats", "get_open_interest", "get_order_by_id", "get_orderbook_snapshot", "get_orders", "get_parent_margin_account_movements", "get_parent_margin_account_summary", "get_perp_market_config", "get_perp_market_summary", "get_portfolio_chart", "get_portfolio_stats", "get_position", "get_position_risk", "get_screener", "get_sub_account_limits", "get_trade_by_id", "get_trades", "get_trading_pair_by_id", "get_user_balance_by_asset", "get_user_balances", "get_user_movements", "get_user_profile", "get_user_trades", "get_withdrawal", "health_check", "initiate_withdrawal", "list_application_balances", "list_application_movements", "list_application_orders", "list_application_users", "list_conditional_orders", "list_delegated_agent_owners", "list_delegated_agents", "list_funding_history", "list_funding_payments", "list_margin_accounts", "list_pending_withdrawals", "list_position_history", "list_positions", "list_sub_accounts_with_balances", "list_trading_pairs", "mint_tokens", "reduce_position_margin", "refresh_session", "replace_order", "revoke_delegated_agent", "revoke_session", "simulate_fees", "simulate_order_risk", "simulate_parent_margin_order_risk", "simulate_risk_bucket_order_risk", "submit_whitelist", "transfer_collateral_from_margin_account", "transfer_collateral_from_parent_margin_account", "transfer_collateral_to_margin_account", "transfer_collateral_to_parent_margin_account", "transfer_collateral_to_risk_bucket", "update_sub_account_limit", "upsert_delegated_agent", "verify_signature"];
14
+ /** Union of every OpenAPI operationId in the spec. */
15
+ export type OperationId = (typeof OPERATION_IDS)[number];
@@ -0,0 +1,101 @@
1
+ /**
2
+ * GENERATED — DO NOT EDIT BY HAND.
3
+ *
4
+ * Runtime list of every OpenAPI operationId in the canonical spec
5
+ * (docs/src/proto-openapi/api/openapi.yaml), emitted by `make ts-wire-gen`
6
+ * (scripts/gen-operation-ids.ts) alongside the type-only `schema.ts`.
7
+ *
8
+ * The MON-1489 endpoint-coverage gate iterates this list to assert that every
9
+ * operationId is classified (covered or intentionally excluded) on each
10
+ * hand-written SDK surface. CI regenerates it and fails on a diff, identical to
11
+ * the `schema.ts` wire-types tripwire (MON-1476), so it can never go stale.
12
+ */
13
+ export const OPERATION_IDS = [
14
+ "add_position_margin",
15
+ "attach_position_tp_sl",
16
+ "authenticate_backend",
17
+ "batch_cancel_all",
18
+ "batch_cancel_all_by_pair",
19
+ "batch_cancel_orders",
20
+ "batch_close_all_positions",
21
+ "batch_create_orders",
22
+ "batch_replace_orders",
23
+ "cancel_conditional_order",
24
+ "cancel_order",
25
+ "close_position",
26
+ "create_challenge",
27
+ "create_delegated_session",
28
+ "create_order",
29
+ "create_sub_account_limit",
30
+ "delete_sub_account_limit",
31
+ "get_application_config",
32
+ "get_application_stats",
33
+ "get_available_collateral",
34
+ "get_candles",
35
+ "get_funding_state",
36
+ "get_index_price",
37
+ "get_margin_account_movements",
38
+ "get_margin_account_summary",
39
+ "get_mark_price",
40
+ "get_market_metadata",
41
+ "get_market_stats",
42
+ "get_open_interest",
43
+ "get_order_by_id",
44
+ "get_orderbook_snapshot",
45
+ "get_orders",
46
+ "get_parent_margin_account_movements",
47
+ "get_parent_margin_account_summary",
48
+ "get_perp_market_config",
49
+ "get_perp_market_summary",
50
+ "get_portfolio_chart",
51
+ "get_portfolio_stats",
52
+ "get_position",
53
+ "get_position_risk",
54
+ "get_screener",
55
+ "get_sub_account_limits",
56
+ "get_trade_by_id",
57
+ "get_trades",
58
+ "get_trading_pair_by_id",
59
+ "get_user_balance_by_asset",
60
+ "get_user_balances",
61
+ "get_user_movements",
62
+ "get_user_profile",
63
+ "get_user_trades",
64
+ "get_withdrawal",
65
+ "health_check",
66
+ "initiate_withdrawal",
67
+ "list_application_balances",
68
+ "list_application_movements",
69
+ "list_application_orders",
70
+ "list_application_users",
71
+ "list_conditional_orders",
72
+ "list_delegated_agent_owners",
73
+ "list_delegated_agents",
74
+ "list_funding_history",
75
+ "list_funding_payments",
76
+ "list_margin_accounts",
77
+ "list_pending_withdrawals",
78
+ "list_position_history",
79
+ "list_positions",
80
+ "list_sub_accounts_with_balances",
81
+ "list_trading_pairs",
82
+ "mint_tokens",
83
+ "reduce_position_margin",
84
+ "refresh_session",
85
+ "replace_order",
86
+ "revoke_delegated_agent",
87
+ "revoke_session",
88
+ "simulate_fees",
89
+ "simulate_order_risk",
90
+ "simulate_parent_margin_order_risk",
91
+ "simulate_risk_bucket_order_risk",
92
+ "submit_whitelist",
93
+ "transfer_collateral_from_margin_account",
94
+ "transfer_collateral_from_parent_margin_account",
95
+ "transfer_collateral_to_margin_account",
96
+ "transfer_collateral_to_parent_margin_account",
97
+ "transfer_collateral_to_risk_bucket",
98
+ "update_sub_account_limit",
99
+ "upsert_delegated_agent",
100
+ "verify_signature",
101
+ ];