@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.
- package/dist/__tests__/e2e/benchmarks/benchmark.utils.d.ts +38 -0
- package/dist/__tests__/e2e/benchmarks/trust_algorithm.benchmark.d.ts +18 -0
- package/dist/__tests__/e2e/events.d.ts +2 -0
- package/dist/__tests__/e2e/index.d.ts +3 -0
- package/dist/__tests__/e2e/scenarios.d.ts +3 -0
- package/dist/__tests__/e2e/service.d.ts +1 -0
- package/dist/__tests__/e2e/socialAlpha.d.ts +2 -0
- package/dist/__tests__/e2e/test-utils.d.ts +12 -0
- package/dist/__tests__/e2e/test.setup.d.ts +2 -0
- package/dist/__tests__/e2e/trustOptimizationE2E.d.ts +4 -0
- package/dist/__tests__/e2e/trustScenariosE2E.d.ts +4 -0
- package/dist/__tests__/e2e/trustScore.d.ts +2 -0
- package/dist/__tests__/mocks/mockPriceService.d.ts +36 -0
- package/dist/assets/index-D088W50X.css +1 -0
- package/dist/assets/index-D32we_nf.js +17204 -0
- package/dist/assets/index-DU6B6kWr.js +17202 -0
- package/dist/clients.d.ts +382 -0
- package/dist/config.d.ts +143 -0
- package/dist/events.d.ts +4 -0
- package/dist/frontend/LeaderboardTable.d.ts +7 -0
- package/dist/frontend/index.d.ts +3 -0
- package/dist/frontend/loader.d.ts +1 -0
- package/dist/frontend/ui/badge.d.ts +11 -0
- package/dist/frontend/ui/button.d.ts +11 -0
- package/dist/frontend/ui/card.d.ts +8 -0
- package/dist/frontend/ui/input.d.ts +3 -0
- package/dist/frontend/ui/table.d.ts +10 -0
- package/dist/frontend/ui/tabs.d.ts +7 -0
- package/dist/frontend/utils.d.ts +2 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.html +14 -0
- package/dist/mockPriceService.d.ts +1 -0
- package/dist/providers/socialAlphaProvider.d.ts +14 -0
- package/dist/reports.d.ts +56 -0
- package/dist/routes.d.ts +2 -0
- package/dist/schemas.d.ts +150 -0
- package/dist/scripts/analyze-trust-scores.d.ts +15 -0
- package/dist/scripts/enrich-price-data.d.ts +15 -0
- package/dist/scripts/optimize-algorithm.d.ts +14 -0
- package/dist/scripts/process-discord-data.d.ts +14 -0
- package/dist/service.d.ts +286 -0
- package/dist/services/PriceDataService.d.ts +34 -0
- package/dist/services/SimulationService.d.ts +31 -0
- package/dist/services/TrustScoreService.d.ts +35 -0
- package/dist/services/balancedTrustScoreCalculator.d.ts +60 -0
- package/dist/services/historicalPriceService.d.ts +58 -0
- package/dist/services/index.d.ts +22 -0
- package/dist/services/priceEnrichmentService.d.ts +112 -0
- package/dist/services/simulationActorsV2.d.ts +53 -0
- package/dist/services/simulationRunner.d.ts +112 -0
- package/dist/services/tokenSimulationService.d.ts +33 -0
- package/dist/services/trustScoreOptimizer.d.ts +109 -0
- package/dist/simulationActors.d.ts +23 -0
- package/dist/tests/index.d.ts +3 -0
- package/dist/types.d.ts +959 -0
- package/dist/utils.d.ts +51 -0
- package/package.json +79 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { TrustScoreResult } from "./trustScoreOptimizer";
|
|
2
|
+
export interface BalancedTrustScoreParams {
|
|
3
|
+
profitWeight: number;
|
|
4
|
+
winRateWeight: number;
|
|
5
|
+
sharpeWeight: number;
|
|
6
|
+
alphaWeight: number;
|
|
7
|
+
consistencyWeight: number;
|
|
8
|
+
qualityWeight: number;
|
|
9
|
+
normalVolumeThreshold: number;
|
|
10
|
+
highVolumeThreshold: number;
|
|
11
|
+
extremeVolumeThreshold: number;
|
|
12
|
+
volumeToleranceByArchetype: Record<string, number>;
|
|
13
|
+
}
|
|
14
|
+
export declare class BalancedTrustScoreCalculator {
|
|
15
|
+
private params;
|
|
16
|
+
/**
|
|
17
|
+
* Calculate balanced trust score
|
|
18
|
+
*/
|
|
19
|
+
calculateBalancedTrustScore(metrics: TrustScoreResult["metrics"], archetype: string, rugPromotions: number, goodCalls: number, totalCalls: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Archetype base scores with good spread
|
|
22
|
+
*/
|
|
23
|
+
private getArchetypeBase;
|
|
24
|
+
/**
|
|
25
|
+
* Profit component with better scaling
|
|
26
|
+
*/
|
|
27
|
+
private calculateProfitComponent;
|
|
28
|
+
/**
|
|
29
|
+
* Win rate component with smooth curve
|
|
30
|
+
*/
|
|
31
|
+
private calculateWinRateComponent;
|
|
32
|
+
/**
|
|
33
|
+
* Sharpe ratio component
|
|
34
|
+
*/
|
|
35
|
+
private calculateSharpeComponent;
|
|
36
|
+
/**
|
|
37
|
+
* Alpha component - fixed to handle negative values better
|
|
38
|
+
*/
|
|
39
|
+
private calculateAlphaComponent;
|
|
40
|
+
/**
|
|
41
|
+
* Quality component based on call quality
|
|
42
|
+
*/
|
|
43
|
+
private calculateQualityComponent;
|
|
44
|
+
/**
|
|
45
|
+
* Volume adjustment - multiplicative factor instead of penalty
|
|
46
|
+
*/
|
|
47
|
+
private calculateVolumeAdjustment;
|
|
48
|
+
/**
|
|
49
|
+
* Archetype performance scaling
|
|
50
|
+
*/
|
|
51
|
+
private getArchetypeScaling;
|
|
52
|
+
/**
|
|
53
|
+
* Set custom parameters
|
|
54
|
+
*/
|
|
55
|
+
setParameters(params: Partial<BalancedTrustScoreParams>): void;
|
|
56
|
+
/**
|
|
57
|
+
* Get current parameters
|
|
58
|
+
*/
|
|
59
|
+
getParameters(): BalancedTrustScoreParams;
|
|
60
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import { SupportedChain } from "../types.ts";
|
|
3
|
+
export interface PricePoint {
|
|
4
|
+
timestamp: number;
|
|
5
|
+
price: number;
|
|
6
|
+
volume?: number;
|
|
7
|
+
liquidity?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface HistoricalPriceData {
|
|
10
|
+
address: string;
|
|
11
|
+
chain: SupportedChain;
|
|
12
|
+
priceHistory: PricePoint[];
|
|
13
|
+
firstPrice?: number;
|
|
14
|
+
lastPrice?: number;
|
|
15
|
+
minPrice?: number;
|
|
16
|
+
maxPrice?: number;
|
|
17
|
+
fetchedAt: number;
|
|
18
|
+
}
|
|
19
|
+
export interface TokenResolution {
|
|
20
|
+
symbol: string;
|
|
21
|
+
address: string;
|
|
22
|
+
name: string;
|
|
23
|
+
chain: SupportedChain;
|
|
24
|
+
liquidity?: number;
|
|
25
|
+
volume24h?: number;
|
|
26
|
+
marketCap?: number;
|
|
27
|
+
createdAt?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare class HistoricalPriceService {
|
|
30
|
+
private birdeyeClient;
|
|
31
|
+
private dexscreenerClient;
|
|
32
|
+
constructor(runtime: IAgentRuntime);
|
|
33
|
+
/**
|
|
34
|
+
* Fetch historical price data from Birdeye using OHLCV endpoint
|
|
35
|
+
*/
|
|
36
|
+
fetchBirdeyeHistoricalPrices(address: string, fromTimestamp: number, toTimestamp: number): Promise<HistoricalPriceData | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch historical price data from Dexscreener
|
|
39
|
+
* Note: DexScreener doesn't provide true historical data, only recent price changes
|
|
40
|
+
*/
|
|
41
|
+
fetchDexscreenerHistoricalPrices(address: string, chain: SupportedChain, _fromTimestamp: number, _toTimestamp: number): Promise<HistoricalPriceData | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Get price at specific timestamp using interpolation
|
|
44
|
+
*/
|
|
45
|
+
getPriceAtTimestamp(historicalData: HistoricalPriceData, timestamp: number): number | null;
|
|
46
|
+
/**
|
|
47
|
+
* Get max price in time window
|
|
48
|
+
*/
|
|
49
|
+
getMaxPriceInWindow(historicalData: HistoricalPriceData, fromTimestamp: number, toTimestamp: number): {
|
|
50
|
+
price: number;
|
|
51
|
+
timestamp: number;
|
|
52
|
+
} | null;
|
|
53
|
+
/**
|
|
54
|
+
* Search for best token match by symbol
|
|
55
|
+
*/
|
|
56
|
+
findBestTokenMatch(symbol: string, chain: SupportedChain): Promise<TokenResolution | null>;
|
|
57
|
+
private getChainId;
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { BalancedTrustScoreCalculator } from "./balancedTrustScoreCalculator";
|
|
2
|
+
export { HistoricalPriceService } from "./historicalPriceService";
|
|
3
|
+
export type { EnrichedTradingCall, HistoricalPriceData, PricePoint, TokenResolution, TradingCall, TrustScore, } from "./PriceDataService";
|
|
4
|
+
export { PriceDataService } from "./PriceDataService";
|
|
5
|
+
export { PriceEnrichmentService } from "./priceEnrichmentService";
|
|
6
|
+
export type { ActorArchetypeV2, ActorConfig, SimulatedActorV2, SimulatedCallData, SimulatedCallV2, SimulationConfig, SimulationResult, SimulationToken, TokenPrice, TokenScenario, } from "./SimulationService";
|
|
7
|
+
export { SimulationService } from "./SimulationService";
|
|
8
|
+
export { SimulationActorsServiceV2 } from "./simulationActorsV2";
|
|
9
|
+
export { SimulationRunner } from "./simulationRunner";
|
|
10
|
+
export type { BalancedTrustScoreParams, OptimizationResult, TrustScoreParameters, TrustScoreResult, } from "./TrustScoreService";
|
|
11
|
+
export { TrustScoreService } from "./TrustScoreService";
|
|
12
|
+
export { TokenSimulationService } from "./tokenSimulationService";
|
|
13
|
+
export { TrustScoreOptimizer } from "./trustScoreOptimizer";
|
|
14
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
15
|
+
import { PriceDataService } from "./PriceDataService";
|
|
16
|
+
import { SimulationService } from "./SimulationService";
|
|
17
|
+
import { TrustScoreService } from "./TrustScoreService";
|
|
18
|
+
export declare function createServices(runtime?: IAgentRuntime): {
|
|
19
|
+
simulation: SimulationService;
|
|
20
|
+
priceData: PriceDataService | null;
|
|
21
|
+
trustScore: TrustScoreService;
|
|
22
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { IAgentRuntime } from "@elizaos/core";
|
|
2
|
+
import { SupportedChain } from "../types.ts";
|
|
3
|
+
export interface TradingCall {
|
|
4
|
+
callId: string;
|
|
5
|
+
originalMessageId: string;
|
|
6
|
+
userId: string;
|
|
7
|
+
username: string;
|
|
8
|
+
timestamp: number;
|
|
9
|
+
content: string;
|
|
10
|
+
tokenMentioned?: string;
|
|
11
|
+
caMentioned?: string;
|
|
12
|
+
chain: string;
|
|
13
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
14
|
+
conviction: "NONE" | "LOW" | "MEDIUM" | "HIGH";
|
|
15
|
+
llmReasoning: string;
|
|
16
|
+
certainty: "low" | "medium" | "high";
|
|
17
|
+
fileSource: string;
|
|
18
|
+
}
|
|
19
|
+
export interface EnrichedTradingCall extends TradingCall {
|
|
20
|
+
resolvedToken?: {
|
|
21
|
+
address: string;
|
|
22
|
+
symbol: string;
|
|
23
|
+
name: string;
|
|
24
|
+
chain: SupportedChain;
|
|
25
|
+
};
|
|
26
|
+
priceData?: {
|
|
27
|
+
calledPrice: number;
|
|
28
|
+
calledPriceTimestamp: number;
|
|
29
|
+
bestPrice: number;
|
|
30
|
+
bestPriceTimestamp: number;
|
|
31
|
+
worstPrice: number;
|
|
32
|
+
worstPriceTimestamp: number;
|
|
33
|
+
idealProfitLoss: number;
|
|
34
|
+
idealProfitLossPercent: number;
|
|
35
|
+
windowDays: number;
|
|
36
|
+
};
|
|
37
|
+
enrichmentStatus: "pending" | "success" | "failed";
|
|
38
|
+
enrichmentError?: string;
|
|
39
|
+
enrichedAt?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface TrustScore {
|
|
42
|
+
userId: string;
|
|
43
|
+
username: string;
|
|
44
|
+
totalCalls: number;
|
|
45
|
+
successfulCalls: number;
|
|
46
|
+
failedCalls: number;
|
|
47
|
+
averageProfitLoss: number;
|
|
48
|
+
averageProfitLossPercent: number;
|
|
49
|
+
trustScore: number;
|
|
50
|
+
consistency: number;
|
|
51
|
+
recencyWeight: number;
|
|
52
|
+
convictionAccuracy: number;
|
|
53
|
+
lastUpdated: number;
|
|
54
|
+
}
|
|
55
|
+
export declare class PriceEnrichmentService {
|
|
56
|
+
private birdeyeClient;
|
|
57
|
+
private dexscreenerClient;
|
|
58
|
+
constructor(runtime: IAgentRuntime);
|
|
59
|
+
/**
|
|
60
|
+
* Load batch files from the cache directory
|
|
61
|
+
*/
|
|
62
|
+
loadBatchFiles(batchCacheDir: string): Promise<TradingCall[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve contract address or token mention to standardized token info
|
|
65
|
+
*/
|
|
66
|
+
resolveToken(call: TradingCall): Promise<{
|
|
67
|
+
address: string;
|
|
68
|
+
symbol: string;
|
|
69
|
+
name: string;
|
|
70
|
+
chain: SupportedChain;
|
|
71
|
+
} | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Get historical price data for a token within a time window
|
|
74
|
+
*/
|
|
75
|
+
getPriceDataInWindow(tokenAddress: string, chain: SupportedChain, callTimestamp: number, windowDays?: number): Promise<{
|
|
76
|
+
calledPrice: number;
|
|
77
|
+
bestPrice: number;
|
|
78
|
+
bestPriceTimestamp: number;
|
|
79
|
+
worstPrice: number;
|
|
80
|
+
worstPriceTimestamp: number;
|
|
81
|
+
} | null>;
|
|
82
|
+
/**
|
|
83
|
+
* Enrich a single trading call with price data
|
|
84
|
+
*/
|
|
85
|
+
enrichCall(call: TradingCall): Promise<EnrichedTradingCall>;
|
|
86
|
+
/**
|
|
87
|
+
* Process all calls in batches and save enriched data
|
|
88
|
+
*/
|
|
89
|
+
enrichAllCalls(batchCacheDir: string, outputDir: string, batchSize?: number): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Calculate trust scores for all users
|
|
92
|
+
*/
|
|
93
|
+
calculateTrustScores(enrichedCalls: EnrichedTradingCall[]): Promise<TrustScore[]>;
|
|
94
|
+
private chainStringToEnum;
|
|
95
|
+
private getTokenInfo;
|
|
96
|
+
private searchTokenBySymbol;
|
|
97
|
+
private getCurrentPrice;
|
|
98
|
+
private simulatePriceWindow;
|
|
99
|
+
private calculateConvictionAccuracy;
|
|
100
|
+
/**
|
|
101
|
+
* Get static token mappings for well-known tokens
|
|
102
|
+
*/
|
|
103
|
+
private getStaticTokenMapping;
|
|
104
|
+
/**
|
|
105
|
+
* Search for token using Birdeye API
|
|
106
|
+
*/
|
|
107
|
+
private searchTokenOnBirdeye;
|
|
108
|
+
/**
|
|
109
|
+
* Search for token using DexScreener API
|
|
110
|
+
*/
|
|
111
|
+
private searchTokenOnDexscreener;
|
|
112
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { UUID } from "@elizaos/core";
|
|
2
|
+
import type { SimulatedToken } from "../mockPriceService";
|
|
3
|
+
import { Conviction, type SupportedChain } from "../types";
|
|
4
|
+
import type { TokenScenario } from "./tokenSimulationService";
|
|
5
|
+
export interface SimulatedCallV2 {
|
|
6
|
+
callId: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
username: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
tokenMentioned: string;
|
|
11
|
+
tokenAddress: string;
|
|
12
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
13
|
+
conviction: Conviction;
|
|
14
|
+
content: string;
|
|
15
|
+
chain: SupportedChain;
|
|
16
|
+
certainty: "high" | "medium" | "low";
|
|
17
|
+
llmReasoning: string;
|
|
18
|
+
}
|
|
19
|
+
export type ActorArchetypeV2 = "elite_analyst" | "skilled_trader" | "pump_chaser" | "rug_promoter" | "fomo_trader" | "contrarian" | "whale_watcher" | "technical_analyst" | "newbie" | "bot_spammer";
|
|
20
|
+
export interface SimulatedActorV2 {
|
|
21
|
+
id: UUID;
|
|
22
|
+
username: string;
|
|
23
|
+
archetype: ActorArchetypeV2;
|
|
24
|
+
trustScore?: number;
|
|
25
|
+
callHistory: SimulatedCallV2[];
|
|
26
|
+
preferences: {
|
|
27
|
+
favoriteTokenTypes?: TokenScenario["type"][];
|
|
28
|
+
callFrequency: "high" | "medium" | "low";
|
|
29
|
+
timingBias: "early" | "middle" | "late" | "random";
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare class SimulationActorsServiceV2 {
|
|
33
|
+
private actors;
|
|
34
|
+
constructor();
|
|
35
|
+
private initializeActors;
|
|
36
|
+
private addActor;
|
|
37
|
+
generateCallsForActor(actor: SimulatedActorV2, token: SimulatedToken, tokenScenario: TokenScenario, currentStep: number, priceHistory: {
|
|
38
|
+
step: number;
|
|
39
|
+
price: number;
|
|
40
|
+
}[]): SimulatedCallV2 | null;
|
|
41
|
+
private shouldMakeCall;
|
|
42
|
+
private determineSentiment;
|
|
43
|
+
private determineConviction;
|
|
44
|
+
private generateCallContent;
|
|
45
|
+
private determineCertainty;
|
|
46
|
+
private generateReasoning;
|
|
47
|
+
getAllActors(): SimulatedActorV2[];
|
|
48
|
+
getActorById(id: UUID): SimulatedActorV2 | undefined;
|
|
49
|
+
getExpectedRankings(): {
|
|
50
|
+
username: string;
|
|
51
|
+
expectedTrustScore: number;
|
|
52
|
+
}[];
|
|
53
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { UUID } from "@elizaos/core";
|
|
2
|
+
import { Conviction, SupportedChain } from "../types";
|
|
3
|
+
export declare enum TokenScenario {
|
|
4
|
+
RUG_PULL_FAST = "rug_fast",
|
|
5
|
+
RUG_PULL_SLOW = "rug_slow",
|
|
6
|
+
SCAM_TOKEN = "scam",
|
|
7
|
+
RUNNER_MOON = "runner_moon",
|
|
8
|
+
RUNNER_STEADY = "runner_steady",
|
|
9
|
+
SUCCESSFUL = "successful",
|
|
10
|
+
MEDIOCRE = "mediocre",
|
|
11
|
+
STAGNANT = "stagnant",
|
|
12
|
+
BLUE_CHIP = "bluechip",
|
|
13
|
+
PUMP_AND_DUMP = "pump_dump",
|
|
14
|
+
SLOW_BLEED = "slow_bleed"
|
|
15
|
+
}
|
|
16
|
+
export interface TokenPrice {
|
|
17
|
+
timestamp: Date;
|
|
18
|
+
price: number;
|
|
19
|
+
volume: number;
|
|
20
|
+
liquidity: number;
|
|
21
|
+
marketCap: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ActorConfig {
|
|
24
|
+
id: UUID;
|
|
25
|
+
username: string;
|
|
26
|
+
archetype: "elite_analyst" | "skilled_trader" | "pump_chaser" | "rug_promoter" | "fomo_trader" | "contrarian" | "technical_analyst" | "newbie" | "bot_spammer";
|
|
27
|
+
expectedTrustScore: number;
|
|
28
|
+
tokenPreferences: TokenScenario[];
|
|
29
|
+
callFrequency: "high" | "medium" | "low";
|
|
30
|
+
timingBias: "early" | "middle" | "late" | "random";
|
|
31
|
+
}
|
|
32
|
+
export interface SimulatedCallData {
|
|
33
|
+
callId: UUID;
|
|
34
|
+
originalMessageId: string;
|
|
35
|
+
userId: string;
|
|
36
|
+
username: string;
|
|
37
|
+
timestamp: number;
|
|
38
|
+
content: string;
|
|
39
|
+
nameMentioned?: string;
|
|
40
|
+
tokenMentioned?: string;
|
|
41
|
+
caMentioned?: string;
|
|
42
|
+
chain: SupportedChain | "unknown";
|
|
43
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
44
|
+
conviction: Conviction;
|
|
45
|
+
llmReasoning: string;
|
|
46
|
+
certainty: "high" | "medium" | "low";
|
|
47
|
+
fileSource: string;
|
|
48
|
+
simulationMetadata: {
|
|
49
|
+
tokenScenario: TokenScenario;
|
|
50
|
+
actorArchetype: string;
|
|
51
|
+
priceAtCall: number;
|
|
52
|
+
marketCapAtCall: number;
|
|
53
|
+
liquidityAtCall: number;
|
|
54
|
+
expectedOutcome: "profit" | "loss" | "neutral";
|
|
55
|
+
actualProfit?: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface SimulationToken {
|
|
59
|
+
address: string;
|
|
60
|
+
symbol: string;
|
|
61
|
+
name: string;
|
|
62
|
+
scenario: TokenScenario;
|
|
63
|
+
launchTime: Date;
|
|
64
|
+
initialPrice: number;
|
|
65
|
+
initialMarketCap: number;
|
|
66
|
+
initialLiquidity: number;
|
|
67
|
+
priceTrajectory?: (step: number) => number;
|
|
68
|
+
}
|
|
69
|
+
export interface SimulationConfig {
|
|
70
|
+
startTime: Date;
|
|
71
|
+
endTime: Date;
|
|
72
|
+
timeStepMinutes: number;
|
|
73
|
+
tokenCount: number;
|
|
74
|
+
tokenScenarioDistribution?: Partial<Record<TokenScenario, number>>;
|
|
75
|
+
actors: ActorConfig[];
|
|
76
|
+
outputDir: string;
|
|
77
|
+
cacheResults: boolean;
|
|
78
|
+
}
|
|
79
|
+
export interface SimulationResult {
|
|
80
|
+
calls: SimulatedCallData[];
|
|
81
|
+
tokens: Map<string, SimulationToken>;
|
|
82
|
+
priceHistory: Map<string, TokenPrice[]>;
|
|
83
|
+
actorPerformance: Map<string, {
|
|
84
|
+
totalCalls: number;
|
|
85
|
+
profitableCalls: number;
|
|
86
|
+
totalProfit: number;
|
|
87
|
+
averageProfit: number;
|
|
88
|
+
trustScore?: number;
|
|
89
|
+
}>;
|
|
90
|
+
}
|
|
91
|
+
export declare class SimulationRunner {
|
|
92
|
+
private tokenService;
|
|
93
|
+
constructor();
|
|
94
|
+
runSimulation(config: SimulationConfig): Promise<SimulationResult>;
|
|
95
|
+
private calculateTokenPrice;
|
|
96
|
+
private mapScenarioToTypes;
|
|
97
|
+
private generateTokens;
|
|
98
|
+
private selectScenarioByWeight;
|
|
99
|
+
private createToken;
|
|
100
|
+
private getScenarioConfig;
|
|
101
|
+
private generateCallsForTimeStep;
|
|
102
|
+
private shouldActorCall;
|
|
103
|
+
private selectTokensForActor;
|
|
104
|
+
private generateActorCall;
|
|
105
|
+
private generateMessage;
|
|
106
|
+
private determineActorSentiment;
|
|
107
|
+
private determineActorConviction;
|
|
108
|
+
private predictOutcome;
|
|
109
|
+
private calculateActualProfits;
|
|
110
|
+
private cacheResults;
|
|
111
|
+
loadCachedSimulation(outputDir: string): Promise<SimulationResult | null>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type SimulatedToken } from "../mockPriceService";
|
|
2
|
+
export interface TokenScenario {
|
|
3
|
+
type: "rug" | "scam" | "runner" | "successful" | "mediocre" | "stagnant" | "bluechip" | "pump_dump" | "slow_bleed";
|
|
4
|
+
name: string;
|
|
5
|
+
symbol: string;
|
|
6
|
+
description: string;
|
|
7
|
+
initialPrice: number;
|
|
8
|
+
initialLiquidity: number;
|
|
9
|
+
initialMarketCap: number;
|
|
10
|
+
rugTiming?: number;
|
|
11
|
+
pumpTiming?: number;
|
|
12
|
+
dumpTiming?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class TokenSimulationService {
|
|
15
|
+
private scenarios;
|
|
16
|
+
constructor();
|
|
17
|
+
private initializeScenarios;
|
|
18
|
+
private addScenario;
|
|
19
|
+
createTokenFromScenario(scenario: TokenScenario): SimulatedToken;
|
|
20
|
+
private mapScenarioToPerformanceType;
|
|
21
|
+
private createRugTrajectory;
|
|
22
|
+
private createScamTrajectory;
|
|
23
|
+
private createRunnerTrajectory;
|
|
24
|
+
private createSuccessfulTrajectory;
|
|
25
|
+
private createMediocreTrajectory;
|
|
26
|
+
private createStagnantTrajectory;
|
|
27
|
+
private createBluechipTrajectory;
|
|
28
|
+
private createPumpDumpTrajectory;
|
|
29
|
+
private createSlowBleedTrajectory;
|
|
30
|
+
getAllScenarios(): TokenScenario[];
|
|
31
|
+
getScenarioBySymbol(symbol: string): TokenScenario | undefined;
|
|
32
|
+
generateDiverseTokenSet(): SimulatedToken[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type SimulationConfig, type SimulationResult } from "./simulationRunner";
|
|
2
|
+
export interface TrustScoreResult {
|
|
3
|
+
userId: string;
|
|
4
|
+
username: string;
|
|
5
|
+
calculatedScore: number;
|
|
6
|
+
expectedScore: number;
|
|
7
|
+
difference: number;
|
|
8
|
+
metrics: {
|
|
9
|
+
totalCalls: number;
|
|
10
|
+
profitableCalls: number;
|
|
11
|
+
averageProfit: number;
|
|
12
|
+
winRate: number;
|
|
13
|
+
sharpeRatio: number;
|
|
14
|
+
alpha: number;
|
|
15
|
+
volumePenalty: number;
|
|
16
|
+
consistency: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface OptimizationResult {
|
|
20
|
+
scores: TrustScoreResult[];
|
|
21
|
+
accuracy: {
|
|
22
|
+
mae: number;
|
|
23
|
+
rmse: number;
|
|
24
|
+
correlation: number;
|
|
25
|
+
rankingAccuracy: number;
|
|
26
|
+
};
|
|
27
|
+
suggestions: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface TrustScoreParameters {
|
|
30
|
+
profitWeight: number;
|
|
31
|
+
consistencyWeight: number;
|
|
32
|
+
volumeWeight: number;
|
|
33
|
+
alphaWeight: number;
|
|
34
|
+
sharpeWeight: number;
|
|
35
|
+
minCallsThreshold: number;
|
|
36
|
+
volumePenaltyThreshold: number;
|
|
37
|
+
timeDecayFactor: number;
|
|
38
|
+
rugPullPenalty: number;
|
|
39
|
+
}
|
|
40
|
+
export declare class TrustScoreOptimizer {
|
|
41
|
+
private simulationRunner;
|
|
42
|
+
private currentParams;
|
|
43
|
+
private balancedCalculator;
|
|
44
|
+
constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Run a full optimization cycle
|
|
47
|
+
*/
|
|
48
|
+
runOptimizationCycle(simulationConfig?: SimulationConfig, useCache?: boolean): Promise<OptimizationResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Get simulation data, either from cache or by running new simulation
|
|
51
|
+
*/
|
|
52
|
+
private getSimulationData;
|
|
53
|
+
/**
|
|
54
|
+
* Create default set of actors for testing
|
|
55
|
+
*/
|
|
56
|
+
private createDefaultActors;
|
|
57
|
+
/**
|
|
58
|
+
* Calculate detailed metrics for an actor
|
|
59
|
+
*/
|
|
60
|
+
private calculateMetrics;
|
|
61
|
+
/**
|
|
62
|
+
* Calculate Sharpe ratio
|
|
63
|
+
*/
|
|
64
|
+
private calculateSharpeRatio;
|
|
65
|
+
/**
|
|
66
|
+
* Calculate market return (average of all token performances)
|
|
67
|
+
*/
|
|
68
|
+
private calculateMarketReturn;
|
|
69
|
+
/**
|
|
70
|
+
* Calculate consistency score
|
|
71
|
+
*/
|
|
72
|
+
private calculateConsistency;
|
|
73
|
+
/**
|
|
74
|
+
* Final optimized trust score calculation
|
|
75
|
+
*/
|
|
76
|
+
calculateFinalTrustScore(metrics: TrustScoreResult["metrics"], archetype?: string, rugPromotionPenalty?: number, goodCallBonus?: number): number;
|
|
77
|
+
/**
|
|
78
|
+
* Enhanced trust score calculation with token quality consideration
|
|
79
|
+
*/
|
|
80
|
+
calculateTrustScoresEnhanced(simulationData: SimulationResult): Promise<TrustScoreResult[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Evaluate accuracy of calculated scores vs expected
|
|
83
|
+
*/
|
|
84
|
+
private evaluateAccuracy;
|
|
85
|
+
/**
|
|
86
|
+
* Calculate Pearson correlation coefficient
|
|
87
|
+
*/
|
|
88
|
+
private calculateCorrelation;
|
|
89
|
+
/**
|
|
90
|
+
* Calculate ranking accuracy (% of correctly ordered pairs)
|
|
91
|
+
*/
|
|
92
|
+
private calculateRankingAccuracy;
|
|
93
|
+
/**
|
|
94
|
+
* Generate optimization suggestions based on results
|
|
95
|
+
*/
|
|
96
|
+
private generateSuggestions;
|
|
97
|
+
/**
|
|
98
|
+
* Log detailed results
|
|
99
|
+
*/
|
|
100
|
+
private logResults;
|
|
101
|
+
/**
|
|
102
|
+
* Grid search for optimal parameters
|
|
103
|
+
*/
|
|
104
|
+
optimizeParameters(parameterRanges: Partial<Record<keyof TrustScoreParameters, number[]>>, simulationConfig?: SimulationConfig): Promise<TrustScoreParameters>;
|
|
105
|
+
/**
|
|
106
|
+
* Generate all combinations of parameters for grid search
|
|
107
|
+
*/
|
|
108
|
+
private generateParameterCombinations;
|
|
109
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type { SimulatedActorV2 as SimulatedActor, SimulatedCallV2 as SimulatedCall, } from "./services/simulationActorsV2";
|
|
2
|
+
export * from "./services/simulationActorsV2";
|
|
3
|
+
import type { SimulatedActorV2 } from "./services/simulationActorsV2";
|
|
4
|
+
export type CallGenerationStrategy = (actor: any, token: any, currentStep: number, priceHistory: any[]) => any;
|
|
5
|
+
export interface SimulatedActorWithLegacy extends SimulatedActorV2 {
|
|
6
|
+
expectedTrustScore?: number;
|
|
7
|
+
callGenerationStrategy?: CallGenerationStrategy;
|
|
8
|
+
actorSpecificData?: {
|
|
9
|
+
calls?: any[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare const goodActorStrategy: CallGenerationStrategy;
|
|
13
|
+
export declare const badActorStrategy: CallGenerationStrategy;
|
|
14
|
+
export declare const neutralObserverStrategy: CallGenerationStrategy;
|
|
15
|
+
export declare const dataDrivenShillStrategy: CallGenerationStrategy;
|
|
16
|
+
export declare function parseDiscordDataToActors(_filePath: string, _runtime: any): Promise<SimulatedActorWithLegacy[]>;
|
|
17
|
+
export declare function createLegacyActor(params: {
|
|
18
|
+
id: string;
|
|
19
|
+
username: string;
|
|
20
|
+
archetype: string;
|
|
21
|
+
expectedTrustScore?: number;
|
|
22
|
+
callGenerationStrategy?: CallGenerationStrategy;
|
|
23
|
+
}): SimulatedActorWithLegacy;
|