@gala-chain/launchpad-sdk 3.7.8 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.8.0 - 2025-10-10
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Local bonding curve calculations** - Client-side instant price quotes without network calls
|
|
8
|
+
- `calculateBuyAmountLocal()` - Calculate buy amounts locally using exponential bonding curve formulas
|
|
9
|
+
- `calculateSellAmountLocal()` - Calculate sell amounts locally with reverse bonding curve fee support
|
|
10
|
+
- `calculateBuyAmountExternal()` - Explicit wrapper for GalaChain buy calculations
|
|
11
|
+
- `calculateSellAmountExternal()` - Explicit wrapper for GalaChain sell calculations
|
|
12
|
+
- `BondingCurveCalculator` utility class with 4 calculation methods
|
|
13
|
+
- `BondingCurveConstants` - All bonding curve parameters (BASE_PRICE, SCALE, fees, etc.)
|
|
14
|
+
- Local calculations match external results with <0.01% difference
|
|
15
|
+
- Supports per-call mode override via `calculateAmountMode` parameter
|
|
16
|
+
|
|
17
|
+
- **Token graduation helper** - Convenient utility for checking pool completion status
|
|
18
|
+
- `isTokenGraduated()` - Returns boolean indicating if token has completed bonding curve phase
|
|
19
|
+
- Checks pool `saleStatus === 'Completed'` condition
|
|
20
|
+
- Useful for conditional logic before graduation attempts
|
|
21
|
+
|
|
22
|
+
- **Demo script** - Comprehensive trading demonstration
|
|
23
|
+
- `npm run demo-trades` - Exercises all 4 calculation methods (buy native, buy exact, sell exact, sell native)
|
|
24
|
+
- Creates test token for live trading
|
|
25
|
+
- A/B comparison of local vs external calculations
|
|
26
|
+
- Real trade execution with slippage protection
|
|
27
|
+
- Complete workflow from token creation to final balance verification
|
|
28
|
+
|
|
29
|
+
### Fixed
|
|
30
|
+
|
|
31
|
+
- **Critical bonding curve formula bug** - Fixed exponential integration limits
|
|
32
|
+
- Changed from integrating 0→tokens to currentSupply→(currentSupply + tokens)
|
|
33
|
+
- Previously caused mathematically impossible negative GALA costs
|
|
34
|
+
- Formula now correctly uses: `exp((supply + tokens) * SCALE) - exp(supply * SCALE)`
|
|
35
|
+
- All calculations now match GalaChain server results exactly
|
|
36
|
+
|
|
37
|
+
### Benefits
|
|
38
|
+
|
|
39
|
+
- ✅ **Instant quotes** - No network delay for price calculations
|
|
40
|
+
- ✅ **Offline support** - Calculate prices without internet connection
|
|
41
|
+
- ✅ **Reduced costs** - No API rate limits or GalaChain call costs for quotes
|
|
42
|
+
- ✅ **Perfect accuracy** - <0.01% difference from server calculations
|
|
43
|
+
- ✅ **Flexible modes** - Use local or external calculations via `calculateAmountMode`
|
|
44
|
+
- ✅ **Graduation utilities** - Easy pool status checking with `isTokenGraduated()`
|
|
45
|
+
|
|
46
|
+
### Documentation
|
|
47
|
+
|
|
48
|
+
- Added `LOCAL_CALCULATIONS.md` - Complete bonding curve formula reference
|
|
49
|
+
- Updated all examples with local calculation patterns
|
|
50
|
+
- Added A/B comparison workflow documentation
|
|
51
|
+
|
|
3
52
|
## 3.7.6 - 2025-10-02
|
|
4
53
|
|
|
5
54
|
### Documentation
|
package/README.md
CHANGED
|
@@ -112,7 +112,7 @@ claude mcp add "galachain-launchpad" -- env PRIVATE_KEY=<YOUR_PRIVATE_KEY> ENVIR
|
|
|
112
112
|
- `DEBUG` - Enable debug logging: `true` | `false` (default: false)
|
|
113
113
|
- `TIMEOUT` - Request timeout in milliseconds (default: 30000)
|
|
114
114
|
|
|
115
|
-
**Features**:
|
|
115
|
+
**Features**: 46 tools for complete Gala Launchpad operations
|
|
116
116
|
|
|
117
117
|
See: [MCP Server Documentation](../../mcp-server/README.md)
|
|
118
118
|
|
|
@@ -121,7 +121,7 @@ See: [MCP Server Documentation](../../mcp-server/README.md)
|
|
|
121
121
|
Need help with SDK integration, trading bots, or MCP server development?
|
|
122
122
|
|
|
123
123
|
Ask **[@agent-galachain-launchpad-developer](../../@agent-galachain-launchpad-developer.md)** - a specialized AI agent with expertise in:
|
|
124
|
-
- Complete SDK API (
|
|
124
|
+
- Complete SDK API (45 methods)
|
|
125
125
|
- Trading patterns and DeFi best practices
|
|
126
126
|
- MCP server architecture
|
|
127
127
|
- Error handling strategies
|
|
@@ -574,6 +574,26 @@ calculateInitialBuyAmount(options): Promise<AmountCalculationResult>
|
|
|
574
574
|
calculateBuyAmountForGraduation(tokenName): Promise<AmountCalculationResult>
|
|
575
575
|
// Returns: { amount, reverseBondingCurveFee, transactionFee }
|
|
576
576
|
// Calculates exact GALA cost to buy all remaining tokens and graduate pool
|
|
577
|
+
|
|
578
|
+
// Local Calculations (Client-Side, No Network)
|
|
579
|
+
calculateBuyAmountLocal(options): Promise<AmountCalculationResult>
|
|
580
|
+
// Options: { tokenName, amount, type: 'native' | 'exact' }
|
|
581
|
+
// Returns: { amount, reverseBondingCurveFee: '0', transactionFee, gasFee }
|
|
582
|
+
// Instant buy calculation using local bonding curve formulas
|
|
583
|
+
|
|
584
|
+
calculateSellAmountLocal(options): Promise<AmountCalculationResult>
|
|
585
|
+
// Options: { tokenName, amount, type: 'native' | 'exact', maxSupply, minFeePortion, maxFeePortion }
|
|
586
|
+
// Returns: { amount, reverseBondingCurveFee, transactionFee, gasFee }
|
|
587
|
+
// Instant sell calculation with reverse bonding curve fees
|
|
588
|
+
|
|
589
|
+
// External Calculations (GalaChain Network)
|
|
590
|
+
calculateBuyAmountExternal(options): Promise<AmountCalculationResult>
|
|
591
|
+
// Explicit external calculation wrapper (same as calculateBuyAmount)
|
|
592
|
+
|
|
593
|
+
calculateSellAmountExternal(options): Promise<AmountCalculationResult>
|
|
594
|
+
// Explicit external calculation wrapper (same as calculateSellAmount)
|
|
595
|
+
|
|
596
|
+
// Note: Pass `calculateAmountMode: 'local' | 'external'` to override SDK default mode
|
|
577
597
|
```
|
|
578
598
|
|
|
579
599
|
### **Trading Operations**
|
|
@@ -619,6 +639,7 @@ uploadProfileImage(options): Promise<ImageUploadResult>
|
|
|
619
639
|
### **Validation & Utilities**
|
|
620
640
|
- `isTokenNameAvailable(tokenName: string): Promise<boolean>`
|
|
621
641
|
- `isTokenSymbolAvailable(symbol: string): Promise<boolean>`
|
|
642
|
+
- `isTokenGraduated(tokenName: string): Promise<boolean>` - Check if token completed bonding curve phase
|
|
622
643
|
- `getAddress(): string` - Get backend format address (eth|...)
|
|
623
644
|
- `getEthereumAddress(): string` - Get Ethereum format address (0x...)
|
|
624
645
|
- `getUrlByTokenName(tokenName: string): string` - Get frontend URL for token
|
|
@@ -856,7 +877,7 @@ Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) for guidelines on contribut
|
|
|
856
877
|
|
|
857
878
|
- GitHub Issues: [Report bugs and request features](https://github.com/gala-chain/launchpad-sdk/issues)
|
|
858
879
|
- Documentation: [Full documentation and examples](./docs/)
|
|
859
|
-
- API Status: All
|
|
880
|
+
- API Status: All 45 methods working and tested
|
|
860
881
|
|
|
861
882
|
---
|
|
862
883
|
|
package/dist/LaunchpadSDK.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { TransferGalaData, TransferTokenData } from './types/transfer.dto';
|
|
|
7
7
|
import { TokenLaunchResult, TradeResult } from './types/result.types';
|
|
8
8
|
import { WebSocketError, WebSocketTimeoutError, TransactionFailedError } from './utils/websocket-errors';
|
|
9
9
|
export { WebSocketError, WebSocketTimeoutError, TransactionFailedError, };
|
|
10
|
-
import { FetchCommentsOptions, PostCommentOptions, FetchVolumeDataOptions, FetchTradesOptions, CalculateBuyAmountOptions, CalculateSellAmountOptions, BuyTokenOptions, SellTokenOptions, UploadImageByTokenNameOptions, FetchTokensHeldOptions, FetchTokensCreatedOptions, GraduateTokenOptions } from './types/options.dto';
|
|
10
|
+
import { FetchCommentsOptions, PostCommentOptions, FetchVolumeDataOptions, FetchTradesOptions, CalculateBuyAmountOptions, CalculateSellAmountOptions, CalculateBuyAmountLocalOptions, CalculateSellAmountLocalOptions, BuyTokenOptions, SellTokenOptions, UploadImageByTokenNameOptions, FetchTokensHeldOptions, FetchTokensCreatedOptions, GraduateTokenOptions } from './types/options.dto';
|
|
11
11
|
/**
|
|
12
12
|
* Configuration for initializing the Launchpad SDK
|
|
13
13
|
*
|
|
@@ -55,6 +55,13 @@ export interface LaunchpadSDKConfig extends SDKConfig {
|
|
|
55
55
|
slippageToleranceFactor?: number;
|
|
56
56
|
/** Optional global reverse bonding curve fee slippage factor (e.g., 0.01 = 1% fee slippage) - defaults to 0.01 */
|
|
57
57
|
maxAcceptableReverseBondingCurveFeeSlippageFactor?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Default calculation mode for amount calculations.
|
|
60
|
+
* 'local' = Client-side bonding curve (instant, no network calls)
|
|
61
|
+
* 'external' = Network calls to GalaChain (slower, always fresh)
|
|
62
|
+
* @default 'local'
|
|
63
|
+
*/
|
|
64
|
+
calculateAmountMode?: 'local' | 'external';
|
|
58
65
|
}
|
|
59
66
|
/**
|
|
60
67
|
* Main Launchpad SDK class providing access to all Gala Launchpad functionality
|
|
@@ -121,6 +128,10 @@ export declare class LaunchpadSDK {
|
|
|
121
128
|
static readonly DEFAULT_SLIPPAGE_TOLERANCE_FACTOR = 0.15;
|
|
122
129
|
/** Default reverse bonding curve fee slippage factor (1%) - Applied to maxAcceptableReverseBondingCurveFee */
|
|
123
130
|
static readonly DEFAULT_MAX_ACCEPTABLE_REVERSE_BONDING_CURVE_FEE_SLIPPAGE_FACTOR = 0.01;
|
|
131
|
+
/** Default maximum total supply for launchpad tokens (10,000,000) - Used when token-specific maxSupply not provided */
|
|
132
|
+
static readonly DEFAULT_LAUNCHPAD_TOKEN_MAX_SUPPLY = 10000000;
|
|
133
|
+
/** Default calculation mode for all amount calculations - 'local' for instant client-side bonding curve calculations */
|
|
134
|
+
static readonly DEFAULT_CALCULATE_AMOUNT_MODE: 'local' | 'external';
|
|
124
135
|
private readonly auth;
|
|
125
136
|
private readonly http;
|
|
126
137
|
private readonly galaChainHttp;
|
|
@@ -129,6 +140,7 @@ export declare class LaunchpadSDK {
|
|
|
129
140
|
private readonly config;
|
|
130
141
|
private readonly slippageToleranceFactor;
|
|
131
142
|
private readonly maxAcceptableReverseBondingCurveFeeSlippageFactor;
|
|
143
|
+
private readonly calculateAmountMode;
|
|
132
144
|
private readonly logger;
|
|
133
145
|
private readonly tokenResolverService;
|
|
134
146
|
private readonly launchpadService;
|
|
@@ -407,10 +419,127 @@ export declare class LaunchpadSDK {
|
|
|
407
419
|
/**
|
|
408
420
|
* Fetch pool details for a token - returns complete bonding curve pool state
|
|
409
421
|
*
|
|
422
|
+
* Delegates to fetchPoolDetailsForCalculation for normalized fee factors and
|
|
423
|
+
* computed values, then enriches with full pool data from GalaChain.
|
|
424
|
+
*
|
|
410
425
|
* @param tokenName Token name to fetch pool details for
|
|
411
426
|
* @returns Promise<PoolDetailsData>
|
|
412
427
|
*/
|
|
413
428
|
fetchPoolDetails(tokenName: string): Promise<PoolDetailsData>;
|
|
429
|
+
/**
|
|
430
|
+
* Fetch optimized pool details for local calculations
|
|
431
|
+
*
|
|
432
|
+
* Retrieves essential pool parameters needed for bonding curve calculations:
|
|
433
|
+
* - Current supply (computed with full precision)
|
|
434
|
+
* - Reverse bonding curve fee factors (normalized to numbers)
|
|
435
|
+
* - Net fee factor (max - min, for convenience)
|
|
436
|
+
* - Remaining tokens available in the pool
|
|
437
|
+
*
|
|
438
|
+
* This method is more efficient than `fetchPoolDetails()` as it returns only
|
|
439
|
+
* the fields needed for calculations, with automatic normalization applied.
|
|
440
|
+
*
|
|
441
|
+
* @category Pool Information
|
|
442
|
+
* @param tokenName Token name to fetch pool details for
|
|
443
|
+
* @returns Promise with calculation-optimized pool details
|
|
444
|
+
* @throws {ValidationError} If token not found or vault address invalid
|
|
445
|
+
* @throws {ConfigurationError} If GalaChain client not configured
|
|
446
|
+
* @throws {NetworkError} If API request fails
|
|
447
|
+
* @since 3.8.0
|
|
448
|
+
*
|
|
449
|
+
* @example Basic usage
|
|
450
|
+
* ```typescript
|
|
451
|
+
* const details = await sdk.fetchPoolDetailsForCalculation('mytoken');
|
|
452
|
+
* console.log('Current supply:', details.currentSupply);
|
|
453
|
+
* console.log('Remaining tokens:', details.remainingTokens);
|
|
454
|
+
* console.log('Max fee factor:', details.reverseBondingCurveMaxFeeFactor);
|
|
455
|
+
* console.log('Min fee factor:', details.reverseBondingCurveMinFeeFactor);
|
|
456
|
+
* console.log('Net fee factor:', details.reverseBondingCurveNetFeeFactor);
|
|
457
|
+
* ```
|
|
458
|
+
*
|
|
459
|
+
* @example Use with local calculations
|
|
460
|
+
* ```typescript
|
|
461
|
+
* // Fetch pool details once
|
|
462
|
+
* const details = await sdk.fetchPoolDetailsForCalculation('mytoken');
|
|
463
|
+
*
|
|
464
|
+
* // Use in multiple local calculations without additional API calls
|
|
465
|
+
* const buyCalc = await sdk.calculateBuyAmountLocal({
|
|
466
|
+
* tokenName: 'mytoken',
|
|
467
|
+
* amount: '100',
|
|
468
|
+
* type: 'native',
|
|
469
|
+
* currentSupply: details.currentSupply
|
|
470
|
+
* });
|
|
471
|
+
*
|
|
472
|
+
* const sellCalc = await sdk.calculateSellAmountLocal({
|
|
473
|
+
* tokenName: 'mytoken',
|
|
474
|
+
* amount: '50',
|
|
475
|
+
* type: 'exact',
|
|
476
|
+
* currentSupply: details.currentSupply,
|
|
477
|
+
* reverseBondingCurveMaxFeeFactor: details.reverseBondingCurveMaxFeeFactor,
|
|
478
|
+
* reverseBondingCurveMinFeeFactor: details.reverseBondingCurveMinFeeFactor
|
|
479
|
+
* });
|
|
480
|
+
* ```
|
|
481
|
+
*
|
|
482
|
+
* @example Check graduation status
|
|
483
|
+
* ```typescript
|
|
484
|
+
* const details = await sdk.fetchPoolDetailsForCalculation('mytoken');
|
|
485
|
+
* console.log(`Tokens available: ${details.remainingTokens}`);
|
|
486
|
+
*
|
|
487
|
+
* if (parseFloat(details.remainingTokens) === 0) {
|
|
488
|
+
* console.log('Pool is graduated!');
|
|
489
|
+
* } else {
|
|
490
|
+
* console.log(`Need to buy ${details.remainingTokens} more tokens to graduate`);
|
|
491
|
+
* }
|
|
492
|
+
* ```
|
|
493
|
+
*/
|
|
494
|
+
fetchPoolDetailsForCalculation(tokenName: string): Promise<{
|
|
495
|
+
currentSupply: string;
|
|
496
|
+
remainingTokens: string;
|
|
497
|
+
maxSupply: string;
|
|
498
|
+
reverseBondingCurveMaxFeeFactor: number;
|
|
499
|
+
reverseBondingCurveMinFeeFactor: number;
|
|
500
|
+
reverseBondingCurveNetFeeFactor: number;
|
|
501
|
+
}>;
|
|
502
|
+
/**
|
|
503
|
+
* Check if a token pool is graduated
|
|
504
|
+
*
|
|
505
|
+
* Convenience method that fetches pool details and returns just the graduation status.
|
|
506
|
+
* A token is considered graduated when all tokens in the bonding curve pool have been
|
|
507
|
+
* purchased, transitioning the token to full DEX trading.
|
|
508
|
+
*
|
|
509
|
+
* This method checks the pool's `saleStatus` field - pools with status 'Completed'
|
|
510
|
+
* are considered graduated.
|
|
511
|
+
*
|
|
512
|
+
* @category Pool Information
|
|
513
|
+
* @param tokenName Token name to check graduation status for
|
|
514
|
+
* @returns Promise<boolean> True if the token pool has graduated, false if still in bonding curve phase
|
|
515
|
+
* @throws ValidationError if token not found or vault address invalid
|
|
516
|
+
* @throws ConfigurationError if GalaChain client not configured
|
|
517
|
+
* @throws NetworkError if API request fails
|
|
518
|
+
* @since 3.8.0
|
|
519
|
+
*
|
|
520
|
+
* @example Check if a token has graduated
|
|
521
|
+
* ```typescript
|
|
522
|
+
* const isGraduated = await sdk.isTokenGraduated('anime');
|
|
523
|
+
* if (isGraduated) {
|
|
524
|
+
* console.log('Token has graduated to DEX trading!');
|
|
525
|
+
* } else {
|
|
526
|
+
* console.log('Token is still in bonding curve phase');
|
|
527
|
+
* }
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @example Use in conditional logic
|
|
531
|
+
* ```typescript
|
|
532
|
+
* const graduated = await sdk.isTokenGraduated('mytoken');
|
|
533
|
+
* if (graduated) {
|
|
534
|
+
* // Use DEX API for graduated token
|
|
535
|
+
* await sdk.swapOnDex(...);
|
|
536
|
+
* } else {
|
|
537
|
+
* // Use bonding curve for non-graduated token
|
|
538
|
+
* await sdk.buy(...);
|
|
539
|
+
* }
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
isTokenGraduated(tokenName: string): Promise<boolean>;
|
|
414
543
|
/**
|
|
415
544
|
* Fetch volume data for a token
|
|
416
545
|
*
|
|
@@ -504,6 +633,125 @@ export declare class LaunchpadSDK {
|
|
|
504
633
|
* @returns Promise<AmountCalculationResult>
|
|
505
634
|
*/
|
|
506
635
|
calculateSellAmount(options: CalculateSellAmountOptions): Promise<import("./types/launchpad.dto").AmountCalculationResult>;
|
|
636
|
+
/**
|
|
637
|
+
* Calculate buy amount locally using bonding curve formula
|
|
638
|
+
*
|
|
639
|
+
* Performs instant client-side calculation without network calls to GalaChain.
|
|
640
|
+
* Uses exponential bonding curve mathematics to calculate GALA costs or token amounts.
|
|
641
|
+
* Requires the current token supply to perform accurate calculations.
|
|
642
|
+
*
|
|
643
|
+
* This method enables instant price quotes and real-time calculations without
|
|
644
|
+
* API rate limits or network latency. Perfect for building responsive UIs that
|
|
645
|
+
* show live pricing as users adjust their trade amounts.
|
|
646
|
+
*
|
|
647
|
+
* @param options Local calculation options with currentSupply
|
|
648
|
+
* @returns Promise<AmountCalculationResult> Calculated amount and fees
|
|
649
|
+
* @throws ValidationError if parameters are invalid
|
|
650
|
+
* @since 3.8.0
|
|
651
|
+
* @category Local Calculations
|
|
652
|
+
*
|
|
653
|
+
* @example Calculate GALA needed to buy 1000 tokens
|
|
654
|
+
* ```typescript
|
|
655
|
+
* const result = await sdk.calculateBuyAmountLocal({
|
|
656
|
+
* tokenName: 'mytoken',
|
|
657
|
+
* amount: '1000',
|
|
658
|
+
* type: 'exact',
|
|
659
|
+
* currentSupply: '500000'
|
|
660
|
+
* });
|
|
661
|
+
* console.log('GALA needed:', result.amount);
|
|
662
|
+
* console.log('Transaction fee:', result.transactionFee);
|
|
663
|
+
* ```
|
|
664
|
+
*
|
|
665
|
+
* @example Calculate tokens received for 100 GALA
|
|
666
|
+
* ```typescript
|
|
667
|
+
* const result = await sdk.calculateBuyAmountLocal({
|
|
668
|
+
* tokenName: 'mytoken',
|
|
669
|
+
* amount: '100',
|
|
670
|
+
* type: 'native',
|
|
671
|
+
* currentSupply: '500000'
|
|
672
|
+
* });
|
|
673
|
+
* console.log('Tokens received:', result.amount);
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
calculateBuyAmountLocal(options: CalculateBuyAmountLocalOptions): Promise<import("./types/launchpad.dto").AmountCalculationResult>;
|
|
677
|
+
/**
|
|
678
|
+
* Calculate sell amount locally using bonding curve formula
|
|
679
|
+
*
|
|
680
|
+
* Performs instant client-side calculation without network calls to GalaChain.
|
|
681
|
+
* Uses exponential bonding curve mathematics to calculate GALA received or tokens needed.
|
|
682
|
+
* Requires the current token supply to perform accurate calculations.
|
|
683
|
+
*
|
|
684
|
+
* This method enables instant price quotes and real-time calculations without
|
|
685
|
+
* API rate limits or network latency. Includes reverse bonding curve fee
|
|
686
|
+
* calculation that scales with supply.
|
|
687
|
+
*
|
|
688
|
+
* @param options Local calculation options with currentSupply
|
|
689
|
+
* @returns Promise<AmountCalculationResult> Calculated amount and fees
|
|
690
|
+
* @throws ValidationError if parameters are invalid
|
|
691
|
+
* @since 3.8.0
|
|
692
|
+
* @category Local Calculations
|
|
693
|
+
*
|
|
694
|
+
* @example Calculate GALA received when selling 500 tokens
|
|
695
|
+
* ```typescript
|
|
696
|
+
* const result = await sdk.calculateSellAmountLocal({
|
|
697
|
+
* tokenName: 'mytoken',
|
|
698
|
+
* amount: '500',
|
|
699
|
+
* type: 'exact',
|
|
700
|
+
* currentSupply: '500000'
|
|
701
|
+
* });
|
|
702
|
+
* console.log('GALA received:', result.amount);
|
|
703
|
+
* console.log('Reverse bonding fee:', result.reverseBondingCurveFee);
|
|
704
|
+
* console.log('Transaction fee:', result.transactionFee);
|
|
705
|
+
* ```
|
|
706
|
+
*
|
|
707
|
+
* @example Calculate tokens needed to receive 50 GALA
|
|
708
|
+
* ```typescript
|
|
709
|
+
* const result = await sdk.calculateSellAmountLocal({
|
|
710
|
+
* tokenName: 'mytoken',
|
|
711
|
+
* amount: '50',
|
|
712
|
+
* type: 'native',
|
|
713
|
+
* currentSupply: '500000'
|
|
714
|
+
* });
|
|
715
|
+
* console.log('Tokens to sell:', result.amount);
|
|
716
|
+
* ```
|
|
717
|
+
*/
|
|
718
|
+
calculateSellAmountLocal(options: CalculateSellAmountLocalOptions): Promise<import("./types/launchpad.dto").AmountCalculationResult>;
|
|
719
|
+
/**
|
|
720
|
+
* Calculate buy amount using external GalaChain call
|
|
721
|
+
*
|
|
722
|
+
* Makes a network request to GalaChain to calculate buy amounts.
|
|
723
|
+
* Always returns fresh calculations based on current blockchain state.
|
|
724
|
+
* Use when you want guaranteed accuracy but don't mind network latency.
|
|
725
|
+
*
|
|
726
|
+
* @param options Buy amount calculation options
|
|
727
|
+
* @returns Promise<AmountCalculationResult> Calculated amount and fees from GalaChain
|
|
728
|
+
* @throws NetworkError if API request fails
|
|
729
|
+
* @since 3.8.0
|
|
730
|
+
* @category External Calculations
|
|
731
|
+
*/
|
|
732
|
+
calculateBuyAmountExternal(options: {
|
|
733
|
+
tokenName: string;
|
|
734
|
+
amount: string;
|
|
735
|
+
type: 'native' | 'exact';
|
|
736
|
+
}): Promise<import("./types/launchpad.dto").AmountCalculationResult>;
|
|
737
|
+
/**
|
|
738
|
+
* Calculate sell amount using external GalaChain call
|
|
739
|
+
*
|
|
740
|
+
* Makes a network request to GalaChain to calculate sell amounts.
|
|
741
|
+
* Always returns fresh calculations based on current blockchain state.
|
|
742
|
+
* Use when you want guaranteed accuracy but don't mind network latency.
|
|
743
|
+
*
|
|
744
|
+
* @param options Sell amount calculation options
|
|
745
|
+
* @returns Promise<AmountCalculationResult> Calculated amount and fees from GalaChain
|
|
746
|
+
* @throws NetworkError if API request fails
|
|
747
|
+
* @since 3.8.0
|
|
748
|
+
* @category External Calculations
|
|
749
|
+
*/
|
|
750
|
+
calculateSellAmountExternal(options: {
|
|
751
|
+
tokenName: string;
|
|
752
|
+
amount: string;
|
|
753
|
+
type: 'native' | 'exact';
|
|
754
|
+
}): Promise<import("./types/launchpad.dto").AmountCalculationResult>;
|
|
507
755
|
/**
|
|
508
756
|
* Calculate buy amount needed to graduate a token pool
|
|
509
757
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LaunchpadSDK.d.ts","sourceRoot":"","sources":["../src/LaunchpadSDK.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa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