Skip to content

Commit c35f06b

Browse files
committed
Rate limit for birdeye
1 parent 9266a2c commit c35f06b

10 files changed

Lines changed: 539 additions & 69 deletions

File tree

.env.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ PRIVATE_KEY=your_base58_private_key_here
88
# API Keys (optional but recommended)
99
COINGECKO_API_KEY=your_coingecko_api_key
1010
DUNE_API_KEY=your_dune_api_key
11+
BIRDEYE_API_KEY=
1112

1213
# Strategy Configuration
1314
CONFIG_FILE=config/strategy.json

JUPITER_MIGRATION.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# Jupiter API Migration Guide
2+
3+
## Overview ✅
4+
5+
Successfully migrated from CoinGecko to Jupiter ecosystem APIs for comprehensive token data fetching. This provides better coverage for Solana tokens and more reliable data sources.
6+
7+
## What Changed
8+
9+
### ❌ Removed: CoinGecko Dependencies
10+
- Removed CoinGecko API integration
11+
- Removed `COINGECKO_API_KEY` environment variable
12+
- Eliminated CoinGecko-specific market data endpoints
13+
14+
### ✅ Added: Jupiter + Birdeye Integration
15+
- **Jupiter Price API v6**: Real-time token prices
16+
- **Jupiter Tokens API**: Token metadata and information
17+
- **Birdeye API**: Comprehensive market data, liquidity, social metrics, and historical data
18+
19+
## New Data Sources
20+
21+
### 1. Price Data
22+
**Source**: Jupiter Price API v6
23+
```
24+
https://price.jup.ag/v6/price?ids={mint}
25+
```
26+
- ✅ Real-time prices for all Jupiter-supported tokens
27+
- ✅ High reliability and low latency
28+
- ✅ Free to use
29+
30+
### 2. Market Data (Market Cap, Volume)
31+
**Primary**: Birdeye API
32+
```
33+
https://public-api.birdeye.so/defi/token_overview?address={mint}
34+
```
35+
**Fallback**: Jupiter Tokens API
36+
```
37+
https://tokens.jup.ag/tokens/{mint}
38+
```
39+
- ✅ Market capitalization
40+
- ✅ 24h trading volume
41+
- ✅ Liquidity data
42+
- ✅ Automatic fallback system
43+
44+
### 3. Historical Data
45+
**Source**: Birdeye History API
46+
```
47+
https://public-api.birdeye.so/defi/history_price
48+
```
49+
- ✅ Multi-day price history
50+
- ✅ Accurate volatility calculations
51+
- ✅ Fallback to simulated data if API unavailable
52+
53+
### 4. Social Metrics
54+
**Source**: Birdeye Social API
55+
```
56+
https://public-api.birdeye.so/defi/token_social
57+
```
58+
- ✅ Twitter followers
59+
- ✅ Telegram members
60+
- ✅ Website verification
61+
- ✅ 24h activity metrics
62+
- ✅ Calculated composite social score (0-100)
63+
64+
### 5. Token Age
65+
**Source**: Birdeye Creation Info + Jupiter Tokens
66+
- ✅ Actual token creation timestamps
67+
- ✅ Accurate age calculations in days
68+
- ✅ Fallback mechanisms
69+
70+
### 6. Liquidity Data
71+
**Source**: Multi-source aggregation
72+
- ✅ Birdeye liquidity pools
73+
- ✅ Jupiter DEX aggregation
74+
- ✅ Cross-validation between sources
75+
76+
## API Key Requirements
77+
78+
### Required: Birdeye API Key
79+
```bash
80+
BIRDEYE_API_KEY=your_birdeye_api_key
81+
```
82+
83+
**How to get Birdeye API Key**:
84+
1. Visit [Birdeye.so](https://birdeye.so)
85+
2. Sign up for an account
86+
3. Go to API section
87+
4. Generate your API key
88+
5. Add to your `.env` file
89+
90+
### Optional: Dune Analytics (for advanced analytics)
91+
```bash
92+
DUNE_API_KEY=your_dune_analytics_api_key
93+
```
94+
95+
## Benefits of the Migration
96+
97+
### 🚀 **Better Solana Coverage**
98+
- Jupiter covers virtually all Solana tokens
99+
- Real-time data from the largest Solana DEX aggregator
100+
- Better price discovery for meme tokens
101+
102+
### 📊 **More Comprehensive Data**
103+
- Social metrics integration
104+
- Real historical price data
105+
- Multi-source liquidity aggregation
106+
- Token age verification
107+
108+
### 💰 **Cost Effectiveness**
109+
- Jupiter Price API is free
110+
- Birdeye offers generous free tier
111+
- Reduced API costs compared to CoinGecko Pro
112+
113+
### **Better Performance**
114+
- Lower latency for Solana-native APIs
115+
- Fallback mechanisms for reliability
116+
- Optimized for meme token data
117+
118+
## Configuration Updates
119+
120+
### Environment Variables
121+
**Old**:
122+
```bash
123+
COINGECKO_API_KEY=your_coingecko_key
124+
DUNE_API_KEY=your_dune_key
125+
```
126+
127+
**New**:
128+
```bash
129+
BIRDEYE_API_KEY=your_birdeye_key
130+
DUNE_API_KEY=your_dune_key # Optional
131+
```
132+
133+
### Strategy Config
134+
No changes required to `config/strategy.json` - all token configurations remain the same.
135+
136+
## Testing the Migration
137+
138+
### 1. Update Environment
139+
```bash
140+
# Copy the new template
141+
cp env.template .env
142+
143+
# Add your Birdeye API key
144+
BIRDEYE_API_KEY=your_actual_birdeye_key
145+
```
146+
147+
### 2. Test Data Fetching
148+
```bash
149+
npm run build
150+
npm start
151+
```
152+
153+
### 3. Verify Data Quality
154+
Check logs for successful data fetching:
155+
```
156+
✓ DataProvider initialized with Jupiter APIs
157+
✓ Token screening completed: Passed: X tokens
158+
```
159+
160+
## API Rate Limits
161+
162+
### Jupiter (Free)
163+
- Price API: No explicit limits
164+
- High throughput for price queries
165+
166+
### Birdeye (Free Tier)
167+
- 1000 requests/day
168+
- Sufficient for strategy operations
169+
- Upgrade available for higher volume
170+
171+
## Troubleshooting
172+
173+
### Issue: Missing Birdeye API Key
174+
**Error**: API calls failing or returning limited data
175+
**Solution**: Add `BIRDEYE_API_KEY` to your `.env` file
176+
177+
### Issue: Rate Limit Exceeded
178+
**Error**: 429 responses from Birdeye
179+
**Solution**:
180+
1. Reduce polling frequency
181+
2. Upgrade to paid Birdeye plan
182+
3. Fallback to Jupiter-only data
183+
184+
### Issue: Token Not Found
185+
**Error**: No data for specific token
186+
**Solution**:
187+
1. Verify token mint address
188+
2. Check if token is listed on Jupiter
189+
3. Ensure token has sufficient liquidity
190+
191+
## Migration Checklist
192+
193+
- ✅ Updated DataProvider to use Jupiter + Birdeye APIs
194+
- ✅ Removed CoinGecko dependencies
195+
- ✅ Added comprehensive fallback mechanisms
196+
- ✅ Updated environment configuration
197+
- ✅ Enhanced social metrics calculation
198+
- ✅ Improved historical data accuracy
199+
- ✅ Added multi-source liquidity aggregation
200+
- ✅ Maintained backward compatibility
201+
- ✅ Added proper error handling and logging
202+
203+
## Next Steps
204+
205+
1. **Get Birdeye API Key**: Sign up at birdeye.so
206+
2. **Update Environment**: Add `BIRDEYE_API_KEY` to `.env`
207+
3. **Test Strategy**: Run with real data
208+
4. **Monitor Performance**: Check data quality and API reliability
209+
5. **Consider Upgrades**: Evaluate paid plans for higher volume
210+
211+
The migration to Jupiter APIs provides better data quality, coverage, and cost-effectiveness for Solana meme token strategies! 🚀

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ This strategy implements the meme-pool fee-harvest methodology described in the
3232
### Prerequisites
3333
- Node.js 18+ and npm
3434
- Solana wallet with SOL for gas fees
35-
- API keys for CoinGecko (optional but recommended)
35+
- API key for Birdeye (recommended for comprehensive data)
3636

3737
### Installation
3838

@@ -208,7 +208,7 @@ All activities are logged with different levels:
208208
```
209209
src/
210210
├── types/ # TypeScript type definitions
211-
├── providers/ # Data providers (CoinGecko, Jupiter, etc.)
211+
├── providers/ # Data providers (Jupiter, Birdeye, etc.)
212212
├── managers/ # Position and risk managers
213213
├── utils/ # Utilities (logger, etc.)
214214
├── strategy.ts # Main strategy implementation

config/strategy.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,18 @@
5252
},
5353
"tokens": [
5454
{
55-
"symbol": "BONK",
56-
"mint": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
55+
"symbol": "USDC",
56+
"mint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
5757
"enabled": true
5858
},
5959
{
60-
"symbol": "WIF",
61-
"mint": "EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm",
60+
"symbol": "USDT",
61+
"mint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
6262
"enabled": true
6363
},
6464
{
65-
"symbol": "PENGU",
66-
"mint": "2zMMhcVQEXDtdE6vsFS7S7D5oUodfJHE8vd1gnBouauv",
65+
"symbol": "RAY",
66+
"mint": "4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R",
6767
"enabled": true
6868
}
6969
],

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ services:
1111
- NODE_ENV=production
1212
- SOLANA_RPC_URL=${SOLANA_RPC_URL:-https://api.mainnet-beta.solana.com}
1313
- PRIVATE_KEY=${PRIVATE_KEY}
14-
- COINGECKO_API_KEY=${COINGECKO_API_KEY}
14+
- BIRDEYE_API_KEY=${BIRDEYE_API_KEY}
1515
- DUNE_API_KEY=${DUNE_API_KEY}
1616
- LOG_LEVEL=${LOG_LEVEL:-info}
1717
volumes:
@@ -38,7 +38,7 @@ services:
3838
- NODE_ENV=development
3939
- SOLANA_RPC_URL=${SOLANA_RPC_URL:-https://api.devnet.solana.com}
4040
- PRIVATE_KEY=${PRIVATE_KEY}
41-
- COINGECKO_API_KEY=${COINGECKO_API_KEY}
41+
- BIRDEYE_API_KEY=${BIRDEYE_API_KEY}
4242
- DUNE_API_KEY=${DUNE_API_KEY}
4343
- LOG_LEVEL=${LOG_LEVEL:-debug}
4444
volumes:

env.template

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
77

88
# Wallet Configuration (CRITICAL - KEEP SECURE)
99
# Your private key can be in multiple formats - see PRIVATE_KEY_SETUP.md for details
10-
# Examples:
11-
# Base58: PRIVATE_KEY=5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
1210
# JSON Array: PRIVATE_KEY='[1,2,3,...,64]'
1311
# Comma-separated: PRIVATE_KEY="1,2,3,...,64"
1412
# Hex: PRIVATE_KEY=0123456789abcdef...
1513
PRIVATE_KEY=your_private_key_here
1614

1715
# API Keys
18-
COINGECKO_API_KEY=your_coingecko_api_key_here
16+
# Get your free Birdeye API key at: https://docs.birdeye.so/reference/getting-started
17+
BIRDEYE_API_KEY=your_birdeye_api_key_here
1918
DUNE_API_KEY=your_dune_analytics_api_key_here
2019

2120
# Logging Configuration

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@coral-xyz/anchor": "^0.29.0",
3131
"@meteora-ag/dlmm": "^1.0.0",
3232
"@solana/spl-token": "^0.3.9",
33-
"@solana/web3.js": "^1.87.6",
33+
"@solana/web3.js": "^1.98.2",
3434
"axios": "^1.6.0",
3535
"bn.js": "^5.2.1",
3636
"bs58": "^6.0.0",

0 commit comments

Comments
 (0)