@rlajous/sdk-trading 1.0.0

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 (65) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +160 -0
  3. package/dist/cjs/client.js +139 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/index.js +24 -0
  6. package/dist/cjs/index.js.map +1 -0
  7. package/dist/cjs/package.json +1 -0
  8. package/dist/cjs/resources/holder-analysis.js +102 -0
  9. package/dist/cjs/resources/holder-analysis.js.map +1 -0
  10. package/dist/cjs/resources/index.js +10 -0
  11. package/dist/cjs/resources/index.js.map +1 -0
  12. package/dist/cjs/resources/tokens.js +175 -0
  13. package/dist/cjs/resources/tokens.js.map +1 -0
  14. package/dist/cjs/resources/trading-lite.js +85 -0
  15. package/dist/cjs/resources/trading-lite.js.map +1 -0
  16. package/dist/cjs/types/holder-analysis.js +3 -0
  17. package/dist/cjs/types/holder-analysis.js.map +1 -0
  18. package/dist/cjs/types/index.js +3 -0
  19. package/dist/cjs/types/index.js.map +1 -0
  20. package/dist/cjs/types/tokens.js +3 -0
  21. package/dist/cjs/types/tokens.js.map +1 -0
  22. package/dist/cjs/types/trading-lite.js +3 -0
  23. package/dist/cjs/types/trading-lite.js.map +1 -0
  24. package/dist/esm/client.js +135 -0
  25. package/dist/esm/client.js.map +1 -0
  26. package/dist/esm/index.js +7 -0
  27. package/dist/esm/index.js.map +1 -0
  28. package/dist/esm/package.json +1 -0
  29. package/dist/esm/resources/holder-analysis.js +98 -0
  30. package/dist/esm/resources/holder-analysis.js.map +1 -0
  31. package/dist/esm/resources/index.js +4 -0
  32. package/dist/esm/resources/index.js.map +1 -0
  33. package/dist/esm/resources/tokens.js +171 -0
  34. package/dist/esm/resources/tokens.js.map +1 -0
  35. package/dist/esm/resources/trading-lite.js +81 -0
  36. package/dist/esm/resources/trading-lite.js.map +1 -0
  37. package/dist/esm/types/holder-analysis.js +2 -0
  38. package/dist/esm/types/holder-analysis.js.map +1 -0
  39. package/dist/esm/types/index.js +2 -0
  40. package/dist/esm/types/index.js.map +1 -0
  41. package/dist/esm/types/tokens.js +2 -0
  42. package/dist/esm/types/tokens.js.map +1 -0
  43. package/dist/esm/types/trading-lite.js +2 -0
  44. package/dist/esm/types/trading-lite.js.map +1 -0
  45. package/dist/types/client.d.ts +123 -0
  46. package/dist/types/client.d.ts.map +1 -0
  47. package/dist/types/index.d.ts +5 -0
  48. package/dist/types/index.d.ts.map +1 -0
  49. package/dist/types/resources/holder-analysis.d.ts +73 -0
  50. package/dist/types/resources/holder-analysis.d.ts.map +1 -0
  51. package/dist/types/resources/index.d.ts +4 -0
  52. package/dist/types/resources/index.d.ts.map +1 -0
  53. package/dist/types/resources/tokens.d.ts +117 -0
  54. package/dist/types/resources/tokens.d.ts.map +1 -0
  55. package/dist/types/resources/trading-lite.d.ts +64 -0
  56. package/dist/types/resources/trading-lite.d.ts.map +1 -0
  57. package/dist/types/types/holder-analysis.d.ts +214 -0
  58. package/dist/types/types/holder-analysis.d.ts.map +1 -0
  59. package/dist/types/types/index.d.ts +4 -0
  60. package/dist/types/types/index.d.ts.map +1 -0
  61. package/dist/types/types/tokens.d.ts +148 -0
  62. package/dist/types/types/tokens.d.ts.map +1 -0
  63. package/dist/types/types/trading-lite.d.ts +72 -0
  64. package/dist/types/types/trading-lite.d.ts.map +1 -0
  65. package/package.json +74 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Webacy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,160 @@
1
+ # @rlajous/sdk-trading
2
+
3
+ Token trading analysis SDK for the Webacy Risk Score API. Analyze token holder distribution, detect snipers and bundlers, and identify trading patterns.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @rlajous/sdk-trading
9
+ ```
10
+
11
+ Or install the full SDK:
12
+
13
+ ```bash
14
+ npm install @rlajous/sdk
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { TradingClient } from '@rlajous/sdk-trading';
21
+
22
+ const client = new TradingClient({
23
+ apiKey: process.env.WEBACY_API_KEY!,
24
+ });
25
+
26
+ // Analyze token holder distribution
27
+ const holders = await client.holderAnalysis.get('token_address', {
28
+ chain: 'sol',
29
+ });
30
+
31
+ console.log(`Sniper count: ${holders.sniper_analysis?.sniper_count}`);
32
+ console.log(`Bundled buyers: ${holders.first_buyers_analysis.bundled_buyers_count}`);
33
+ ```
34
+
35
+ ## Features
36
+
37
+ ### Holder Analysis
38
+
39
+ Comprehensive token holder distribution analysis with sniper and bundler detection.
40
+
41
+ ```typescript
42
+ const holders = await client.holderAnalysis.get('token_address', {
43
+ chain: 'sol',
44
+ });
45
+
46
+ // First buyers analysis
47
+ const fba = holders.first_buyers_analysis;
48
+ console.log(`Initially acquired: ${fba.initially_acquired_percentage}%`);
49
+ console.log(`Top 10 buyers bought: ${fba.top_10_buyers_bought_percentage}%`);
50
+ console.log(`Bundled buyers: ${fba.bundled_buyers_count}`);
51
+ console.log(`Still holding: ${fba.buyers_still_holding_count}`);
52
+
53
+ // Sniper analysis
54
+ const sa = holders.sniper_analysis;
55
+ console.log(`Sniper count: ${sa?.sniper_count}`);
56
+ console.log(`Sniper percentage: ${sa?.sniper_total_percentage}%`);
57
+ console.log(`Confidence score: ${sa?.sniper_confidence_score}/100`);
58
+
59
+ // Top holders
60
+ const top10 = holders.top_10_holders_analysis;
61
+ console.log(`Top 10 hold: ${top10?.percentageHeldByTop10}%`);
62
+ ```
63
+
64
+ ### Trading Lite (Solana)
65
+
66
+ Simplified trading analysis optimized for Solana tokens.
67
+
68
+ ```typescript
69
+ const analysis = await client.tradingLite.analyze('pump_token_address');
70
+
71
+ console.log(`Sniper % on Launch: ${analysis.SniperPercentageOnLaunch}%`);
72
+ console.log(`Bundler % on Launch: ${analysis.BundlerPercentageOnLaunch}%`);
73
+ console.log(`Sniper % Holding: ${analysis.SniperPercentageHolding}%`);
74
+ console.log(`Bundler % Holding: ${analysis.BundlerPercentageHolding}%`);
75
+ console.log(`Dev Holding: ${analysis.DevHoldingPercentage}%`);
76
+ console.log(`Top 10 Holding: ${analysis.Top10HoldingPercentage}%`);
77
+ ```
78
+
79
+ ### Trending Tokens
80
+
81
+ Discover trending tokens with risk data.
82
+
83
+ ```typescript
84
+ const trending = await client.tokens.getTrending({ chain: 'sol' });
85
+
86
+ for (const token of trending.tokens) {
87
+ console.log(`${token.name} (${token.symbol})`);
88
+ console.log(` Price: $${token.price}`);
89
+ console.log(` Volume: $${token.volume_24h}`);
90
+ }
91
+ ```
92
+
93
+ ### Token Pools
94
+
95
+ Get liquidity pool data for tokens.
96
+
97
+ ```typescript
98
+ const pools = await client.tokens.getPools('token_address', { chain: 'sol' });
99
+
100
+ for (const pool of pools.pools) {
101
+ console.log(`${pool.name} on ${pool.dex}`);
102
+ console.log(` Liquidity: $${pool.liquidity}`);
103
+ }
104
+
105
+ // Get trending pools
106
+ const trendingPools = await client.tokens.getTrendingPools({ chain: 'sol' });
107
+ ```
108
+
109
+ ## API Reference
110
+
111
+ ### TradingClient
112
+
113
+ ```typescript
114
+ const client = new TradingClient({
115
+ apiKey: string; // Required: Your Webacy API key
116
+ baseUrl?: string; // Optional: Custom API URL
117
+ timeout?: number; // Optional: Request timeout (ms)
118
+ retry?: RetryConfig; // Optional: Retry configuration
119
+ });
120
+ ```
121
+
122
+ ### Resources
123
+
124
+ | Resource | Method | Description |
125
+ |----------|--------|-------------|
126
+ | `holderAnalysis` | `get(address, options)` | Get holder distribution analysis |
127
+ | `tradingLite` | `analyze(address, options?)` | Get simplified trading analysis |
128
+ | `tokens` | `getTrending(options)` | Get trending tokens |
129
+ | `tokens` | `getPools(address, options)` | Get liquidity pools for token |
130
+ | `tokens` | `getTrendingPools(options)` | Get trending liquidity pools |
131
+
132
+ ## Supported Chains
133
+
134
+ - Solana (`sol`) - Full support including Trading Lite
135
+ - Ethereum (`eth`) - Holder analysis
136
+ - Base (`base`) - Holder analysis
137
+ - BSC (`bsc`) - Holder analysis
138
+ - Polygon (`pol`) - Holder analysis
139
+ - Arbitrum (`arb`) - Holder analysis
140
+ - Optimism (`opt`) - Holder analysis
141
+
142
+ ## Error Handling
143
+
144
+ ```typescript
145
+ import { TradingClient, RateLimitError, NotFoundError } from '@rlajous/sdk-trading';
146
+
147
+ try {
148
+ const holders = await client.holderAnalysis.get('token', { chain: 'sol' });
149
+ } catch (error) {
150
+ if (error instanceof RateLimitError) {
151
+ console.log(`Rate limited. Retry after ${error.retryAfter}s`);
152
+ } else if (error instanceof NotFoundError) {
153
+ console.log('Token not found');
154
+ }
155
+ }
156
+ ```
157
+
158
+ ## License
159
+
160
+ MIT
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TradingClient = void 0;
4
+ const sdk_core_1 = require("@rlajous/sdk-core");
5
+ const holder_analysis_1 = require("./resources/holder-analysis");
6
+ const trading_lite_1 = require("./resources/trading-lite");
7
+ const tokens_1 = require("./resources/tokens");
8
+ /**
9
+ * Webacy Trading SDK Client
10
+ *
11
+ * Provides access to token trading analysis including holder analysis,
12
+ * sniper/bundler detection, and trending tokens.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { TradingClient, Chain } from '@rlajous/sdk-trading';
17
+ *
18
+ * const client = new TradingClient({
19
+ * apiKey: process.env.WEBACY_API_KEY!,
20
+ * });
21
+ *
22
+ * // Comprehensive holder analysis
23
+ * const holders = await client.holderAnalysis.get('token_address', {
24
+ * chain: 'sol',
25
+ * });
26
+ *
27
+ * // Quick trading analysis (Solana)
28
+ * const trading = await client.tradingLite.analyze('pump_token');
29
+ *
30
+ * // Token pools and trending
31
+ * const pools = await client.tokens.getPools('token_address', { chain: 'eth' });
32
+ * ```
33
+ */
34
+ class TradingClient extends sdk_core_1.BaseClient {
35
+ /**
36
+ * Holder analysis resource
37
+ *
38
+ * Provides comprehensive analysis of token holder distribution including:
39
+ * - Top holders and concentration metrics
40
+ * - First buyers analysis
41
+ * - Sniper detection with confidence scoring
42
+ * - Bundler detection
43
+ * - Developer wallet tracking
44
+ */
45
+ holderAnalysis;
46
+ /**
47
+ * Trading lite resource
48
+ *
49
+ * Provides quick, simplified token analysis optimized for trading decisions.
50
+ * Currently supports Solana only.
51
+ */
52
+ tradingLite;
53
+ /**
54
+ * Tokens resource
55
+ *
56
+ * Provides access to token pools and trending data.
57
+ */
58
+ tokens;
59
+ /**
60
+ * Create a new TradingClient instance
61
+ *
62
+ * @param config - Client configuration
63
+ * @throws AuthenticationError if API key is not provided
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * // Basic setup
68
+ * const client = new TradingClient({
69
+ * apiKey: 'your-api-key',
70
+ * });
71
+ *
72
+ * // With default chain (omit chain in API calls)
73
+ * const client = new TradingClient({
74
+ * apiKey: 'your-api-key',
75
+ * defaultChain: Chain.SOL,
76
+ * });
77
+ *
78
+ * // With custom configuration
79
+ * const client = new TradingClient({
80
+ * apiKey: 'your-api-key',
81
+ * timeout: 60000,
82
+ * retry: {
83
+ * maxRetries: 5,
84
+ * },
85
+ * });
86
+ * ```
87
+ */
88
+ constructor(config) {
89
+ super(config);
90
+ // Initialize resources with the HTTP client and default chain
91
+ this.holderAnalysis = new holder_analysis_1.HolderAnalysisResource(this.httpClient, this.defaultChain);
92
+ this.tradingLite = new trading_lite_1.TradingLiteResource(this.httpClient, this.defaultChain);
93
+ this.tokens = new tokens_1.TokensResource(this.httpClient, this.defaultChain);
94
+ }
95
+ /**
96
+ * Add a request interceptor
97
+ *
98
+ * @example
99
+ * ```typescript
100
+ * client.addRequestInterceptor((url, config) => {
101
+ * console.log(`Making request to ${url}`);
102
+ * return config;
103
+ * });
104
+ * ```
105
+ */
106
+ addRequestInterceptor(interceptor) {
107
+ super.addRequestInterceptor(interceptor);
108
+ }
109
+ /**
110
+ * Add a response interceptor
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * client.addResponseInterceptor((response) => {
115
+ * console.log(`Received ${response.status} response`);
116
+ * return response;
117
+ * });
118
+ * ```
119
+ */
120
+ addResponseInterceptor(interceptor) {
121
+ super.addResponseInterceptor(interceptor);
122
+ }
123
+ /**
124
+ * Add an error interceptor
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * client.addErrorInterceptor((error) => {
129
+ * console.error(`Request failed: ${error.message}`);
130
+ * return error;
131
+ * });
132
+ * ```
133
+ */
134
+ addErrorInterceptor(interceptor) {
135
+ super.addErrorInterceptor(interceptor);
136
+ }
137
+ }
138
+ exports.TradingClient = TradingClient;
139
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,gDAM2B;AAC3B,iEAAqE;AACrE,2DAA+D;AAC/D,+CAAoD;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,aAAc,SAAQ,qBAAU;IAC3C;;;;;;;;;OASG;IACa,cAAc,CAAyB;IAEvD;;;;;OAKG;IACa,WAAW,CAAsB;IAEjD;;;;OAIG;IACa,MAAM,CAAiB;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,8DAA8D;QAC9D,IAAI,CAAC,cAAc,GAAG,IAAI,wCAAsB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACrF,IAAI,CAAC,WAAW,GAAG,IAAI,kCAAmB,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAC/E,IAAI,CAAC,MAAM,GAAG,IAAI,uBAAc,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;OAUG;IACM,qBAAqB,CAAC,WAA+B;QAC5D,KAAK,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;IAED;;;;;;;;;;OAUG;IACM,sBAAsB,CAAC,WAAgC;QAC9D,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED;;;;;;;;;;OAUG;IACM,mBAAmB,CAAC,WAA6B;QACxD,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;CACF;AA9GD,sCA8GC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NetworkError = exports.NotFoundError = exports.ValidationError = exports.RateLimitError = exports.AuthenticationError = exports.WebacyError = exports.CHAIN_NAMES = exports.isEvmChain = exports.ChainCompatibility = exports.Chain = exports.TokensResource = exports.TradingLiteResource = exports.HolderAnalysisResource = exports.TradingClient = void 0;
4
+ // Client
5
+ var client_1 = require("./client");
6
+ Object.defineProperty(exports, "TradingClient", { enumerable: true, get: function () { return client_1.TradingClient; } });
7
+ // Resources
8
+ var resources_1 = require("./resources");
9
+ Object.defineProperty(exports, "HolderAnalysisResource", { enumerable: true, get: function () { return resources_1.HolderAnalysisResource; } });
10
+ Object.defineProperty(exports, "TradingLiteResource", { enumerable: true, get: function () { return resources_1.TradingLiteResource; } });
11
+ Object.defineProperty(exports, "TokensResource", { enumerable: true, get: function () { return resources_1.TokensResource; } });
12
+ // Re-export commonly used types from core
13
+ var sdk_core_1 = require("@rlajous/sdk-core");
14
+ Object.defineProperty(exports, "Chain", { enumerable: true, get: function () { return sdk_core_1.Chain; } });
15
+ Object.defineProperty(exports, "ChainCompatibility", { enumerable: true, get: function () { return sdk_core_1.ChainCompatibility; } });
16
+ Object.defineProperty(exports, "isEvmChain", { enumerable: true, get: function () { return sdk_core_1.isEvmChain; } });
17
+ Object.defineProperty(exports, "CHAIN_NAMES", { enumerable: true, get: function () { return sdk_core_1.CHAIN_NAMES; } });
18
+ Object.defineProperty(exports, "WebacyError", { enumerable: true, get: function () { return sdk_core_1.WebacyError; } });
19
+ Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return sdk_core_1.AuthenticationError; } });
20
+ Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return sdk_core_1.RateLimitError; } });
21
+ Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return sdk_core_1.ValidationError; } });
22
+ Object.defineProperty(exports, "NotFoundError", { enumerable: true, get: function () { return sdk_core_1.NotFoundError; } });
23
+ Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return sdk_core_1.NetworkError; } });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,SAAS;AACT,mCAAyC;AAAhC,uGAAA,aAAa,OAAA;AAEtB,YAAY;AACZ,yCAA0F;AAAjF,mHAAA,sBAAsB,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAAE,2GAAA,cAAc,OAAA;AAgCpE,0CAA0C;AAC1C,8CAe2B;AAdzB,iGAAA,KAAK,OAAA;AACL,8GAAA,kBAAkB,OAAA;AAClB,sGAAA,UAAU,OAAA;AACV,uGAAA,WAAW,OAAA;AACX,uGAAA,WAAW,OAAA;AACX,+GAAA,mBAAmB,OAAA;AACnB,0GAAA,cAAc,OAAA;AACd,2GAAA,eAAe,OAAA;AACf,yGAAA,aAAa,OAAA;AACb,wGAAA,YAAY,OAAA"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HolderAnalysisResource = void 0;
4
+ const sdk_core_1 = require("@rlajous/sdk-core");
5
+ /**
6
+ * Resource for token holder analysis
7
+ *
8
+ * Provides comprehensive analysis of token holder distribution including:
9
+ * - Top holders and concentration metrics
10
+ * - First buyers analysis
11
+ * - Sniper detection with confidence scoring
12
+ * - Bundler detection
13
+ * - Developer wallet tracking
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const analysis = await client.holderAnalysis.get('token_address', {
18
+ * chain: Chain.SOL,
19
+ * });
20
+ * console.log(`Sniper count: ${analysis.sniper_analysis?.sniper_count}`);
21
+ *
22
+ * // With default chain configured, chain can be omitted
23
+ * const client = new TradingClient({ apiKey: '...', defaultChain: Chain.SOL });
24
+ * const analysis = await client.holderAnalysis.get('token_address'); // Uses SOL
25
+ * ```
26
+ */
27
+ class HolderAnalysisResource {
28
+ httpClient;
29
+ defaultChain;
30
+ constructor(httpClient, defaultChain) {
31
+ this.httpClient = httpClient;
32
+ this.defaultChain = defaultChain;
33
+ }
34
+ /**
35
+ * Resolve the chain to use for a request
36
+ * @throws ValidationError if no chain is specified and no default is set
37
+ */
38
+ resolveChain(options) {
39
+ const chain = options?.chain ?? this.defaultChain;
40
+ if (!chain) {
41
+ throw new sdk_core_1.ValidationError('Chain is required. Either specify chain in options or set defaultChain in client configuration.');
42
+ }
43
+ return chain;
44
+ }
45
+ /**
46
+ * Get comprehensive holder analysis for a token
47
+ *
48
+ * Returns detailed analysis including:
49
+ * - Token holder distribution
50
+ * - First buyers analysis with bundler detection
51
+ * - Sniper detection with confidence scoring
52
+ * - Top 10 holders concentration
53
+ * - Developer activity metrics
54
+ *
55
+ * @param address - Token address to analyze
56
+ * @param options - Request options (chain is optional if defaultChain is set)
57
+ * @returns Complete holder analysis result
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * // Solana token analysis
62
+ * const result = await client.holderAnalysis.get('pump_token_address', {
63
+ * chain: Chain.SOL,
64
+ * });
65
+ *
66
+ * // With default chain configured
67
+ * const result = await client.holderAnalysis.get('pump_token_address');
68
+ *
69
+ * // Check sniper activity
70
+ * if (result.sniper_analysis?.sniper_count > 0) {
71
+ * console.log(`Found ${result.sniper_analysis.sniper_count} snipers`);
72
+ * console.log(`Sniper confidence: ${result.sniper_analysis.sniper_confidence_score}`);
73
+ * }
74
+ *
75
+ * // Check bundler activity
76
+ * const bundledBuyers = result.first_buyers_analysis.bundled_buyers_count;
77
+ * if (bundledBuyers && bundledBuyers > 0) {
78
+ * console.log(`Found ${bundledBuyers} bundled buyers`);
79
+ * }
80
+ * ```
81
+ */
82
+ async get(address, options = {}) {
83
+ const chain = this.resolveChain(options);
84
+ // Validate token address format before making API call
85
+ if (!(0, sdk_core_1.isValidAddress)(address, chain)) {
86
+ const chainName = sdk_core_1.CHAIN_NAMES[chain] || chain;
87
+ throw new sdk_core_1.ValidationError(`Invalid ${chainName} token address: "${address}". Please provide a valid token address format for the ${chainName} blockchain.`);
88
+ }
89
+ const queryParams = new URLSearchParams();
90
+ queryParams.append('chain', chain);
91
+ if (options.disableRefetch !== undefined) {
92
+ queryParams.append('disableRefetch', String(options.disableRefetch));
93
+ }
94
+ const response = await this.httpClient.get(`/holder-analysis/${encodeURIComponent(address)}?${queryParams.toString()}`, {
95
+ timeout: options.timeout,
96
+ signal: options.signal,
97
+ });
98
+ return response.data;
99
+ }
100
+ }
101
+ exports.HolderAnalysisResource = HolderAnalysisResource;
102
+ //# sourceMappingURL=holder-analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"holder-analysis.js","sourceRoot":"","sources":["../../../src/resources/holder-analysis.ts"],"names":[],"mappings":";;;AAAA,gDAO2B;AAG3B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,sBAAsB;IAEd;IACA;IAFnB,YACmB,UAAsB,EACtB,YAAoB;QADpB,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAQ;IACpC,CAAC;IAEJ;;;OAGG;IACK,YAAY,CAAC,OAA2B;QAC9C,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC;QAClD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,0BAAe,CACvB,iGAAiG,CAClG,CAAC;QACJ,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,KAAK,CAAC,GAAG,CAAC,OAAe,EAAE,UAAiC,EAAE;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAEzC,uDAAuD;QACvD,IAAI,CAAC,IAAA,yBAAc,EAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,SAAS,GAAG,sBAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;YAC9C,MAAM,IAAI,0BAAe,CACvB,WAAW,SAAS,oBAAoB,OAAO,0DAA0D,SAAS,cAAc,CACjI,CAAC;QACJ,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,eAAe,EAAE,CAAC;QAC1C,WAAW,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAEnC,IAAI,OAAO,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACzC,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,QAAQ,GAAuC,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAC5E,oBAAoB,kBAAkB,CAAC,OAAO,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,EAAE,EAC3E;YACE,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AArFD,wDAqFC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokensResource = exports.TradingLiteResource = exports.HolderAnalysisResource = void 0;
4
+ var holder_analysis_1 = require("./holder-analysis");
5
+ Object.defineProperty(exports, "HolderAnalysisResource", { enumerable: true, get: function () { return holder_analysis_1.HolderAnalysisResource; } });
6
+ var trading_lite_1 = require("./trading-lite");
7
+ Object.defineProperty(exports, "TradingLiteResource", { enumerable: true, get: function () { return trading_lite_1.TradingLiteResource; } });
8
+ var tokens_1 = require("./tokens");
9
+ Object.defineProperty(exports, "TokensResource", { enumerable: true, get: function () { return tokens_1.TokensResource; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/resources/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2D;AAAlD,yHAAA,sBAAsB,OAAA;AAC/B,+CAAqD;AAA5C,mHAAA,mBAAmB,OAAA;AAC5B,mCAA0C;AAAjC,wGAAA,cAAc,OAAA"}
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokensResource = void 0;
4
+ const sdk_core_1 = require("@rlajous/sdk-core");
5
+ /**
6
+ * Resource for token pools and trending data
7
+ *
8
+ * Provides access to:
9
+ * - Token liquidity pools with risk analysis
10
+ * - Trending tokens across chains
11
+ * - Trending liquidity pools
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Get trending tokens
16
+ * const trending = await client.tokens.getTrending({ chain: Chain.SOL });
17
+ *
18
+ * // Get pools for a specific token
19
+ * const pools = await client.tokens.getPools('token_address', { chain: Chain.ETH });
20
+ *
21
+ * // With default chain configured, chain can be omitted
22
+ * const client = new TradingClient({ apiKey: '...', defaultChain: Chain.SOL });
23
+ * const pools = await client.tokens.getPools('token_address'); // Uses SOL
24
+ * ```
25
+ */
26
+ class TokensResource {
27
+ httpClient;
28
+ defaultChain;
29
+ constructor(httpClient, defaultChain) {
30
+ this.httpClient = httpClient;
31
+ this.defaultChain = defaultChain;
32
+ }
33
+ /**
34
+ * Resolve the chain to use for a request
35
+ * @throws ValidationError if no chain is specified and no default is set
36
+ */
37
+ resolveChain(options) {
38
+ const chain = options?.chain ?? this.defaultChain;
39
+ if (!chain) {
40
+ throw new sdk_core_1.ValidationError('Chain is required. Either specify chain in options or set defaultChain in client configuration.');
41
+ }
42
+ return chain;
43
+ }
44
+ /**
45
+ * Get liquidity pools for a token with risk analysis
46
+ *
47
+ * Returns all liquidity pools where the token is traded,
48
+ * along with risk analysis for the tokens in each pool.
49
+ *
50
+ * @param address - Token address
51
+ * @param options - Request options (chain is optional if defaultChain is set)
52
+ * @returns Pools with token risk analysis
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const result = await client.tokens.getPools('0x...', { chain: Chain.ETH });
57
+ *
58
+ * // With default chain configured
59
+ * const result = await client.tokens.getPools('0x...');
60
+ *
61
+ * for (const pool of result.pools) {
62
+ * console.log(`Pool: ${pool.name}`);
63
+ * console.log(`Liquidity: ${pool.reserve}`);
64
+ * console.log(`24h Volume: ${pool.volume.h24}`);
65
+ * }
66
+ *
67
+ * // Check risk for tokens in pools
68
+ * for (const token of result.tokens) {
69
+ * if (token.risk.overallRisk && token.risk.overallRisk > 70) {
70
+ * console.warn(`High risk token: ${token.address}`);
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ async getPools(address, options = {}) {
76
+ const chain = this.resolveChain(options);
77
+ // Validate token address format before making API call
78
+ if (!(0, sdk_core_1.isValidAddress)(address, chain)) {
79
+ const chainName = sdk_core_1.CHAIN_NAMES[chain] || chain;
80
+ throw new sdk_core_1.ValidationError(`Invalid ${chainName} token address: "${address}". Please provide a valid token address format for the ${chainName} blockchain.`);
81
+ }
82
+ const queryParams = new URLSearchParams();
83
+ queryParams.append('chain', chain);
84
+ const response = await this.httpClient.get(`/tokens/${encodeURIComponent(address)}/pools?${queryParams.toString()}`, {
85
+ timeout: options.timeout,
86
+ signal: options.signal,
87
+ });
88
+ return response.data;
89
+ }
90
+ /**
91
+ * Get trending tokens
92
+ *
93
+ * Returns currently trending tokens based on trading activity
94
+ * and community interest.
95
+ *
96
+ * @param options - Request options (chain is optional)
97
+ * @returns List of trending tokens with risk analysis
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const trending = await client.tokens.getTrending({ chain: Chain.SOL, limit: 20 });
102
+ *
103
+ * // Or with default chain configured
104
+ * const trending = await client.tokens.getTrending();
105
+ *
106
+ * for (const token of trending.tokens) {
107
+ * console.log(`${token.symbol}: $${token.price_usd}`);
108
+ * console.log(`24h change: ${token.price_change_24h}%`);
109
+ *
110
+ * if (token.risk?.overallRisk && token.risk.overallRisk > 50) {
111
+ * console.warn(' Warning: Elevated risk');
112
+ * }
113
+ * }
114
+ * ```
115
+ */
116
+ async getTrending(options = {}) {
117
+ const queryParams = new URLSearchParams();
118
+ const chain = options.chain ?? this.defaultChain;
119
+ if (chain) {
120
+ queryParams.append('chain', chain);
121
+ }
122
+ if (options.limit !== undefined) {
123
+ queryParams.append('limit', String(options.limit));
124
+ }
125
+ const queryString = queryParams.toString();
126
+ const path = queryString ? `/tokens/trending?${queryString}` : '/tokens/trending';
127
+ const response = await this.httpClient.get(path, {
128
+ timeout: options.timeout,
129
+ signal: options.signal,
130
+ });
131
+ return response.data;
132
+ }
133
+ /**
134
+ * Get trending liquidity pools
135
+ *
136
+ * Returns currently trending liquidity pools based on
137
+ * trading volume and activity.
138
+ *
139
+ * @param options - Request options (chain is optional)
140
+ * @returns List of trending pools
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const trending = await client.tokens.getTrendingPools({ chain: Chain.ETH });
145
+ *
146
+ * // Or with default chain configured
147
+ * const trending = await client.tokens.getTrendingPools();
148
+ *
149
+ * for (const pool of trending.pools) {
150
+ * console.log(`${pool.name}`);
151
+ * console.log(`FDV: ${pool.fdv}`);
152
+ * console.log(`24h Volume: ${pool.volume.h24}`);
153
+ * }
154
+ * ```
155
+ */
156
+ async getTrendingPools(options = {}) {
157
+ const queryParams = new URLSearchParams();
158
+ const chain = options.chain ?? this.defaultChain;
159
+ if (chain) {
160
+ queryParams.append('chain', chain);
161
+ }
162
+ if (options.limit !== undefined) {
163
+ queryParams.append('limit', String(options.limit));
164
+ }
165
+ const queryString = queryParams.toString();
166
+ const path = queryString ? `/tokens/pools/trending?${queryString}` : '/tokens/pools/trending';
167
+ const response = await this.httpClient.get(path, {
168
+ timeout: options.timeout,
169
+ signal: options.signal,
170
+ });
171
+ return response.data;
172
+ }
173
+ }
174
+ exports.TokensResource = TokensResource;
175
+ //# sourceMappingURL=tokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/resources/tokens.ts"],"names":[],"mappings":";;;AAAA,gDAO2B;AAS3B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,cAAc;IAEN;IACA;IAFnB,YACmB,UAAsB,EACtB,YAAoB;QADpB,eAAU,GAAV,UAAU,CAAY;QACtB,iBAAY,GAAZ,YAAY,CAAQ;IACpC,CAAC;IAEJ;;;OAGG;IACK,YAAY,CAAC,OAA2B;QAC9C,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC;QACl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