@0xmonaco/types 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +190 -73
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/market/index.d.ts +79 -0
- package/dist/market/index.d.ts.map +1 -0
- package/dist/market/index.js +7 -0
- package/dist/market/index.js.map +1 -0
- package/dist/sdk/index.d.ts +6 -3
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/trading/index.d.ts +2 -14
- package/dist/trading/index.d.ts.map +1 -1
- package/dist/trading/responses.d.ts +0 -42
- package/dist/trading/responses.d.ts.map +1 -1
- package/dist/vault/index.d.ts +11 -9
- package/dist/vault/index.d.ts.map +1 -1
- package/dist/vault/responses.d.ts +2 -0
- package/dist/vault/responses.d.ts.map +1 -1
- package/dist/websocket/events.d.ts +51 -0
- package/dist/websocket/events.d.ts.map +1 -0
- package/dist/websocket/events.js +7 -0
- package/dist/websocket/events.js.map +1 -0
- package/dist/websocket/index.d.ts +26 -19
- package/dist/websocket/index.d.ts.map +1 -1
- package/dist/websocket/index.js +3 -3
- package/dist/websocket/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @0xmonaco/types
|
|
2
2
|
|
|
3
|
-
Core type definitions for the Monaco protocol. This package provides TypeScript types and interfaces used throughout the Monaco ecosystem, focusing on SDK configuration, vault operations, trading operations, and contract management.
|
|
3
|
+
Core type definitions for the Monaco protocol. This package provides TypeScript types and interfaces used throughout the Monaco ecosystem, focusing on SDK configuration, vault operations, trading operations, market data, and contract management.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -19,28 +19,40 @@ import { MonacoSDK, SDKConfig } from "@0xmonaco/types";
|
|
|
19
19
|
|
|
20
20
|
// SDK configuration
|
|
21
21
|
interface SDKConfig {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
network?: Network; // Network override (defaults to 'mainnet')
|
|
22
|
+
walletClient: WalletClient; // Wallet client for signing operations
|
|
23
|
+
network?: Network; // Network override (defaults to 'mainnet')
|
|
24
|
+
transport?: Transport; // Optional transport for the public client
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
// Main SDK interface
|
|
29
28
|
interface MonacoSDK {
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
applications: ApplicationsAPI; // Applications operations API
|
|
30
|
+
auth: AuthAPI; // Auth operations API
|
|
31
|
+
vault: VaultAPI; // Vault operations API
|
|
32
|
+
trading: TradingAPI; // Trading operations API
|
|
33
|
+
market: MarketAPI; // Market metadata API
|
|
34
|
+
profile: ProfileAPI; // Profile operations API
|
|
35
|
+
websocket: OrderWebSocketClient; // WebSocket client for real-time order events
|
|
32
36
|
walletClient: WalletClient; // Wallet client for blockchain operations
|
|
33
37
|
publicClient: PublicClient; // Public client for read-only operations
|
|
34
|
-
|
|
38
|
+
|
|
39
|
+
// Authentication
|
|
40
|
+
login(clientId: string): Promise<AuthState>;
|
|
41
|
+
logout(): Promise<void>;
|
|
42
|
+
refreshAuth(): Promise<AuthState>;
|
|
43
|
+
getAuthState(): AuthState | undefined;
|
|
44
|
+
|
|
35
45
|
// Account management
|
|
46
|
+
isAuthenticated(): boolean;
|
|
36
47
|
isConnected(): boolean;
|
|
37
48
|
getAccountAddress(): string;
|
|
38
49
|
getNetwork(): Network;
|
|
39
50
|
getChainId(): number;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
waitForTransaction(
|
|
52
|
+
hash: string,
|
|
53
|
+
confirmations?: number,
|
|
54
|
+
timeout?: number
|
|
55
|
+
): Promise<TransactionReceipt>;
|
|
44
56
|
}
|
|
45
57
|
```
|
|
46
58
|
|
|
@@ -52,13 +64,25 @@ Types for vault operations including deposits, withdrawals, and balance manageme
|
|
|
52
64
|
import { VaultAPI, Balance, TransactionResult } from "@0xmonaco/types";
|
|
53
65
|
|
|
54
66
|
// Vault operations
|
|
55
|
-
interface VaultAPI {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
67
|
+
interface VaultAPI extends BaseAPI {
|
|
68
|
+
setVaultAddress(vaultAddress: Address): void;
|
|
69
|
+
getVaultAddress(): Address | undefined;
|
|
70
|
+
approve(
|
|
71
|
+
token: string,
|
|
72
|
+
amount: bigint,
|
|
73
|
+
autoWait?: boolean
|
|
74
|
+
): Promise<TransactionResult>;
|
|
75
|
+
deposit(
|
|
76
|
+
token: string,
|
|
77
|
+
amount: bigint,
|
|
78
|
+
autoWait?: boolean
|
|
79
|
+
): Promise<TransactionResult>;
|
|
80
|
+
withdraw(
|
|
81
|
+
token: string,
|
|
82
|
+
amount: bigint,
|
|
83
|
+
autoWait?: boolean
|
|
84
|
+
): Promise<TransactionResult>;
|
|
59
85
|
getBalance(token: string): Promise<Balance>;
|
|
60
|
-
getAllowance(token: string): Promise<bigint>;
|
|
61
|
-
needsApproval(token: string, amount: bigint): Promise<boolean>;
|
|
62
86
|
}
|
|
63
87
|
|
|
64
88
|
// Vault response types
|
|
@@ -74,6 +98,7 @@ interface TransactionResult {
|
|
|
74
98
|
hash: string;
|
|
75
99
|
status: "pending" | "confirmed" | "failed";
|
|
76
100
|
nonce: bigint;
|
|
101
|
+
receipt?: TransactionReceipt;
|
|
77
102
|
}
|
|
78
103
|
```
|
|
79
104
|
|
|
@@ -82,62 +107,134 @@ interface TransactionResult {
|
|
|
82
107
|
Types for trading operations including order placement and management:
|
|
83
108
|
|
|
84
109
|
```typescript
|
|
85
|
-
import {
|
|
86
|
-
TradingAPI,
|
|
87
|
-
OrderSide,
|
|
88
|
-
OrderType,
|
|
89
|
-
|
|
90
|
-
|
|
110
|
+
import {
|
|
111
|
+
TradingAPI,
|
|
112
|
+
OrderSide,
|
|
113
|
+
OrderType,
|
|
114
|
+
CreateOrderResponse,
|
|
115
|
+
CancelOrderResponse,
|
|
116
|
+
ReplaceOrderResponse,
|
|
117
|
+
GetPaginatedOrdersResponse,
|
|
118
|
+
GetOrderResponse,
|
|
91
119
|
} from "@0xmonaco/types";
|
|
92
120
|
|
|
93
121
|
// Trading operations
|
|
94
|
-
interface TradingAPI {
|
|
95
|
-
placeLimitOrder(
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
122
|
+
interface TradingAPI extends BaseAPI {
|
|
123
|
+
placeLimitOrder(
|
|
124
|
+
market: string,
|
|
125
|
+
side: OrderSide,
|
|
126
|
+
quantity: string,
|
|
127
|
+
price: string,
|
|
128
|
+
options?: {
|
|
129
|
+
tradingMode?: string;
|
|
130
|
+
useMasterBalance?: boolean;
|
|
131
|
+
expirationDate?: string;
|
|
132
|
+
}
|
|
133
|
+
): Promise<CreateOrderResponse>;
|
|
134
|
+
|
|
135
|
+
placeMarketOrder(
|
|
136
|
+
market: string,
|
|
137
|
+
side: OrderSide,
|
|
138
|
+
quantity: string,
|
|
139
|
+
options?: { tradingMode?: string }
|
|
140
|
+
): Promise<CreateOrderResponse>;
|
|
141
|
+
|
|
99
142
|
cancelOrder(orderId: string): Promise<CancelOrderResponse>;
|
|
100
|
-
|
|
143
|
+
|
|
144
|
+
replaceOrder(
|
|
145
|
+
orderId: string,
|
|
146
|
+
newOrder: {
|
|
147
|
+
price?: string;
|
|
148
|
+
quantity: string;
|
|
149
|
+
useMasterBalance?: boolean;
|
|
150
|
+
}
|
|
151
|
+
): Promise<ReplaceOrderResponse>;
|
|
152
|
+
|
|
153
|
+
getPaginatedOrders(
|
|
154
|
+
params?: GetPaginatedOrdersParams
|
|
155
|
+
): Promise<GetPaginatedOrdersResponse>;
|
|
156
|
+
getOrder(orderId: string): Promise<GetOrderResponse>;
|
|
101
157
|
}
|
|
102
158
|
|
|
103
159
|
// Trading types
|
|
104
|
-
type OrderSide = "
|
|
105
|
-
|
|
106
|
-
type
|
|
107
|
-
type
|
|
108
|
-
|
|
109
|
-
interface OrderIntent {
|
|
110
|
-
market: string;
|
|
111
|
-
side: OrderSide;
|
|
112
|
-
size: string;
|
|
113
|
-
orderType: OrderType;
|
|
114
|
-
userAddress: string;
|
|
115
|
-
timestamp: bigint;
|
|
116
|
-
nonce: bigint;
|
|
117
|
-
price?: string;
|
|
118
|
-
timeInForce?: TimeInForce;
|
|
119
|
-
slippageTolerance?: string;
|
|
120
|
-
}
|
|
160
|
+
type OrderSide = "BUY" | "SELL";
|
|
161
|
+
type OrderType = "LIMIT" | "MARKET";
|
|
162
|
+
type OrderStatus = "PENDING" | "FILLED" | "CANCELLED" | "REJECTED";
|
|
163
|
+
type TradingMode = "SPOT";
|
|
121
164
|
|
|
122
165
|
// Trading response types
|
|
123
|
-
interface
|
|
124
|
-
|
|
125
|
-
status: "
|
|
126
|
-
|
|
166
|
+
interface CreateOrderResponse {
|
|
167
|
+
order_id: string;
|
|
168
|
+
status: "SUCCESS" | "FAILED";
|
|
169
|
+
match_result?: {
|
|
170
|
+
remaining_quantity: string;
|
|
171
|
+
status: string;
|
|
172
|
+
};
|
|
127
173
|
}
|
|
128
174
|
|
|
129
175
|
interface CancelOrderResponse {
|
|
130
|
-
|
|
131
|
-
status: "
|
|
132
|
-
|
|
176
|
+
order_id: string;
|
|
177
|
+
status: "SUCCESS" | "FAILED";
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
interface ReplaceOrderResponse {
|
|
181
|
+
order_id: string;
|
|
182
|
+
status: "SUCCESS" | "FAILED";
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Market Types
|
|
187
|
+
|
|
188
|
+
Types for market data operations including trading pair metadata:
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
import {
|
|
192
|
+
MarketAPI,
|
|
193
|
+
TradingPair,
|
|
194
|
+
GetTradingPairsResponse,
|
|
195
|
+
GetTradingPairResponse,
|
|
196
|
+
} from "@0xmonaco/types";
|
|
197
|
+
|
|
198
|
+
// Market operations
|
|
199
|
+
interface MarketAPI extends BaseAPI {
|
|
200
|
+
getTradingPairs(): Promise<TradingPair[]>;
|
|
201
|
+
getTradingPairBySymbol(symbol: string): Promise<TradingPair | undefined>;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Market data types
|
|
205
|
+
interface TradingPair {
|
|
206
|
+
id: string;
|
|
207
|
+
symbol: string;
|
|
208
|
+
base_token: string;
|
|
209
|
+
quote_token: string;
|
|
210
|
+
base_token_contract: string;
|
|
211
|
+
quote_token_contract: string;
|
|
212
|
+
base_decimals: number;
|
|
213
|
+
quote_decimals: number;
|
|
214
|
+
market_type: string;
|
|
215
|
+
is_active: boolean;
|
|
216
|
+
maker_fee_bps: number;
|
|
217
|
+
taker_fee_bps: number;
|
|
218
|
+
min_order_size: string;
|
|
219
|
+
max_order_size: string;
|
|
220
|
+
tick_size: string;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Market response types
|
|
224
|
+
interface GetTradingPairsResponse {
|
|
225
|
+
data: {
|
|
226
|
+
data: TradingPair[];
|
|
227
|
+
limit: number;
|
|
228
|
+
page: number;
|
|
229
|
+
total: number;
|
|
230
|
+
total_pages: number;
|
|
231
|
+
};
|
|
232
|
+
success: boolean;
|
|
133
233
|
}
|
|
134
234
|
|
|
135
|
-
interface
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
closedSize?: bigint;
|
|
139
|
-
remainingSize?: bigint;
|
|
140
|
-
timestamp: number;
|
|
235
|
+
interface GetTradingPairResponse {
|
|
236
|
+
data: TradingPair;
|
|
237
|
+
success: boolean;
|
|
141
238
|
}
|
|
142
239
|
```
|
|
143
240
|
|
|
@@ -146,7 +243,12 @@ interface ClosePositionResponse {
|
|
|
146
243
|
Types for contract addresses, instances, and contract-related operations:
|
|
147
244
|
|
|
148
245
|
```typescript
|
|
149
|
-
import {
|
|
246
|
+
import {
|
|
247
|
+
ContractAddresses,
|
|
248
|
+
ContractInstances,
|
|
249
|
+
Token,
|
|
250
|
+
UserBalance,
|
|
251
|
+
} from "@0xmonaco/types";
|
|
150
252
|
|
|
151
253
|
// Contract addresses
|
|
152
254
|
interface ContractAddresses {
|
|
@@ -192,9 +294,10 @@ interface NetworkEndpoints {
|
|
|
192
294
|
|
|
193
295
|
### SDK Types
|
|
194
296
|
|
|
195
|
-
- `MonacoSDK`: Main SDK interface with
|
|
297
|
+
- `MonacoSDK`: Main SDK interface with all API modules
|
|
196
298
|
- `SDKConfig`: Configuration options for the Monaco SDK
|
|
197
299
|
- `Network`: Network type ("mainnet" | "testnet")
|
|
300
|
+
- `AuthState`: Authentication state information
|
|
198
301
|
|
|
199
302
|
### Vault Types
|
|
200
303
|
|
|
@@ -205,12 +308,18 @@ interface NetworkEndpoints {
|
|
|
205
308
|
### Trading Types
|
|
206
309
|
|
|
207
310
|
- `TradingAPI`: Interface for trading operations (orders, positions)
|
|
208
|
-
- `OrderSide`: Order side type ("
|
|
209
|
-
- `OrderType`: Order type
|
|
210
|
-
- `
|
|
211
|
-
- `OrderResponse`: Response from order operations
|
|
311
|
+
- `OrderSide`: Order side type ("BUY" | "SELL")
|
|
312
|
+
- `OrderType`: Order type ("LIMIT" | "MARKET")
|
|
313
|
+
- `CreateOrderResponse`: Response from order placement
|
|
212
314
|
- `CancelOrderResponse`: Response from order cancellation
|
|
213
|
-
- `
|
|
315
|
+
- `ReplaceOrderResponse`: Response from order replacement
|
|
316
|
+
|
|
317
|
+
### Market Types
|
|
318
|
+
|
|
319
|
+
- `MarketAPI`: Interface for market data operations
|
|
320
|
+
- `TradingPair`: Trading pair metadata with all market information
|
|
321
|
+
- `GetTradingPairsResponse`: Response wrapper for trading pairs list
|
|
322
|
+
- `GetTradingPairResponse`: Response wrapper for single trading pair
|
|
214
323
|
|
|
215
324
|
### Contract Types
|
|
216
325
|
|
|
@@ -225,19 +334,27 @@ The types package is organized into domain-specific modules:
|
|
|
225
334
|
|
|
226
335
|
```
|
|
227
336
|
src/
|
|
337
|
+
├── api/ # Base API types
|
|
338
|
+
│ └── index.ts # Common API interfaces
|
|
339
|
+
├── applications/ # Applications types
|
|
340
|
+
├── auth/ # Authentication types
|
|
341
|
+
├── contracts/ # Contract types
|
|
342
|
+
│ ├── index.ts # Contract interfaces
|
|
343
|
+
│ └── balances.ts # Balance-related types
|
|
344
|
+
├── market/ # Market data types
|
|
345
|
+
│ └── index.ts # Market API interface and types
|
|
346
|
+
├── profile/ # Profile types
|
|
228
347
|
├── sdk/ # SDK types
|
|
229
348
|
│ ├── index.ts # Main SDK interfaces and configuration
|
|
230
349
|
│ └── network.ts # Network-related types
|
|
231
|
-
├── vault/ # Vault types
|
|
232
|
-
│ ├── index.ts # Vault API interface
|
|
233
|
-
│ └── responses.ts # Vault response types
|
|
234
350
|
├── trading/ # Trading types
|
|
235
351
|
│ ├── index.ts # Trading API interface
|
|
236
352
|
│ ├── orders.ts # Order-related types
|
|
237
353
|
│ └── responses.ts # Trading response types
|
|
238
|
-
├──
|
|
239
|
-
│ ├── index.ts #
|
|
240
|
-
│ └──
|
|
354
|
+
├── vault/ # Vault types
|
|
355
|
+
│ ├── index.ts # Vault API interface
|
|
356
|
+
│ └── responses.ts # Vault response types
|
|
357
|
+
├── websocket/ # WebSocket types
|
|
241
358
|
└── index.ts # Package exports
|
|
242
359
|
```
|
|
243
360
|
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,qCAAqC;AACrC,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Market Types
|
|
3
|
+
*
|
|
4
|
+
* Types for market data operations including trading pair metadata.
|
|
5
|
+
*/
|
|
6
|
+
import { type BaseAPI } from "../api";
|
|
7
|
+
/**
|
|
8
|
+
* Trading pair metadata
|
|
9
|
+
*/
|
|
10
|
+
export interface TradingPair {
|
|
11
|
+
/** Unique identifier */
|
|
12
|
+
id: string;
|
|
13
|
+
/** Trading pair symbol e.g. BTC/USDC */
|
|
14
|
+
symbol: string;
|
|
15
|
+
/** Base token symbol */
|
|
16
|
+
base_token: string;
|
|
17
|
+
/** Quote token symbol */
|
|
18
|
+
quote_token: string;
|
|
19
|
+
/** Base token contract address */
|
|
20
|
+
base_token_contract: string;
|
|
21
|
+
/** Quote token contract address */
|
|
22
|
+
quote_token_contract: string;
|
|
23
|
+
/** Base token decimals */
|
|
24
|
+
base_decimals: number;
|
|
25
|
+
/** Quote token decimals */
|
|
26
|
+
quote_decimals: number;
|
|
27
|
+
/** Market type (e.g. SPOT) */
|
|
28
|
+
market_type: string;
|
|
29
|
+
/** Whether the market is active */
|
|
30
|
+
is_active: boolean;
|
|
31
|
+
/** Maker fee in basis points */
|
|
32
|
+
maker_fee_bps: number;
|
|
33
|
+
/** Taker fee in basis points */
|
|
34
|
+
taker_fee_bps: number;
|
|
35
|
+
/** Minimum order size */
|
|
36
|
+
min_order_size: string;
|
|
37
|
+
/** Maximum order size */
|
|
38
|
+
max_order_size: string;
|
|
39
|
+
/** Tick size for price increments */
|
|
40
|
+
tick_size: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* API response wrapper for trading pairs
|
|
44
|
+
*/
|
|
45
|
+
export interface GetTradingPairsResponse {
|
|
46
|
+
data: {
|
|
47
|
+
data: TradingPair[];
|
|
48
|
+
limit: number;
|
|
49
|
+
page: number;
|
|
50
|
+
total: number;
|
|
51
|
+
total_pages: number;
|
|
52
|
+
};
|
|
53
|
+
success: boolean;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* API response wrapper for single trading pair
|
|
57
|
+
*/
|
|
58
|
+
export interface GetTradingPairResponse {
|
|
59
|
+
data: TradingPair;
|
|
60
|
+
success: boolean;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Market API interface.
|
|
64
|
+
* Provides methods for fetching market metadata and trading pair information.
|
|
65
|
+
*/
|
|
66
|
+
export interface MarketAPI extends BaseAPI {
|
|
67
|
+
/**
|
|
68
|
+
* Fetch all available trading pairs supported by Monaco.
|
|
69
|
+
* @returns Promise resolving to array of trading pairs
|
|
70
|
+
*/
|
|
71
|
+
getTradingPairs(): Promise<TradingPair[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Fetch metadata for a single trading pair by its symbol (e.g. BTC-USDC).
|
|
74
|
+
* @param symbol - Trading pair symbol
|
|
75
|
+
* @returns Promise resolving to trading pair or undefined if not found
|
|
76
|
+
*/
|
|
77
|
+
getTradingPairBySymbol(symbol: string): Promise<TradingPair | undefined>;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/market/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAMtC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wBAAwB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mCAAmC;IACnC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,0BAA0B;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,2BAA2B;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,mCAAmC;IACnC,SAAS,EAAE,OAAO,CAAC;IACnB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,yBAAyB;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,yBAAyB;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE,WAAW,EAAE,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,OAAO;IACxC;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAE1C;;;;OAIG;IACH,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CAAC;CAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/market/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ import type { ApplicationsAPI } from "../applications";
|
|
|
3
3
|
import type { AuthAPI, AuthState } from "../auth";
|
|
4
4
|
import type { ProfileAPI } from "../profile";
|
|
5
5
|
import type { TradingAPI } from "../trading";
|
|
6
|
+
import type { MarketAPI } from "../market";
|
|
6
7
|
import type { VaultAPI } from "../vault";
|
|
7
|
-
import type {
|
|
8
|
+
import type { OrderWebSocketClient } from "../websocket";
|
|
8
9
|
import type { Network } from "./network";
|
|
9
10
|
/**
|
|
10
11
|
* Configuration options for the Monaco SDK.
|
|
@@ -32,10 +33,12 @@ export interface MonacoSDK {
|
|
|
32
33
|
vault: VaultAPI;
|
|
33
34
|
/** Trading operations API */
|
|
34
35
|
trading: TradingAPI;
|
|
36
|
+
/** Market metadata API */
|
|
37
|
+
market: MarketAPI;
|
|
35
38
|
/** Profile operations API */
|
|
36
39
|
profile: ProfileAPI;
|
|
37
|
-
/** WebSocket client for real-time events */
|
|
38
|
-
websocket:
|
|
40
|
+
/** WebSocket client for real-time order events */
|
|
41
|
+
websocket: OrderWebSocketClient;
|
|
39
42
|
/** Wallet client for all blockchain operations */
|
|
40
43
|
walletClient: WalletClient;
|
|
41
44
|
/** Public client for read-only blockchain operations */
|
package/dist/sdk/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACtF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACzB,2CAA2C;IAC3C,YAAY,EAAE,YAAY,CAAC;IAE3B,yDAAyD;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,gDAAgD;IAChD,SAAS,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,kCAAkC;IAClC,YAAY,EAAE,eAAe,CAAC;IAE9B,0BAA0B;IAC1B,IAAI,EAAE,OAAO,CAAC;IAEd,2BAA2B;IAC3B,KAAK,EAAE,QAAQ,CAAC;IAEhB,6BAA6B;IAC7B,OAAO,EAAE,UAAU,CAAC;IAEpB,0BAA0B;IAC1B,MAAM,EAAE,SAAS,CAAC;IAElB,6BAA6B;IAC7B,OAAO,EAAE,UAAU,CAAC;IAEpB,kDAAkD;IAClD,SAAS,EAAE,oBAAoB,CAAC;IAEhC,kDAAkD;IAClD,YAAY,EAAE,YAAY,CAAC;IAE3B,wDAAwD;IACxD,YAAY,EAAE,YAAY,CAAC;IAE3B,mCAAmC;IACnC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAE5C,sBAAsB;IACtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB,+BAA+B;IAC/B,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC;IAElC,2CAA2C;IAC3C,YAAY,IAAI,SAAS,GAAG,SAAS,CAAC;IAEtC,yCAAyC;IACzC,eAAe,IAAI,OAAO,CAAC;IAE3B,8BAA8B;IAC9B,WAAW,IAAI,OAAO,CAAC;IAEvB,sCAAsC;IACtC,iBAAiB,IAAI,MAAM,CAAC;IAE5B,uDAAuD;IACvD,UAAU,IAAI,OAAO,CAAC;IAEtB,+BAA+B;IAC/B,UAAU,IAAI,MAAM,CAAC;IAErB,6CAA6C;IAC7C,kBAAkB,CACjB,IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC/B;AAGD,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC"}
|
package/dist/trading/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type BaseAPI } from "../api";
|
|
7
7
|
import { type OrderSide } from "./orders";
|
|
8
|
-
import { type CancelOrderResponse, type
|
|
8
|
+
import { type CancelOrderResponse, type CreateOrderResponse, type ReplaceOrderResponse, type GetPaginatedOrdersResponse, type GetPaginatedOrdersParams, type GetOrderResponse } from "./responses";
|
|
9
9
|
/**
|
|
10
10
|
* Trading API interface.
|
|
11
11
|
* Provides methods for placing and managing orders.
|
|
@@ -45,18 +45,6 @@ export interface TradingAPI extends BaseAPI {
|
|
|
45
45
|
* @returns Promise resolving to the cancellation result
|
|
46
46
|
*/
|
|
47
47
|
cancelOrder(orderId: string): Promise<CancelOrderResponse>;
|
|
48
|
-
/**
|
|
49
|
-
* Updates an existing order (price and/or quantity).
|
|
50
|
-
* @param orderId - ID of the order to update
|
|
51
|
-
* @param updates - Fields to update
|
|
52
|
-
* @param updates.price - New price (optional)
|
|
53
|
-
* @param updates.quantity - New quantity (optional)
|
|
54
|
-
* @returns Promise resolving to the update result
|
|
55
|
-
*/
|
|
56
|
-
updateOrder(orderId: string, updates: {
|
|
57
|
-
price?: string;
|
|
58
|
-
quantity?: string;
|
|
59
|
-
}): Promise<UpdateOrderResponse>;
|
|
60
48
|
/**
|
|
61
49
|
* Replaces an existing order with new parameters.
|
|
62
50
|
* Updates the order with new price, quantity, and balance settings.
|
|
@@ -90,5 +78,5 @@ export interface TradingAPI extends BaseAPI {
|
|
|
90
78
|
getOrder(orderId: string): Promise<GetOrderResponse>;
|
|
91
79
|
}
|
|
92
80
|
export type { Order, OrderSide, OrderType, OrderStatus, TradingMode, } from "./orders";
|
|
93
|
-
export type {
|
|
81
|
+
export type { CancelOrderResponse, CreateOrderResponse, ReplaceOrderResponse, GetPaginatedOrdersResponse, GetPaginatedOrdersParams, GetOrderResponse, } from "./responses";
|
|
94
82
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trading/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/trading/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AAMrB;;;;GAIG;AACH,MAAM,WAAW,UAAW,SAAQ,OAAO;IAC1C;;;;;;;;;OASG;IACH,eAAe,CACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;KACxB,GACC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;;;;;OAQG;IACH,gBAAgB,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QACT,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,GACC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;OAIG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAE1D;;;;;;;;;OASG;IACH,YAAY,CACV,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;KAC5B,GACA,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC;;;;;;;;OAQG;IACH,kBAAkB,CAAC,MAAM,CAAC,EAAE,wBAAwB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAE3F;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACtD;AAGD,YAAY,EACX,KAAK,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,WAAW,GACX,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,aAAa,CAAC"}
|
|
@@ -4,17 +4,6 @@
|
|
|
4
4
|
* Response types for trading operations.
|
|
5
5
|
*/
|
|
6
6
|
import type { Order, OrderStatus } from "./orders";
|
|
7
|
-
/**
|
|
8
|
-
* Response from placing an order (legacy - kept for backward compatibility).
|
|
9
|
-
*/
|
|
10
|
-
export interface OrderResponse {
|
|
11
|
-
/** Order identifier */
|
|
12
|
-
orderId: string;
|
|
13
|
-
/** Order status */
|
|
14
|
-
status: "accepted" | "rejected";
|
|
15
|
-
/** Timestamp of the response */
|
|
16
|
-
timestamp: number;
|
|
17
|
-
}
|
|
18
7
|
/**
|
|
19
8
|
* Response from creating an order.
|
|
20
9
|
*/
|
|
@@ -40,22 +29,6 @@ export interface CancelOrderResponse {
|
|
|
40
29
|
/** Cancellation status */
|
|
41
30
|
status: "SUCCESS" | "FAILED";
|
|
42
31
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Response from updating an order.
|
|
45
|
-
*/
|
|
46
|
-
export interface UpdateOrderResponse {
|
|
47
|
-
/** Order identifier */
|
|
48
|
-
order_id: string;
|
|
49
|
-
/** Update status */
|
|
50
|
-
status: "SUCCESS" | "FAILED";
|
|
51
|
-
/** Updated fields */
|
|
52
|
-
updated_fields: {
|
|
53
|
-
/** Updated price if changed */
|
|
54
|
-
price?: string;
|
|
55
|
-
/** Updated quantity if changed */
|
|
56
|
-
quantity?: string;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
32
|
/**
|
|
60
33
|
* Response from replacing an order.
|
|
61
34
|
*/
|
|
@@ -74,21 +47,6 @@ export interface ReplaceOrderResponse {
|
|
|
74
47
|
status: string;
|
|
75
48
|
};
|
|
76
49
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Response from closing a position (legacy - kept for backward compatibility).
|
|
79
|
-
*/
|
|
80
|
-
export interface ClosePositionResponse {
|
|
81
|
-
/** Market identifier */
|
|
82
|
-
market: string;
|
|
83
|
-
/** Close position status */
|
|
84
|
-
status: "closed" | "no_position" | "partial_close";
|
|
85
|
-
/** Amount that was closed */
|
|
86
|
-
closedSize?: bigint;
|
|
87
|
-
/** Remaining position size */
|
|
88
|
-
remainingSize?: bigint;
|
|
89
|
-
/** Timestamp of the response */
|
|
90
|
-
timestamp: number;
|
|
91
|
-
}
|
|
92
50
|
/**
|
|
93
51
|
* Query parameters for getting paginated orders
|
|
94
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/trading/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/trading/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB;IACnB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,+BAA+B;IAC/B,YAAY,CAAC,EAAE;QACd,iDAAiD;QACjD,kBAAkB,EAAE,MAAM,CAAC;QAC3B,0BAA0B;QAC1B,MAAM,EAAE,MAAM,CAAC;KACf,CAAC;CACF;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC,uBAAuB;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,2BAA2B;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,+BAA+B;IAC/B,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7B,iDAAiD;IACjD,YAAY,CAAC,EAAE;QACb,iDAAiD;QACjD,kBAAkB,EAAE,MAAM,CAAC;QAC3B,0BAA0B;QAC1B,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,6BAA6B;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,6BAA6B;IAC7B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,sBAAsB;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,WAAW,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC,iBAAiB;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,qBAAqB;IACrB,MAAM,EAAE,SAAS,GAAG,QAAQ,CAAC;CAC7B"}
|
package/dist/vault/index.d.ts
CHANGED
|
@@ -11,33 +11,30 @@ import type { Balance, TransactionResult } from "./responses";
|
|
|
11
11
|
* Handles token approvals and balance management.
|
|
12
12
|
*/
|
|
13
13
|
export interface VaultAPI extends BaseAPI {
|
|
14
|
-
/**
|
|
15
|
-
* Set the address of the vault.
|
|
16
|
-
* @param vaultAddress - Address of the vault
|
|
17
|
-
* @returns void
|
|
18
|
-
*/
|
|
19
|
-
setVaultAddress(vaultAddress: string): void;
|
|
20
14
|
/**
|
|
21
15
|
* Approves the vault to spend tokens.
|
|
22
16
|
* @param token - Address of the token to approve
|
|
23
17
|
* @param amount - Amount to approve
|
|
18
|
+
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
24
19
|
* @returns Promise resolving to the transaction result
|
|
25
20
|
*/
|
|
26
|
-
approve(token: string, amount: bigint): Promise<TransactionResult>;
|
|
21
|
+
approve(token: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
|
|
27
22
|
/**
|
|
28
23
|
* Deposits tokens into the vault.
|
|
29
24
|
* @param token - Address of the token to deposit
|
|
30
25
|
* @param amount - Amount to deposit
|
|
26
|
+
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
31
27
|
* @returns Promise resolving to the transaction result
|
|
32
28
|
*/
|
|
33
|
-
deposit(token: string, amount: bigint): Promise<TransactionResult>;
|
|
29
|
+
deposit(token: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
|
|
34
30
|
/**
|
|
35
31
|
* Withdraws tokens from the vault.
|
|
36
32
|
* @param token - Address of the token to withdraw
|
|
37
33
|
* @param amount - Amount to withdraw
|
|
34
|
+
* @param autoWait - Whether to automatically wait for transaction confirmation (defaults to true)
|
|
38
35
|
* @returns Promise resolving to the transaction result
|
|
39
36
|
*/
|
|
40
|
-
withdraw(token: string, amount: bigint): Promise<TransactionResult>;
|
|
37
|
+
withdraw(token: string, amount: bigint, autoWait?: boolean): Promise<TransactionResult>;
|
|
41
38
|
/**
|
|
42
39
|
* Gets the balance of a token in the vault.
|
|
43
40
|
* @param token - Address of the token to check
|
|
@@ -57,6 +54,11 @@ export interface VaultAPI extends BaseAPI {
|
|
|
57
54
|
* @returns Promise resolving to whether approval is needed
|
|
58
55
|
*/
|
|
59
56
|
needsApproval(token: string, amount: bigint): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the address of the vault.
|
|
59
|
+
* @returns Promise resolving to the address of the vault
|
|
60
|
+
*/
|
|
61
|
+
getVaultAddress(): Promise<string>;
|
|
60
62
|
}
|
|
61
63
|
export type { Balance, TransactionResult } from "./responses";
|
|
62
64
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vault/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAM9D;;;;GAIG;AACH,MAAM,WAAW,QAAS,SAAQ,OAAO;IACxC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vault/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAM9D;;;;GAIG;AACH,MAAM,WAAW,QAAS,SAAQ,OAAO;IACxC;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEvF;;;;;;OAMG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEvF;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAExF;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE5C;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7C;;;;;OAKG;IACH,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAE/D;;;OAGG;IACH,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACnC;AAGD,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -13,6 +13,8 @@ export interface TransactionResult {
|
|
|
13
13
|
status: "pending" | "confirmed" | "failed";
|
|
14
14
|
/** Nonce used for this operation */
|
|
15
15
|
nonce: bigint;
|
|
16
|
+
/** Transaction receipt (only available when autoWait is enabled) */
|
|
17
|
+
receipt?: import('viem').TransactionReceipt;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* Token balance information.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/vault/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3C,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/vault/responses.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,yBAAyB;IACzB,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAC3C,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,kBAAkB,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;CACjB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebSocket Event Types
|
|
3
|
+
*
|
|
4
|
+
* Event interfaces for real-time WebSocket communications
|
|
5
|
+
*/
|
|
6
|
+
import { OrderSide, OrderType, TradingMode } from "../trading";
|
|
7
|
+
/**
|
|
8
|
+
* Base interface for all WebSocket events
|
|
9
|
+
*/
|
|
10
|
+
export interface BaseWebSocketEvent {
|
|
11
|
+
/** Event type identifier */
|
|
12
|
+
type: string;
|
|
13
|
+
/** Event timestamp (ISO string) */
|
|
14
|
+
timestamp: string;
|
|
15
|
+
/** Unique event ID */
|
|
16
|
+
eventId: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Order event types
|
|
20
|
+
*/
|
|
21
|
+
export type OrderEventType = "OrderPlaced" | "OrderMatched" | "OrderPartiallyFilled" | "OrderFilled" | "OrderCancelled" | "OrderRejected" | "OrderReplaced" | "OrderExpired";
|
|
22
|
+
/**
|
|
23
|
+
* Order event interface with camelCase properties
|
|
24
|
+
*/
|
|
25
|
+
export interface OrderEvent {
|
|
26
|
+
orderId: string;
|
|
27
|
+
eventType: OrderEventType;
|
|
28
|
+
details: {
|
|
29
|
+
applicationId?: string;
|
|
30
|
+
orderType?: OrderType;
|
|
31
|
+
price?: string;
|
|
32
|
+
quantity?: string;
|
|
33
|
+
side?: OrderSide;
|
|
34
|
+
tradingMode?: TradingMode;
|
|
35
|
+
tradingPair?: string;
|
|
36
|
+
tradingPairId?: string;
|
|
37
|
+
userId: string;
|
|
38
|
+
cancelledAt?: string;
|
|
39
|
+
filledQuantity?: string;
|
|
40
|
+
remainingQuantity?: string;
|
|
41
|
+
reason?: string;
|
|
42
|
+
};
|
|
43
|
+
timestamp: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Subscription configuration for order events
|
|
47
|
+
*/
|
|
48
|
+
export interface OrderSubscriptionConfig {
|
|
49
|
+
eventTypes: OrderEventType[];
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/websocket/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,cAAc,GACd,sBAAsB,GACtB,aAAa,GACb,gBAAgB,GAChB,eAAe,GACf,eAAe,GACf,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,WAAW,CAAC,EAAE,WAAW,CAAC;QAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,cAAc,EAAE,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/websocket/events.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Websocket Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Fundamental definitions for Websocket connections, errors and events.
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*/
|
|
9
|
-
export interface BaseWebSocketEvent {
|
|
10
|
-
/** Event type identifier */
|
|
11
|
-
type: string;
|
|
12
|
-
/** Event timestamp (ISO string) */
|
|
13
|
-
timestamp: string;
|
|
14
|
-
/** Unique event ID */
|
|
15
|
-
eventId: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* WebSocket connection status
|
|
19
|
-
*/
|
|
20
|
-
export type ConnectionStatus = "connected" | "disconnected" | "connecting" | "reconnecting";
|
|
6
|
+
export * from "./events";
|
|
7
|
+
import type { OrderEvent } from "./events";
|
|
21
8
|
/**
|
|
22
9
|
* WebSocket connection configuration
|
|
23
10
|
*/
|
|
@@ -44,9 +31,13 @@ export interface BaseErrorEvent {
|
|
|
44
31
|
details?: any;
|
|
45
32
|
}
|
|
46
33
|
/**
|
|
47
|
-
*
|
|
34
|
+
* WebSocket connection status
|
|
48
35
|
*/
|
|
49
|
-
export
|
|
36
|
+
export type ConnectionStatus = "connected" | "disconnected" | "connecting" | "reconnecting";
|
|
37
|
+
/**
|
|
38
|
+
* Base WebSocket client interface
|
|
39
|
+
*/
|
|
40
|
+
export interface BaseWebSocketClient {
|
|
50
41
|
/**
|
|
51
42
|
* Connect to the WebSocket server
|
|
52
43
|
* @returns Promise that resolves when connected
|
|
@@ -77,4 +68,20 @@ export interface WebSocketClient {
|
|
|
77
68
|
*/
|
|
78
69
|
send(data: any): void;
|
|
79
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Order-specific WebSocket client interface
|
|
73
|
+
*/
|
|
74
|
+
export interface OrderWebSocketClient extends BaseWebSocketClient {
|
|
75
|
+
/**
|
|
76
|
+
* Subscribe to order events for a specific market
|
|
77
|
+
* @param market - Market symbol (e.g., 'ETH-USD')
|
|
78
|
+
* @param callback - Callback function for order events
|
|
79
|
+
*/
|
|
80
|
+
subscribeToOrderEvents(market: string, callback: (event: OrderEvent) => void): void;
|
|
81
|
+
/**
|
|
82
|
+
* Unsubscribe from order events for a specific market
|
|
83
|
+
* @param market - Market symbol
|
|
84
|
+
*/
|
|
85
|
+
unsubscribeFromOrderEvents(market: string): void;
|
|
86
|
+
}
|
|
80
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/websocket/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/websocket/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC;AACzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,yDAAyD;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iDAAiD;IACjD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,cAAc,GAAG,YAAY,GAAG,cAAc,CAAC;AAG5F;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;OAEG;IACH,UAAU,IAAI,IAAI,CAAC;IAEnB;;;OAGG;IACH,mBAAmB,IAAI,gBAAgB,CAAC;IAExC;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,mBAAmB;IAC/D;;;;OAIG;IACH,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CAAC;IAEpF;;;OAGG;IACH,0BAA0B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAClD"}
|
package/dist/websocket/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Websocket Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Fundamental definitions for Websocket connections, errors and events.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export * from "./events";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/websocket/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/websocket/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,UAAU,CAAC"}
|