@autonomaai/mcp-client 1.0.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/src/types.ts ADDED
@@ -0,0 +1,972 @@
1
+ /**
2
+ * Unified MCP Client Types for autonoma Trading System
3
+ *
4
+ * This file contains all the type definitions for the MCP client library,
5
+ * extracted and consolidated from the original implementation.
6
+ */
7
+
8
+ // =============================================================================
9
+ // Common Types
10
+ // =============================================================================
11
+
12
+ export interface ErrorResponse {
13
+ error: string;
14
+ detail?: string;
15
+ }
16
+
17
+ export interface ConfigurationObject {
18
+ [key: string]: string | number | boolean | ConfigurationObject;
19
+ }
20
+
21
+ export interface PositionData {
22
+ symbol: string;
23
+ size: number;
24
+ side: 'long' | 'short';
25
+ entry_price: number;
26
+ unrealized_pnl: number;
27
+ [key: string]: string | number;
28
+ }
29
+
30
+ // =============================================================================
31
+ // Health and Context Types
32
+ // =============================================================================
33
+
34
+ export interface HummingbotHealthResponse {
35
+ status: string;
36
+ version: string;
37
+ system: string;
38
+ services: {
39
+ mcp_server: string;
40
+ backend_api: string;
41
+ command_delivery: string;
42
+ controller_architecture: string;
43
+ configuration_management: string;
44
+ live_trading: string;
45
+ hyperliquid_integration: string;
46
+ };
47
+ capabilities: {
48
+ ai_agent_interface: boolean;
49
+ real_exchange_connectivity: boolean;
50
+ controller_based_pools: boolean;
51
+ database_driven_config: boolean;
52
+ hot_reload: boolean;
53
+ live_hyperliquid_trading: boolean;
54
+ multi_strategy_support: boolean;
55
+ batch_operations: boolean;
56
+ real_time_analytics: boolean;
57
+ };
58
+ ai_features: {
59
+ automated_trading: boolean;
60
+ performance_analytics: boolean;
61
+ risk_assessment: boolean;
62
+ optimization_suggestions: boolean;
63
+ market_intelligence: boolean;
64
+ predictive_insights: boolean;
65
+ };
66
+ trading_capabilities: {
67
+ supported_exchanges: string[];
68
+ supported_strategies: string[];
69
+ live_execution: boolean;
70
+ real_time_data: boolean;
71
+ position_management: boolean;
72
+ risk_controls: boolean;
73
+ };
74
+ architecture: {
75
+ type: string;
76
+ deployment_model: string;
77
+ ai_interface: string;
78
+ backend_integration: string;
79
+ scalability: string;
80
+ };
81
+ timestamp: string;
82
+ }
83
+
84
+ export interface StrategyInfo {
85
+ name: string;
86
+ description: string;
87
+ parameters: Record<string, string>;
88
+ supported_exchanges: string[];
89
+ risk_management: Record<string, string>;
90
+ performance_features: string[];
91
+ }
92
+
93
+ export interface ExchangeProfile {
94
+ name: string;
95
+ type: string;
96
+ mode: string;
97
+ supported_pairs: string[];
98
+ features: string[];
99
+ trading_fees: {
100
+ maker: number;
101
+ taker: number;
102
+ };
103
+ api_rate_limits: Record<string, number>;
104
+ connection_method: string;
105
+ }
106
+
107
+ export interface PerformanceCapabilities {
108
+ max_concurrent_strategies: number;
109
+ supported_order_types: string[];
110
+ max_positions: number;
111
+ risk_management_features: string[];
112
+ performance_metrics: string[];
113
+ [key: string]: string | number | string[];
114
+ }
115
+
116
+ export interface OperationalFeatures {
117
+ hot_reload: boolean;
118
+ real_time_monitoring: boolean;
119
+ automated_risk_management: boolean;
120
+ multi_exchange_support: boolean;
121
+ strategy_optimization: boolean;
122
+ [key: string]: boolean | string | number;
123
+ }
124
+
125
+ export interface HummingbotContext {
126
+ name: string;
127
+ version: string;
128
+ description: string;
129
+ endpoints: string[];
130
+ strategies_supported: StrategyInfo[];
131
+ exchange_profiles: ExchangeProfile[];
132
+ features: string[];
133
+ status: string;
134
+ uptime: number;
135
+ timestamp: string;
136
+ system_architecture: Record<string, string>;
137
+ performance_capabilities: PerformanceCapabilities;
138
+ operational_features: OperationalFeatures;
139
+ }
140
+
141
+ // =============================================================================
142
+ // Controller Types
143
+ // =============================================================================
144
+
145
+ export interface CreateControllerRequest {
146
+ name: string;
147
+ strategy: string;
148
+ trading_pair: string;
149
+ config: ConfigurationObject;
150
+ }
151
+
152
+ export interface ControllerResponse {
153
+ id: string;
154
+ name: string;
155
+ strategy: string;
156
+ trading_pair: string;
157
+ status: string;
158
+ config: ConfigurationObject;
159
+ created_at: string;
160
+ updated_at: string;
161
+ pool_id?: string;
162
+ }
163
+
164
+ export interface ControllerMetrics {
165
+ id: string;
166
+ performance: {
167
+ total_pnl: number;
168
+ win_rate: number;
169
+ total_trades: number;
170
+ current_positions: Record<string, PositionData>;
171
+ };
172
+ status: {
173
+ is_running: boolean;
174
+ last_update: string;
175
+ health_score: number;
176
+ };
177
+ trading_stats: {
178
+ volume_24h: number;
179
+ fees_paid: number;
180
+ active_orders: number;
181
+ };
182
+ }
183
+
184
+ // =============================================================================
185
+ // Trading Types
186
+ // =============================================================================
187
+
188
+ export interface ExchangeListResponse {
189
+ supported_exchanges: string[];
190
+ count: number;
191
+ ai_capabilities?: {
192
+ live_trading: boolean;
193
+ real_time_data: boolean;
194
+ multi_strategy: boolean;
195
+ automated_execution: boolean;
196
+ };
197
+ hyperliquid_features?: {
198
+ perpetual_trading: boolean;
199
+ spot_trading: boolean;
200
+ low_fees: boolean;
201
+ fast_execution: boolean;
202
+ vault_integration: boolean;
203
+ };
204
+ }
205
+
206
+ export interface ConnectExchangeRequest {
207
+ exchange: string;
208
+ trading_pair: string;
209
+ credentials: {
210
+ wallet_address?: string;
211
+ private_key?: string;
212
+ api_key?: string;
213
+ api_secret?: string;
214
+ };
215
+ }
216
+
217
+ export interface TradingConnectionResponse {
218
+ controller_id: string;
219
+ exchange: string;
220
+ trading_pair: string;
221
+ status: string;
222
+ connected_at: string;
223
+ account_balance?: Record<string, number>;
224
+ }
225
+
226
+ export interface MarketDataResponse {
227
+ symbol: string;
228
+ price: number;
229
+ bid: number;
230
+ ask: number;
231
+ volume_24h: number;
232
+ change_24h: number;
233
+ timestamp: string;
234
+ exchange: string;
235
+ }
236
+
237
+ export interface ExecuteSignalRequest {
238
+ controller_id: string;
239
+ signal: {
240
+ type: string;
241
+ side: string;
242
+ amount: number;
243
+ price?: number;
244
+ order_type: string;
245
+ };
246
+ }
247
+
248
+ export interface SignalExecutionResponse {
249
+ success: boolean;
250
+ order_id?: string;
251
+ message: string;
252
+ timestamp: string;
253
+ }
254
+
255
+ // =============================================================================
256
+ // Bot Types (Legacy)
257
+ // =============================================================================
258
+
259
+ export interface CreateBotRequest {
260
+ name: string;
261
+ strategy: string;
262
+ trading_pair: string;
263
+ config: ConfigurationObject;
264
+ }
265
+
266
+ export interface BotResponse {
267
+ id: string;
268
+ name: string;
269
+ strategy: string;
270
+ trading_pair: string;
271
+ status: string;
272
+ config: ConfigurationObject;
273
+ created_at: string;
274
+ }
275
+
276
+ // =============================================================================
277
+ // Pool Types
278
+ // =============================================================================
279
+
280
+ export interface PoolResponse {
281
+ id: string;
282
+ name: string;
283
+ max_controllers: number;
284
+ current_controllers: number;
285
+ status: string;
286
+ created_at: string;
287
+ }
288
+
289
+ export interface CreatePoolRequest {
290
+ name?: string;
291
+ max_controllers?: number;
292
+ }
293
+
294
+ // =============================================================================
295
+ // Hyperliquid Market Data Types (Legacy)
296
+ // =============================================================================
297
+
298
+ export interface HyperliquidOrderbook {
299
+ bids: Array<[string, string]>;
300
+ asks: Array<[string, string]>;
301
+ timestamp: number;
302
+ symbol: string;
303
+ }
304
+
305
+ export interface HyperliquidSummary {
306
+ symbol: string;
307
+ price: number;
308
+ volume_24h: number;
309
+ change_24h: number;
310
+ high_24h: number;
311
+ low_24h: number;
312
+ timestamp: number;
313
+ }
314
+
315
+ // =============================================================================
316
+ // MCP Tools Types (Standardized Interface)
317
+ // =============================================================================
318
+
319
+ export interface MCPRequest {
320
+ jsonrpc: string;
321
+ id: string | number;
322
+ method: string;
323
+ params?: any;
324
+ }
325
+
326
+ export interface MCPResponse {
327
+ jsonrpc: string;
328
+ id: string | number;
329
+ result?: any;
330
+ error?: {
331
+ code: number;
332
+ message: string;
333
+ data?: any;
334
+ };
335
+ }
336
+
337
+ export interface MCPTool {
338
+ name: string;
339
+ title: string;
340
+ description: string;
341
+ inputSchema?: {
342
+ type: string;
343
+ properties: any;
344
+ required?: string[];
345
+ };
346
+ }
347
+
348
+ export interface MCPToolsListResponse {
349
+ tools: MCPTool[];
350
+ }
351
+
352
+ export interface MCPToolCallRequest {
353
+ name: string;
354
+ arguments?: Record<string, any>;
355
+ }
356
+
357
+ export interface MCPToolCallResponse {
358
+ content: Array<{
359
+ type: string;
360
+ text: string;
361
+ }>;
362
+ meta?: any;
363
+ isError?: boolean;
364
+ }
365
+
366
+ // =============================================================================
367
+ // Dexscreener MCP Types
368
+ // =============================================================================
369
+
370
+ export interface DexscreenerTokenData {
371
+ name: string;
372
+ symbol: string;
373
+ priceUsd: number;
374
+ liquidityUsd: number;
375
+ volumeH1: number;
376
+ priceChangeH1: number;
377
+ pairAddress: string;
378
+ pairUrl: string;
379
+ }
380
+
381
+ export interface DexscreenerMarketAnalysis {
382
+ tokens: DexscreenerTokenData[];
383
+ marketSummary: {
384
+ totalLiquidity: number;
385
+ totalVolume: number;
386
+ avgPriceChange: number;
387
+ peakLiquidity: number;
388
+ peakVolume: number;
389
+ peakChange: number;
390
+ };
391
+ riskAssessment: {
392
+ moonshots: number;
393
+ stableGainers: number;
394
+ highVolume: number;
395
+ qualityTokens: number;
396
+ };
397
+ }
398
+
399
+ // =============================================================================
400
+ // Data Collector MCP Types
401
+ // =============================================================================
402
+
403
+ export interface TokenPriceData {
404
+ token: string;
405
+ chain: string;
406
+ price?: number;
407
+ bid?: number;
408
+ ask?: number;
409
+ volume_24h?: number;
410
+ change_24h?: number;
411
+ timestamp?: string;
412
+ }
413
+
414
+ export interface TokenVolumeData {
415
+ token: string;
416
+ chain: string;
417
+ interval: string;
418
+ volume?: number;
419
+ tokenFormat?: string;
420
+ source?: string;
421
+ }
422
+
423
+ export interface OrderbookData {
424
+ base: string;
425
+ quote: string;
426
+ chain: string;
427
+ midPrice?: number;
428
+ spread?: number;
429
+ bids?: Array<{ price: number; size: number }>;
430
+ asks?: Array<{ price: number; size: number }>;
431
+ }
432
+
433
+ export interface EnhancedOHLCVData {
434
+ token: string;
435
+ chain: string;
436
+ interval: string;
437
+ candles: Array<{
438
+ timestamp: number;
439
+ open: number;
440
+ high: number;
441
+ low: number;
442
+ close: number;
443
+ volume: number;
444
+ }>;
445
+ source?: string;
446
+ meta?: {
447
+ construction_method?: string;
448
+ tick_data_points?: number;
449
+ total_candles?: number;
450
+ };
451
+ }
452
+
453
+ export interface TokenDiscoveryData {
454
+ chain: string;
455
+ type: string;
456
+ tokens: Array<{
457
+ symbol: string;
458
+ name?: string;
459
+ volume?: number;
460
+ marketCap?: number;
461
+ }>;
462
+ sortBy: string;
463
+ sortOrder: string;
464
+ }
465
+
466
+ export interface TradingIntensityData {
467
+ token: string;
468
+ chain: string;
469
+ interval: string;
470
+ tokenFormat: string;
471
+ metrics: {
472
+ tradesPerMinute?: number;
473
+ volumePerMinute?: number;
474
+ activityScore?: number;
475
+ };
476
+ marketState?: string;
477
+ }
478
+
479
+ export interface SymbolResolutionData {
480
+ symbol: string;
481
+ chain: string;
482
+ resolved: boolean;
483
+ metadata?: {
484
+ symbol?: string;
485
+ type?: string;
486
+ pair?: string;
487
+ assetId?: number;
488
+ verified?: boolean;
489
+ };
490
+ }
491
+
492
+ export interface PerformanceMetricsData {
493
+ chain: string;
494
+ endpoint: string;
495
+ metrics: Array<{
496
+ endpoint: string;
497
+ average_ms?: number;
498
+ latency_ms?: number;
499
+ status?: string;
500
+ }>;
501
+ }
502
+
503
+ // =============================================================================
504
+ // Client Configuration Types
505
+ // =============================================================================
506
+
507
+ export interface MCPClientConfig {
508
+ baseUrl: string;
509
+ timeout?: number;
510
+ retries?: number;
511
+ retryDelay?: number;
512
+ enableLogging?: boolean;
513
+ apiKey?: string;
514
+ headers?: Record<string, string>;
515
+ }
516
+
517
+ export interface MCPClientOptions {
518
+ timeout?: number;
519
+ retries?: number;
520
+ retryDelay?: number;
521
+ headers?: Record<string, string>;
522
+ }
523
+
524
+ // =============================================================================
525
+ // WebSocket Types (for future real-time features)
526
+ // =============================================================================
527
+
528
+ export interface WebSocketMessage {
529
+ type: string;
530
+ data: any;
531
+ timestamp: string;
532
+ }
533
+
534
+ export interface WebSocketConfig {
535
+ url: string;
536
+ reconnect?: boolean;
537
+ reconnectDelay?: number;
538
+ maxReconnectAttempts?: number;
539
+ }
540
+
541
+ // =============================================================================
542
+ // APY Strategy MCP Types (DeFi Yield Optimization)
543
+ // =============================================================================
544
+
545
+ export interface YieldOpportunity {
546
+ protocol: string;
547
+ pool: string;
548
+ apy: number;
549
+ tvl: number;
550
+ risk_score: number;
551
+ chain: string;
552
+ asset: string;
553
+ lockup_period?: number;
554
+ minimum_deposit?: number;
555
+ confidence_score: number;
556
+ last_updated: string;
557
+ }
558
+
559
+ export interface YieldSearchParams {
560
+ asset?: string;
561
+ chain?: string[];
562
+ min_apy?: number;
563
+ max_risk?: number;
564
+ min_tvl?: number;
565
+ protocols?: string[];
566
+ limit?: number;
567
+ }
568
+
569
+ export interface AllocationOptimization {
570
+ strategy: 'max_sharpe' | 'risk_parity' | 'mean_variance';
571
+ allocations: Record<string, number>;
572
+ expected_return: number;
573
+ expected_risk: number;
574
+ sharpe_ratio: number;
575
+ constraints: AllocationConstraints;
576
+ rebalancing_threshold: number;
577
+ }
578
+
579
+ export interface AllocationConstraints {
580
+ max_protocol_allocation: number;
581
+ max_single_asset: number;
582
+ min_liquidity: number;
583
+ max_risk_score: number;
584
+ required_chains?: string[];
585
+ }
586
+
587
+ export interface ArbitrageOpportunity {
588
+ protocol_a: string;
589
+ protocol_b: string;
590
+ asset: string;
591
+ apy_difference: number;
592
+ potential_profit: number;
593
+ execution_cost: number;
594
+ net_profit: number;
595
+ risk_assessment: string;
596
+ time_sensitivity: 'low' | 'medium' | 'high';
597
+ }
598
+
599
+ export interface BacktestResult {
600
+ strategy_name: string;
601
+ period: string;
602
+ total_return: number;
603
+ annualized_return: number;
604
+ volatility: number;
605
+ sharpe_ratio: number;
606
+ max_drawdown: number;
607
+ win_rate: number;
608
+ trade_count: number;
609
+ transaction_costs: number;
610
+ }
611
+
612
+ export interface PortfolioRiskAssessment {
613
+ var_95: number;
614
+ var_99: number;
615
+ expected_shortfall: number;
616
+ portfolio_volatility: number;
617
+ correlation_risk: number;
618
+ concentration_risk: number;
619
+ liquidity_risk: number;
620
+ overall_risk_score: number;
621
+ recommendations: string[];
622
+ }
623
+
624
+ export interface ProtocolRiskAssessment {
625
+ protocol: string;
626
+ overall_risk_score: number;
627
+ smart_contract_risk: number;
628
+ liquidity_risk: number;
629
+ governance_risk: number;
630
+ audit_score: number;
631
+ tvl_stability: number;
632
+ track_record: number;
633
+ risk_factors: string[];
634
+ recommendation: 'low_risk' | 'medium_risk' | 'high_risk' | 'avoid';
635
+ }
636
+
637
+ export interface RiskMetrics {
638
+ score: number; // 0-100 (0 = highest risk, 100 = lowest risk)
639
+ category: 'low' | 'medium' | 'high' | 'extreme';
640
+ factors: RiskFactor[];
641
+ var95: number; // Value at Risk (95% confidence)
642
+ var99: number; // Value at Risk (99% confidence)
643
+ sharpeRatio?: number;
644
+ maxDrawdown?: number;
645
+ volatility: number;
646
+ }
647
+
648
+ export interface RiskFactor {
649
+ type: 'smart_contract' | 'liquidity' | 'impermanent_loss' | 'protocol' | 'market' | 'regulatory';
650
+ severity: 'low' | 'medium' | 'high' | 'extreme';
651
+ impact: number; // 0-100
652
+ description: string;
653
+ mitigationSuggestion?: string;
654
+ }
655
+
656
+ export interface PerformanceAlert {
657
+ type: 'warning' | 'error' | 'info';
658
+ severity: 'low' | 'medium' | 'high';
659
+ message: string;
660
+ timestamp: string;
661
+ protocol?: string;
662
+ action_required?: boolean;
663
+ }
664
+
665
+ export interface PerformanceTracking {
666
+ portfolio_value: number;
667
+ total_yield_earned: number;
668
+ yield_rate: number;
669
+ position_breakdown: PositionData[];
670
+ attribution_analysis: AttributionData;
671
+ risk_metrics: RiskMetrics;
672
+ alerts: PerformanceAlert[];
673
+ }
674
+
675
+ export interface PositionData {
676
+ protocol: string;
677
+ pool: string;
678
+ amount_deposited: number;
679
+ current_value: number;
680
+ yield_earned: number;
681
+ apy: number;
682
+ risk_score: number;
683
+ allocation_percentage: number;
684
+ }
685
+
686
+ export interface AttributionData {
687
+ protocol_contribution: Record<string, number>;
688
+ asset_contribution: Record<string, number>;
689
+ chain_contribution: Record<string, number>;
690
+ strategy_alpha: number;
691
+ }
692
+
693
+ export interface APYHistoryData {
694
+ protocol: string;
695
+ pool: string;
696
+ historical_data: APYDataPoint[];
697
+ statistics: APYStatistics;
698
+ trend_analysis: TrendAnalysis;
699
+ volatility_metrics: VolatilityMetrics;
700
+ }
701
+
702
+ export interface APYDataPoint {
703
+ timestamp: string;
704
+ apy: number;
705
+ tvl: number;
706
+ volume_24h: number;
707
+ utilization_rate: number;
708
+ }
709
+
710
+ export interface APYStatistics {
711
+ mean_apy: number;
712
+ median_apy: number;
713
+ std_deviation: number;
714
+ min_apy: number;
715
+ max_apy: number;
716
+ percentile_25: number;
717
+ percentile_75: number;
718
+ }
719
+
720
+ export interface TrendAnalysis {
721
+ trend_direction: 'up' | 'down' | 'stable';
722
+ trend_strength: number;
723
+ momentum: number;
724
+ seasonality: Record<string, number>;
725
+ }
726
+
727
+ export interface VolatilityMetrics {
728
+ apy_volatility: number;
729
+ tvl_volatility: number;
730
+ stability_score: number;
731
+ risk_adjusted_return: number;
732
+ }
733
+
734
+ // =============================================================================
735
+ // APY Strategy Tool Parameters
736
+ // =============================================================================
737
+
738
+ export interface FindYieldOpportunitiesParams {
739
+ search_criteria: YieldSearchParams;
740
+ risk_tolerance: 'conservative' | 'moderate' | 'aggressive';
741
+ time_horizon: 'short' | 'medium' | 'long';
742
+ }
743
+
744
+ export interface OptimizeAllocationParams {
745
+ current_portfolio: PositionData[];
746
+ available_capital: number;
747
+ optimization_strategy: 'max_sharpe' | 'risk_parity' | 'mean_variance';
748
+ constraints: AllocationConstraints;
749
+ rebalancing_frequency: 'daily' | 'weekly' | 'monthly';
750
+ }
751
+
752
+ export interface AnalyzeArbitrageParams {
753
+ asset: string;
754
+ chains: string[];
755
+ protocols: string[];
756
+ min_profit_threshold: number;
757
+ max_execution_cost: number;
758
+ }
759
+
760
+ export interface BacktestStrategyParams {
761
+ strategy_config: {
762
+ name: string;
763
+ allocation_method: string;
764
+ rebalancing_frequency: string;
765
+ risk_limits: Record<string, number>;
766
+ };
767
+ start_date: string;
768
+ end_date: string;
769
+ initial_capital: number;
770
+ include_costs: boolean;
771
+ }
772
+
773
+ export interface CalculateRiskParams {
774
+ portfolio: PositionData[];
775
+ time_horizon: number;
776
+ confidence_level: number;
777
+ correlation_window: number;
778
+ }
779
+
780
+ export interface AssessProtocolRiskParams {
781
+ protocol: string;
782
+ include_governance: boolean;
783
+ include_smart_contract: boolean;
784
+ include_market: boolean;
785
+ }
786
+
787
+ export interface TrackPerformanceParams {
788
+ portfolio_id?: string;
789
+ time_range: '24h' | '7d' | '30d' | '90d' | '1y';
790
+ include_attribution: boolean;
791
+ benchmark?: string;
792
+ }
793
+
794
+ export interface GetAPYHistoryParams {
795
+ protocol: string;
796
+ pool?: string;
797
+ asset?: string;
798
+ time_range: '7d' | '30d' | '90d' | '180d' | '1y';
799
+ granularity: 'hourly' | 'daily' | 'weekly';
800
+ }
801
+
802
+ // =============================================================================
803
+ // APY Strategy MCP Tools Types
804
+ // =============================================================================
805
+
806
+ export interface GetApyHistoryRequest {
807
+ protocol: string;
808
+ chain: string;
809
+ pool?: string;
810
+ timeframe?: '7d' | '30d' | '90d' | '180d' | '1y';
811
+ includeRiskMetrics?: boolean;
812
+ includeStatistics?: boolean;
813
+ minTvl?: number;
814
+ maxRiskScore?: number;
815
+ }
816
+
817
+ export interface FindYieldOpportunitiesRequest {
818
+ chains?: string[];
819
+ minApy?: number;
820
+ maxRisk?: number;
821
+ minTvl?: number;
822
+ protocols?: string[];
823
+ assets?: string[];
824
+ includeArbitrage?: boolean;
825
+ riskTolerance?: 'conservative' | 'moderate' | 'aggressive';
826
+ sortBy?: 'apy' | 'risk_adjusted_return' | 'tvl' | 'risk_score';
827
+ }
828
+
829
+ export interface AnalyzeArbitrageOpportunitiesRequest {
830
+ sourceChain: string;
831
+ targetChain: string;
832
+ token: string;
833
+ amount?: number;
834
+ includeGasCosts?: boolean;
835
+ slippageTolerance?: number;
836
+ bridgeProtocols?: string[];
837
+ }
838
+
839
+ export interface BacktestStrategyRequest {
840
+ strategy: 'yield_farming' | 'arbitrage' | 'optimization' | 'balanced';
841
+ protocols?: string[];
842
+ chains?: string[];
843
+ startDate: string;
844
+ endDate: string;
845
+ initialAmount: number;
846
+ rebalanceFrequency?: 'daily' | 'weekly' | 'monthly' | 'quarterly';
847
+ riskTolerance?: 'conservative' | 'moderate' | 'aggressive';
848
+ includeTransactionCosts?: boolean;
849
+ optimizationMethod?: 'max_sharpe' | 'risk_parity' | 'mean_variance';
850
+ }
851
+
852
+ export interface CalculatePortfolioRiskRequest {
853
+ positions: Array<{
854
+ protocol: string;
855
+ chain?: string;
856
+ asset: string;
857
+ amount: number;
858
+ currentApy?: number;
859
+ }>;
860
+ riskMetrics?: ('var' | 'correlation' | 'concentration' | 'stress_test')[];
861
+ confidenceLevel?: 90 | 95 | 99;
862
+ timeHorizon?: number;
863
+ stressScenarios?: string[];
864
+ }
865
+
866
+ export interface OptimizeYieldAllocationRequest {
867
+ amount: number;
868
+ riskTolerance: 'conservative' | 'moderate' | 'aggressive';
869
+ optimizationMethod: 'max_sharpe' | 'risk_parity' | 'mean_variance' | 'min_variance';
870
+ constraints?: {
871
+ maxProtocolAllocation?: number;
872
+ maxChainAllocation?: number;
873
+ maxRiskScore?: number;
874
+ minYield?: number;
875
+ };
876
+ includeProtocols?: string[];
877
+ excludeProtocols?: string[];
878
+ targetChains?: string[];
879
+ rebalanceFrequency?: 'never' | 'daily' | 'weekly' | 'monthly';
880
+ }
881
+
882
+ export interface AssessProtocolRiskRequest {
883
+ protocol: string;
884
+ chain?: string;
885
+ includeHistoricalEvents?: boolean;
886
+ riskCategories?: ('smart_contract' | 'economic' | 'governance' | 'liquidity' | 'oracle')[];
887
+ depth?: 'basic' | 'detailed' | 'comprehensive';
888
+ }
889
+
890
+ export interface TrackYieldPerformanceRequest {
891
+ portfolioId: string;
892
+ timeframe?: '1d' | '7d' | '30d' | '90d' | '1y' | 'all';
893
+ includeBenchmarks?: boolean;
894
+ benchmarks?: string[];
895
+ attributionAnalysis?: boolean;
896
+ includeRealTimeData?: boolean;
897
+ alertThresholds?: {
898
+ minYield?: number;
899
+ maxDrawdown?: number;
900
+ riskScoreChange?: number;
901
+ };
902
+ granularity?: 'hourly' | 'daily' | 'weekly';
903
+ }
904
+
905
+ // APY Strategy Response Types
906
+ export interface YieldOpportunity {
907
+ protocol: string;
908
+ chain: string;
909
+ pool: string;
910
+ asset: string;
911
+ apy: number;
912
+ tvl: number;
913
+ riskScore: number;
914
+ riskAdjustedReturn: number;
915
+ confidence: number;
916
+ }
917
+
918
+ export interface ArbitrageOpportunity {
919
+ sourceChain: string;
920
+ targetChain: string;
921
+ token: string;
922
+ sourceApy: number;
923
+ targetApy: number;
924
+ apyDifference: number;
925
+ estimatedProfit: number;
926
+ bridgeCost: number;
927
+ gasCost: number;
928
+ netProfit: number;
929
+ profitability: number;
930
+ risk: 'low' | 'medium' | 'high';
931
+ }
932
+
933
+ export interface BacktestPerformance {
934
+ totalReturn: number;
935
+ annualizedReturn: number;
936
+ sharpeRatio: number;
937
+ sortinoRatio: number;
938
+ maxDrawdown: number;
939
+ volatility: number;
940
+ winRate: number;
941
+ }
942
+
943
+ export interface PortfolioRisk {
944
+ portfolioValue: number;
945
+ riskScore: number;
946
+ diversificationScore: number;
947
+ var: {
948
+ confidence95: number;
949
+ confidence99: number;
950
+ timeHorizon: number;
951
+ };
952
+ correlation: {
953
+ matrix: number[][];
954
+ averageCorrelation: number;
955
+ };
956
+ concentration: {
957
+ herfindahlIndex: number;
958
+ maxAllocation: number;
959
+ protocolExposure: Record<string, number>;
960
+ };
961
+ }
962
+
963
+ export interface OptimizedAllocation {
964
+ protocol: string;
965
+ chain: string;
966
+ asset: string;
967
+ allocation: number;
968
+ amount: number;
969
+ expectedApy: number;
970
+ riskScore: number;
971
+ weight: number;
972
+ }