Skip to content

Commit aa7ff57

Browse files
authored
Merge branch 'develop' into feature/add-coinmarketcap-plugin
2 parents 374e6ad + 235c523 commit aa7ff57

28 files changed

+3653
-776
lines changed

packages/plugin-anyone/src/actions/startAnyone.ts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
State,
77
type Action,
88
} from "@elizaos/core";
9-
import axios from "axios";
109
import { AnyoneClientService } from "../services/AnyoneClientService";
1110
import { AnyoneProxyService } from "../services/AnyoneProxyService";
1211

packages/plugin-letzai/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export const letzAiImageGeneration = {
258258
],
259259
};
260260

261-
const letzAIPlugin = {
261+
export const letzAIPlugin = {
262262
name: "letzai",
263263
actions: [letzAiImageGeneration],
264264
};

packages/plugin-letzai/tsconfig.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
"extends": "../core/tsconfig.json",
33
"compilerOptions": {
44
"outDir": "dist",
5-
"rootDir": "src",
6-
"types": [
7-
"node"
8-
]
5+
"rootDir": "./src",
6+
"declaration": true
97
},
108
"include": [
11-
"src/**/*.ts"
9+
"src"
1210
]
1311
}

packages/plugin-letzai/tsup.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ export default defineConfig({
1515
"https",
1616
"http",
1717
"agentkeepalive",
18-
"zod",
1918
// Add other modules you want to externalize
2019
],
2120
});
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@elizaos/plugin-rabbi-trader",
3+
"version": "0.1.5-alpha.5",
4+
"main": "dist/index.js",
5+
"type": "module",
6+
"types": "dist/index.d.ts",
7+
"dependencies": {
8+
"@elizaos/core": "workspace:*",
9+
"@elizaos/client-twitter":"workspace:*",
10+
"@elizaos/plugin-solana":"workspace:*",
11+
"@elizaos/plugin-trustdb":"workspace:*",
12+
"@solana/web3.js": "^1.87.6",
13+
"zod":"3.23.8",
14+
"@goat-sdk/core": "0.3.8",
15+
"@goat-sdk/plugin-erc20": "0.1.7",
16+
"@goat-sdk/wallet-viem": "0.1.3",
17+
"node-cache": "^5.1.2",
18+
"bignumber": "1.1.0",
19+
"bignumber.js": "9.1.2",
20+
"@goat-sdk/plugin-coingecko":"0.1.4",
21+
"tsup": "8.3.5",
22+
"ws": "^8.0.0"
23+
},
24+
"scripts": {
25+
"build": "tsup --format esm --dts",
26+
"dev": "tsup --format esm --dts --watch"
27+
},
28+
"peerDependencies": {
29+
"whatwg-url": "7.1.0"
30+
}
31+
}
+179
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Rabbi Trader Plugin
2+
3+
An automated cryptocurrency trading plugin for Solana tokens with integrated trust scoring, market analysis, and Twitter notifications.
4+
5+
## Features
6+
7+
- Automated trading on Solana blockchain
8+
- Real-time market data analysis using DexScreener
9+
- Trust score evaluation for tokens
10+
- Twitter integration for trade notifications
11+
- Safety limits and risk management
12+
- Simulation capabilities before executing trades
13+
- Performance tracking and trade history
14+
- Rate limiting and cache management
15+
16+
## Installation
17+
18+
```bash
19+
npm install @elizaos/plugin-rabbi-trader
20+
```
21+
22+
## Prerequisites
23+
24+
The following environment variables need to be configured:
25+
26+
- `WALLET_PRIVATE_KEY`: Your Solana wallet private key
27+
- `WALLET_PUBLIC_KEY`: Your Solana wallet public address
28+
- `RPC_URL`: Solana RPC endpoint (defaults to mainnet)
29+
- `BIRDEYE_API_KEY`: API key for Birdeye data provider
30+
- `TWITTER_ENABLED`: Enable/disable Twitter notifications
31+
- `TWITTER_USERNAME`: Twitter username for notifications
32+
- `DEXSCREENER_WATCHLIST_ID`: DexScreener watchlist identifier
33+
- `COINGECKO_API_KEY`: CoinGecko API key for additional market data
34+
35+
## Usage
36+
37+
```typescript
38+
import createRabbiTraderPlugin from '@elizaos/plugin-rabbi-trader';
39+
import { IAgentRuntime } from '@elizaos/core';
40+
41+
const plugin = await createRabbiTraderPlugin(
42+
(key: string) => process.env[key],
43+
runtime
44+
);
45+
46+
// Plugin will automatically start monitoring and trading if enabled
47+
```
48+
49+
## Configuration
50+
51+
### Safety Limits
52+
53+
The plugin includes built-in safety limits that can be configured:
54+
55+
```typescript
56+
export const SAFETY_LIMITS = {
57+
MINIMUM_TRADE: 0.01, // Minimum SOL per trade
58+
MAX_POSITION_SIZE: 0.1, // Maximum 10% of token liquidity
59+
MAX_SLIPPAGE: 0.05, // Maximum 5% slippage allowed
60+
MIN_LIQUIDITY: 1000, // Minimum $1000 liquidity required
61+
MIN_VOLUME: 2000, // Minimum $2000 24h volume required
62+
MIN_TRUST_SCORE: 0.4, // Minimum trust score to trade
63+
STOP_LOSS: 0.2, // 20% stop loss trigger
64+
TAKE_PROFIT: 0.12, // Take profit at 12% gain
65+
TRAILING_STOP: 0.2 // 20% trailing stop from highest
66+
};
67+
```
68+
69+
### Trading Parameters
70+
71+
Default trading parameters can be adjusted in the configuration:
72+
73+
```typescript
74+
{
75+
CHECK_INTERVAL: 5 * 60 * 1000, // Check every 5 minutes
76+
REENTRY_DELAY: 60 * 60 * 1000, // Wait 1 hour before re-entering
77+
MAX_ACTIVE_POSITIONS: 5, // Maximum concurrent positions
78+
MIN_WALLET_BALANCE: 0.05 // Keep minimum 0.05 SOL in wallet
79+
}
80+
```
81+
82+
## API Integration
83+
84+
The plugin integrates with multiple APIs:
85+
86+
- **Birdeye API**: Market data and token security information
87+
- **DexScreener**: Real-time trading data and market analysis
88+
- **Twitter**: Trade notifications and updates
89+
- **Jupiter**: Token swaps and liquidity aggregation
90+
91+
## Error Handling
92+
93+
The plugin includes comprehensive error handling for common scenarios:
94+
95+
```typescript
96+
export const ERROR_SIGNATURES = [
97+
{
98+
sig: "0x13be252b",
99+
name: "InsufficientAllowance",
100+
description: "Token allowance too low"
101+
},
102+
{
103+
sig: "0xf4d678b8",
104+
name: "InsufficientBalance",
105+
description: "Insufficient token balance"
106+
},
107+
// ... additional error signatures
108+
];
109+
```
110+
111+
## Trade Analysis
112+
113+
The plugin performs detailed analysis before executing trades:
114+
115+
1. Token security evaluation
116+
2. Market data analysis
117+
3. Trust score calculation
118+
4. Liquidity assessment
119+
5. Volume verification
120+
6. Price movement analysis
121+
7. Holder distribution review
122+
123+
## Twitter Integration
124+
125+
When enabled, the plugin can post trade notifications with:
126+
127+
- Token information
128+
- Trade details (buy/sell price, amount)
129+
- Trust score and risk level
130+
- Market metrics
131+
- Transaction signature
132+
- Profit/loss for sells
133+
134+
## Caching
135+
136+
The plugin implements multiple caching mechanisms:
137+
138+
- Token analysis cache (20 minutes)
139+
- Twitter rate limiting cache (hourly limits)
140+
- Skip/wait cache (2 hours)
141+
- Analysis history (24 hours)
142+
143+
## Development
144+
145+
### Building
146+
147+
```bash
148+
npm run build
149+
```
150+
151+
### Development Mode
152+
153+
```bash
154+
npm run dev
155+
```
156+
157+
## Dependencies
158+
159+
Key dependencies include:
160+
161+
- `@solana/web3.js`: Solana blockchain interaction
162+
- `@elizaos/core`: Core agent runtime
163+
- `@elizaos/plugin-solana`: Solana integration
164+
- `@elizaos/plugin-trustdb`: Trust score database
165+
- `node-cache`: Caching functionality
166+
- `bignumber.js`: Precise number handling
167+
168+
## Contributing
169+
170+
1. Fork the repository
171+
2. Create your feature branch
172+
3. Commit your changes
173+
4. Push to the branch
174+
5. Create a new Pull Request
175+
176+
## License
177+
178+
This project is licensed under the MIT License - see the LICENSE file for details.
179+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import { analyzeTradeAction } from "./actions/analyzeTrade";
2+
export const actions = [analyzeTradeAction];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import {
2+
Action,
3+
composeContext,
4+
elizaLogger,
5+
generateText,
6+
ModelClass,
7+
parseJSONObjectFromText,
8+
} from "@elizaOS/core";
9+
10+
export const analyzeTradeAction: Action = {
11+
name: "ANALYZE_TRADE",
12+
description: "Analyze a token for trading opportunities",
13+
similes: [
14+
"ANALYZE",
15+
"ANALYZE_TOKEN",
16+
"TRADE",
17+
"ANALYZE_TRADE",
18+
"EVALUATE",
19+
"ASSESS",
20+
],
21+
examples: [],
22+
validate: async () => true,
23+
handler: async (runtime, memory, state, params, callback) => {
24+
try {
25+
// composeState
26+
if (!state) {
27+
state = await runtime.composeState(memory);
28+
} else state = await runtime.updateRecentMessageState(state);
29+
30+
const tokenData = {
31+
walletBalance: params.walletBalance,
32+
tokenAddress: params.tokenAddress,
33+
price: params.price,
34+
volume: params.volume,
35+
marketCap: params.marketCap,
36+
liquidity: params.liquidity,
37+
holderDistribution: params.holderDistribution,
38+
trustScore: params.trustScore,
39+
dexscreener: params.dexscreener,
40+
position: params.position,
41+
};
42+
43+
// Direct prompt instead of template
44+
const prompt = `Analyze the following token data and provide a trading recommendation.
45+
Return the response as a JSON object with the following structure:
46+
{
47+
"recommendation": "BUY" | "SELL" | "HOLD",
48+
"confidence": number (0-100),
49+
"reasoning": string,
50+
"risks": string[],
51+
"opportunities": string[]
52+
}
53+
54+
Token Data:
55+
${JSON.stringify(tokenData, null, 2)}`;
56+
57+
// Generate analysis using direct prompt
58+
const content = await generateText({
59+
runtime,
60+
context: prompt,
61+
modelClass: ModelClass.LARGE,
62+
});
63+
64+
if (!content) {
65+
throw new Error("No analysis generated");
66+
}
67+
68+
elizaLogger.log(`Raw analysis response:`, content);
69+
70+
// Parse the response to get the recommended action
71+
const recommendation = parseJSONObjectFromText(content);
72+
elizaLogger.log(
73+
`Parsed recommendation for ${params.tokenAddress}:`,
74+
recommendation,
75+
);
76+
77+
// Send result through callback
78+
if (callback) {
79+
await callback({
80+
text: JSON.stringify(recommendation),
81+
type: "analysis",
82+
});
83+
}
84+
85+
return true;
86+
} catch (error) {
87+
elizaLogger.error(`Analysis failed:`, {
88+
error: error instanceof Error ? error.message : "Unknown error",
89+
stack: error instanceof Error ? error.stack : undefined,
90+
});
91+
return false;
92+
}
93+
},
94+
};

0 commit comments

Comments
 (0)