@gala-chain/launchpad-sdk 3.7.8 → 3.8.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/CHANGELOG.md +49 -0
- package/README.md +24 -3
- package/dist/LaunchpadSDK.d.ts +249 -1
- package/dist/LaunchpadSDK.d.ts.map +1 -1
- package/dist/api/LaunchpadAPI.d.ts +317 -24
- package/dist/api/LaunchpadAPI.d.ts.map +1 -1
- package/dist/constants/bondingCurve.d.ts +102 -0
- package/dist/constants/bondingCurve.d.ts.map +1 -0
- package/dist/constants/enums.d.ts +30 -0
- package/dist/constants/enums.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/services/GalaChainService.d.ts.map +1 -1
- package/dist/types/launchpad.dto.d.ts +6 -0
- package/dist/types/launchpad.dto.d.ts.map +1 -1
- package/dist/types/options.dto.d.ts +109 -4
- package/dist/types/options.dto.d.ts.map +1 -1
- package/dist/types/trade.dto.d.ts +16 -2
- package/dist/types/trade.dto.d.ts.map +1 -1
- package/dist/utils/bondingCurveCalculations.d.ts +144 -0
- package/dist/utils/bondingCurveCalculations.d.ts.map +1 -0
- package/dist/utils/validation.d.ts +28 -0
- package/dist/utils/validation.d.ts.map +1 -1
- package/package.json +2 -1
|
@@ -9,7 +9,7 @@ import { Logger } from '../utils/Logger';
|
|
|
9
9
|
import { TokenResolverService } from '../services/TokenResolverService';
|
|
10
10
|
import { FetchPoolOptions, PoolsResult, AmountCalculationResult, CheckPoolOptions, GraphDataResult, TokenDistributionResult, LaunchTokenData, TokenBadgesResult, TokenSpotPrice } from '../types/launchpad.dto';
|
|
11
11
|
import { CalculatePreMintData } from '../types/trade.dto';
|
|
12
|
-
import { FetchVolumeDataOptions, CalculateBuyAmountOptions, CalculateSellAmountOptions, HasTokenBadgeOptions, UploadImageByTokenNameOptions } from '../types/options.dto';
|
|
12
|
+
import { FetchVolumeDataOptions, CalculateBuyAmountOptions, CalculateSellAmountOptions, CalculateBuyAmountLocalOptions, CalculateSellAmountLocalOptions, HasTokenBadgeOptions, UploadImageByTokenNameOptions } from '../types/options.dto';
|
|
13
13
|
/**
|
|
14
14
|
* Launchpad API controller for pool creation and management operations
|
|
15
15
|
*
|
|
@@ -56,7 +56,13 @@ export declare class LaunchpadAPI {
|
|
|
56
56
|
private readonly bundleHttp?;
|
|
57
57
|
private readonly galaChainHttp?;
|
|
58
58
|
private readonly dexApiHttp?;
|
|
59
|
-
|
|
59
|
+
private readonly defaultCalculateAmountMode;
|
|
60
|
+
constructor(http: HttpClient, tokenResolver: TokenResolverService, logger: Logger, bundleHttp?: HttpClient | undefined, galaChainHttp?: HttpClient | undefined, dexApiHttp?: HttpClient | undefined, defaultCalculateAmountMode?: 'local' | 'external');
|
|
61
|
+
/**
|
|
62
|
+
* Helper to conditionally add properties to an object (for exactOptionalPropertyTypes compliance)
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
private addIfDefined;
|
|
60
66
|
/**
|
|
61
67
|
* Uploads an image for a token pool
|
|
62
68
|
*
|
|
@@ -207,55 +213,303 @@ export declare class LaunchpadAPI {
|
|
|
207
213
|
/**
|
|
208
214
|
* Get buy token amount calculation with unified API (replaces getBuyWithNativeAmountByTokenName/getBuyExactTokenAmountByTokenName)
|
|
209
215
|
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
+
* Supports both local (instant) and external (network-based) calculation modes with a flexible priority chain:
|
|
217
|
+
* 1. Per-call `options.mode` override (highest priority)
|
|
218
|
+
* 2. SDK-level `calculateAmountMode` configuration
|
|
219
|
+
* 3. Hardcoded default ('local')
|
|
220
|
+
*
|
|
221
|
+
* Priority chain resolution examples:
|
|
222
|
+
* - Per-call override: `calculateBuyAmount({ mode: 'external' })` → uses 'external' (regardless of SDK config)
|
|
223
|
+
* - SDK config: `new SDK({ calculateAmountMode: 'external' })` → uses 'external' (if no per-call override)
|
|
224
|
+
* - Hardcoded default: `new SDK({})` → uses 'local' (if no config or override)
|
|
225
|
+
*
|
|
226
|
+
* @param {CalculateBuyAmountOptions} options - Calculation options
|
|
227
|
+
* @param {string} options.tokenName - Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
228
|
+
* @param {string} options.amount - Amount to calculate (GALA for 'native', tokens for 'exact')
|
|
229
|
+
* @param {'native' | 'exact'} options.type - Calculation type: 'native' = GALA input, 'exact' = token output
|
|
230
|
+
* @param {'local' | 'external'} [options.mode] - Calculation mode: 'local' = instant client-side, 'external' = network-based (optional, uses SDK default if not provided)
|
|
231
|
+
* @param {string} [options.currentSupply] - Current token supply for local calculations (optional, auto-fetched if mode is 'local' and not provided)
|
|
232
|
+
* @returns {Promise<AmountCalculationResult>} Calculated amount
|
|
233
|
+
* @throws {ValidationError} If parameters are invalid or token not found
|
|
216
234
|
*
|
|
217
235
|
* @example
|
|
218
236
|
* ```typescript
|
|
219
|
-
* // Calculate tokens received when spending 1 GALA
|
|
220
|
-
* const result = await sdk.launchpad.
|
|
237
|
+
* // Calculate tokens received when spending 1 GALA (uses SDK default mode)
|
|
238
|
+
* const result = await sdk.launchpad.calculateBuyAmount({
|
|
239
|
+
* tokenName: "dragnrkti",
|
|
221
240
|
* amount: "1", // 1 GALA
|
|
222
241
|
* type: "native"
|
|
223
242
|
* });
|
|
224
243
|
*
|
|
225
|
-
* // Calculate GALA cost for buying 100 tokens
|
|
226
|
-
* const result = await sdk.launchpad.
|
|
244
|
+
* // Calculate GALA cost for buying 100 tokens (force external mode)
|
|
245
|
+
* const result = await sdk.launchpad.calculateBuyAmount({
|
|
246
|
+
* tokenName: "dragnrkti",
|
|
227
247
|
* amount: "100", // 100 tokens
|
|
228
|
-
* type: "exact"
|
|
248
|
+
* type: "exact",
|
|
249
|
+
* mode: "external" // Override: always use network calculation
|
|
250
|
+
* });
|
|
251
|
+
*
|
|
252
|
+
* // Fast local calculation with known supply (instant, no network calls)
|
|
253
|
+
* const result = await sdk.launchpad.calculateBuyAmount({
|
|
254
|
+
* tokenName: "dragnrkti",
|
|
255
|
+
* amount: "100",
|
|
256
|
+
* type: "exact",
|
|
257
|
+
* mode: "local",
|
|
258
|
+
* currentSupply: "500000" // Pre-fetched supply eliminates API roundtrip
|
|
229
259
|
* });
|
|
230
260
|
* ```
|
|
231
261
|
*/
|
|
232
262
|
calculateBuyAmount(options: CalculateBuyAmountOptions): Promise<AmountCalculationResult>;
|
|
263
|
+
/**
|
|
264
|
+
* Calculate buy amount using external network calculation (GalaChain)
|
|
265
|
+
*
|
|
266
|
+
* Performs network-based calculation via GalaChain gateway. This method bypasses local
|
|
267
|
+
* bonding curve calculations and queries the blockchain directly for accurate, real-time pricing.
|
|
268
|
+
*
|
|
269
|
+
* Use this method when:
|
|
270
|
+
* - You need guaranteed accuracy from the blockchain source
|
|
271
|
+
* - You want to ensure calculations match on-chain state exactly
|
|
272
|
+
* - Network latency is acceptable for your use case
|
|
273
|
+
*
|
|
274
|
+
* For instant calculations without network calls, use `calculateBuyAmountLocal()` instead.
|
|
275
|
+
*
|
|
276
|
+
* @param options External calculation options
|
|
277
|
+
* @param options.tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
278
|
+
* @param options.amount Amount to calculate (GALA for 'native', tokens for 'exact')
|
|
279
|
+
* @param options.type Calculation type: 'native' = GALA input, 'exact' = token output
|
|
280
|
+
* @returns Promise<AmountCalculationResult> Calculated amount from GalaChain
|
|
281
|
+
* @throws ValidationError if token not found or parameters invalid
|
|
282
|
+
*
|
|
283
|
+
* @example Calculate GALA cost for buying 100 tokens
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const result = await sdk.launchpad.calculateBuyAmountExternal({
|
|
286
|
+
* tokenName: 'mytoken',
|
|
287
|
+
* amount: '100',
|
|
288
|
+
* type: 'exact'
|
|
289
|
+
* });
|
|
290
|
+
* console.log('GALA needed:', result.amount);
|
|
291
|
+
* ```
|
|
292
|
+
*
|
|
293
|
+
* @example Calculate tokens received for 1 GALA
|
|
294
|
+
* ```typescript
|
|
295
|
+
* const result = await sdk.launchpad.calculateBuyAmountExternal({
|
|
296
|
+
* tokenName: 'mytoken',
|
|
297
|
+
* amount: '1',
|
|
298
|
+
* type: 'native'
|
|
299
|
+
* });
|
|
300
|
+
* console.log('Tokens received:', result.amount);
|
|
301
|
+
* ```
|
|
302
|
+
*
|
|
303
|
+
* @since 3.8.0
|
|
304
|
+
* @category External Calculations
|
|
305
|
+
*/
|
|
306
|
+
calculateBuyAmountExternal(options: {
|
|
307
|
+
tokenName: string;
|
|
308
|
+
amount: string;
|
|
309
|
+
type: 'native' | 'exact';
|
|
310
|
+
}): Promise<AmountCalculationResult>;
|
|
233
311
|
/**
|
|
234
312
|
* Get sell token amount calculation with unified API (replaces getSellExactTokenAmountByTokenName/getSellWithNativeAmountByTokenName)
|
|
235
313
|
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
314
|
+
* Supports both local (instant) and external (network-based) calculation modes with a flexible priority chain:
|
|
315
|
+
* 1. Per-call `options.mode` override (highest priority)
|
|
316
|
+
* 2. SDK-level `calculateAmountMode` configuration
|
|
317
|
+
* 3. Hardcoded default ('local')
|
|
318
|
+
*
|
|
319
|
+
* Priority chain resolution examples:
|
|
320
|
+
* - Per-call override: `calculateSellAmount({ mode: 'external' })` → uses 'external' (regardless of SDK config)
|
|
321
|
+
* - SDK config: `new SDK({ calculateAmountMode: 'external' })` → uses 'external' (if no per-call override)
|
|
322
|
+
* - Hardcoded default: `new SDK({})` → uses 'local' (if no config or override)
|
|
323
|
+
*
|
|
324
|
+
* @param {CalculateSellAmountOptions} options - Calculation options
|
|
325
|
+
* @param {string} options.tokenName - Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
326
|
+
* @param {string} options.amount - Amount to calculate (tokens for 'exact', GALA for 'native')
|
|
327
|
+
* @param {'exact' | 'native'} options.type - Calculation type: 'exact' = token input, 'native' = GALA output
|
|
328
|
+
* @param {'local' | 'external'} [options.mode] - Calculation mode: 'local' = instant client-side, 'external' = network-based (optional, uses SDK default if not provided)
|
|
329
|
+
* @param {string} [options.currentSupply] - Current token supply for local calculations (optional, auto-fetched if mode is 'local' and not provided)
|
|
330
|
+
* @param {string} [options.maxSupply] - Maximum token supply for local calculations (optional, auto-fetched if mode is 'local' and not provided)
|
|
331
|
+
* @param {number} [options.reverseBondingCurveMaxFeeFactor] - Max fee factor for local calculations (optional, auto-fetched if mode is 'local' and not provided)
|
|
332
|
+
* @param {number} [options.reverseBondingCurveMinFeeFactor] - Min fee factor for local calculations (optional, auto-fetched if mode is 'local' and not provided)
|
|
333
|
+
* @returns {Promise<AmountCalculationResult>} Calculated amount
|
|
334
|
+
* @throws {ValidationError} If parameters are invalid or token not found
|
|
242
335
|
*
|
|
243
336
|
* @example
|
|
244
337
|
* ```typescript
|
|
245
|
-
* // Calculate GALA received when selling 50 tokens
|
|
246
|
-
* const result = await sdk.launchpad.
|
|
338
|
+
* // Calculate GALA received when selling 50 tokens (uses SDK default mode)
|
|
339
|
+
* const result = await sdk.launchpad.calculateSellAmount({
|
|
340
|
+
* tokenName: "dragnrkti",
|
|
247
341
|
* amount: "50", // 50 tokens
|
|
248
342
|
* type: "exact"
|
|
249
343
|
* });
|
|
250
344
|
*
|
|
251
|
-
* // Calculate tokens needed to receive 0.5 GALA
|
|
252
|
-
* const result = await sdk.launchpad.
|
|
345
|
+
* // Calculate tokens needed to receive 0.5 GALA (force external mode)
|
|
346
|
+
* const result = await sdk.launchpad.calculateSellAmount({
|
|
347
|
+
* tokenName: "dragnrkti",
|
|
253
348
|
* amount: "0.5", // 0.5 GALA
|
|
254
|
-
* type: "native"
|
|
349
|
+
* type: "native",
|
|
350
|
+
* mode: "external" // Override: always use network calculation
|
|
351
|
+
* });
|
|
352
|
+
*
|
|
353
|
+
* // Fast local calculation with all parameters (instant, no network calls)
|
|
354
|
+
* const result = await sdk.launchpad.calculateSellAmount({
|
|
355
|
+
* tokenName: "dragnrkti",
|
|
356
|
+
* amount: "50",
|
|
357
|
+
* type: "exact",
|
|
358
|
+
* mode: "local",
|
|
359
|
+
* currentSupply: "500000",
|
|
360
|
+
* maxSupply: "10000000",
|
|
361
|
+
* reverseBondingCurveMaxFeeFactor: 0.5,
|
|
362
|
+
* reverseBondingCurveMinFeeFactor: 0.0 // Pre-fetched params eliminate API roundtrip
|
|
255
363
|
* });
|
|
256
364
|
* ```
|
|
257
365
|
*/
|
|
258
366
|
calculateSellAmount(options: CalculateSellAmountOptions): Promise<AmountCalculationResult>;
|
|
367
|
+
/**
|
|
368
|
+
* Calculate sell amount using external network calculation (GalaChain)
|
|
369
|
+
*
|
|
370
|
+
* Performs network-based calculation via GalaChain gateway. This method bypasses local
|
|
371
|
+
* bonding curve calculations and queries the blockchain directly for accurate, real-time pricing.
|
|
372
|
+
*
|
|
373
|
+
* Use this method when:
|
|
374
|
+
* - You need guaranteed accuracy from the blockchain source
|
|
375
|
+
* - You want to ensure calculations match on-chain state exactly
|
|
376
|
+
* - Network latency is acceptable for your use case
|
|
377
|
+
*
|
|
378
|
+
* For instant calculations without network calls, use `calculateSellAmountLocal()` instead.
|
|
379
|
+
*
|
|
380
|
+
* @param options External calculation options
|
|
381
|
+
* @param options.tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
|
|
382
|
+
* @param options.amount Amount to calculate (tokens for 'exact', GALA for 'native')
|
|
383
|
+
* @param options.type Calculation type: 'exact' = token input, 'native' = GALA output
|
|
384
|
+
* @returns Promise<AmountCalculationResult> Calculated amount from GalaChain
|
|
385
|
+
* @throws ValidationError if token not found or parameters invalid
|
|
386
|
+
*
|
|
387
|
+
* @example Calculate GALA received when selling 50 tokens
|
|
388
|
+
* ```typescript
|
|
389
|
+
* const result = await sdk.launchpad.calculateSellAmountExternal({
|
|
390
|
+
* tokenName: 'mytoken',
|
|
391
|
+
* amount: '50',
|
|
392
|
+
* type: 'exact'
|
|
393
|
+
* });
|
|
394
|
+
* console.log('GALA received:', result.amount);
|
|
395
|
+
* ```
|
|
396
|
+
*
|
|
397
|
+
* @example Calculate tokens needed to sell to receive 0.5 GALA
|
|
398
|
+
* ```typescript
|
|
399
|
+
* const result = await sdk.launchpad.calculateSellAmountExternal({
|
|
400
|
+
* tokenName: 'mytoken',
|
|
401
|
+
* amount: '0.5',
|
|
402
|
+
* type: 'native'
|
|
403
|
+
* });
|
|
404
|
+
* console.log('Tokens to sell:', result.amount);
|
|
405
|
+
* ```
|
|
406
|
+
*
|
|
407
|
+
* @since 3.8.0
|
|
408
|
+
* @category External Calculations
|
|
409
|
+
*/
|
|
410
|
+
calculateSellAmountExternal(options: {
|
|
411
|
+
tokenName: string;
|
|
412
|
+
amount: string;
|
|
413
|
+
type: 'exact' | 'native';
|
|
414
|
+
}): Promise<AmountCalculationResult>;
|
|
415
|
+
/**
|
|
416
|
+
* Calculate buy amount locally using bonding curve formula
|
|
417
|
+
*
|
|
418
|
+
* Performs instant client-side calculation without network calls to GalaChain.
|
|
419
|
+
* Uses exponential bonding curve mathematics to calculate GALA costs or token amounts.
|
|
420
|
+
*
|
|
421
|
+
* Benefits:
|
|
422
|
+
* - Instant calculation (no network latency)
|
|
423
|
+
* - No API rate limits
|
|
424
|
+
* - Works offline with known supply
|
|
425
|
+
* - Perfect for real-time price discovery
|
|
426
|
+
*
|
|
427
|
+
* Returns the same AmountCalculationResult structure as calculateBuyAmount for
|
|
428
|
+
* drop-in compatibility with existing code.
|
|
429
|
+
*
|
|
430
|
+
* @param options Local calculation options
|
|
431
|
+
* @param options.tokenName Token name (optional if currentSupply provided, required for auto-fetching)
|
|
432
|
+
* @param options.amount Amount to calculate (GALA for 'native', tokens for 'exact')
|
|
433
|
+
* @param options.type Calculation type: 'native' = GALA input, 'exact' = token output
|
|
434
|
+
* @param options.currentSupply Current token supply (optional - auto-fetched if missing)
|
|
435
|
+
* @returns Promise<AmountCalculationResult> Calculated amount and fees
|
|
436
|
+
* @throws ValidationError if parameters are invalid or tokenName missing when auto-fetching needed
|
|
437
|
+
*
|
|
438
|
+
* @example Calculate with auto-fetch (requires tokenName)
|
|
439
|
+
* ```typescript
|
|
440
|
+
* const result = await sdk.launchpad.calculateBuyAmountLocal({
|
|
441
|
+
* tokenName: 'mytoken',
|
|
442
|
+
* amount: '1000',
|
|
443
|
+
* type: 'exact'
|
|
444
|
+
* });
|
|
445
|
+
* ```
|
|
446
|
+
*
|
|
447
|
+
* @example Pure calculation without network calls (tokenName not needed!)
|
|
448
|
+
* ```typescript
|
|
449
|
+
* const result = await sdk.launchpad.calculateBuyAmountLocal({
|
|
450
|
+
* amount: '1000',
|
|
451
|
+
* type: 'exact',
|
|
452
|
+
* currentSupply: '500000'
|
|
453
|
+
* });
|
|
454
|
+
* console.log('GALA needed:', result.amount);
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @since 3.8.0
|
|
458
|
+
* @category Local Calculations
|
|
459
|
+
*/
|
|
460
|
+
calculateBuyAmountLocal(options: CalculateBuyAmountLocalOptions): Promise<AmountCalculationResult>;
|
|
461
|
+
/**
|
|
462
|
+
* Calculate sell amount locally using bonding curve formula
|
|
463
|
+
*
|
|
464
|
+
* Performs instant client-side calculation without network calls to GalaChain.
|
|
465
|
+
* Uses exponential bonding curve mathematics to calculate GALA received or tokens needed.
|
|
466
|
+
*
|
|
467
|
+
* Benefits:
|
|
468
|
+
* - Instant calculation (no network latency)
|
|
469
|
+
* - No API rate limits
|
|
470
|
+
* - Works offline with known parameters
|
|
471
|
+
* - Perfect for real-time price discovery
|
|
472
|
+
*
|
|
473
|
+
* Returns the same AmountCalculationResult structure as calculateSellAmount for
|
|
474
|
+
* drop-in compatibility with existing code. Includes reverse bonding curve fee
|
|
475
|
+
* calculation that scales with supply.
|
|
476
|
+
*
|
|
477
|
+
* @param options Local calculation options
|
|
478
|
+
* @param options.tokenName Token name (optional if all parameters provided, required for auto-fetching)
|
|
479
|
+
* @param options.amount Amount to calculate (tokens for 'exact', GALA for 'native')
|
|
480
|
+
* @param options.type Calculation type: 'exact' = token input, 'native' = GALA output
|
|
481
|
+
* @param options.currentSupply Current token supply (optional - auto-fetched if missing)
|
|
482
|
+
* @param options.maxSupply Maximum token supply (optional - auto-fetched if missing)
|
|
483
|
+
* @param options.reverseBondingCurveMaxFeeFactor Max fee factor (optional - auto-fetched if missing)
|
|
484
|
+
* @param options.reverseBondingCurveMinFeeFactor Min fee factor (optional - auto-fetched if missing)
|
|
485
|
+
* @returns Promise<AmountCalculationResult> Calculated amount and fees
|
|
486
|
+
* @throws ValidationError if parameters are invalid or tokenName missing when auto-fetching needed
|
|
487
|
+
*
|
|
488
|
+
* @example Calculate with auto-fetch (requires tokenName)
|
|
489
|
+
* ```typescript
|
|
490
|
+
* const result = await sdk.launchpad.calculateSellAmountLocal({
|
|
491
|
+
* tokenName: 'mytoken',
|
|
492
|
+
* amount: '500',
|
|
493
|
+
* type: 'exact'
|
|
494
|
+
* });
|
|
495
|
+
* ```
|
|
496
|
+
*
|
|
497
|
+
* @example Pure calculation without network calls (tokenName not needed!)
|
|
498
|
+
* ```typescript
|
|
499
|
+
* const result = await sdk.launchpad.calculateSellAmountLocal({
|
|
500
|
+
* amount: '500',
|
|
501
|
+
* type: 'exact',
|
|
502
|
+
* currentSupply: '500000',
|
|
503
|
+
* maxSupply: '10000000',
|
|
504
|
+
* reverseBondingCurveMaxFeeFactor: 0.5,
|
|
505
|
+
* reverseBondingCurveMinFeeFactor: 0.0
|
|
506
|
+
* });
|
|
507
|
+
* ```
|
|
508
|
+
*
|
|
509
|
+
* @since 3.8.0
|
|
510
|
+
* @category Local Calculations
|
|
511
|
+
*/
|
|
512
|
+
calculateSellAmountLocal(options: CalculateSellAmountLocalOptions): Promise<AmountCalculationResult>;
|
|
259
513
|
/**
|
|
260
514
|
* Calculate buy amount needed to graduate a token pool
|
|
261
515
|
*
|
|
@@ -417,6 +671,45 @@ export declare class LaunchpadAPI {
|
|
|
417
671
|
* ```
|
|
418
672
|
*/
|
|
419
673
|
calculateInitialBuyAmount(data: CalculatePreMintData): Promise<AmountCalculationResult>;
|
|
674
|
+
/**
|
|
675
|
+
* Fetches pool details from GalaChain optimized for local calculations
|
|
676
|
+
*
|
|
677
|
+
* Retrieves essential pool parameters needed for bonding curve calculations:
|
|
678
|
+
* - Current supply (computed with full precision)
|
|
679
|
+
* - Reverse bonding curve fee factors (normalized to numbers)
|
|
680
|
+
* - Net fee factor (max - min, for convenience)
|
|
681
|
+
* - Remaining tokens available in the pool
|
|
682
|
+
*
|
|
683
|
+
* This method is more efficient than `fetchPoolDetails()` as it returns only
|
|
684
|
+
* the fields needed for calculations, with automatic normalization applied.
|
|
685
|
+
*
|
|
686
|
+
* @param tokenName Token name to fetch pool details for
|
|
687
|
+
* @returns Promise with calculation-optimized pool details
|
|
688
|
+
* @throws {ValidationError} If token not found or vault address invalid
|
|
689
|
+
* @throws {ConfigurationError} If GalaChain client not configured
|
|
690
|
+
* @throws {NetworkError} If API request fails
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
* ```typescript
|
|
694
|
+
* const details = await sdk.launchpad.fetchPoolDetailsForCalculation('mytoken');
|
|
695
|
+
* console.log('Current supply:', details.currentSupply);
|
|
696
|
+
* console.log('Remaining tokens:', details.remainingTokens);
|
|
697
|
+
* console.log('Max fee factor:', details.reverseBondingCurveMaxFeeFactor);
|
|
698
|
+
* console.log('Min fee factor:', details.reverseBondingCurveMinFeeFactor);
|
|
699
|
+
* console.log('Net fee factor:', details.reverseBondingCurveNetFeeFactor);
|
|
700
|
+
* ```
|
|
701
|
+
*
|
|
702
|
+
* @since 3.8.0
|
|
703
|
+
* @category Pool Information
|
|
704
|
+
*/
|
|
705
|
+
fetchPoolDetailsForCalculation(tokenName: string): Promise<{
|
|
706
|
+
currentSupply: string;
|
|
707
|
+
remainingTokens: string;
|
|
708
|
+
maxSupply: string;
|
|
709
|
+
reverseBondingCurveMaxFeeFactor: number;
|
|
710
|
+
reverseBondingCurveMinFeeFactor: number;
|
|
711
|
+
reverseBondingCurveNetFeeFactor: number;
|
|
712
|
+
}>;
|
|
420
713
|
/**
|
|
421
714
|
* Gets the authenticated user's address in backend format
|
|
422
715
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LaunchpadAPI.d.ts","sourceRoot":"","sources":["../../src/api/LaunchpadAPI.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"LaunchpadAPI.d.ts","sourceRoot":"","sources":["../../src/api/LaunchpadAPI.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAmBxE,OAAO,EAEL,gBAAgB,EAGhB,WAAW,EAEX,uBAAuB,EACvB,gBAAgB,EAIhB,eAAe,EAEf,uBAAuB,EACvB,eAAe,EAKf,iBAAiB,EAIjB,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EACL,oBAAoB,EAIrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,8BAA8B,EAC9B,+BAA+B,EAC/B,oBAAoB,EACpB,6BAA6B,EAE9B,MAAM,sBAAsB,CAAC;AAI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,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G;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IA+ChF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;CAiD/E"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bonding Curve Mathematical Constants
|
|
3
|
+
*
|
|
4
|
+
* These constants define the pricing model for launchpad tokens using an exponential bonding curve.
|
|
5
|
+
* The bonding curve ensures that token prices increase as supply increases, creating natural price discovery.
|
|
6
|
+
*
|
|
7
|
+
* @category Constants
|
|
8
|
+
* @since 3.8.0
|
|
9
|
+
*
|
|
10
|
+
* @example Using constants directly
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { BondingCurveConstants } from '@gala-chain/launchpad-sdk';
|
|
13
|
+
*
|
|
14
|
+
* console.log('Base Price:', BondingCurveConstants.BASE_PRICE);
|
|
15
|
+
* console.log('Max Supply:', BondingCurveConstants.LAUNCHPAD_TOKEN_MAX_SUPPLY);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class BondingCurveConstants {
|
|
19
|
+
/**
|
|
20
|
+
* Base price of the first token in the bonding curve
|
|
21
|
+
*
|
|
22
|
+
* This determines the initial cost when supply is at its minimum.
|
|
23
|
+
* The price increases exponentially as more tokens are minted.
|
|
24
|
+
*
|
|
25
|
+
* @constant
|
|
26
|
+
* @default 0.00001650667151
|
|
27
|
+
*/
|
|
28
|
+
static readonly BASE_PRICE = 0.00001650667151;
|
|
29
|
+
/**
|
|
30
|
+
* Scaling factor controlling the rate of price increase
|
|
31
|
+
*
|
|
32
|
+
* Higher values cause faster price appreciation as supply grows.
|
|
33
|
+
* This factor is applied to supply in exponential calculations.
|
|
34
|
+
*
|
|
35
|
+
* @constant
|
|
36
|
+
* @default 0.000001166069
|
|
37
|
+
*/
|
|
38
|
+
static readonly PRICE_SCALING_FACTOR = 0.000001166069;
|
|
39
|
+
/**
|
|
40
|
+
* Trading fee percentage (0.1%)
|
|
41
|
+
*
|
|
42
|
+
* Applied to all buy and sell transactions as a transaction fee.
|
|
43
|
+
* Calculated as: transactionAmount * TRADING_FEE_FACTOR
|
|
44
|
+
*
|
|
45
|
+
* @constant
|
|
46
|
+
* @default 0.001
|
|
47
|
+
*/
|
|
48
|
+
static readonly TRADING_FEE_FACTOR = 0.001;
|
|
49
|
+
/**
|
|
50
|
+
* Static gas fee in GALA
|
|
51
|
+
*
|
|
52
|
+
* Fixed fee charged for blockchain transaction execution.
|
|
53
|
+
* This covers the cost of processing the transaction on GalaChain.
|
|
54
|
+
*
|
|
55
|
+
* @constant
|
|
56
|
+
* @default "1"
|
|
57
|
+
*/
|
|
58
|
+
static readonly GAS_FEE = "1";
|
|
59
|
+
/**
|
|
60
|
+
* Minimum unbonding fee factor (0%)
|
|
61
|
+
*
|
|
62
|
+
* Base fee applied when selling tokens back to the bonding curve.
|
|
63
|
+
* Combined with supply-based dynamic fee for total unbonding cost.
|
|
64
|
+
*
|
|
65
|
+
* @constant
|
|
66
|
+
* @default 0
|
|
67
|
+
*/
|
|
68
|
+
static readonly MIN_UNBONDING_FEE_FACTOR = 0;
|
|
69
|
+
/**
|
|
70
|
+
* Maximum unbonding fee factor (50%)
|
|
71
|
+
*
|
|
72
|
+
* Maximum additional fee that can be applied when selling tokens.
|
|
73
|
+
* Used in combination with current supply to calculate dynamic fees.
|
|
74
|
+
*
|
|
75
|
+
* @constant
|
|
76
|
+
* @default 0.5
|
|
77
|
+
*/
|
|
78
|
+
static readonly MAX_UNBONDING_FEE_FACTOR = 0.5;
|
|
79
|
+
/**
|
|
80
|
+
* Net unbonding fee factor (50%)
|
|
81
|
+
*
|
|
82
|
+
* Used to calculate supply-proportional unbonding fees.
|
|
83
|
+
* Applied as: (currentSupply / maxSupply) * NET_UNBONDING_FEE_FACTOR
|
|
84
|
+
*
|
|
85
|
+
* @constant
|
|
86
|
+
* @default 0.5
|
|
87
|
+
*/
|
|
88
|
+
static readonly NET_UNBONDING_FEE_FACTOR = 0.5;
|
|
89
|
+
/**
|
|
90
|
+
* Default maximum total supply for launchpad tokens
|
|
91
|
+
*
|
|
92
|
+
* This is the default value used when a token's specific maxSupply is not provided.
|
|
93
|
+
* Each token can have its own maxSupply value returned from pool details.
|
|
94
|
+
* Once this supply is reached, the token "graduates" from the bonding curve
|
|
95
|
+
* and becomes available for trading on the full DEX.
|
|
96
|
+
*
|
|
97
|
+
* @constant
|
|
98
|
+
* @default 10000000
|
|
99
|
+
*/
|
|
100
|
+
static readonly DEFAULT_LAUNCHPAD_TOKEN_MAX_SUPPLY = 10000000;
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=bondingCurve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bondingCurve.d.ts","sourceRoot":"","sources":["../../src/constants/bondingCurve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,qBAAqB;IAChC;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,oBAAoB;IAE9C;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,oBAAoB,kBAAkB;IAEtD;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,kBAAkB,SAAS;IAE3C;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,OAAO;IAE9B;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,wBAAwB,KAAK;IAE7C;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,wBAAwB,OAAO;IAE/C;;;;;;;;OAQG;IACH,MAAM,CAAC,QAAQ,CAAC,wBAAwB,OAAO;IAE/C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,QAAQ,CAAC,kCAAkC,YAAY;CAC/D"}
|
|
@@ -32,4 +32,34 @@ export declare const POOL_TYPES: {
|
|
|
32
32
|
readonly RECENT: "recent";
|
|
33
33
|
readonly POPULAR: "popular";
|
|
34
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Calculation mode constants for amount calculations
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* import { CALCULATION_MODES } from '@gala-chain/launchpad-sdk';
|
|
41
|
+
*
|
|
42
|
+
* // Use local mode for instant calculations
|
|
43
|
+
* await sdk.calculateBuyAmount({
|
|
44
|
+
* tokenName: 'anime',
|
|
45
|
+
* amount: '100',
|
|
46
|
+
* type: 'exact',
|
|
47
|
+
* mode: CALCULATION_MODES.LOCAL
|
|
48
|
+
* });
|
|
49
|
+
*
|
|
50
|
+
* // Use external mode for network-based calculations
|
|
51
|
+
* await sdk.calculateBuyAmount({
|
|
52
|
+
* tokenName: 'anime',
|
|
53
|
+
* amount: '100',
|
|
54
|
+
* type: 'exact',
|
|
55
|
+
* mode: CALCULATION_MODES.EXTERNAL
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const CALCULATION_MODES: {
|
|
60
|
+
/** Client-side bonding curve calculation (instant, no network calls) */
|
|
61
|
+
readonly LOCAL: "local";
|
|
62
|
+
/** Network-based calculation via GalaChain (slower, always fresh) */
|
|
63
|
+
readonly EXTERNAL: "external";
|
|
64
|
+
};
|
|
35
65
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/constants/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;;;CAGb,CAAC"}
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/constants/enums.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;;;CAGhB,CAAC;AAEX;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;;;CAGb,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,iBAAiB;IAC5B,wEAAwE;;IAExE,qEAAqE;;CAE7D,CAAC"}
|