@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,959 @@
1
+ import type { Content, UUID as CoreUUID, IAgentRuntime, Memory } from "@elizaos/core";
2
+ /**
3
+ * Represents a universally unique identifier (UUID).
4
+ */
5
+ export type UUID = CoreUUID;
6
+ /**
7
+ * Represents a type where certain properties from the original type T are optional.
8
+ * @template T - The original type
9
+ * @template K - The keys of the properties that should be optional
10
+ * @typedef {Omit<T, K> & Partial<Pick<T, K>>} Optional
11
+ */
12
+ export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
13
+ /**
14
+ * Creates a new type by transforming each key in the provided type `type` into a property with the same key and value.
15
+ * @template type The type to make pretty.
16
+ * @typedef {Object} Pretty
17
+ * @property {keyof type} key The key from the original type
18
+ * @property {type[key]} value The value associated with the key from the original type
19
+ * @augments unknown
20
+ */
21
+ export type Pretty<type> = {
22
+ [key in keyof type]: type[key];
23
+ } & unknown;
24
+ /**
25
+ * Type that extracts variables enclosed in double curly braces from a given string.
26
+ *
27
+ * @template T The input string type
28
+ * @typedef {T} ExtractVariables
29
+ * @param {T} T The input string to extract variables from
30
+ * @returns {Var} The variables extracted from the input string
31
+ */
32
+ type ExtractVariables<T extends string> = T extends `${infer Start}{{${infer Var}}}${infer Rest}` ? Var | ExtractVariables<Rest> : never;
33
+ /**
34
+ * Represents a type that defines template variables for a given string type.
35
+ *
36
+ * @template T - The string type for which template variables are defined.
37
+ * @typedef TemplateVariables
38
+ * @type {Pretty<{ [K in ExtractVariables<T>]: string; }>}
39
+ */
40
+ export type TemplateVariables<T extends string> = Pretty<{
41
+ [K in ExtractVariables<T>]: string;
42
+ }>;
43
+ /** Recursive JSON-compatible value used in metadata records. */
44
+ export type MetadataJsonValue = string | number | boolean | null | undefined | MetadataJsonValue[] | {
45
+ [key: string]: MetadataJsonValue;
46
+ };
47
+ /** Record type for token metadata (supports nested objects like security info). */
48
+ export type TokenMetadataRecord = Record<string, MetadataJsonValue>;
49
+ /**
50
+ * Represents a value that can be stored in a SQLite database, which can be a string, number, or null.
51
+ */
52
+ type SQLiteValue = string | number | null;
53
+ /**
54
+ * Type utility for converting TypeScript types to SQLite column types.
55
+ *
56
+ * @template T - The TypeScript type to convert.
57
+ * @param {T} - The value to convert.
58
+ * @returns {ToSQLiteType<T>} - The SQLite column type equivalent of the input type.
59
+ */
60
+ type ToSQLiteType<T> = T extends boolean ? number : T extends Date ? string : T extends bigint ? string : T extends Array<unknown> ? string : T extends object ? string : T extends SQLiteValue ? T : never;
61
+ /**
62
+ * Converts a generic record type to a SQLite record type, where each property value is converted to a SQLite type.
63
+ *
64
+ * @template T - The generic record type to be converted to a SQLite record type.
65
+ * @typedef ToSQLiteRecord
66
+ * @type {object}
67
+ */
68
+ export type ToSQLiteRecord<T extends Record<string, any>> = {
69
+ [K in keyof T]: ToSQLiteType<T[K]>;
70
+ };
71
+ /**
72
+ * Represents a type which is used to define a single row in the database table for RecommenderMetrics.
73
+ */
74
+ export type RecommenderMetricsRow = ToSQLiteRecord<RecommenderMetrics>;
75
+ /**
76
+ * Defines an alias for converting a TokenPerformance object into a SQLite record format.
77
+ */
78
+ export type TokenPerformanceRow = ToSQLiteRecord<TokenPerformance>;
79
+ /**
80
+ * Represents a single row of data in a SQLite database table, corresponding to the Position model.
81
+ */
82
+ export type PositionRow = ToSQLiteRecord<Position>;
83
+ /**
84
+ * A type alias representing a row in the Transaction table,
85
+ * serialized as a SQLite record.
86
+ */
87
+ export type TransactionRow = ToSQLiteRecord<Transaction>;
88
+ /**
89
+ * Interface representing the metrics of a recommender.
90
+ * @typedef {{
91
+ * entityId: UUID,
92
+ * platform: string,
93
+ * totalRecommendations: number,
94
+ * successfulRecs: number,
95
+ * failedTrades: number,
96
+ * totalProfit: number,
97
+ * avgTokenPerformance: number,
98
+ * consistencyScore: number,
99
+ * trustScore: number,
100
+ * lastUpdated: Date,
101
+ * createdAt: Date
102
+ * }} RecommenderMetrics
103
+ */
104
+ export interface RecommenderMetrics {
105
+ entityId: UUID;
106
+ platform: string;
107
+ totalRecommendations: number;
108
+ successfulRecs: number;
109
+ failedTrades: number;
110
+ totalProfit: number;
111
+ avgTokenPerformance: number;
112
+ consistencyScore: number;
113
+ trustScore: number;
114
+ lastUpdated: Date;
115
+ createdAt: Date;
116
+ }
117
+ /**
118
+ * Interface representing the history of recommender metrics for a specific entity.
119
+ * @typedef {Object} RecommenderMetricsHistory
120
+ * @property {UUID} entityId - The ID of the entity for which the metrics are recorded.
121
+ * @property {RecommenderMetrics} metrics - The metrics related to the entity.
122
+ * @property {Date} timestamp - The timestamp when the metrics were recorded.
123
+ */
124
+ export interface RecommenderMetricsHistory {
125
+ entityId: UUID;
126
+ metrics: RecommenderMetrics;
127
+ timestamp: Date;
128
+ }
129
+ /**
130
+ * Interface representing performance data for a token.
131
+ * @typedef {Object} TokenPerformance
132
+ * @property {string} [chain] - The blockchain network the token belongs to.
133
+ * @property {string} [address] - The address of the token.
134
+ * @property {string} [name] - The name of the token.
135
+ * @property {string} [symbol] - The symbol of the token.
136
+ * @property {number} [decimals] - The number of decimal places for the token.
137
+ * @property {Object.<string, any>} [metadata] - Additional metadata for the token.
138
+ * @property {number} [price] - The current price of the token.
139
+ * @property {number} [price24hChange] - The percentage change in price over the last 24 hours.
140
+ * @property {number} [volume] - The trading volume of the token.
141
+ * @property {number} [volume24hChange] - The percentage change in trading volume over the last 24 hours.
142
+ * @property {number} [trades] - The number of trades for the token.
143
+ * @property {number} [trades24hChange] - The percentage change in number of trades over the last 24 hours.
144
+ * @property {number} [liquidity] - The liquidity of the token.
145
+ * @property {number} [holders] - The number of holders of the token.
146
+ * @property {number} [holders24hChange] - The percentage change in number of holders over the last 24 hours.
147
+ * @property {number} [initialMarketCap] - The initial market capitalization of the token.
148
+ * @property {number} [currentMarketCap] - The current market capitalization of the token.
149
+ * @property {boolean} [rugPull] - Indicates if the token is associated with a rug pull.
150
+ * @property {boolean} [isScam] - Indicates if the token is considered a scam.
151
+ * @property {boolean} [sustainedGrowth] - Indicates if the token has shown sustained growth.
152
+ * @property {boolean} [rapidDump] - Indicates if the token has experienced a rapid dump in price.
153
+ * @property {boolean} [suspiciousVolume] - Indicates if the token has suspicious trading volume.
154
+ * @property {number} [validationTrust] - The level of trust in the token's validation.
155
+ * @property {Date} [createdAt] - The date and time when the token performance data was created.
156
+ * @property {Date} [updatedAt] - The date and time when the token performance data was last updated.
157
+ */
158
+ export interface TokenPerformance {
159
+ chain?: string;
160
+ address?: string;
161
+ name?: string;
162
+ symbol?: string;
163
+ decimals?: number;
164
+ metadata?: TokenMetadataRecord;
165
+ price?: number;
166
+ price24hChange?: number;
167
+ volume?: number;
168
+ volume24hChange?: number;
169
+ trades?: number;
170
+ trades24hChange?: number;
171
+ liquidity?: number;
172
+ holders?: number;
173
+ holders24hChange?: number;
174
+ initialMarketCap?: number;
175
+ currentMarketCap?: number;
176
+ rugPull?: boolean;
177
+ isScam?: boolean;
178
+ sustainedGrowth?: boolean;
179
+ rapidDump?: boolean;
180
+ suspiciousVolume?: boolean;
181
+ validationTrust?: number;
182
+ createdAt?: Date;
183
+ updatedAt?: Date;
184
+ }
185
+ /**
186
+ * Conviction levels for recommendations
187
+ * IMPORTANT: Must match the enum in config.ts
188
+ */
189
+ /**
190
+ * Enumeration representing levels of conviction.
191
+ * @readonly
192
+ * @enum {string}
193
+ * @property {string} NONE - No conviction.
194
+ * @property {string} LOW - Low level of conviction.
195
+ * @property {string} MEDIUM - Medium level of conviction.
196
+ * @property {string} HIGH - High level of conviction.
197
+ * @property {string} VERY_HIGH - Very high level of conviction.
198
+ */
199
+ export declare enum Conviction {
200
+ NONE = "NONE",
201
+ LOW = "LOW",
202
+ MEDIUM = "MEDIUM",
203
+ HIGH = "HIGH",
204
+ VERY_HIGH = "VERY_HIGH",
205
+ NEUTRAL = "NEUTRAL"
206
+ }
207
+ /**
208
+ * Recommendation types
209
+ * IMPORTANT: Must match the enum in config.ts
210
+ */
211
+ export declare enum RecommendationType {
212
+ BUY = "BUY",
213
+ DONT_BUY = "DONT_BUY",
214
+ SELL = "SELL",
215
+ DONT_SELL = "DONT_SELL",
216
+ NONE = "NONE",
217
+ HOLD = "HOLD"
218
+ }
219
+ export type TokenRecommendation = {
220
+ id: UUID;
221
+ entityId: UUID;
222
+ chain: string;
223
+ tokenAddress: string;
224
+ conviction: Conviction;
225
+ type: RecommendationType;
226
+ initialMarketCap: string;
227
+ initialLiquidity: string;
228
+ initialPrice: string;
229
+ marketCap: string;
230
+ liquidity: string;
231
+ price: string;
232
+ rugPull: boolean;
233
+ isScam: boolean;
234
+ riskScore: number;
235
+ performanceScore: number;
236
+ metadata: TokenMetadataRecord;
237
+ status: "ACTIVE" | "COMPLETED" | "EXPIRED" | "WITHDRAWN";
238
+ createdAt: Date;
239
+ updatedAt: Date;
240
+ };
241
+ export interface Position {
242
+ id: UUID;
243
+ entityId: UUID;
244
+ tokenAddress: string;
245
+ chain: string;
246
+ walletAddress: string;
247
+ balance: string;
248
+ status: "OPEN" | "CLOSED";
249
+ createdAt: Date;
250
+ closedAt?: Date;
251
+ isSimulation: boolean;
252
+ amount: string;
253
+ initialPrice: string;
254
+ currentPrice?: string;
255
+ recommendationId: UUID;
256
+ }
257
+ export type PositionWithBalance = Position & {
258
+ balance: bigint;
259
+ };
260
+ /**
261
+ * Unified transaction type enums to ensure consistency
262
+ * IMPORTANT: Must match the enum in config.ts
263
+ */
264
+ export declare enum TransactionType {
265
+ BUY = "BUY",
266
+ SELL = "SELL",
267
+ TRANSFER_IN = "transfer_in",
268
+ TRANSFER_OUT = "transfer_out"
269
+ }
270
+ /**
271
+ * Complete transaction interface with all possible fields
272
+ */
273
+ export interface Transaction {
274
+ id: UUID;
275
+ positionId: UUID;
276
+ tokenAddress: string;
277
+ type: TransactionType;
278
+ amount: string;
279
+ valueUsd?: number;
280
+ marketCap?: number;
281
+ liquidity?: number;
282
+ price: string;
283
+ isSimulation: boolean;
284
+ timestamp: Date;
285
+ chain?: string;
286
+ transactionHash?: string;
287
+ }
288
+ export type SellDetails = {
289
+ price: number;
290
+ timestamp: string;
291
+ amount: bigint;
292
+ receivedSol: bigint;
293
+ valueUsd: number;
294
+ profitUsd: number;
295
+ profitPercent: number;
296
+ marketCap: number;
297
+ marketCapChange: number;
298
+ liquidity: number;
299
+ liquidityChange: number;
300
+ rapidDump: boolean;
301
+ entityId: string;
302
+ };
303
+ export type BuyData = {
304
+ positionId: string;
305
+ chain: string;
306
+ tokenAddress: string;
307
+ walletAddress: string;
308
+ entityID: UUID;
309
+ recommendationId: string;
310
+ solAmount: bigint;
311
+ buyAmount: bigint;
312
+ timestamp: Date;
313
+ initialTokenPriceUsd: string;
314
+ isSimulation: boolean;
315
+ txHash: string;
316
+ };
317
+ export type SellData = {
318
+ positionId: string;
319
+ chain: string;
320
+ tokenAddress: string;
321
+ walletAddress: string;
322
+ entityID: UUID;
323
+ solAmount: bigint;
324
+ sellAmount: bigint;
325
+ timestamp: Date;
326
+ isSimulation: boolean;
327
+ txHash: string;
328
+ };
329
+ export type RecommenderAnalytics = {
330
+ entityId: string;
331
+ trustScore: number;
332
+ riskScore: number;
333
+ consistencyScore: number;
334
+ recommenderMetrics: RecommenderMetrics;
335
+ };
336
+ export type TokenRecommendationSummary = {
337
+ chain: string;
338
+ tokenAddress: string;
339
+ averageTrustScore: number;
340
+ averageRiskScore: number;
341
+ averageConsistencyScore: number;
342
+ recommenders: RecommenderAnalytics[];
343
+ };
344
+ export type TransactionData = {
345
+ chain: string;
346
+ tokenAddress: string;
347
+ pairId: string;
348
+ amount: string;
349
+ currentBalance: string;
350
+ sellRecommenderId: string;
351
+ walletAddress: string;
352
+ transaction: Transaction | null;
353
+ isSimulation: boolean;
354
+ };
355
+ export type QuoteResult<Data = unknown> = {
356
+ amountOut: bigint;
357
+ data?: Data;
358
+ };
359
+ export type SwapInResult<Data = unknown> = {
360
+ txHash: string;
361
+ amountOut: bigint;
362
+ timestamp: Date;
363
+ data?: Data;
364
+ };
365
+ export type QuoteInParams = {
366
+ inputToken: string;
367
+ outputToken: string;
368
+ amountIn: bigint;
369
+ slippageBps?: number;
370
+ };
371
+ export type SwapInParams<SwapData = unknown> = {
372
+ inputToken: string;
373
+ outputToken: string;
374
+ amountIn: bigint;
375
+ minAmountOut: bigint;
376
+ isSimulation: boolean;
377
+ data?: SwapData;
378
+ };
379
+ export interface TrustWalletProvider<QuoteData = unknown, TQuoteResult extends QuoteResult<QuoteData> = QuoteResult<QuoteData>, SwapResultData = unknown, TSwapResult extends SwapInResult<SwapResultData> = SwapInResult<SwapResultData>> {
380
+ getCurrencyAddress(): string;
381
+ getAddress(): string;
382
+ getQuoteIn(props: QuoteInParams): Promise<TQuoteResult>;
383
+ swapIn(props: SwapInParams<QuoteData>): Promise<TSwapResult>;
384
+ executeSwap<SwapData = unknown, SwapResultData = unknown>(params: {
385
+ inputToken: string;
386
+ outputToken: string;
387
+ swapData: SwapData;
388
+ }): Promise<SwapInResult<SwapResultData>>;
389
+ getTokenFromWallet(tokenSymbol: string): Promise<string | null>;
390
+ getAccountBalance(): Promise<bigint>;
391
+ }
392
+ export type TokenMetadata = {
393
+ chain: string;
394
+ address: string;
395
+ name: string;
396
+ symbol: string;
397
+ decimals: number;
398
+ metadata: TokenMetadataRecord;
399
+ };
400
+ export type TokenMarketData = {
401
+ price: number;
402
+ priceUsd: string;
403
+ price24hChange: number;
404
+ marketCap: number;
405
+ uniqueWallet24h: number;
406
+ uniqueWallet24hChange: number;
407
+ volume24h: number;
408
+ volume24hChange: number;
409
+ trades: number;
410
+ trades24hChange: number;
411
+ liquidityUsd: number;
412
+ holders: number;
413
+ };
414
+ export interface MessageRecommendation {
415
+ tokenMentioned: string;
416
+ isTicker: boolean;
417
+ sentiment: "positive" | "negative" | "neutral";
418
+ conviction: "NONE" | "LOW" | "MEDIUM" | "HIGH";
419
+ quote: string;
420
+ }
421
+ export interface RecommendationMemory extends Memory {
422
+ content: Content & {
423
+ recommendation: MessageRecommendation & {
424
+ confirmed?: boolean;
425
+ };
426
+ };
427
+ }
428
+ export type Account = {
429
+ id: UUID;
430
+ name: string;
431
+ username: string;
432
+ email: string;
433
+ avatarUrl: string;
434
+ telegramId: string;
435
+ discordId: string;
436
+ };
437
+ export type TokenTradeData = {
438
+ address: string;
439
+ holder: number;
440
+ market: number;
441
+ last_trade_unix_time: number;
442
+ last_trade_human_time: string;
443
+ price: number;
444
+ history_30m_price: number;
445
+ price_change_30m_percent: number;
446
+ history_1h_price: number;
447
+ price_change_1h_percent: number;
448
+ history_2h_price: number;
449
+ price_change_2h_percent: number;
450
+ history_4h_price: number;
451
+ price_change_4h_percent: number;
452
+ history_6h_price: number;
453
+ price_change_6h_percent: number;
454
+ history_8h_price: number;
455
+ price_change_8h_percent: number;
456
+ history_12h_price: number;
457
+ price_change_12h_percent: number;
458
+ history_24h_price: number;
459
+ price_change_24h_percent: number;
460
+ unique_wallet_30m: number;
461
+ unique_wallet_history_30m: number;
462
+ unique_wallet_30m_change_percent: number;
463
+ unique_wallet_1h: number;
464
+ unique_wallet_history_1h: number;
465
+ unique_wallet_1h_change_percent: number;
466
+ unique_wallet_2h: number;
467
+ unique_wallet_history_2h: number;
468
+ unique_wallet_2h_change_percent: number;
469
+ unique_wallet_4h: number;
470
+ unique_wallet_history_4h: number;
471
+ unique_wallet_4h_change_percent: number;
472
+ unique_wallet_8h: number;
473
+ unique_wallet_history_8h: number | null;
474
+ unique_wallet_8h_change_percent: number | null;
475
+ unique_wallet_24h: number;
476
+ unique_wallet_history_24h: number | null;
477
+ unique_wallet_24h_change_percent: number | null;
478
+ trade_30m: number;
479
+ trade_history_30m: number;
480
+ trade_30m_change_percent: number;
481
+ sell_30m: number;
482
+ sell_history_30m: number;
483
+ sell_30m_change_percent: number;
484
+ buy_30m: number;
485
+ buy_history_30m: number;
486
+ buy_30m_change_percent: number;
487
+ volume_30m: number;
488
+ volume_30m_usd: number;
489
+ volume_history_30m: number;
490
+ volume_history_30m_usd: number;
491
+ volume_30m_change_percent: number;
492
+ volume_buy_30m: number;
493
+ volume_buy_30m_usd: number;
494
+ volume_buy_history_30m: number;
495
+ volume_buy_history_30m_usd: number;
496
+ volume_buy_30m_change_percent: number;
497
+ volume_sell_30m: number;
498
+ volume_sell_30m_usd: number;
499
+ volume_sell_history_30m: number;
500
+ volume_sell_history_30m_usd: number;
501
+ volume_sell_30m_change_percent: number;
502
+ trade_1h: number;
503
+ trade_history_1h: number;
504
+ trade_1h_change_percent: number;
505
+ sell_1h: number;
506
+ sell_history_1h: number;
507
+ sell_1h_change_percent: number;
508
+ buy_1h: number;
509
+ buy_history_1h: number;
510
+ buy_1h_change_percent: number;
511
+ volume_1h: number;
512
+ volume_1h_usd: number;
513
+ volume_history_1h: number;
514
+ volume_history_1h_usd: number;
515
+ volume_1h_change_percent: number;
516
+ volume_buy_1h: number;
517
+ volume_buy_1h_usd: number;
518
+ volume_buy_history_1h: number;
519
+ volume_buy_history_1h_usd: number;
520
+ volume_buy_1h_change_percent: number;
521
+ volume_sell_1h: number;
522
+ volume_sell_1h_usd: number;
523
+ volume_sell_history_1h: number;
524
+ volume_sell_history_1h_usd: number;
525
+ volume_sell_1h_change_percent: number;
526
+ trade_2h: number;
527
+ trade_history_2h: number;
528
+ trade_2h_change_percent: number;
529
+ sell_2h: number;
530
+ sell_history_2h: number;
531
+ sell_2h_change_percent: number;
532
+ buy_2h: number;
533
+ buy_history_2h: number;
534
+ buy_2h_change_percent: number;
535
+ volume_2h: number;
536
+ volume_2h_usd: number;
537
+ volume_history_2h: number;
538
+ volume_history_2h_usd: number;
539
+ volume_2h_change_percent: number;
540
+ volume_buy_2h: number;
541
+ volume_buy_2h_usd: number;
542
+ volume_buy_history_2h: number;
543
+ volume_buy_history_2h_usd: number;
544
+ volume_buy_2h_change_percent: number;
545
+ volume_sell_2h: number;
546
+ volume_sell_2h_usd: number;
547
+ volume_sell_history_2h: number;
548
+ volume_sell_history_2h_usd: number;
549
+ volume_sell_2h_change_percent: number;
550
+ trade_4h: number;
551
+ trade_history_4h: number;
552
+ trade_4h_change_percent: number;
553
+ sell_4h: number;
554
+ sell_history_4h: number;
555
+ sell_4h_change_percent: number;
556
+ buy_4h: number;
557
+ buy_history_4h: number;
558
+ buy_4h_change_percent: number;
559
+ volume_4h: number;
560
+ volume_4h_usd: number;
561
+ volume_history_4h: number;
562
+ volume_history_4h_usd: number;
563
+ volume_4h_change_percent: number;
564
+ volume_buy_4h: number;
565
+ volume_buy_4h_usd: number;
566
+ volume_buy_history_4h: number;
567
+ volume_buy_history_4h_usd: number;
568
+ volume_buy_4h_change_percent: number;
569
+ volume_sell_4h: number;
570
+ volume_sell_4h_usd: number;
571
+ volume_sell_history_4h: number;
572
+ volume_sell_history_4h_usd: number;
573
+ volume_sell_4h_change_percent: number;
574
+ trade_8h: number;
575
+ trade_history_8h: number | null;
576
+ trade_8h_change_percent: number | null;
577
+ sell_8h: number;
578
+ sell_history_8h: number | null;
579
+ sell_8h_change_percent: number | null;
580
+ buy_8h: number;
581
+ buy_history_8h: number | null;
582
+ buy_8h_change_percent: number | null;
583
+ volume_8h: number;
584
+ volume_8h_usd: number;
585
+ volume_history_8h: number;
586
+ volume_history_8h_usd: number;
587
+ volume_8h_change_percent: number | null;
588
+ volume_buy_8h: number;
589
+ volume_buy_8h_usd: number;
590
+ volume_buy_history_8h: number;
591
+ volume_buy_history_8h_usd: number;
592
+ volume_buy_8h_change_percent: number | null;
593
+ volume_sell_8h: number;
594
+ volume_sell_8h_usd: number;
595
+ volume_sell_history_8h: number;
596
+ volume_sell_history_8h_usd: number;
597
+ volume_sell_8h_change_percent: number | null;
598
+ trade_24h: number;
599
+ trade_history_24h: number;
600
+ trade_24h_change_percent: number | null;
601
+ sell_24h: number;
602
+ sell_history_24h: number;
603
+ sell_24h_change_percent: number | null;
604
+ buy_24h: number;
605
+ buy_history_24h: number;
606
+ buy_24h_change_percent: number | null;
607
+ volume_24h: number;
608
+ volume_24h_usd: number;
609
+ volume_history_24h: number;
610
+ volume_history_24h_usd: number;
611
+ volume_24h_change_percent: number | null;
612
+ volume_buy_24h: number;
613
+ volume_buy_24h_usd: number;
614
+ volume_buy_history_24h: number;
615
+ volume_buy_history_24h_usd: number;
616
+ volume_buy_24h_change_percent: number | null;
617
+ volume_sell_24h: number;
618
+ volume_sell_24h_usd: number;
619
+ volume_sell_history_24h: number;
620
+ volume_sell_history_24h_usd: number;
621
+ volume_sell_24h_change_percent: number | null;
622
+ };
623
+ export type HolderData = {
624
+ address: string;
625
+ balance: string;
626
+ };
627
+ export type TokenSecurityData = {
628
+ ownerBalance: string;
629
+ creatorBalance: string;
630
+ ownerPercentage: number;
631
+ creatorPercentage: number;
632
+ top10HolderBalance: string;
633
+ top10HolderPercent: number;
634
+ };
635
+ export type ProcessedTokenData = {
636
+ token: TokenOverview;
637
+ security: TokenSecurityData;
638
+ tradeData: TokenTradeData;
639
+ holderDistributionTrend: string;
640
+ highValueHolders: {
641
+ holderAddress: string;
642
+ balanceUsd: string;
643
+ }[];
644
+ recentTrades: boolean;
645
+ highSupplyHoldersCount: number;
646
+ dexScreenerData: DexScreenerData;
647
+ isDexScreenerListed: boolean;
648
+ isDexScreenerPaid: boolean;
649
+ };
650
+ export type DexScreenerPair = {
651
+ chainId: string;
652
+ dexId: string;
653
+ url: string;
654
+ pairAddress: string;
655
+ baseToken: {
656
+ address: string;
657
+ name: string;
658
+ symbol: string;
659
+ };
660
+ quoteToken: {
661
+ address: string;
662
+ name: string;
663
+ symbol: string;
664
+ };
665
+ priceNative: string;
666
+ priceUsd: string;
667
+ txns: {
668
+ m5: {
669
+ buys: number;
670
+ sells: number;
671
+ };
672
+ h1: {
673
+ buys: number;
674
+ sells: number;
675
+ };
676
+ h6: {
677
+ buys: number;
678
+ sells: number;
679
+ };
680
+ h24: {
681
+ buys: number;
682
+ sells: number;
683
+ };
684
+ };
685
+ volume: {
686
+ h24: number;
687
+ h6: number;
688
+ h1: number;
689
+ m5: number;
690
+ };
691
+ priceChange: {
692
+ m5: number;
693
+ h1: number;
694
+ h6: number;
695
+ h24: number;
696
+ };
697
+ liquidity?: {
698
+ usd: number;
699
+ base: number;
700
+ quote: number;
701
+ };
702
+ fdv: number;
703
+ marketCap: number;
704
+ pairCreatedAt: number;
705
+ info: {
706
+ imageUrl: string;
707
+ websites: {
708
+ label: string;
709
+ url: string;
710
+ }[];
711
+ socials: {
712
+ type: string;
713
+ url: string;
714
+ }[];
715
+ };
716
+ boosts: {
717
+ active: number;
718
+ };
719
+ };
720
+ export type DexScreenerData = {
721
+ schemaVersion: string;
722
+ pairs: DexScreenerPair[];
723
+ };
724
+ export type Prices = {
725
+ solana: {
726
+ usd: string;
727
+ };
728
+ bitcoin: {
729
+ usd: string;
730
+ };
731
+ ethereum: {
732
+ usd: string;
733
+ };
734
+ };
735
+ export type CalculatedBuyAmounts = {
736
+ none: 0;
737
+ low: number;
738
+ medium: number;
739
+ high: number;
740
+ };
741
+ export type WalletPortfolioItem = {
742
+ name: string;
743
+ address: string;
744
+ symbol: string;
745
+ decimals: number;
746
+ balance: string;
747
+ uiAmount: string;
748
+ priceUsd: string;
749
+ valueUsd: string;
750
+ valueSol?: string;
751
+ };
752
+ export type WalletPortfolio = {
753
+ totalUsd: string;
754
+ totalSol?: string;
755
+ items: WalletPortfolioItem[];
756
+ };
757
+ export type TokenOverview = {
758
+ address: string;
759
+ name: string;
760
+ symbol: string;
761
+ decimals?: number;
762
+ logoURI?: string;
763
+ };
764
+ export interface BuySignalMessage {
765
+ positionId?: string;
766
+ tokenAddress: string;
767
+ chain: string;
768
+ walletAddress: string;
769
+ isSimulation: boolean;
770
+ entityId: string;
771
+ recommendationId: string;
772
+ price: string;
773
+ marketCap: string;
774
+ liquidity: string;
775
+ amount: string;
776
+ type: RecommendationType;
777
+ conviction: Conviction;
778
+ }
779
+ export interface Trade {
780
+ id: string;
781
+ positionId: string;
782
+ type: TransactionType.BUY | TransactionType.SELL;
783
+ amount: bigint;
784
+ price: bigint;
785
+ timestamp: Date;
786
+ txHash: string;
787
+ }
788
+ export interface TradePerformance {
789
+ token_address: string;
790
+ recommender_id: string;
791
+ buy_price: number;
792
+ sell_price: number;
793
+ buy_timeStamp: string;
794
+ sell_timeStamp: string;
795
+ buy_amount: number;
796
+ sell_amount: number;
797
+ buy_sol: number;
798
+ received_sol: number;
799
+ buy_value_usd: number;
800
+ sell_value_usd: number;
801
+ profit_usd: number;
802
+ profit_percent: number;
803
+ buy_market_cap: number;
804
+ sell_market_cap: number;
805
+ market_cap_change: number;
806
+ buy_liquidity: number;
807
+ sell_liquidity: number;
808
+ liquidity_change: number;
809
+ last_updated: string;
810
+ rapidDump: boolean;
811
+ }
812
+ /**
813
+ * Represents the metrics of a trade including total bought quantity, total bought value, total sold quantity,
814
+ * total sold value, total transfer in quantity, total transfer out quantity, average entry price, average exit price,
815
+ * realized profit and loss, realized profit and loss percentage, volume in USD, first trade time, and last trade time.
816
+ * @typedef {Object} TradeMetrics
817
+ * @property {number} totalBought - The total quantity bought
818
+ * @property {number} totalBoughtValue - The total value of items bought
819
+ * @property {number} totalSold - The total quantity sold
820
+ * @property {number} totalSoldValue - The total value of items sold
821
+ * @property {number} totalTransferIn - The total quantity transferred in
822
+ * @property {number} totalTransferOut - The total quantity transferred out
823
+ * @property {number} averageEntryPrice - The average price at which items were bought
824
+ * @property {number} averageExitPrice - The average price at which items were sold
825
+ * @property {number} realizedPnL - The realized profit and loss
826
+ * @property {number} realizedPnLPercent - The realized profit and loss percentage
827
+ * @property {number} volumeUsd - The volume in USD
828
+ * @property {Date} firstTradeTime - The timestamp of the first trade
829
+ * @property {Date} lastTradeTime - The timestamp of the last trade
830
+ */
831
+ export type TradeMetrics = {
832
+ totalBought: number;
833
+ totalBoughtValue: number;
834
+ totalSold: number;
835
+ totalSoldValue: number;
836
+ totalTransferIn: number;
837
+ totalTransferOut: number;
838
+ averageEntryPrice: number;
839
+ averageExitPrice: number;
840
+ realizedPnL: number;
841
+ realizedPnLPercent: number;
842
+ volumeUsd: number;
843
+ firstTradeTime: Date;
844
+ lastTradeTime: Date;
845
+ };
846
+ /**
847
+ * Type for position performance statistics.
848
+ * Includes information about the position such as token, current value, initial value, profit/loss, profit/loss percentage,
849
+ * price change, price change percentage, normalized balance, trade metrics, unrealized profit/loss, unrealized profit/loss percentage,
850
+ * total profit/loss, and total profit/loss percentage.
851
+ */
852
+ export type PositionPerformance = Pretty<PositionWithBalance & {
853
+ token: TokenPerformance;
854
+ currentValue: number;
855
+ initialValue: number;
856
+ profitLoss: number;
857
+ profitLossPercentage: number;
858
+ priceChange: number;
859
+ priceChangePercentage: number;
860
+ normalizedBalance: number;
861
+ trades: TradeMetrics;
862
+ unrealizedPnL: number;
863
+ unrealizedPnLPercent: number;
864
+ totalPnL: number;
865
+ totalPnLPercent: number;
866
+ }>;
867
+ export declare enum ServiceType {
868
+ COMMUNITY_INVESTOR = "community-investor"
869
+ }
870
+ export declare enum SupportedChain {
871
+ SOLANA = "SOLANA",
872
+ ETHEREUM = "ETHEREUM",
873
+ BASE = "BASE",
874
+ UNKNOWN = "UNKNOWN"
875
+ }
876
+ export interface RecommendationMetric {
877
+ potentialProfitPercent?: number;
878
+ avoidedLossPercent?: number;
879
+ isScamOrRug?: boolean;
880
+ evaluationTimestamp: number;
881
+ notes?: string;
882
+ }
883
+ export interface Recommendation {
884
+ id: UUID;
885
+ userId: UUID;
886
+ messageId: UUID;
887
+ timestamp: number;
888
+ tokenTicker?: string;
889
+ tokenAddress: string;
890
+ chain: SupportedChain;
891
+ recommendationType: "BUY" | "SELL";
892
+ conviction: Conviction;
893
+ rawMessageQuote: string;
894
+ priceAtRecommendation?: number;
895
+ metrics?: RecommendationMetric;
896
+ processedForTradeDecision?: boolean;
897
+ }
898
+ export interface UserTrustProfile {
899
+ version: string;
900
+ userId: UUID;
901
+ trustScore: number;
902
+ lastTrustScoreCalculationTimestamp: number;
903
+ lastTradeDecisionMadeTimestamp?: number;
904
+ recommendations: Recommendation[];
905
+ [key: string]: string | number | boolean | Recommendation[] | undefined;
906
+ }
907
+ export type TrustMarketplaceComponentData = UserTrustProfile;
908
+ export declare const TRUST_MARKETPLACE_COMPONENT_TYPE = "communityInvestorProfile";
909
+ export interface TradeDecisionInput {
910
+ recommendationId: UUID;
911
+ userId: UUID;
912
+ }
913
+ export interface TokenAPIData {
914
+ name?: string;
915
+ symbol?: string;
916
+ currentPrice?: number;
917
+ ath?: number;
918
+ atl?: number;
919
+ priceHistory?: {
920
+ timestamp: number;
921
+ price: number;
922
+ }[];
923
+ liquidity?: number;
924
+ marketCap?: number;
925
+ isKnownScam?: boolean;
926
+ }
927
+ export interface HighValueHolder {
928
+ holderAddress: string;
929
+ balanceUsd: string;
930
+ }
931
+ export interface LeaderboardEntry {
932
+ rank?: number;
933
+ userId: UUID;
934
+ username?: string;
935
+ trustScore: number;
936
+ recommendations: Recommendation[];
937
+ }
938
+ export interface ICommunityInvestorService {
939
+ initialize(runtime: IAgentRuntime): Promise<void>;
940
+ resolveTicker(ticker: string, chain: SupportedChain, contextMessages: Memory[]): Promise<{
941
+ address: string;
942
+ chain: SupportedChain;
943
+ ticker?: string;
944
+ } | null>;
945
+ getTokenAPIData(address: string, chain: SupportedChain): Promise<TokenAPIData | null>;
946
+ isLikelyScamOrRug(tokenData: TokenAPIData, recommendationTimestamp: number): Promise<boolean>;
947
+ evaluateRecommendationPerformance(recommendation: Recommendation, tokenData: TokenAPIData): Promise<RecommendationMetric>;
948
+ calculateUserTrustScore(userId: UUID, runtime: IAgentRuntime): Promise<number>;
949
+ getRecencyWeight(recommendationTimestamp: number): number;
950
+ getConvictionWeight(conviction: Recommendation["conviction"]): number;
951
+ getLeaderboardData(runtime: IAgentRuntime): Promise<LeaderboardEntry[]>;
952
+ }
953
+ export interface MessageReceivedHandlerParams {
954
+ runtime: IAgentRuntime;
955
+ message: Memory;
956
+ callback: (response: string | Record<string, any>, metadata?: Record<string, any>) => Promise<void>;
957
+ onComplete?: () => void;
958
+ }
959
+ export {};