@gala-chain/launchpad-sdk 0.4.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/README.md +358 -75
  2. package/dist/examples/complete-sdk-demo.d.ts +22 -0
  3. package/dist/examples/complete-sdk-demo.d.ts.map +1 -0
  4. package/dist/index.cjs.js +1 -1
  5. package/dist/index.esm.js +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/src/LaunchpadSDK.d.ts +755 -0
  8. package/dist/src/LaunchpadSDK.d.ts.map +1 -0
  9. package/dist/{api → src/api}/LaunchpadAPI.d.ts +101 -63
  10. package/dist/src/api/LaunchpadAPI.d.ts.map +1 -0
  11. package/dist/{api → src/api}/dto/BondingCurveDTOs.d.ts +8 -5
  12. package/dist/src/api/dto/BondingCurveDTOs.d.ts.map +1 -0
  13. package/dist/src/api/dto/TransferTokenDto.d.ts +76 -0
  14. package/dist/src/api/dto/TransferTokenDto.d.ts.map +1 -0
  15. package/dist/src/auth/SignatureAuth.d.ts.map +1 -0
  16. package/dist/src/auth/types.d.ts.map +1 -0
  17. package/dist/src/config/environments.d.ts +45 -0
  18. package/dist/src/config/environments.d.ts.map +1 -0
  19. package/dist/{helpers → src/helpers}/sdk.d.ts +23 -13
  20. package/dist/src/helpers/sdk.d.ts.map +1 -0
  21. package/dist/src/helpers/wallet.d.ts.map +1 -0
  22. package/dist/src/index.d.ts +25 -0
  23. package/dist/src/index.d.ts.map +1 -0
  24. package/dist/src/services/BundleService.d.ts +197 -0
  25. package/dist/src/services/BundleService.d.ts.map +1 -0
  26. package/dist/src/services/DexService.d.ts +84 -0
  27. package/dist/src/services/DexService.d.ts.map +1 -0
  28. package/dist/src/services/GalaChainService.d.ts +254 -0
  29. package/dist/src/services/GalaChainService.d.ts.map +1 -0
  30. package/dist/src/services/LaunchpadService.d.ts +479 -0
  31. package/dist/src/services/LaunchpadService.d.ts.map +1 -0
  32. package/dist/src/services/SignatureService.d.ts.map +1 -0
  33. package/dist/src/services/TokenClassKeyService.d.ts.map +1 -0
  34. package/dist/src/services/TokenResolverService.d.ts +154 -0
  35. package/dist/src/services/TokenResolverService.d.ts.map +1 -0
  36. package/dist/src/services/WebSocketManager.d.ts.map +1 -0
  37. package/dist/{api → src}/services/WebSocketService.d.ts +4 -1
  38. package/dist/src/services/WebSocketService.d.ts.map +1 -0
  39. package/dist/{types → src/types}/comment.dto.d.ts +14 -5
  40. package/dist/src/types/comment.dto.d.ts.map +1 -0
  41. package/dist/{types → src/types}/common.d.ts +36 -1
  42. package/dist/src/types/common.d.ts.map +1 -0
  43. package/dist/{types → src/types}/dto.d.ts +19 -0
  44. package/dist/src/types/dto.d.ts.map +1 -0
  45. package/dist/{types → src/types}/launchpad.dto.d.ts +216 -30
  46. package/dist/src/types/launchpad.dto.d.ts.map +1 -0
  47. package/dist/{types → src/types}/launchpad.validation.d.ts +8 -8
  48. package/dist/src/types/launchpad.validation.d.ts.map +1 -0
  49. package/dist/src/types/options.dto.d.ts +281 -0
  50. package/dist/src/types/options.dto.d.ts.map +1 -0
  51. package/dist/src/types/result.types.d.ts +120 -0
  52. package/dist/src/types/result.types.d.ts.map +1 -0
  53. package/dist/{types → src/types}/trade.dto.d.ts +46 -19
  54. package/dist/src/types/trade.dto.d.ts.map +1 -0
  55. package/dist/src/types/transfer.dto.d.ts +161 -0
  56. package/dist/src/types/transfer.dto.d.ts.map +1 -0
  57. package/dist/{types → src/types}/user.dto.d.ts +98 -38
  58. package/dist/src/types/user.dto.d.ts.map +1 -0
  59. package/dist/src/types/websocket.types.d.ts +82 -0
  60. package/dist/src/types/websocket.types.d.ts.map +1 -0
  61. package/dist/src/utils/Logger.d.ts +136 -0
  62. package/dist/src/utils/Logger.d.ts.map +1 -0
  63. package/dist/src/utils/SignatureHelper.d.ts +77 -0
  64. package/dist/src/utils/SignatureHelper.d.ts.map +1 -0
  65. package/dist/src/utils/adapters.d.ts.map +1 -0
  66. package/dist/src/utils/agent-config.d.ts.map +1 -0
  67. package/dist/src/utils/date-utils.d.ts +39 -0
  68. package/dist/src/utils/date-utils.d.ts.map +1 -0
  69. package/dist/src/utils/http.d.ts.map +1 -0
  70. package/dist/src/utils/multipart.d.ts.map +1 -0
  71. package/dist/src/utils/number-utils.d.ts +57 -0
  72. package/dist/src/utils/number-utils.d.ts.map +1 -0
  73. package/dist/src/utils/precision-math.d.ts.map +1 -0
  74. package/dist/src/utils/slippage-utils.d.ts +70 -0
  75. package/dist/src/utils/slippage-utils.d.ts.map +1 -0
  76. package/dist/src/utils/tokenNormalizer.d.ts +111 -0
  77. package/dist/src/utils/tokenNormalizer.d.ts.map +1 -0
  78. package/dist/{utils → src/utils}/validation.d.ts +4 -4
  79. package/dist/src/utils/validation.d.ts.map +1 -0
  80. package/dist/{utils → src/utils}/wallet.d.ts +2 -2
  81. package/dist/src/utils/wallet.d.ts.map +1 -0
  82. package/package.json +10 -12
  83. package/dist/LaunchpadSDK.d.ts +0 -573
  84. package/dist/LaunchpadSDK.d.ts.map +0 -1
  85. package/dist/api/CommentAPI.d.ts +0 -119
  86. package/dist/api/CommentAPI.d.ts.map +0 -1
  87. package/dist/api/LaunchpadAPI.d.ts.map +0 -1
  88. package/dist/api/TradeAPI.d.ts +0 -164
  89. package/dist/api/TradeAPI.d.ts.map +0 -1
  90. package/dist/api/Trading.d.ts +0 -176
  91. package/dist/api/Trading.d.ts.map +0 -1
  92. package/dist/api/UserAPI.d.ts +0 -426
  93. package/dist/api/UserAPI.d.ts.map +0 -1
  94. package/dist/api/WebSocketAPI.d.ts +0 -156
  95. package/dist/api/WebSocketAPI.d.ts.map +0 -1
  96. package/dist/api/dto/BondingCurveDTOs.d.ts.map +0 -1
  97. package/dist/api/services/BundleService.d.ts +0 -105
  98. package/dist/api/services/BundleService.d.ts.map +0 -1
  99. package/dist/api/services/SignatureService.d.ts.map +0 -1
  100. package/dist/api/services/TokenClassKeyService.d.ts.map +0 -1
  101. package/dist/api/services/WebSocketManager.d.ts.map +0 -1
  102. package/dist/api/services/WebSocketService.d.ts.map +0 -1
  103. package/dist/auth/SignatureAuth.d.ts.map +0 -1
  104. package/dist/auth/types.d.ts.map +0 -1
  105. package/dist/helpers/sdk.d.ts.map +0 -1
  106. package/dist/helpers/wallet.d.ts.map +0 -1
  107. package/dist/index.d.ts +0 -49
  108. package/dist/index.d.ts.map +0 -1
  109. package/dist/types/comment.dto.d.ts.map +0 -1
  110. package/dist/types/common.d.ts.map +0 -1
  111. package/dist/types/dto.d.ts.map +0 -1
  112. package/dist/types/launchpad.dto.d.ts.map +0 -1
  113. package/dist/types/launchpad.validation.d.ts.map +0 -1
  114. package/dist/types/trade.dto.d.ts.map +0 -1
  115. package/dist/types/user.dto.d.ts.map +0 -1
  116. package/dist/utils/VaultCache.d.ts +0 -73
  117. package/dist/utils/VaultCache.d.ts.map +0 -1
  118. package/dist/utils/adapters.d.ts.map +0 -1
  119. package/dist/utils/agent-config.d.ts.map +0 -1
  120. package/dist/utils/http.d.ts.map +0 -1
  121. package/dist/utils/multipart.d.ts.map +0 -1
  122. package/dist/utils/precision-math.d.ts.map +0 -1
  123. package/dist/utils/validation.d.ts.map +0 -1
  124. package/dist/utils/wallet.d.ts.map +0 -1
  125. /package/dist/{auth → src/auth}/SignatureAuth.d.ts +0 -0
  126. /package/dist/{auth → src/auth}/types.d.ts +0 -0
  127. /package/dist/{helpers → src/helpers}/wallet.d.ts +0 -0
  128. /package/dist/{api → src}/services/SignatureService.d.ts +0 -0
  129. /package/dist/{api → src}/services/TokenClassKeyService.d.ts +0 -0
  130. /package/dist/{api → src}/services/WebSocketManager.d.ts +0 -0
  131. /package/dist/{utils → src/utils}/adapters.d.ts +0 -0
  132. /package/dist/{utils → src/utils}/agent-config.d.ts +0 -0
  133. /package/dist/{utils → src/utils}/http.d.ts +0 -0
  134. /package/dist/{utils → src/utils}/multipart.d.ts +0 -0
  135. /package/dist/{utils → src/utils}/precision-math.d.ts +0 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Gala Launchpad SDK
3
+ *
4
+ * A TypeScript SDK for interacting with the Gala Launchpad backend API.
5
+ * Provides type-safe, authenticated access to all launchpad functionality.
6
+ *
7
+ * @packageDocumentation
8
+ */
9
+ export { LaunchpadSDK, type LaunchpadSDKConfig, WebSocketError, WebSocketTimeoutError, TransactionFailedError } from './LaunchpadSDK';
10
+ export { createLaunchpadSDK } from './helpers/sdk';
11
+ export { createWallet } from './helpers/wallet';
12
+ export { AgentConfig, type AgentSDKConfig, type AgentEnvironment, type SetupValidation, } from './utils/agent-config';
13
+ export { ValidationError } from './utils/validation';
14
+ export { FileValidationError } from './utils/multipart';
15
+ export type { SDKConfig, } from './types/common';
16
+ export type { PoolData, LaunchTokenData, ReverseBondingCurveConfiguration, FetchPoolsOptions, PoolsResult, AmountCalculationResult, GraphDataResult, TokenDistributionResult, TokenBadgesResult, TokenSpotPrice, } from './types/launchpad.dto';
17
+ export type { PoolDetailsData, TradesResult, } from './types/trade.dto';
18
+ export type { UserTokenType, TransferFaucetsData, TokenBalanceInfo, UpdateProfileData, FetchGalaBalanceOptions, FetchTokenBalanceOptions, UploadProfileImageOptions, TokenBalanceResult, UserTokenListResult, } from './types/user.dto';
19
+ export type { CommentsResult, } from './types/comment.dto';
20
+ export type { TransferGalaData, TransferTokenData, TransferError, TransferErrorType, } from './types/transfer.dto';
21
+ export type { FetchVolumeDataOptions, FetchTradesOptions, FetchCommentsOptions, PostCommentOptions, CalculateBuyAmountOptions, CalculateSellAmountOptions, BuyTokenOptions, SellTokenOptions, UploadImageByTokenNameOptions, FetchTokensHeldOptions, FetchTokensCreatedOptions, } from './types/options.dto';
22
+ export type { BaseTransactionResult, TokenLaunchResult, TradeResult, TransferResult, CommentResult, TransactionResult, } from './types/result.types';
23
+ export { SDKTransactionStatus, } from './types/websocket.types';
24
+ export declare const SDK_VERSION = "3.0.0";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceR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AAyB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,aAAa,EACb,iBAAiB,GAClB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EACL,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AAGjC,eAAO,MAAM,WAAW,UAAU,CAAC"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Bundle Service for Transaction Processing
3
+ *
4
+ * This service handles bundle transaction submission to the launchpad
5
+ * backend. It formats the request data in the exact structure expected
6
+ * by the bundle API and provides proper error handling.
7
+ *
8
+ * ## Bundle Transaction Format:
9
+ * ```json
10
+ * {
11
+ * "signedDto": {
12
+ * // Signed DTO with signature, types, domain
13
+ * },
14
+ * "stringsInstructions": [
15
+ * // Array of resource tracking strings
16
+ * ],
17
+ * "method": "BuyWithNative" | "BuyExactToken" | "SellExactToken" | "SellWithNative"
18
+ * }
19
+ * ```
20
+ *
21
+ * ## Response Handling:
22
+ * - Success: Returns transaction ID for WebSocket monitoring
23
+ * - Error: Provides detailed error messages for debugging
24
+ *
25
+ * @category Services
26
+ * @since 2.0.0
27
+ */
28
+ import { HttpClient } from '../utils/http';
29
+ import type { ApiResponse } from '../types/common';
30
+ import { TokenResolverService } from './TokenResolverService';
31
+ import { BuyTokenOptions, SellTokenOptions } from '../types/options.dto';
32
+ /**
33
+ * Bundle transaction data structure
34
+ */
35
+ export interface BundleTransactionData {
36
+ signedDto: any;
37
+ stringsInstructions: string[];
38
+ method: string;
39
+ }
40
+ /**
41
+ * Service for handling bundle transaction submission and trading operations
42
+ */
43
+ export declare class BundleService {
44
+ private httpClient;
45
+ private tokenResolver;
46
+ private walletProvider?;
47
+ private userAddress?;
48
+ private defaultSlippageToleranceFactor;
49
+ private readonly bundleEndpoint;
50
+ private readonly logger;
51
+ private signatureService?;
52
+ private tokenKeyService?;
53
+ constructor(httpClient: HttpClient, tokenResolver: TokenResolverService, debugMode?: boolean, walletProvider?: any | undefined, userAddress?: string | undefined, defaultSlippageToleranceFactor?: number);
54
+ /**
55
+ * Submit a bundle transaction to the backend
56
+ *
57
+ * @param bundleData - Complete bundle transaction data
58
+ * @returns API response with transaction ID or error
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const bundleData = {
63
+ * signedDto: signedPayload,
64
+ * stringsInstructions: [
65
+ * '$service$Token$Unit$ANIME$none$launchpad',
66
+ * '$tokenBalance$Token$Unit$ANIME$none$vaultAddress',
67
+ * // ... more strings
68
+ * ],
69
+ * method: 'BuyWithNative'
70
+ * };
71
+ *
72
+ * const response = await bundleService.submitTransaction(bundleData);
73
+ * ```
74
+ */
75
+ submitTransaction(bundleData: BundleTransactionData): Promise<ApiResponse>;
76
+ /**
77
+ * Validate bundle transaction data
78
+ */
79
+ private validateBundleData;
80
+ /**
81
+ * Format bundle request for API submission
82
+ */
83
+ private formatBundleRequest;
84
+ /**
85
+ * Handle bundle API response
86
+ */
87
+ private handleBundleResponse;
88
+ /**
89
+ * Format error message for consistent error handling
90
+ */
91
+ private formatErrorMessage;
92
+ /**
93
+ * Get bundle transaction status
94
+ *
95
+ * @param transactionId - Transaction ID returned from submitTransaction
96
+ * @returns Transaction status information
97
+ */
98
+ getTransactionStatus(transactionId: string): Promise<ApiResponse>;
99
+ /**
100
+ * Cancel a pending bundle transaction
101
+ *
102
+ * @param transactionId - Transaction ID to cancel
103
+ * @returns Cancellation result
104
+ */
105
+ cancelTransaction(transactionId: string): Promise<ApiResponse>;
106
+ /**
107
+ * Get bundle service health status
108
+ *
109
+ * @returns Service health information
110
+ */
111
+ getHealthStatus(): Promise<ApiResponse>;
112
+ /**
113
+ * Buy tokens with unified, simplified API
114
+ *
115
+ * @param options Trading options
116
+ * @param options.tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
117
+ * @param options.amount Amount to trade (GALA for 'native', tokens for 'exact')
118
+ * @param options.type Trading type: 'native' = spend GALA, 'exact' = buy exact tokens
119
+ * @param options.expectedAmount Expected amount from prior calculation (required)
120
+ * @param options.slippageToleranceFactor Optional slippage tolerance factor (default: SDK default)
121
+ * @returns Promise<ApiResponse> Transaction result
122
+ * @throws ValidationError if parameters are invalid or token not found
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // Buy tokens by spending exactly 100 GALA
127
+ * const result = await bundleService.buyToken({
128
+ * tokenName: "dragnrkti",
129
+ * amount: "100",
130
+ * type: "native",
131
+ * expectedAmount: "1342612.26",
132
+ * slippageToleranceFactor: 0.05
133
+ * });
134
+ *
135
+ * // Buy exactly 50 tokens
136
+ * const result = await bundleService.buyToken({
137
+ * tokenName: "dragnrkti",
138
+ * amount: "50",
139
+ * type: "exact",
140
+ * expectedAmount: "3.75",
141
+ * slippageToleranceFactor: 0.03
142
+ * });
143
+ * ```
144
+ */
145
+ buyToken(options: BuyTokenOptions): Promise<ApiResponse>;
146
+ /**
147
+ * Sell tokens with unified, simplified API
148
+ *
149
+ * @param options Trading options
150
+ * @param options.tokenName Token name (e.g., "dragnrkti", "rocketri", "unicornri")
151
+ * @param options.amount Amount to trade (tokens for 'exact', GALA for 'native')
152
+ * @param options.type Trading type: 'exact' = sell exact tokens, 'native' = receive exact GALA
153
+ * @param options.expectedAmount Expected amount from prior calculation (required)
154
+ * @param options.maxAcceptableReverseBondingCurveFee Optional max acceptable reverse bonding curve fee
155
+ * @param options.slippageToleranceFactor Optional slippage tolerance factor (default: SDK default)
156
+ * @returns Promise<ApiResponse> Transaction result
157
+ * @throws ValidationError if parameters are invalid or token not found
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * // Sell exactly 50 tokens (with slippage protection)
162
+ * const result = await bundleService.sellToken({
163
+ * tokenName: "dragnrkti",
164
+ * amount: "50",
165
+ * type: "exact",
166
+ * expectedAmount: "3.75",
167
+ * slippageToleranceFactor: 0.05
168
+ * });
169
+ *
170
+ * // Sell tokens to receive exactly 25 GALA (with slippage protection)
171
+ * const result = await bundleService.sellToken({
172
+ * tokenName: "dragnrkti",
173
+ * amount: "25",
174
+ * type: "native",
175
+ * expectedAmount: "333.33",
176
+ * slippageToleranceFactor: 0.03
177
+ * });
178
+ * ```
179
+ */
180
+ sellToken(options: SellTokenOptions): Promise<ApiResponse>;
181
+ /**
182
+ * Ensure trading services are available
183
+ */
184
+ private ensureTradingServicesAvailable;
185
+ /**
186
+ * Execute bundle transaction with signature generation
187
+ */
188
+ private executeBundleTransaction;
189
+ /**
190
+ * Resolves a token name to its vault address using TokenResolverService
191
+ *
192
+ * @param tokenName Token name to resolve (e.g., 'dragnrkti', 'rocketri')
193
+ * @returns Promise<string | null> Vault address if found, null otherwise
194
+ */
195
+ private resolveTokenNameToVault;
196
+ }
197
+ //# sourceMappingURL=BundleService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BundleService.d.ts","sourceRoot":"","sources":["../../../src/services/BundleService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAMzE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,GAAG,CAAC;IACf,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAYD;;GAEG;AACH,qBAAa,aAAa;IAOtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa;IAErB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,WAAW,CAAC;IACpB,OAAO,CAAC,8BAA8B;IAXxC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAa;IAC5C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,gBAAgB,CAAC,CAAmB;IAC5C,OAAO,CAAC,eAAe,CAAC,CAAuB;gBAGrC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,oBAAoB,EAC3C,SAAS,GAAE,OAAe,EAClB,cAAc,CAAC,EAAE,GAAG,YAAA,EACpB,WAAW,CAAC,EAAE,MAAM,YAAA,EACpB,8BAA8B,GAAE,MAAa;IAYvD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,iBAAiB,CACrB,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,WAAW,CAAC;IA4CvB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAmD1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAQ3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAwB5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAoB1B;;;;;OAKG;IACG,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA8BvE;;;;;OAKG;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IA8BpE;;;;OAIG;IACG,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC;IA6B7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC;IA6F9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACG,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAgHhE;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAYtC;;OAEG;YACW,wBAAwB;IA2DtC;;;;;OAKG;YAEW,uBAAuB;CAKtC"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * DEX API Service
3
+ *
4
+ * This service handles DEX API spot price operations for tokens.
5
+ * It provides methods to fetch current USD spot prices for DEX tokens
6
+ * and calculate spot prices for launchpad tokens.
7
+ */
8
+ import { HttpClient } from '../utils/http';
9
+ import { TokenSpotPrice } from '../types/launchpad.dto';
10
+ import { CalculateBuyAmountOptions } from '../types/options.dto';
11
+ import { AmountCalculationResult } from '../types/launchpad.dto';
12
+ /**
13
+ * DexService handles DEX API spot price operations
14
+ *
15
+ * This service provides access to token pricing information from the DEX API.
16
+ * It supports both single and multiple token price queries, as well as
17
+ * calculated spot prices for launchpad tokens.
18
+ *
19
+ * @category Services
20
+ * @since 1.0.0
21
+ */
22
+ export declare class DexService {
23
+ private readonly http;
24
+ constructor(http: HttpClient);
25
+ /**
26
+ * Fetch current USD spot prices for one or more DEX token symbols
27
+ *
28
+ * Uses the DEX API to retrieve current pricing information for tokens.
29
+ * Supports both single symbol and multiple symbol requests with comma-separated format.
30
+ *
31
+ * @param symbols Single symbol string or array of symbols (e.g., 'GALA', ['GALA', 'SILK'])
32
+ * @returns Promise<TokenSpotPrice[]> Array of simplified token spot prices
33
+ *
34
+ * @example Single token price
35
+ * ```typescript
36
+ * const prices = await dexService.fetchTokenSpotPrice('GALA');
37
+ * console.log(prices[0].price); // 0.01463269
38
+ * console.log(prices[0].symbol); // 'GALA'
39
+ * ```
40
+ *
41
+ * @example Multiple token prices
42
+ * ```typescript
43
+ * const prices = await dexService.fetchTokenSpotPrice(['GALA', 'SILK', 'MUSIC']);
44
+ * prices.forEach(price => {
45
+ * console.log(`${price.symbol}: $${price.price}`);
46
+ * });
47
+ * ```
48
+ *
49
+ * @throws Error if no valid symbols provided
50
+ * @throws Error if API request fails
51
+ */
52
+ fetchTokenSpotPrice(symbols: string | string[]): Promise<TokenSpotPrice[]>;
53
+ /**
54
+ * Calculate spot price for a launchpad token in USD
55
+ *
56
+ * Calculates the USD price of a launchpad token by:
57
+ * 1. Determining how many tokens you get for 1 GALA using calculateBuyAmount
58
+ * 2. Getting the current GALA price in USD
59
+ * 3. Computing: GALA_price_USD / tokens_per_GALA
60
+ *
61
+ * **Note**: This method requires a reference to the LaunchpadAPI's calculateBuyAmount
62
+ * method to work. It should be called from the LaunchpadAPI context.
63
+ *
64
+ * @param tokenName Token name (e.g., 'dragnrkti', 'rocketri', 'unicornri')
65
+ * @param calculateBuyAmount Reference to LaunchpadAPI's calculateBuyAmount method
66
+ * @returns Promise<TokenSpotPrice> Spot price with symbol and USD price
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * const price = await dexService.fetchLaunchpadTokenSpotPrice(
71
+ * 'dragnrkti',
72
+ * (opts) => launchpadAPI.calculateBuyAmount(opts)
73
+ * );
74
+ * console.log(`${price.symbol}: $${price.price.toFixed(6)}`);
75
+ * // Output: DRAGNRKTI: $0.000123
76
+ * ```
77
+ *
78
+ * @throws Error if token not found
79
+ * @throws Error if price calculation fails
80
+ * @throws Error if GALA price unavailable
81
+ */
82
+ fetchLaunchpadTokenSpotPrice(tokenName: string, calculateBuyAmount: (options: CalculateBuyAmountOptions) => Promise<AmountCalculationResult>): Promise<TokenSpotPrice>;
83
+ }
84
+ //# sourceMappingURL=DexService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DexService.d.ts","sourceRoot":"","sources":["../../../src/services/DexService.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EACL,cAAc,EAEf,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;;;;;;;;GASG;AACH,qBAAa,UAAU;IACT,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAsChF;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,4BAA4B,CAChC,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,CAAC,OAAO,EAAE,yBAAyB,KAAK,OAAO,CAAC,uBAAuB,CAAC,GAC3F,OAAO,CAAC,cAAc,CAAC;CA4C3B"}
@@ -0,0 +1,254 @@
1
+ /**
2
+ * GalaChain Service
3
+ *
4
+ * Consolidated service for all GalaChain gateway operations.
5
+ * This service encapsulates direct interactions with the GalaChain gateway,
6
+ * providing a clean separation of concerns between backend API calls and
7
+ * blockchain operations.
8
+ *
9
+ * Features:
10
+ * - Pool details fetching (for bonding curves)
11
+ * - GALA balance queries
12
+ * - Token balance queries
13
+ * - GALA transfers with EIP-712 signatures
14
+ * - Token transfers with EIP-712 signatures
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const galaChainService = new GalaChainService(galaChainHttp, wallet);
19
+ *
20
+ * // Fetch pool details for bonding curve
21
+ * const poolDetails = await galaChainService.fetchPoolDetails({
22
+ * vaultAddress: "service|Token$Unit$MYSYMBOL$address$launchpad"
23
+ * });
24
+ *
25
+ * // Get GALA balance
26
+ * const balance = await galaChainService.fetchGalaBalance({
27
+ * owner: "eth|1234567890abcdef1234567890abcdef12345678",
28
+ * collection: "GALA",
29
+ * category: "Unit",
30
+ * additionalKey: "none",
31
+ * type: "none",
32
+ * instance: "0"
33
+ * });
34
+ *
35
+ * // Transfer tokens
36
+ * const txId = await galaChainService.transferToken({
37
+ * from: "eth|sender...",
38
+ * to: "eth|recipient...",
39
+ * quantity: "100",
40
+ * tokenInstance: {...},
41
+ * signedPayload: {...}
42
+ * });
43
+ * ```
44
+ */
45
+ import { HttpClient } from '../utils/http';
46
+ import { TokenResolverService } from './TokenResolverService';
47
+ import { TokenClassKey } from '../types/common';
48
+ import { Wallet } from 'ethers';
49
+ import { FetchPoolDetailsData, InternalFetchPoolDetailsResponse } from '../types/trade.dto';
50
+ import { TokenBalanceResult } from '../types/user.dto';
51
+ import { TransferGalaData, TransferTokenData } from '../types/transfer.dto';
52
+ /**
53
+ * GalaChain Service for blockchain operations
54
+ */
55
+ export declare class GalaChainService {
56
+ private readonly http;
57
+ private readonly wallet;
58
+ private readonly tokenResolver;
59
+ private readonly signatureHelper;
60
+ private readonly logger;
61
+ /**
62
+ * Initialize GalaChain Service
63
+ *
64
+ * @param http - HTTP client configured for GalaChain gateway
65
+ * @param wallet - Ethers wallet for signing transactions
66
+ * @param tokenResolver - Token resolver service for vault address resolution
67
+ * @param debug - Enable debug logging (default: false)
68
+ */
69
+ constructor(http: HttpClient, wallet: Wallet, tokenResolver: TokenResolverService, debug?: boolean);
70
+ /**
71
+ * Fetches pool details by vault address from GalaChain
72
+ *
73
+ * Internal method for fetching pool details by vault address
74
+ * Used internally after vault resolution
75
+ *
76
+ * @param data Fetch pool details data with vault address
77
+ * @returns Promise<InternalFetchPoolDetailsResponse> Current trading pool state
78
+ * @throws ValidationError if input validation fails
79
+ * @throws Error if pool details fetch fails
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const poolDetails = await galaChainService.fetchPoolDetails({
84
+ * vaultAddress: "service|Token$Unit$MYSYMBOL$eth:address$launchpad"
85
+ * });
86
+ * console.log('GALA in vault:', poolDetails.Data.nativeTokenQuantity);
87
+ * ```
88
+ */
89
+ fetchPoolDetails(data: FetchPoolDetailsData): Promise<InternalFetchPoolDetailsResponse>;
90
+ /**
91
+ * Validates fetch pool details data
92
+ */
93
+ private validateFetchPoolDetailsData;
94
+ /**
95
+ * Fetches GALA balance for a user from GalaChain
96
+ *
97
+ * Uses the GalaChain FetchBalances endpoint with GALA token parameters.
98
+ *
99
+ * @param requestBody Balance query parameters
100
+ * @returns Promise<TokenBalanceResult | null> Clean balance information or null if not held
101
+ * @throws Error if balance fetch fails
102
+ *
103
+ * @example
104
+ * ```typescript
105
+ * const balance = await galaChainService.fetchGalaBalance({
106
+ * owner: "eth|1234567890abcdef1234567890abcdef12345678",
107
+ * collection: "GALA",
108
+ * category: "Unit",
109
+ * additionalKey: "none",
110
+ * type: "none",
111
+ * instance: "0"
112
+ * });
113
+ * ```
114
+ */
115
+ fetchGalaBalance(requestBody: {
116
+ owner: string;
117
+ collection: string;
118
+ category: string;
119
+ additionalKey: string;
120
+ type: string;
121
+ instance: string;
122
+ }): Promise<TokenBalanceResult | null>;
123
+ /**
124
+ * Fetches token balance for any token from GalaChain
125
+ *
126
+ * Generic method for querying token balances using the GalaChain FetchBalances endpoint.
127
+ *
128
+ * @param requestBody Balance query parameters
129
+ * @returns Promise<TokenBalanceResult | null> Clean balance information or null if not held
130
+ * @throws Error if balance fetch fails
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const balance = await galaChainService.fetchTokenBalance({
135
+ * owner: "eth|1234567890abcdef1234567890abcdef12345678",
136
+ * collection: "ANIME",
137
+ * category: "Unit",
138
+ * additionalKey: "none",
139
+ * type: "none",
140
+ * instance: "0"
141
+ * });
142
+ * ```
143
+ */
144
+ fetchTokenBalance(requestBody: {
145
+ owner: string;
146
+ collection: string;
147
+ category: string;
148
+ additionalKey: string;
149
+ type: string;
150
+ instance: string;
151
+ }): Promise<TokenBalanceResult | null>;
152
+ /**
153
+ * Transfer GALA tokens between wallets
154
+ *
155
+ * Creates and signs a TransferToken transaction for GALA using EIP-712
156
+ * signatures and submits it to the GalaChain gateway.
157
+ *
158
+ * @param data - Transfer data including recipient and amount
159
+ * @returns Promise<string> Transaction ID from successful transfer
160
+ *
161
+ * @example
162
+ * ```typescript
163
+ * const transactionId = await galaChainService.transferGala({
164
+ * recipientAddress: 'eth|1234567890abcdef1234567890abcdef12345678',
165
+ * amount: '1000000000000000000' // 1 GALA in wei
166
+ * });
167
+ *
168
+ * console.log('GALA transfer successful:', transactionId);
169
+ * ```
170
+ *
171
+ * @throws {TransferError} When validation fails or transfer is rejected
172
+ */
173
+ transferGala(data: TransferGalaData): Promise<string>;
174
+ /**
175
+ * Transfer launchpad tokens between wallets
176
+ *
177
+ * Creates and signs a TransferToken transaction for launchpad tokens using
178
+ * EIP-712 signatures and submits it to the GalaChain gateway.
179
+ *
180
+ * @param data - Transfer data including recipient, token name, and amount
181
+ * @returns Promise<string> Transaction ID from successful transfer
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * const transactionId = await galaChainService.transferToken({
186
+ * to: 'eth|9876543210fedcba9876543210fedcba98765432',
187
+ * tokenName: 'tinyevil',
188
+ * amount: '100000000'
189
+ * });
190
+ *
191
+ * console.log('Token transfer successful:', transactionId);
192
+ * ```
193
+ *
194
+ * @throws {TransferError} When validation fails or transfer is rejected
195
+ */
196
+ transferToken(data: TransferTokenData): Promise<string>;
197
+ /**
198
+ * Resolve token class key from token name
199
+ *
200
+ * Public method to resolve a token name to its tokenClassKey for caching or optimization patterns.
201
+ * Uses the same resolution logic as transferToken internally.
202
+ *
203
+ * @param tokenName - Token name to resolve (e.g., 'unicorn', 'tinyevil')
204
+ * @returns Promise<TokenClassKey> The resolved token class key object
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * const tokenClassKey = await galaChainService.resolveTokenClassKey('unicorn');
209
+ * // Returns: { collection: "Token", category: "Unit", type: "UNI", additionalKey: "eth:..." }
210
+ *
211
+ * // Can be cached and used later for direct transfers
212
+ * await galaChainService.transferToken({
213
+ * to: 'eth|...',
214
+ * tokenId: tokenClassKey, // Direct, no lookup
215
+ * amount: '1'
216
+ * });
217
+ * ```
218
+ *
219
+ * @throws {TransferError} When token name cannot be resolved
220
+ */
221
+ resolveTokenClassKey(tokenName: string): Promise<TokenClassKey>;
222
+ /**
223
+ * Validate GALA transfer data
224
+ */
225
+ private validateTransferGalaData;
226
+ /**
227
+ * Validate token transfer data
228
+ */
229
+ private validateTransferTokenData;
230
+ /**
231
+ * Check if an address is in valid format (eth| or 0x)
232
+ */
233
+ private isValidAddress;
234
+ /**
235
+ * Convert address to backend format (eth|40hex)
236
+ */
237
+ private formatAddressForBackend;
238
+ /**
239
+ * Resolve token name to tokenInstance object for transfers
240
+ * Uses TokenResolverService to get vault address, then parses it to extract tokenInstance components
241
+ */
242
+ private resolveTokenInstance;
243
+ /**
244
+ * Parse vault address and extract token instance components
245
+ * Vault format: service|Token$Unit$UNI$eth:9401b171307bE656f00F9e18DF756643FD3a91dE$launchpad
246
+ * Returns structured tokenInstance object like transferGala uses
247
+ */
248
+ private resolveTokenInstanceFromVaultAddress;
249
+ /**
250
+ * Handle transfer errors with proper typing and context
251
+ */
252
+ private handleTransferError;
253
+ }
254
+ //# sourceMappingURL=GalaChainService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GalaChainService.d.ts","sourceRoot":"","sources":["../../../src/services/GalaChainService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EACL,oBAAoB,EACpB,gCAAgC,EAEjC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EAQlB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,qBAAa,gBAAgB;IAazB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAdhC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAEhC;;;;;;;OAOG;gBAEgB,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,oBAAoB,EACpD,KAAK,GAAE,OAAe;IAUxB;;;;;;;;;;;;;;;;;;OAkBG;IACG,gBAA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