@0xmonaco/types 0.7.7 → 0.7.8

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 (81) hide show
  1. package/dist/api/index.d.ts +18 -0
  2. package/dist/api/index.js +6 -0
  3. package/dist/applications/index.d.ts +23 -0
  4. package/dist/applications/index.js +5 -0
  5. package/dist/applications/responses.d.ts +22 -0
  6. package/dist/applications/responses.js +5 -0
  7. package/dist/auth/index.d.ts +81 -0
  8. package/dist/auth/index.js +6 -0
  9. package/dist/auth/responses.d.ts +67 -0
  10. package/dist/auth/responses.js +5 -0
  11. package/dist/contracts/balances.d.ts +43 -0
  12. package/dist/contracts/balances.js +5 -0
  13. package/dist/contracts/index.d.ts +27 -0
  14. package/dist/contracts/index.js +5 -0
  15. package/dist/fees/index.d.ts +39 -0
  16. package/dist/fees/index.js +6 -0
  17. package/dist/fees/responses.d.ts +54 -0
  18. package/dist/fees/responses.js +86 -0
  19. package/dist/index.d.ts +20 -0
  20. package/dist/index.js +21 -0
  21. package/dist/margin-accounts/index.d.ts +110 -0
  22. package/dist/margin-accounts/index.js +0 -0
  23. package/dist/market/index.d.ts +312 -0
  24. package/dist/market/index.js +5 -0
  25. package/dist/positions/index.d.ts +128 -0
  26. package/dist/positions/index.js +0 -0
  27. package/dist/profile/index.d.ts +405 -0
  28. package/dist/profile/index.js +5 -0
  29. package/dist/sdk/index.d.ts +131 -0
  30. package/dist/sdk/index.js +0 -0
  31. package/dist/sdk/network.d.ts +25 -0
  32. package/dist/sdk/network.js +5 -0
  33. package/dist/trading/index.d.ts +132 -0
  34. package/dist/trading/index.js +6 -0
  35. package/dist/trading/orders.d.ts +137 -0
  36. package/dist/trading/orders.js +9 -0
  37. package/dist/trading/responses.d.ts +347 -0
  38. package/dist/trading/responses.js +5 -0
  39. package/dist/validation/common.d.ts +179 -0
  40. package/dist/validation/common.js +199 -0
  41. package/dist/validation/index.d.ts +22 -0
  42. package/dist/validation/index.js +24 -0
  43. package/dist/validation/margin-accounts.d.ts +55 -0
  44. package/dist/validation/margin-accounts.js +59 -0
  45. package/dist/validation/market.d.ts +214 -0
  46. package/dist/validation/market.js +225 -0
  47. package/dist/validation/positions.d.ts +89 -0
  48. package/dist/validation/positions.js +93 -0
  49. package/dist/validation/profile.d.ts +69 -0
  50. package/dist/validation/profile.js +44 -0
  51. package/dist/validation/trading.d.ts +350 -0
  52. package/dist/validation/trading.js +313 -0
  53. package/dist/validation/vault.d.ts +66 -0
  54. package/dist/validation/vault.js +79 -0
  55. package/dist/vault/index.d.ts +84 -0
  56. package/dist/vault/index.js +5 -0
  57. package/dist/vault/responses.d.ts +51 -0
  58. package/dist/vault/responses.js +5 -0
  59. package/dist/websocket/base.d.ts +31 -0
  60. package/dist/websocket/base.js +5 -0
  61. package/dist/websocket/clients/orderbook-client.d.ts +14 -0
  62. package/dist/websocket/clients/orderbook-client.js +3 -0
  63. package/dist/websocket/events/balance-events.d.ts +48 -0
  64. package/dist/websocket/events/balance-events.js +6 -0
  65. package/dist/websocket/events/conditional-order-events.d.ts +33 -0
  66. package/dist/websocket/events/conditional-order-events.js +0 -0
  67. package/dist/websocket/events/index.d.ts +7 -0
  68. package/dist/websocket/events/index.js +7 -0
  69. package/dist/websocket/events/movement-events.d.ts +64 -0
  70. package/dist/websocket/events/movement-events.js +6 -0
  71. package/dist/websocket/events/ohlcv-events.d.ts +31 -0
  72. package/dist/websocket/events/ohlcv-events.js +5 -0
  73. package/dist/websocket/events/orderbook-events.d.ts +72 -0
  74. package/dist/websocket/events/orderbook-events.js +5 -0
  75. package/dist/websocket/events/orders-events.d.ts +284 -0
  76. package/dist/websocket/events/orders-events.js +0 -0
  77. package/dist/websocket/events/trade-events.d.ts +34 -0
  78. package/dist/websocket/events/trade-events.js +5 -0
  79. package/dist/websocket/index.d.ts +8 -0
  80. package/dist/websocket/index.js +8 -0
  81. package/package.json +2 -2
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Base API Types
3
+ *
4
+ * Common interface that all API implementations should inherit from.
5
+ * Provides standardized methods for token management and common functionality.
6
+ */
7
+ /**
8
+ * Base API interface that all API implementations should inherit from.
9
+ * Provides common functionality for access token management.
10
+ */
11
+ export interface BaseAPI {
12
+ /**
13
+ * Set the access token for authenticated requests.
14
+ *
15
+ * @param token - JWT access token
16
+ */
17
+ setAccessToken(token: string): void;
18
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Base API Types
3
+ *
4
+ * Common interface that all API implementations should inherit from.
5
+ * Provides standardized methods for token management and common functionality.
6
+ */
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Applications Types
3
+ *
4
+ * Types for application configuration operations.
5
+ */
6
+ import type { BaseAPI } from "../api";
7
+ import type { ApplicationConfigResponse } from "./responses";
8
+ /**
9
+ * Applications API interface.
10
+ * Provides methods for retrieving application configuration.
11
+ */
12
+ export interface ApplicationsAPI extends BaseAPI {
13
+ /**
14
+ * Gets the configuration for the authenticated application.
15
+ *
16
+ * Returns the application's configuration including allowed origins,
17
+ * webhook URL, and other settings. Requires valid authentication.
18
+ *
19
+ * @returns Promise resolving to the application configuration
20
+ */
21
+ getApplicationConfig(): Promise<ApplicationConfigResponse>;
22
+ }
23
+ export type { ApplicationConfigResponse } from "./responses";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Applications Types
3
+ *
4
+ * Types for application configuration operations.
5
+ */
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Applications Response Types
3
+ *
4
+ * Response types for application configuration operations.
5
+ */
6
+ /**
7
+ * Response to an application configuration request.
8
+ */
9
+ export interface ApplicationConfigResponse {
10
+ /** Unique identifier for the application */
11
+ id: string;
12
+ /** Human-readable name of the application */
13
+ name: string;
14
+ /** List of allowed origins for CORS */
15
+ allowedOrigins: string[];
16
+ /** Webhook URL for receiving events (optional) */
17
+ webhookUrl?: string;
18
+ /** Vault contract address */
19
+ vaultContractAddress: string;
20
+ /** Application client ID, embedded in on-chain deposit calls */
21
+ clientId: string;
22
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Applications Response Types
3
+ *
4
+ * Response types for application configuration operations.
5
+ */
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Auth Types
3
+ *
4
+ * Types for authentication operations including challenge creation,
5
+ * signature verification, and backend authentication.
6
+ */
7
+ import type { BaseAPI } from "../api";
8
+ import type { AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse } from "./responses";
9
+ /**
10
+ * Auth API interface.
11
+ * Provides methods for frontend and backend authentication.
12
+ * Handles challenge creation, signature verification, and backend auth.
13
+ */
14
+ export interface AuthAPI extends BaseAPI {
15
+ /**
16
+ * Complete authentication flow for frontend applications.
17
+ *
18
+ * This method handles the entire authentication process:
19
+ * 1. Creates a challenge
20
+ * 2. Signs the challenge message
21
+ * 3. Verifies the signature and returns JWT tokens
22
+ *
23
+ * @param clientId - Client ID of the application
24
+ * @returns Promise resolving to the authentication state with JWT tokens
25
+ */
26
+ authenticate(clientId: string): Promise<AuthState>;
27
+ /**
28
+ * Signs a challenge message using the wallet client.
29
+ *
30
+ * Signs the provided message using the wallet's private key.
31
+ * This is used in the authentication flow to prove ownership of the wallet.
32
+ *
33
+ * @param message - The message to sign
34
+ * @returns Promise resolving to the signature
35
+ */
36
+ signChallenge(message: string): Promise<string>;
37
+ /**
38
+ * Creates a challenge for frontend authentication.
39
+ * Generates a unique nonce and message that the user must sign with their wallet.
40
+ * @param address - Wallet address of the user
41
+ * @param clientId - Client ID of the application
42
+ * @returns Promise resolving to the challenge response
43
+ */
44
+ createChallenge(address: string, clientId: string): Promise<ChallengeResponse>;
45
+ /**
46
+ * Verifies a signature for frontend authentication.
47
+ * Validates the signature against the challenge and returns JWT tokens.
48
+ * @param address - Wallet address of the user
49
+ * @param signature - Signature of the challenge message
50
+ * @param nonce - Nonce from the challenge response
51
+ * @param clientId - Client ID of the application
52
+ * @returns Promise resolving to the authentication state with JWT tokens
53
+ */
54
+ verifySignature(address: string, signature: string, nonce: string, clientId: string): Promise<AuthState>;
55
+ /**
56
+ * Authenticates a backend service using a secret key.
57
+ * Returns JWT tokens for API access.
58
+ * @param secretKey - Secret key of the application
59
+ * @returns Promise resolving to the backend auth response with JWT tokens
60
+ */
61
+ authenticateBackend(secretKey: string): Promise<BackendAuthResponse>;
62
+ /**
63
+ * Refreshes an access token using a refresh token.
64
+ * @param refreshToken - The refresh token to use
65
+ * @returns Promise resolving to new access and refresh tokens
66
+ */
67
+ refreshToken(refreshToken: string): Promise<TokenRefreshResponse>;
68
+ /**
69
+ * Revokes the current session's refresh token.
70
+ * The server identifies the token to revoke from the access token in the Authorization header.
71
+ * @returns Promise resolving when the token is revoked
72
+ */
73
+ revokeToken(): Promise<void>;
74
+ /**
75
+ * Sets the wallet client for signing operations.
76
+ * Used when the wallet becomes available after SDK initialization.
77
+ * @param walletClient - The wallet client to set
78
+ */
79
+ setWalletClient(walletClient: unknown): void;
80
+ }
81
+ export type { ApplicationInfo, AuthState, BackendAuthResponse, ChallengeResponse, TokenRefreshResponse, User, } from "./responses";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Auth Types
3
+ *
4
+ * Types for authentication operations including challenge creation,
5
+ * signature verification, and backend authentication.
6
+ */
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Auth Response Types
3
+ *
4
+ * Response types for authentication operations.
5
+ */
6
+ /**
7
+ * Response to a challenge request.
8
+ */
9
+ export interface ChallengeResponse {
10
+ /** Unique nonce for this challenge */
11
+ nonce: string;
12
+ /** Message to be signed by the user's wallet */
13
+ message: string;
14
+ /** Unix timestamp when the challenge expires */
15
+ expiresAt: number;
16
+ }
17
+ export interface User {
18
+ /** Unique identifier for the user */
19
+ id: string;
20
+ /** Wallet address of the user */
21
+ address: string;
22
+ /** Username of the user */
23
+ username?: string;
24
+ }
25
+ /**
26
+ * Authentication state containing all tokens and metadata
27
+ *
28
+ * Returned by authentication methods and contains the tokens needed for API access.
29
+ */
30
+ export interface AuthState {
31
+ /** JWT access token for authenticated requests */
32
+ accessToken: string;
33
+ /** JWT refresh token for token renewal and revocation */
34
+ refreshToken: string;
35
+ /** Unix timestamp (in seconds) when the access token expires */
36
+ expiresAt: number;
37
+ /** Information about the authenticated user */
38
+ user: User;
39
+ }
40
+ export interface ApplicationInfo {
41
+ /** Unique identifier for the application */
42
+ id: string;
43
+ /** Human-readable name of the application */
44
+ name: string;
45
+ /** Client ID for frontend authentication */
46
+ clientId: string;
47
+ }
48
+ /**
49
+ * Response to a backend authentication request.
50
+ */
51
+ export interface BackendAuthResponse {
52
+ /** JWT access token for authenticated requests */
53
+ accessToken: string;
54
+ /** Unix timestamp when the access token expires */
55
+ expiresAt: number;
56
+ /** Information about the application */
57
+ application: ApplicationInfo;
58
+ }
59
+ /**
60
+ * Response to a token refresh request.
61
+ */
62
+ export interface TokenRefreshResponse {
63
+ /** New JWT access token */
64
+ accessToken: string;
65
+ /** Unix timestamp when the access token expires */
66
+ expiresAt: number;
67
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Auth Response Types
3
+ *
4
+ * Response types for authentication operations.
5
+ */
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Contract Balance Types
3
+ *
4
+ * Types for contract balance management and token information.
5
+ */
6
+ import type { Address } from "viem";
7
+ /**
8
+ * Type representing a token in the Monaco Markets protocol.
9
+ * Contains essential token metadata and contract information.
10
+ *
11
+ * @property address - Token contract address
12
+ * @property symbol - Token symbol (e.g. "ETH", "USDC")
13
+ * @property decimals - Number of decimal places for token amounts
14
+ * @property name - Full token name
15
+ */
16
+ export interface Token {
17
+ /** Token contract address */
18
+ address: Address;
19
+ /** Token symbol (e.g. "ETH", "USDC") */
20
+ symbol: string;
21
+ /** Number of decimal places for token amounts */
22
+ decimals: number;
23
+ /** Full token name */
24
+ name: string;
25
+ }
26
+ /**
27
+ * Type representing a user's balance for a specific token in contract storage.
28
+ *
29
+ * @property token - Token address
30
+ * @property available - Available balance for trading
31
+ * @property locked - Locked balance in open orders
32
+ * @property total - Total balance (available + locked)
33
+ */
34
+ export interface UserBalance {
35
+ /** Token address */
36
+ token: string;
37
+ /** Available balance for trading */
38
+ available: bigint;
39
+ /** Locked balance in open orders */
40
+ locked: bigint;
41
+ /** Total balance (available + locked) */
42
+ total: bigint;
43
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Contract Balance Types
3
+ *
4
+ * Types for contract balance management and token information.
5
+ */
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Contract Types
3
+ *
4
+ * Types for contract addresses, instances, and contract-related operations.
5
+ */
6
+ import type { CONTRACT_ABIS } from "@0xmonaco/contracts";
7
+ import type { GetContractReturnType } from "viem";
8
+ /**
9
+ * Interface for all contract addresses in the Monaco Markets protocol.
10
+ *
11
+ * @property VAULT - Vault contract address for managing user balances
12
+ */
13
+ export interface ContractAddresses {
14
+ /** Vault contract address for managing user balances */
15
+ VAULT: string;
16
+ }
17
+ /**
18
+ * Type representing all contract instances.
19
+ * Maps contract names to their typed instances with full ABI type safety.
20
+ *
21
+ * @property vault - Vault contract instance for managing user balances
22
+ */
23
+ export type ContractInstances = {
24
+ /** Vault contract instance for managing user balances */
25
+ vault: GetContractReturnType<typeof CONTRACT_ABIS.vault>;
26
+ };
27
+ export type { Token, UserBalance } from "./balances";
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Contract Types
3
+ *
4
+ * Types for contract addresses, instances, and contract-related operations.
5
+ */
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Fees Types
3
+ *
4
+ * Types for fees operations including fee simulation.
5
+ */
6
+ import type { BaseAPI } from "../api/index";
7
+ import type { SimulateFeeParams, SimulateFeeResponse } from "./responses";
8
+ /**
9
+ * Fees API interface.
10
+ * Provides methods for simulating and calculating trading fees.
11
+ */
12
+ export interface FeesAPI extends BaseAPI {
13
+ /**
14
+ * Simulate fees for an order before placing it.
15
+ * Returns exact fees for that specific order.
16
+ *
17
+ * @param params - Parameters for fee simulation
18
+ * @param params.trading_pair_id - Trading pair ID
19
+ * @param params.side - Order side ("BUY" or "SELL")
20
+ * @param params.price - Price per unit
21
+ * @param params.quantity - Quantity to trade
22
+ * @returns Promise resolving to fee simulation details
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * const feeDetails = await feesAPI.simulateFees({
27
+ * trading_pair_id: "123e4567-e89b-12d3-a456-426614174000",
28
+ * side: "BUY",
29
+ * price: "40000.00",
30
+ * quantity: "0.5"
31
+ * });
32
+ * console.log(`Total taker fees: ${feeDetails.total_taker_fees}`);
33
+ * console.log(`Taker must pay: ${feeDetails.taker_total_payment}`);
34
+ * ```
35
+ */
36
+ simulateFees(params: SimulateFeeParams): Promise<SimulateFeeResponse>;
37
+ }
38
+ export type { SimulateFeeParams, SimulateFeeResponse } from "./responses";
39
+ export { SimulateFeeParamsSchema, SimulateFeeResponseSchema } from "./responses";
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Fees Types
3
+ *
4
+ * Types for fees operations including fee simulation.
5
+ */
6
+ export { SimulateFeeParamsSchema, SimulateFeeResponseSchema } from "./responses";
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Fees Response Types
3
+ *
4
+ * Types for fees-related API responses.
5
+ * All types are derived from Zod schemas for runtime validation.
6
+ */
7
+ import { z } from "zod";
8
+ /**
9
+ * Zod schema for simulating order fees parameters
10
+ */
11
+ export declare const SimulateFeeParamsSchema: z.ZodObject<{
12
+ trading_pair_id: z.ZodString;
13
+ side: z.ZodEnum<{
14
+ BUY: "BUY";
15
+ SELL: "SELL";
16
+ }>;
17
+ price: z.ZodString;
18
+ quantity: z.ZodString;
19
+ order_type: z.ZodOptional<z.ZodEnum<{
20
+ LIMIT: "LIMIT";
21
+ MARKET: "MARKET";
22
+ }>>;
23
+ slippage_tolerance_bps: z.ZodOptional<z.ZodNumber>;
24
+ }, z.core.$strip>;
25
+ /**
26
+ * Zod schema for fee simulation response
27
+ */
28
+ export declare const SimulateFeeResponseSchema: z.ZodObject<{
29
+ application_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
30
+ application_taker_fee: z.ZodString;
31
+ application_taker_fee_bps: z.ZodNumber;
32
+ buy_order_lock_amount: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ maker_total_receipt: z.ZodString;
34
+ monaco_maker_rebate: z.ZodString;
35
+ monaco_maker_rebate_bps: z.ZodNumber;
36
+ monaco_taker_fee: z.ZodString;
37
+ monaco_taker_fee_bps: z.ZodNumber;
38
+ notional: z.ZodString;
39
+ taker_total_payment: z.ZodString;
40
+ total_taker_fees: z.ZodString;
41
+ max_quantity: z.ZodNullable<z.ZodString>;
42
+ max_quantity_raw: z.ZodNullable<z.ZodString>;
43
+ slippage_tolerance_bps: z.ZodNullable<z.ZodNumber>;
44
+ }, z.core.$strip>;
45
+ /**
46
+ * Parameters for simulating order fees
47
+ * @remarks Type is inferred from SimulateFeeParamsSchema
48
+ */
49
+ export type SimulateFeeParams = z.infer<typeof SimulateFeeParamsSchema>;
50
+ /**
51
+ * Response with detailed fee breakdown for simulating order fees
52
+ * @remarks Type is inferred from SimulateFeeResponseSchema
53
+ */
54
+ export type SimulateFeeResponse = z.infer<typeof SimulateFeeResponseSchema>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Fees Response Types
3
+ *
4
+ * Types for fees-related API responses.
5
+ * All types are derived from Zod schemas for runtime validation.
6
+ */
7
+ import { z } from "zod";
8
+ /**
9
+ * Zod schema for simulating order fees parameters
10
+ */
11
+ export const SimulateFeeParamsSchema = z
12
+ .object({
13
+ /** Trading pair ID */
14
+ trading_pair_id: z.string().trim().min(1, "Trading pair ID is required and cannot be empty"),
15
+ /** Order side: "BUY" or "SELL" */
16
+ side: z.enum(["BUY", "SELL"], {
17
+ message: "Order side is required and must be either 'BUY' or 'SELL'",
18
+ }),
19
+ /** Price per unit */
20
+ price: z
21
+ .string()
22
+ .trim()
23
+ .min(1, "Price is required and cannot be empty")
24
+ .refine((val) => !Number.isNaN(Number(val)), "Price must be a valid number")
25
+ .refine((val) => Number(val) > 0, "Price must be greater than 0"),
26
+ /** Quantity to trade */
27
+ quantity: z
28
+ .string()
29
+ .trim()
30
+ .min(1, "Quantity is required and cannot be empty")
31
+ .refine((val) => !Number.isNaN(Number(val)), "Quantity must be a valid number")
32
+ .refine((val) => Number(val) > 0, "Quantity must be greater than 0"),
33
+ /** Order type: "LIMIT" (default) or "MARKET". MARKET orders include a slippage buffer in the lock amount. */
34
+ order_type: z.enum(["LIMIT", "MARKET"]).optional(),
35
+ /** Slippage tolerance in basis points (0–1000). Only valid for MARKET orders. Default: 500 (5%). */
36
+ slippage_tolerance_bps: z
37
+ .number()
38
+ .int()
39
+ .min(0, "Slippage tolerance must be between 0 and 1000 bps")
40
+ .max(1000, "Slippage tolerance must be between 0 and 1000 bps")
41
+ .optional(),
42
+ })
43
+ .superRefine((data, ctx) => {
44
+ if (data.slippage_tolerance_bps !== undefined && data.order_type !== "MARKET") {
45
+ ctx.addIssue({
46
+ code: z.ZodIssueCode.custom,
47
+ message: "slippage_tolerance_bps is only valid when order_type is MARKET",
48
+ path: ["slippage_tolerance_bps"],
49
+ });
50
+ }
51
+ });
52
+ /**
53
+ * Zod schema for fee simulation response
54
+ */
55
+ export const SimulateFeeResponseSchema = z.object({
56
+ /** Application name (if applicable) */
57
+ application_name: z.string().nullable().optional(),
58
+ /** Frontend application taker fee */
59
+ application_taker_fee: z.string(),
60
+ /** Application fee in basis points */
61
+ application_taker_fee_bps: z.number(),
62
+ /** Amount to lock for BUY orders (null for `SELL`) */
63
+ buy_order_lock_amount: z.string().nullable().optional(),
64
+ /** Total amount maker receives */
65
+ maker_total_receipt: z.string(),
66
+ /** Monaco protocol maker rebate (negative = rebate) */
67
+ monaco_maker_rebate: z.string(),
68
+ /** Monaco maker rebate in basis points */
69
+ monaco_maker_rebate_bps: z.number(),
70
+ /** Monaco protocol taker fee */
71
+ monaco_taker_fee: z.string(),
72
+ /** Monaco taker fee in basis points */
73
+ monaco_taker_fee_bps: z.number(),
74
+ /** Notional value (price * quantity) */
75
+ notional: z.string(),
76
+ /** Total amount taker must pay */
77
+ taker_total_payment: z.string(),
78
+ /** Total taker fees (monaco + application) */
79
+ total_taker_fees: z.string(),
80
+ /** Maximum quantity affordable at the given price, accounting for fees (null if not authenticated or balance unavailable) */
81
+ max_quantity: z.string().nullable(),
82
+ /** Maximum quantity in RAW (smallest unit) format */
83
+ max_quantity_raw: z.string().nullable(),
84
+ /** Slippage tolerance used in the calculation, echoed back for MARKET orders (null for LIMIT orders) */
85
+ slippage_tolerance_bps: z.number().nullable(),
86
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Monaco Types Package
3
+ *
4
+ * This package provides TypeScript types for the Monaco protocol.
5
+ * It includes SDK types, vault types, trading types, contract types, and common types.
6
+ */
7
+ export * from "./api";
8
+ export * from "./applications";
9
+ export * from "./auth";
10
+ export * from "./contracts";
11
+ export * from "./fees";
12
+ export * from "./margin-accounts";
13
+ export * from "./market";
14
+ export * from "./positions";
15
+ export * from "./profile";
16
+ export * from "./sdk";
17
+ export * from "./trading";
18
+ export * from "./validation";
19
+ export * from "./vault";
20
+ export * from "./websocket";
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Monaco Types Package
3
+ *
4
+ * This package provides TypeScript types for the Monaco protocol.
5
+ * It includes SDK types, vault types, trading types, contract types, and common types.
6
+ */
7
+ // Export everything from all modules
8
+ export * from "./api";
9
+ export * from "./applications";
10
+ export * from "./auth";
11
+ export * from "./contracts";
12
+ export * from "./fees";
13
+ export * from "./margin-accounts";
14
+ export * from "./market";
15
+ export * from "./positions";
16
+ export * from "./profile";
17
+ export * from "./sdk";
18
+ export * from "./trading";
19
+ export * from "./validation";
20
+ export * from "./vault";
21
+ export * from "./websocket";
@@ -0,0 +1,110 @@
1
+ import type { BaseAPI } from "../api";
2
+ import type { OrderSide, OrderType, PositionSide } from "../trading";
3
+ export interface MarginAccountSummary {
4
+ margin_account_id: string;
5
+ label?: string;
6
+ account_state: string;
7
+ equity: string;
8
+ initial_margin_required: string;
9
+ maintenance_margin_required: string;
10
+ free_collateral: string;
11
+ withdrawable_collateral: string;
12
+ total_position_notional: string;
13
+ unrealized_pnl: string;
14
+ realized_pnl: string;
15
+ updated_at: string;
16
+ }
17
+ export interface ListMarginAccountsParams {
18
+ page?: number;
19
+ page_size?: number;
20
+ state?: string;
21
+ }
22
+ export interface ListMarginAccountsResponse {
23
+ accounts: MarginAccountSummary[];
24
+ total: number;
25
+ page: number;
26
+ page_size: number;
27
+ }
28
+ export interface CreateMarginAccountRequest {
29
+ label?: string;
30
+ collateralAsset?: string;
31
+ }
32
+ export interface CreateMarginAccountResponse {
33
+ margin_account_id: string;
34
+ label?: string;
35
+ account_state: string;
36
+ collateral_asset: string;
37
+ created_at: string;
38
+ }
39
+ export interface GetAvailableCollateralParams {
40
+ asset?: string;
41
+ }
42
+ export interface GetAvailableCollateralResponse {
43
+ asset: string;
44
+ wallet_available: string;
45
+ wallet_locked: string;
46
+ margin_transferable?: string;
47
+ }
48
+ export interface TransferCollateralRequest {
49
+ asset: string;
50
+ amount: string;
51
+ }
52
+ export interface TransferCollateralResponse {
53
+ movement_id: string;
54
+ margin_account_id: string;
55
+ asset: string;
56
+ amount: string;
57
+ status: string;
58
+ new_equity: string;
59
+ new_total_collateral_value: string;
60
+ new_withdrawable_collateral: string;
61
+ }
62
+ export interface GetMarginAccountMovementsParams {
63
+ movement_type?: string;
64
+ page?: number;
65
+ page_size?: number;
66
+ }
67
+ export interface MarginAccountMovement {
68
+ movement_id: string;
69
+ margin_account_id: string;
70
+ movement_type: string;
71
+ asset: string;
72
+ amount: string;
73
+ created_at: string;
74
+ }
75
+ export interface GetMarginAccountMovementsResponse {
76
+ movements: MarginAccountMovement[];
77
+ total: number;
78
+ page: number;
79
+ page_size: number;
80
+ }
81
+ export interface SimulateOrderRiskRequest {
82
+ tradingPairId: string;
83
+ side: OrderSide;
84
+ positionSide: PositionSide;
85
+ orderType: OrderType;
86
+ price?: string;
87
+ quantity: string;
88
+ leverage: string;
89
+ reduceOnly?: boolean;
90
+ }
91
+ export interface SimulateOrderRiskResponse {
92
+ accepted: boolean;
93
+ reject_reason?: string;
94
+ equity_after: string;
95
+ initial_margin_required_after: string;
96
+ maintenance_margin_required_after: string;
97
+ free_collateral_after: string;
98
+ estimated_fee?: string;
99
+ estimated_liquidation_price?: string;
100
+ }
101
+ export interface MarginAccountsAPI extends BaseAPI {
102
+ listMarginAccounts(params?: ListMarginAccountsParams): Promise<ListMarginAccountsResponse>;
103
+ createMarginAccount(request?: CreateMarginAccountRequest): Promise<CreateMarginAccountResponse>;
104
+ getMarginAccountSummary(marginAccountId: string): Promise<MarginAccountSummary>;
105
+ getAvailableCollateral(params?: GetAvailableCollateralParams): Promise<GetAvailableCollateralResponse>;
106
+ transferCollateralToMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
107
+ transferCollateralFromMarginAccount(marginAccountId: string, request: TransferCollateralRequest): Promise<TransferCollateralResponse>;
108
+ getMarginAccountMovements(marginAccountId: string, params?: GetMarginAccountMovementsParams): Promise<GetMarginAccountMovementsResponse>;
109
+ simulateOrderRisk(marginAccountId: string, request: SimulateOrderRiskRequest): Promise<SimulateOrderRiskResponse>;
110
+ }