@gala-chain/launchpad-sdk 3.23.0 → 3.24.1
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/API.md +955 -0
- package/CHANGELOG.md +120 -0
- package/README.md +154 -0
- package/dist/LaunchpadSDK.d.ts +121 -0
- package/dist/LaunchpadSDK.d.ts.map +1 -1
- package/dist/constants/version.generated.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/services/GSwapService.d.ts +59 -0
- package/dist/services/GSwapService.d.ts.map +1 -0
- package/dist/services/TokenMetadataService.d.ts +113 -0
- package/dist/services/TokenMetadataService.d.ts.map +1 -0
- package/dist/setup.d.ts +8 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/types/gswap.dto.d.ts +139 -0
- package/dist/types/gswap.dto.d.ts.map +1 -0
- package/dist/utils/errors.d.ts +177 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/token-format-converter.d.ts +58 -0
- package/dist/utils/token-format-converter.d.ts.map +1 -0
- package/package.json +3 -2
package/API.md
ADDED
|
@@ -0,0 +1,955 @@
|
|
|
1
|
+
# Gala Launchpad SDK - API Reference
|
|
2
|
+
|
|
3
|
+
Complete API documentation for the Gala Launchpad SDK (v3.23.0+).
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [SDK Initialization](#sdk-initialization)
|
|
8
|
+
- [Bonding Curve Trading (Launchpad Tokens)](#bonding-curve-trading)
|
|
9
|
+
- [DEX Trading (Graduated Tokens)](#dex-trading-galaswap)
|
|
10
|
+
- [Pool Information](#pool-information)
|
|
11
|
+
- [Token Management](#token-management)
|
|
12
|
+
- [Portfolio & Balances](#portfolio--balances)
|
|
13
|
+
- [Price History & Analytics](#price-history--analytics)
|
|
14
|
+
- [Real-Time Features](#real-time-features)
|
|
15
|
+
- [Type Definitions](#type-definitions)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## SDK Initialization
|
|
20
|
+
|
|
21
|
+
### `createLaunchpadSDK(config?)`
|
|
22
|
+
|
|
23
|
+
Creates and returns a configured LaunchpadSDK instance for interacting with the Gala Launchpad Backend.
|
|
24
|
+
|
|
25
|
+
**Parameters:**
|
|
26
|
+
```typescript
|
|
27
|
+
interface LaunchpadSDKConfig {
|
|
28
|
+
environment?: 'development' | 'staging' | 'production'; // Default: 'production'
|
|
29
|
+
privateKey?: string; // Private key for signing (optional)
|
|
30
|
+
wallet?: string; // Wallet address (optional)
|
|
31
|
+
timeout?: number; // Request timeout in ms (default: 30000)
|
|
32
|
+
debug?: boolean; // Enable debug logging (default: false)
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Example:**
|
|
37
|
+
```typescript
|
|
38
|
+
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
39
|
+
|
|
40
|
+
// Read-only mode
|
|
41
|
+
const sdk = createLaunchpadSDK({ environment: 'production' });
|
|
42
|
+
|
|
43
|
+
// With wallet for signing operations
|
|
44
|
+
const sdk = createLaunchpadSDK({
|
|
45
|
+
environment: 'production',
|
|
46
|
+
privateKey: process.env.PRIVATE_KEY,
|
|
47
|
+
wallet: 'eth|0x...'
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Bonding Curve Trading
|
|
54
|
+
|
|
55
|
+
Trading tokens that are still in bonding curve pools (pre-graduation).
|
|
56
|
+
|
|
57
|
+
### `calculateBuyAmount(tokenName, amount, type?)`
|
|
58
|
+
|
|
59
|
+
Calculate token amounts and fees for a purchase on a bonding curve.
|
|
60
|
+
|
|
61
|
+
**Parameters:**
|
|
62
|
+
```typescript
|
|
63
|
+
tokenName: string; // Token symbol (e.g., "anime")
|
|
64
|
+
amount: string; // Input amount (GALA or exact token count)
|
|
65
|
+
type?: 'native' | 'exact'; // 'native' = GALA amount, 'exact' = token amount (default: 'native')
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Returns:**
|
|
69
|
+
```typescript
|
|
70
|
+
{
|
|
71
|
+
amount: string; // Token quantity you'll receive
|
|
72
|
+
totalCost: string; // Total GALA cost (input + fees)
|
|
73
|
+
transactionFee: string; // Transaction fee in GALA
|
|
74
|
+
gasFee: string; // Gas fee in GALA
|
|
75
|
+
reverseBondingCurveFee: string; // RBC fee in GALA
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Example:**
|
|
80
|
+
```typescript
|
|
81
|
+
// How many tokens for 100 GALA?
|
|
82
|
+
const quote = await sdk.calculateBuyAmount('anime', '100', 'native');
|
|
83
|
+
console.log(`Receive: ${quote.amount} tokens`);
|
|
84
|
+
console.log(`Cost: ${quote.totalCost} GALA`);
|
|
85
|
+
|
|
86
|
+
// How much GALA for 10,000 tokens?
|
|
87
|
+
const exactQuote = await sdk.calculateBuyAmount('anime', '10000', 'exact');
|
|
88
|
+
console.log(`Need: ${exactQuote.totalCost} GALA`);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `calculateSellAmount(tokenName, amount, type?)`
|
|
92
|
+
|
|
93
|
+
Calculate GALA amount received when selling tokens.
|
|
94
|
+
|
|
95
|
+
**Parameters:**
|
|
96
|
+
```typescript
|
|
97
|
+
tokenName: string; // Token symbol
|
|
98
|
+
amount: string; // Token amount or GALA desired
|
|
99
|
+
type?: 'native' | 'exact'; // 'native' = GALA desired, 'exact' = token amount (default: 'native')
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**Returns:**
|
|
103
|
+
```typescript
|
|
104
|
+
{
|
|
105
|
+
amount: string; // GALA you'll receive
|
|
106
|
+
transactionFee: string; // Transaction fee
|
|
107
|
+
gasFee: string; // Gas fee
|
|
108
|
+
reverseBondingCurveFee: string; // RBC fee
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Example:**
|
|
113
|
+
```typescript
|
|
114
|
+
// How much GALA for selling 5000 tokens?
|
|
115
|
+
const sellQuote = await sdk.calculateSellAmount('anime', '5000', 'exact');
|
|
116
|
+
console.log(`Receive: ${sellQuote.amount} GALA`);
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `buyTokens(tokenName, amount, expectedAmount, slippageToleranceFactor?, maxAcceptableReverseBondingCurveFee?)`
|
|
120
|
+
|
|
121
|
+
Execute a token purchase with slippage protection.
|
|
122
|
+
|
|
123
|
+
**Parameters:**
|
|
124
|
+
```typescript
|
|
125
|
+
tokenName: string; // Token symbol
|
|
126
|
+
amount: string; // GALA amount to spend
|
|
127
|
+
expectedAmount: string; // Expected token output (from calculateBuyAmount)
|
|
128
|
+
slippageToleranceFactor?: number; // Slippage tolerance (0-1, default: 0.01 = 1%)
|
|
129
|
+
maxAcceptableReverseBondingCurveFee?: string; // Max RBC fee
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Returns:**
|
|
133
|
+
```typescript
|
|
134
|
+
{
|
|
135
|
+
transactionId: string;
|
|
136
|
+
status: 'PENDING' | 'COMPLETED' | 'FAILED';
|
|
137
|
+
inputAmount: string;
|
|
138
|
+
outputAmount: string;
|
|
139
|
+
actualFees: { transaction: string; gas: string; rbc: string };
|
|
140
|
+
wait(): Promise<TransactionResult>; // Wait for completion
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
**Example:**
|
|
145
|
+
```typescript
|
|
146
|
+
// Get quote first
|
|
147
|
+
const quote = await sdk.calculateBuyAmount('anime', '100', 'native');
|
|
148
|
+
|
|
149
|
+
// Execute buy with 1% slippage tolerance
|
|
150
|
+
const result = await sdk.buyTokens('anime', '100', quote.amount, 0.01);
|
|
151
|
+
|
|
152
|
+
console.log(`Transaction ID: ${result.transactionId}`);
|
|
153
|
+
|
|
154
|
+
// Wait for completion (optional)
|
|
155
|
+
const completed = await result.wait();
|
|
156
|
+
console.log(`Received: ${completed.outputAmount} tokens`);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### `sellTokens(tokenName, amount, expectedAmount, slippageToleranceFactor?)`
|
|
160
|
+
|
|
161
|
+
Execute a token sale with slippage protection.
|
|
162
|
+
|
|
163
|
+
**Parameters:**
|
|
164
|
+
```typescript
|
|
165
|
+
tokenName: string; // Token symbol
|
|
166
|
+
amount: string; // Token amount to sell
|
|
167
|
+
expectedAmount: string; // Expected GALA output (from calculateSellAmount)
|
|
168
|
+
slippageToleranceFactor?: number; // Slippage tolerance (default: 0.01 = 1%)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Returns:** Same structure as `buyTokens()`
|
|
172
|
+
|
|
173
|
+
**Example:**
|
|
174
|
+
```typescript
|
|
175
|
+
// Get quote
|
|
176
|
+
const quote = await sdk.calculateSellAmount('anime', '5000', 'exact');
|
|
177
|
+
|
|
178
|
+
// Execute sell
|
|
179
|
+
const result = await sdk.sellTokens('anime', '5000', quote.amount, 0.01);
|
|
180
|
+
console.log(`Received: ${result.outputAmount} GALA`);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### `calculateBuyAmountForGraduation(tokenName)`
|
|
184
|
+
|
|
185
|
+
Calculate total GALA cost to graduate a token (buy all remaining tokens).
|
|
186
|
+
|
|
187
|
+
**⚠️ CRITICAL:** Returns **GALA cost**, NOT token quantity!
|
|
188
|
+
|
|
189
|
+
**Parameters:**
|
|
190
|
+
```typescript
|
|
191
|
+
tokenName: string; // Token symbol
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Returns:**
|
|
195
|
+
```typescript
|
|
196
|
+
{
|
|
197
|
+
amount: string; // GALA cost to graduate (e.g., "1639972.84")
|
|
198
|
+
totalCost: string; // Total cost including fees
|
|
199
|
+
transactionFee: string;
|
|
200
|
+
gasFee: string;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Example:**
|
|
205
|
+
```typescript
|
|
206
|
+
const graduation = await sdk.calculateBuyAmountForGraduation('QATOKEN');
|
|
207
|
+
console.log(`Cost to graduate: ${graduation.amount} GALA`);
|
|
208
|
+
// Example output: "1639972.84 GALA" (1.6 million GALA, not tokens!)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### `graduateToken(tokenName, options?)`
|
|
212
|
+
|
|
213
|
+
Graduate a token by buying all remaining bonding curve tokens (convenience method).
|
|
214
|
+
|
|
215
|
+
**Parameters:**
|
|
216
|
+
```typescript
|
|
217
|
+
tokenName: string;
|
|
218
|
+
options?: {
|
|
219
|
+
slippageToleranceFactor?: number; // Default: 0.01 (1%)
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Returns:** Transaction result (same as buyTokens)
|
|
224
|
+
|
|
225
|
+
**Example:**
|
|
226
|
+
```typescript
|
|
227
|
+
const result = await sdk.graduateToken('QATOKEN', { slippageToleranceFactor: 0.01 });
|
|
228
|
+
console.log(`Graduation initiated: ${result.transactionId}`);
|
|
229
|
+
|
|
230
|
+
// Verify graduation
|
|
231
|
+
const pool = await sdk.fetchPoolDetails('QATOKEN');
|
|
232
|
+
console.log(`Pool status: ${pool.saleStatus}`); // Should be "Completed"
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## DEX Trading (GalaSwap)
|
|
238
|
+
|
|
239
|
+
Trading tokens that have graduated from bonding curves to full DEX trading.
|
|
240
|
+
|
|
241
|
+
### `getSwapQuoteExactInput(fromToken, toToken, amount)`
|
|
242
|
+
|
|
243
|
+
Get a quote for swapping a known input amount on GalaSwap DEX.
|
|
244
|
+
|
|
245
|
+
**Parameters:**
|
|
246
|
+
```typescript
|
|
247
|
+
fromToken: string; // Source token ("GALA", "GUSDC", or pipe-delimited format)
|
|
248
|
+
toToken: string; // Destination token ("GALA", "GUSDC", or pipe-delimited format)
|
|
249
|
+
amount: string; // Input amount (how much fromToken to spend)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Returns:**
|
|
253
|
+
```typescript
|
|
254
|
+
{
|
|
255
|
+
estimatedOutput: string; // Expected toToken amount
|
|
256
|
+
priceImpact: number; // Price impact percentage (0-1)
|
|
257
|
+
feeTier: number; // Fee tier in basis points (500, 3000, 10000)
|
|
258
|
+
exchangeRate: string; // Rate: toToken per fromToken
|
|
259
|
+
minimumOutput: string; // Minimum output with 1% slippage
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Example:**
|
|
264
|
+
```typescript
|
|
265
|
+
// How many GUSDC for 100 GALA?
|
|
266
|
+
const quote = await sdk.getSwapQuoteExactInput('GALA', 'GUSDC', '100');
|
|
267
|
+
console.log(`Spend: 100 GALA`);
|
|
268
|
+
console.log(`Receive: ~${quote.estimatedOutput} GUSDC`);
|
|
269
|
+
console.log(`Price impact: ${(quote.priceImpact * 100).toFixed(2)}%`);
|
|
270
|
+
console.log(`Fee tier: ${quote.feeTier} (${quote.feeTier / 100}%)`);
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### `getSwapQuoteExactOutput(fromToken, toToken, amount)`
|
|
274
|
+
|
|
275
|
+
Get a quote for swapping to a known output amount on GalaSwap DEX.
|
|
276
|
+
|
|
277
|
+
**Parameters:**
|
|
278
|
+
```typescript
|
|
279
|
+
fromToken: string; // Source token
|
|
280
|
+
toToken: string; // Destination token
|
|
281
|
+
amount: string; // Desired output amount (how much toToken you want)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
**Returns:**
|
|
285
|
+
```typescript
|
|
286
|
+
{
|
|
287
|
+
inputAmount: string; // fromToken amount needed to spend
|
|
288
|
+
priceImpact: number; // Price impact percentage
|
|
289
|
+
feeTier: number; // Fee tier
|
|
290
|
+
exchangeRate: string; // Exchange rate
|
|
291
|
+
maximumInput: string; // Maximum input with 1% slippage
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
**Example:**
|
|
296
|
+
```typescript
|
|
297
|
+
// How much GALA to get 100 GUSDC?
|
|
298
|
+
const quote = await sdk.getSwapQuoteExactOutput('GALA', 'GUSDC', '100');
|
|
299
|
+
console.log(`Need: ${quote.inputAmount} GALA`);
|
|
300
|
+
console.log(`To get: 100 GUSDC`);
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### `executeSwap(fromToken, toToken, inputAmount, estimatedOutput, feeTier, slippageTolerance?)`
|
|
304
|
+
|
|
305
|
+
Execute a token swap on GalaSwap DEX with slippage protection.
|
|
306
|
+
|
|
307
|
+
**Parameters:**
|
|
308
|
+
```typescript
|
|
309
|
+
fromToken: string; // Source token
|
|
310
|
+
toToken: string; // Destination token
|
|
311
|
+
inputAmount: string; // How much fromToken to spend
|
|
312
|
+
estimatedOutput: string; // Expected output (from quote)
|
|
313
|
+
feeTier: number; // Fee tier (from quote)
|
|
314
|
+
slippageTolerance?: number; // Slippage tolerance (0-1, default: 0.01)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Returns:**
|
|
318
|
+
```typescript
|
|
319
|
+
{
|
|
320
|
+
transactionId: string;
|
|
321
|
+
status: 'PENDING' | 'COMPLETED' | 'FAILED';
|
|
322
|
+
inputAmount: string;
|
|
323
|
+
outputAmount: string;
|
|
324
|
+
actualFees: { transaction: string; gas: string };
|
|
325
|
+
wait(): Promise<TransactionResult>;
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Example:**
|
|
330
|
+
```typescript
|
|
331
|
+
// Get quote
|
|
332
|
+
const quote = await sdk.getSwapQuoteExactInput('GALA', 'GUSDC', '100');
|
|
333
|
+
|
|
334
|
+
// Execute swap with 1% slippage protection
|
|
335
|
+
const result = await sdk.executeSwap(
|
|
336
|
+
'GALA',
|
|
337
|
+
'GUSDC',
|
|
338
|
+
'100',
|
|
339
|
+
quote.estimatedOutput,
|
|
340
|
+
quote.feeTier,
|
|
341
|
+
0.01 // 1% slippage tolerance
|
|
342
|
+
);
|
|
343
|
+
|
|
344
|
+
console.log(`Swap ID: ${result.transactionId}`);
|
|
345
|
+
console.log(`Received: ${result.outputAmount} GUSDC`);
|
|
346
|
+
|
|
347
|
+
// Wait for confirmation (optional)
|
|
348
|
+
await result.wait();
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### `getSwapUserAssets(walletAddress)`
|
|
352
|
+
|
|
353
|
+
Get all token balances for a wallet on GalaSwap.
|
|
354
|
+
|
|
355
|
+
**Parameters:**
|
|
356
|
+
```typescript
|
|
357
|
+
walletAddress: string; // Wallet address (eth|0x... format)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Returns:**
|
|
361
|
+
```typescript
|
|
362
|
+
Array<{
|
|
363
|
+
symbol: string; // Token symbol (e.g., "GALA")
|
|
364
|
+
balance: string; // Token balance
|
|
365
|
+
decimals: number; // Token decimals
|
|
366
|
+
tokenId: string; // Pipe-delimited token ID
|
|
367
|
+
}>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
**Example:**
|
|
371
|
+
```typescript
|
|
372
|
+
const assets = await sdk.getSwapUserAssets('eth|0x...');
|
|
373
|
+
|
|
374
|
+
assets.forEach(asset => {
|
|
375
|
+
console.log(`${asset.symbol}: ${asset.balance}`);
|
|
376
|
+
});
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### `getSwapPoolInfo(tokenA, tokenB)`
|
|
380
|
+
|
|
381
|
+
Get liquidity and fee information for a DEX pool.
|
|
382
|
+
|
|
383
|
+
**Parameters:**
|
|
384
|
+
```typescript
|
|
385
|
+
tokenA: string; // First token
|
|
386
|
+
tokenB: string; // Second token
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
**Returns:**
|
|
390
|
+
```typescript
|
|
391
|
+
{
|
|
392
|
+
liquidity: string; // Total pool liquidity
|
|
393
|
+
feeTiers: number[]; // Available fee tiers
|
|
394
|
+
volume24h: string; // 24-hour volume
|
|
395
|
+
swapCount: number; // Total swap count
|
|
396
|
+
lastUpdated: Date; // Snapshot timestamp
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
**Example:**
|
|
401
|
+
```typescript
|
|
402
|
+
const pool = await sdk.getSwapPoolInfo('GALA', 'GUSDC');
|
|
403
|
+
console.log(`Liquidity: ${pool.liquidity}`);
|
|
404
|
+
console.log(`Fee tiers: ${pool.feeTiers.map(t => t / 100 + '%').join(', ')}`);
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
## Pool Information
|
|
410
|
+
|
|
411
|
+
### `fetchPoolDetails(tokenName)`
|
|
412
|
+
|
|
413
|
+
Get detailed information about a bonding curve pool.
|
|
414
|
+
|
|
415
|
+
**Parameters:**
|
|
416
|
+
```typescript
|
|
417
|
+
tokenName: string; // Token symbol
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Returns:**
|
|
421
|
+
```typescript
|
|
422
|
+
{
|
|
423
|
+
tokenName: string;
|
|
424
|
+
symbol: string;
|
|
425
|
+
currentSupply: string;
|
|
426
|
+
maxSupply: string;
|
|
427
|
+
sellingTokenQuantity: string;
|
|
428
|
+
reserveGala: string;
|
|
429
|
+
saleStatus: 'Ongoing' | 'Completed';
|
|
430
|
+
createdAt: Date;
|
|
431
|
+
fees: {
|
|
432
|
+
transactionFee: string;
|
|
433
|
+
reverseBondingCurveFee: { min: string; max: string };
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
**Example:**
|
|
439
|
+
```typescript
|
|
440
|
+
const pool = await sdk.fetchPoolDetails('anime');
|
|
441
|
+
console.log(`Supply: ${pool.currentSupply}/${pool.maxSupply}`);
|
|
442
|
+
console.log(`Status: ${pool.saleStatus}`);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
### `fetchAllPools(options?)`
|
|
446
|
+
|
|
447
|
+
Fetch all bonding curve pools with filtering and pagination.
|
|
448
|
+
|
|
449
|
+
**Parameters:**
|
|
450
|
+
```typescript
|
|
451
|
+
interface FetchPoolsOptions {
|
|
452
|
+
type?: 'recent' | 'popular'; // Default: 'recent'
|
|
453
|
+
page?: number; // Default: 1
|
|
454
|
+
limit?: number; // Default: 20, max: 100
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
**Example:**
|
|
459
|
+
```typescript
|
|
460
|
+
const pools = await sdk.fetchAllPools({ type: 'popular', limit: 50 });
|
|
461
|
+
pools.forEach(pool => {
|
|
462
|
+
console.log(`${pool.tokenName}: ${pool.saleStatus}`);
|
|
463
|
+
});
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
## Token Management
|
|
469
|
+
|
|
470
|
+
### `launchToken(options)`
|
|
471
|
+
|
|
472
|
+
Create a new token on the launchpad.
|
|
473
|
+
|
|
474
|
+
**Parameters:**
|
|
475
|
+
```typescript
|
|
476
|
+
interface TokenLaunchOptions {
|
|
477
|
+
tokenName: string; // Token name (3-20 alphanumeric)
|
|
478
|
+
tokenSymbol: string; // Token symbol (1-8 uppercase)
|
|
479
|
+
tokenDescription: string; // Description (1-500 chars)
|
|
480
|
+
tokenImage: string; // Image URL
|
|
481
|
+
websiteUrl?: string; // Website URL (optional)
|
|
482
|
+
twitterUrl?: string; // Twitter URL (optional)
|
|
483
|
+
telegramUrl?: string; // Telegram URL (optional)
|
|
484
|
+
preBuyQuantity?: string; // Pre-buy token amount (default: "0")
|
|
485
|
+
reverseBondingCurveConfiguration?: {
|
|
486
|
+
minFeePortion?: string;
|
|
487
|
+
maxFeePortion?: string;
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
**Returns:**
|
|
493
|
+
```typescript
|
|
494
|
+
{
|
|
495
|
+
tokenName: string;
|
|
496
|
+
tokenSymbol: string;
|
|
497
|
+
creatorAddress: string;
|
|
498
|
+
transactionId: string;
|
|
499
|
+
status: 'PENDING' | 'COMPLETED' | 'FAILED';
|
|
500
|
+
}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
**Example:**
|
|
504
|
+
```typescript
|
|
505
|
+
const result = await sdk.launchToken({
|
|
506
|
+
tokenName: 'mytoken',
|
|
507
|
+
tokenSymbol: 'MTK',
|
|
508
|
+
tokenDescription: 'A new launchpad token',
|
|
509
|
+
tokenImage: 'https://example.com/image.png',
|
|
510
|
+
websiteUrl: 'https://example.com',
|
|
511
|
+
preBuyQuantity: '1000' // Pre-buy 1000 tokens
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
console.log(`Token created: ${result.tokenName}`);
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### `checkTokenName(tokenName)`
|
|
518
|
+
|
|
519
|
+
Check if a token name is available.
|
|
520
|
+
|
|
521
|
+
**Parameters:**
|
|
522
|
+
```typescript
|
|
523
|
+
tokenName: string;
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
**Returns:**
|
|
527
|
+
```typescript
|
|
528
|
+
{
|
|
529
|
+
available: boolean;
|
|
530
|
+
tokenName: string;
|
|
531
|
+
}
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### `checkTokenSymbol(symbol)`
|
|
535
|
+
|
|
536
|
+
Check if a token symbol is available.
|
|
537
|
+
|
|
538
|
+
**Parameters:**
|
|
539
|
+
```typescript
|
|
540
|
+
symbol: string; // 1-8 uppercase characters
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
**Returns:**
|
|
544
|
+
```typescript
|
|
545
|
+
{
|
|
546
|
+
available: boolean;
|
|
547
|
+
symbol: string;
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
## Portfolio & Balances
|
|
554
|
+
|
|
555
|
+
### `fetchGalaBalance(address?)`
|
|
556
|
+
|
|
557
|
+
Get GALA token balance for a wallet.
|
|
558
|
+
|
|
559
|
+
**Parameters:**
|
|
560
|
+
```typescript
|
|
561
|
+
address?: string; // Wallet address (default: authenticated wallet)
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
**Returns:**
|
|
565
|
+
```typescript
|
|
566
|
+
string; // GALA balance
|
|
567
|
+
```
|
|
568
|
+
|
|
569
|
+
**Example:**
|
|
570
|
+
```typescript
|
|
571
|
+
const balance = await sdk.fetchGalaBalance();
|
|
572
|
+
console.log(`GALA balance: ${balance}`);
|
|
573
|
+
```
|
|
574
|
+
|
|
575
|
+
### `fetchTokenBalance(tokenName, address)`
|
|
576
|
+
|
|
577
|
+
Get balance for a specific launchpad token.
|
|
578
|
+
|
|
579
|
+
**Parameters:**
|
|
580
|
+
```typescript
|
|
581
|
+
tokenName: string; // Token symbol
|
|
582
|
+
address: string; // Wallet address
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
**Returns:**
|
|
586
|
+
```typescript
|
|
587
|
+
string; // Token balance
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### `fetchTokensHeld(options?)`
|
|
591
|
+
|
|
592
|
+
Get all tokens held by a wallet with optional filtering.
|
|
593
|
+
|
|
594
|
+
**Parameters:**
|
|
595
|
+
```typescript
|
|
596
|
+
interface FetchTokensOptions {
|
|
597
|
+
tokenName?: string; // Exact token name filter
|
|
598
|
+
search?: string; // Fuzzy search filter
|
|
599
|
+
page?: number; // Default: 1
|
|
600
|
+
limit?: number; // Default: 20, max: 20
|
|
601
|
+
}
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
**Returns:**
|
|
605
|
+
```typescript
|
|
606
|
+
Array<{
|
|
607
|
+
tokenName: string;
|
|
608
|
+
balance: string;
|
|
609
|
+
symbol: string;
|
|
610
|
+
decimals: number;
|
|
611
|
+
}>
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
**Example:**
|
|
615
|
+
```typescript
|
|
616
|
+
// Get specific token
|
|
617
|
+
const anime = await sdk.fetchTokensHeld({ tokenName: 'anime', limit: 1 });
|
|
618
|
+
|
|
619
|
+
// Search for tokens
|
|
620
|
+
const dragonTokens = await sdk.fetchTokensHeld({ search: 'dragon', limit: 10 });
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
### `fetchTokensCreated(options?)`
|
|
624
|
+
|
|
625
|
+
Get all tokens created by a wallet with optional filtering.
|
|
626
|
+
|
|
627
|
+
**Parameters:** Same as `fetchTokensHeld()`
|
|
628
|
+
|
|
629
|
+
### `fetchTokenDistribution(tokenName)`
|
|
630
|
+
|
|
631
|
+
Get all token holders and distribution percentages (non-paginated).
|
|
632
|
+
|
|
633
|
+
**Parameters:**
|
|
634
|
+
```typescript
|
|
635
|
+
tokenName: string;
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
**Returns:**
|
|
639
|
+
```typescript
|
|
640
|
+
{
|
|
641
|
+
holders: Array<{
|
|
642
|
+
address: string; // Holder address
|
|
643
|
+
balance: string; // Token balance
|
|
644
|
+
percentage: number; // Ownership percentage
|
|
645
|
+
}>;
|
|
646
|
+
totalSupply: string;
|
|
647
|
+
totalHolders: number;
|
|
648
|
+
lastUpdated: Date;
|
|
649
|
+
}
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
**Example:**
|
|
653
|
+
```typescript
|
|
654
|
+
const distribution = await sdk.fetchTokenDistribution('anime');
|
|
655
|
+
const topHolders = distribution.holders
|
|
656
|
+
.sort((a, b) => b.percentage - a.percentage)
|
|
657
|
+
.slice(0, 5);
|
|
658
|
+
|
|
659
|
+
topHolders.forEach((h, i) => {
|
|
660
|
+
console.log(`#${i + 1}: ${h.percentage.toFixed(2)}% (${h.address})`);
|
|
661
|
+
});
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
### `fetchProfile(address?)`
|
|
665
|
+
|
|
666
|
+
Get user profile information.
|
|
667
|
+
|
|
668
|
+
**Parameters:**
|
|
669
|
+
```typescript
|
|
670
|
+
address?: string; // Wallet address (default: authenticated user)
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
**Returns:**
|
|
674
|
+
```typescript
|
|
675
|
+
{
|
|
676
|
+
address: string;
|
|
677
|
+
fullName: string;
|
|
678
|
+
profileImage: string;
|
|
679
|
+
createdAt: Date;
|
|
680
|
+
}
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
### `updateProfile(options)`
|
|
684
|
+
|
|
685
|
+
Update user profile.
|
|
686
|
+
|
|
687
|
+
**Parameters:**
|
|
688
|
+
```typescript
|
|
689
|
+
interface UpdateProfileOptions {
|
|
690
|
+
fullName: string;
|
|
691
|
+
profileImage: string; // URL or empty string
|
|
692
|
+
address: string; // Wallet address
|
|
693
|
+
}
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
## Price History & Analytics
|
|
699
|
+
|
|
700
|
+
### `fetchPriceHistory(options)`
|
|
701
|
+
|
|
702
|
+
Get historical price snapshots (paginated, Node.js only).
|
|
703
|
+
|
|
704
|
+
**Parameters:**
|
|
705
|
+
```typescript
|
|
706
|
+
interface FetchPriceHistoryOptions {
|
|
707
|
+
tokenName?: string; // Simple token name (NEW v3.20.0)
|
|
708
|
+
tokenId?: string | TokenClassKey; // OR full token ID
|
|
709
|
+
from?: Date | string; // Start date (ISO 8601)
|
|
710
|
+
to?: Date | string; // End date (ISO 8601)
|
|
711
|
+
sortOrder?: 'ASC' | 'DESC'; // Default: 'DESC' (newest first)
|
|
712
|
+
page?: number; // Default: 1
|
|
713
|
+
limit?: number; // Default: 10, max: 50
|
|
714
|
+
}
|
|
715
|
+
```
|
|
716
|
+
|
|
717
|
+
**Returns:**
|
|
718
|
+
```typescript
|
|
719
|
+
{
|
|
720
|
+
snapshots: Array<{
|
|
721
|
+
price: string; // Token price in GUSDC
|
|
722
|
+
timestamp: Date; // Snapshot timestamp
|
|
723
|
+
tokenId: string; // Token identifier
|
|
724
|
+
}>;
|
|
725
|
+
page: number;
|
|
726
|
+
limit: number;
|
|
727
|
+
total: number;
|
|
728
|
+
totalPages: number;
|
|
729
|
+
hasNext: boolean;
|
|
730
|
+
hasPrevious: boolean;
|
|
731
|
+
}
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
**Example:**
|
|
735
|
+
```typescript
|
|
736
|
+
// Using simple token name
|
|
737
|
+
const history = await sdk.fetchPriceHistory({
|
|
738
|
+
tokenName: 'anime',
|
|
739
|
+
from: new Date('2025-01-01'),
|
|
740
|
+
to: new Date('2025-01-31'),
|
|
741
|
+
limit: 50
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
console.log(`Latest price: $${history.snapshots[0].price}`);
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
### `fetchAllPriceHistory(options)`
|
|
748
|
+
|
|
749
|
+
Get all historical price snapshots (auto-paginated, Node.js only).
|
|
750
|
+
|
|
751
|
+
**Parameters:** Same as `fetchPriceHistory()` but without pagination parameters
|
|
752
|
+
|
|
753
|
+
**Returns:** Same structure as `fetchPriceHistory()` with all snapshots combined
|
|
754
|
+
|
|
755
|
+
**Example:**
|
|
756
|
+
```typescript
|
|
757
|
+
const allHistory = await sdk.fetchAllPriceHistory({
|
|
758
|
+
tokenName: 'anime',
|
|
759
|
+
from: '2024-01-01',
|
|
760
|
+
to: '2025-01-31'
|
|
761
|
+
});
|
|
762
|
+
|
|
763
|
+
console.log(`Total snapshots: ${allHistory.snapshots.length}`);
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
### `fetchTokenDetails(tokenId)`
|
|
767
|
+
|
|
768
|
+
Get comprehensive token metadata from DEX API.
|
|
769
|
+
|
|
770
|
+
**Parameters:**
|
|
771
|
+
```typescript
|
|
772
|
+
tokenId: string | {
|
|
773
|
+
collection: string;
|
|
774
|
+
category: string;
|
|
775
|
+
type: string;
|
|
776
|
+
additionalKey: string;
|
|
777
|
+
};
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
**Returns:**
|
|
781
|
+
```typescript
|
|
782
|
+
{
|
|
783
|
+
symbol: string;
|
|
784
|
+
name: string;
|
|
785
|
+
decimals: number;
|
|
786
|
+
verified: boolean;
|
|
787
|
+
image: string;
|
|
788
|
+
description: string;
|
|
789
|
+
network: string;
|
|
790
|
+
chainId: string;
|
|
791
|
+
contractAddress: string;
|
|
792
|
+
tradingEnabled: boolean;
|
|
793
|
+
currentPrice?: string;
|
|
794
|
+
volume24h?: string;
|
|
795
|
+
}
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
**Example:**
|
|
799
|
+
```typescript
|
|
800
|
+
const details = await sdk.fetchTokenDetails('Token|Unit|GUSDC|eth:0x...');
|
|
801
|
+
|
|
802
|
+
if (details.verified && details.tradingEnabled) {
|
|
803
|
+
console.log(`${details.symbol}: ${details.name}`);
|
|
804
|
+
}
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
---
|
|
808
|
+
|
|
809
|
+
## Real-Time Features
|
|
810
|
+
|
|
811
|
+
### `fetchTrades(options?)`
|
|
812
|
+
|
|
813
|
+
Get trade history for your wallet.
|
|
814
|
+
|
|
815
|
+
**Parameters:**
|
|
816
|
+
```typescript
|
|
817
|
+
interface FetchTradesOptions {
|
|
818
|
+
tokenName?: string; // Filter by token
|
|
819
|
+
tradeType?: 'BUY' | 'SELL'; // Filter by type
|
|
820
|
+
userAddress?: string; // Filter by user address
|
|
821
|
+
startDate?: Date; // Start date
|
|
822
|
+
endDate?: Date; // End date
|
|
823
|
+
sortOrder?: 'ASC' | 'DESC'; // Default: 'DESC'
|
|
824
|
+
page?: number; // Default: 1
|
|
825
|
+
limit?: number; // Default: 10, max: 20
|
|
826
|
+
}
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
**Returns:**
|
|
830
|
+
```typescript
|
|
831
|
+
Array<{
|
|
832
|
+
transactionId: string;
|
|
833
|
+
type: 'BUY' | 'SELL';
|
|
834
|
+
tokenName: string;
|
|
835
|
+
inputAmount: string;
|
|
836
|
+
outputAmount: string;
|
|
837
|
+
fees: { transaction: string; gas: string };
|
|
838
|
+
timestamp: Date;
|
|
839
|
+
status: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
840
|
+
}>
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### `getBundlerTransactionResult(transactionId)`
|
|
844
|
+
|
|
845
|
+
Get detailed transaction status and results.
|
|
846
|
+
|
|
847
|
+
**Parameters:**
|
|
848
|
+
```typescript
|
|
849
|
+
transactionId: string; // UUID format transaction ID
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
**Returns:**
|
|
853
|
+
```typescript
|
|
854
|
+
{
|
|
855
|
+
id: string;
|
|
856
|
+
method: string;
|
|
857
|
+
status: 'COMPLETED' | 'FAILED' | 'PENDING' | 'PROCESSING';
|
|
858
|
+
result?: {
|
|
859
|
+
transactionId: string;
|
|
860
|
+
inputAmount: string;
|
|
861
|
+
outputAmount: string;
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
---
|
|
867
|
+
|
|
868
|
+
## Type Definitions
|
|
869
|
+
|
|
870
|
+
### TokenClassKey
|
|
871
|
+
```typescript
|
|
872
|
+
interface TokenClassKey {
|
|
873
|
+
collection: string; // Usually "Token"
|
|
874
|
+
category: string; // Usually "Unit"
|
|
875
|
+
type: string; // Token symbol (e.g., "GALA")
|
|
876
|
+
additionalKey: string; // Network/chain info or "none"
|
|
877
|
+
}
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
### TransactionResult
|
|
881
|
+
```typescript
|
|
882
|
+
interface TransactionResult {
|
|
883
|
+
transactionId: string;
|
|
884
|
+
status: 'COMPLETED' | 'FAILED' | 'PENDING';
|
|
885
|
+
inputAmount: string;
|
|
886
|
+
outputAmount: string;
|
|
887
|
+
actualFees: {
|
|
888
|
+
transaction: string;
|
|
889
|
+
gas: string;
|
|
890
|
+
rbc?: string;
|
|
891
|
+
};
|
|
892
|
+
timestamp: Date;
|
|
893
|
+
}
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
### SwapQuote
|
|
897
|
+
```typescript
|
|
898
|
+
interface SwapQuote {
|
|
899
|
+
estimatedOutput: string;
|
|
900
|
+
priceImpact: number;
|
|
901
|
+
feeTier: number;
|
|
902
|
+
exchangeRate: string;
|
|
903
|
+
minimumOutput: string;
|
|
904
|
+
}
|
|
905
|
+
```
|
|
906
|
+
|
|
907
|
+
---
|
|
908
|
+
|
|
909
|
+
## Error Handling
|
|
910
|
+
|
|
911
|
+
The SDK throws descriptive errors for invalid operations:
|
|
912
|
+
|
|
913
|
+
```typescript
|
|
914
|
+
try {
|
|
915
|
+
const quote = await sdk.getSwapQuoteExactInput('GALA', 'UNKNOWN', '100');
|
|
916
|
+
} catch (error) {
|
|
917
|
+
if (error.message.includes('Pool not found')) {
|
|
918
|
+
console.log('Token pair has no DEX liquidity');
|
|
919
|
+
} else if (error.message.includes('Invalid token')) {
|
|
920
|
+
console.log('Token format is not recognized');
|
|
921
|
+
} else if (error.message.includes('Wallet')) {
|
|
922
|
+
console.log('No wallet configured - set privateKey in SDK config');
|
|
923
|
+
} else {
|
|
924
|
+
console.log(`Error: ${error.message}`);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
```
|
|
928
|
+
|
|
929
|
+
### Common Error Scenarios
|
|
930
|
+
|
|
931
|
+
| Error | Cause | Solution |
|
|
932
|
+
|-------|-------|----------|
|
|
933
|
+
| "Wallet not configured" | No privateKey set for signing | Add privateKey to SDK config |
|
|
934
|
+
| "Pool not found" | Token pair has no DEX liquidity | Check token has graduated |
|
|
935
|
+
| "Slippage exceeded" | Price moved too much | Increase slippageTolerance |
|
|
936
|
+
| "Insufficient balance" | Not enough tokens to sell | Check wallet balance first |
|
|
937
|
+
| "Invalid token format" | Token ID is malformed | Use correct format or simple symbol |
|
|
938
|
+
|
|
939
|
+
---
|
|
940
|
+
|
|
941
|
+
## Version Compatibility
|
|
942
|
+
|
|
943
|
+
- **SDK Version**: v3.23.0+
|
|
944
|
+
- **GSwap SDK**: v0.0.7+
|
|
945
|
+
- **Node.js**: 16+
|
|
946
|
+
- **Browser**: Modern browsers with ES2020+ support
|
|
947
|
+
|
|
948
|
+
---
|
|
949
|
+
|
|
950
|
+
## Additional Resources
|
|
951
|
+
|
|
952
|
+
- [GalaSwap Integration Guide](../docs/gswap-integration.md)
|
|
953
|
+
- [Project Instructions & Examples](../CLAUDE.md)
|
|
954
|
+
- [GitHub Repository](https://github.com/GalaChain/launchpad-sdk)
|
|
955
|
+
- [MCP Server Tools Reference](../packages/mcp-server/README.md)
|