@cedros/trade-react 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.
@@ -0,0 +1,600 @@
1
+ import { default as default_2 } from 'react';
2
+ import { JSX as JSX_2 } from 'react/jsx-runtime';
3
+
4
+ export declare function ActionNotificationBadge({ walletAddress, onClick, className }: ActionNotificationBadgeProps): JSX_2.Element | null;
5
+
6
+ export declare interface ActionNotificationBadgeProps {
7
+ walletAddress?: string;
8
+ onClick?: () => void;
9
+ className?: string;
10
+ }
11
+
12
+ export declare function ActionQueue({ walletAddress, onSign, className }: ActionQueueProps): JSX_2.Element | null;
13
+
14
+ export declare interface ActionQueueProps {
15
+ walletAddress?: string;
16
+ onSign?: (transaction: string) => Promise<string>;
17
+ className?: string;
18
+ }
19
+
20
+ export declare interface CedrosTradeConfig {
21
+ /** Base URL of the cedros-trade server (e.g. "/api/trade" or "https://trade.example.com") */
22
+ serverUrl: string;
23
+ /** Function to get the auth token (from cedros-login or custom auth) */
24
+ getAccessToken?: () => string | null;
25
+ /** Optional API key for rate-limited access */
26
+ apiKey?: string;
27
+ /** Default slippage in bps */
28
+ defaultSlippageBps?: number;
29
+ /** Chart type: 'tradingview' | 'lightweight' */
30
+ chartType?: 'tradingview' | 'lightweight';
31
+ }
32
+
33
+ export declare function CedrosTradeProvider({ config, children }: CedrosTradeProviderProps): JSX_2.Element;
34
+
35
+ export declare interface CedrosTradeProviderProps {
36
+ config: CedrosTradeConfig;
37
+ children: default_2.ReactNode;
38
+ }
39
+
40
+ export declare function ChartContainer({ chartType, symbol, theme, chartData, className }: ChartContainerProps): JSX_2.Element;
41
+
42
+ export declare interface ChartContainerProps {
43
+ chartType: 'tradingview' | 'lightweight';
44
+ symbol: string;
45
+ theme?: 'light' | 'dark';
46
+ chartData?: {
47
+ time: string;
48
+ open: number;
49
+ high: number;
50
+ low: number;
51
+ close: number;
52
+ }[];
53
+ className?: string;
54
+ }
55
+
56
+ export declare interface DcaOrder {
57
+ dcaAccountId: string;
58
+ inputMint: string;
59
+ outputMint: string;
60
+ totalInAmount: string;
61
+ perCycleAmount: string;
62
+ cycleInterval: number;
63
+ completedCycles: number;
64
+ totalCycles: number;
65
+ totalOutReceived: string;
66
+ status: string;
67
+ nextCycleAt?: string;
68
+ }
69
+
70
+ export declare function ErrorMessage({ message, className, onDismiss }: ErrorMessageProps): JSX_2.Element | null;
71
+
72
+ export declare interface ErrorMessageProps {
73
+ message: string | null;
74
+ className?: string;
75
+ onDismiss?: () => void;
76
+ }
77
+
78
+ export declare interface ExecuteResult {
79
+ signature: string;
80
+ status: 'confirmed' | 'submitted' | 'failed';
81
+ }
82
+
83
+ export declare interface Holding {
84
+ mint: string;
85
+ symbol?: string;
86
+ balance: string;
87
+ decimals: number;
88
+ uiBalance: string;
89
+ currentPrice?: string;
90
+ currentValue?: string;
91
+ }
92
+
93
+ export declare function LightweightChart({ data, theme, className }: LightweightChartProps): JSX_2.Element;
94
+
95
+ export declare interface LightweightChartProps {
96
+ data?: {
97
+ time: string;
98
+ open: number;
99
+ high: number;
100
+ low: number;
101
+ close: number;
102
+ }[];
103
+ theme?: 'light' | 'dark';
104
+ className?: string;
105
+ }
106
+
107
+ export declare function LoadingSpinner({ className }: {
108
+ className?: string;
109
+ }): JSX_2.Element;
110
+
111
+ export declare interface OpenOrder {
112
+ orderId: string;
113
+ inputMint: string;
114
+ outputMint: string;
115
+ inAmount: string;
116
+ outAmount: string;
117
+ filled: string;
118
+ status: string;
119
+ orderType: 'limit' | 'stop-loss' | 'take-profit';
120
+ triggerPrice?: string;
121
+ createdAt?: string;
122
+ expiry?: string;
123
+ }
124
+
125
+ export declare function OpenOrdersTable({ limitOrders, dcaOrders, isLoading, onCancel, className }: OpenOrdersTableProps): JSX_2.Element;
126
+
127
+ export declare interface OpenOrdersTableProps {
128
+ limitOrders: OpenOrder[];
129
+ dcaOrders: DcaOrder[];
130
+ isLoading: boolean;
131
+ onCancel?: (orderId: string) => void;
132
+ className?: string;
133
+ }
134
+
135
+ export declare function OrderForm({ walletAddress, inputMint, outputMint, inputSymbol, outputSymbol, currentPrice, onSign, onSuccess, className, }: OrderFormProps): JSX_2.Element;
136
+
137
+ export declare interface OrderFormProps {
138
+ walletAddress?: string;
139
+ inputMint: string;
140
+ outputMint: string;
141
+ inputSymbol?: string;
142
+ outputSymbol?: string;
143
+ currentPrice?: number;
144
+ onSign?: (transaction: string) => Promise<string>;
145
+ onSuccess?: (orderId: string) => void;
146
+ className?: string;
147
+ }
148
+
149
+ export declare interface PendingAction {
150
+ id: string;
151
+ walletAddress: string;
152
+ orderId: string;
153
+ actionType: string;
154
+ transaction: string;
155
+ reason: string;
156
+ status: string;
157
+ createdAt: string;
158
+ expiresAt: string;
159
+ txSignature?: string;
160
+ }
161
+
162
+ export declare function PortfolioPage({ walletAddress, className }: PortfolioPageProps): JSX_2.Element;
163
+
164
+ export declare interface PortfolioPageProps {
165
+ walletAddress?: string;
166
+ className?: string;
167
+ }
168
+
169
+ export declare interface PositionsResponse {
170
+ holdings: Holding[];
171
+ openOrders: number;
172
+ totalValue: string;
173
+ }
174
+
175
+ export declare function PositionsTable({ holdings, isLoading, totalValue, className }: PositionsTableProps): JSX_2.Element;
176
+
177
+ export declare interface PositionsTableProps {
178
+ holdings: Holding[];
179
+ isLoading: boolean;
180
+ totalValue?: string;
181
+ className?: string;
182
+ }
183
+
184
+ export declare interface PriceSnapshot {
185
+ mint: string;
186
+ priceUsd: number;
187
+ sources: {
188
+ name: string;
189
+ priceUsd: number;
190
+ stale: boolean;
191
+ }[];
192
+ degraded: boolean;
193
+ marketCap?: number;
194
+ volume24h?: number;
195
+ priceChange24hPct?: number;
196
+ }
197
+
198
+ export declare interface ProviderInfo {
199
+ name: string;
200
+ enabled: boolean;
201
+ capabilities: {
202
+ name: string;
203
+ gasless: boolean;
204
+ mevProtected: boolean;
205
+ supportsExactOut: boolean;
206
+ };
207
+ health: {
208
+ name: string;
209
+ healthy: boolean;
210
+ latencyMs?: number;
211
+ error?: string;
212
+ };
213
+ }
214
+
215
+ export declare function SlippageControl({ value, onChange, className }: SlippageControlProps): JSX_2.Element;
216
+
217
+ export declare interface SlippageControlProps {
218
+ value: number;
219
+ onChange: (bps: number) => void;
220
+ className?: string;
221
+ }
222
+
223
+ export declare function SwapForm({ walletAddress, onSign, onSuccess, onError, defaultInputMint, defaultOutputMint, className, }: SwapFormProps): JSX_2.Element;
224
+
225
+ export declare interface SwapFormProps {
226
+ /** User's wallet public key */
227
+ walletAddress?: string;
228
+ /** Called with the unsigned transaction for signing */
229
+ onSign?: (transaction: string, provider: string, requestId?: string) => Promise<string>;
230
+ /** Called after successful execution */
231
+ onSuccess?: (signature: string) => void;
232
+ onError?: (error: string) => void;
233
+ defaultInputMint?: string;
234
+ defaultOutputMint?: string;
235
+ className?: string;
236
+ }
237
+
238
+ export declare function SwapPage({ title, ...formProps }: SwapPageProps): JSX_2.Element;
239
+
240
+ export declare interface SwapPageProps extends SwapFormProps {
241
+ title?: string;
242
+ }
243
+
244
+ export declare interface SwapQuote {
245
+ provider: string;
246
+ inputMint: string;
247
+ outputMint: string;
248
+ inAmount: string;
249
+ outAmount: string;
250
+ otherAmountThreshold?: string;
251
+ priceImpactPct: number;
252
+ slippageBps: number;
253
+ routeData?: unknown;
254
+ gasless: boolean;
255
+ }
256
+
257
+ export declare interface SwapTransaction {
258
+ transaction: string;
259
+ gasless: boolean;
260
+ lastValidBlockHeight?: number;
261
+ requestId?: string;
262
+ }
263
+
264
+ export declare interface TokenRecord {
265
+ mint: string;
266
+ symbol: string;
267
+ name: string;
268
+ decimals: number;
269
+ logoUrl?: string;
270
+ coingeckoId?: string;
271
+ tradingviewSymbol?: string;
272
+ categories: string[];
273
+ }
274
+
275
+ export declare function TokenSelector({ isOpen, onClose, onSelect, excludeMints, className }: TokenSelectorProps): JSX_2.Element | null;
276
+
277
+ export declare interface TokenSelectorProps {
278
+ isOpen: boolean;
279
+ onClose: () => void;
280
+ onSelect: (token: TokenRecord) => void;
281
+ /** Mints to exclude from the list (e.g. the other side of the pair) */
282
+ excludeMints?: string[];
283
+ className?: string;
284
+ }
285
+
286
+ export declare class TradeApiClient {
287
+ private baseUrl;
288
+ private tokenFn?;
289
+ private apiKey?;
290
+ constructor(baseUrl: string, tokenFn?: (() => string | null) | undefined, apiKey?: string | undefined);
291
+ private request;
292
+ private get;
293
+ private post;
294
+ private del;
295
+ getTokens(category?: string): Promise<{
296
+ tokens: TokenRecord[];
297
+ count: number;
298
+ }>;
299
+ getToken(mint: string): Promise<TokenRecord>;
300
+ getQuote(params: {
301
+ inputMint: string;
302
+ outputMint: string;
303
+ amount: string;
304
+ slippageBps?: number;
305
+ provider?: string;
306
+ }): Promise<SwapQuote>;
307
+ buildSwap(quote: SwapQuote, userPublicKey: string): Promise<SwapTransaction>;
308
+ compareQuotes(inputMint: string, outputMint: string, amount: string): Promise<SwapQuote[]>;
309
+ executeSwap(signedTransaction: string, provider: string, requestId?: string): Promise<ExecuteResult>;
310
+ getProviders(): Promise<ProviderInfo[]>;
311
+ getPrice(mint: string): Promise<PriceSnapshot>;
312
+ getBatchPrices(mints: string[]): Promise<{
313
+ prices: PriceSnapshot[];
314
+ }>;
315
+ buildTransfer(params: {
316
+ sender: string;
317
+ recipient: string;
318
+ mint: string;
319
+ amount: string;
320
+ memo?: string;
321
+ }): Promise<TransferBuildResponse>;
322
+ executeTransfer(signedTransaction: string): Promise<ExecuteResult>;
323
+ resolveAddress(address: string): Promise<{
324
+ input: string;
325
+ resolved: string;
326
+ type: string;
327
+ }>;
328
+ createLimitOrder(params: {
329
+ maker: string;
330
+ inputMint: string;
331
+ outputMint: string;
332
+ inAmount: string;
333
+ outAmount: string;
334
+ expiry?: string;
335
+ }): Promise<{
336
+ transaction: string;
337
+ orderId: string;
338
+ }>;
339
+ createStopLoss(params: {
340
+ maker: string;
341
+ inputMint: string;
342
+ outputMint: string;
343
+ inAmount: string;
344
+ triggerPrice: string;
345
+ slippageBps?: number;
346
+ }): Promise<{
347
+ transaction: string;
348
+ orderId: string;
349
+ }>;
350
+ createTakeProfit(params: {
351
+ maker: string;
352
+ inputMint: string;
353
+ outputMint: string;
354
+ inAmount: string;
355
+ triggerPrice: string;
356
+ slippageBps?: number;
357
+ }): Promise<{
358
+ transaction: string;
359
+ orderId: string;
360
+ }>;
361
+ createDca(params: {
362
+ maker: string;
363
+ inputMint: string;
364
+ outputMint: string;
365
+ totalInAmount: string;
366
+ perCycleAmount: string;
367
+ cycleInterval: number;
368
+ }): Promise<{
369
+ transaction: string;
370
+ orderId: string;
371
+ }>;
372
+ cancelOrder(orderId: string, maker: string): Promise<{
373
+ transaction: string;
374
+ }>;
375
+ getOpenOrders(wallet: string): Promise<{
376
+ limitOrders: OpenOrder[];
377
+ dcaOrders: DcaOrder[];
378
+ }>;
379
+ getPositions(wallet: string): Promise<PositionsResponse>;
380
+ getPendingActions(wallet: string): Promise<PendingAction[]>;
381
+ completeAction(actionId: string, signedTransaction: string): Promise<{
382
+ actionId: string;
383
+ status: string;
384
+ signature: string;
385
+ }>;
386
+ dismissAction(actionId: string): Promise<{
387
+ actionId: string;
388
+ status: string;
389
+ }>;
390
+ getHealth(): Promise<{
391
+ status: string;
392
+ version: string;
393
+ }>;
394
+ }
395
+
396
+ export declare class TradeApiError extends Error {
397
+ status: number;
398
+ code: string;
399
+ constructor(status: number, code: string, message: string);
400
+ }
401
+
402
+ declare interface TradeContextValue {
403
+ api: TradeApiClient;
404
+ config: CedrosTradeConfig;
405
+ }
406
+
407
+ export declare function TradingPage({ walletAddress, inputMint, outputMint, inputSymbol, outputSymbol, tradingViewSymbol, chartType, manifestMarket, theme, onSign, onOrderSuccess, className, }: TradingPageProps): JSX_2.Element;
408
+
409
+ export declare interface TradingPageProps {
410
+ walletAddress?: string;
411
+ inputMint?: string;
412
+ outputMint?: string;
413
+ inputSymbol?: string;
414
+ outputSymbol?: string;
415
+ tradingViewSymbol?: string;
416
+ chartType?: 'tradingview' | 'lightweight';
417
+ /** Manifest market address for orderbook (optional — hides orderbook if not set) */
418
+ manifestMarket?: string;
419
+ theme?: 'light' | 'dark';
420
+ onSign?: (transaction: string) => Promise<string>;
421
+ onOrderSuccess?: (orderId: string) => void;
422
+ className?: string;
423
+ }
424
+
425
+ export declare function TradingViewChart({ symbol, interval, theme, className, }: TradingViewChartProps): JSX_2.Element;
426
+
427
+ export declare interface TradingViewChartProps {
428
+ symbol: string;
429
+ interval?: string;
430
+ theme?: 'light' | 'dark';
431
+ className?: string;
432
+ }
433
+
434
+ export declare interface TransferBuildResponse {
435
+ transaction: string;
436
+ recipientResolved: string;
437
+ recipientType: 'address' | 'domain';
438
+ lastValidBlockHeight: number;
439
+ createsAta: boolean;
440
+ }
441
+
442
+ export declare function TransferForm({ walletAddress, onSign, onSuccess, onError, className }: TransferFormProps): JSX_2.Element;
443
+
444
+ export declare interface TransferFormProps {
445
+ walletAddress?: string;
446
+ onSign?: (transaction: string) => Promise<string>;
447
+ onSuccess?: (signature: string) => void;
448
+ onError?: (error: string) => void;
449
+ className?: string;
450
+ }
451
+
452
+ export declare function TransferPage(props: TransferPageProps): JSX_2.Element;
453
+
454
+ export declare interface TransferPageProps extends TransferFormProps {
455
+ }
456
+
457
+ export declare function useActionQueue(walletAddress: string | null): UseActionQueueReturn;
458
+
459
+ export declare interface UseActionQueueReturn {
460
+ actions: PendingAction[];
461
+ count: number;
462
+ isLoading: boolean;
463
+ error: string | null;
464
+ refresh: () => Promise<void>;
465
+ complete: (actionId: string, signedTransaction: string) => Promise<void>;
466
+ dismiss: (actionId: string) => Promise<void>;
467
+ }
468
+
469
+ export declare function useLimitOrder(): UseLimitOrderReturn;
470
+
471
+ export declare interface UseLimitOrderReturn {
472
+ isLoading: boolean;
473
+ error: string | null;
474
+ createLimit: (params: {
475
+ maker: string;
476
+ inputMint: string;
477
+ outputMint: string;
478
+ inAmount: string;
479
+ outAmount: string;
480
+ expiry?: string;
481
+ }) => Promise<{
482
+ transaction: string;
483
+ orderId: string;
484
+ }>;
485
+ createStopLoss: (params: {
486
+ maker: string;
487
+ inputMint: string;
488
+ outputMint: string;
489
+ inAmount: string;
490
+ triggerPrice: string;
491
+ slippageBps?: number;
492
+ }) => Promise<{
493
+ transaction: string;
494
+ orderId: string;
495
+ }>;
496
+ createTakeProfit: (params: {
497
+ maker: string;
498
+ inputMint: string;
499
+ outputMint: string;
500
+ inAmount: string;
501
+ triggerPrice: string;
502
+ slippageBps?: number;
503
+ }) => Promise<{
504
+ transaction: string;
505
+ orderId: string;
506
+ }>;
507
+ createDca: (params: {
508
+ maker: string;
509
+ inputMint: string;
510
+ outputMint: string;
511
+ totalInAmount: string;
512
+ perCycleAmount: string;
513
+ cycleInterval: number;
514
+ }) => Promise<{
515
+ transaction: string;
516
+ orderId: string;
517
+ }>;
518
+ }
519
+
520
+ export declare function useOpenOrders(walletAddress: string | null): UseOpenOrdersReturn;
521
+
522
+ export declare interface UseOpenOrdersReturn {
523
+ limitOrders: OpenOrder[];
524
+ dcaOrders: DcaOrder[];
525
+ isLoading: boolean;
526
+ error: string | null;
527
+ refresh: () => Promise<void>;
528
+ cancelOrder: (orderId: string, maker: string) => Promise<{
529
+ transaction: string;
530
+ }>;
531
+ }
532
+
533
+ export declare function usePositions(walletAddress: string | null): UsePositionsReturn;
534
+
535
+ export declare interface UsePositionsReturn {
536
+ positions: PositionsResponse | null;
537
+ isLoading: boolean;
538
+ error: string | null;
539
+ refresh: () => Promise<void>;
540
+ }
541
+
542
+ export declare function usePrices(): UsePricesReturn;
543
+
544
+ export declare interface UsePricesReturn {
545
+ prices: Record<string, PriceSnapshot>;
546
+ isLoading: boolean;
547
+ error: string | null;
548
+ getPrice: (mint: string) => Promise<PriceSnapshot>;
549
+ subscribe: (mints: string[]) => void;
550
+ unsubscribe: (mints: string[]) => void;
551
+ }
552
+
553
+ export declare function useSwap(): UseSwapReturn;
554
+
555
+ export declare interface UseSwapReturn {
556
+ quote: SwapQuote | null;
557
+ transaction: SwapTransaction | null;
558
+ result: ExecuteResult | null;
559
+ isLoading: boolean;
560
+ error: string | null;
561
+ getQuote: (inputMint: string, outputMint: string, amount: string, slippageBps?: number) => Promise<SwapQuote>;
562
+ buildTransaction: (quote: SwapQuote, userPublicKey: string) => Promise<SwapTransaction>;
563
+ execute: (signedTransaction: string, provider: string, requestId?: string) => Promise<ExecuteResult>;
564
+ compareProviders: (inputMint: string, outputMint: string, amount: string) => Promise<SwapQuote[]>;
565
+ reset: () => void;
566
+ }
567
+
568
+ export declare function useTokens(): UseTokensReturn;
569
+
570
+ export declare interface UseTokensReturn {
571
+ tokens: TokenRecord[];
572
+ isLoading: boolean;
573
+ error: string | null;
574
+ refresh: () => Promise<void>;
575
+ getByMint: (mint: string) => TokenRecord | undefined;
576
+ getBySymbol: (symbol: string) => TokenRecord | undefined;
577
+ }
578
+
579
+ export declare function useTradeApi(): TradeApiClient;
580
+
581
+ export declare function useTradeContext(): TradeContextValue;
582
+
583
+ export declare function useTransfer(): UseTransferReturn;
584
+
585
+ export declare interface UseTransferReturn {
586
+ buildResult: TransferBuildResponse | null;
587
+ executeResult: ExecuteResult | null;
588
+ isLoading: boolean;
589
+ error: string | null;
590
+ build: (sender: string, recipient: string, mint: string, amount: string, memo?: string) => Promise<TransferBuildResponse>;
591
+ execute: (signedTransaction: string) => Promise<ExecuteResult>;
592
+ resolveAddress: (address: string) => Promise<{
593
+ input: string;
594
+ resolved: string;
595
+ type: string;
596
+ }>;
597
+ reset: () => void;
598
+ }
599
+
600
+ export { }