@gala-chain/launchpad-sdk 3.31.2 → 4.0.1-beta.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 (369) hide show
  1. package/API.md +525 -5
  2. package/CHANGELOG.md +101 -9
  3. package/EXAMPLES.md +923 -0
  4. package/README.md +539 -15
  5. package/dist/index.cjs.js +1 -1
  6. package/dist/index.d.ts +37 -27
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.esm.js +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/{LaunchpadSDK.d.ts → src/LaunchpadSDK.d.ts} +1333 -37
  11. package/dist/src/LaunchpadSDK.d.ts.map +1 -0
  12. package/dist/src/api/LaunchpadAPI.d.ts.map +1 -0
  13. package/dist/src/api/dto/BondingCurveDTOs.d.ts.map +1 -0
  14. package/dist/src/api/dto/LockTokenDto.d.ts +97 -0
  15. package/dist/src/api/dto/LockTokenDto.d.ts.map +1 -0
  16. package/dist/src/api/dto/TransferTokenDto.d.ts.map +1 -0
  17. package/dist/src/api/dto/UnlockTokenDto.d.ts +86 -0
  18. package/dist/src/api/dto/UnlockTokenDto.d.ts.map +1 -0
  19. package/dist/src/auth/SignatureAuth.d.ts.map +1 -0
  20. package/dist/src/auth/types.d.ts.map +1 -0
  21. package/dist/src/config/environments.d.ts.map +1 -0
  22. package/dist/src/constants/bondingCurve.d.ts.map +1 -0
  23. package/dist/src/constants/config.d.ts.map +1 -0
  24. package/dist/src/constants/counts.d.ts.map +1 -0
  25. package/dist/src/constants/decimals.d.ts.map +1 -0
  26. package/dist/src/constants/endpoints.d.ts.map +1 -0
  27. package/dist/src/constants/enums.d.ts.map +1 -0
  28. package/dist/src/constants/error-messages.d.ts.map +1 -0
  29. package/dist/src/constants/pagination.d.ts.map +1 -0
  30. package/dist/src/constants/query-fields.d.ts.map +1 -0
  31. package/dist/src/constants/version.d.ts.map +1 -0
  32. package/dist/{constants → src/constants}/version.generated.d.ts +1 -1
  33. package/dist/src/constants/version.generated.d.ts.map +1 -0
  34. package/dist/src/helpers/sdk.d.ts.map +1 -0
  35. package/dist/src/helpers/wallet.d.ts.map +1 -0
  36. package/dist/src/index.d.ts +51 -0
  37. package/dist/src/index.d.ts.map +1 -0
  38. package/dist/src/polyfills/file-global.d.ts.map +1 -0
  39. package/dist/src/schemas/files.d.ts.map +1 -0
  40. package/dist/src/schemas/index.d.ts.map +1 -0
  41. package/dist/src/schemas/launchpad.d.ts.map +1 -0
  42. package/dist/src/schemas/pagination.d.ts.map +1 -0
  43. package/dist/src/schemas/primitives.d.ts.map +1 -0
  44. package/dist/src/schemas/trade.d.ts.map +1 -0
  45. package/dist/src/schemas/user.d.ts.map +1 -0
  46. package/dist/src/schemas/validators.d.ts.map +1 -0
  47. package/dist/src/services/BaseService.d.ts.map +1 -0
  48. package/dist/src/services/BundleService.d.ts.map +1 -0
  49. package/dist/src/services/CommentService.d.ts.map +1 -0
  50. package/dist/src/services/DexBackendClient.d.ts +46 -0
  51. package/dist/src/services/DexBackendClient.d.ts.map +1 -0
  52. package/dist/src/services/DexPoolService.d.ts +137 -0
  53. package/dist/src/services/DexPoolService.d.ts.map +1 -0
  54. package/dist/src/services/DexQuoteService.d.ts +288 -0
  55. package/dist/src/services/DexQuoteService.d.ts.map +1 -0
  56. package/dist/{services → src/services}/DexService.d.ts +83 -9
  57. package/dist/src/services/DexService.d.ts.map +1 -0
  58. package/dist/src/services/FaucetService.d.ts.map +1 -0
  59. package/dist/src/services/GSwapService.d.ts +817 -0
  60. package/dist/src/services/GSwapService.d.ts.map +1 -0
  61. package/dist/src/services/GalaChainGatewayClient.d.ts +98 -0
  62. package/dist/src/services/GalaChainGatewayClient.d.ts.map +1 -0
  63. package/dist/{services → src/services}/GalaChainService.d.ts +99 -4
  64. package/dist/src/services/GalaChainService.d.ts.map +1 -0
  65. package/dist/src/services/ImageService.d.ts.map +1 -0
  66. package/dist/src/services/LaunchpadService.d.ts.map +1 -0
  67. package/dist/src/services/MultiPoolStateManager.d.ts +284 -0
  68. package/dist/src/services/MultiPoolStateManager.d.ts.map +1 -0
  69. package/dist/src/services/PoolCacheManager.d.ts +171 -0
  70. package/dist/src/services/PoolCacheManager.d.ts.map +1 -0
  71. package/dist/src/services/PoolService.d.ts.map +1 -0
  72. package/dist/src/services/PoolStateManager.d.ts +176 -0
  73. package/dist/src/services/PoolStateManager.d.ts.map +1 -0
  74. package/dist/{services → src/services}/PriceHistoryService.d.ts +5 -5
  75. package/dist/src/services/PriceHistoryService.d.ts.map +1 -0
  76. package/dist/{services → src/services}/SignatureService.d.ts +13 -35
  77. package/dist/src/services/SignatureService.d.ts.map +1 -0
  78. package/dist/src/services/SwapEventQueue.d.ts +123 -0
  79. package/dist/src/services/SwapEventQueue.d.ts.map +1 -0
  80. package/dist/src/services/TokenClassKeyService.d.ts.map +1 -0
  81. package/dist/{services → src/services}/TokenMetadataCache.d.ts +5 -5
  82. package/dist/src/services/TokenMetadataCache.d.ts.map +1 -0
  83. package/dist/{services → src/services}/TokenMetadataService.d.ts +3 -3
  84. package/dist/src/services/TokenMetadataService.d.ts.map +1 -0
  85. package/dist/src/services/TokenResolverService.d.ts.map +1 -0
  86. package/dist/src/services/TradeService.d.ts.map +1 -0
  87. package/dist/src/services/UserService.d.ts.map +1 -0
  88. package/dist/src/services/WebSocketManager.d.ts.map +1 -0
  89. package/dist/src/services/WebSocketService.d.ts +183 -0
  90. package/dist/src/services/WebSocketService.d.ts.map +1 -0
  91. package/dist/src/services/__mocks__/logger.mock.d.ts +17 -0
  92. package/dist/src/services/__mocks__/logger.mock.d.ts.map +1 -0
  93. package/dist/{setup.d.ts.map → src/setup.d.ts.map} +1 -1
  94. package/dist/{types → src/types}/backend-responses.d.ts +17 -0
  95. package/dist/src/types/backend-responses.d.ts.map +1 -0
  96. package/dist/src/types/comment.dto.d.ts.map +1 -0
  97. package/dist/{types → src/types}/common.d.ts +2 -0
  98. package/dist/src/types/common.d.ts.map +1 -0
  99. package/dist/src/types/composite-pool.dto.d.ts +103 -0
  100. package/dist/src/types/composite-pool.dto.d.ts.map +1 -0
  101. package/dist/{types → src/types}/dex-pool.dto.d.ts +56 -5
  102. package/dist/src/types/dex-pool.dto.d.ts.map +1 -0
  103. package/dist/{types → src/types}/dto.d.ts +6 -6
  104. package/dist/src/types/dto.d.ts.map +1 -0
  105. package/dist/src/types/eip712-types.d.ts +140 -0
  106. package/dist/src/types/eip712-types.d.ts.map +1 -0
  107. package/dist/src/types/galachain-api.types.d.ts +216 -0
  108. package/dist/src/types/galachain-api.types.d.ts.map +1 -0
  109. package/dist/src/types/gswap-responses.types.d.ts +366 -0
  110. package/dist/src/types/gswap-responses.types.d.ts.map +1 -0
  111. package/dist/{types → src/types}/gswap.dto.d.ts +58 -3
  112. package/dist/src/types/gswap.dto.d.ts.map +1 -0
  113. package/dist/{types → src/types}/launchpad.dto.d.ts +232 -0
  114. package/dist/src/types/launchpad.dto.d.ts.map +1 -0
  115. package/dist/src/types/launchpad.validation.d.ts.map +1 -0
  116. package/dist/src/types/liquidity-monitor.dto.d.ts +177 -0
  117. package/dist/src/types/liquidity-monitor.dto.d.ts.map +1 -0
  118. package/dist/src/types/lock.dto.d.ts +146 -0
  119. package/dist/src/types/lock.dto.d.ts.map +1 -0
  120. package/dist/src/types/options.dto.d.ts.map +1 -0
  121. package/dist/src/types/pool-state-delta.dto.d.ts +246 -0
  122. package/dist/src/types/pool-state-delta.dto.d.ts.map +1 -0
  123. package/dist/src/types/pool-state-manager-config.dto.d.ts +103 -0
  124. package/dist/src/types/pool-state-manager-config.dto.d.ts.map +1 -0
  125. package/dist/{types → src/types}/priceHistory.dto.d.ts +4 -4
  126. package/dist/src/types/priceHistory.dto.d.ts.map +1 -0
  127. package/dist/src/types/result.types.d.ts.map +1 -0
  128. package/dist/src/types/swap-monitor.dto.d.ts +256 -0
  129. package/dist/src/types/swap-monitor.dto.d.ts.map +1 -0
  130. package/dist/src/types/trade.dto.d.ts.map +1 -0
  131. package/dist/src/types/transfer.dto.d.ts.map +1 -0
  132. package/dist/src/types/user.dto.d.ts.map +1 -0
  133. package/dist/src/types/websocket-data.types.d.ts.map +1 -0
  134. package/dist/src/types/websocket.types.d.ts.map +1 -0
  135. package/dist/src/utils/LiquidityEventExtractor.d.ts +99 -0
  136. package/dist/src/utils/LiquidityEventExtractor.d.ts.map +1 -0
  137. package/dist/src/utils/Logger.d.ts.map +1 -0
  138. package/dist/src/utils/MonitoringMetrics.d.ts +152 -0
  139. package/dist/src/utils/MonitoringMetrics.d.ts.map +1 -0
  140. package/dist/src/utils/PoolKeyNormalizer.d.ts +135 -0
  141. package/dist/src/utils/PoolKeyNormalizer.d.ts.map +1 -0
  142. package/dist/{utils → src/utils}/SignatureHelper.d.ts +38 -0
  143. package/dist/src/utils/SignatureHelper.d.ts.map +1 -0
  144. package/dist/src/utils/SwapEventExtractor.d.ts +152 -0
  145. package/dist/src/utils/SwapEventExtractor.d.ts.map +1 -0
  146. package/dist/src/utils/adapters.d.ts.map +1 -0
  147. package/dist/src/utils/agent-config.d.ts.map +1 -0
  148. package/dist/{utils → src/utils}/auto-pagination.d.ts +75 -1
  149. package/dist/src/utils/auto-pagination.d.ts.map +1 -0
  150. package/dist/{utils → src/utils}/bignumber-helpers.d.ts +79 -3
  151. package/dist/src/utils/bignumber-helpers.d.ts.map +1 -0
  152. package/dist/src/utils/bignumber-pool-cache.d.ts +169 -0
  153. package/dist/src/utils/bignumber-pool-cache.d.ts.map +1 -0
  154. package/dist/src/utils/bondingCurveCalculations.d.ts.map +1 -0
  155. package/dist/src/utils/cacheWarmingHelpers.d.ts.map +1 -0
  156. package/dist/src/utils/composite-pool-converter.d.ts +121 -0
  157. package/dist/src/utils/composite-pool-converter.d.ts.map +1 -0
  158. package/dist/src/utils/date-utils.d.ts.map +1 -0
  159. package/dist/src/utils/error-factories.d.ts.map +1 -0
  160. package/dist/src/utils/error-utils.d.ts.map +1 -0
  161. package/dist/{utils → src/utils}/errors.d.ts +86 -0
  162. package/dist/src/utils/errors.d.ts.map +1 -0
  163. package/dist/src/utils/http.d.ts.map +1 -0
  164. package/dist/src/utils/load-env.d.ts +31 -0
  165. package/dist/src/utils/load-env.d.ts.map +1 -0
  166. package/dist/src/utils/multipart-helpers.d.ts.map +1 -0
  167. package/dist/{utils → src/utils}/multipart.d.ts +2 -2
  168. package/dist/src/utils/multipart.d.ts.map +1 -0
  169. package/dist/src/utils/number-utils.d.ts.map +1 -0
  170. package/dist/src/utils/pool-pair-parser.d.ts +55 -0
  171. package/dist/src/utils/pool-pair-parser.d.ts.map +1 -0
  172. package/dist/src/utils/pool-state-validator.d.ts +207 -0
  173. package/dist/src/utils/pool-state-validator.d.ts.map +1 -0
  174. package/dist/src/utils/position-filters.d.ts +253 -0
  175. package/dist/src/utils/position-filters.d.ts.map +1 -0
  176. package/dist/src/utils/precision-math.d.ts.map +1 -0
  177. package/dist/{utils → src/utils}/query-params.d.ts +2 -2
  178. package/dist/src/utils/query-params.d.ts.map +1 -0
  179. package/dist/src/utils/response-handlers.d.ts.map +1 -0
  180. package/dist/src/utils/response-normalizers.d.ts.map +1 -0
  181. package/dist/src/utils/slippage-utils.d.ts.map +1 -0
  182. package/dist/src/utils/swap-delta-calculator.d.ts +231 -0
  183. package/dist/src/utils/swap-delta-calculator.d.ts.map +1 -0
  184. package/dist/src/utils/tick-crossing-handler.d.ts +250 -0
  185. package/dist/src/utils/tick-crossing-handler.d.ts.map +1 -0
  186. package/dist/{utils → src/utils}/token-format-converter.d.ts +18 -11
  187. package/dist/src/utils/token-format-converter.d.ts.map +1 -0
  188. package/dist/src/utils/token-parser.d.ts +235 -0
  189. package/dist/src/utils/token-parser.d.ts.map +1 -0
  190. package/dist/src/utils/tokenNormalizer.d.ts.map +1 -0
  191. package/dist/src/utils/trade-transformers.d.ts.map +1 -0
  192. package/dist/src/utils/transfer-validation.d.ts.map +1 -0
  193. package/dist/{utils → src/utils}/validation-helpers.d.ts +1 -1
  194. package/dist/src/utils/validation-helpers.d.ts.map +1 -0
  195. package/dist/src/utils/validation.d.ts.map +1 -0
  196. package/dist/src/utils/wallet.d.ts.map +1 -0
  197. package/dist/src/utils/websocket-errors.d.ts.map +1 -0
  198. package/dist/src/utils/websocket-validators.d.ts.map +1 -0
  199. package/package.json +73 -19
  200. package/dist/LaunchpadSDK.d.ts.map +0 -1
  201. package/dist/api/LaunchpadAPI.d.ts.map +0 -1
  202. package/dist/api/dto/BondingCurveDTOs.d.ts.map +0 -1
  203. package/dist/api/dto/TransferTokenDto.d.ts.map +0 -1
  204. package/dist/auth/SignatureAuth.d.ts.map +0 -1
  205. package/dist/auth/types.d.ts.map +0 -1
  206. package/dist/config/environments.d.ts.map +0 -1
  207. package/dist/constants/bondingCurve.d.ts.map +0 -1
  208. package/dist/constants/config.d.ts.map +0 -1
  209. package/dist/constants/counts.d.ts.map +0 -1
  210. package/dist/constants/decimals.d.ts.map +0 -1
  211. package/dist/constants/endpoints.d.ts.map +0 -1
  212. package/dist/constants/enums.d.ts.map +0 -1
  213. package/dist/constants/error-messages.d.ts.map +0 -1
  214. package/dist/constants/pagination.d.ts.map +0 -1
  215. package/dist/constants/query-fields.d.ts.map +0 -1
  216. package/dist/constants/version.d.ts.map +0 -1
  217. package/dist/constants/version.generated.d.ts.map +0 -1
  218. package/dist/helpers/sdk.d.ts.map +0 -1
  219. package/dist/helpers/wallet.d.ts.map +0 -1
  220. package/dist/polyfills/file-global.d.ts.map +0 -1
  221. package/dist/schemas/files.d.ts.map +0 -1
  222. package/dist/schemas/index.d.ts.map +0 -1
  223. package/dist/schemas/launchpad.d.ts.map +0 -1
  224. package/dist/schemas/pagination.d.ts.map +0 -1
  225. package/dist/schemas/primitives.d.ts.map +0 -1
  226. package/dist/schemas/trade.d.ts.map +0 -1
  227. package/dist/schemas/user.d.ts.map +0 -1
  228. package/dist/schemas/validators.d.ts.map +0 -1
  229. package/dist/services/BaseService.d.ts.map +0 -1
  230. package/dist/services/BundleService.d.ts.map +0 -1
  231. package/dist/services/CommentService.d.ts.map +0 -1
  232. package/dist/services/DexPoolService.d.ts +0 -95
  233. package/dist/services/DexPoolService.d.ts.map +0 -1
  234. package/dist/services/DexService.d.ts.map +0 -1
  235. package/dist/services/FaucetService.d.ts.map +0 -1
  236. package/dist/services/GSwapService.d.ts +0 -315
  237. package/dist/services/GSwapService.d.ts.map +0 -1
  238. package/dist/services/GalaChainService.d.ts.map +0 -1
  239. package/dist/services/ImageService.d.ts.map +0 -1
  240. package/dist/services/LaunchpadService.d.ts.map +0 -1
  241. package/dist/services/PoolService.d.ts.map +0 -1
  242. package/dist/services/PriceHistoryService.d.ts.map +0 -1
  243. package/dist/services/SignatureService.d.ts.map +0 -1
  244. package/dist/services/TokenClassKeyService.d.ts.map +0 -1
  245. package/dist/services/TokenMetadataCache.d.ts.map +0 -1
  246. package/dist/services/TokenMetadataService.d.ts.map +0 -1
  247. package/dist/services/TokenResolverService.d.ts.map +0 -1
  248. package/dist/services/TradeService.d.ts.map +0 -1
  249. package/dist/services/UserService.d.ts.map +0 -1
  250. package/dist/services/WebSocketManager.d.ts.map +0 -1
  251. package/dist/services/WebSocketService.d.ts +0 -85
  252. package/dist/services/WebSocketService.d.ts.map +0 -1
  253. package/dist/types/backend-responses.d.ts.map +0 -1
  254. package/dist/types/comment.dto.d.ts.map +0 -1
  255. package/dist/types/common.d.ts.map +0 -1
  256. package/dist/types/dex-pool.dto.d.ts.map +0 -1
  257. package/dist/types/dto.d.ts.map +0 -1
  258. package/dist/types/gswap.dto.d.ts.map +0 -1
  259. package/dist/types/launchpad.dto.d.ts.map +0 -1
  260. package/dist/types/launchpad.validation.d.ts.map +0 -1
  261. package/dist/types/options.dto.d.ts.map +0 -1
  262. package/dist/types/priceHistory.dto.d.ts.map +0 -1
  263. package/dist/types/result.types.d.ts.map +0 -1
  264. package/dist/types/trade.dto.d.ts.map +0 -1
  265. package/dist/types/transfer.dto.d.ts.map +0 -1
  266. package/dist/types/user.dto.d.ts.map +0 -1
  267. package/dist/types/websocket-data.types.d.ts.map +0 -1
  268. package/dist/types/websocket.types.d.ts.map +0 -1
  269. package/dist/utils/Logger.d.ts.map +0 -1
  270. package/dist/utils/SignatureHelper.d.ts.map +0 -1
  271. package/dist/utils/adapters.d.ts.map +0 -1
  272. package/dist/utils/agent-config.d.ts.map +0 -1
  273. package/dist/utils/auto-pagination.d.ts.map +0 -1
  274. package/dist/utils/bignumber-helpers.d.ts.map +0 -1
  275. package/dist/utils/bondingCurveCalculations.d.ts.map +0 -1
  276. package/dist/utils/cacheWarmingHelpers.d.ts.map +0 -1
  277. package/dist/utils/date-utils.d.ts.map +0 -1
  278. package/dist/utils/error-factories.d.ts.map +0 -1
  279. package/dist/utils/error-utils.d.ts.map +0 -1
  280. package/dist/utils/errors.d.ts.map +0 -1
  281. package/dist/utils/http.d.ts.map +0 -1
  282. package/dist/utils/multipart-helpers.d.ts.map +0 -1
  283. package/dist/utils/multipart.d.ts.map +0 -1
  284. package/dist/utils/number-utils.d.ts.map +0 -1
  285. package/dist/utils/precision-math.d.ts.map +0 -1
  286. package/dist/utils/query-params.d.ts.map +0 -1
  287. package/dist/utils/response-handlers.d.ts.map +0 -1
  288. package/dist/utils/response-normalizers.d.ts.map +0 -1
  289. package/dist/utils/slippage-utils.d.ts.map +0 -1
  290. package/dist/utils/token-format-converter.d.ts.map +0 -1
  291. package/dist/utils/tokenNormalizer.d.ts.map +0 -1
  292. package/dist/utils/trade-transformers.d.ts.map +0 -1
  293. package/dist/utils/transfer-validation.d.ts.map +0 -1
  294. package/dist/utils/validation-helpers.d.ts.map +0 -1
  295. package/dist/utils/validation.d.ts.map +0 -1
  296. package/dist/utils/wallet.d.ts.map +0 -1
  297. package/dist/utils/websocket-errors.d.ts.map +0 -1
  298. package/dist/utils/websocket-validators.d.ts.map +0 -1
  299. /package/dist/{api → src/api}/LaunchpadAPI.d.ts +0 -0
  300. /package/dist/{api → src/api}/dto/BondingCurveDTOs.d.ts +0 -0
  301. /package/dist/{api → src/api}/dto/TransferTokenDto.d.ts +0 -0
  302. /package/dist/{auth → src/auth}/SignatureAuth.d.ts +0 -0
  303. /package/dist/{auth → src/auth}/types.d.ts +0 -0
  304. /package/dist/{config → src/config}/environments.d.ts +0 -0
  305. /package/dist/{constants → src/constants}/bondingCurve.d.ts +0 -0
  306. /package/dist/{constants → src/constants}/config.d.ts +0 -0
  307. /package/dist/{constants → src/constants}/counts.d.ts +0 -0
  308. /package/dist/{constants → src/constants}/decimals.d.ts +0 -0
  309. /package/dist/{constants → src/constants}/endpoints.d.ts +0 -0
  310. /package/dist/{constants → src/constants}/enums.d.ts +0 -0
  311. /package/dist/{constants → src/constants}/error-messages.d.ts +0 -0
  312. /package/dist/{constants → src/constants}/pagination.d.ts +0 -0
  313. /package/dist/{constants → src/constants}/query-fields.d.ts +0 -0
  314. /package/dist/{constants → src/constants}/version.d.ts +0 -0
  315. /package/dist/{helpers → src/helpers}/sdk.d.ts +0 -0
  316. /package/dist/{helpers → src/helpers}/wallet.d.ts +0 -0
  317. /package/dist/{polyfills → src/polyfills}/file-global.d.ts +0 -0
  318. /package/dist/{schemas → src/schemas}/files.d.ts +0 -0
  319. /package/dist/{schemas → src/schemas}/index.d.ts +0 -0
  320. /package/dist/{schemas → src/schemas}/launchpad.d.ts +0 -0
  321. /package/dist/{schemas → src/schemas}/pagination.d.ts +0 -0
  322. /package/dist/{schemas → src/schemas}/primitives.d.ts +0 -0
  323. /package/dist/{schemas → src/schemas}/trade.d.ts +0 -0
  324. /package/dist/{schemas → src/schemas}/user.d.ts +0 -0
  325. /package/dist/{schemas → src/schemas}/validators.d.ts +0 -0
  326. /package/dist/{services → src/services}/BaseService.d.ts +0 -0
  327. /package/dist/{services → src/services}/BundleService.d.ts +0 -0
  328. /package/dist/{services → src/services}/CommentService.d.ts +0 -0
  329. /package/dist/{services → src/services}/FaucetService.d.ts +0 -0
  330. /package/dist/{services → src/services}/ImageService.d.ts +0 -0
  331. /package/dist/{services → src/services}/LaunchpadService.d.ts +0 -0
  332. /package/dist/{services → src/services}/PoolService.d.ts +0 -0
  333. /package/dist/{services → src/services}/TokenClassKeyService.d.ts +0 -0
  334. /package/dist/{services → src/services}/TokenResolverService.d.ts +0 -0
  335. /package/dist/{services → src/services}/TradeService.d.ts +0 -0
  336. /package/dist/{services → src/services}/UserService.d.ts +0 -0
  337. /package/dist/{services → src/services}/WebSocketManager.d.ts +0 -0
  338. /package/dist/{setup.d.ts → src/setup.d.ts} +0 -0
  339. /package/dist/{types → src/types}/comment.dto.d.ts +0 -0
  340. /package/dist/{types → src/types}/launchpad.validation.d.ts +0 -0
  341. /package/dist/{types → src/types}/options.dto.d.ts +0 -0
  342. /package/dist/{types → src/types}/result.types.d.ts +0 -0
  343. /package/dist/{types → src/types}/trade.dto.d.ts +0 -0
  344. /package/dist/{types → src/types}/transfer.dto.d.ts +0 -0
  345. /package/dist/{types → src/types}/user.dto.d.ts +0 -0
  346. /package/dist/{types → src/types}/websocket-data.types.d.ts +0 -0
  347. /package/dist/{types → src/types}/websocket.types.d.ts +0 -0
  348. /package/dist/{utils → src/utils}/Logger.d.ts +0 -0
  349. /package/dist/{utils → src/utils}/adapters.d.ts +0 -0
  350. /package/dist/{utils → src/utils}/agent-config.d.ts +0 -0
  351. /package/dist/{utils → src/utils}/bondingCurveCalculations.d.ts +0 -0
  352. /package/dist/{utils → src/utils}/cacheWarmingHelpers.d.ts +0 -0
  353. /package/dist/{utils → src/utils}/date-utils.d.ts +0 -0
  354. /package/dist/{utils → src/utils}/error-factories.d.ts +0 -0
  355. /package/dist/{utils → src/utils}/error-utils.d.ts +0 -0
  356. /package/dist/{utils → src/utils}/http.d.ts +0 -0
  357. /package/dist/{utils → src/utils}/multipart-helpers.d.ts +0 -0
  358. /package/dist/{utils → src/utils}/number-utils.d.ts +0 -0
  359. /package/dist/{utils → src/utils}/precision-math.d.ts +0 -0
  360. /package/dist/{utils → src/utils}/response-handlers.d.ts +0 -0
  361. /package/dist/{utils → src/utils}/response-normalizers.d.ts +0 -0
  362. /package/dist/{utils → src/utils}/slippage-utils.d.ts +0 -0
  363. /package/dist/{utils → src/utils}/tokenNormalizer.d.ts +0 -0
  364. /package/dist/{utils → src/utils}/trade-transformers.d.ts +0 -0
  365. /package/dist/{utils → src/utils}/transfer-validation.d.ts +0 -0
  366. /package/dist/{utils → src/utils}/validation.d.ts +0 -0
  367. /package/dist/{utils → src/utils}/wallet.d.ts +0 -0
  368. /package/dist/{utils → src/utils}/websocket-errors.d.ts +0 -0
  369. /package/dist/{utils → src/utils}/websocket-validators.d.ts +0 -0
@@ -0,0 +1,817 @@
1
+ import { LoggerBase } from './BaseService';
2
+ import { WebSocketService } from './WebSocketService';
3
+ import { DexQuoteService } from './DexQuoteService';
4
+ import type { SwapQuoteParams, SwapQuoteResult, ExecuteSwapParams, ExecuteSwapResult, UserAsset, PoolInfo, GSwapServiceConfig, GSwapPosition, PoolSlot0Data, PoolPriceData, GetLiquidityPositionsOptions, GetLiquidityPositionsResult } from '../types/gswap.dto';
5
+ import type { GSwapEstimateRemoveLiquidityResult, GSwapAddLiquidityResult } from '../types/gswap-responses.types';
6
+ import type { TokenClassKey } from '../types/common';
7
+ export declare class GSwapService extends LoggerBase {
8
+ private gatewayClient;
9
+ private dexBackendClient;
10
+ private tokenConverter;
11
+ private webSocketService;
12
+ private dexQuoteService;
13
+ private getWalletAddress;
14
+ private galaChainBaseUrl;
15
+ private bundlerBaseUrl;
16
+ private gatewayBaseUrl;
17
+ private privateKey;
18
+ private pricingConcurrency;
19
+ constructor(config: GSwapServiceConfig, webSocketService: WebSocketService, dexQuoteService?: DexQuoteService);
20
+ /**
21
+ * Set the pricing concurrency level for liquidity position pricing operations
22
+ * This is set once at SDK initialization and applies to all pricing operations
23
+ * @param concurrency Number of concurrent pricing requests (default: 5, max recommended: 20)
24
+ */
25
+ setPricingConcurrency(concurrency: number): void;
26
+ /**
27
+ * Get swap quote for exact input (spending known amount)
28
+ *
29
+ * Uses DexQuoteService with dynamic fee tier discovery ([3000, 500, 10000]).
30
+ * NEVER falls back - if all fee tiers fail, throws loudly to expose the real problem.
31
+ *
32
+ * Guarantees: All quotes are ALWAYS fresh (never cached) to prevent MEV in volatile markets.
33
+ *
34
+ * @param params Quote request with fromToken, toToken, and input amount
35
+ * @returns Quote with estimated output, actual price impact, and fees
36
+ * @throws GSwapQuoteError if DexQuoteService not configured or all fee tiers fail
37
+ */
38
+ getSwapQuoteExactInput(params: SwapQuoteParams): Promise<SwapQuoteResult>;
39
+ /**
40
+ * Get swap quote for exact output (receive known amount)
41
+ *
42
+ * Uses DexQuoteService with dynamic fee tier discovery ([3000, 500, 10000]).
43
+ * NEVER falls back - if all fee tiers fail, throws loudly to expose the real problem.
44
+ *
45
+ * Guarantees: All quotes are ALWAYS fresh (never cached) to prevent MEV in volatile markets.
46
+ *
47
+ * @param params Quote request with fromToken, toToken, and desired output
48
+ * @returns Quote with required input, actual price impact, and fees
49
+ * @throws GSwapQuoteError if DexQuoteService not configured or all fee tiers fail
50
+ */
51
+ getSwapQuoteExactOutput(params: SwapQuoteParams): Promise<SwapQuoteResult>;
52
+ /**
53
+ * Execute a token swap with slippage protection
54
+ * @param params Swap execution parameters
55
+ * @returns Swap result with transaction details
56
+ */
57
+ executeSwap(params: ExecuteSwapParams): Promise<ExecuteSwapResult>;
58
+ /**
59
+ * Get user's token assets/balances
60
+ *
61
+ * Fetches all tokens held by a user from the GSwap API with graceful handling
62
+ * of token conversion. Assets that cannot be converted are skipped with debug logging.
63
+ *
64
+ * @param walletAddress User's wallet address (e.g., "eth|0x1234...")
65
+ * @returns Array of user assets with balances (skips unconvertible assets)
66
+ * @throws {GSwapAssetError} When the API call itself fails or wallet address is invalid
67
+ * @since v3.30.0 Now gracefully skips unconvertible assets instead of throwing
68
+ */
69
+ getUserAssets(walletAddress: string, page?: number, limit?: number): Promise<UserAsset[]>;
70
+ /**
71
+ * Get all user assets across all pages (auto-paginated)
72
+ * @param walletAddress Wallet address to fetch assets for
73
+ * @returns All user assets across all pages
74
+ */
75
+ getAllUserAssets(walletAddress: string): Promise<UserAsset[]>;
76
+ /**
77
+ * Get pool information for token pair
78
+ * @param tokenA First token
79
+ * @param tokenB Second token
80
+ * @returns Pool information
81
+ */
82
+ getPoolInfo(tokenA: string, tokenB: string): Promise<PoolInfo>;
83
+ /**
84
+ * Get all liquidity positions for a wallet
85
+ * @param ownerAddress User's wallet address
86
+ * @param limit Maximum number of positions to return (default 100)
87
+ * @param bookmark Pagination bookmark
88
+ * @returns Array of liquidity positions with full type safety
89
+ */
90
+ /**
91
+ * Chunk array into smaller batches for concurrent processing
92
+ * @private
93
+ */
94
+ private chunkArray;
95
+ /**
96
+ * Fetch real-time pricing for liquidity positions
97
+ * Deduplicates pools and processes in chunks for optimal performance
98
+ * @private
99
+ */
100
+ private fetchPositionPrices;
101
+ /**
102
+ * Normalize GSwap API position response to match LiquidityPosition interface
103
+ * Handles different field naming conventions from the API
104
+ */
105
+ private normalizePositionResponse;
106
+ /**
107
+ * Parse token string flexibly - supports both delimited and simple formats
108
+ * @param tokenString Token in format "GALA" or "GALA|Unit|none|none"
109
+ * @returns TokenClassKey object
110
+ */
111
+ private parseTokenFlexible;
112
+ getUserLiquidityPositions(ownerAddress: string, limit?: number, bookmark?: string, options?: GetLiquidityPositionsOptions): Promise<GetLiquidityPositionsResult>;
113
+ /**
114
+ * Get ALL user liquidity positions with automatic pagination
115
+ * Automatically fetches all pages of liquidity positions for a wallet
116
+ * Uses bookmark-based cursor pagination internally
117
+ * @param ownerAddress User's wallet address
118
+ * @param options Optional configuration for pricing enrichment
119
+ * @returns All liquidity positions combined from all pages, optionally with pricing data
120
+ */
121
+ getAllSwapUserLiquidityPositions(ownerAddress: string, options?: GetLiquidityPositionsOptions): Promise<GSwapPosition[] | GetLiquidityPositionsResult>;
122
+ /**
123
+ * Get a specific liquidity position
124
+ * @param ownerAddress User's wallet address
125
+ * @param position Position details (token0, token1, fee, tickLower, tickUpper)
126
+ * @returns Detailed position information with full type safety
127
+ */
128
+ getLiquidityPosition(ownerAddress: string, position: {
129
+ token0: string;
130
+ token1: string;
131
+ fee: number;
132
+ tickLower: number;
133
+ tickUpper: number;
134
+ }): Promise<GSwapPosition>;
135
+ /**
136
+ * Get a liquidity position by its ID
137
+ * @param ownerAddress User's wallet address
138
+ * @param positionId Position UUID
139
+ * @param token0 Optional first token for compound key lookup (token0)
140
+ * @param token1 Optional second token for compound key lookup (token1)
141
+ * @param feeTier Optional fee tier for compound key lookup (500, 3000, or 10000)
142
+ * @param tickLower Optional lower tick boundary for compound key lookup
143
+ * @param tickUpper Optional upper tick boundary for compound key lookup
144
+ * @returns Detailed position information with full type safety
145
+ */
146
+ getLiquidityPositionById(ownerAddress: string, positionId: string, token0?: string | Record<string, unknown>, token1?: string | Record<string, unknown>, feeTier?: number, tickLower?: number, tickUpper?: number): Promise<GSwapPosition>;
147
+ /**
148
+ * Fetch a single liquidity position using ONLY the compound key (direct HTTP call)
149
+ * Most efficient when you already have all position parameters
150
+ * @param params Position parameters - token0, token1, fee, tickLower, tickUpper, owner (ALL REQUIRED)
151
+ * @returns Detailed position information with full type safety
152
+ * @remarks
153
+ * - Does NOT use positionId (not needed or accepted)
154
+ * - Single direct HTTP call to GalaChain (no GSwap SDK)
155
+ * - Best for cases where caller has full position parameters
156
+ * - Requires: token0, token1, fee (500|3000|10000), tickLower, tickUpper, owner
157
+ */
158
+ fetchSwapPositionDirect(params: {
159
+ token0: string;
160
+ token1: string;
161
+ fee: number;
162
+ tickLower: number;
163
+ tickUpper: number;
164
+ owner: string;
165
+ }): Promise<GSwapPosition>;
166
+ /**
167
+ * Estimate tokens received from removing liquidity
168
+ * @param args Removal estimation parameters
169
+ * @returns Estimated token amounts
170
+ */
171
+ estimateRemoveLiquidity(args: {
172
+ token0: string;
173
+ token1: string;
174
+ fee: number;
175
+ liquidity: string;
176
+ tickLower: number;
177
+ tickUpper: number;
178
+ }): Promise<GSwapEstimateRemoveLiquidityResult>;
179
+ /**
180
+ * Add liquidity using price ranges (user-friendly)
181
+ * @param args Liquidity addition parameters with price ranges
182
+ * @returns Transaction result with position ID
183
+ */
184
+ addLiquidityByPrice(args: {
185
+ token0: string;
186
+ token1: string;
187
+ fee: number;
188
+ minPrice: string;
189
+ maxPrice: string;
190
+ amount0Desired: string;
191
+ amount1Desired: string;
192
+ amount0Min?: string;
193
+ amount1Min?: string;
194
+ }): Promise<GSwapAddLiquidityResult & {
195
+ timestamp?: Date;
196
+ wait?: (timeoutMs?: number) => Promise<void>;
197
+ }>;
198
+ /**
199
+ * Add liquidity to GSwap pool using precise tick ranges (concentrated liquidity)
200
+ *
201
+ * **CRITICAL: WebSocket-First Pattern**
202
+ * This method ensures WebSocket connection is established BEFORE submitting the
203
+ * transaction to prevent race conditions where the transaction confirms before
204
+ * the listener becomes active. This is essential because:
205
+ *
206
+ * 1. WebSocket listener created IMMEDIATELY after transactionId received
207
+ * 2. Socket.IO buffers events for registered listeners
208
+ * 3. If listener not active when transaction confirms, confirmation is missed
209
+ * 4. Position discovery retry logic handles indexing delays (up to 11 seconds)
210
+ *
211
+ * **Position Discovery Flow**
212
+ * After bundler submits transaction:
213
+ * 1. WebSocket listener monitors for on-chain confirmation (~2-3 seconds)
214
+ * 2. Once confirmed, waits for backend position indexing (5-11 seconds)
215
+ * 3. Queries positions API up to 3 times with exponential backoff
216
+ * 4. Matches position by token pair + fee tier (handles multiple positions)
217
+ * 5. Fetches full position details for complete data
218
+ *
219
+ * **Token Format Support**
220
+ * - String tokens: 'GALA', 'GUSDC' → auto-converted to TokenClassKey
221
+ * - TokenClassKey: { collection, category, type, additionalKey }
222
+ * - Both formats normalized to TokenClassKey for bundler submission
223
+ *
224
+ * **Tick Range Details**
225
+ * - Supports negative ticks for full concentrated liquidity ranges
226
+ * - Example: tickLower: -1080, tickUpper: 900
227
+ * - Must be multiples of tickSpacing (determined by fee tier)
228
+ * - Fee 500bps: tickSpacing=10, Fee 3000bps: tickSpacing=60, Fee 10000bps: tickSpacing=200
229
+ *
230
+ * @param args Liquidity addition parameters
231
+ * @param args.token0 First token (string or TokenClassKey)
232
+ * @param args.token1 Second token (string or TokenClassKey)
233
+ * @param args.fee Fee tier in basis points (500, 3000, or 10000)
234
+ * @param args.tickLower Lower tick boundary (supports negative values)
235
+ * @param args.tickUpper Upper tick boundary
236
+ * @param args.amount0Desired Desired amount of token0
237
+ * @param args.amount1Desired Desired amount of token1
238
+ * @param args.amount0Min Optional minimum token0 (default: '0')
239
+ * @param args.amount1Min Optional minimum token1 (default: '0')
240
+ *
241
+ * @returns Promise<GSwapAddLiquidityResult> Transaction result with:
242
+ * - transactionId: Bundler transaction ID
243
+ * - positionId: GSwap position ID (discovered from on-chain data)
244
+ * - status: Transaction status from WebSocket
245
+ * - liquidity: Position liquidity amount
246
+ * - amount0/amount1: Actual amounts added
247
+ * - wait(): Async method to wait for confirmation
248
+ *
249
+ * @throws GSwapPositionError if private key unavailable or bundler submission fails
250
+ *
251
+ * @example
252
+ * // Add liquidity with explicit tick range
253
+ * const result = await sdk.addSwapLiquidityByTicks({
254
+ * token0: 'GALA',
255
+ * token1: 'GUSDC',
256
+ * fee: 3000,
257
+ * tickLower: -1080, // Supports negative ticks
258
+ * tickUpper: 900,
259
+ * amount0Desired: '100',
260
+ * amount1Desired: '100',
261
+ * });
262
+ * console.log('Position ID:', result.positionId);
263
+ * await result.wait(); // Wait for on-chain confirmation
264
+ */
265
+ addSwapLiquidityByTicks(args: {
266
+ token0: string | TokenClassKey;
267
+ token1: string | TokenClassKey;
268
+ fee: number;
269
+ tickLower: number;
270
+ tickUpper: number;
271
+ amount0Desired: string;
272
+ amount1Desired: string;
273
+ amount0Min?: string;
274
+ amount1Min?: string;
275
+ }): Promise<GSwapAddLiquidityResult & {
276
+ timestamp?: Date;
277
+ wait?: (timeoutMs?: number) => Promise<void>;
278
+ }>;
279
+ /**
280
+ * Monitor a bundler transaction with graceful fallback on timeout
281
+ *
282
+ * **Pattern Overview**
283
+ * This helper consolidates the common error handling pattern used by all bundler-direct
284
+ * operations (removeSwapLiquidity, collectSwapPositionFees, etc.):
285
+ *
286
+ * 1. Set up WebSocket listener BEFORE bundler submission (already done by caller)
287
+ * 2. Try to await transaction confirmation via WebSocket
288
+ * 3. If timeout occurs: Return partial result with status: 'SUBMITTED'
289
+ * 4. If successful: Return confirmed result with on-chain status
290
+ * 5. Both cases include a .wait() method for retry/manual monitoring
291
+ *
292
+ * **Why This Pattern Matters**
293
+ * - Prevents race conditions (listener active before transaction confirmation)
294
+ * - Handles network timeouts gracefully (users still get transaction ID)
295
+ * - Provides flexibility (users can call .wait() again if needed)
296
+ * - Consistent error handling across all bundler operations
297
+ *
298
+ * @param transactionId Transaction ID from bundler submission
299
+ * @param transactionPromise WebSocket monitoring promise (already created before bundler call)
300
+ * @param operationName Operation name for logging context (e.g., 'liquidity removal')
301
+ * @returns Bundler operation result with status and wait() method
302
+ * @private
303
+ */
304
+ private monitorBundlerTransaction;
305
+ /**
306
+ * Remove liquidity from an existing concentrated liquidity position
307
+ *
308
+ * **CRITICAL: WebSocket-First Pattern**
309
+ * This method ensures WebSocket connection is established BEFORE submitting the
310
+ * transaction to prevent race conditions where the transaction confirms before
311
+ * the listener becomes active. This is essential because:
312
+ *
313
+ * 1. WebSocket listener created IMMEDIATELY after transactionId received
314
+ * 2. Socket.IO buffers events for registered listeners
315
+ * 3. If listener not active when transaction confirms, confirmation is missed
316
+ * 4. Graceful fallback returns partial result with transaction ID on timeout
317
+ *
318
+ * **Error Handling & Recovery**
319
+ * If WebSocket monitoring times out (after 60 seconds):
320
+ * - Returns `{ transactionId, status: 'SUBMITTED' }` indicating transaction was accepted
321
+ * - Transaction may still succeed on-chain even if monitoring fails
322
+ * - Users can call `.wait()` again to retry monitoring
323
+ * - Recommended: retry monitoring after waiting or check on-chain later
324
+ *
325
+ * **Partial vs Complete Removal**
326
+ * - Partial: Set liquidity to a fraction (e.g., 50% of current amount)
327
+ * - Complete: Set liquidity to the full amount to close the position
328
+ * - Retrieved from position details via `getSwapUserLiquidityPositions()`
329
+ *
330
+ * **Token Format Support**
331
+ * - String tokens: 'GALA', 'GUSDC' → auto-converted to TokenClassKey
332
+ * - TokenClassKey: { collection, category, type, additionalKey }
333
+ * - Both formats normalized to TokenClassKey for bundler submission
334
+ *
335
+ * @param args Liquidity removal parameters
336
+ * @param args.token0 First token (string or TokenClassKey)
337
+ * @param args.token1 Second token (string or TokenClassKey)
338
+ * @param args.fee Fee tier in basis points (500, 3000, or 10000)
339
+ * @param args.tickLower Lower tick boundary of the position
340
+ * @param args.tickUpper Upper tick boundary of the position
341
+ * @param args.liquidity Amount of liquidity to remove (partial or complete)
342
+ * @param args.amount0Min Optional minimum token0 to accept (default: '0')
343
+ * @param args.amount1Min Optional minimum token1 to accept (default: '0')
344
+ * @param args.positionId Optional position ID for tracking/verification
345
+ *
346
+ * @returns Promise<GSwapRemoveLiquidityResult> Transaction result with:
347
+ * - transactionId: Bundler transaction ID
348
+ * - status: Transaction status from WebSocket (or 'SUBMITTED' if timeout)
349
+ * - timestamp: When transaction was submitted
350
+ * - wait(): Async method to monitor or retry confirmation
351
+ *
352
+ * @throws GSwapPositionError if private key unavailable or bundler submission fails
353
+ *
354
+ * @example
355
+ * // Get position first
356
+ * const positions = await sdk.getSwapUserLiquidityPositions(walletAddress);
357
+ * const position = positions[0];
358
+ *
359
+ * // Remove 50% of liquidity
360
+ * const liquidityToRemove = (parseFloat(position.liquidity) * 50) / 100;
361
+ * const result = await sdk.removeSwapLiquidity({
362
+ * token0: 'GALA',
363
+ * token1: 'GUSDC',
364
+ * fee: 3000,
365
+ * tickLower: position.tickLower,
366
+ * tickUpper: position.tickUpper,
367
+ * liquidity: liquidityToRemove.toString(),
368
+ * amount0Min: '0',
369
+ * amount1Min: '0',
370
+ * positionId: position.positionId,
371
+ * });
372
+ *
373
+ * console.log('Removal submitted:', result.transactionId);
374
+ * await result.wait(); // Wait for on-chain confirmation
375
+ * console.log('Final status:', result.status);
376
+ */
377
+ removeLiquidity(args: {
378
+ token0: string | TokenClassKey;
379
+ token1: string | TokenClassKey;
380
+ fee: number;
381
+ tickLower: number;
382
+ tickUpper: number;
383
+ liquidity: string;
384
+ amount0Min?: string;
385
+ amount1Min?: string;
386
+ positionId?: string;
387
+ }): Promise<GSwapAddLiquidityResult>;
388
+ /**
389
+ * Collect accumulated trading fees from a concentrated liquidity position
390
+ *
391
+ * **CRITICAL: WebSocket-First Pattern**
392
+ * This method ensures WebSocket connection is established BEFORE submitting the
393
+ * transaction to prevent race conditions where the transaction confirms before
394
+ * the listener becomes active. This is essential because:
395
+ *
396
+ * 1. WebSocket listener created IMMEDIATELY after transactionId received
397
+ * 2. Socket.IO buffers events for registered listeners
398
+ * 3. If listener not active when transaction confirms, confirmation is missed
399
+ * 4. Graceful fallback returns partial result with transaction ID on timeout
400
+ *
401
+ * **Error Handling & Recovery**
402
+ * If WebSocket monitoring times out (after 60 seconds):
403
+ * - Returns `{ transactionId, status: 'SUBMITTED' }` indicating transaction was accepted
404
+ * - Transaction may still succeed on-chain even if monitoring fails
405
+ * - Users can call `.wait()` again to retry monitoring
406
+ * - Recommended: retry monitoring after waiting or check position fees on-chain later
407
+ *
408
+ * **Fee Accumulation**
409
+ * Fees accumulate when your position is in-range and trades execute within your price range.
410
+ * - In-range fees: Actively accumulating (trading happens in your range)
411
+ * - Out-of-range fees: Not accumulating (current price outside your range)
412
+ * - Collect periodically for optimal capital efficiency (fees don't compound)
413
+ * - Fees are denominated in the two tokens of the pair (token0 and token1)
414
+ *
415
+ * **Partial vs Complete Collection**
416
+ * - Collect all: Set amount0Requested='0' and amount1Requested='0' (default)
417
+ * - Collect specific amount: Set amount0Requested/amount1Requested to desired amounts
418
+ * - Partial collection doesn't affect the position's liquidity
419
+ * - Current fees visible in position details via `getSwapUserLiquidityPositions()`
420
+ *
421
+ * **Token Format Support**
422
+ * - String tokens: 'GALA', 'GUSDC' → auto-converted to TokenClassKey
423
+ * - TokenClassKey: { collection, category, type, additionalKey }
424
+ * - Both formats normalized to TokenClassKey for bundler submission
425
+ *
426
+ * @param args Fee collection parameters
427
+ * @param args.token0 First token (string or TokenClassKey)
428
+ * @param args.token1 Second token (string or TokenClassKey)
429
+ * @param args.fee Fee tier in basis points (500, 3000, or 10000)
430
+ * @param args.tickLower Lower tick boundary of the position
431
+ * @param args.tickUpper Upper tick boundary of the position
432
+ * @param args.amount0Requested Optional amount of token0 fees to collect (default: '0' = all)
433
+ * @param args.amount1Requested Optional amount of token1 fees to collect (default: '0' = all)
434
+ * @param args.positionId Optional position ID for tracking/verification
435
+ *
436
+ * @returns Promise<GSwapCollectFeesResult> Transaction result with:
437
+ * - transactionId: Bundler transaction ID
438
+ * - status: Transaction status from WebSocket (or 'SUBMITTED' if timeout)
439
+ * - timestamp: When transaction was submitted
440
+ * - wait(): Async method to monitor or retry confirmation
441
+ *
442
+ * @throws GSwapPositionError if private key unavailable or bundler submission fails
443
+ *
444
+ * @example
445
+ * // Get position with accumulated fees
446
+ * const positions = await sdk.getSwapUserLiquidityPositions(walletAddress);
447
+ * const position = positions[0];
448
+ *
449
+ * if (parseFloat(position.feeAmount0) > 0 || parseFloat(position.feeAmount1) > 0) {
450
+ * // Collect all accumulated fees
451
+ * const result = await sdk.collectSwapPositionFees({
452
+ * token0: 'GALA',
453
+ * token1: 'GUSDC',
454
+ * fee: 3000,
455
+ * tickLower: position.tickLower,
456
+ * tickUpper: position.tickUpper,
457
+ * amount0Requested: '0', // Collect all token0 fees
458
+ * amount1Requested: '0', // Collect all token1 fees
459
+ * positionId: position.positionId,
460
+ * });
461
+ *
462
+ * console.log('Fee collection submitted:', result.transactionId);
463
+ * await result.wait(); // Wait for on-chain confirmation
464
+ * console.log('Fees collected successfully');
465
+ * }
466
+ */
467
+ collectPositionFees(args: {
468
+ token0: string | TokenClassKey;
469
+ token1: string | TokenClassKey;
470
+ fee: number;
471
+ tickLower: number;
472
+ tickUpper: number;
473
+ amount0Requested?: string;
474
+ amount1Requested?: string;
475
+ positionId?: string;
476
+ }): Promise<GSwapAddLiquidityResult>;
477
+ /**
478
+ * Get real-time pool state with liquidity depth and current price
479
+ * @param tokenA First token symbol (e.g., 'GALA')
480
+ * @param tokenB Second token symbol (e.g., 'GUSDC')
481
+ * @param feeTier Fee tier (500, 3000, or 10000 basis points)
482
+ * @returns Pool data with liquidity, current tick, and price
483
+ */
484
+ getPoolData(tokenA: string, tokenB: string, feeTier: number): Promise<{
485
+ tokenA: string;
486
+ tokenB: string;
487
+ feeTier: number;
488
+ liquidity: string;
489
+ sqrtPriceX96: string;
490
+ tick: number;
491
+ feeGrowthGlobal0X128: string;
492
+ feeGrowthGlobal1X128: string;
493
+ currentPrice: string;
494
+ }>;
495
+ /**
496
+ * Calculate current market price for a token pair from DEX pool
497
+ * @param tokenA First token symbol
498
+ * @param tokenB Second token symbol
499
+ * @param feeTier Fee tier (500, 3000, or 10000 basis points)
500
+ * @returns Current spot price without executing trade
501
+ */
502
+ calculateDexPoolSpotPrice(tokenA: string, tokenB: string, feeTier: number): Promise<{
503
+ tokenA: string;
504
+ tokenB: string;
505
+ feeTier: number;
506
+ price: string;
507
+ invertedPrice: string;
508
+ tick: number;
509
+ liquidity: string;
510
+ }>;
511
+ /**
512
+ * Calculate optimal token amounts for concentrated liquidity position
513
+ * @param tokenA First token symbol
514
+ * @param tokenB Second token symbol
515
+ * @param feeTier Fee tier (500, 3000, or 10000 basis points)
516
+ * @param desiredAmount0 Desired amount of token A
517
+ * @param desiredAmount1 Desired amount of token B
518
+ * @param tickLower Lower tick boundary
519
+ * @param tickUpper Upper tick boundary
520
+ * @returns Optimal amounts and utilization percentages
521
+ */
522
+ calculateOptimalPositionSize(tokenA: string, tokenB: string, feeTier: number, desiredAmount0: string, desiredAmount1: string, tickLower: number, tickUpper: number): Promise<{
523
+ amount0: string;
524
+ amount1: string;
525
+ liquidity: string;
526
+ ratio: string;
527
+ utilizationPercent: {
528
+ amount0: string;
529
+ amount1: string;
530
+ };
531
+ }>;
532
+ /**
533
+ * Validate liquidity position parameters before creation
534
+ * @param tokenA First token symbol
535
+ * @param tokenB Second token symbol
536
+ * @param feeTier Fee tier (500, 3000, or 10000 basis points)
537
+ * @param tickLower Lower tick boundary
538
+ * @param tickUpper Upper tick boundary
539
+ * @param amount0 Token A amount
540
+ * @param amount1 Token B amount
541
+ * @returns Validation result with errors and warnings
542
+ */
543
+ validatePositionParameters(tokenA: string, tokenB: string, feeTier: number, tickLower: number, tickUpper: number, amount0: string, amount1: string): Promise<{
544
+ valid: boolean;
545
+ errors: string[];
546
+ warnings: string[];
547
+ gasEstimate: number;
548
+ tickSpacing?: number;
549
+ currentTick?: number;
550
+ poolLiquidity?: string;
551
+ }>;
552
+ /**
553
+ * Convert human-readable price range to tick boundaries
554
+ * @param tokenA First token symbol
555
+ * @param tokenB Second token symbol
556
+ * @param minPrice Minimum price boundary
557
+ * @param maxPrice Maximum price boundary
558
+ * @param feeTier Fee tier (500, 3000, or 10000 basis points)
559
+ * @returns Calculated tick boundaries and price deviations
560
+ */
561
+ calculateTicksForPrice(tokenA: string, tokenB: string, minPrice: string, maxPrice: string, feeTier: number): Promise<{
562
+ tokenA: string;
563
+ tokenB: string;
564
+ feeTier: number;
565
+ tickLower: number;
566
+ tickUpper: number;
567
+ tickSpacing: number;
568
+ requestedMinPrice: string;
569
+ requestedMaxPrice: string;
570
+ actualMinPrice: string;
571
+ actualMaxPrice: string;
572
+ priceDeviation: {
573
+ minPriceDeviation: string;
574
+ maxPriceDeviation: string;
575
+ };
576
+ }>;
577
+ /**
578
+ * Convert tick boundaries back to human-readable prices
579
+ * @param tokenA First token symbol
580
+ * @param tokenB Second token symbol
581
+ * @param tickLower Lower tick boundary
582
+ * @param tickUpper Upper tick boundary
583
+ * @returns Price range and current price
584
+ */
585
+ calculatePriceForTicks(tokenA: string, tokenB: string, tickLower: number, tickUpper: number): Promise<{
586
+ tokenA: string;
587
+ tokenB: string;
588
+ tickLower: number;
589
+ tickUpper: number;
590
+ minPrice: string;
591
+ maxPrice: string;
592
+ currentPrice?: string;
593
+ priceRange?: string;
594
+ tickSpread?: number;
595
+ }>;
596
+ /**
597
+ * Calculate execution price (output per unit input)
598
+ */
599
+ private calculateExecutionPrice;
600
+ /**
601
+ * Get tick spacing for a given fee tier (Uniswap v3 standard)
602
+ * @private
603
+ */
604
+ private getTickSpacing;
605
+ /**
606
+ * Calculate price from sqrtPriceX96 format (Uniswap v3 standard)
607
+ * price = (sqrtPriceX96 / 2^96)^2
608
+ * @private
609
+ */
610
+ private calculatePriceFromSqrtPriceX96;
611
+ /**
612
+ * Calculate price from sqrtPrice in decimal format (GetSlot0 API)
613
+ * Different from sqrtPriceX96 - GetSlot0 returns already-decoded decimal
614
+ * Formula: price = sqrtPrice²
615
+ * @private
616
+ */
617
+ private calculatePriceFromSqrtPriceDecimal;
618
+ /**
619
+ * Get current pool state (slot0 data) for a token pair
620
+ * Fetches sqrtPrice, tick, and liquidity from GalaChain Gateway
621
+ * @param token0 First token symbol or TokenClassKey
622
+ * Accepts: "GALA" (plain), "GALA|Unit|none|none" (pipe), "GALA$Unit$none$none" (dollar)
623
+ * @param token1 Second token symbol or TokenClassKey
624
+ * Accepts: "GALA" (plain), "GALA|Unit|none|none" (pipe), "GALA$Unit$none$none" (dollar)
625
+ * @param fee Fee tier in basis points (500, 3000, 10000)
626
+ * @returns PoolSlot0Data with current sqrtPrice, tick, liquidity, and feeGrowth
627
+ */
628
+ getPoolSlot0(token0: string | TokenClassKey, token1: string | TokenClassKey, fee: number): Promise<PoolSlot0Data>;
629
+ /**
630
+ * Get current price for a liquidity position's pool
631
+ * Fetches slot0 data and calculates token0/token1 price ratio
632
+ * @param position Position token pair and fee tier
633
+ */
634
+ getPositionCurrentPrice(position: {
635
+ token0: string;
636
+ token1: string;
637
+ feeTier: number;
638
+ }): Promise<PoolPriceData>;
639
+ /**
640
+ * Calculate liquidity from amount0 (Uniswap v3 math)
641
+ * Uses @gala-chain/dex liquidity0() function for production-accurate calculation
642
+ * @private
643
+ */
644
+ private calculateLiquidityFromAmount0;
645
+ /**
646
+ * Calculate liquidity from amount1 (Uniswap v3 math)
647
+ * Uses @gala-chain/dex liquidity1() function for production-accurate calculation
648
+ * @private
649
+ */
650
+ private calculateLiquidityFromAmount1;
651
+ /**
652
+ * Calculate amount0 from liquidity (Uniswap v3 math)
653
+ * Uses @gala-chain/dex getAmount0Delta() function for production-accurate calculation
654
+ * @private
655
+ */
656
+ private calculateAmount0FromLiquidity;
657
+ /**
658
+ * Calculate amount1 from liquidity (Uniswap v3 math)
659
+ * Uses @gala-chain/dex getAmount1Delta() function for production-accurate calculation
660
+ * @private
661
+ */
662
+ private calculateAmount1FromLiquidity;
663
+ /**
664
+ * Convert a token pair from Launchpad format to GSwap format
665
+ *
666
+ * Converts both tokens in a pair simultaneously for cleaner, more readable code
667
+ * when working with token swaps and pool queries.
668
+ *
669
+ * @param token0 - First token in any supported format
670
+ * @param token1 - Second token in any supported format
671
+ * @returns Object with converted tokens as gswapToken0 and gswapToken1
672
+ *
673
+ * @private
674
+ */
675
+ private convertTokenPair;
676
+ /**
677
+ * Send AddLiquidity transaction directly to bundler (bypassing gswap-sdk)
678
+ *
679
+ * Creates a liquidity position by signing a DTO and posting it directly to the
680
+ * GalaChain bundler. This method replaces the gswap-sdk wrapper with a direct
681
+ * implementation following the same pattern as CreateSale.
682
+ *
683
+ * @param params - AddLiquidity parameters including token pair, fee, tick range, and amounts
684
+ * @returns Transaction ID from bundler response
685
+ * @throws Error if not in full-access mode or if bundler request fails
686
+ *
687
+ * @private
688
+ */
689
+ private sendAddLiquidityToBundler;
690
+ /**
691
+ * Send RemoveLiquidity transaction directly to bundler
692
+ *
693
+ * Bypasses GSwap SDK and posts signed EIP-712 RemoveLiquidity DTO directly to bundler.
694
+ * Supports full tick ranges including negative values.
695
+ *
696
+ * @param tickLower Lower tick boundary (int256, supports negative)
697
+ * @param tickUpper Upper tick boundary (int256, supports negative)
698
+ * @param amount Liquidity amount to remove
699
+ * @param token0 First token class key
700
+ * @param token1 Second token class key
701
+ * @param fee Fee tier (500, 3000, or 10000)
702
+ * @param amount0Min Minimum amount0 to receive (slippage protection)
703
+ * @param amount1Min Minimum amount1 to receive (slippage protection)
704
+ * @param positionId Unique position identifier
705
+ * @returns Transaction ID from bundler response
706
+ *
707
+ * @private
708
+ * @throws Error if signing or bundler submission fails
709
+ */
710
+ private sendRemoveLiquidityToBundler;
711
+ /**
712
+ * Send CollectPositionFees transaction directly to bundler
713
+ *
714
+ * Bypasses GSwap SDK and posts signed EIP-712 CollectPositionFees DTO directly to bundler.
715
+ * Collects accumulated trading fees from a liquidity position independently of the position itself.
716
+ *
717
+ * @param token0 First token class key
718
+ * @param token1 Second token class key
719
+ * @param fee Fee tier (500, 3000, or 10000)
720
+ * @param amount0Requested Requested amount0 to collect (0 to collect all available)
721
+ * @param amount1Requested Requested amount1 to collect (0 to collect all available)
722
+ * @param tickLower Lower tick boundary (int256, supports negative)
723
+ * @param tickUpper Upper tick boundary (int256, supports negative)
724
+ * @param positionId Unique position identifier
725
+ * @returns Transaction ID from bundler response
726
+ *
727
+ * @private
728
+ * @throws Error if signing or bundler submission fails
729
+ */
730
+ private sendCollectPositionFeesToBundler;
731
+ /**
732
+ * Send Swap transaction directly to bundler
733
+ *
734
+ * Bypasses GSwap SDK and posts signed EIP-712 Swap DTO directly to bundler.
735
+ * Implements exact input swapping (sell exact amount of input token, receive output token).
736
+ *
737
+ * @param fromToken Input token (token being sold) in GSwap format
738
+ * @param toToken Output token (token being bought) in GSwap format
739
+ * @param inputAmount Amount of input token to sell
740
+ * @param minOutput Minimum amount of output token to receive (slippage protection)
741
+ * @param feeTier Fee tier (500, 3000, or 10000)
742
+ * @param walletAddress Wallet address executing the swap
743
+ * @returns Transaction ID from bundler response
744
+ *
745
+ * @private
746
+ * @throws Error if signing or bundler submission fails
747
+ */
748
+ private sendSwapToBundler;
749
+ /**
750
+ * Build strings instructions for AddLiquidity state locking
751
+ *
752
+ * Strings instructions are used by the bundler to lock the necessary state
753
+ * fields during transaction execution. This ensures atomicity of the operation.
754
+ *
755
+ * @param token0 First token class key
756
+ * @param token1 Second token class key
757
+ * @param fee Fee tier (500, 3000, or 10000 basis points)
758
+ * @param ownerAddress Wallet address creating the position
759
+ * @returns Array of strings instructions for state locking
760
+ *
761
+ * @private
762
+ */
763
+ private buildLiquidityStringsInstructions;
764
+ /**
765
+ * Handle GSwap SDK errors with consistent logging and error transformation
766
+ *
767
+ * Centralizes error handling for GSwap operations by:
768
+ * 1. Logging the error with context
769
+ * 2. Extracting error code from original error
770
+ * 3. Creating typed GSwap error with standardized message
771
+ *
772
+ * @param logMessage - Message to log when error occurs
773
+ * @param ErrorClass - Error constructor to throw (GSwapQuoteError, GSwapSwapError, etc.)
774
+ * @param originalError - Original error from GSwap SDK
775
+ * @param additionalFields - Optional additional context (e.g., { transactionHash: txHash })
776
+ * @throws Throws instance of provided ErrorClass with formatted message
777
+ *
778
+ * @private
779
+ */
780
+ private handleGSwapError;
781
+ /**
782
+ * Extract error code from GSwap SDK error
783
+ *
784
+ * Maps GSwapSDKError instances to standard error codes for consistent
785
+ * error handling across SDK operations. Preserves error code information
786
+ * from the original GSwap SDK error.
787
+ *
788
+ * @param error - Error thrown by GSwap SDK operations
789
+ * @returns Error code string if available, undefined otherwise
790
+ *
791
+ * @private
792
+ */
793
+ private extractGSwapErrorCode;
794
+ /**
795
+ * Ensure WebSocket connection is established before transaction monitoring
796
+ *
797
+ * Checks if WebSocketService is already connected, and connects if needed.
798
+ * This prevents unnecessary connection attempts while ensuring transactions can be monitored.
799
+ *
800
+ * @private
801
+ * @throws Error if connection fails
802
+ */
803
+ private ensureWebSocketConnected;
804
+ /**
805
+ * Calculate personal sign prefix for GalaChain compatibility
806
+ *
807
+ * Builds the prefix string required by GalaChain for EIP-712 signing.
808
+ * This matches the format used in production working payloads.
809
+ *
810
+ * @param payload The payload being signed
811
+ * @returns Prefix string for signing
812
+ *
813
+ * @private
814
+ */
815
+ private calculatePersonalSignPrefix;
816
+ }
817
+ //# sourceMappingURL=GSwapService.d.ts.map