@gala-chain/launchpad-mcp-server 1.13.4 → 1.13.5

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 (61) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/generated/version.d.ts +1 -1
  3. package/dist/generated/version.js +1 -1
  4. package/package.json +2 -2
  5. package/docs/AI-AGENT-PATTERNS.md +0 -555
  6. package/docs/CONSTRAINTS-REFERENCE.md +0 -454
  7. package/docs/PROMPT-TOOL-MAPPING.md +0 -352
  8. package/docs/examples/default-values-pattern.md +0 -240
  9. package/docs/examples/tool-factory-pattern.md +0 -217
  10. package/jest.config.js +0 -94
  11. package/src/__tests__/integration/poolTools.integration.test.ts +0 -185
  12. package/src/constants/mcpToolNames.ts +0 -141
  13. package/src/index.ts +0 -19
  14. package/src/prompts/__tests__/promptStructure.test.ts +0 -114
  15. package/src/prompts/__tests__/registry.test.ts +0 -143
  16. package/src/prompts/analysis.ts +0 -429
  17. package/src/prompts/index.ts +0 -127
  18. package/src/prompts/portfolio.ts +0 -242
  19. package/src/prompts/trading.ts +0 -191
  20. package/src/prompts/utility.ts +0 -43
  21. package/src/prompts/utils/workflowTemplates.ts +0 -344
  22. package/src/schemas/common-schemas.ts +0 -392
  23. package/src/scripts/test-all-prompts.ts +0 -184
  24. package/src/server.ts +0 -247
  25. package/src/tools/balance/index.ts +0 -174
  26. package/src/tools/creation/index.ts +0 -182
  27. package/src/tools/index.ts +0 -80
  28. package/src/tools/pools/fetchAllPools.ts +0 -47
  29. package/src/tools/pools/fetchAllPriceHistory.ts +0 -103
  30. package/src/tools/pools/fetchAllPrices.ts +0 -39
  31. package/src/tools/pools/fetchPoolDetails.ts +0 -27
  32. package/src/tools/pools/fetchPoolDetailsForCalculation.ts +0 -22
  33. package/src/tools/pools/fetchPools.ts +0 -47
  34. package/src/tools/pools/fetchPriceHistory.ts +0 -108
  35. package/src/tools/pools/fetchPrices.ts +0 -52
  36. package/src/tools/pools/index.ts +0 -248
  37. package/src/tools/social/index.ts +0 -64
  38. package/src/tools/trading/index.ts +0 -605
  39. package/src/tools/transfers/index.ts +0 -75
  40. package/src/tools/utils/clearCache.ts +0 -36
  41. package/src/tools/utils/createWallet.ts +0 -19
  42. package/src/tools/utils/explainSdkUsage.ts +0 -853
  43. package/src/tools/utils/getAddress.ts +0 -12
  44. package/src/tools/utils/getCacheInfo.ts +0 -14
  45. package/src/tools/utils/getConfig.ts +0 -11
  46. package/src/tools/utils/getEthereumAddress.ts +0 -12
  47. package/src/tools/utils/getUrlByTokenName.ts +0 -12
  48. package/src/tools/utils/getVersion.ts +0 -25
  49. package/src/tools/utils/index.ts +0 -27
  50. package/src/tools/utils/isTokenGraduated.ts +0 -16
  51. package/src/types/mcp.ts +0 -72
  52. package/src/utils/__tests__/validation.test.ts +0 -147
  53. package/src/utils/constraints.ts +0 -146
  54. package/src/utils/default-values.ts +0 -208
  55. package/src/utils/error-handler.ts +0 -69
  56. package/src/utils/error-templates.ts +0 -273
  57. package/src/utils/response-formatter.ts +0 -51
  58. package/src/utils/tool-factory.ts +0 -257
  59. package/src/utils/tool-registry.ts +0 -296
  60. package/src/utils/validation.ts +0 -336
  61. package/tsconfig.json +0 -23
@@ -1,853 +0,0 @@
1
- /**
2
- * SDK Usage Explanation Tool
3
- *
4
- * Provides detailed explanations and code examples for using the Gala Launchpad SDK directly.
5
- * Acts as a development reference showing how MCP tools map to SDK methods.
6
- */
7
-
8
- import type { MCPTool } from '../../types/mcp.js';
9
- import { withErrorHandling } from '../../utils/error-handler.js';
10
- import { formatSuccess } from '../../utils/response-formatter.js';
11
-
12
- /**
13
- * SDK code examples organized by topic
14
- */
15
- const SDK_EXAMPLES = {
16
- // Trading workflows
17
- 'buy-tokens': `
18
- ## Buying Tokens with SDK
19
-
20
- \`\`\`typescript
21
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
22
-
23
- async function buyTokens() {
24
- // 1. Create SDK instance
25
- const sdk = createLaunchpadSDK({
26
- wallet: 'your-private-key-or-mnemonic'
27
- });
28
-
29
- // 2. Calculate expected amounts FIRST (REQUIRED)
30
- const calculation = await sdk.calculateBuyAmount({
31
- tokenName: 'dragnrkti',
32
- amount: '100', // Spending 100 GALA
33
- type: 'native' // 'native' = GALA amount, 'exact' = token amount
34
- });
35
-
36
- console.log('Expected tokens:', calculation.amount);
37
- console.log('RBC Fee:', calculation.reverseBondingCurveFee);
38
- console.log('Transaction fee:', calculation.transactionFee);
39
-
40
- // 3. Execute buy with slippage protection
41
- const result = await sdk.buy({
42
- tokenName: 'dragnrkti',
43
- amount: '100',
44
- type: 'native',
45
- expectedAmount: calculation.amount, // REQUIRED: from step 2
46
- maxAcceptableReverseBondingCurveFee: calculation.reverseBondingCurveFee, // RECOMMENDED
47
- slippageToleranceFactor: 0.01 // 1% slippage tolerance (REQUIRED)
48
- });
49
-
50
- console.log('Transaction ID:', result.transactionId);
51
- console.log('GALA spent:', result.inputAmount);
52
- console.log('Tokens received:', result.outputAmount);
53
- console.log('Total fees:', result.totalFees);
54
- }
55
- \`\`\`
56
-
57
- **MCP Tool Equivalent:** \`gala_launchpad_buy_tokens\`
58
- `,
59
-
60
- 'sell-tokens': `
61
- ## Selling Tokens with SDK
62
-
63
- \`\`\`typescript
64
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
65
-
66
- async function sellTokens() {
67
- // 1. Create SDK instance
68
- const sdk = createLaunchpadSDK({
69
- wallet: 'your-private-key'
70
- });
71
-
72
- // 2. Calculate expected GALA FIRST (REQUIRED)
73
- const calculation = await sdk.calculateSellAmount({
74
- tokenName: 'dragnrkti',
75
- amount: '1000', // Selling 1000 tokens
76
- type: 'exact' // 'exact' = exact tokens, 'native' = target GALA amount
77
- });
78
-
79
- console.log('Expected GALA:', calculation.amount);
80
- console.log('RBC Fee:', calculation.reverseBondingCurveFee);
81
-
82
- // 3. Execute sell with slippage protection
83
- const result = await sdk.sell({
84
- tokenName: 'dragnrkti',
85
- amount: '1000',
86
- type: 'exact',
87
- expectedAmount: calculation.amount, // REQUIRED: from step 2
88
- maxAcceptableReverseBondingCurveFee: calculation.reverseBondingCurveFee, // RECOMMENDED
89
- slippageToleranceFactor: 0.01 // 1% slippage
90
- });
91
-
92
- console.log('Tokens sold:', result.inputAmount);
93
- console.log('GALA received:', result.outputAmount);
94
- }
95
- \`\`\`
96
-
97
- **MCP Tool Equivalent:** \`gala_launchpad_sell_tokens\`
98
- `,
99
-
100
- 'pool-graduation': `
101
- ## Pool Graduation with SDK
102
-
103
- \`\`\`typescript
104
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
105
-
106
- async function graduatePool() {
107
- const sdk = createLaunchpadSDK({
108
- wallet: 'your-private-key'
109
- });
110
-
111
- // Option 1: Calculate graduation cost first (recommended)
112
- const calculation = await sdk.calculateBuyAmountForGraduation('dragnrkti');
113
-
114
- console.log('GALA cost to graduate:', calculation.amount);
115
- console.log('RBC Fee:', calculation.reverseBondingCurveFee);
116
- console.log('Transaction fee:', calculation.transactionFee);
117
-
118
- // Check if you have enough balance
119
- const balance = await sdk.fetchGalaBalance();
120
- if (parseFloat(balance.balance) < parseFloat(calculation.amount)) {
121
- throw new Error('Insufficient GALA balance');
122
- }
123
-
124
- // Option 2: One-step graduation (convenience method)
125
- const result = await sdk.graduateToken({
126
- tokenName: 'dragnrkti',
127
- slippageToleranceFactor: 0.01 // Optional: defaults to SDK config
128
- });
129
-
130
- console.log('Pool graduated!');
131
- console.log('Transaction ID:', result.transactionId);
132
- console.log('Total GALA spent:', result.inputAmount);
133
- console.log('Tokens received:', result.outputAmount);
134
- }
135
- \`\`\`
136
-
137
- **MCP Tool Equivalents:**
138
- - \`gala_launchpad_calculate_buy_amount_for_graduation\`
139
- - \`gala_launchpad_graduate_token\`
140
- `,
141
-
142
- 'fetch-pools': `
143
- ## Fetching Pool Data with SDK
144
-
145
- \`\`\`typescript
146
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
147
-
148
- async function fetchPools() {
149
- const sdk = createLaunchpadSDK({
150
- wallet: 'your-private-key'
151
- });
152
-
153
- // Fetch recent pools with pagination
154
- const pools = await sdk.fetchPools({
155
- type: 'recent',
156
- limit: 10,
157
- page: 1
158
- });
159
-
160
- console.log(\`Found \${pools.total} pools\`);
161
- console.log(\`Page \${pools.page} of \${pools.totalPages}\`);
162
- console.log(\`Has next page: \${pools.hasNext}\`);
163
-
164
- pools.pools.forEach(pool => {
165
- console.log(\`\${pool.tokenName}: \${pool.tokenSymbol}\`);
166
- console.log(\`Creator: \${pool.creatorAddress}\`);
167
- console.log(\`Created: \${pool.createdAt}\`);
168
- });
169
-
170
- // Fetch specific pool details
171
- const details = await sdk.fetchPoolDetails('dragnrkti');
172
-
173
- console.log('Sale status:', details.saleStatus);
174
- console.log('Base price:', details.basePrice);
175
- console.log('Max supply:', details.maxSupply);
176
- console.log('Native token quantity:', details.nativeTokenQuantity);
177
- }
178
- \`\`\`
179
-
180
- **MCP Tool Equivalents:**
181
- - \`gala_launchpad_fetch_pools\`
182
- - \`gala_launchpad_fetch_pool_details\`
183
- `,
184
-
185
- 'balances': `
186
- ## Checking Balances with SDK
187
-
188
- \`\`\`typescript
189
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
190
-
191
- async function checkBalances() {
192
- const sdk = createLaunchpadSDK({
193
- wallet: 'your-private-key'
194
- });
195
-
196
- // Check GALA balance
197
- const galaBalance = await sdk.fetchGalaBalance();
198
- console.log(\`GALA: \${galaBalance.balance}\`);
199
- console.log(\`Decimals: \${galaBalance.decimals}\`);
200
- console.log(\`Last updated: \${galaBalance.lastUpdated.toISOString()}\`);
201
-
202
- // Check specific token balance
203
- const tokenBalance = await sdk.fetchTokenBalance({
204
- tokenName: 'dragnrkti',
205
- address: sdk.getAddress()
206
- });
207
-
208
- console.log(\`Token: \${tokenBalance.quantity}\`);
209
- console.log(\`USD value: $\${tokenBalance.holdingPriceUsd}\`);
210
- console.log(\`GALA value: \${tokenBalance.holdingPriceGala}\`);
211
-
212
- // Check all tokens held
213
- const portfolio = await sdk.fetchTokensHeld({
214
- address: sdk.getAddress(),
215
- limit: 20
216
- });
217
-
218
- console.log(\`Holding \${portfolio.total} different tokens\`);
219
- portfolio.tokens.forEach(token => {
220
- console.log(\`\${token.name}: \${token.quantity}\`);
221
- });
222
- }
223
- \`\`\`
224
-
225
- **MCP Tool Equivalents:**
226
- - \`gala_launchpad_fetch_gala_balance\`
227
- - \`gala_launchpad_fetch_token_balance\`
228
- - \`gala_launchpad_fetch_tokens_held\`
229
- `,
230
-
231
- 'token-creation': `
232
- ## Creating Tokens with SDK
233
-
234
- \`\`\`typescript
235
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
236
-
237
- async function launchToken() {
238
- const sdk = createLaunchpadSDK({
239
- wallet: 'your-private-key'
240
- });
241
-
242
- // 1. Check if name/symbol available
243
- const nameAvailable = await sdk.isTokenNameAvailable('mytoken');
244
- const symbolAvailable = await sdk.isTokenSymbolAvailable('MTK');
245
-
246
- if (!nameAvailable || !symbolAvailable) {
247
- throw new Error('Name or symbol already taken');
248
- }
249
-
250
- // 2. Check launch fee
251
- const launchFee = await sdk.fetchLaunchTokenFee();
252
- console.log(\`Launch fee: \${launchFee} GALA\`);
253
-
254
- // 3. Upload token image (Node.js only)
255
- const imageUpload = await sdk.uploadTokenImage({
256
- tokenName: 'mytoken',
257
- imagePath: '/path/to/image.png'
258
- });
259
-
260
- // 4. Launch the token
261
- const result = await sdk.launchToken({
262
- tokenName: 'mytoken',
263
- tokenSymbol: 'MTK',
264
- tokenDescription: 'My awesome token',
265
- tokenImage: imageUpload.imageUrl,
266
- websiteUrl: 'https://mytoken.com',
267
- twitterUrl: 'https://twitter.com/mytoken',
268
- preBuyQuantity: '100' // Optional: pre-buy with GALA
269
- });
270
-
271
- console.log('Token launched!');
272
- console.log('Transaction ID:', result.transactionId);
273
-
274
- // Get frontend URL
275
- const url = sdk.getUrlByTokenName('mytoken');
276
- console.log(\`View at: \${url}\`);
277
- }
278
- \`\`\`
279
-
280
- **MCP Tool Equivalents:**
281
- - \`gala_launchpad_check_token_name\`
282
- - \`gala_launchpad_check_token_symbol\`
283
- - \`gala_launchpad_fetch_launch_token_fee\`
284
- - \`gala_launchpad_upload_token_image\`
285
- - \`gala_launchpad_launch_token\`
286
- - \`gala_launchpad_get_url_by_token_name\`
287
- `,
288
-
289
- 'multi-wallet': `
290
- ## Multi-Wallet Support with SDK
291
-
292
- \`\`\`typescript
293
- import { createLaunchpadSDK, createWallet } from '@gala-chain/launchpad-sdk';
294
-
295
- async function multiWalletExample() {
296
- // Main SDK with your wallet
297
- const sdk = createLaunchpadSDK({
298
- wallet: 'your-main-private-key'
299
- });
300
-
301
- // Create a test wallet
302
- const testWallet = createWallet();
303
- console.log('Test wallet:', testWallet.address);
304
-
305
- // 1. Fund test wallet from main wallet
306
- await sdk.transferGala({
307
- recipientAddress: testWallet.address,
308
- amount: '1000'
309
- });
310
-
311
- // 2. Have test wallet buy tokens (using privateKey override)
312
- const buyCalc = await sdk.calculateBuyAmount({
313
- tokenName: 'dragnrkti',
314
- amount: '100',
315
- type: 'native'
316
- });
317
-
318
- const buyResult = await sdk.buy({
319
- tokenName: 'dragnrkti',
320
- amount: '100',
321
- type: 'native',
322
- expectedAmount: buyCalc.amount,
323
- slippageToleranceFactor: 0.01,
324
- privateKey: testWallet.privateKey // Override to use test wallet
325
- });
326
-
327
- console.log('Test wallet bought tokens');
328
-
329
- // 3. Have test wallet post comment
330
- await sdk.postComment({
331
- tokenName: 'dragnrkti',
332
- content: 'Great project!',
333
- privateKey: testWallet.privateKey // Test wallet posts
334
- });
335
-
336
- // 4. Check balances for both wallets
337
- const mainBalance = await sdk.fetchGalaBalance(); // Main wallet
338
- const testBalance = await sdk.fetchGalaBalance(testWallet.address); // Test wallet
339
-
340
- console.log(\`Main wallet: \${mainBalance.balance} GALA\`);
341
- console.log(\`Test wallet: \${testBalance.balance} GALA\`);
342
- }
343
- \`\`\`
344
-
345
- **Key Points:**
346
- - All signing operations support \`privateKey\` parameter
347
- - Creates temporary SDK instance internally
348
- - Supports: buy, sell, launchToken, transfers, comments, profile updates
349
- `,
350
-
351
- 'transfers': `
352
- ## Token Transfers with SDK
353
-
354
- \`\`\`typescript
355
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
356
-
357
- async function transferTokens() {
358
- const sdk = createLaunchpadSDK({
359
- wallet: 'your-private-key'
360
- });
361
-
362
- // Transfer GALA tokens
363
- const galaTransfer = await sdk.transferGala({
364
- recipientAddress: '0x1234...', // or 'eth|1234...'
365
- amount: '100',
366
- uniqueKey: 'galaconnect-operation-my-transfer-123' // Optional idempotency
367
- });
368
-
369
- console.log('GALA transfer ID:', galaTransfer.transactionId);
370
- console.log('Status:', galaTransfer.status);
371
-
372
- // Transfer launchpad tokens
373
- const tokenTransfer = await sdk.transferToken({
374
- to: 'eth|5678...',
375
- tokenName: 'dragnrkti',
376
- amount: '1000', // Token amount
377
- uniqueKey: 'galaconnect-operation-token-456'
378
- });
379
-
380
- console.log('Token transfer ID:', tokenTransfer.transactionId);
381
- }
382
- \`\`\`
383
-
384
- **Features:**
385
- - EIP-712 signatures for security
386
- - Supports both \`0x\` and \`eth|\` address formats
387
- - Optional idempotency keys prevent duplicates
388
- - Comprehensive validation
389
-
390
- **MCP Tool Equivalents:**
391
- - \`gala_launchpad_transfer_gala\`
392
- - \`gala_launchpad_transfer_token\`
393
- `,
394
-
395
- 'error-handling': `
396
- ## Error Handling with SDK
397
-
398
- \`\`\`typescript
399
- import {
400
- createLaunchpadSDK,
401
- ValidationError,
402
- NetworkError,
403
- TransactionError,
404
- TokenNotFoundError
405
- } from '@gala-chain/launchpad-sdk';
406
-
407
- async function errorHandlingExample() {
408
- const sdk = createLaunchpadSDK({
409
- wallet: 'your-private-key'
410
- });
411
-
412
- try {
413
- // Attempt trade
414
- const result = await sdk.buy({
415
- tokenName: 'dragnrkti',
416
- amount: '100',
417
- type: 'native',
418
- expectedAmount: '5000',
419
- slippageToleranceFactor: 0.01
420
- });
421
-
422
- console.log('Success:', result.transactionId);
423
-
424
- } catch (error) {
425
- if (error instanceof ValidationError) {
426
- console.error('Invalid input:', error.message);
427
- console.error('Field:', error.field);
428
- console.error('Code:', error.code);
429
-
430
- } else if (error instanceof TokenNotFoundError) {
431
- console.error('Token does not exist:', error.tokenName);
432
-
433
- } catch if (error instanceof NetworkError) {
434
- console.error('Network issue:', error.message);
435
- console.error('Status code:', error.statusCode);
436
-
437
- } else if (error instanceof TransactionError) {
438
- console.error('Transaction failed:', error.message);
439
- console.error('Transaction ID:', error.transactionId);
440
-
441
- } else {
442
- console.error('Unexpected error:', error);
443
- }
444
- }
445
- }
446
- \`\`\`
447
-
448
- **Error Types:**
449
- - \`ValidationError\` - Invalid input parameters
450
- - \`NetworkError\` - HTTP/network failures
451
- - \`TransactionError\` - Blockchain transaction failures
452
- - \`TokenNotFoundError\` - Token doesn't exist
453
- - \`ConfigurationError\` - SDK misconfiguration
454
- - \`WebSocketError\` - Real-time connection issues
455
- `,
456
-
457
- 'installation': `
458
- ## Installing and Importing SDK
459
-
460
- ### NPM Installation
461
-
462
- \`\`\`bash
463
- # Install SDK
464
- npm install @gala-chain/launchpad-sdk
465
-
466
- # Install peer dependencies
467
- npm install ethers@^6.15.0 @gala-chain/api@^2.4.3 @gala-chain/connect@^2.4.3 \\
468
- socket.io-client@^4.8.1 axios@^1.12.2 bignumber.js@^9.1.2 zod@^3.25.76
469
- \`\`\`
470
-
471
- ### Import Patterns
472
-
473
- \`\`\`typescript
474
- // Main SDK class
475
- import { LaunchpadSDK } from '@gala-chain/launchpad-sdk';
476
-
477
- // Helper functions (recommended)
478
- import {
479
- createLaunchpadSDK,
480
- createTestLaunchpadSDK,
481
- createWallet,
482
- validateWalletInput
483
- } from '@gala-chain/launchpad-sdk';
484
-
485
- // Error types
486
- import {
487
- ValidationError,
488
- NetworkError,
489
- TransactionError,
490
- TokenNotFoundError
491
- } from '@gala-chain/launchpad-sdk';
492
-
493
- // Type definitions
494
- import type {
495
- PoolData,
496
- TradeResult,
497
- TokenBalanceInfo,
498
- BuyTokenOptions,
499
- SellTokenOptions
500
- } from '@gala-chain/launchpad-sdk';
501
- \`\`\`
502
-
503
- ### Environment Configuration
504
-
505
- \`\`\`typescript
506
- // Development (default)
507
- const sdk = createLaunchpadSDK({
508
- wallet: 'your-private-key',
509
- config: {
510
- baseUrl: 'https://lpad-backend-dev1.defi.gala.com',
511
- debug: true
512
- }
513
- });
514
-
515
- // Production
516
- const sdk = createLaunchpadSDK({
517
- wallet: 'your-private-key',
518
- config: {
519
- baseUrl: 'https://lpad-backend-prod1.defi.gala.com',
520
- debug: false,
521
- timeout: 60000
522
- }
523
- });
524
- \`\`\`
525
- `,
526
-
527
- 'local-calculations': `
528
- ## Local Bonding Curve Calculations with SDK
529
-
530
- \`\`\`typescript
531
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
532
-
533
- async function localCalculationsExample() {
534
- const sdk = createLaunchpadSDK({
535
- wallet: 'your-private-key'
536
- });
537
-
538
- // ============================================================================
539
- // LOCAL CALCULATIONS - Instant quotes without network calls
540
- // ============================================================================
541
-
542
- // 1. Buy calculation (local, instant)
543
- const localBuy = await sdk.calculateBuyAmountLocal({
544
- tokenName: 'dragnrkti',
545
- amount: '100', // Spending 100 GALA
546
- type: 'native' // 'native' = GALA amount, 'exact' = token amount
547
- });
548
-
549
- console.log('LOCAL Buy Quote (instant):');
550
- console.log(' Tokens received:', localBuy.amount);
551
- console.log(' Transaction fee:', localBuy.transactionFee);
552
- console.log(' RBC Fee:', localBuy.reverseBondingCurveFee); // Always "0" for buys
553
- console.log(' Gas fee:', localBuy.gasFee);
554
-
555
- // 2. Sell calculation (local, requires pool details)
556
- const poolDetails = await sdk.fetchPoolDetails('dragnrkti');
557
-
558
- const localSell = await sdk.calculateSellAmountLocal({
559
- tokenName: 'dragnrkti',
560
- amount: '1000', // Selling 1000 tokens
561
- type: 'exact',
562
- // Required parameters from pool details:
563
- maxSupply: poolDetails.maxSupply.toString(),
564
- minFeePortion: poolDetails.reverseBondingCurveMinFeeFactor || 0,
565
- maxFeePortion: poolDetails.reverseBondingCurveMaxFeeFactor || 0
566
- });
567
-
568
- console.log('LOCAL Sell Quote (instant):');
569
- console.log(' GALA received:', localSell.amount);
570
- console.log(' RBC Fee:', localSell.reverseBondingCurveFee);
571
- console.log(' Transaction fee:', localSell.transactionFee);
572
-
573
- // ============================================================================
574
- // EXTERNAL CALCULATIONS - Real-time network queries (explicit)
575
- // ============================================================================
576
-
577
- // 3. External buy (explicit network call)
578
- const externalBuy = await sdk.calculateBuyAmountExternal({
579
- tokenName: 'dragnrkti',
580
- amount: '100',
581
- type: 'native'
582
- });
583
-
584
- console.log('EXTERNAL Buy Quote (network):');
585
- console.log(' Tokens received:', externalBuy.amount);
586
-
587
- // 4. External sell (explicit network call)
588
- const externalSell = await sdk.calculateSellAmountExternal({
589
- tokenName: 'dragnrkti',
590
- amount: '1000',
591
- type: 'exact'
592
- });
593
-
594
- console.log('EXTERNAL Sell Quote (network):');
595
- console.log(' GALA received:', externalSell.amount);
596
-
597
- // ============================================================================
598
- // A/B COMPARISON - Verify local accuracy
599
- // ============================================================================
600
-
601
- const buyDiff = Math.abs(parseFloat(localBuy.amount) - parseFloat(externalBuy.amount));
602
- const buyPct = (buyDiff / parseFloat(externalBuy.amount)) * 100;
603
-
604
- console.log('Local vs External Accuracy:');
605
- console.log(\` Buy difference: \${buyPct.toFixed(4)}% (should be <0.01%)\`);
606
-
607
- // ============================================================================
608
- // PERFORMANCE BENEFIT - Local is instant
609
- // ============================================================================
610
-
611
- console.time('Local calculation');
612
- await sdk.calculateBuyAmountLocal({ tokenName: 'dragnrkti', amount: '100', type: 'native' });
613
- console.timeEnd('Local calculation'); // ~0ms (instant)
614
-
615
- console.time('External calculation');
616
- await sdk.calculateBuyAmountExternal({ tokenName: 'dragnrkti', amount: '100', type: 'native' });
617
- console.timeEnd('External calculation'); // ~200-500ms (network roundtrip)
618
- }
619
- \`\`\`
620
-
621
- **Benefits of Local Calculations:**
622
- - ✅ Instant quotes (no network delay)
623
- - ✅ Offline support (no internet required)
624
- - ✅ No API rate limits
625
- - ✅ Perfect accuracy (<0.01% difference)
626
- - ✅ Reduced server load
627
-
628
- **When to Use:**
629
- - Local: Price discovery, UI updates, offline scenarios
630
- - External: Production trades (always verify before executing)
631
-
632
- **MCP Tool Equivalents:**
633
- - \`gala_launchpad_calculate_buy_amount_local\`
634
- - \`gala_launchpad_calculate_buy_amount_external\`
635
- - \`gala_launchpad_calculate_sell_amount_local\`
636
- - \`gala_launchpad_calculate_sell_amount_external\`
637
- `,
638
-
639
- 'token-distribution': `
640
- ## Token Holder Distribution with SDK
641
-
642
- \`\`\`typescript
643
- import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
644
-
645
- async function analyzeTokenDistribution() {
646
- const sdk = createLaunchpadSDK({
647
- wallet: 'your-private-key-or-mnemonic'
648
- });
649
-
650
- // Fetch complete token distribution (all holders, non-paginated)
651
- const distribution = await sdk.fetchTokenDistribution('anime');
652
-
653
- console.log(\`Total holders: \${distribution.totalHolders}\`);
654
- console.log(\`Total supply: \${distribution.totalSupply}\`);
655
- console.log(\`Last updated: \${distribution.lastUpdated.toISOString()}\`);
656
-
657
- // Analyze top holders
658
- distribution.holders
659
- .sort((a, b) => parseFloat(b.balance) - parseFloat(a.balance))
660
- .slice(0, 5)
661
- .forEach((holder, index) => {
662
- console.log(\`#\${index + 1}: \${holder.address}\`);
663
- console.log(\` Balance: \${holder.balance}\`);
664
- console.log(\` Ownership: \${holder.percentage.toFixed(2)}%\`);
665
- });
666
-
667
- // Check concentration risk (e.g., top 5 holders own >80%)
668
- const top5Ownership = distribution.holders
669
- .sort((a, b) => parseFloat(b.balance) - parseFloat(a.balance))
670
- .slice(0, 5)
671
- .reduce((sum, holder) => sum + holder.percentage, 0);
672
-
673
- console.log(\`Top 5 holders control: \${top5Ownership.toFixed(2)}%\`);
674
-
675
- // Find specific holder
676
- const myAddress = sdk.getAddress();
677
- const myHolding = distribution.holders.find(h => h.address === myAddress);
678
-
679
- if (myHolding) {
680
- console.log(\`Your ownership: \${myHolding.percentage.toFixed(4)}%\`);
681
- console.log(\`Your balance: \${myHolding.balance}\`);
682
- }
683
-
684
- // Calculate concentration metrics
685
- const giniCoefficient = calculateGini(distribution.holders);
686
- console.log(\`Gini coefficient: \${giniCoefficient.toFixed(4)}\`);
687
-
688
- // Count whales (holders with >5%)
689
- const whales = distribution.holders.filter(h => h.percentage > 5);
690
- console.log(\`Whales (>5%): \${whales.length}\`);
691
- }
692
-
693
- // Helper: Calculate Gini coefficient for wealth distribution
694
- function calculateGini(holders: Array<{balance: string}>) {
695
- const balances = holders.map(h => parseFloat(h.balance)).sort((a, b) => a - b);
696
- const n = balances.length;
697
- const sum = balances.reduce((a, b) => a + b, 0);
698
-
699
- let numerator = 0;
700
- for (let i = 0; i < n; i++) {
701
- numerator += (2 * (i + 1) - n - 1) * balances[i];
702
- }
703
-
704
- return numerator / (n * sum);
705
- }
706
- \`\`\`
707
-
708
- **Key Characteristics:**
709
- - **Non-Paginated**: Returns ALL token holders in single response (no pagination)
710
- - **Complete Distribution**: Full holder list with addresses, balances, and ownership percentages
711
- - **BigNumber Precision**: Uses BigNumber.js for accurate percentage calculations
712
- - **Total Supply**: Computed from holder balances (sum of all holdings)
713
- - **Service Account Included**: Vault/service accounts appear in holder list
714
-
715
- **Use Cases:**
716
- - Analyze token concentration risk
717
- - Identify whale holders
718
- - Track ownership changes over time
719
- - Generate holder reports
720
- - Calculate distribution metrics (Gini coefficient, etc.)
721
-
722
- **MCP Tool Equivalent:** \`gala_launchpad_fetch_token_distribution\`
723
- `,
724
-
725
- 'mcp-to-sdk-mapping': `
726
- ## MCP Tool to SDK Method Mapping
727
-
728
- ### Trading Operations
729
- | MCP Tool | SDK Method | Notes |
730
- |----------|------------|-------|
731
- | \`gala_launchpad_calculate_buy_amount\` | \`sdk.calculateBuyAmount(options)\` | Get quote before buying |
732
- | \`gala_launchpad_calculate_buy_amount_local\` | \`sdk.calculateBuyAmountLocal(options)\` | Local instant quote (buy) |
733
- | \`gala_launchpad_calculate_buy_amount_external\` | \`sdk.calculateBuyAmountExternal(options)\` | Explicit network quote (buy) |
734
- | \`gala_launchpad_calculate_sell_amount\` | \`sdk.calculateSellAmount(options)\` | Get quote before selling |
735
- | \`gala_launchpad_calculate_sell_amount_local\` | \`sdk.calculateSellAmountLocal(options)\` | Local instant quote (sell) |
736
- | \`gala_launchpad_calculate_sell_amount_external\` | \`sdk.calculateSellAmountExternal(options)\` | Explicit network quote (sell) |
737
- | \`gala_launchpad_buy_tokens\` | \`sdk.buy(options)\` | Execute token purchase |
738
- | \`gala_launchpad_sell_tokens\` | \`sdk.sell(options)\` | Execute token sale |
739
- | \`gala_launchpad_graduate_token\` | \`sdk.graduateToken(options)\` | One-step pool graduation |
740
-
741
- ### Pool Management
742
- | MCP Tool | SDK Method | Notes |
743
- |----------|------------|-------|
744
- | \`gala_launchpad_fetch_pools\` | \`sdk.fetchPools(options)\` | List pools with filtering |
745
- | \`gala_launchpad_fetch_pool_details\` | \`sdk.fetchPoolDetails(tokenName)\` | Get specific pool data |
746
- | \`gala_launchpad_fetch_token_distribution\` | \`sdk.fetchTokenDistribution(tokenName)\` | Holder distribution |
747
- | \`gala_launchpad_fetch_token_badges\` | \`sdk.fetchTokenBadges(tokenName)\` | Achievement badges |
748
-
749
- ### Balance & Portfolio
750
- | MCP Tool | SDK Method | Notes |
751
- |----------|------------|-------|
752
- | \`gala_launchpad_fetch_gala_balance\` | \`sdk.fetchGalaBalance(address?)\` | GALA balance |
753
- | \`gala_launchpad_fetch_token_balance\` | \`sdk.fetchTokenBalance(options)\` | Specific token balance |
754
- | \`gala_launchpad_fetch_tokens_held\` | \`sdk.fetchTokensHeld(options)\` | Portfolio holdings |
755
- | \`gala_launchpad_fetch_tokens_created\` | \`sdk.fetchTokensCreated(options)\` | Created tokens |
756
-
757
- ### Token Creation
758
- | MCP Tool | SDK Method | Notes |
759
- |----------|------------|-------|
760
- | \`gala_launchpad_fetch_launch_token_fee\` | \`sdk.fetchLaunchTokenFee()\` | Get launch cost |
761
- | \`gala_launchpad_check_token_name\` | \`sdk.isTokenNameAvailable(name)\` | Check name |
762
- | \`gala_launchpad_check_token_symbol\` | \`sdk.isTokenSymbolAvailable(symbol)\` | Check symbol |
763
- | \`gala_launchpad_launch_token\` | \`sdk.launchToken(data)\` | Create token |
764
- | \`gala_launchpad_upload_token_image\` | \`sdk.uploadTokenImage(options)\` | Upload image |
765
-
766
- ### Transfers & Social
767
- | MCP Tool | SDK Method | Notes |
768
- |----------|------------|-------|
769
- | \`gala_launchpad_transfer_gala\` | \`sdk.transferGala(options)\` | Transfer GALA |
770
- | \`gala_launchpad_transfer_token\` | \`sdk.transferToken(options)\` | Transfer tokens |
771
- | \`gala_launchpad_post_comment\` | \`sdk.postComment(options)\` | Post comment |
772
- | \`gala_launchpad_fetch_comments\` | \`sdk.fetchComments(options)\` | Get comments |
773
-
774
- ### Utilities
775
- | MCP Tool | SDK Method | Notes |
776
- |----------|------------|-------|
777
- | \`gala_launchpad_create_wallet\` | \`createWallet()\` | Generate wallet |
778
- | \`gala_launchpad_get_address\` | \`sdk.getAddress()\` | Get backend format |
779
- | \`gala_launchpad_get_ethereum_address\` | \`sdk.getEthereumAddress()\` | Get 0x format |
780
- | \`gala_launchpad_get_url_by_token_name\` | \`sdk.getUrlByTokenName(name)\` | Frontend URL |
781
- | \`gala_launchpad_is_token_graduated\` | \`sdk.isTokenGraduated(tokenName)\` | Check if pool completed |
782
-
783
- **Key Difference:** MCP tools return \`{ success: true, data: {...} }\`, SDK methods return direct result objects.
784
- `,
785
- };
786
-
787
- /**
788
- * SDK Usage Explanation Tool
789
- */
790
- export const explainSdkUsageTool: MCPTool = {
791
- name: 'gala_launchpad_explain_sdk_usage',
792
- description: `Get detailed SDK code examples and explanations for using the Gala Launchpad SDK directly.
793
-
794
- This tool provides complete, working code examples showing how to use the SDK instead of MCP tools.
795
- Perfect for developers who want to integrate the SDK into their applications.
796
-
797
- Available topics:
798
- - 'buy-tokens' - Complete buying workflow with calculation and execution
799
- - 'sell-tokens' - Complete selling workflow with slippage protection
800
- - 'pool-graduation' - Graduate a bonding curve pool
801
- - 'fetch-pools' - Query pool data and details
802
- - 'balances' - Check GALA and token balances
803
- - 'token-distribution' - Analyze token holder distribution and concentration
804
- - 'token-creation' - Launch new tokens
805
- - 'multi-wallet' - Use multiple wallets (privateKey override pattern)
806
- - 'transfers' - Transfer GALA and tokens between wallets
807
- - 'error-handling' - Handle errors and exceptions
808
- - 'installation' - Install and configure SDK
809
- - 'local-calculations' - Local vs external bonding curve calculations
810
- - 'mcp-to-sdk-mapping' - Complete mapping of MCP tools to SDK methods
811
-
812
- Returns runnable TypeScript code examples with explanations.`,
813
- inputSchema: {
814
- type: 'object',
815
- properties: {
816
- topic: {
817
- type: 'string',
818
- enum: [
819
- 'buy-tokens',
820
- 'sell-tokens',
821
- 'pool-graduation',
822
- 'fetch-pools',
823
- 'balances',
824
- 'token-distribution',
825
- 'token-creation',
826
- 'multi-wallet',
827
- 'transfers',
828
- 'error-handling',
829
- 'installation',
830
- 'local-calculations',
831
- 'mcp-to-sdk-mapping',
832
- ],
833
- description: 'The SDK usage topic to explain',
834
- },
835
- },
836
- required: ['topic'],
837
- },
838
- handler: withErrorHandling(async (_sdk, args) => {
839
- const example = SDK_EXAMPLES[args.topic as keyof typeof SDK_EXAMPLES];
840
-
841
- if (!example) {
842
- throw new Error(`Unknown topic: ${args.topic}`);
843
- }
844
-
845
- return formatSuccess({
846
- topic: args.topic,
847
- explanation: example,
848
- sdkVersion: '3.11.7',
849
- packageName: '@gala-chain/launchpad-sdk',
850
- documentation: 'https://www.npmjs.com/package/@gala-chain/launchpad-sdk',
851
- });
852
- }),
853
- };