@lightconexyz/lightcone-sdk 0.1.0
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 +232 -0
- package/dist/api/client.d.ts +225 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +452 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/error.d.ts +58 -0
- package/dist/api/error.d.ts.map +1 -0
- package/dist/api/error.js +98 -0
- package/dist/api/error.js.map +1 -0
- package/dist/api/index.d.ts +23 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +51 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/types/admin.d.ts +49 -0
- package/dist/api/types/admin.d.ts.map +1 -0
- package/dist/api/types/admin.js +13 -0
- package/dist/api/types/admin.js.map +1 -0
- package/dist/api/types/index.d.ts +14 -0
- package/dist/api/types/index.d.ts.map +1 -0
- package/dist/api/types/index.js +13 -0
- package/dist/api/types/index.js.map +1 -0
- package/dist/api/types/market.d.ts +186 -0
- package/dist/api/types/market.d.ts.map +1 -0
- package/dist/api/types/market.js +6 -0
- package/dist/api/types/market.js.map +1 -0
- package/dist/api/types/order.d.ts +190 -0
- package/dist/api/types/order.d.ts.map +1 -0
- package/dist/api/types/order.js +6 -0
- package/dist/api/types/order.js.map +1 -0
- package/dist/api/types/orderbook.d.ts +36 -0
- package/dist/api/types/orderbook.d.ts.map +1 -0
- package/dist/api/types/orderbook.js +6 -0
- package/dist/api/types/orderbook.js.map +1 -0
- package/dist/api/types/position.d.ts +60 -0
- package/dist/api/types/position.d.ts.map +1 -0
- package/dist/api/types/position.js +6 -0
- package/dist/api/types/position.js.map +1 -0
- package/dist/api/types/price_history.d.ts +68 -0
- package/dist/api/types/price_history.d.ts.map +1 -0
- package/dist/api/types/price_history.js +13 -0
- package/dist/api/types/price_history.js.map +1 -0
- package/dist/api/types/trade.d.ts +67 -0
- package/dist/api/types/trade.d.ts.map +1 -0
- package/dist/api/types/trade.js +13 -0
- package/dist/api/types/trade.js.map +1 -0
- package/dist/api/validation.d.ts +24 -0
- package/dist/api/validation.d.ts.map +1 -0
- package/dist/api/validation.js +53 -0
- package/dist/api/validation.js.map +1 -0
- package/dist/auth.d.ts +80 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +149 -0
- package/dist/auth.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +107 -0
- package/dist/index.js.map +1 -0
- package/dist/network.d.ts +5 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +8 -0
- package/dist/network.js.map +1 -0
- package/dist/program/accounts.d.ts +98 -0
- package/dist/program/accounts.d.ts.map +1 -0
- package/dist/program/accounts.js +319 -0
- package/dist/program/accounts.js.map +1 -0
- package/dist/program/builder.d.ts +94 -0
- package/dist/program/builder.d.ts.map +1 -0
- package/dist/program/builder.js +175 -0
- package/dist/program/builder.js.map +1 -0
- package/dist/program/client.d.ts +56 -0
- package/dist/program/client.d.ts.map +1 -0
- package/dist/program/client.js +288 -0
- package/dist/program/client.js.map +1 -0
- package/dist/program/constants.d.ts +108 -0
- package/dist/program/constants.d.ts.map +1 -0
- package/dist/program/constants.js +112 -0
- package/dist/program/constants.js.map +1 -0
- package/dist/program/index.d.ts +14 -0
- package/dist/program/index.d.ts.map +1 -0
- package/dist/program/index.js +149 -0
- package/dist/program/index.js.map +1 -0
- package/dist/program/instructions.d.ts +248 -0
- package/dist/program/instructions.d.ts.map +1 -0
- package/dist/program/instructions.js +692 -0
- package/dist/program/instructions.js.map +1 -0
- package/dist/program/orders.d.ts +151 -0
- package/dist/program/orders.d.ts.map +1 -0
- package/dist/program/orders.js +417 -0
- package/dist/program/orders.js.map +1 -0
- package/dist/program/pda.d.ts +73 -0
- package/dist/program/pda.d.ts.map +1 -0
- package/dist/program/pda.js +131 -0
- package/dist/program/pda.js.map +1 -0
- package/dist/program/types.d.ts +380 -0
- package/dist/program/types.d.ts.map +1 -0
- package/dist/program/types.js +27 -0
- package/dist/program/types.js.map +1 -0
- package/dist/program/utils.d.ts +91 -0
- package/dist/program/utils.d.ts.map +1 -0
- package/dist/program/utils.js +219 -0
- package/dist/program/utils.js.map +1 -0
- package/dist/shared/index.d.ts +8 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +18 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/price.d.ts +41 -0
- package/dist/shared/price.d.ts.map +1 -0
- package/dist/shared/price.js +57 -0
- package/dist/shared/price.js.map +1 -0
- package/dist/shared/scaling.d.ts +45 -0
- package/dist/shared/scaling.d.ts.map +1 -0
- package/dist/shared/scaling.js +84 -0
- package/dist/shared/scaling.js.map +1 -0
- package/dist/shared/types.d.ts +19 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +23 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/websocket/client.d.ts +238 -0
- package/dist/websocket/client.d.ts.map +1 -0
- package/dist/websocket/client.js +580 -0
- package/dist/websocket/client.js.map +1 -0
- package/dist/websocket/error.d.ts +47 -0
- package/dist/websocket/error.d.ts.map +1 -0
- package/dist/websocket/error.js +83 -0
- package/dist/websocket/error.js.map +1 -0
- package/dist/websocket/handlers.d.ts +97 -0
- package/dist/websocket/handlers.d.ts.map +1 -0
- package/dist/websocket/handlers.js +277 -0
- package/dist/websocket/handlers.js.map +1 -0
- package/dist/websocket/index.d.ts +38 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/index.js +75 -0
- package/dist/websocket/index.js.map +1 -0
- package/dist/websocket/state/index.d.ts +7 -0
- package/dist/websocket/state/index.d.ts.map +1 -0
- package/dist/websocket/state/index.js +14 -0
- package/dist/websocket/state/index.js.map +1 -0
- package/dist/websocket/state/orderbook.d.ts +107 -0
- package/dist/websocket/state/orderbook.d.ts.map +1 -0
- package/dist/websocket/state/orderbook.js +293 -0
- package/dist/websocket/state/orderbook.js.map +1 -0
- package/dist/websocket/state/price.d.ts +108 -0
- package/dist/websocket/state/price.d.ts.map +1 -0
- package/dist/websocket/state/price.js +243 -0
- package/dist/websocket/state/price.js.map +1 -0
- package/dist/websocket/state/user.d.ts +83 -0
- package/dist/websocket/state/user.d.ts.map +1 -0
- package/dist/websocket/state/user.js +228 -0
- package/dist/websocket/state/user.js.map +1 -0
- package/dist/websocket/subscriptions.d.ts +143 -0
- package/dist/websocket/subscriptions.d.ts.map +1 -0
- package/dist/websocket/subscriptions.js +244 -0
- package/dist/websocket/subscriptions.js.map +1 -0
- package/dist/websocket/types.d.ts +417 -0
- package/dist/websocket/types.d.ts.map +1 -0
- package/dist/websocket/types.js +195 -0
- package/dist/websocket/types.js.map +1 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Lightcone TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Lightcone protocol on Solana.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @lightcone/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Modules
|
|
12
|
+
|
|
13
|
+
| Module | Description |
|
|
14
|
+
|--------|-------------|
|
|
15
|
+
| [`program`](src/program/README.md) | On-chain Solana program interaction (accounts, transactions, orders, Ed25519 verification) |
|
|
16
|
+
| [`api`](src/api/README.md) | REST API client for market data and order management |
|
|
17
|
+
| [`websocket`](src/websocket/README.md) | Real-time data streaming via WebSocket |
|
|
18
|
+
| [`shared`](src/shared/README.md) | Shared utilities (Resolution, constants, decimal helpers) |
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { LightconePinocchioClient, PROGRAM_ID, api, websocket } from "@lightcone/sdk";
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### REST API
|
|
27
|
+
|
|
28
|
+
Query markets, submit orders, and manage positions via the REST API.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import { api } from "@lightcone/sdk";
|
|
32
|
+
|
|
33
|
+
const client = new api.LightconeApiClient();
|
|
34
|
+
|
|
35
|
+
// Get markets
|
|
36
|
+
const markets = await client.getMarkets();
|
|
37
|
+
console.log(`Found ${markets.total} markets`);
|
|
38
|
+
|
|
39
|
+
// Get orderbook depth
|
|
40
|
+
const orderbook = await client.getOrderbook("orderbook_id", 10);
|
|
41
|
+
console.log(`Best bid: ${orderbook.best_bid}`);
|
|
42
|
+
console.log(`Best ask: ${orderbook.best_ask}`);
|
|
43
|
+
|
|
44
|
+
// Get user positions
|
|
45
|
+
const positions = await client.getUserPositions("user_pubkey");
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### On-Chain Program
|
|
49
|
+
|
|
50
|
+
Build transactions for on-chain operations: minting positions, matching orders, redeeming winnings.
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Connection, Keypair } from "@solana/web3.js";
|
|
54
|
+
import { LightconePinocchioClient, BidOrderParams } from "@lightcone/sdk";
|
|
55
|
+
|
|
56
|
+
const connection = new Connection("https://api.devnet.solana.com");
|
|
57
|
+
const client = new LightconePinocchioClient(connection);
|
|
58
|
+
|
|
59
|
+
// Fetch account state
|
|
60
|
+
const exchange = await client.getExchange();
|
|
61
|
+
const market = await client.getMarket(0n);
|
|
62
|
+
console.log(`Market status: ${market.status}`);
|
|
63
|
+
|
|
64
|
+
// Create a signed order
|
|
65
|
+
const keypair = Keypair.generate();
|
|
66
|
+
const nonce = await client.getNextNonce(keypair.publicKey);
|
|
67
|
+
|
|
68
|
+
const order = client.signFullOrder(
|
|
69
|
+
client.createBidOrder({
|
|
70
|
+
nonce,
|
|
71
|
+
maker: keypair.publicKey,
|
|
72
|
+
market: client.pda.getMarketPda(0n, client.programId)[0],
|
|
73
|
+
baseMint: conditionalTokenMint,
|
|
74
|
+
quoteMint: usdcMint,
|
|
75
|
+
makerAmount: 1_000_000n, // 1 USDC
|
|
76
|
+
takerAmount: 500_000n, // 0.5 outcome tokens
|
|
77
|
+
expiration: 0n,
|
|
78
|
+
}),
|
|
79
|
+
keypair
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### WebSocket
|
|
84
|
+
|
|
85
|
+
Stream real-time orderbook updates, trades, and user events.
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { websocket } from "@lightcone/sdk";
|
|
89
|
+
|
|
90
|
+
const client = await websocket.LightconeWebSocketClient.connectDefault();
|
|
91
|
+
|
|
92
|
+
// Subscribe to orderbook updates
|
|
93
|
+
client.subscribeBookUpdates(["market:orderbook"]);
|
|
94
|
+
|
|
95
|
+
// Register event handler
|
|
96
|
+
client.on((event) => {
|
|
97
|
+
if (event.type === "BookUpdate") {
|
|
98
|
+
const book = client.getOrderbook(event.orderbookId);
|
|
99
|
+
if (book) {
|
|
100
|
+
console.log(`Best bid: ${book.bestBid()}`);
|
|
101
|
+
console.log(`Best ask: ${book.bestAsk()}`);
|
|
102
|
+
}
|
|
103
|
+
} else if (event.type === "Trade") {
|
|
104
|
+
console.log(`Trade: ${event.trade.size} @ ${event.trade.price}`);
|
|
105
|
+
} else if (event.type === "Disconnected") {
|
|
106
|
+
console.log(`Disconnected: ${event.reason}`);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Module Overview
|
|
112
|
+
|
|
113
|
+
### Program Module
|
|
114
|
+
|
|
115
|
+
Direct interaction with the Lightcone Solana program:
|
|
116
|
+
|
|
117
|
+
- **Account Types**: Exchange, Market, Position, OrderStatus, UserNonce
|
|
118
|
+
- **Transaction Builders**: All 14 instructions (mint, merge, match, settle, etc.)
|
|
119
|
+
- **PDA Derivation**: 8 PDA functions with seeds
|
|
120
|
+
- **Order Types**: FullOrder (225 bytes), CompactOrder (65 bytes)
|
|
121
|
+
- **Ed25519 Verification**: Three strategies (individual, batch, cross-reference)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import {
|
|
125
|
+
LightconePinocchioClient,
|
|
126
|
+
createBidOrder,
|
|
127
|
+
signOrderFull,
|
|
128
|
+
hashOrder,
|
|
129
|
+
} from "@lightcone/sdk";
|
|
130
|
+
|
|
131
|
+
// Create and sign an order
|
|
132
|
+
const order = signOrderFull(
|
|
133
|
+
createBidOrder({
|
|
134
|
+
nonce: 1n,
|
|
135
|
+
maker: pubkey,
|
|
136
|
+
market: marketPda,
|
|
137
|
+
baseMint: yesToken,
|
|
138
|
+
quoteMint: noToken,
|
|
139
|
+
makerAmount: 100_000n,
|
|
140
|
+
takerAmount: 50_000n,
|
|
141
|
+
expiration: 0n,
|
|
142
|
+
}),
|
|
143
|
+
keypair
|
|
144
|
+
);
|
|
145
|
+
const orderHash = hashOrder(order);
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### API Module
|
|
149
|
+
|
|
150
|
+
REST API client with typed requests and responses:
|
|
151
|
+
|
|
152
|
+
- **Markets**: getMarkets, getMarket, getMarketBySlug
|
|
153
|
+
- **Orderbooks**: getOrderbook with depth parameter
|
|
154
|
+
- **Orders**: submitOrder, cancelOrder, cancelAllOrders
|
|
155
|
+
- **Positions**: getUserPositions, getUserMarketPositions
|
|
156
|
+
- **Trades**: getTrades with filters
|
|
157
|
+
- **Price History**: getPriceHistory with OHLCV
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
import { api } from "@lightcone/sdk";
|
|
161
|
+
|
|
162
|
+
const client = new api.LightconeApiClient();
|
|
163
|
+
const response = await client.submitOrder({
|
|
164
|
+
maker: "pubkey",
|
|
165
|
+
nonce: 1,
|
|
166
|
+
market_pubkey: "market",
|
|
167
|
+
base_token: "base",
|
|
168
|
+
quote_token: "quote",
|
|
169
|
+
side: 0, // BID
|
|
170
|
+
maker_amount: 1000000,
|
|
171
|
+
taker_amount: 500000,
|
|
172
|
+
expiration: 0,
|
|
173
|
+
signature: "hex_signature",
|
|
174
|
+
orderbook_id: "orderbook",
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### WebSocket Module
|
|
179
|
+
|
|
180
|
+
Real-time streaming with automatic state management:
|
|
181
|
+
|
|
182
|
+
- **Subscriptions**: book_updates, trades, user, price_history, market
|
|
183
|
+
- **State Management**: LocalOrderbook, UserState, PriceHistory
|
|
184
|
+
- **Authentication**: Ed25519 sign-in for user streams
|
|
185
|
+
- **Auto-Reconnect**: Configurable reconnection with exponential backoff and jitter
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
import { websocket } from "@lightcone/sdk";
|
|
189
|
+
import { Keypair } from "@solana/web3.js";
|
|
190
|
+
|
|
191
|
+
// Authenticated connection for user streams
|
|
192
|
+
const keypair = Keypair.generate();
|
|
193
|
+
const client = await websocket.LightconeWebSocketClient.connectAuthenticated(keypair);
|
|
194
|
+
client.subscribeUser(keypair.publicKey.toBase58());
|
|
195
|
+
|
|
196
|
+
// Access maintained state
|
|
197
|
+
const state = client.getUserState(keypair.publicKey.toBase58());
|
|
198
|
+
if (state) {
|
|
199
|
+
console.log(`Open orders: ${state.orderCount()}`);
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Shared Module
|
|
204
|
+
|
|
205
|
+
Common utilities used across modules:
|
|
206
|
+
|
|
207
|
+
- **Resolution**: Candle intervals (1m, 5m, 15m, 1h, 4h, 1d)
|
|
208
|
+
- **Constants**: Program IDs, seeds, discriminators, sizes
|
|
209
|
+
- **Types**: MarketStatus, OrderSide, account data interfaces
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
import { Resolution, PROGRAM_ID } from "@lightcone/sdk";
|
|
213
|
+
|
|
214
|
+
const res = Resolution.OneHour; // "1h"
|
|
215
|
+
console.log(res); // "1h"
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Features
|
|
219
|
+
|
|
220
|
+
- **Full TypeScript support**: Comprehensive types for all APIs
|
|
221
|
+
- **Zero-copy serialization**: Efficient binary order formats
|
|
222
|
+
- **Cross-instruction Ed25519**: Optimized transaction sizes
|
|
223
|
+
- **Automatic reconnection**: Jittered exponential backoff
|
|
224
|
+
- **State management**: Local orderbook and user state tracking
|
|
225
|
+
|
|
226
|
+
## Program ID
|
|
227
|
+
|
|
228
|
+
**Mainnet/Devnet**: `EfRvELrn4b5aJRwddD1VUrqzsfm1pewBLPebq3iMPDp2`
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST API client for Lightcone.
|
|
3
|
+
*/
|
|
4
|
+
import { Keypair } from "@solana/web3.js";
|
|
5
|
+
import { type AuthCredentials } from "../auth";
|
|
6
|
+
import type { MarketsResponse, MarketInfoResponse, DepositAssetsResponse, OrderbookResponse, SubmitOrderRequest, OrderResponse, CancelResponse, CancelAllResponse, PositionsResponse, MarketPositionsResponse, UserOrdersResponse, PriceHistoryParams, PriceHistoryResponse, TradesParams, TradesResponse, AdminResponse, CreateOrderbookRequest, CreateOrderbookResponse } from "./types";
|
|
7
|
+
export { DEFAULT_API_URL } from "../network";
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for retry behavior.
|
|
10
|
+
*/
|
|
11
|
+
export interface RetryConfig {
|
|
12
|
+
/** Maximum number of retry attempts (default: 0 = disabled) */
|
|
13
|
+
maxRetries: number;
|
|
14
|
+
/** Initial delay in milliseconds (default: 100) */
|
|
15
|
+
baseDelayMs: number;
|
|
16
|
+
/** Maximum delay cap in milliseconds (default: 10000) */
|
|
17
|
+
maxDelayMs: number;
|
|
18
|
+
}
|
|
19
|
+
/** Default retry configuration (disabled) */
|
|
20
|
+
export declare const DEFAULT_RETRY_CONFIG: RetryConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Configuration for the Lightcone API client.
|
|
23
|
+
*/
|
|
24
|
+
export interface LightconeApiClientConfig {
|
|
25
|
+
/** Base URL for the API (default: https://tapi.lightcone.xyz/api) */
|
|
26
|
+
baseUrl?: string;
|
|
27
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
28
|
+
timeout?: number;
|
|
29
|
+
/** Additional headers to include in requests */
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
/** Retry configuration for transient failures */
|
|
32
|
+
retry?: Partial<RetryConfig>;
|
|
33
|
+
/** Authentication token for authenticated endpoints */
|
|
34
|
+
authToken?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* REST API client for the Lightcone platform.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import { LightconeApiClient } from "@lightcone/sdk/api";
|
|
42
|
+
*
|
|
43
|
+
* const client = new LightconeApiClient();
|
|
44
|
+
*
|
|
45
|
+
* // Get all markets
|
|
46
|
+
* const markets = await client.getMarkets();
|
|
47
|
+
*
|
|
48
|
+
* // Get orderbook
|
|
49
|
+
* const orderbook = await client.getOrderbook("market1:ob1");
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare class LightconeApiClient {
|
|
53
|
+
private readonly baseUrl;
|
|
54
|
+
private readonly timeout;
|
|
55
|
+
private readonly headers;
|
|
56
|
+
private readonly retryConfig;
|
|
57
|
+
private authToken?;
|
|
58
|
+
constructor(config?: LightconeApiClientConfig);
|
|
59
|
+
/**
|
|
60
|
+
* Log in with a Solana keypair. Stores the auth token for subsequent requests.
|
|
61
|
+
*
|
|
62
|
+
* @param keypair - The Solana Keypair for authentication
|
|
63
|
+
* @returns AuthCredentials containing the auth token and user info
|
|
64
|
+
*/
|
|
65
|
+
login(keypair: Keypair): Promise<AuthCredentials>;
|
|
66
|
+
/**
|
|
67
|
+
* Set the authentication token manually.
|
|
68
|
+
*/
|
|
69
|
+
setAuthToken(token: string): void;
|
|
70
|
+
/**
|
|
71
|
+
* Clear the authentication token.
|
|
72
|
+
*/
|
|
73
|
+
clearAuthToken(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Check if the client has an authentication token.
|
|
76
|
+
*/
|
|
77
|
+
hasAuthToken(): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Make an HTTP request with retry support.
|
|
80
|
+
*/
|
|
81
|
+
private request;
|
|
82
|
+
/**
|
|
83
|
+
* Check if the API is healthy.
|
|
84
|
+
*
|
|
85
|
+
* @throws {ApiError} If the health check fails
|
|
86
|
+
*/
|
|
87
|
+
healthCheck(): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Get all available markets.
|
|
90
|
+
*
|
|
91
|
+
* @returns List of markets
|
|
92
|
+
*/
|
|
93
|
+
getMarkets(): Promise<MarketsResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Get market information by pubkey.
|
|
96
|
+
*
|
|
97
|
+
* @param marketPubkey - Market PDA address (Base58)
|
|
98
|
+
* @returns Market details
|
|
99
|
+
* @throws {ApiError} If marketPubkey is invalid
|
|
100
|
+
*/
|
|
101
|
+
getMarket(marketPubkey: string): Promise<MarketInfoResponse>;
|
|
102
|
+
/**
|
|
103
|
+
* Get market information by slug.
|
|
104
|
+
*
|
|
105
|
+
* @param slug - URL-friendly market slug
|
|
106
|
+
* @returns Market details
|
|
107
|
+
*/
|
|
108
|
+
getMarketBySlug(slug: string): Promise<MarketInfoResponse>;
|
|
109
|
+
/**
|
|
110
|
+
* Get deposit assets for a market.
|
|
111
|
+
*
|
|
112
|
+
* @param marketPubkey - Market PDA address (Base58)
|
|
113
|
+
* @returns Deposit assets
|
|
114
|
+
* @throws {ApiError} If marketPubkey is invalid
|
|
115
|
+
*/
|
|
116
|
+
getDepositAssets(marketPubkey: string): Promise<DepositAssetsResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Get orderbook snapshot.
|
|
119
|
+
*
|
|
120
|
+
* @param orderbookId - Orderbook identifier
|
|
121
|
+
* @param depth - Number of levels (default: 20)
|
|
122
|
+
* @returns Orderbook snapshot
|
|
123
|
+
*/
|
|
124
|
+
getOrderbook(orderbookId: string, depth?: number): Promise<OrderbookResponse>;
|
|
125
|
+
/**
|
|
126
|
+
* Submit a new order.
|
|
127
|
+
*
|
|
128
|
+
* @param request - Order details
|
|
129
|
+
* @returns Order response with hash and fill info
|
|
130
|
+
* @throws {ApiError} If any pubkey or signature is invalid
|
|
131
|
+
*/
|
|
132
|
+
submitOrder(request: SubmitOrderRequest): Promise<OrderResponse>;
|
|
133
|
+
/**
|
|
134
|
+
* Cancel an order with a pre-computed signature.
|
|
135
|
+
*
|
|
136
|
+
* @param orderHash - Hash of the order to cancel (hex)
|
|
137
|
+
* @param maker - Order creator's pubkey (Base58)
|
|
138
|
+
* @param signature - Ed25519 signature over the order hash (hex, 128 chars)
|
|
139
|
+
* @returns Cancel response
|
|
140
|
+
* @throws {ApiError} If maker pubkey or signature is invalid
|
|
141
|
+
*/
|
|
142
|
+
cancelOrderWithSignature(orderHash: string, maker: string, signature: string): Promise<CancelResponse>;
|
|
143
|
+
/**
|
|
144
|
+
* Cancel an order, auto-signing with the given keypair.
|
|
145
|
+
*
|
|
146
|
+
* @param orderHash - Hash of the order to cancel (hex)
|
|
147
|
+
* @param signer - Keypair to sign the cancellation
|
|
148
|
+
* @returns Cancel response
|
|
149
|
+
*/
|
|
150
|
+
cancelOrder(orderHash: string, signer: Keypair): Promise<CancelResponse>;
|
|
151
|
+
/**
|
|
152
|
+
* Cancel all orders for a user with a pre-computed signature.
|
|
153
|
+
*
|
|
154
|
+
* @param userPubkey - User's public key (Base58)
|
|
155
|
+
* @param signature - Ed25519 signature over "cancel_all:{pubkey}:{timestamp}" (hex, 128 chars)
|
|
156
|
+
* @param timestamp - Unix timestamp used in the signed message
|
|
157
|
+
* @param orderbookId - Optional orderbook filter
|
|
158
|
+
* @returns Cancel all response
|
|
159
|
+
* @throws {ApiError} If any pubkey or signature is invalid
|
|
160
|
+
*/
|
|
161
|
+
cancelAllOrdersWithSignature(userPubkey: string, signature: string, timestamp: number, orderbookId?: string): Promise<CancelAllResponse>;
|
|
162
|
+
/**
|
|
163
|
+
* Cancel all orders for a user, auto-signing with the given keypair.
|
|
164
|
+
*
|
|
165
|
+
* @param signer - Keypair to sign the cancellation
|
|
166
|
+
* @param orderbookId - Optional orderbook filter
|
|
167
|
+
* @returns Cancel all response
|
|
168
|
+
*/
|
|
169
|
+
cancelAllOrders(signer: Keypair, orderbookId?: string): Promise<CancelAllResponse>;
|
|
170
|
+
/**
|
|
171
|
+
* Get user positions across all markets.
|
|
172
|
+
*
|
|
173
|
+
* @param userPubkey - User's public key (Base58)
|
|
174
|
+
* @returns User positions
|
|
175
|
+
* @throws {ApiError} If userPubkey is invalid
|
|
176
|
+
*/
|
|
177
|
+
getUserPositions(userPubkey: string): Promise<PositionsResponse>;
|
|
178
|
+
/**
|
|
179
|
+
* Get user positions in a specific market.
|
|
180
|
+
*
|
|
181
|
+
* @param userPubkey - User's public key (Base58)
|
|
182
|
+
* @param marketPubkey - Market PDA address (Base58)
|
|
183
|
+
* @returns Market positions
|
|
184
|
+
* @throws {ApiError} If any pubkey is invalid
|
|
185
|
+
*/
|
|
186
|
+
getUserMarketPositions(userPubkey: string, marketPubkey: string): Promise<MarketPositionsResponse>;
|
|
187
|
+
/**
|
|
188
|
+
* Get user's open orders.
|
|
189
|
+
*
|
|
190
|
+
* @param userPubkey - User's public key (Base58)
|
|
191
|
+
* @returns User orders and balances
|
|
192
|
+
* @throws {ApiError} If userPubkey is invalid
|
|
193
|
+
*/
|
|
194
|
+
getUserOrders(userPubkey: string): Promise<UserOrdersResponse>;
|
|
195
|
+
/**
|
|
196
|
+
* Get historical price data.
|
|
197
|
+
*
|
|
198
|
+
* @param params - Query parameters
|
|
199
|
+
* @returns Price history data
|
|
200
|
+
* @throws {ApiError} If limit is out of bounds (1-500)
|
|
201
|
+
*/
|
|
202
|
+
getPriceHistory(params: PriceHistoryParams): Promise<PriceHistoryResponse>;
|
|
203
|
+
/**
|
|
204
|
+
* Get recent trades.
|
|
205
|
+
*
|
|
206
|
+
* @param params - Query parameters
|
|
207
|
+
* @returns Trade history
|
|
208
|
+
* @throws {ApiError} If limit is out of bounds (1-500)
|
|
209
|
+
*/
|
|
210
|
+
getTrades(params: TradesParams): Promise<TradesResponse>;
|
|
211
|
+
/**
|
|
212
|
+
* Admin health check.
|
|
213
|
+
*
|
|
214
|
+
* @returns Admin status
|
|
215
|
+
*/
|
|
216
|
+
adminHealthCheck(): Promise<AdminResponse>;
|
|
217
|
+
/**
|
|
218
|
+
* Create a new orderbook (admin only).
|
|
219
|
+
*
|
|
220
|
+
* @param request - Orderbook creation request
|
|
221
|
+
* @returns Created orderbook info
|
|
222
|
+
*/
|
|
223
|
+
createOrderbook(request: CreateOrderbookRequest): Promise<CreateOrderbookResponse>;
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAS1C,OAAO,EAAgB,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EAEb,cAAc,EAEd,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAkBjB,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,UAAU,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,yDAAyD;IACzD,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,6CAA6C;AAC7C,eAAO,MAAM,oBAA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