@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.
- package/API.md +525 -5
- package/CHANGELOG.md +101 -9
- package/EXAMPLES.md +923 -0
- package/README.md +539 -15
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +37 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{LaunchpadSDK.d.ts → src/LaunchpadSDK.d.ts} +1333 -37
- package/dist/src/LaunchpadSDK.d.ts.map +1 -0
- package/dist/src/api/LaunchpadAPI.d.ts.map +1 -0
- package/dist/src/api/dto/BondingCurveDTOs.d.ts.map +1 -0
- package/dist/src/api/dto/LockTokenDto.d.ts +97 -0
- package/dist/src/api/dto/LockTokenDto.d.ts.map +1 -0
- package/dist/src/api/dto/TransferTokenDto.d.ts.map +1 -0
- package/dist/src/api/dto/UnlockTokenDto.d.ts +86 -0
- package/dist/src/api/dto/UnlockTokenDto.d.ts.map +1 -0
- package/dist/src/auth/SignatureAuth.d.ts.map +1 -0
- package/dist/src/auth/types.d.ts.map +1 -0
- package/dist/src/config/environments.d.ts.map +1 -0
- package/dist/src/constants/bondingCurve.d.ts.map +1 -0
- package/dist/src/constants/config.d.ts.map +1 -0
- package/dist/src/constants/counts.d.ts.map +1 -0
- package/dist/src/constants/decimals.d.ts.map +1 -0
- package/dist/src/constants/endpoints.d.ts.map +1 -0
- package/dist/src/constants/enums.d.ts.map +1 -0
- package/dist/src/constants/error-messages.d.ts.map +1 -0
- package/dist/src/constants/pagination.d.ts.map +1 -0
- package/dist/src/constants/query-fields.d.ts.map +1 -0
- package/dist/src/constants/version.d.ts.map +1 -0
- package/dist/{constants → src/constants}/version.generated.d.ts +1 -1
- package/dist/src/constants/version.generated.d.ts.map +1 -0
- package/dist/src/helpers/sdk.d.ts.map +1 -0
- package/dist/src/helpers/wallet.d.ts.map +1 -0
- package/dist/src/index.d.ts +51 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/polyfills/file-global.d.ts.map +1 -0
- package/dist/src/schemas/files.d.ts.map +1 -0
- package/dist/src/schemas/index.d.ts.map +1 -0
- package/dist/src/schemas/launchpad.d.ts.map +1 -0
- package/dist/src/schemas/pagination.d.ts.map +1 -0
- package/dist/src/schemas/primitives.d.ts.map +1 -0
- package/dist/src/schemas/trade.d.ts.map +1 -0
- package/dist/src/schemas/user.d.ts.map +1 -0
- package/dist/src/schemas/validators.d.ts.map +1 -0
- package/dist/src/services/BaseService.d.ts.map +1 -0
- package/dist/src/services/BundleService.d.ts.map +1 -0
- package/dist/src/services/CommentService.d.ts.map +1 -0
- package/dist/src/services/DexBackendClient.d.ts +46 -0
- package/dist/src/services/DexBackendClient.d.ts.map +1 -0
- package/dist/src/services/DexPoolService.d.ts +137 -0
- package/dist/src/services/DexPoolService.d.ts.map +1 -0
- package/dist/src/services/DexQuoteService.d.ts +288 -0
- package/dist/src/services/DexQuoteService.d.ts.map +1 -0
- package/dist/{services → src/services}/DexService.d.ts +83 -9
- package/dist/src/services/DexService.d.ts.map +1 -0
- package/dist/src/services/FaucetService.d.ts.map +1 -0
- package/dist/src/services/GSwapService.d.ts +817 -0
- package/dist/src/services/GSwapService.d.ts.map +1 -0
- package/dist/src/services/GalaChainGatewayClient.d.ts +98 -0
- package/dist/src/services/GalaChainGatewayClient.d.ts.map +1 -0
- package/dist/{services → src/services}/GalaChainService.d.ts +99 -4
- package/dist/src/services/GalaChainService.d.ts.map +1 -0
- package/dist/src/services/ImageService.d.ts.map +1 -0
- package/dist/src/services/LaunchpadService.d.ts.map +1 -0
- package/dist/src/services/MultiPoolStateManager.d.ts +284 -0
- package/dist/src/services/MultiPoolStateManager.d.ts.map +1 -0
- package/dist/src/services/PoolCacheManager.d.ts +171 -0
- package/dist/src/services/PoolCacheManager.d.ts.map +1 -0
- package/dist/src/services/PoolService.d.ts.map +1 -0
- package/dist/src/services/PoolStateManager.d.ts +176 -0
- package/dist/src/services/PoolStateManager.d.ts.map +1 -0
- package/dist/{services → src/services}/PriceHistoryService.d.ts +5 -5
- package/dist/src/services/PriceHistoryService.d.ts.map +1 -0
- package/dist/{services → src/services}/SignatureService.d.ts +13 -35
- package/dist/src/services/SignatureService.d.ts.map +1 -0
- package/dist/src/services/SwapEventQueue.d.ts +123 -0
- package/dist/src/services/SwapEventQueue.d.ts.map +1 -0
- package/dist/src/services/TokenClassKeyService.d.ts.map +1 -0
- package/dist/{services → src/services}/TokenMetadataCache.d.ts +5 -5
- package/dist/src/services/TokenMetadataCache.d.ts.map +1 -0
- package/dist/{services → src/services}/TokenMetadataService.d.ts +3 -3
- package/dist/src/services/TokenMetadataService.d.ts.map +1 -0
- package/dist/src/services/TokenResolverService.d.ts.map +1 -0
- package/dist/src/services/TradeService.d.ts.map +1 -0
- package/dist/src/services/UserService.d.ts.map +1 -0
- package/dist/src/services/WebSocketManager.d.ts.map +1 -0
- package/dist/src/services/WebSocketService.d.ts +183 -0
- package/dist/src/services/WebSocketService.d.ts.map +1 -0
- package/dist/src/services/__mocks__/logger.mock.d.ts +17 -0
- package/dist/src/services/__mocks__/logger.mock.d.ts.map +1 -0
- package/dist/{setup.d.ts.map → src/setup.d.ts.map} +1 -1
- package/dist/{types → src/types}/backend-responses.d.ts +17 -0
- package/dist/src/types/backend-responses.d.ts.map +1 -0
- package/dist/src/types/comment.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/common.d.ts +2 -0
- package/dist/src/types/common.d.ts.map +1 -0
- package/dist/src/types/composite-pool.dto.d.ts +103 -0
- package/dist/src/types/composite-pool.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/dex-pool.dto.d.ts +56 -5
- package/dist/src/types/dex-pool.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/dto.d.ts +6 -6
- package/dist/src/types/dto.d.ts.map +1 -0
- package/dist/src/types/eip712-types.d.ts +140 -0
- package/dist/src/types/eip712-types.d.ts.map +1 -0
- package/dist/src/types/galachain-api.types.d.ts +216 -0
- package/dist/src/types/galachain-api.types.d.ts.map +1 -0
- package/dist/src/types/gswap-responses.types.d.ts +366 -0
- package/dist/src/types/gswap-responses.types.d.ts.map +1 -0
- package/dist/{types → src/types}/gswap.dto.d.ts +58 -3
- package/dist/src/types/gswap.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/launchpad.dto.d.ts +232 -0
- package/dist/src/types/launchpad.dto.d.ts.map +1 -0
- package/dist/src/types/launchpad.validation.d.ts.map +1 -0
- package/dist/src/types/liquidity-monitor.dto.d.ts +177 -0
- package/dist/src/types/liquidity-monitor.dto.d.ts.map +1 -0
- package/dist/src/types/lock.dto.d.ts +146 -0
- package/dist/src/types/lock.dto.d.ts.map +1 -0
- package/dist/src/types/options.dto.d.ts.map +1 -0
- package/dist/src/types/pool-state-delta.dto.d.ts +246 -0
- package/dist/src/types/pool-state-delta.dto.d.ts.map +1 -0
- package/dist/src/types/pool-state-manager-config.dto.d.ts +103 -0
- package/dist/src/types/pool-state-manager-config.dto.d.ts.map +1 -0
- package/dist/{types → src/types}/priceHistory.dto.d.ts +4 -4
- package/dist/src/types/priceHistory.dto.d.ts.map +1 -0
- package/dist/src/types/result.types.d.ts.map +1 -0
- package/dist/src/types/swap-monitor.dto.d.ts +256 -0
- package/dist/src/types/swap-monitor.dto.d.ts.map +1 -0
- package/dist/src/types/trade.dto.d.ts.map +1 -0
- package/dist/src/types/transfer.dto.d.ts.map +1 -0
- package/dist/src/types/user.dto.d.ts.map +1 -0
- package/dist/src/types/websocket-data.types.d.ts.map +1 -0
- package/dist/src/types/websocket.types.d.ts.map +1 -0
- package/dist/src/utils/LiquidityEventExtractor.d.ts +99 -0
- package/dist/src/utils/LiquidityEventExtractor.d.ts.map +1 -0
- package/dist/src/utils/Logger.d.ts.map +1 -0
- package/dist/src/utils/MonitoringMetrics.d.ts +152 -0
- package/dist/src/utils/MonitoringMetrics.d.ts.map +1 -0
- package/dist/src/utils/PoolKeyNormalizer.d.ts +135 -0
- package/dist/src/utils/PoolKeyNormalizer.d.ts.map +1 -0
- package/dist/{utils → src/utils}/SignatureHelper.d.ts +38 -0
- package/dist/src/utils/SignatureHelper.d.ts.map +1 -0
- package/dist/src/utils/SwapEventExtractor.d.ts +152 -0
- package/dist/src/utils/SwapEventExtractor.d.ts.map +1 -0
- package/dist/src/utils/adapters.d.ts.map +1 -0
- package/dist/src/utils/agent-config.d.ts.map +1 -0
- package/dist/{utils → src/utils}/auto-pagination.d.ts +75 -1
- package/dist/src/utils/auto-pagination.d.ts.map +1 -0
- package/dist/{utils → src/utils}/bignumber-helpers.d.ts +79 -3
- package/dist/src/utils/bignumber-helpers.d.ts.map +1 -0
- package/dist/src/utils/bignumber-pool-cache.d.ts +169 -0
- package/dist/src/utils/bignumber-pool-cache.d.ts.map +1 -0
- package/dist/src/utils/bondingCurveCalculations.d.ts.map +1 -0
- package/dist/src/utils/cacheWarmingHelpers.d.ts.map +1 -0
- package/dist/src/utils/composite-pool-converter.d.ts +121 -0
- package/dist/src/utils/composite-pool-converter.d.ts.map +1 -0
- package/dist/src/utils/date-utils.d.ts.map +1 -0
- package/dist/src/utils/error-factories.d.ts.map +1 -0
- package/dist/src/utils/error-utils.d.ts.map +1 -0
- package/dist/{utils → src/utils}/errors.d.ts +86 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/http.d.ts.map +1 -0
- package/dist/src/utils/load-env.d.ts +31 -0
- package/dist/src/utils/load-env.d.ts.map +1 -0
- package/dist/src/utils/multipart-helpers.d.ts.map +1 -0
- package/dist/{utils → src/utils}/multipart.d.ts +2 -2
- package/dist/src/utils/multipart.d.ts.map +1 -0
- package/dist/src/utils/number-utils.d.ts.map +1 -0
- package/dist/src/utils/pool-pair-parser.d.ts +55 -0
- package/dist/src/utils/pool-pair-parser.d.ts.map +1 -0
- package/dist/src/utils/pool-state-validator.d.ts +207 -0
- package/dist/src/utils/pool-state-validator.d.ts.map +1 -0
- package/dist/src/utils/position-filters.d.ts +253 -0
- package/dist/src/utils/position-filters.d.ts.map +1 -0
- package/dist/src/utils/precision-math.d.ts.map +1 -0
- package/dist/{utils → src/utils}/query-params.d.ts +2 -2
- package/dist/src/utils/query-params.d.ts.map +1 -0
- package/dist/src/utils/response-handlers.d.ts.map +1 -0
- package/dist/src/utils/response-normalizers.d.ts.map +1 -0
- package/dist/src/utils/slippage-utils.d.ts.map +1 -0
- package/dist/src/utils/swap-delta-calculator.d.ts +231 -0
- package/dist/src/utils/swap-delta-calculator.d.ts.map +1 -0
- package/dist/src/utils/tick-crossing-handler.d.ts +250 -0
- package/dist/src/utils/tick-crossing-handler.d.ts.map +1 -0
- package/dist/{utils → src/utils}/token-format-converter.d.ts +18 -11
- package/dist/src/utils/token-format-converter.d.ts.map +1 -0
- package/dist/src/utils/token-parser.d.ts +235 -0
- package/dist/src/utils/token-parser.d.ts.map +1 -0
- package/dist/src/utils/tokenNormalizer.d.ts.map +1 -0
- package/dist/src/utils/trade-transformers.d.ts.map +1 -0
- package/dist/src/utils/transfer-validation.d.ts.map +1 -0
- package/dist/{utils → src/utils}/validation-helpers.d.ts +1 -1
- package/dist/src/utils/validation-helpers.d.ts.map +1 -0
- package/dist/src/utils/validation.d.ts.map +1 -0
- package/dist/src/utils/wallet.d.ts.map +1 -0
- package/dist/src/utils/websocket-errors.d.ts.map +1 -0
- package/dist/src/utils/websocket-validators.d.ts.map +1 -0
- package/package.json +73 -19
- package/dist/LaunchpadSDK.d.ts.map +0 -1
- package/dist/api/LaunchpadAPI.d.ts.map +0 -1
- package/dist/api/dto/BondingCurveDTOs.d.ts.map +0 -1
- package/dist/api/dto/TransferTokenDto.d.ts.map +0 -1
- package/dist/auth/SignatureAuth.d.ts.map +0 -1
- package/dist/auth/types.d.ts.map +0 -1
- package/dist/config/environments.d.ts.map +0 -1
- package/dist/constants/bondingCurve.d.ts.map +0 -1
- package/dist/constants/config.d.ts.map +0 -1
- package/dist/constants/counts.d.ts.map +0 -1
- package/dist/constants/decimals.d.ts.map +0 -1
- package/dist/constants/endpoints.d.ts.map +0 -1
- package/dist/constants/enums.d.ts.map +0 -1
- package/dist/constants/error-messages.d.ts.map +0 -1
- package/dist/constants/pagination.d.ts.map +0 -1
- package/dist/constants/query-fields.d.ts.map +0 -1
- package/dist/constants/version.d.ts.map +0 -1
- package/dist/constants/version.generated.d.ts.map +0 -1
- package/dist/helpers/sdk.d.ts.map +0 -1
- package/dist/helpers/wallet.d.ts.map +0 -1
- package/dist/polyfills/file-global.d.ts.map +0 -1
- package/dist/schemas/files.d.ts.map +0 -1
- package/dist/schemas/index.d.ts.map +0 -1
- package/dist/schemas/launchpad.d.ts.map +0 -1
- package/dist/schemas/pagination.d.ts.map +0 -1
- package/dist/schemas/primitives.d.ts.map +0 -1
- package/dist/schemas/trade.d.ts.map +0 -1
- package/dist/schemas/user.d.ts.map +0 -1
- package/dist/schemas/validators.d.ts.map +0 -1
- package/dist/services/BaseService.d.ts.map +0 -1
- package/dist/services/BundleService.d.ts.map +0 -1
- package/dist/services/CommentService.d.ts.map +0 -1
- package/dist/services/DexPoolService.d.ts +0 -95
- package/dist/services/DexPoolService.d.ts.map +0 -1
- package/dist/services/DexService.d.ts.map +0 -1
- package/dist/services/FaucetService.d.ts.map +0 -1
- package/dist/services/GSwapService.d.ts +0 -315
- package/dist/services/GSwapService.d.ts.map +0 -1
- package/dist/services/GalaChainService.d.ts.map +0 -1
- package/dist/services/ImageService.d.ts.map +0 -1
- package/dist/services/LaunchpadService.d.ts.map +0 -1
- package/dist/services/PoolService.d.ts.map +0 -1
- package/dist/services/PriceHistoryService.d.ts.map +0 -1
- package/dist/services/SignatureService.d.ts.map +0 -1
- package/dist/services/TokenClassKeyService.d.ts.map +0 -1
- package/dist/services/TokenMetadataCache.d.ts.map +0 -1
- package/dist/services/TokenMetadataService.d.ts.map +0 -1
- package/dist/services/TokenResolverService.d.ts.map +0 -1
- package/dist/services/TradeService.d.ts.map +0 -1
- package/dist/services/UserService.d.ts.map +0 -1
- package/dist/services/WebSocketManager.d.ts.map +0 -1
- package/dist/services/WebSocketService.d.ts +0 -85
- package/dist/services/WebSocketService.d.ts.map +0 -1
- package/dist/types/backend-responses.d.ts.map +0 -1
- package/dist/types/comment.dto.d.ts.map +0 -1
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/dex-pool.dto.d.ts.map +0 -1
- package/dist/types/dto.d.ts.map +0 -1
- package/dist/types/gswap.dto.d.ts.map +0 -1
- package/dist/types/launchpad.dto.d.ts.map +0 -1
- package/dist/types/launchpad.validation.d.ts.map +0 -1
- package/dist/types/options.dto.d.ts.map +0 -1
- package/dist/types/priceHistory.dto.d.ts.map +0 -1
- package/dist/types/result.types.d.ts.map +0 -1
- package/dist/types/trade.dto.d.ts.map +0 -1
- package/dist/types/transfer.dto.d.ts.map +0 -1
- package/dist/types/user.dto.d.ts.map +0 -1
- package/dist/types/websocket-data.types.d.ts.map +0 -1
- package/dist/types/websocket.types.d.ts.map +0 -1
- package/dist/utils/Logger.d.ts.map +0 -1
- package/dist/utils/SignatureHelper.d.ts.map +0 -1
- package/dist/utils/adapters.d.ts.map +0 -1
- package/dist/utils/agent-config.d.ts.map +0 -1
- package/dist/utils/auto-pagination.d.ts.map +0 -1
- package/dist/utils/bignumber-helpers.d.ts.map +0 -1
- package/dist/utils/bondingCurveCalculations.d.ts.map +0 -1
- package/dist/utils/cacheWarmingHelpers.d.ts.map +0 -1
- package/dist/utils/date-utils.d.ts.map +0 -1
- package/dist/utils/error-factories.d.ts.map +0 -1
- package/dist/utils/error-utils.d.ts.map +0 -1
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/http.d.ts.map +0 -1
- package/dist/utils/multipart-helpers.d.ts.map +0 -1
- package/dist/utils/multipart.d.ts.map +0 -1
- package/dist/utils/number-utils.d.ts.map +0 -1
- package/dist/utils/precision-math.d.ts.map +0 -1
- package/dist/utils/query-params.d.ts.map +0 -1
- package/dist/utils/response-handlers.d.ts.map +0 -1
- package/dist/utils/response-normalizers.d.ts.map +0 -1
- package/dist/utils/slippage-utils.d.ts.map +0 -1
- package/dist/utils/token-format-converter.d.ts.map +0 -1
- package/dist/utils/tokenNormalizer.d.ts.map +0 -1
- package/dist/utils/trade-transformers.d.ts.map +0 -1
- package/dist/utils/transfer-validation.d.ts.map +0 -1
- package/dist/utils/validation-helpers.d.ts.map +0 -1
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/wallet.d.ts.map +0 -1
- package/dist/utils/websocket-errors.d.ts.map +0 -1
- package/dist/utils/websocket-validators.d.ts.map +0 -1
- /package/dist/{api → src/api}/LaunchpadAPI.d.ts +0 -0
- /package/dist/{api → src/api}/dto/BondingCurveDTOs.d.ts +0 -0
- /package/dist/{api → src/api}/dto/TransferTokenDto.d.ts +0 -0
- /package/dist/{auth → src/auth}/SignatureAuth.d.ts +0 -0
- /package/dist/{auth → src/auth}/types.d.ts +0 -0
- /package/dist/{config → src/config}/environments.d.ts +0 -0
- /package/dist/{constants → src/constants}/bondingCurve.d.ts +0 -0
- /package/dist/{constants → src/constants}/config.d.ts +0 -0
- /package/dist/{constants → src/constants}/counts.d.ts +0 -0
- /package/dist/{constants → src/constants}/decimals.d.ts +0 -0
- /package/dist/{constants → src/constants}/endpoints.d.ts +0 -0
- /package/dist/{constants → src/constants}/enums.d.ts +0 -0
- /package/dist/{constants → src/constants}/error-messages.d.ts +0 -0
- /package/dist/{constants → src/constants}/pagination.d.ts +0 -0
- /package/dist/{constants → src/constants}/query-fields.d.ts +0 -0
- /package/dist/{constants → src/constants}/version.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/sdk.d.ts +0 -0
- /package/dist/{helpers → src/helpers}/wallet.d.ts +0 -0
- /package/dist/{polyfills → src/polyfills}/file-global.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/files.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/index.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/launchpad.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/pagination.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/primitives.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/trade.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/user.d.ts +0 -0
- /package/dist/{schemas → src/schemas}/validators.d.ts +0 -0
- /package/dist/{services → src/services}/BaseService.d.ts +0 -0
- /package/dist/{services → src/services}/BundleService.d.ts +0 -0
- /package/dist/{services → src/services}/CommentService.d.ts +0 -0
- /package/dist/{services → src/services}/FaucetService.d.ts +0 -0
- /package/dist/{services → src/services}/ImageService.d.ts +0 -0
- /package/dist/{services → src/services}/LaunchpadService.d.ts +0 -0
- /package/dist/{services → src/services}/PoolService.d.ts +0 -0
- /package/dist/{services → src/services}/TokenClassKeyService.d.ts +0 -0
- /package/dist/{services → src/services}/TokenResolverService.d.ts +0 -0
- /package/dist/{services → src/services}/TradeService.d.ts +0 -0
- /package/dist/{services → src/services}/UserService.d.ts +0 -0
- /package/dist/{services → src/services}/WebSocketManager.d.ts +0 -0
- /package/dist/{setup.d.ts → src/setup.d.ts} +0 -0
- /package/dist/{types → src/types}/comment.dto.d.ts +0 -0
- /package/dist/{types → src/types}/launchpad.validation.d.ts +0 -0
- /package/dist/{types → src/types}/options.dto.d.ts +0 -0
- /package/dist/{types → src/types}/result.types.d.ts +0 -0
- /package/dist/{types → src/types}/trade.dto.d.ts +0 -0
- /package/dist/{types → src/types}/transfer.dto.d.ts +0 -0
- /package/dist/{types → src/types}/user.dto.d.ts +0 -0
- /package/dist/{types → src/types}/websocket-data.types.d.ts +0 -0
- /package/dist/{types → src/types}/websocket.types.d.ts +0 -0
- /package/dist/{utils → src/utils}/Logger.d.ts +0 -0
- /package/dist/{utils → src/utils}/adapters.d.ts +0 -0
- /package/dist/{utils → src/utils}/agent-config.d.ts +0 -0
- /package/dist/{utils → src/utils}/bondingCurveCalculations.d.ts +0 -0
- /package/dist/{utils → src/utils}/cacheWarmingHelpers.d.ts +0 -0
- /package/dist/{utils → src/utils}/date-utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/error-factories.d.ts +0 -0
- /package/dist/{utils → src/utils}/error-utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/http.d.ts +0 -0
- /package/dist/{utils → src/utils}/multipart-helpers.d.ts +0 -0
- /package/dist/{utils → src/utils}/number-utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/precision-math.d.ts +0 -0
- /package/dist/{utils → src/utils}/response-handlers.d.ts +0 -0
- /package/dist/{utils → src/utils}/response-normalizers.d.ts +0 -0
- /package/dist/{utils → src/utils}/slippage-utils.d.ts +0 -0
- /package/dist/{utils → src/utils}/tokenNormalizer.d.ts +0 -0
- /package/dist/{utils → src/utils}/trade-transformers.d.ts +0 -0
- /package/dist/{utils → src/utils}/transfer-validation.d.ts +0 -0
- /package/dist/{utils → src/utils}/validation.d.ts +0 -0
- /package/dist/{utils → src/utils}/wallet.d.ts +0 -0
- /package/dist/{utils → src/utils}/websocket-errors.d.ts +0 -0
- /package/dist/{utils → src/utils}/websocket-validators.d.ts +0 -0
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { Wallet } from 'ethers';
|
|
2
2
|
import { SDKConfig, AddressFormat, TokenClassKey, TokenId } from './types/common';
|
|
3
3
|
import { PoolDetailsData } from './types/trade.dto';
|
|
4
|
-
import { LaunchTokenData, TokenSpotPrice, FetchPoolsOptions, PoolsResult, GalaChainTokenDetails, PoolData } from './types/launchpad.dto';
|
|
4
|
+
import { LaunchTokenData, TokenSpotPrice, FetchPoolsOptions, PoolsResult, GalaChainTokenDetails, PoolData, TokenClassWithSupply, DexSeason, LeaderboardResult, DexAggregatedVolumeSummary } from './types/launchpad.dto';
|
|
5
5
|
import { UpdateProfileData, UploadProfileImageOptions, FetchTokenBalanceOptions } from './types/user.dto';
|
|
6
6
|
import { TransferGalaData, TransferTokenData } from './types/transfer.dto';
|
|
7
|
+
import { LockTokenData, UnlockTokenData } from './types/lock.dto';
|
|
7
8
|
import { TokenLaunchResult, TradeResult } from './types/result.types';
|
|
8
9
|
import { WebSocketError, WebSocketTimeoutError, TransactionFailedError } from './utils/websocket-errors';
|
|
9
10
|
export { WebSocketError, WebSocketTimeoutError, TransactionFailedError, };
|
|
10
11
|
import { FetchCommentsOptions, PostCommentOptions, FetchVolumeDataOptions, FetchTradesOptions, CalculateBuyAmountOptions, CalculateSellAmountOptions, CalculateBuyAmountLocalOptions, CalculateSellAmountLocalOptions, BuyTokenOptions, SellTokenOptions, UploadImageByTokenNameOptions, FetchTokensHeldOptions, FetchTokensCreatedOptions, GraduateTokenOptions, FetchLaunchpadTokenSpotPriceOptions, FetchTokenSpotPriceParams, CalculateBuyAmountForGraduationOptions } from './types/options.dto';
|
|
11
12
|
import { FetchPriceHistoryOptions, PriceHistoryResult } from './types/priceHistory.dto';
|
|
12
13
|
import { FetchDexPoolsOptions, DexPoolsResult, DexPoolData } from './types/dex-pool.dto';
|
|
14
|
+
import { GSwapPosition, PoolPriceData, GetLiquidityPositionsOptions, GetLiquidityPositionsResult } from './types/gswap.dto';
|
|
15
|
+
import type { FetchCompositePoolDataOptions, CompositePoolDataResult, CalculateDexPoolQuoteOptions, DexPoolQuoteResult } from './types/composite-pool.dto';
|
|
16
|
+
import type { SubscribeSwapOptions, SwapMonitorConfig, CleanupFunction, SwapEventCallback } from './types/swap-monitor.dto';
|
|
17
|
+
import type { LiquidityChangedCallback, LiquidityCleanupFunction, SubscribeLiquidityOptions } from './types/liquidity-monitor.dto';
|
|
13
18
|
/**
|
|
14
19
|
* Configuration for initializing the Launchpad SDK
|
|
15
20
|
*
|
|
@@ -72,6 +77,22 @@ export interface LaunchpadSDKConfig extends SDKConfig {
|
|
|
72
77
|
* @default 'local'
|
|
73
78
|
*/
|
|
74
79
|
calculateAmountMode?: 'local' | 'external';
|
|
80
|
+
/**
|
|
81
|
+
* Optional network timeout for DEX quote API calls (in milliseconds).
|
|
82
|
+
* Use for rate-limited APIs or networks with high latency.
|
|
83
|
+
* @default 30000 (30 seconds)
|
|
84
|
+
* @min 1000
|
|
85
|
+
* @max 300000
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* // Increase timeout for rate-limited API
|
|
89
|
+
* const sdk = new LaunchpadSDK({
|
|
90
|
+
* wallet,
|
|
91
|
+
* dexQuoteNetworkTimeout: 60000 // 60 seconds
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
dexQuoteNetworkTimeout?: number;
|
|
75
96
|
}
|
|
76
97
|
/**
|
|
77
98
|
* Main Launchpad SDK class providing access to all Gala Launchpad functionality
|
|
@@ -151,9 +172,11 @@ export declare class LaunchpadSDK {
|
|
|
151
172
|
private readonly dexApiHttp;
|
|
152
173
|
private readonly dexBackendHttp;
|
|
153
174
|
private readonly config;
|
|
175
|
+
private readonly environment;
|
|
154
176
|
private readonly slippageToleranceFactor;
|
|
155
177
|
private readonly maxAcceptableReverseBondingCurveFeeSlippageFactor;
|
|
156
178
|
private readonly calculateAmountMode;
|
|
179
|
+
private readonly pricingConcurrency;
|
|
157
180
|
private readonly logger;
|
|
158
181
|
private readonly tokenResolverService;
|
|
159
182
|
private readonly launchpadService;
|
|
@@ -164,6 +187,7 @@ export declare class LaunchpadSDK {
|
|
|
164
187
|
private readonly priceHistoryService;
|
|
165
188
|
private readonly gswapService;
|
|
166
189
|
private readonly dexPoolService;
|
|
190
|
+
private readonly dexQuoteService;
|
|
167
191
|
private readonly cache;
|
|
168
192
|
private readonly launchpadAPI;
|
|
169
193
|
constructor(config: LaunchpadSDKConfig);
|
|
@@ -413,7 +437,9 @@ export declare class LaunchpadSDK {
|
|
|
413
437
|
* }
|
|
414
438
|
* ```
|
|
415
439
|
*/
|
|
416
|
-
getConfig(): Omit<LaunchpadSDKConfig, 'wallet'
|
|
440
|
+
getConfig(): Omit<LaunchpadSDKConfig, 'wallet'> & {
|
|
441
|
+
environment: 'STAGE' | 'PROD';
|
|
442
|
+
};
|
|
417
443
|
/**
|
|
418
444
|
* Get the SDK version
|
|
419
445
|
*
|
|
@@ -685,7 +711,170 @@ export declare class LaunchpadSDK {
|
|
|
685
711
|
*/
|
|
686
712
|
fetchAllDexPools(options?: Omit<FetchDexPoolsOptions, 'page' | 'limit'>): Promise<DexPoolsResult>;
|
|
687
713
|
/**
|
|
688
|
-
* Fetch
|
|
714
|
+
* Fetch composite pool data from GalaChain for offline DEX quote calculations
|
|
715
|
+
*
|
|
716
|
+
* Retrieves complete pool state including liquidity, tick data, token balances, and decimals.
|
|
717
|
+
* This data is required for offline quote calculations using local bonding curve math.
|
|
718
|
+
*
|
|
719
|
+
* The composite pool data can be fetched once and reused for multiple quote calculations,
|
|
720
|
+
* making it efficient for bulk pricing operations.
|
|
721
|
+
*
|
|
722
|
+
* @param options Pool identification options with token pair and fee tier
|
|
723
|
+
* @returns CompositePoolDataResult containing complete pool state for offline calculations
|
|
724
|
+
* @throws DexPoolNotFoundError if the pool does not exist
|
|
725
|
+
* @throws DexQuoteError on API or conversion errors
|
|
726
|
+
* @since 3.32.0
|
|
727
|
+
* @category DEX Quotes
|
|
728
|
+
*
|
|
729
|
+
* @example Fetch and reuse composite pool data
|
|
730
|
+
* ```typescript
|
|
731
|
+
* // Step 1: Fetch composite data (one network call)
|
|
732
|
+
* const composite = await sdk.fetchCompositePoolData({
|
|
733
|
+
* token0: 'GALA|Unit|none|none',
|
|
734
|
+
* token1: 'Token|Unit|BENE|client:5c806869e7fd0e2384461ce9',
|
|
735
|
+
* fee: 3000 // 0.30%
|
|
736
|
+
* });
|
|
737
|
+
*
|
|
738
|
+
* // Step 2: Calculate multiple quotes using same composite data (instant, local)
|
|
739
|
+
* const quote1 = await sdk.calculateDexPoolQuoteExactAmountLocal({
|
|
740
|
+
* compositePoolData: composite,
|
|
741
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
742
|
+
* toToken: 'Token|Unit|BENE|client:5c806869e7fd0e2384461ce9',
|
|
743
|
+
* amount: '100'
|
|
744
|
+
* });
|
|
745
|
+
*
|
|
746
|
+
* const quote2 = await sdk.calculateDexPoolQuoteExactAmountLocal({
|
|
747
|
+
* compositePoolData: composite,
|
|
748
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
749
|
+
* toToken: 'Token|Unit|BENE|client:5c806869e7fd0e2384461ce9',
|
|
750
|
+
* amount: '500'
|
|
751
|
+
* });
|
|
752
|
+
*
|
|
753
|
+
* // Step 3: Compare with real-time quote from chain
|
|
754
|
+
* const liveQuote = await sdk.calculateDexPoolQuoteExactAmountExternal({
|
|
755
|
+
* compositePoolData: composite,
|
|
756
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
757
|
+
* toToken: 'Token|Unit|BENE|client:5c806869e7fd0e2384461ce9',
|
|
758
|
+
* amount: '100'
|
|
759
|
+
* });
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
fetchCompositePoolData(options: FetchCompositePoolDataOptions): Promise<CompositePoolDataResult>;
|
|
763
|
+
/**
|
|
764
|
+
* Calculate DEX pool quote using LOCAL client-side calculation
|
|
765
|
+
*
|
|
766
|
+
* Instant quotes without network calls using pre-fetched composite pool data and
|
|
767
|
+
* the @gala-chain/dex bonding curve math library.
|
|
768
|
+
*
|
|
769
|
+
* Perfect for bulk pricing operations, simulations, and price discovery where
|
|
770
|
+
* network latency is unacceptable.
|
|
771
|
+
*
|
|
772
|
+
* @param options Quote calculation options (must include pre-fetched compositePoolData)
|
|
773
|
+
* @returns DexPoolQuoteResult with input/output amounts and execution prices
|
|
774
|
+
* @throws DexQuoteError on calculation errors
|
|
775
|
+
* @since 3.32.0
|
|
776
|
+
* @category DEX Quotes
|
|
777
|
+
*
|
|
778
|
+
* @example Fast bulk pricing
|
|
779
|
+
* ```typescript
|
|
780
|
+
* const composite = await sdk.fetchCompositePoolData({
|
|
781
|
+
* token0: 'GALA|Unit|none|none',
|
|
782
|
+
* token1: 'Token|Unit|BENE|client:123',
|
|
783
|
+
* fee: 3000
|
|
784
|
+
* });
|
|
785
|
+
*
|
|
786
|
+
* // Get 100 instant quotes without any network calls
|
|
787
|
+
* const amounts = ['10', '50', '100', '500', '1000'];
|
|
788
|
+
* const quotes = await Promise.all(
|
|
789
|
+
* amounts.map(amount =>
|
|
790
|
+
* sdk.calculateDexPoolQuoteExactAmountLocal({
|
|
791
|
+
* compositePoolData: composite,
|
|
792
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
793
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
794
|
+
* amount
|
|
795
|
+
* })
|
|
796
|
+
* )
|
|
797
|
+
* );
|
|
798
|
+
* ```
|
|
799
|
+
*/
|
|
800
|
+
calculateDexPoolQuoteExactAmountLocal(options: CalculateDexPoolQuoteOptions): Promise<DexPoolQuoteResult>;
|
|
801
|
+
/**
|
|
802
|
+
* Calculate DEX pool quote using EXTERNAL GalaChain network call
|
|
803
|
+
*
|
|
804
|
+
* Real-time quotes directly from the blockchain. Slower than local calculation
|
|
805
|
+
* but always reflects current pool state and is useful for final price verification.
|
|
806
|
+
*
|
|
807
|
+
* @param options Quote calculation options (compositePoolData provides token metadata)
|
|
808
|
+
* @returns DexPoolQuoteResult with current chain state
|
|
809
|
+
* @throws DexQuoteError on network or calculation errors
|
|
810
|
+
* @since 3.32.0
|
|
811
|
+
* @category DEX Quotes
|
|
812
|
+
*
|
|
813
|
+
* @example Verify quote with live chain data
|
|
814
|
+
* ```typescript
|
|
815
|
+
* const composite = await sdk.fetchCompositePoolData({
|
|
816
|
+
* token0: 'GALA|Unit|none|none',
|
|
817
|
+
* token1: 'Token|Unit|BENE|client:123',
|
|
818
|
+
* fee: 3000
|
|
819
|
+
* });
|
|
820
|
+
*
|
|
821
|
+
* // Local estimate (instant)
|
|
822
|
+
* const estimate = await sdk.calculateDexPoolQuoteExactAmountLocal({
|
|
823
|
+
* compositePoolData: composite,
|
|
824
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
825
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
826
|
+
* amount: '1000'
|
|
827
|
+
* });
|
|
828
|
+
*
|
|
829
|
+
* // Live verification from chain
|
|
830
|
+
* const liveQuote = await sdk.calculateDexPoolQuoteExactAmountExternal({
|
|
831
|
+
* compositePoolData: composite,
|
|
832
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
833
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
834
|
+
* amount: '1000'
|
|
835
|
+
* });
|
|
836
|
+
*
|
|
837
|
+
* console.log(`Difference: ${estimate.amount1} vs ${liveQuote.amount1}`);
|
|
838
|
+
* ```
|
|
839
|
+
*/
|
|
840
|
+
calculateDexPoolQuoteExactAmountExternal(options: CalculateDexPoolQuoteOptions): Promise<DexPoolQuoteResult>;
|
|
841
|
+
/**
|
|
842
|
+
* Calculate DEX pool quote with automatic mode selection
|
|
843
|
+
*
|
|
844
|
+
* Main quote calculation method that delegates to local or external based on mode parameter.
|
|
845
|
+
* Defaults to local (instant) calculation.
|
|
846
|
+
*
|
|
847
|
+
* @param options Quote calculation options
|
|
848
|
+
* @param mode 'local' (instant, client-side) or 'external' (real-time, chain) - defaults to 'local'
|
|
849
|
+
* @returns DexPoolQuoteResult with amounts and prices
|
|
850
|
+
* @since 3.32.0
|
|
851
|
+
* @category DEX Quotes
|
|
852
|
+
*
|
|
853
|
+
* @example Using default local mode
|
|
854
|
+
* ```typescript
|
|
855
|
+
* const quote = await sdk.calculateDexPoolQuoteExactAmount({
|
|
856
|
+
* compositePoolData: composite,
|
|
857
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
858
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
859
|
+
* amount: '1000'
|
|
860
|
+
* });
|
|
861
|
+
* // Returns instant local quote
|
|
862
|
+
* ```
|
|
863
|
+
*
|
|
864
|
+
* @example Explicit external mode for real-time
|
|
865
|
+
* ```typescript
|
|
866
|
+
* const liveQuote = await sdk.calculateDexPoolQuoteExactAmount({
|
|
867
|
+
* compositePoolData: composite,
|
|
868
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
869
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
870
|
+
* amount: '1000'
|
|
871
|
+
* }, 'external');
|
|
872
|
+
* // Returns real-time quote from chain
|
|
873
|
+
* ```
|
|
874
|
+
*/
|
|
875
|
+
calculateDexPoolQuoteExactAmount(options: CalculateDexPoolQuoteOptions, mode?: 'local' | 'external'): Promise<DexPoolQuoteResult>;
|
|
876
|
+
/**
|
|
877
|
+
* Token distribution information
|
|
689
878
|
*
|
|
690
879
|
* @param tokenName Token name to fetch distribution for
|
|
691
880
|
* @returns Promise<TokenDistributionResult>
|
|
@@ -786,7 +975,7 @@ export declare class LaunchpadSDK {
|
|
|
786
975
|
* and trading capabilities.
|
|
787
976
|
*
|
|
788
977
|
* Supports flexible token identification using either string or object format:
|
|
789
|
-
* - String: `'
|
|
978
|
+
* - String: `'GUSDC|Unit|none|eth:0x...'` (pipe-delimited)
|
|
790
979
|
* - Object: `{ collection, category, type, additionalKey }`
|
|
791
980
|
*
|
|
792
981
|
* @param tokenId Token identifier in flexible format
|
|
@@ -794,7 +983,7 @@ export declare class LaunchpadSDK {
|
|
|
794
983
|
*
|
|
795
984
|
* @example String format
|
|
796
985
|
* ```typescript
|
|
797
|
-
* const details = await sdk.fetchTokenDetails('
|
|
986
|
+
* const details = await sdk.fetchTokenDetails('GUSDC|Unit|none|none');
|
|
798
987
|
* console.log(details.symbol); // 'GUSDC'
|
|
799
988
|
* console.log(details.decimals); // 6
|
|
800
989
|
* console.log(details.verified); // true
|
|
@@ -804,10 +993,10 @@ export declare class LaunchpadSDK {
|
|
|
804
993
|
* @example Object format
|
|
805
994
|
* ```typescript
|
|
806
995
|
* const details = await sdk.fetchTokenDetails({
|
|
807
|
-
* collection: '
|
|
996
|
+
* collection: 'GUSDC',
|
|
808
997
|
* category: 'Unit',
|
|
809
|
-
* type: '
|
|
810
|
-
* additionalKey: '
|
|
998
|
+
* type: 'none',
|
|
999
|
+
* additionalKey: 'none'
|
|
811
1000
|
* });
|
|
812
1001
|
* ```
|
|
813
1002
|
*
|
|
@@ -815,6 +1004,156 @@ export declare class LaunchpadSDK {
|
|
|
815
1004
|
* @throws {NetworkError} If API request fails or token not found
|
|
816
1005
|
*/
|
|
817
1006
|
fetchTokenDetails(tokenId: TokenId): Promise<GalaChainTokenDetails>;
|
|
1007
|
+
/**
|
|
1008
|
+
* Fetch all available DEX leaderboard seasons
|
|
1009
|
+
*
|
|
1010
|
+
* Returns all season configurations with time ranges. Use season IDs
|
|
1011
|
+
* to fetch specific leaderboards with `fetchDexLeaderboardBySeasonId()`.
|
|
1012
|
+
*
|
|
1013
|
+
* @category DEX Leaderboard
|
|
1014
|
+
* @returns Promise<DexSeason[]> Array of all seasons
|
|
1015
|
+
* @throws {NetworkError} If API request fails
|
|
1016
|
+
* @since 3.X.0
|
|
1017
|
+
*
|
|
1018
|
+
* @example
|
|
1019
|
+
* ```typescript
|
|
1020
|
+
* const seasons = await sdk.fetchAllDexSeasons();
|
|
1021
|
+
* console.log(`Found ${seasons.length} seasons`);
|
|
1022
|
+
* seasons.forEach(s => {
|
|
1023
|
+
* console.log(`${s.name}: ${s.start} to ${s.end}`);
|
|
1024
|
+
* });
|
|
1025
|
+
* ```
|
|
1026
|
+
*/
|
|
1027
|
+
fetchAllDexSeasons(): Promise<DexSeason[]>;
|
|
1028
|
+
/**
|
|
1029
|
+
* Find the currently active DEX leaderboard season
|
|
1030
|
+
*
|
|
1031
|
+
* Determines which season is active based on current time falling
|
|
1032
|
+
* between season start and end dates. Returns null if no season
|
|
1033
|
+
* is currently active.
|
|
1034
|
+
*
|
|
1035
|
+
* @category DEX Leaderboard
|
|
1036
|
+
* @returns Promise<DexSeason | null> Current season or null
|
|
1037
|
+
* @throws {NetworkError} If API request fails
|
|
1038
|
+
* @since 3.X.0
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* ```typescript
|
|
1042
|
+
* const current = await sdk.fetchCurrentDexSeason();
|
|
1043
|
+
* if (current) {
|
|
1044
|
+
* console.log(`Active: ${current.name} (ID: ${current.id})`);
|
|
1045
|
+
* } else {
|
|
1046
|
+
* console.log('No active season');
|
|
1047
|
+
* }
|
|
1048
|
+
* ```
|
|
1049
|
+
*/
|
|
1050
|
+
fetchCurrentDexSeason(): Promise<DexSeason | null>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Fetch DEX leaderboard for a specific season
|
|
1053
|
+
*
|
|
1054
|
+
* Returns complete leaderboard rankings with XP metrics and achievement titles.
|
|
1055
|
+
* Non-paginated response includes all entries (typically 100 participants).
|
|
1056
|
+
*
|
|
1057
|
+
* **XP Metrics:**
|
|
1058
|
+
* - `totalXp`: Combined liquidity + trading XP
|
|
1059
|
+
* - `liquidityXp`: Points from providing liquidity
|
|
1060
|
+
* - `tradingXp`: Points from trading volume
|
|
1061
|
+
*
|
|
1062
|
+
* **Achievement Titles:**
|
|
1063
|
+
* - Liquidity titles: Pool Explorer, Flow Enabler, Yield Artisan, etc.
|
|
1064
|
+
* - Trading titles: Novice Trader, Rookie Trader, Elite Trader, etc.
|
|
1065
|
+
* - Order indicates tier (1 = entry level, higher = more advanced)
|
|
1066
|
+
*
|
|
1067
|
+
* @category DEX Leaderboard
|
|
1068
|
+
* @param seasonId Season identifier number (must be positive integer)
|
|
1069
|
+
* @returns Promise<LeaderboardResult> Complete leaderboard with rankings and metrics
|
|
1070
|
+
* @throws {RequiredFieldError} If seasonId is invalid
|
|
1071
|
+
* @throws {NetworkError} If API request fails
|
|
1072
|
+
* @since 3.X.0
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* ```typescript
|
|
1076
|
+
* // Fetch specific season leaderboard
|
|
1077
|
+
* const leaderboard = await sdk.fetchDexLeaderboardBySeasonId(4);
|
|
1078
|
+
*
|
|
1079
|
+
* // Display top trader
|
|
1080
|
+
* const topTrader = leaderboard.entries[0];
|
|
1081
|
+
* console.log(`Rank 1: ${topTrader.wallet}`);
|
|
1082
|
+
* console.log(`Total XP: ${topTrader.totalXp}`);
|
|
1083
|
+
* console.log(`Distribution: ${topTrader.distributionPercent}%`);
|
|
1084
|
+
*
|
|
1085
|
+
* // Find users with specific titles
|
|
1086
|
+
* const whales = leaderboard.entries.filter(entry =>
|
|
1087
|
+
* entry.masteryTitles.some(t => t.name === 'Protocol Whale')
|
|
1088
|
+
* );
|
|
1089
|
+
* ```
|
|
1090
|
+
*/
|
|
1091
|
+
fetchDexLeaderboardBySeasonId(seasonId: number): Promise<LeaderboardResult>;
|
|
1092
|
+
/**
|
|
1093
|
+
* Fetch leaderboard for the currently active season
|
|
1094
|
+
*
|
|
1095
|
+
* Convenience method that automatically determines the current season
|
|
1096
|
+
* and fetches its leaderboard. Returns null if no season is active.
|
|
1097
|
+
*
|
|
1098
|
+
* Equivalent to:
|
|
1099
|
+
* ```typescript
|
|
1100
|
+
* const season = await sdk.fetchCurrentDexSeason();
|
|
1101
|
+
* return season ? sdk.fetchDexLeaderboardBySeasonId(season.id) : null;
|
|
1102
|
+
* ```
|
|
1103
|
+
*
|
|
1104
|
+
* @category DEX Leaderboard
|
|
1105
|
+
* @returns Promise<LeaderboardResult | null> Current leaderboard or null
|
|
1106
|
+
* @throws {NetworkError} If API request fails
|
|
1107
|
+
* @since 3.X.0
|
|
1108
|
+
*
|
|
1109
|
+
* @example
|
|
1110
|
+
* ```typescript
|
|
1111
|
+
* // Get current leaderboard in one call
|
|
1112
|
+
* const leaderboard = await sdk.fetchCurrentDexLeaderboard();
|
|
1113
|
+
*
|
|
1114
|
+
* if (leaderboard) {
|
|
1115
|
+
* console.log(`Season ${leaderboard.seasonId} leaders:`);
|
|
1116
|
+
* leaderboard.entries.slice(0, 10).forEach(entry => {
|
|
1117
|
+
* console.log(`${entry.rank}. ${entry.wallet}: ${entry.totalXp} XP`);
|
|
1118
|
+
* });
|
|
1119
|
+
* } else {
|
|
1120
|
+
* console.log('No active season');
|
|
1121
|
+
* }
|
|
1122
|
+
* ```
|
|
1123
|
+
*/
|
|
1124
|
+
fetchCurrentDexLeaderboard(): Promise<LeaderboardResult | null>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Fetch DEX aggregated volume summary with trend metrics
|
|
1127
|
+
*
|
|
1128
|
+
* Returns platform-wide trading volume statistics across all DEX pools with
|
|
1129
|
+
* 1-day, 7-day, and 30-day comparisons and percentage changes.
|
|
1130
|
+
*
|
|
1131
|
+
* **Use Cases:**
|
|
1132
|
+
* - Monitor overall DEX trading activity
|
|
1133
|
+
* - Identify volume trends and patterns
|
|
1134
|
+
* - Compare performance across time periods
|
|
1135
|
+
* - Detect market changes (increases/decreases)
|
|
1136
|
+
*
|
|
1137
|
+
* @category DEX Analytics
|
|
1138
|
+
* @returns Promise<DexAggregatedVolumeSummary> Volume metrics with deltas
|
|
1139
|
+
* @throws {NetworkError} If API request fails
|
|
1140
|
+
* @since 4.0.0
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const summary = await sdk.fetchDexAggregatedVolumeSummary();
|
|
1145
|
+
* console.log(`Today's volume: $${summary.volume1d.toFixed(2)}`);
|
|
1146
|
+
* console.log(`7-day change: ${(summary.volume7dDelta * 100).toFixed(2)}%`);
|
|
1147
|
+
*
|
|
1148
|
+
* // Analyze trend direction
|
|
1149
|
+
* if (summary.volume1dDelta > 0) {
|
|
1150
|
+
* console.log('✅ Volume increasing');
|
|
1151
|
+
* } else {
|
|
1152
|
+
* console.log('📉 Volume decreasing');
|
|
1153
|
+
* }
|
|
1154
|
+
* ```
|
|
1155
|
+
*/
|
|
1156
|
+
fetchDexAggregatedVolumeSummary(): Promise<DexAggregatedVolumeSummary>;
|
|
818
1157
|
/**
|
|
819
1158
|
* Fetch the current launchpad token launch fee
|
|
820
1159
|
*
|
|
@@ -840,6 +1179,44 @@ export declare class LaunchpadSDK {
|
|
|
840
1179
|
* ```
|
|
841
1180
|
*/
|
|
842
1181
|
fetchLaunchTokenFee(): Promise<number>;
|
|
1182
|
+
/**
|
|
1183
|
+
* Fetch supply information for token classes from GalaChain
|
|
1184
|
+
*
|
|
1185
|
+
* Queries GalaChain for authoritative token supply data including:
|
|
1186
|
+
* - Total supply and maximum supply
|
|
1187
|
+
* - Total burned amount
|
|
1188
|
+
* - Mint-related supply metrics
|
|
1189
|
+
* - Token metadata (symbol, decimals, name)
|
|
1190
|
+
*
|
|
1191
|
+
* @param tokenClasses Array of token class keys to query
|
|
1192
|
+
* @returns Promise<TokenClassWithSupply[]> Array of token classes with supply information
|
|
1193
|
+
* @throws {ValidationError} if tokenClasses array is empty
|
|
1194
|
+
* @throws {Error} if network request fails
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* ```typescript
|
|
1198
|
+
* // Query single token
|
|
1199
|
+
* const supplies = await sdk.fetchTokenClassesWithSupply([
|
|
1200
|
+
* { collection: 'GALA', category: 'Unit', type: 'none', additionalKey: 'none' }
|
|
1201
|
+
* ]);
|
|
1202
|
+
* console.log(`GALA total supply: ${supplies[0].totalSupply}`);
|
|
1203
|
+
*
|
|
1204
|
+
* // Query multiple tokens
|
|
1205
|
+
* const multiSupplies = await sdk.fetchTokenClassesWithSupply([
|
|
1206
|
+
* { collection: 'GALA', category: 'Unit', type: 'none', additionalKey: 'none' },
|
|
1207
|
+
* { collection: 'GUSDC', category: 'Unit', type: 'none', additionalKey: 'eth:0x...' }
|
|
1208
|
+
* ]);
|
|
1209
|
+
*
|
|
1210
|
+
* // Print supply summary
|
|
1211
|
+
* for (const token of multiSupplies) {
|
|
1212
|
+
* console.log(`${token.symbol}: ${token.totalSupply} (max: ${token.maxSupply})`);
|
|
1213
|
+
* }
|
|
1214
|
+
* ```
|
|
1215
|
+
*
|
|
1216
|
+
* @category Token Data
|
|
1217
|
+
* @since 3.32.0
|
|
1218
|
+
*/
|
|
1219
|
+
fetchTokenClassesWithSupply(tokenClasses: TokenClassKey[]): Promise<TokenClassWithSupply[]>;
|
|
843
1220
|
/**
|
|
844
1221
|
* Fetch pool details for a token - returns complete bonding curve pool state
|
|
845
1222
|
*
|
|
@@ -1495,10 +1872,10 @@ export declare class LaunchpadSDK {
|
|
|
1495
1872
|
* // Fetch price history for a DEX token
|
|
1496
1873
|
* const history = await sdk.fetchPriceHistory({
|
|
1497
1874
|
* tokenClassKey: {
|
|
1498
|
-
* collection: '
|
|
1875
|
+
* collection: 'GUSDC',
|
|
1499
1876
|
* category: 'Unit',
|
|
1500
|
-
* type: '
|
|
1501
|
-
* additionalKey: '
|
|
1877
|
+
* type: 'none',
|
|
1878
|
+
* additionalKey: 'none'
|
|
1502
1879
|
* },
|
|
1503
1880
|
* from: new Date('2024-01-01'),
|
|
1504
1881
|
* to: new Date('2024-01-31'),
|
|
@@ -1534,10 +1911,10 @@ export declare class LaunchpadSDK {
|
|
|
1534
1911
|
* // Fetch all price history for a DEX token (automatic pagination)
|
|
1535
1912
|
* const allHistory = await sdk.fetchAllPriceHistory({
|
|
1536
1913
|
* tokenId: {
|
|
1537
|
-
* collection: '
|
|
1914
|
+
* collection: 'GUSDC',
|
|
1538
1915
|
* category: 'Unit',
|
|
1539
|
-
* type: '
|
|
1540
|
-
* additionalKey: '
|
|
1916
|
+
* type: 'none',
|
|
1917
|
+
* additionalKey: 'none'
|
|
1541
1918
|
* },
|
|
1542
1919
|
* from: new Date('2024-01-01'),
|
|
1543
1920
|
* to: new Date('2024-12-31')
|
|
@@ -1628,6 +2005,88 @@ export declare class LaunchpadSDK {
|
|
|
1628
2005
|
* @throws {TransferError} When token name cannot be resolved
|
|
1629
2006
|
*/
|
|
1630
2007
|
resolveTokenClassKey(tokenName: string): Promise<TokenClassKey>;
|
|
2008
|
+
/**
|
|
2009
|
+
* Lock tokens on GalaChain
|
|
2010
|
+
*
|
|
2011
|
+
* Places a hold on tokens, preventing them from being transferred until unlocked.
|
|
2012
|
+
* Useful for staking, escrow, vesting, or other hold scenarios.
|
|
2013
|
+
*
|
|
2014
|
+
* The lock operation creates a hold that can only be released by the lock authority
|
|
2015
|
+
* (defaults to the caller's address if not specified).
|
|
2016
|
+
*
|
|
2017
|
+
* @param data Lock token parameters
|
|
2018
|
+
* @param data.tokenId Flexible token identifier (string, TokenClassKey, or TokenInstanceKey)
|
|
2019
|
+
* @param data.tokenName Token name for lookup (used if tokenId not provided)
|
|
2020
|
+
* @param data.amount Amount of tokens to lock in decimal format
|
|
2021
|
+
* @param data.lockAuthority Address that can manage/unlock (defaults to caller)
|
|
2022
|
+
* @param data.expires Optional expiration timestamp (epoch milliseconds)
|
|
2023
|
+
* @param data.name Optional lock name/identifier for matching during unlock
|
|
2024
|
+
* @param data.uniqueKey Optional unique key for idempotency
|
|
2025
|
+
* @param data.privateKey Optional private key override for this operation
|
|
2026
|
+
* @returns Transaction ID of the lock operation
|
|
2027
|
+
*
|
|
2028
|
+
* @example Lock tokens with default authority
|
|
2029
|
+
* ```typescript
|
|
2030
|
+
* const txId = await sdk.lockToken({
|
|
2031
|
+
* tokenName: 'anime',
|
|
2032
|
+
* amount: '1000'
|
|
2033
|
+
* });
|
|
2034
|
+
* console.log('Tokens locked, txId:', txId);
|
|
2035
|
+
* ```
|
|
2036
|
+
*
|
|
2037
|
+
* @example Lock with expiration and custom authority
|
|
2038
|
+
* ```typescript
|
|
2039
|
+
* const txId = await sdk.lockToken({
|
|
2040
|
+
* tokenName: 'anime',
|
|
2041
|
+
* amount: '500',
|
|
2042
|
+
* lockAuthority: 'eth|OtherWalletAddress',
|
|
2043
|
+
* expires: Date.now() + 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
2044
|
+
* name: 'staking-lock-001'
|
|
2045
|
+
* });
|
|
2046
|
+
* ```
|
|
2047
|
+
*
|
|
2048
|
+
* @throws {TransferError} When token cannot be found or lock fails
|
|
2049
|
+
* @throws {ValidationError} When wallet is not configured
|
|
2050
|
+
*/
|
|
2051
|
+
lockToken(data: LockTokenData): Promise<string>;
|
|
2052
|
+
/**
|
|
2053
|
+
* Unlock previously locked tokens on GalaChain
|
|
2054
|
+
*
|
|
2055
|
+
* Releases a token hold, making the tokens available for transfer again.
|
|
2056
|
+
* Must be signed by the lock authority (the address that locked the tokens
|
|
2057
|
+
* or was designated as lock authority during the lock operation).
|
|
2058
|
+
*
|
|
2059
|
+
* @param data Unlock token parameters
|
|
2060
|
+
* @param data.tokenId Flexible token identifier (string, TokenClassKey, or TokenInstanceKey)
|
|
2061
|
+
* @param data.tokenName Token name for lookup (used if tokenId not provided)
|
|
2062
|
+
* @param data.amount Amount of tokens to unlock in decimal format
|
|
2063
|
+
* @param data.name Optional lock name to match (if used during lock)
|
|
2064
|
+
* @param data.uniqueKey Optional unique key for idempotency
|
|
2065
|
+
* @param data.privateKey Optional private key override for this operation
|
|
2066
|
+
* @returns Transaction ID of the unlock operation
|
|
2067
|
+
*
|
|
2068
|
+
* @example Unlock tokens
|
|
2069
|
+
* ```typescript
|
|
2070
|
+
* const txId = await sdk.unlockToken({
|
|
2071
|
+
* tokenName: 'anime',
|
|
2072
|
+
* amount: '1000'
|
|
2073
|
+
* });
|
|
2074
|
+
* console.log('Tokens unlocked, txId:', txId);
|
|
2075
|
+
* ```
|
|
2076
|
+
*
|
|
2077
|
+
* @example Unlock with lock name matching
|
|
2078
|
+
* ```typescript
|
|
2079
|
+
* const txId = await sdk.unlockToken({
|
|
2080
|
+
* tokenName: 'anime',
|
|
2081
|
+
* amount: '500',
|
|
2082
|
+
* name: 'staking-lock-001' // Match specific lock
|
|
2083
|
+
* });
|
|
2084
|
+
* ```
|
|
2085
|
+
*
|
|
2086
|
+
* @throws {TransferError} When token or lock cannot be found, or unlock fails
|
|
2087
|
+
* @throws {ValidationError} When wallet is not configured
|
|
2088
|
+
*/
|
|
2089
|
+
unlockToken(data: UnlockTokenData): Promise<string>;
|
|
1631
2090
|
/**
|
|
1632
2091
|
* Resolve vault address for a token name
|
|
1633
2092
|
*
|
|
@@ -1733,6 +2192,28 @@ export declare class LaunchpadSDK {
|
|
|
1733
2192
|
* Queries GalaSwap DEX for a quote when swapping from one token to another,
|
|
1734
2193
|
* specifying the exact amount you want to spend.
|
|
1735
2194
|
*
|
|
2195
|
+
* Current Implementation (v3.32.0):
|
|
2196
|
+
* - Delegates to GSwapService which uses GSwap SDK quoting engine
|
|
2197
|
+
* - Handles automatic token format conversion (symbols → TokenClassKey)
|
|
2198
|
+
* - Returns quote with estimated output, fee tier, and price impact
|
|
2199
|
+
* - Automatically selects optimal liquidity pool for best pricing
|
|
2200
|
+
*
|
|
2201
|
+
* Phase 2 Migration Plan:
|
|
2202
|
+
* This method will be migrated to eliminate GSwap SDK dependency by:
|
|
2203
|
+
* 1. Implementing quote calculation directly in BundlerService
|
|
2204
|
+
* 2. Fetching pool state directly from GalaChain (Slot0, liquidity, ticks)
|
|
2205
|
+
* 3. Implementing Uniswap V3 quote algorithm locally
|
|
2206
|
+
* 4. Adding intelligent route finding for multi-hop swaps
|
|
2207
|
+
* 5. Adding quote result caching for performance
|
|
2208
|
+
* 6. Maintaining backward-compatible API while removing SDK dependency
|
|
2209
|
+
*
|
|
2210
|
+
* Benefits of Phase 2 Migration:
|
|
2211
|
+
* - Eliminates external GSwap SDK dependency
|
|
2212
|
+
* - Enables offline quote calculations
|
|
2213
|
+
* - Adds quote caching for repeated queries
|
|
2214
|
+
* - Better control over quote accuracy and staleness
|
|
2215
|
+
* - Foundation for more advanced routing strategies
|
|
2216
|
+
*
|
|
1736
2217
|
* @category DEX Trading
|
|
1737
2218
|
* @param fromToken Source token symbol (e.g., "GALA", "GUSDC")
|
|
1738
2219
|
* @param toToken Destination token symbol (e.g., "GALA", "GUSDC")
|
|
@@ -1748,13 +2229,36 @@ export declare class LaunchpadSDK {
|
|
|
1748
2229
|
* console.log(`Price impact: ${quote.priceImpact}%`);
|
|
1749
2230
|
* ```
|
|
1750
2231
|
*/
|
|
1751
|
-
getSwapQuoteExactInput(fromToken: string, toToken: string, amount: string): Promise<import(".").SwapQuoteResult>;
|
|
2232
|
+
getSwapQuoteExactInput(fromToken: string, toToken: string, amount: string): Promise<import("./types/gswap.dto").SwapQuoteResult>;
|
|
1752
2233
|
/**
|
|
1753
2234
|
* Get a swap quote for exact output amount
|
|
1754
2235
|
*
|
|
1755
2236
|
* Queries GalaSwap DEX for a quote when swapping from one token to another,
|
|
1756
2237
|
* specifying the exact amount you want to receive.
|
|
1757
2238
|
*
|
|
2239
|
+
* Current Implementation (v3.32.0):
|
|
2240
|
+
* - Delegates to GSwapService which uses GSwap SDK quoting engine
|
|
2241
|
+
* - Calculates required input amount for exact output target
|
|
2242
|
+
* - Handles automatic token format conversion (symbols → TokenClassKey)
|
|
2243
|
+
* - Returns quote with required input, fee tier, and price impact
|
|
2244
|
+
* - Ensures amount constraints are satisfied with slippage buffer
|
|
2245
|
+
*
|
|
2246
|
+
* Phase 2 Migration Plan:
|
|
2247
|
+
* This method will be migrated to eliminate GSwap SDK dependency by:
|
|
2248
|
+
* 1. Implementing quote calculation directly in BundlerService
|
|
2249
|
+
* 2. Fetching pool state directly from GalaChain (Slot0, liquidity, ticks)
|
|
2250
|
+
* 3. Implementing reverse Uniswap V3 quote algorithm locally
|
|
2251
|
+
* 4. Adding intelligent route finding for multi-hop swaps
|
|
2252
|
+
* 5. Adding quote result caching for performance
|
|
2253
|
+
* 6. Maintaining backward-compatible API while removing SDK dependency
|
|
2254
|
+
*
|
|
2255
|
+
* Benefits of Phase 2 Migration:
|
|
2256
|
+
* - Eliminates external GSwap SDK dependency
|
|
2257
|
+
* - Enables offline quote calculations
|
|
2258
|
+
* - Adds quote caching for repeated queries
|
|
2259
|
+
* - Better control over quote accuracy and staleness
|
|
2260
|
+
* - Foundation for more advanced routing strategies
|
|
2261
|
+
*
|
|
1758
2262
|
* @category DEX Trading
|
|
1759
2263
|
* @param fromToken Source token symbol (e.g., "GALA", "GUSDC")
|
|
1760
2264
|
* @param toToken Destination token symbol (e.g., "GALA", "GUSDC")
|
|
@@ -1770,7 +2274,7 @@ export declare class LaunchpadSDK {
|
|
|
1770
2274
|
* console.log(`Price impact: ${quote.priceImpact}%`);
|
|
1771
2275
|
* ```
|
|
1772
2276
|
*/
|
|
1773
|
-
getSwapQuoteExactOutput(fromToken: string, toToken: string, amount: string): Promise<import(".").SwapQuoteResult>;
|
|
2277
|
+
getSwapQuoteExactOutput(fromToken: string, toToken: string, amount: string): Promise<import("./types/gswap.dto").SwapQuoteResult>;
|
|
1774
2278
|
/**
|
|
1775
2279
|
* Execute a token swap on GalaSwap DEX
|
|
1776
2280
|
*
|
|
@@ -1807,7 +2311,7 @@ export declare class LaunchpadSDK {
|
|
|
1807
2311
|
* console.log(`Transaction: ${result.transactionId}`);
|
|
1808
2312
|
* ```
|
|
1809
2313
|
*/
|
|
1810
|
-
executeSwap(fromToken: string, toToken: string, inputAmount: string, estimatedOutput: string, feeTier: number, slippageTolerance?: number): Promise<import(".").ExecuteSwapResult>;
|
|
2314
|
+
executeSwap(fromToken: string, toToken: string, inputAmount: string, estimatedOutput: string, feeTier: number, slippageTolerance?: number): Promise<import("./types/gswap.dto").ExecuteSwapResult>;
|
|
1811
2315
|
/**
|
|
1812
2316
|
* Get user's token assets/balances from GalaSwap
|
|
1813
2317
|
*
|
|
@@ -1826,7 +2330,12 @@ export declare class LaunchpadSDK {
|
|
|
1826
2330
|
* });
|
|
1827
2331
|
* ```
|
|
1828
2332
|
*/
|
|
1829
|
-
getSwapUserAssets(walletAddress: string): Promise<import(".").UserAsset[]>;
|
|
2333
|
+
getSwapUserAssets(walletAddress: string): Promise<import("./types/gswap.dto").UserAsset[]>;
|
|
2334
|
+
/**
|
|
2335
|
+
* Get all user assets across all pages (auto-paginated)
|
|
2336
|
+
* Automatically handles pagination to fetch all assets a user holds.
|
|
2337
|
+
*/
|
|
2338
|
+
getAllSwapUserAssets(walletAddress: string): Promise<import("./types/gswap.dto").UserAsset[]>;
|
|
1830
2339
|
/**
|
|
1831
2340
|
* Get pool information for a token pair
|
|
1832
2341
|
*
|
|
@@ -1846,34 +2355,133 @@ export declare class LaunchpadSDK {
|
|
|
1846
2355
|
* console.log(`Active swaps: ${poolInfo.swapCount}`);
|
|
1847
2356
|
* ```
|
|
1848
2357
|
*/
|
|
1849
|
-
getSwapPoolInfo(tokenA: string, tokenB: string): Promise<import(".").PoolInfo>;
|
|
2358
|
+
getSwapPoolInfo(tokenA: string, tokenB: string): Promise<import("./types/gswap.dto").PoolInfo>;
|
|
1850
2359
|
/**
|
|
1851
|
-
* Get
|
|
2360
|
+
* Get current market price for a DEX pool
|
|
2361
|
+
*
|
|
2362
|
+
* Fetches the current pool state (sqrtPrice and tick) from the GalaChain Gateway
|
|
2363
|
+
* and calculates the token1/token0 price ratio. This is useful for determining
|
|
2364
|
+
* the current price and whether a liquidity position is in-range.
|
|
2365
|
+
*
|
|
2366
|
+
* @category DEX Market Data
|
|
2367
|
+
* @since 3.31.0
|
|
2368
|
+
*
|
|
2369
|
+
* @param token0 - First token symbol (e.g., "GALA")
|
|
2370
|
+
* @param token1 - Second token symbol (e.g., "GUSDC")
|
|
2371
|
+
* @param fee - Fee tier in basis points (500, 3000, or 10000)
|
|
2372
|
+
* @returns PoolPriceData with current price, sqrtPrice, tick, and liquidity
|
|
1852
2373
|
*
|
|
1853
|
-
*
|
|
2374
|
+
* @example Get current pool price
|
|
2375
|
+
* ```typescript
|
|
2376
|
+
* const priceData = await sdk.getSwapPoolPrice('GALA', 'GUSDC', 3000);
|
|
2377
|
+
* console.log(`Current price: ${priceData.price} GUSDC per GALA`);
|
|
2378
|
+
* console.log(`Current tick: ${priceData.tick}`);
|
|
2379
|
+
* console.log(`Pool liquidity: ${priceData.liquidity}`);
|
|
2380
|
+
*
|
|
2381
|
+
* // Determine if position is in-range
|
|
2382
|
+
* const position = await sdk.getSwapLiquidityPositionById(ownerAddress, positionId);
|
|
2383
|
+
* const inRange = priceData.tick >= position.tickLower && priceData.tick <= position.tickUpper;
|
|
2384
|
+
* console.log(`Position in-range: ${inRange}`);
|
|
2385
|
+
* ```
|
|
2386
|
+
*/
|
|
2387
|
+
getSwapPoolPrice(token0: string, token1: string, fee: number): Promise<PoolPriceData>;
|
|
2388
|
+
/**
|
|
2389
|
+
* Get liquidity positions for a wallet (single page)
|
|
2390
|
+
*
|
|
2391
|
+
* Retrieves a single page of liquidity positions for the specified wallet address.
|
|
1854
2392
|
* Includes position details like token pair, liquidity amount, and accumulated fees.
|
|
2393
|
+
* Optionally fetches real-time pricing for each position's pool.
|
|
2394
|
+
*
|
|
2395
|
+
* For complete enumeration across all pages, use getAllSwapUserLiquidityPositions().
|
|
1855
2396
|
*
|
|
1856
2397
|
* @category DEX Liquidity Management
|
|
1857
2398
|
* @since 3.25.0
|
|
1858
2399
|
*
|
|
1859
2400
|
* @param ownerAddress - Wallet address (eth|0x... format or standard 0x...)
|
|
1860
|
-
* @param limit - Optional limit on number of positions to return
|
|
1861
|
-
* @param
|
|
1862
|
-
* @
|
|
2401
|
+
* @param limit - Optional limit on number of positions to return per page
|
|
2402
|
+
* @param bookmarkOrOptions - Optional pagination bookmark (deprecated) or options object
|
|
2403
|
+
* @param options - Optional options object with pricing configuration
|
|
2404
|
+
* @returns Object with items array (liquidity positions), optional nextBookmark for pagination, and optional prices map
|
|
1863
2405
|
*
|
|
1864
|
-
* @example Get
|
|
2406
|
+
* @example Get single page of positions
|
|
1865
2407
|
* ```typescript
|
|
1866
|
-
* const
|
|
1867
|
-
* console.log(`
|
|
1868
|
-
*
|
|
2408
|
+
* const result = await sdk.getSwapUserLiquidityPositions('eth|0x123...');
|
|
2409
|
+
* console.log(`Positions on page: ${result.items.length}`);
|
|
2410
|
+
* result.items.forEach(pos => {
|
|
1869
2411
|
* console.log(`Position ${pos.positionId}:`);
|
|
1870
2412
|
* console.log(` Tokens: ${pos.token0} / ${pos.token1}`);
|
|
1871
2413
|
* console.log(` Liquidity: ${pos.liquidity}`);
|
|
1872
2414
|
* console.log(` Fee0: ${pos.feeAmount0}, Fee1: ${pos.feeAmount1}`);
|
|
1873
2415
|
* });
|
|
2416
|
+
*
|
|
2417
|
+
* // Fetch next page if bookmark available
|
|
2418
|
+
* if (result.nextBookmark) {
|
|
2419
|
+
* const nextPage = await sdk.getSwapUserLiquidityPositions('eth|0x123...', undefined, result.nextBookmark);
|
|
2420
|
+
* }
|
|
2421
|
+
* ```
|
|
2422
|
+
*
|
|
2423
|
+
* @example Get positions with real-time pricing (5 concurrent requests)
|
|
2424
|
+
* ```typescript
|
|
2425
|
+
* const result = await sdk.getSwapUserLiquidityPositions('eth|0x123...', 10, { withPrices: true });
|
|
2426
|
+
* result.items.forEach(pos => {
|
|
2427
|
+
* const poolKey = `${pos.token0}|${pos.token1}|${pos.feeTier}`;
|
|
2428
|
+
* const price = result.prices?.get(poolKey);
|
|
2429
|
+
* if (price) {
|
|
2430
|
+
* console.log(`Current price: 1 ${pos.token0} = ${price.currentPrice} ${pos.token1}`);
|
|
2431
|
+
* }
|
|
2432
|
+
* });
|
|
1874
2433
|
* ```
|
|
1875
2434
|
*/
|
|
1876
|
-
getSwapUserLiquidityPositions(ownerAddress: string, limit?: number,
|
|
2435
|
+
getSwapUserLiquidityPositions(ownerAddress: string, limit?: number, bookmarkOrOptions?: string | GetLiquidityPositionsOptions, options?: GetLiquidityPositionsOptions): Promise<GetLiquidityPositionsResult>;
|
|
2436
|
+
/**
|
|
2437
|
+
* Get ALL user liquidity positions with automatic pagination
|
|
2438
|
+
*
|
|
2439
|
+
* Fetches all liquidity positions for a wallet across all pages automatically.
|
|
2440
|
+
* This is the recommended method for complete position enumeration.
|
|
2441
|
+
* Optionally fetches real-time pricing for each position's pool.
|
|
2442
|
+
*
|
|
2443
|
+
* @category DEX Liquidity Management
|
|
2444
|
+
* @since 3.31.3
|
|
2445
|
+
*
|
|
2446
|
+
* @param ownerAddress - User's wallet address
|
|
2447
|
+
* @param options - Optional options object with pricing configuration
|
|
2448
|
+
* @returns Array of all liquidity positions (auto-paginated) or result object with positions and pricing
|
|
2449
|
+
*
|
|
2450
|
+
* @example Get all positions automatically
|
|
2451
|
+
* ```typescript
|
|
2452
|
+
* const allPositions = await sdk.getAllSwapUserLiquidityPositions('eth|0x123...');
|
|
2453
|
+
* console.log(`Total positions: ${allPositions.length}`);
|
|
2454
|
+
* allPositions.forEach(pos => {
|
|
2455
|
+
* console.log(`Position ${pos.positionId}:`);
|
|
2456
|
+
* console.log(` Tokens: ${pos.token0} / ${pos.token1}`);
|
|
2457
|
+
* console.log(` Liquidity: ${pos.liquidity}`);
|
|
2458
|
+
* console.log(` Fees: ${pos.feeAmount0} ${pos.token0}, ${pos.feeAmount1} ${pos.token1}`);
|
|
2459
|
+
* });
|
|
2460
|
+
* ```
|
|
2461
|
+
*
|
|
2462
|
+
* @example Get all positions with real-time pricing (default 5 concurrent requests)
|
|
2463
|
+
* ```typescript
|
|
2464
|
+
* const result = await sdk.getAllSwapUserLiquidityPositions('eth|0x123...', { withPrices: true });
|
|
2465
|
+
* console.log(`Total positions: ${result.items.length}`);
|
|
2466
|
+
* result.items.forEach(pos => {
|
|
2467
|
+
* const poolKey = `${pos.token0}|${pos.token1}|${pos.feeTier}`;
|
|
2468
|
+
* const price = result.prices?.get(poolKey);
|
|
2469
|
+
* if (price) {
|
|
2470
|
+
* console.log(`Current price: 1 ${pos.token0} = ${price.currentPrice} ${pos.token1}`);
|
|
2471
|
+
* console.log(`Price Impact: ${price.priceImpact}%`);
|
|
2472
|
+
* }
|
|
2473
|
+
* });
|
|
2474
|
+
* ```
|
|
2475
|
+
*
|
|
2476
|
+
* @example Get all positions with custom concurrency (10 concurrent pricing requests)
|
|
2477
|
+
* ```typescript
|
|
2478
|
+
* const result = await sdk.getAllSwapUserLiquidityPositions('eth|0x123...', {
|
|
2479
|
+
* withPrices: true,
|
|
2480
|
+
* pricingConcurrency: 10 // Speed up pricing with more concurrent requests
|
|
2481
|
+
* });
|
|
2482
|
+
* ```
|
|
2483
|
+
*/
|
|
2484
|
+
getAllSwapUserLiquidityPositions(ownerAddress: string, options?: GetLiquidityPositionsOptions): Promise<GSwapPosition[] | GetLiquidityPositionsResult>;
|
|
1877
2485
|
/**
|
|
1878
2486
|
* Get specific liquidity position by token pair
|
|
1879
2487
|
*
|
|
@@ -1911,23 +2519,78 @@ export declare class LaunchpadSDK {
|
|
|
1911
2519
|
* Get liquidity position by position ID
|
|
1912
2520
|
*
|
|
1913
2521
|
* Retrieves a specific liquidity position by its unique identifier.
|
|
2522
|
+
* Optionally accepts token information for more efficient compound key lookups.
|
|
1914
2523
|
*
|
|
1915
2524
|
* @category DEX Liquidity Management
|
|
1916
2525
|
* @since 3.25.0
|
|
1917
2526
|
*
|
|
1918
2527
|
* @param ownerAddress - Wallet address
|
|
1919
2528
|
* @param positionId - Unique position identifier
|
|
2529
|
+
* @param token0 - Optional token0 for compound key lookup (improves lookup reliability)
|
|
2530
|
+
* @param token1 - Optional token1 for compound key lookup (improves lookup reliability)
|
|
2531
|
+
* @param feeTier - Optional fee tier for compound key lookup (improves lookup reliability)
|
|
2532
|
+
* @param tickLower - Optional lower tick boundary for compound key lookup
|
|
2533
|
+
* @param tickUpper - Optional upper tick boundary for compound key lookup
|
|
1920
2534
|
* @returns Liquidity position details
|
|
1921
2535
|
*
|
|
1922
|
-
* @example Get position by ID
|
|
2536
|
+
* @example Get position by ID with token information
|
|
1923
2537
|
* ```typescript
|
|
1924
2538
|
* const position = await sdk.getSwapLiquidityPositionById(
|
|
1925
2539
|
* 'eth|0x123...',
|
|
1926
|
-
* 'pos-abc123'
|
|
2540
|
+
* 'pos-abc123',
|
|
2541
|
+
* 'GALA',
|
|
2542
|
+
* 'GUSDC',
|
|
2543
|
+
* 3000,
|
|
2544
|
+
* -1080, // tickLower
|
|
2545
|
+
* 900 // tickUpper
|
|
1927
2546
|
* );
|
|
1928
2547
|
* ```
|
|
1929
2548
|
*/
|
|
1930
|
-
getSwapLiquidityPositionById(ownerAddress: string, positionId: string): Promise<import("./types/gswap.dto").LiquidityPosition>;
|
|
2549
|
+
getSwapLiquidityPositionById(ownerAddress: string, positionId: string, token0?: string | Record<string, any>, token1?: string | Record<string, any>, feeTier?: number, tickLower?: number, tickUpper?: number): Promise<import("./types/gswap.dto").LiquidityPosition>;
|
|
2550
|
+
/**
|
|
2551
|
+
* Fetch a single liquidity position using ONLY the compound key (most efficient)
|
|
2552
|
+
*
|
|
2553
|
+
* Makes a direct HTTP call to GalaChain Gateway using token0, token1, fee, and tick range.
|
|
2554
|
+
* This is the most efficient method when you already have all position parameters.
|
|
2555
|
+
*
|
|
2556
|
+
* @param params - Position lookup parameters (all required):
|
|
2557
|
+
* - token0: First token (e.g., "GALA" or "GALA|Unit|none|none")
|
|
2558
|
+
* - token1: Second token (e.g., "GUSDC" or "GUSDC|Unit|none|none")
|
|
2559
|
+
* - fee: Fee tier (500, 3000, or 10000 basis points)
|
|
2560
|
+
* - tickLower: Lower tick boundary
|
|
2561
|
+
* - tickUpper: Upper tick boundary
|
|
2562
|
+
* - owner: Wallet address (e.g., "eth|0x...")
|
|
2563
|
+
* @returns Detailed liquidity position information
|
|
2564
|
+
*
|
|
2565
|
+
* @example
|
|
2566
|
+
* ```typescript
|
|
2567
|
+
* const position = await sdk.fetchSwapPositionDirect({
|
|
2568
|
+
* token0: 'GALA',
|
|
2569
|
+
* token1: 'GUSDC',
|
|
2570
|
+
* fee: 3000,
|
|
2571
|
+
* tickLower: -26440,
|
|
2572
|
+
* tickUpper: -22390,
|
|
2573
|
+
* owner: 'eth|A278F228BB9Ea280C537763974FF1c1d427c85bb'
|
|
2574
|
+
* });
|
|
2575
|
+
* ```
|
|
2576
|
+
*
|
|
2577
|
+
* @category DEX Liquidity Queries
|
|
2578
|
+
* @since 3.35.0
|
|
2579
|
+
*
|
|
2580
|
+
* @remarks
|
|
2581
|
+
* - Single direct HTTP call (most efficient path)
|
|
2582
|
+
* - Does NOT require or accept positionId
|
|
2583
|
+
* - No GSwap SDK dependency
|
|
2584
|
+
* - All parameters are required
|
|
2585
|
+
*/
|
|
2586
|
+
fetchSwapPositionDirect(params: {
|
|
2587
|
+
token0: string;
|
|
2588
|
+
token1: string;
|
|
2589
|
+
fee: number;
|
|
2590
|
+
tickLower: number;
|
|
2591
|
+
tickUpper: number;
|
|
2592
|
+
owner: string;
|
|
2593
|
+
}): Promise<GSwapPosition>;
|
|
1931
2594
|
/**
|
|
1932
2595
|
* Estimate tokens to receive when removing liquidity
|
|
1933
2596
|
*
|
|
@@ -1961,7 +2624,7 @@ export declare class LaunchpadSDK {
|
|
|
1961
2624
|
liquidity: string;
|
|
1962
2625
|
tickLower: number;
|
|
1963
2626
|
tickUpper: number;
|
|
1964
|
-
}): Promise<
|
|
2627
|
+
}): Promise<import("./types/gswap-responses.types").GSwapEstimateRemoveLiquidityResult>;
|
|
1965
2628
|
/**
|
|
1966
2629
|
* Add liquidity using price range
|
|
1967
2630
|
*
|
|
@@ -1991,7 +2654,10 @@ export declare class LaunchpadSDK {
|
|
|
1991
2654
|
* console.log(`Position created: ${result.positionId}`);
|
|
1992
2655
|
* ```
|
|
1993
2656
|
*/
|
|
1994
|
-
addSwapLiquidityByPrice(args: any): Promise<
|
|
2657
|
+
addSwapLiquidityByPrice(args: any): Promise<import("./types/gswap-responses.types").GSwapAddLiquidityResult & {
|
|
2658
|
+
timestamp?: Date;
|
|
2659
|
+
wait?: (timeoutMs?: number) => Promise<void>;
|
|
2660
|
+
}>;
|
|
1995
2661
|
/**
|
|
1996
2662
|
* Add liquidity using tick range
|
|
1997
2663
|
*
|
|
@@ -2017,7 +2683,10 @@ export declare class LaunchpadSDK {
|
|
|
2017
2683
|
* });
|
|
2018
2684
|
* ```
|
|
2019
2685
|
*/
|
|
2020
|
-
addSwapLiquidityByTicks(args: any): Promise<
|
|
2686
|
+
addSwapLiquidityByTicks(args: any): Promise<import("./types/gswap-responses.types").GSwapAddLiquidityResult & {
|
|
2687
|
+
timestamp?: Date;
|
|
2688
|
+
wait?: (timeoutMs?: number) => Promise<void>;
|
|
2689
|
+
}>;
|
|
2021
2690
|
/**
|
|
2022
2691
|
* Remove liquidity from a position
|
|
2023
2692
|
*
|
|
@@ -2042,7 +2711,7 @@ export declare class LaunchpadSDK {
|
|
|
2042
2711
|
* });
|
|
2043
2712
|
* ```
|
|
2044
2713
|
*/
|
|
2045
|
-
removeSwapLiquidity(args: any): Promise<
|
|
2714
|
+
removeSwapLiquidity(args: any): Promise<import("./types/gswap-responses.types").GSwapAddLiquidityResult>;
|
|
2046
2715
|
/**
|
|
2047
2716
|
* Collect accumulated position fees
|
|
2048
2717
|
*
|
|
@@ -2064,7 +2733,7 @@ export declare class LaunchpadSDK {
|
|
|
2064
2733
|
* console.log(`Collected: ${result.amount0} token0, ${result.amount1} token1`);
|
|
2065
2734
|
* ```
|
|
2066
2735
|
*/
|
|
2067
|
-
collectSwapPositionFees(args: any): Promise<
|
|
2736
|
+
collectSwapPositionFees(args: any): Promise<import("./types/gswap-responses.types").GSwapAddLiquidityResult>;
|
|
2068
2737
|
/**
|
|
2069
2738
|
* Connect to WebSocket for real-time events
|
|
2070
2739
|
*
|
|
@@ -2257,6 +2926,633 @@ export declare class LaunchpadSDK {
|
|
|
2257
2926
|
intervalMs?: number;
|
|
2258
2927
|
creatorAddress?: string;
|
|
2259
2928
|
}): () => void;
|
|
2929
|
+
private static readonly TOKEN_CREATION_SOCKET_WAIT_ATTEMPTS;
|
|
2930
|
+
private static readonly TOKEN_CREATION_SOCKET_POLL_INTERVAL_MS;
|
|
2931
|
+
private static readonly DEX_POOL_SOCKET_WAIT_ATTEMPTS;
|
|
2932
|
+
private static readonly DEX_POOL_SOCKET_POLL_INTERVAL_MS;
|
|
2933
|
+
/**
|
|
2934
|
+
* Normalize fee tier to standard format (500, 3000, or 10000)
|
|
2935
|
+
*
|
|
2936
|
+
* Handles various fee formats: percentage strings ("0.3", "1"), basis points (500, 3000, 10000)
|
|
2937
|
+
*
|
|
2938
|
+
* @param value - Fee value in any format
|
|
2939
|
+
* @returns Normalized fee tier (500, 3000, 10000) or null if invalid
|
|
2940
|
+
* @private
|
|
2941
|
+
*/
|
|
2942
|
+
private normalizeFee;
|
|
2943
|
+
/**
|
|
2944
|
+
* Extract a field from an object with multiple possible key names
|
|
2945
|
+
*
|
|
2946
|
+
* @param obj - Object to search
|
|
2947
|
+
* @param keys - Possible key names to try in order
|
|
2948
|
+
* @returns Value of first matching key or empty string
|
|
2949
|
+
* @private
|
|
2950
|
+
*/
|
|
2951
|
+
private extractField;
|
|
2952
|
+
/**
|
|
2953
|
+
* Check if a string looks like a pool pair format
|
|
2954
|
+
*
|
|
2955
|
+
* Format: "token0/token1/fee" or full format with class keys
|
|
2956
|
+
*
|
|
2957
|
+
* @param value - Value to check
|
|
2958
|
+
* @returns Normalized pool pair string or null
|
|
2959
|
+
* @private
|
|
2960
|
+
*/
|
|
2961
|
+
private looksLikePoolPair;
|
|
2962
|
+
/**
|
|
2963
|
+
* Build pool pair from object with token and fee fields
|
|
2964
|
+
*
|
|
2965
|
+
* Tries multiple field name patterns to extract token0, token1, and fee
|
|
2966
|
+
*
|
|
2967
|
+
* @param obj - Object potentially containing pool data
|
|
2968
|
+
* @returns Pool pair string or null
|
|
2969
|
+
* @private
|
|
2970
|
+
*/
|
|
2971
|
+
private buildPoolPairFromObject;
|
|
2972
|
+
/**
|
|
2973
|
+
* Parse pool pair string into token0, token1, and fee
|
|
2974
|
+
*
|
|
2975
|
+
* Format: "token0ClassKey/token1ClassKey/feeTier"
|
|
2976
|
+
* Example: "GALA|Unit|none|none/GUSDC|Unit|none|none/10000"
|
|
2977
|
+
*
|
|
2978
|
+
* @param poolPairString - Pool pair string
|
|
2979
|
+
* @returns Pool data or null if invalid
|
|
2980
|
+
* @private
|
|
2981
|
+
*/
|
|
2982
|
+
private parsePoolPairString;
|
|
2983
|
+
/**
|
|
2984
|
+
* Serialize balance token object to classKey format
|
|
2985
|
+
* Used by buildPoolPairFromBalances to convert balance objects to token symbols
|
|
2986
|
+
*
|
|
2987
|
+
* Format: "collection|category|type|additionalKey"
|
|
2988
|
+
* Example: "GALA|Unit|none|none"
|
|
2989
|
+
*
|
|
2990
|
+
* @param balance - Balance object with collection, category, type fields
|
|
2991
|
+
* @returns Serialized token string or empty string if invalid
|
|
2992
|
+
* @private
|
|
2993
|
+
*/
|
|
2994
|
+
private serializeBalanceToken;
|
|
2995
|
+
/**
|
|
2996
|
+
* Build pool pair from balance delta objects
|
|
2997
|
+
* Handles extraction from swap and liquidity events that include balance changes
|
|
2998
|
+
*
|
|
2999
|
+
* Looks for:
|
|
3000
|
+
* - userBalanceDelta, balanceDelta, or delta objects
|
|
3001
|
+
* - token0Balance/token0/baseBalance/primaryBalance fields
|
|
3002
|
+
* - token1Balance/token1/quoteBalance/secondaryBalance fields
|
|
3003
|
+
* - Fee from poolFee, feeTier, fee, feeTierBps, or liquidityFeeBps
|
|
3004
|
+
*
|
|
3005
|
+
* @param obj - Object that may contain balance delta data
|
|
3006
|
+
* @returns Pool pair string or null if extraction failed
|
|
3007
|
+
* @private
|
|
3008
|
+
*/
|
|
3009
|
+
private buildPoolPairFromBalances;
|
|
3010
|
+
/**
|
|
3011
|
+
* Extract pool data from WebSocket event payload
|
|
3012
|
+
*
|
|
3013
|
+
* Tries multiple patterns in order to find pool data:
|
|
3014
|
+
* 1. Direct poolPair string
|
|
3015
|
+
* 2. Direct poolPair field
|
|
3016
|
+
* 3. Balance delta patterns (from swap/liquidity events) - CRITICAL for event detection
|
|
3017
|
+
* 4. Object fields (token0, token1, fee)
|
|
3018
|
+
* 5. Nested pool object
|
|
3019
|
+
*
|
|
3020
|
+
* Order matches reference implementation (newPoolsWatch.js) for maximum compatibility
|
|
3021
|
+
*
|
|
3022
|
+
* @param payload - WebSocket event payload
|
|
3023
|
+
* @returns Pool data or null if not found
|
|
3024
|
+
* @private
|
|
3025
|
+
*/
|
|
3026
|
+
private extractPoolDataFromPayload;
|
|
3027
|
+
/**
|
|
3028
|
+
* Check if a pool matches the optional filters
|
|
3029
|
+
*
|
|
3030
|
+
* Implements position-independent token matching:
|
|
3031
|
+
* - tokenFilter matches if token appears in EITHER position (token0 OR token1)
|
|
3032
|
+
* - pairTokens matches if BOTH tokens are present regardless of order
|
|
3033
|
+
* - feeTierFilter matches the fee tier
|
|
3034
|
+
*
|
|
3035
|
+
* @param pool - Pool data to check
|
|
3036
|
+
* @param options - Optional filters
|
|
3037
|
+
* @returns true if pool matches all specified filters
|
|
3038
|
+
* @private
|
|
3039
|
+
*/
|
|
3040
|
+
private matchesPoolFilter;
|
|
3041
|
+
/**
|
|
3042
|
+
* Check if a token creation event matches the optional creator filter
|
|
3043
|
+
*
|
|
3044
|
+
* Extracted for testability and maintainability.
|
|
3045
|
+
*
|
|
3046
|
+
* @param token - Token data from event
|
|
3047
|
+
* @param creatorFilter - Optional creator address filter
|
|
3048
|
+
* @returns true if token matches filter (or no filter specified)
|
|
3049
|
+
* @private
|
|
3050
|
+
*/
|
|
3051
|
+
private matchesCreatorFilter;
|
|
3052
|
+
/**
|
|
3053
|
+
* Subscribe to real-time token creation broadcasts
|
|
3054
|
+
*
|
|
3055
|
+
* Listens to WebSocket broadcasts for ALL token creations globally.
|
|
3056
|
+
* Provides real-time notifications with ~1-2 second latency (vs 15-30s polling).
|
|
3057
|
+
*
|
|
3058
|
+
* **Architecture:**
|
|
3059
|
+
* The backend broadcasts transaction confirmation events to ALL connected Socket.IO clients.
|
|
3060
|
+
* This listener captures "CreateSale" events which indicate token creation.
|
|
3061
|
+
*
|
|
3062
|
+
* **Key Difference from onLaunchpadTokenCreation():**
|
|
3063
|
+
* - `subscribeToTokenCreations()` - WebSocket broadcasts (instant, <2s latency)
|
|
3064
|
+
* - `onLaunchpadTokenCreation()` - REST API polling (slow, 15-30s latency)
|
|
3065
|
+
*
|
|
3066
|
+
* **Connection Management:**
|
|
3067
|
+
* - If WebSocket is already connected, listener is registered immediately
|
|
3068
|
+
* - If not connected, automatically initiates connection with 3-second timeout
|
|
3069
|
+
* - Connection failures are logged and can be handled via error callback
|
|
3070
|
+
*
|
|
3071
|
+
* **Cleanup Function:**
|
|
3072
|
+
* - Safe to call multiple times (idempotent)
|
|
3073
|
+
* - Removes listener and cleans up tracking state
|
|
3074
|
+
* - Returns immediately if listener was never registered
|
|
3075
|
+
*
|
|
3076
|
+
* @param callback - Called when any token is created
|
|
3077
|
+
* @param options - Optional filtering and error handling
|
|
3078
|
+
* @param options.creatorFilter - Only receive tokens from specific creator address
|
|
3079
|
+
* @param options.onError - Called if WebSocket connection fails
|
|
3080
|
+
* @returns Cleanup function to stop listening - safe to call multiple times
|
|
3081
|
+
*
|
|
3082
|
+
* @category Real-time Monitoring
|
|
3083
|
+
* @since 4.1.0
|
|
3084
|
+
*
|
|
3085
|
+
* @throws Error if WebSocket service not initialized
|
|
3086
|
+
*
|
|
3087
|
+
* @example Basic usage - listen to all token creations
|
|
3088
|
+
* ```typescript
|
|
3089
|
+
* const cleanup = sdk.subscribeToTokenCreations((token) => {
|
|
3090
|
+
* console.log(`Token created: ${token.tokenName} by ${token.creatorAddress}`);
|
|
3091
|
+
* });
|
|
3092
|
+
*
|
|
3093
|
+
* // Stop listening when done
|
|
3094
|
+
* cleanup();
|
|
3095
|
+
* ```
|
|
3096
|
+
*
|
|
3097
|
+
* @example Filter to specific creator
|
|
3098
|
+
* ```typescript
|
|
3099
|
+
* const cleanup = sdk.subscribeToTokenCreations(
|
|
3100
|
+
* (token) => console.log(`My token: ${token.tokenName}`),
|
|
3101
|
+
* {
|
|
3102
|
+
* creatorFilter: sdk.getAddress(),
|
|
3103
|
+
* onError: (error) => console.error('Connection failed:', error)
|
|
3104
|
+
* }
|
|
3105
|
+
* );
|
|
3106
|
+
* ```
|
|
3107
|
+
*
|
|
3108
|
+
* @example Monitor for competitor tokens with error handling
|
|
3109
|
+
* ```typescript
|
|
3110
|
+
* const cleanup = sdk.subscribeToTokenCreations(
|
|
3111
|
+
* (token) => {
|
|
3112
|
+
* console.log(`New token: ${token.tokenName} - ${token.symbol}`);
|
|
3113
|
+
* // Could trigger automatic buy/analysis
|
|
3114
|
+
* },
|
|
3115
|
+
* {
|
|
3116
|
+
* onError: (error) => {
|
|
3117
|
+
* console.error('Real-time monitoring failed:', error);
|
|
3118
|
+
* // Fallback to polling
|
|
3119
|
+
* }
|
|
3120
|
+
* }
|
|
3121
|
+
* );
|
|
3122
|
+
* ```
|
|
3123
|
+
*/
|
|
3124
|
+
subscribeToTokenCreations(callback: (token: {
|
|
3125
|
+
tokenName: string;
|
|
3126
|
+
symbol: string;
|
|
3127
|
+
creatorAddress: string;
|
|
3128
|
+
description: string;
|
|
3129
|
+
image: string;
|
|
3130
|
+
vaultAddress: string;
|
|
3131
|
+
tokenStringKey: string;
|
|
3132
|
+
preBuyQuantity: string;
|
|
3133
|
+
websiteUrl: string;
|
|
3134
|
+
telegramUrl: string;
|
|
3135
|
+
twitterUrl: string;
|
|
3136
|
+
isFinalized: boolean;
|
|
3137
|
+
}) => void, options?: {
|
|
3138
|
+
creatorFilter?: string;
|
|
3139
|
+
onError?: (error: Error) => void;
|
|
3140
|
+
}): () => void;
|
|
3141
|
+
/**
|
|
3142
|
+
* Recursively walk WebSocket event payload to find all pools
|
|
3143
|
+
*
|
|
3144
|
+
* Exhaustively searches through entire payload tree, including nested objects.
|
|
3145
|
+
* Matches reference implementation (newPoolsWatch.js walkPayload) for complete event coverage.
|
|
3146
|
+
*
|
|
3147
|
+
* Uses WeakSet to track visited objects and prevent infinite loops on circular references.
|
|
3148
|
+
* Deduplicates pools using the provided seenPools Set.
|
|
3149
|
+
*
|
|
3150
|
+
* @param payload - Event payload to walk (can be string, object, or any value)
|
|
3151
|
+
* @param seenPools - Set of already-seen pool pair strings (for deduplication)
|
|
3152
|
+
* @param visited - WeakSet of visited objects (to prevent circular reference loops)
|
|
3153
|
+
* @returns Array of newly discovered pool data objects
|
|
3154
|
+
* @private
|
|
3155
|
+
*/
|
|
3156
|
+
private walkPayloadForPools;
|
|
3157
|
+
/**
|
|
3158
|
+
* Subscribe to real-time DEX pool creation broadcasts
|
|
3159
|
+
*
|
|
3160
|
+
* Listens to WebSocket broadcasts for DEX pool creation events globally.
|
|
3161
|
+
* Provides real-time notifications when new liquidity pools are added (~1-2 second latency).
|
|
3162
|
+
*
|
|
3163
|
+
* **Use Case:**
|
|
3164
|
+
* Monitor for graduated tokens becoming swappable on the DEX. When a token graduates from
|
|
3165
|
+
* bonding curve to DEX, a pool is created and this subscription notifies in real-time.
|
|
3166
|
+
*
|
|
3167
|
+
* **Position-Independent Token Matching:**
|
|
3168
|
+
* Token filters work regardless of position (token0 vs token1):
|
|
3169
|
+
* - `tokenFilter: 'GALA'` matches both GALA/USDC and USDC/GALA pools
|
|
3170
|
+
* - `pairTokens: ['GALA', 'USDC']` matches the specific pair in any order
|
|
3171
|
+
*
|
|
3172
|
+
* **Connection Management:**
|
|
3173
|
+
* - If WebSocket is already connected, listener is registered immediately
|
|
3174
|
+
* - If not connected, automatically initiates connection with 3-second timeout
|
|
3175
|
+
* - Connection failures are logged and can be handled via error callback
|
|
3176
|
+
*
|
|
3177
|
+
* **Cleanup Function:**
|
|
3178
|
+
* - Safe to call multiple times (idempotent)
|
|
3179
|
+
* - Removes listener and cleans up tracking state
|
|
3180
|
+
* - Returns immediately if listener was never registered
|
|
3181
|
+
*
|
|
3182
|
+
* @param callback - Called when a new DEX pool is created
|
|
3183
|
+
* @param options - Optional filtering and error handling
|
|
3184
|
+
* @param options.tokenFilter - Only receive pools containing this token (in either position)
|
|
3185
|
+
* @param options.pairTokens - Only receive pools with this specific token pair (order-independent)
|
|
3186
|
+
* @param options.feeTierFilter - Only receive pools with this fee tier (500, 3000, or 10000)
|
|
3187
|
+
* @param options.onError - Called if WebSocket connection fails
|
|
3188
|
+
* @returns Cleanup function to stop listening - safe to call multiple times
|
|
3189
|
+
*
|
|
3190
|
+
* @category Real-time Monitoring
|
|
3191
|
+
* @since 4.1.0
|
|
3192
|
+
*
|
|
3193
|
+
* @throws Error if WebSocket service not initialized
|
|
3194
|
+
*
|
|
3195
|
+
* @example Listen to all new pools
|
|
3196
|
+
* ```typescript
|
|
3197
|
+
* const cleanup = sdk.subscribeToDexPoolAdded((pool) => {
|
|
3198
|
+
* console.log(`New pool: ${pool.token0}/${pool.token1} (${pool.fee}% fee)`);
|
|
3199
|
+
* });
|
|
3200
|
+
*
|
|
3201
|
+
* // Stop listening when done
|
|
3202
|
+
* cleanup();
|
|
3203
|
+
* ```
|
|
3204
|
+
*
|
|
3205
|
+
* @example Listen for GALA pools only
|
|
3206
|
+
* ```typescript
|
|
3207
|
+
* const cleanup = sdk.subscribeToDexPoolAdded(
|
|
3208
|
+
* (pool) => {
|
|
3209
|
+
* if (pool.token0 === 'GALA' || pool.token1 === 'GALA') {
|
|
3210
|
+
* console.log(`GALA pool created: ${pool.poolPair}`);
|
|
3211
|
+
* }
|
|
3212
|
+
* },
|
|
3213
|
+
* { tokenFilter: 'GALA' }
|
|
3214
|
+
* );
|
|
3215
|
+
* ```
|
|
3216
|
+
*
|
|
3217
|
+
* @example Monitor specific pair with fee tier
|
|
3218
|
+
* ```typescript
|
|
3219
|
+
* const cleanup = sdk.subscribeToDexPoolAdded(
|
|
3220
|
+
* (pool) => {
|
|
3221
|
+
* console.log(`GALA/GUSDC 0.3% pool created!`);
|
|
3222
|
+
* },
|
|
3223
|
+
* {
|
|
3224
|
+
* pairTokens: ['GALA', 'GUSDC'],
|
|
3225
|
+
* feeTierFilter: 3000, // 0.3%
|
|
3226
|
+
* onError: (error) => console.error('Connection failed:', error)
|
|
3227
|
+
* }
|
|
3228
|
+
* );
|
|
3229
|
+
* ```
|
|
3230
|
+
*
|
|
3231
|
+
* @example Monitor graduated tokens (all pools, real-time)
|
|
3232
|
+
* ```typescript
|
|
3233
|
+
* // Watch for ANY new pools - indicates graduated tokens
|
|
3234
|
+
* const cleanup = sdk.subscribeToDexPoolAdded(
|
|
3235
|
+
* (pool) => {
|
|
3236
|
+
* console.log(`Graduated token detected: ${pool.token0}/${pool.token1}`);
|
|
3237
|
+
* // Could trigger automatic trading strategies
|
|
3238
|
+
* }
|
|
3239
|
+
* );
|
|
3240
|
+
* ```
|
|
3241
|
+
*/
|
|
3242
|
+
subscribeToDexPoolAdded(callback: (pool: {
|
|
3243
|
+
token0: string;
|
|
3244
|
+
token1: string;
|
|
3245
|
+
fee: string;
|
|
3246
|
+
poolPair: string;
|
|
3247
|
+
}) => void, options?: {
|
|
3248
|
+
tokenFilter?: string;
|
|
3249
|
+
pairTokens?: [string, string];
|
|
3250
|
+
feeTierFilter?: string | number;
|
|
3251
|
+
onError?: (error: Error) => void;
|
|
3252
|
+
}): () => void;
|
|
3253
|
+
/**
|
|
3254
|
+
* Subscribe to real-time DEX swap execution events
|
|
3255
|
+
*
|
|
3256
|
+
* Monitors all completed swaps on the DEX globally with real-time notifications (~1-2 second latency).
|
|
3257
|
+
* Provides offline price predictions and delta-based pool state updates for arbitrage bot use cases.
|
|
3258
|
+
*
|
|
3259
|
+
* **Architecture:**
|
|
3260
|
+
* The backend broadcasts transaction confirmation events for completed swaps to ALL connected clients.
|
|
3261
|
+
* This listener captures "ExecuteSwap" events and provides:
|
|
3262
|
+
* - Real-time swap transaction data (tokens, amounts, fees)
|
|
3263
|
+
* - Offline price quotes using cached pool state (~25-50ms vs network requests)
|
|
3264
|
+
* - Delta-based pool updates (~15-25ms vs full refetch ~200-400ms)
|
|
3265
|
+
* - Performance metrics (latency percentiles, cache hit rates, throughput)
|
|
3266
|
+
*
|
|
3267
|
+
* **Position-Independent Token Matching:**
|
|
3268
|
+
* Token filters work regardless of position (token0 vs token1):
|
|
3269
|
+
* - `tokenFilter: 'GALA'` matches both GALA/USDC and USDC/GALA swaps
|
|
3270
|
+
* - `pairTokens: ['GALA', 'USDC']` matches the specific pair in any order
|
|
3271
|
+
*
|
|
3272
|
+
* **Connection Management:**
|
|
3273
|
+
* - If WebSocket is already connected, listener is registered immediately
|
|
3274
|
+
* - If not connected, automatically initiates connection with 3-second timeout
|
|
3275
|
+
* - Connection failures are logged and can be handled via error callback
|
|
3276
|
+
*
|
|
3277
|
+
* **Cleanup Function:**
|
|
3278
|
+
* - Safe to call multiple times (idempotent)
|
|
3279
|
+
* - Removes listener and cleans up tracking state
|
|
3280
|
+
* - Returns immediately if listener was never registered
|
|
3281
|
+
*
|
|
3282
|
+
* @param callback - Called when a swap completes with enriched swap data
|
|
3283
|
+
* @param options - Optional filtering, configuration, and error handling
|
|
3284
|
+
* @param options.tokenFilter - Only receive swaps containing this token (in either position)
|
|
3285
|
+
* @param options.pairTokens - Only receive swaps with this specific token pair (order-independent)
|
|
3286
|
+
* @param options.feeTierFilter - Only receive swaps with this fee tier (500, 3000, or 10000)
|
|
3287
|
+
* @param options.userFilter - Only receive swaps from this wallet address
|
|
3288
|
+
* @param options.memoryProfile - Cache memory profile: 'conservative' (55MB), 'moderate' (250MB), 'aggressive' (530MB)
|
|
3289
|
+
* @param options.maxPools - Maximum pools to cache (default: 500)
|
|
3290
|
+
* @param options.enableDeltaOptimization - Use delta updates instead of full refetch (default: true)
|
|
3291
|
+
* @param options.enableOfflineQuotes - Calculate offline quotes for known pools (default: true)
|
|
3292
|
+
* @param options.debug - Enable debug logging (default: false)
|
|
3293
|
+
* @param options.onError - Called if WebSocket connection fails
|
|
3294
|
+
* @returns Cleanup function to stop listening - safe to call multiple times
|
|
3295
|
+
*
|
|
3296
|
+
* @category Real-time Monitoring
|
|
3297
|
+
* @since 4.2.0
|
|
3298
|
+
*
|
|
3299
|
+
* @throws Error if WebSocket service not initialized
|
|
3300
|
+
*
|
|
3301
|
+
* @example Listen to all swaps globally
|
|
3302
|
+
* ```typescript
|
|
3303
|
+
* const cleanup = sdk.subscribeToDexSwapExecuted((swap) => {
|
|
3304
|
+
* console.log(`Swap: ${swap.token0} → ${swap.token1}`);
|
|
3305
|
+
* console.log(`Amount: ${swap.amount0} / ${swap.amount1}`);
|
|
3306
|
+
* if (swap.estimatedPrice) {
|
|
3307
|
+
* console.log(`Price: ${swap.estimatedPrice}`);
|
|
3308
|
+
* }
|
|
3309
|
+
* });
|
|
3310
|
+
*
|
|
3311
|
+
* // Stop listening when done
|
|
3312
|
+
* cleanup();
|
|
3313
|
+
* ```
|
|
3314
|
+
*
|
|
3315
|
+
* @example Arbitrage bot - monitor GALA/GUSDC swaps with offline pricing
|
|
3316
|
+
* ```typescript
|
|
3317
|
+
* const cleanup = sdk.subscribeToDexSwapExecuted(
|
|
3318
|
+
* async (swap) => {
|
|
3319
|
+
* if (swap.estimatedPrice && swap.poolStateUpdated) {
|
|
3320
|
+
* // Price calculated instantly using cached pool state
|
|
3321
|
+
* console.log(`Arbitrage opportunity: ${swap.estimatedPrice}`);
|
|
3322
|
+
*
|
|
3323
|
+
* // Trigger trading logic
|
|
3324
|
+
* await executeArbitrageStrategy(swap);
|
|
3325
|
+
* }
|
|
3326
|
+
* },
|
|
3327
|
+
* {
|
|
3328
|
+
* pairTokens: ['GALA', 'GUSDC'],
|
|
3329
|
+
* memoryProfile: 'aggressive', // Max cache for arbitrage
|
|
3330
|
+
* enableDeltaOptimization: true, // Fast updates
|
|
3331
|
+
* enableOfflineQuotes: true, // Instant pricing
|
|
3332
|
+
* onError: (error) => console.error('Swap monitoring failed:', error)
|
|
3333
|
+
* }
|
|
3334
|
+
* );
|
|
3335
|
+
* ```
|
|
3336
|
+
*
|
|
3337
|
+
* @example Monitor specific token with fee tier
|
|
3338
|
+
* ```typescript
|
|
3339
|
+
* const cleanup = sdk.subscribeToDexSwapExecuted(
|
|
3340
|
+
* (swap) => {
|
|
3341
|
+
* console.log(`GALA 0.3% pool swap: ${swap.amount0}`);
|
|
3342
|
+
* },
|
|
3343
|
+
* {
|
|
3344
|
+
* tokenFilter: 'GALA',
|
|
3345
|
+
* feeTierFilter: 3000, // 0.3% fee tier
|
|
3346
|
+
* }
|
|
3347
|
+
* );
|
|
3348
|
+
* ```
|
|
3349
|
+
*
|
|
3350
|
+
* @example Health monitoring for swap monitoring system
|
|
3351
|
+
* ```typescript
|
|
3352
|
+
* let swapMonitor: MultiPoolStateManager | null = null;
|
|
3353
|
+
*
|
|
3354
|
+
* const cleanup = sdk.subscribeToDexSwapExecuted(
|
|
3355
|
+
* (swap) => {
|
|
3356
|
+
* console.log(`Swap processed in <50ms:`, swap.poolStateUpdated);
|
|
3357
|
+
* },
|
|
3358
|
+
* {
|
|
3359
|
+
* memoryProfile: 'moderate',
|
|
3360
|
+
* onError: (error) => console.error('Connection failed:', error)
|
|
3361
|
+
* }
|
|
3362
|
+
* );
|
|
3363
|
+
*
|
|
3364
|
+
* // Can get health metrics
|
|
3365
|
+
* // const health = swapMonitor?.getHealth();
|
|
3366
|
+
* // console.log(`Cache hit rate: ${health.metrics.cacheHitRate}%`);
|
|
3367
|
+
* ```
|
|
3368
|
+
*/
|
|
3369
|
+
subscribeToDexSwapExecuted(callback: SwapEventCallback, options?: SubscribeSwapOptions & SwapMonitorConfig): CleanupFunction;
|
|
3370
|
+
/**
|
|
3371
|
+
* Subscribe to real-time DEX liquidity addition events
|
|
3372
|
+
*
|
|
3373
|
+
* Monitors all liquidity additions on the DEX globally with real-time notifications.
|
|
3374
|
+
* All liquidity events are broadcast to all connected clients - you can monitor
|
|
3375
|
+
* market-wide liquidity activity, not just your own transactions.
|
|
3376
|
+
*
|
|
3377
|
+
* **Use Cases:**
|
|
3378
|
+
* - LP position tracking: Monitor when users add liquidity to positions
|
|
3379
|
+
* - Whale watching: Detect large liquidity additions
|
|
3380
|
+
* - Market analysis: Track overall DEX liquidity growth
|
|
3381
|
+
* - Position management: React to liquidity changes in pools you care about
|
|
3382
|
+
*
|
|
3383
|
+
* **Position-Independent Token Matching:**
|
|
3384
|
+
* Token filters work regardless of position (token0 vs token1):
|
|
3385
|
+
* - `tokenFilter: 'GALA'` matches liquidity additions to any GALA pool
|
|
3386
|
+
* - `pairTokens: ['GALA', 'GUSDC']` matches the specific pair in any order
|
|
3387
|
+
*
|
|
3388
|
+
* @param callback - Called when liquidity is added with event data
|
|
3389
|
+
* @param options - Optional filtering and error handling
|
|
3390
|
+
* @param options.positionId - Only receive events for this LP position NFT
|
|
3391
|
+
* @param options.poolHash - Only receive events for this pool
|
|
3392
|
+
* @param options.tokenFilter - Only receive events containing this token (in either position)
|
|
3393
|
+
* @param options.pairTokens - Only receive events with this specific token pair (order-independent)
|
|
3394
|
+
* @param options.feeTierFilter - Only receive events with this fee tier (500, 3000, or 10000)
|
|
3395
|
+
* @param options.userFilter - Only receive events from this wallet address
|
|
3396
|
+
* @param options.minAmount - Only receive events where at least one amount exceeds this value
|
|
3397
|
+
* @param options.onError - Called if WebSocket connection fails
|
|
3398
|
+
* @returns Cleanup function to stop listening - safe to call multiple times
|
|
3399
|
+
*
|
|
3400
|
+
* @category Real-time Monitoring
|
|
3401
|
+
* @since 4.3.0
|
|
3402
|
+
*
|
|
3403
|
+
* @throws Error if WebSocket service not initialized
|
|
3404
|
+
*
|
|
3405
|
+
* @example Listen to all liquidity additions
|
|
3406
|
+
* ```typescript
|
|
3407
|
+
* const cleanup = sdk.subscribeToDexLiquidityAdded((event) => {
|
|
3408
|
+
* console.log(`Liquidity added: ${event.amounts[0]} / ${event.amounts[1]}`);
|
|
3409
|
+
* console.log(`Position: ${event.positionId}`);
|
|
3410
|
+
* console.log(`Pool: ${event.poolHash}`);
|
|
3411
|
+
* });
|
|
3412
|
+
*
|
|
3413
|
+
* // Stop listening when done
|
|
3414
|
+
* await cleanup();
|
|
3415
|
+
* ```
|
|
3416
|
+
*
|
|
3417
|
+
* @example Track specific pool liquidity
|
|
3418
|
+
* ```typescript
|
|
3419
|
+
* const cleanup = sdk.subscribeToDexLiquidityAdded(
|
|
3420
|
+
* (event) => {
|
|
3421
|
+
* console.log(`GALA/GUSDC liquidity: +${event.amounts[0]} GALA`);
|
|
3422
|
+
* },
|
|
3423
|
+
* {
|
|
3424
|
+
* pairTokens: ['GALA', 'GUSDC'],
|
|
3425
|
+
* feeTierFilter: 3000, // 0.3% fee tier
|
|
3426
|
+
* }
|
|
3427
|
+
* );
|
|
3428
|
+
* ```
|
|
3429
|
+
*
|
|
3430
|
+
* @example Whale watching
|
|
3431
|
+
* ```typescript
|
|
3432
|
+
* const cleanup = sdk.subscribeToDexLiquidityAdded(
|
|
3433
|
+
* (event) => {
|
|
3434
|
+
* console.log(`🐋 Large liquidity add detected!`);
|
|
3435
|
+
* console.log(`Amount: ${event.amounts[0]} / ${event.amounts[1]}`);
|
|
3436
|
+
* console.log(`User: ${event.userAddress}`);
|
|
3437
|
+
* },
|
|
3438
|
+
* { minAmount: '10000' } // Only large additions
|
|
3439
|
+
* );
|
|
3440
|
+
* ```
|
|
3441
|
+
*/
|
|
3442
|
+
subscribeToDexLiquidityAdded(callback: LiquidityChangedCallback, options?: SubscribeLiquidityOptions): LiquidityCleanupFunction;
|
|
3443
|
+
/**
|
|
3444
|
+
* Subscribe to real-time DEX liquidity removal events
|
|
3445
|
+
*
|
|
3446
|
+
* Monitors all liquidity removals on the DEX globally with real-time notifications.
|
|
3447
|
+
* All liquidity events are broadcast to all connected clients - you can monitor
|
|
3448
|
+
* market-wide liquidity activity, not just your own transactions.
|
|
3449
|
+
*
|
|
3450
|
+
* **Use Cases:**
|
|
3451
|
+
* - LP exit tracking: Monitor when users remove liquidity from positions
|
|
3452
|
+
* - Whale watching: Detect large liquidity withdrawals
|
|
3453
|
+
* - Market analysis: Track overall DEX liquidity changes
|
|
3454
|
+
* - Risk management: React to liquidity decreases in pools you trade
|
|
3455
|
+
*
|
|
3456
|
+
* @param callback - Called when liquidity is removed with event data
|
|
3457
|
+
* @param options - Optional filtering and error handling
|
|
3458
|
+
* @param options.positionId - Only receive events for this LP position NFT
|
|
3459
|
+
* @param options.poolHash - Only receive events for this pool
|
|
3460
|
+
* @param options.tokenFilter - Only receive events containing this token (in either position)
|
|
3461
|
+
* @param options.pairTokens - Only receive events with this specific token pair (order-independent)
|
|
3462
|
+
* @param options.feeTierFilter - Only receive events with this fee tier (500, 3000, or 10000)
|
|
3463
|
+
* @param options.userFilter - Only receive events from this wallet address
|
|
3464
|
+
* @param options.minAmount - Only receive events where at least one amount exceeds this value
|
|
3465
|
+
* @param options.onError - Called if WebSocket connection fails
|
|
3466
|
+
* @returns Cleanup function to stop listening - safe to call multiple times
|
|
3467
|
+
*
|
|
3468
|
+
* @category Real-time Monitoring
|
|
3469
|
+
* @since 4.3.0
|
|
3470
|
+
*
|
|
3471
|
+
* @throws Error if WebSocket service not initialized
|
|
3472
|
+
*
|
|
3473
|
+
* @example Listen to all liquidity removals
|
|
3474
|
+
* ```typescript
|
|
3475
|
+
* const cleanup = sdk.subscribeToDexLiquidityRemoved((event) => {
|
|
3476
|
+
* console.log(`Liquidity removed: ${event.amounts[0]} / ${event.amounts[1]}`);
|
|
3477
|
+
* console.log(`Position: ${event.positionId}`);
|
|
3478
|
+
* });
|
|
3479
|
+
*
|
|
3480
|
+
* await cleanup();
|
|
3481
|
+
* ```
|
|
3482
|
+
*
|
|
3483
|
+
* @example Track position exits
|
|
3484
|
+
* ```typescript
|
|
3485
|
+
* const cleanup = sdk.subscribeToDexLiquidityRemoved(
|
|
3486
|
+
* (event) => {
|
|
3487
|
+
* console.log(`Position ${event.positionId} reduced liquidity`);
|
|
3488
|
+
* },
|
|
3489
|
+
* { positionId: 'my-position-id' }
|
|
3490
|
+
* );
|
|
3491
|
+
* ```
|
|
3492
|
+
*/
|
|
3493
|
+
subscribeToDexLiquidityRemoved(callback: LiquidityChangedCallback, options?: SubscribeLiquidityOptions): LiquidityCleanupFunction;
|
|
3494
|
+
/**
|
|
3495
|
+
* Subscribe to all DEX liquidity changes
|
|
3496
|
+
*
|
|
3497
|
+
* Monitors all liquidity operations on the DEX globally with real-time notifications.
|
|
3498
|
+
* The backend broadcasts position change events without distinguishing between
|
|
3499
|
+
* add and remove operations.
|
|
3500
|
+
*
|
|
3501
|
+
* **Use Cases:**
|
|
3502
|
+
* - Complete liquidity tracking: Monitor all LP activity in a pool
|
|
3503
|
+
* - Position monitoring: Track changes to specific positions
|
|
3504
|
+
* - Dashboard displays: Show real-time liquidity activity feed
|
|
3505
|
+
*
|
|
3506
|
+
* @param callback - Called when liquidity changes with event data
|
|
3507
|
+
* @param options - Optional filtering and error handling
|
|
3508
|
+
* @returns Cleanup function to stop listening - safe to call multiple times
|
|
3509
|
+
*
|
|
3510
|
+
* @category Real-time Monitoring
|
|
3511
|
+
* @since 4.3.0
|
|
3512
|
+
*
|
|
3513
|
+
* @throws Error if WebSocket service not initialized
|
|
3514
|
+
*
|
|
3515
|
+
* @example Monitor all liquidity activity
|
|
3516
|
+
* ```typescript
|
|
3517
|
+
* const cleanup = sdk.subscribeToDexLiquidityChanged((event) => {
|
|
3518
|
+
* console.log(`Liquidity changed: ${event.amounts[0]} / ${event.amounts[1]}`);
|
|
3519
|
+
* console.log(`Pool: ${event.poolHash}`);
|
|
3520
|
+
* console.log(`Position: ${event.positionId}`);
|
|
3521
|
+
* });
|
|
3522
|
+
*
|
|
3523
|
+
* await cleanup();
|
|
3524
|
+
* ```
|
|
3525
|
+
*
|
|
3526
|
+
* @example Track specific pool liquidity
|
|
3527
|
+
* ```typescript
|
|
3528
|
+
* const cleanup = sdk.subscribeToDexLiquidityChanged(
|
|
3529
|
+
* (event) => {
|
|
3530
|
+
* console.log(`Pool activity: ${event.amounts[0]} / ${event.amounts[1]}`);
|
|
3531
|
+
* console.log(`User: ${event.userAddress}`);
|
|
3532
|
+
* },
|
|
3533
|
+
* { pairTokens: ['GALA', 'GUSDC'] }
|
|
3534
|
+
* );
|
|
3535
|
+
* ```
|
|
3536
|
+
*/
|
|
3537
|
+
subscribeToDexLiquidityChanged(callback: LiquidityChangedCallback, options?: SubscribeLiquidityOptions): LiquidityCleanupFunction;
|
|
3538
|
+
/**
|
|
3539
|
+
* Internal method for subscribing to liquidity events
|
|
3540
|
+
*
|
|
3541
|
+
* @internal
|
|
3542
|
+
*/
|
|
3543
|
+
private subscribeToDexLiquidityEvents;
|
|
3544
|
+
/**
|
|
3545
|
+
* Check if a liquidity event matches the specified filters
|
|
3546
|
+
*
|
|
3547
|
+
* @internal
|
|
3548
|
+
*/
|
|
3549
|
+
private matchesLiquidityFilter;
|
|
3550
|
+
/**
|
|
3551
|
+
* Normalize fee tier to basis points
|
|
3552
|
+
*
|
|
3553
|
+
* @internal
|
|
3554
|
+
*/
|
|
3555
|
+
private normalizeFeeTier;
|
|
2260
3556
|
/**
|
|
2261
3557
|
* Cleanup SDK resources and connections
|
|
2262
3558
|
*
|