@elizaos/plugin-social-alpha 2.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/__tests__/e2e/benchmarks/benchmark.utils.d.ts +38 -0
  2. package/dist/__tests__/e2e/benchmarks/trust_algorithm.benchmark.d.ts +18 -0
  3. package/dist/__tests__/e2e/events.d.ts +2 -0
  4. package/dist/__tests__/e2e/index.d.ts +3 -0
  5. package/dist/__tests__/e2e/scenarios.d.ts +3 -0
  6. package/dist/__tests__/e2e/service.d.ts +1 -0
  7. package/dist/__tests__/e2e/socialAlpha.d.ts +2 -0
  8. package/dist/__tests__/e2e/test-utils.d.ts +12 -0
  9. package/dist/__tests__/e2e/test.setup.d.ts +2 -0
  10. package/dist/__tests__/e2e/trustOptimizationE2E.d.ts +4 -0
  11. package/dist/__tests__/e2e/trustScenariosE2E.d.ts +4 -0
  12. package/dist/__tests__/e2e/trustScore.d.ts +2 -0
  13. package/dist/__tests__/mocks/mockPriceService.d.ts +36 -0
  14. package/dist/assets/index-D088W50X.css +1 -0
  15. package/dist/assets/index-D32we_nf.js +17204 -0
  16. package/dist/assets/index-DU6B6kWr.js +17202 -0
  17. package/dist/clients.d.ts +382 -0
  18. package/dist/config.d.ts +143 -0
  19. package/dist/events.d.ts +4 -0
  20. package/dist/frontend/LeaderboardTable.d.ts +7 -0
  21. package/dist/frontend/index.d.ts +3 -0
  22. package/dist/frontend/loader.d.ts +1 -0
  23. package/dist/frontend/ui/badge.d.ts +11 -0
  24. package/dist/frontend/ui/button.d.ts +11 -0
  25. package/dist/frontend/ui/card.d.ts +8 -0
  26. package/dist/frontend/ui/input.d.ts +3 -0
  27. package/dist/frontend/ui/table.d.ts +10 -0
  28. package/dist/frontend/ui/tabs.d.ts +7 -0
  29. package/dist/frontend/utils.d.ts +2 -0
  30. package/dist/index.d.ts +30 -0
  31. package/dist/index.html +14 -0
  32. package/dist/mockPriceService.d.ts +1 -0
  33. package/dist/providers/socialAlphaProvider.d.ts +14 -0
  34. package/dist/reports.d.ts +56 -0
  35. package/dist/routes.d.ts +2 -0
  36. package/dist/schemas.d.ts +150 -0
  37. package/dist/scripts/analyze-trust-scores.d.ts +15 -0
  38. package/dist/scripts/enrich-price-data.d.ts +15 -0
  39. package/dist/scripts/optimize-algorithm.d.ts +14 -0
  40. package/dist/scripts/process-discord-data.d.ts +14 -0
  41. package/dist/service.d.ts +286 -0
  42. package/dist/services/PriceDataService.d.ts +34 -0
  43. package/dist/services/SimulationService.d.ts +31 -0
  44. package/dist/services/TrustScoreService.d.ts +35 -0
  45. package/dist/services/balancedTrustScoreCalculator.d.ts +60 -0
  46. package/dist/services/historicalPriceService.d.ts +58 -0
  47. package/dist/services/index.d.ts +22 -0
  48. package/dist/services/priceEnrichmentService.d.ts +112 -0
  49. package/dist/services/simulationActorsV2.d.ts +53 -0
  50. package/dist/services/simulationRunner.d.ts +112 -0
  51. package/dist/services/tokenSimulationService.d.ts +33 -0
  52. package/dist/services/trustScoreOptimizer.d.ts +109 -0
  53. package/dist/simulationActors.d.ts +23 -0
  54. package/dist/tests/index.d.ts +3 -0
  55. package/dist/types.d.ts +959 -0
  56. package/dist/utils.d.ts +51 -0
  57. package/package.json +79 -0
@@ -0,0 +1,14 @@
1
+ import type { Provider } from "@elizaos/core";
2
+ /**
3
+ * socialAlphaProvider — Injects trust-score intelligence into agent context.
4
+ *
5
+ * When the agent processes a message, this provider:
6
+ * 1. Looks up the sender's trust profile (if they have one).
7
+ * 2. Provides a compact leaderboard summary (top callers + bottom callers).
8
+ * 3. Surfaces win rate, rank, avg P&L, scam detection stats.
9
+ *
10
+ * The agent can use this data to weigh recommendations, respond with trust
11
+ * context, or decline to act on low-trust callers.
12
+ */
13
+ export declare const socialAlphaProvider: Provider;
14
+ export default socialAlphaProvider;
@@ -0,0 +1,56 @@
1
+ import type { Entity } from "@elizaos/core";
2
+ import type { PositionWithBalance, RecommenderMetrics, RecommenderMetricsHistory, TokenPerformance, Transaction } from "./types";
3
+ /**
4
+ * Formats a full report based on the provided data.
5
+ *
6
+ * @param {TokenPerformance[]} tokens - Array of token performance data.
7
+ * @param {PositionWithBalance[]} positions - Array of positions with balance data.
8
+ * @param {Transaction[]} transactions - Array of transactions data.
9
+ * @returns {{
10
+ * tokenReports: Object[],
11
+ * positionReports: Object[],
12
+ * totalCurrentValue: string,
13
+ * totalRealizedPnL: string,
14
+ * totalUnrealizedPnL: string,
15
+ * totalPnL: string,
16
+ * positionsWithBalance: Object[],
17
+ * }} Formatted full report containing token reports, position reports, total values, and positions with balance.
18
+ */
19
+ export declare function formatFullReport(tokens: TokenPerformance[], positions: PositionWithBalance[], transactions: Transaction[]): {
20
+ tokenReports: string[];
21
+ positionReports: string[];
22
+ totalCurrentValue: string;
23
+ totalRealizedPnL: string;
24
+ totalUnrealizedPnL: string;
25
+ totalPnL: string;
26
+ positionsWithBalance: {
27
+ position: PositionWithBalance;
28
+ token: TokenPerformance;
29
+ transactions: Transaction[];
30
+ }[];
31
+ };
32
+ /**
33
+ * Formats the recommender profile for a given entity based on the provided metrics and history.
34
+ * @param {Entity} entity - The entity for which the profile is being formatted.
35
+ * @param {RecommenderMetrics} metrics - The metrics related to the recommendations for the entity.
36
+ * @param {RecommenderMetricsHistory[]} history - The history of metrics for the entity.
37
+ * @returns {string} The formatted recommender profile string.
38
+ */
39
+ export declare function formatRecommenderProfile(entity: Entity, metrics: RecommenderMetrics, history: RecommenderMetricsHistory[]): string;
40
+ /**
41
+ * Formats a recommender report for an entity with provided metrics and history.
42
+ * @param {Entity} entity - The entity for which the report is being generated.
43
+ * @param {RecommenderMetrics} metrics - The metrics for the entity's recommendations.
44
+ * @param {RecommenderMetricsHistory[]} history - The historical metrics for the entity's recommendations.
45
+ * @returns {string} The formatted recommender report.
46
+ */
47
+ export declare function formatRecommenderReport(entity: Entity, metrics: RecommenderMetrics, history: RecommenderMetricsHistory[]): string;
48
+ /**
49
+ * Formats the top recommenders overview based on the provided data.
50
+ *
51
+ * @param {Entity[]} recommenders - The list of recommenders to be formatted
52
+ * @param {Map<string, RecommenderMetrics>} metrics - The map of recommender metrics
53
+ * @param {Map<string, RecommenderMetricsHistory[]>} history - The map of historical metrics data
54
+ * @returns {string} The formatted top recommenders overview in XML format
55
+ */
56
+ export declare function formatTopRecommendersOverview(recommenders: Entity[], metrics: Map<string, RecommenderMetrics>, history: Map<string, RecommenderMetricsHistory[]>): string;
@@ -0,0 +1,2 @@
1
+ import type { Route } from "@elizaos/core";
2
+ export declare const communityInvestorRoutes: Route[];
@@ -0,0 +1,150 @@
1
+ import { z } from "zod";
2
+ import type { Transaction } from "./types";
3
+ /**
4
+ * Core schema definitions for community-trader plugin
5
+ * This approach provides runtime validation and better type safety
6
+ */
7
+ export declare const TransactionType: {
8
+ readonly BUY: "BUY";
9
+ readonly SELL: "SELL";
10
+ readonly TRANSFER_IN: "transfer_in";
11
+ readonly TRANSFER_OUT: "transfer_out";
12
+ };
13
+ export declare const tokenPerformanceSchema: z.ZodObject<{
14
+ chain: z.ZodDefault<z.ZodString>;
15
+ address: z.ZodString;
16
+ name: z.ZodDefault<z.ZodOptional<z.ZodString>>;
17
+ symbol: z.ZodString;
18
+ decimals: z.ZodDefault<z.ZodNumber>;
19
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
20
+ price: z.ZodDefault<z.ZodNumber>;
21
+ volume: z.ZodDefault<z.ZodNumber>;
22
+ trades: z.ZodDefault<z.ZodNumber>;
23
+ liquidity: z.ZodDefault<z.ZodNumber>;
24
+ holders: z.ZodDefault<z.ZodNumber>;
25
+ price24hChange: z.ZodDefault<z.ZodNumber>;
26
+ volume24hChange: z.ZodDefault<z.ZodNumber>;
27
+ trades24hChange: z.ZodDefault<z.ZodNumber>;
28
+ holders24hChange: z.ZodDefault<z.ZodNumber>;
29
+ initialMarketCap: z.ZodDefault<z.ZodNumber>;
30
+ currentMarketCap: z.ZodDefault<z.ZodNumber>;
31
+ rugPull: z.ZodDefault<z.ZodBoolean>;
32
+ isScam: z.ZodDefault<z.ZodBoolean>;
33
+ sustainedGrowth: z.ZodDefault<z.ZodBoolean>;
34
+ rapidDump: z.ZodDefault<z.ZodBoolean>;
35
+ suspiciousVolume: z.ZodDefault<z.ZodBoolean>;
36
+ validationTrust: z.ZodDefault<z.ZodNumber>;
37
+ createdAt: z.ZodDefault<z.ZodDate>;
38
+ updatedAt: z.ZodDefault<z.ZodDate>;
39
+ }, z.core.$strip>;
40
+ export declare const transactionSchema: z.ZodObject<{
41
+ id: z.ZodString;
42
+ positionId: z.ZodString;
43
+ chain: z.ZodDefault<z.ZodString>;
44
+ tokenAddress: z.ZodString;
45
+ transactionHash: z.ZodString;
46
+ type: z.ZodEnum<{
47
+ BUY: "BUY";
48
+ SELL: "SELL";
49
+ }>;
50
+ amount: z.ZodNumber;
51
+ price: z.ZodOptional<z.ZodNumber>;
52
+ isSimulation: z.ZodDefault<z.ZodBoolean>;
53
+ timestamp: z.ZodString;
54
+ }, z.core.$strip>;
55
+ export declare const recommenderMetricsSchema: z.ZodObject<{
56
+ entityId: z.ZodString;
57
+ trustScore: z.ZodNumber;
58
+ totalRecommendations: z.ZodNumber;
59
+ successfulRecs: z.ZodNumber;
60
+ avgTokenPerformance: z.ZodNumber;
61
+ riskScore: z.ZodNumber;
62
+ consistencyScore: z.ZodNumber;
63
+ virtualConfidence: z.ZodNumber;
64
+ lastActiveDate: z.ZodDate;
65
+ trustDecay: z.ZodNumber;
66
+ updatedAt: z.ZodDefault<z.ZodOptional<z.ZodDate>>;
67
+ }, z.core.$strip>;
68
+ export declare const positionSchema: z.ZodObject<{
69
+ id: z.ZodString;
70
+ chain: z.ZodString;
71
+ tokenAddress: z.ZodString;
72
+ walletAddress: z.ZodString;
73
+ isSimulation: z.ZodBoolean;
74
+ entityId: z.ZodString;
75
+ recommendationId: z.ZodString;
76
+ initialPrice: z.ZodString;
77
+ initialMarketCap: z.ZodString;
78
+ initialLiquidity: z.ZodString;
79
+ performanceScore: z.ZodNumber;
80
+ rapidDump: z.ZodBoolean;
81
+ openedAt: z.ZodDate;
82
+ closedAt: z.ZodOptional<z.ZodDate>;
83
+ updatedAt: z.ZodDate;
84
+ amount: z.ZodString;
85
+ entryPrice: z.ZodString;
86
+ currentPrice: z.ZodString;
87
+ }, z.core.$strip>;
88
+ export declare const tokenRecommendationSchema: z.ZodObject<{
89
+ id: z.ZodString;
90
+ entityId: z.ZodString;
91
+ chain: z.ZodString;
92
+ tokenAddress: z.ZodString;
93
+ type: z.ZodString;
94
+ conviction: z.ZodString;
95
+ initialMarketCap: z.ZodString;
96
+ initialLiquidity: z.ZodString;
97
+ initialPrice: z.ZodString;
98
+ marketCap: z.ZodString;
99
+ liquidity: z.ZodString;
100
+ price: z.ZodString;
101
+ rugPull: z.ZodBoolean;
102
+ isScam: z.ZodBoolean;
103
+ riskScore: z.ZodNumber;
104
+ performanceScore: z.ZodNumber;
105
+ metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
106
+ status: z.ZodEnum<{
107
+ ACTIVE: "ACTIVE";
108
+ COMPLETED: "COMPLETED";
109
+ EXPIRED: "EXPIRED";
110
+ WITHDRAWN: "WITHDRAWN";
111
+ }>;
112
+ createdAt: z.ZodDate;
113
+ updatedAt: z.ZodDate;
114
+ }, z.core.$strip>;
115
+ export type TokenPerformance = z.infer<typeof tokenPerformanceSchema>;
116
+ export type RecommenderMetrics = z.infer<typeof recommenderMetricsSchema>;
117
+ export type Position = z.infer<typeof positionSchema>;
118
+ export type TokenRecommendation = z.infer<typeof tokenRecommendationSchema>;
119
+ /**
120
+ * Transform functions to convert database objects to schema-validated objects
121
+ */
122
+ export declare function transformTokenPerformance(dbToken: Record<string, unknown>, chain?: string): TokenPerformance;
123
+ export declare function transformTransaction(dbTx: Record<string, unknown>, positionId?: string, chain?: string): Transaction;
124
+ export declare function transformPosition(dbPos: Record<string, unknown>): Position;
125
+ /**
126
+ * Type definition for MessageRecommendation based on the schema recommendationSchema
127
+ */
128
+ export type MessageRecommendation = z.infer<typeof recommendationSchema>;
129
+ /**
130
+ * Schema for extracting trading recommendations from conversational text, capturing the key components of who made the recommendation, what asset was discussed, what action was recommended, and how strongly it was recommended
131
+ */
132
+ export declare const recommendationSchema: z.ZodObject<{
133
+ username: z.ZodString;
134
+ ticker: z.ZodNullable<z.ZodOptional<z.ZodString>>;
135
+ tokenAddress: z.ZodNullable<z.ZodOptional<z.ZodString>>;
136
+ type: z.ZodEnum<{
137
+ NONE: "NONE";
138
+ BUY: "BUY";
139
+ DONT_BUY: "DONT_BUY";
140
+ SELL: "SELL";
141
+ DONT_SELL: "DONT_SELL";
142
+ }>;
143
+ conviction: z.ZodEnum<{
144
+ NONE: "NONE";
145
+ LOW: "LOW";
146
+ MEDIUM: "MEDIUM";
147
+ HIGH: "HIGH";
148
+ }>;
149
+ }, z.core.$strip>;
150
+ export declare function transformTokenRecommendation(dbRec: Record<string, unknown>): TokenRecommendation;
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Analyze Trust Scores
4
+ *
5
+ * This script analyzes trust scores from enriched trading call data:
6
+ * 1. Load enriched call data
7
+ * 2. Calculate trust scores using the balanced algorithm
8
+ * 3. Generate rankings and statistics
9
+ * 4. Compare different algorithms if requested
10
+ * 5. Visualize results
11
+ *
12
+ * Usage:
13
+ * npm run analyze-trust-scores [--input <file>] [--output <dir>] [--compare] [--visualize]
14
+ */
15
+ export {};
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Enrich Price Data
4
+ *
5
+ * This script enriches trading calls with historical price data:
6
+ * 1. Load trading calls from batches
7
+ * 2. Resolve token addresses
8
+ * 3. Fetch historical price data
9
+ * 4. Calculate profit/loss metrics
10
+ * 5. Save enriched data
11
+ *
12
+ * Usage:
13
+ * npm run enrich-price-data [--input <dir>] [--output <dir>] [--batch-size <number>] [--resume]
14
+ */
15
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Optimize Trust Score Algorithm
4
+ *
5
+ * This script optimizes the trust score algorithm parameters:
6
+ * 1. Run simulations with different actor types
7
+ * 2. Test various parameter combinations
8
+ * 3. Find the best parameters that minimize error
9
+ * 4. Generate optimization report
10
+ *
11
+ * Usage:
12
+ * npm run optimize-algorithm [--cache] [--quick] [--output <dir>]
13
+ */
14
+ export {};
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Process Discord Data
4
+ *
5
+ * This script processes Discord trading call data through the following steps:
6
+ * 1. Load raw Discord data from JSON files
7
+ * 2. Parse and validate trading calls
8
+ * 3. Batch the data for processing
9
+ * 4. Analyze the processed data
10
+ *
11
+ * Usage:
12
+ * npm run process-discord-data [--input <dir>] [--output <dir>] [--batch-size <number>]
13
+ */
14
+ export {};
@@ -0,0 +1,286 @@
1
+ import { type Entity, type IAgentRuntime, type Memory, Service, type UUID } from "@elizaos/core";
2
+ import { type TradingConfig } from "./config";
3
+ import { type BuySignalMessage, Conviction, type ICommunityInvestorService, type LeaderboardEntry, type Position, type PositionWithBalance, type ProcessedTokenData, type Recommendation, type RecommendationMetric, RecommendationType, type RecommenderMetrics, type RecommenderMetricsHistory, ServiceType, SupportedChain, type TokenAPIData, type TokenMarketData, type TokenMetadata, type TokenPerformance, type TokenRecommendation, type Transaction } from "./types";
4
+ /**
5
+ * Represents different types of trading events that can occur.
6
+ * @typedef {Object} TradingEvent
7
+ * @property {string} type - The type of trading event.
8
+ * @property {Position} [position] - The position associated with the event. (if type is 'position_opened' or 'position_closed')
9
+ * @property {Transaction} [transaction] - The transaction associated with the event. (if type is 'transaction_added')
10
+ * @property {TokenRecommendation} [recommendation] - The token recommendation associated with the event. (if type is 'recommendation_added')
11
+ * @property {TokenPerformance} [performance] - The token performance associated with the event. (if type is 'token_performance_updated')
12
+ */
13
+ export type TradingEvent = {
14
+ type: "position_opened";
15
+ position: Position;
16
+ } | {
17
+ type: "position_closed";
18
+ position: Position;
19
+ } | {
20
+ type: "transaction_added";
21
+ transaction: Transaction;
22
+ } | {
23
+ type: "recommendation_added";
24
+ recommendation: TokenRecommendation;
25
+ } | {
26
+ type: "token_performance_updated";
27
+ performance: TokenPerformance;
28
+ };
29
+ /**
30
+ * Unified Trading Service that centralizes all trading operations
31
+ */
32
+ /**
33
+ * CommunityInvestorService class representing a service for trading on the Solana blockchain.
34
+ * @extends Service
35
+ * @property {string} serviceType - The type of service, set to ServiceType.COMMUNITY_INVESTOR.
36
+ * @property {string} capabilityDescription - Description of the agent's ability to trade on the Solana blockchain.
37
+ * @method storeRecommenderMetrics - Store entity metrics and cache for 5 minutes.
38
+ * @method storeRecommenderMetricsHistory - Store entity metrics history.
39
+ */
40
+ export declare class CommunityInvestorService extends Service implements ICommunityInvestorService {
41
+ protected runtime: IAgentRuntime;
42
+ static serviceType: ServiceType;
43
+ capabilityDescription: string;
44
+ private birdeyeClient;
45
+ private dexscreenerClient;
46
+ private heliusClient;
47
+ tradingConfig: TradingConfig;
48
+ private apiKeys;
49
+ private balancedTrustCalculator;
50
+ private readonly POSITIVE_TRADE_THRESHOLD;
51
+ private readonly NEUTRAL_MARGIN;
52
+ private readonly RECENCY_WEIGHT_MONTHS;
53
+ private readonly USER_TRADE_COOLDOWN_HOURS;
54
+ private readonly METRIC_REFRESH_INTERVAL;
55
+ private userRegistry;
56
+ readonly componentWorldId: UUID;
57
+ readonly componentRoomId: UUID;
58
+ constructor(runtime: IAgentRuntime);
59
+ static start(runtime: IAgentRuntime): Promise<CommunityInvestorService>;
60
+ static stop(runtime: IAgentRuntime): Promise<void>;
61
+ stop(): Promise<void>;
62
+ /**
63
+ * Process a buy signal from an entity
64
+ */
65
+ processBuySignal(buySignal: BuySignalMessage, entity: Entity): Promise<Position | null>;
66
+ /**
67
+ * Process a sell signal for an existing position
68
+ */
69
+ processSellSignal(positionId: UUID, _sellRecommenderId: UUID): Promise<boolean>;
70
+ /**
71
+ * Handle a recommendation from a entity
72
+ */
73
+ handleRecommendation(entity: Entity, recommendation: {
74
+ chain: string;
75
+ tokenAddress: string;
76
+ conviction: Conviction;
77
+ type: RecommendationType;
78
+ timestamp: Date;
79
+ metadata?: Record<string, any>;
80
+ }): Promise<Position | null>;
81
+ /**
82
+ * Check if a wallet is registered for a chain
83
+ */
84
+ hasWallet(chain: string): boolean;
85
+ /**
86
+ * Get token overview data
87
+ */
88
+ getTokenOverview(chain: string, tokenAddress: string, forceRefresh?: boolean): Promise<TokenMetadata & TokenMarketData>;
89
+ /**
90
+ * Resolve a ticker to a token address
91
+ */
92
+ resolveTicker(ticker: string, chain?: SupportedChain, contextMessages?: Memory[]): Promise<{
93
+ address: string;
94
+ chain: SupportedChain;
95
+ ticker?: string;
96
+ } | null>;
97
+ /**
98
+ * Get current price for a token
99
+ */
100
+ getCurrentPrice(chain: string, tokenAddress: string): Promise<number>;
101
+ /**
102
+ * Determine if a token should be traded
103
+ */
104
+ shouldTradeToken(chain: string, tokenAddress: string): Promise<boolean>;
105
+ /**
106
+ * Get processed token data with security and trade information
107
+ */
108
+ getProcessedTokenData(chain: string, tokenAddress: string): Promise<ProcessedTokenData | null>;
109
+ /**
110
+ * Analyze holder distribution trend
111
+ */
112
+ private analyzeHolderDistribution;
113
+ /**
114
+ * Update token performance data
115
+ */
116
+ updateTokenPerformance(chain: string, tokenAddress: string): Promise<TokenPerformance>;
117
+ /**
118
+ * Calculate risk score for a token
119
+ */
120
+ calculateRiskScore(token: TokenPerformance): number;
121
+ /**
122
+ * Update entity metrics based on their recommendation performance
123
+ */
124
+ updateRecommenderMetrics(entityId: UUID, performance?: number): Promise<void>;
125
+ /**
126
+ * Calculate trust score based on metrics and new performance
127
+ */
128
+ private calculateTrustScore;
129
+ /**
130
+ * Get or fetch token performance data
131
+ */
132
+ private getOrFetchTokenPerformance;
133
+ /**
134
+ * Validate if a token meets trading criteria
135
+ */
136
+ private validateToken;
137
+ /**
138
+ * Create a token recommendation
139
+ */
140
+ private createTokenRecommendation;
141
+ /**
142
+ * Calculate buy amount based on entity trust score and conviction
143
+ */
144
+ private calculateBuyAmount;
145
+ /**
146
+ * Create a new position
147
+ */
148
+ private createPosition;
149
+ /**
150
+ * Record a transaction
151
+ */
152
+ private recordTransaction;
153
+ /**
154
+ * Get all positions for an entity
155
+ */
156
+ getPositionsByRecommender(entityId: UUID): Promise<Position[]>;
157
+ /**
158
+ * Get all positions for a token
159
+ */
160
+ private getPositionsByToken;
161
+ /**
162
+ * Get all transactions for a position
163
+ */
164
+ getTransactionsByPosition(positionId: UUID): Promise<Transaction[]>;
165
+ /**
166
+ * Get all transactions for a token
167
+ */
168
+ getTransactionsByToken(tokenAddress: string): Promise<Transaction[]>;
169
+ /**
170
+ * Get a position by ID
171
+ */
172
+ getPosition(positionId: UUID): Promise<Position | null>;
173
+ /**
174
+ * Get all recommendations by a entity
175
+ */
176
+ getRecommendationsByRecommender(entityId: UUID): Promise<TokenRecommendation[]>;
177
+ /**
178
+ * Close a position and update metrics
179
+ */
180
+ closePosition(positionId: UUID): Promise<boolean>;
181
+ /**
182
+ * Calculate position performance
183
+ */
184
+ private calculatePositionPerformance;
185
+ /**
186
+ * Store token performance data
187
+ */
188
+ private storeTokenPerformance;
189
+ /**
190
+ * Store position data
191
+ */
192
+ private storePosition;
193
+ /**
194
+ * Store transaction data
195
+ */
196
+ private storeTransaction;
197
+ /**
198
+ * Store token recommendation data
199
+ */
200
+ private storeTokenRecommendation;
201
+ /**
202
+ * Store entity metrics
203
+ */
204
+ private storeRecommenderMetrics;
205
+ /**
206
+ * Store entity metrics history
207
+ */
208
+ private storeRecommenderMetricsHistory;
209
+ /**
210
+ * Get entity metrics
211
+ */
212
+ getRecommenderMetrics(entityId: UUID): Promise<RecommenderMetrics | null>;
213
+ /**
214
+ * Get entity metrics history
215
+ */
216
+ getRecommenderMetricsHistory(entityId: UUID): Promise<RecommenderMetricsHistory[]>;
217
+ /**
218
+ * Initialize entity metrics
219
+ */
220
+ initializeRecommenderMetrics(entityId: UUID, platform: string): Promise<void>;
221
+ /**
222
+ * Get token performance
223
+ */
224
+ getTokenPerformance(tokenAddress: string, chain: string): Promise<TokenPerformance | null>;
225
+ /**
226
+ * Get open positions with balance
227
+ */
228
+ getOpenPositionsWithBalance(): Promise<PositionWithBalance[]>;
229
+ /**
230
+ * Get positions transactions
231
+ */
232
+ getPositionsTransactions(positionIds: UUID[]): Promise<Transaction[]>;
233
+ /**
234
+ * Get formatted portfolio report
235
+ */
236
+ getFormattedPortfolioReport(entityId?: UUID): Promise<string>;
237
+ initialize(runtime: IAgentRuntime): Promise<void>;
238
+ /**
239
+ * Fetches token data from an external API.
240
+ * Uses Birdeye and DexScreener for real market data.
241
+ */
242
+ getTokenAPIData(address: string, chain: SupportedChain): Promise<TokenAPIData | null>;
243
+ isLikelyScamOrRug(tokenData: TokenAPIData, recommendationTimestamp: number): Promise<boolean>;
244
+ evaluateRecommendationPerformance(recommendation: Recommendation, tokenData: TokenAPIData): Promise<RecommendationMetric>;
245
+ getRecencyWeight(recommendationTimestamp: number): number;
246
+ getConvictionWeight(conviction: Recommendation["conviction"]): number;
247
+ calculateUserTrustScore(userId: UUID, runtime: IAgentRuntime, _worldId?: UUID): Promise<number>;
248
+ /**
249
+ * Calculate trust score from user profile recommendations
250
+ */
251
+ private calculateNewScoreFromProfile;
252
+ private executeProcessTradeDecision;
253
+ private registerTaskWorkers;
254
+ getLeaderboardData(runtime: IAgentRuntime): Promise<LeaderboardEntry[]>;
255
+ private registerUser;
256
+ private loadUserRegistry;
257
+ private ensurePluginComponentContext;
258
+ /**
259
+ * Processes a batch of historical messages, intended to be called from a script.
260
+ */
261
+ processHistoricalData(batch: {
262
+ fileId: string;
263
+ batchIndex: number;
264
+ messages: any[];
265
+ userMap: Record<string, string>;
266
+ }): Promise<any[]>;
267
+ /**
268
+ * Main entry point for processing a single, real-time message from the event handler.
269
+ */
270
+ processIncomingMessage(message: {
271
+ id?: UUID;
272
+ userId: UUID;
273
+ roomId: UUID;
274
+ text: string;
275
+ timestamp: number;
276
+ username?: string;
277
+ }): Promise<void>;
278
+ /**
279
+ * Builds the system and user prompts for the recommendation extraction LLM call.
280
+ */
281
+ private buildExtractionPrompts;
282
+ /**
283
+ * Updates a user's profile with new recommendations extracted from a message batch.
284
+ */
285
+ private updateProfileWithRecommendations;
286
+ }
@@ -0,0 +1,34 @@
1
+ import type { IAgentRuntime } from "@elizaos/core";
2
+ import { SupportedChain } from "../types";
3
+ export { HistoricalPriceData, PricePoint, TokenResolution, } from "./historicalPriceService";
4
+ export { EnrichedTradingCall, TradingCall, TrustScore, } from "./priceEnrichmentService";
5
+ /**
6
+ * Consolidated Price Data Service that combines historical and enrichment functionality
7
+ */
8
+ export declare class PriceDataService {
9
+ private historicalService;
10
+ private enrichmentService;
11
+ constructor(runtime: IAgentRuntime);
12
+ fetchBirdeyeHistoricalPrices(address: string, fromTimestamp: number, toTimestamp: number): Promise<any>;
13
+ fetchDexscreenerHistoricalPrices(address: string, chain: SupportedChain, fromTimestamp: number, toTimestamp: number): Promise<any>;
14
+ getPriceAtTimestamp(historicalData: any, timestamp: number): number | null;
15
+ getMaxPriceInWindow(historicalData: any, fromTimestamp: number, toTimestamp: number): any;
16
+ findBestTokenMatch(symbol: string, chain: SupportedChain): Promise<any>;
17
+ loadBatchFiles(batchCacheDir: string): Promise<any[]>;
18
+ resolveToken(call: any): Promise<any>;
19
+ getPriceDataInWindow(tokenAddress: string, chain: SupportedChain, callTimestamp: number, windowDays?: number): Promise<any>;
20
+ enrichCall(call: any): Promise<any>;
21
+ enrichAllCalls(batchCacheDir: string, outputDir: string, batchSize?: number): Promise<void>;
22
+ calculateTrustScores(enrichedCalls: any[]): Promise<any[]>;
23
+ /**
24
+ * Get current price for a token using the best available source
25
+ */
26
+ getCurrentPrice(address: string, chain: SupportedChain): Promise<number | null>;
27
+ /**
28
+ * Enrich a batch of trading calls with price data and calculate trust scores
29
+ */
30
+ processAndScoreTradingCalls(calls: any[], outputDir: string): Promise<{
31
+ enrichedCalls: any[];
32
+ trustScores: any[];
33
+ }>;
34
+ }
@@ -0,0 +1,31 @@
1
+ import type { UUID } from "@elizaos/core";
2
+ export { ActorArchetypeV2, SimulatedActorV2, SimulatedCallV2, } from "./simulationActorsV2";
3
+ export { ActorConfig, SimulatedCallData, SimulationConfig, SimulationResult, SimulationToken, TokenPrice, TokenScenario, } from "./simulationRunner";
4
+ export { TokenScenario as TokenScenarioInterface } from "./tokenSimulationService";
5
+ /**
6
+ * Consolidated Simulation Service that combines all simulation functionality
7
+ */
8
+ export declare class SimulationService {
9
+ private simulationRunner;
10
+ private actorsService;
11
+ private tokenService;
12
+ constructor();
13
+ runSimulation(config: any): Promise<any>;
14
+ loadCachedSimulation(outputDir: string): Promise<any>;
15
+ generateCallsForActor(actor: any, token: any, tokenScenario: any, currentStep: number, priceHistory: any[]): any;
16
+ getAllActors(): any[];
17
+ getActorById(id: UUID): any;
18
+ getExpectedRankings(): any[];
19
+ createTokenFromScenario(scenario: any): any;
20
+ getAllScenarios(): any[];
21
+ getScenarioBySymbol(symbol: string): any;
22
+ generateDiverseTokenSet(): any[];
23
+ /**
24
+ * Create default actors for testing
25
+ */
26
+ createDefaultActors(): any[];
27
+ /**
28
+ * Run a quick test simulation
29
+ */
30
+ runTestSimulation(): Promise<any>;
31
+ }
@@ -0,0 +1,35 @@
1
+ import { type TrustScoreResult } from "./trustScoreOptimizer";
2
+ export { BalancedTrustScoreParams } from "./balancedTrustScoreCalculator";
3
+ export { OptimizationResult, TrustScoreParameters, TrustScoreResult, } from "./trustScoreOptimizer";
4
+ /**
5
+ * Consolidated Trust Score Service
6
+ */
7
+ export declare class TrustScoreService {
8
+ private calculator;
9
+ private optimizer;
10
+ constructor();
11
+ calculateBalancedTrustScore(metrics: TrustScoreResult["metrics"], archetype: string, rugPromotions: number, goodCalls: number, totalCalls: number): number;
12
+ setCalculatorParameters(params: Partial<any>): void;
13
+ getCalculatorParameters(): any;
14
+ runOptimizationCycle(simulationConfig?: any, useCache?: boolean): Promise<any>;
15
+ optimizeParameters(parameterRanges: any, simulationConfig?: any): Promise<any>;
16
+ /**
17
+ * Calculate trust score for a user based on their trading history
18
+ */
19
+ calculateUserTrustScore(userCalls: any[], archetype?: string): {
20
+ score: number;
21
+ metrics: TrustScoreResult["metrics"];
22
+ breakdown: {
23
+ profitComponent: number;
24
+ winRateComponent: number;
25
+ sharpeComponent: number;
26
+ alphaComponent: number;
27
+ consistencyComponent: number;
28
+ qualityComponent: number;
29
+ };
30
+ };
31
+ /**
32
+ * Run a complete optimization test
33
+ */
34
+ runOptimizationTest(): Promise<void>;
35
+ }