@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
package/README.md
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
A comprehensive TypeScript SDK for the Gala Launchpad Backend API, providing type-safe authentication, trading, and real-time features for DeFi applications.
|
|
4
4
|
|
|
5
|
+
> **⚠️ BREAKING CHANGE (v3.33.0+)**: Token format parsing now **ONLY accepts delimited formats** (`GALA|Unit|none|none` or `GALA$Unit$none$none`). Plain token strings (`'GALA'`, `'GUSDC'`) are **permanently rejected** for security. See [Migration Guide](#token-format-migration-v330) below.
|
|
6
|
+
|
|
5
7
|
[](https://badge.fury.io/js/@gala-chain%2Flaunchpad-sdk)
|
|
6
8
|
[](https://opensource.org/licenses/MIT)
|
|
7
9
|
[](http://www.typescriptlang.org/)
|
|
10
|
+
[](./docs/API-REFERENCE.md)
|
|
8
11
|
|
|
9
12
|
## Features
|
|
10
13
|
|
|
@@ -63,7 +66,7 @@ console.log(pools.hasNext); // Computed convenience properties
|
|
|
63
66
|
- **Token Trading**: Buy and sell tokens with slippage protection via GalaChain
|
|
64
67
|
- **DEX Pool Discovery**: Discover and explore GalaSwap liquidity pools with filtering, sorting, and pagination
|
|
65
68
|
- **DEX Trading**: Real-time token swaps on GalaSwap DEX with quote generation and slippage protection
|
|
66
|
-
- **Liquidity Management**: Manage liquidity positions on GalaSwap (add, remove, collect fees)
|
|
69
|
+
- **Liquidity Management**: Manage liquidity positions on GalaSwap (add, remove, collect fees) with filtering and organization utilities
|
|
67
70
|
- **Token Transfers**: Transfer GALA and launchpad tokens between wallets with EIP-712 signatures
|
|
68
71
|
- **User Operations**: Portfolio management, token balances, and account management
|
|
69
72
|
- **Comment System**: Post and retrieve comments on token pools
|
|
@@ -292,6 +295,245 @@ const result = await sdk.buy({
|
|
|
292
295
|
- ✅ Missing wallet throws `ValidationError` with code `WALLET_REQUIRED`
|
|
293
296
|
- ⚠️ Only methods that sign transactions require a wallet
|
|
294
297
|
|
|
298
|
+
## Environment Configuration
|
|
299
|
+
|
|
300
|
+
The SDK supports multiple environments (STAGE and PROD). All demo scripts and examples use a **centralized environment configuration pattern** via `.env` file.
|
|
301
|
+
|
|
302
|
+
### Quick Setup
|
|
303
|
+
|
|
304
|
+
Create/edit `.env` in the repository root:
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
# .env
|
|
308
|
+
ENVIRONMENT=STAGE # Switch between STAGE and PROD
|
|
309
|
+
WALLET_PRIVATE_KEY=0x... # Your wallet private key (optional)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
All demo scripts automatically read from this `.env` file:
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
npm run demo:read-only # Uses ENVIRONMENT from .env
|
|
316
|
+
npm run demo:dex # Uses ENVIRONMENT from .env
|
|
317
|
+
npm run demo:liquidity # Uses ENVIRONMENT from .env
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### Environment Values
|
|
321
|
+
|
|
322
|
+
| Value | Accepts | Use Case |
|
|
323
|
+
|-------|---------|----------|
|
|
324
|
+
| `STAGE` | `STAGE`, `STAGING` | Development/staging |
|
|
325
|
+
| `PROD` | `PROD`, `PRODUCTION` | Production |
|
|
326
|
+
| Default | (if not set) | Defaults to `STAGE` with warning |
|
|
327
|
+
|
|
328
|
+
### SDK Initialization
|
|
329
|
+
|
|
330
|
+
When using demo scripts or examples, the environment is automatically loaded:
|
|
331
|
+
|
|
332
|
+
```typescript
|
|
333
|
+
import { getEnvironment } from './examples/utils/get-environment';
|
|
334
|
+
|
|
335
|
+
const environment = getEnvironment(); // Reads from .env
|
|
336
|
+
const sdk = new LaunchpadSDK({
|
|
337
|
+
env: environment,
|
|
338
|
+
wallet: undefined // Optional
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
### Validation
|
|
343
|
+
|
|
344
|
+
Prevent hardcoded environment values:
|
|
345
|
+
|
|
346
|
+
```bash
|
|
347
|
+
npm run validate:env # Validates no hardcoded 'STAGE' or 'PROD'
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Full Documentation
|
|
351
|
+
|
|
352
|
+
See [docs/ENVIRONMENT_CONFIGURATION.md](./docs/ENVIRONMENT_CONFIGURATION.md) for:
|
|
353
|
+
- Architecture and implementation details
|
|
354
|
+
- Pattern for adding new scripts
|
|
355
|
+
- Troubleshooting guide
|
|
356
|
+
- Migration guide for existing scripts
|
|
357
|
+
|
|
358
|
+
## Token Format Migration (v3.33.0)
|
|
359
|
+
|
|
360
|
+
### Breaking Change: Strict Token Format Enforcement
|
|
361
|
+
|
|
362
|
+
**v3.33.0 removes support for plain token strings** and requires all tokens to use **delimited format**.
|
|
363
|
+
|
|
364
|
+
#### Old Behavior (v3.32.x and below) - DEPRECATED
|
|
365
|
+
|
|
366
|
+
Plain token strings were accepted:
|
|
367
|
+
```typescript
|
|
368
|
+
// ❌ NO LONGER WORKS (v3.33.0+)
|
|
369
|
+
await sdk.addSwapLiquidityByPrice({
|
|
370
|
+
token0: 'GALA', // Plain string
|
|
371
|
+
token1: 'GUSDC', // Plain string
|
|
372
|
+
fee: 3000,
|
|
373
|
+
minPrice: '0.95',
|
|
374
|
+
maxPrice: '1.05',
|
|
375
|
+
amount0Desired: '100',
|
|
376
|
+
amount1Desired: '100'
|
|
377
|
+
});
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### New Behavior (v3.33.0+) - REQUIRED
|
|
381
|
+
|
|
382
|
+
All tokens must use **pipe-delimited** (`|`) or **dollar-delimited** (`$`) format:
|
|
383
|
+
|
|
384
|
+
```typescript
|
|
385
|
+
// ✅ REQUIRED FORMAT (v3.33.0+)
|
|
386
|
+
await sdk.addSwapLiquidityByPrice({
|
|
387
|
+
token0: 'GALA|Unit|none|none', // Delimited format
|
|
388
|
+
token1: 'GUSDC|Unit|none|none', // Delimited format
|
|
389
|
+
fee: 3000,
|
|
390
|
+
minPrice: '0.95',
|
|
391
|
+
maxPrice: '1.05',
|
|
392
|
+
amount0Desired: '100',
|
|
393
|
+
amount1Desired: '100'
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
#### Format Options
|
|
398
|
+
|
|
399
|
+
**Pipe-Delimited (Recommended):**
|
|
400
|
+
```typescript
|
|
401
|
+
'GALA|Unit|none|none'
|
|
402
|
+
'GUSDC|Unit|none|none'
|
|
403
|
+
'MYTOKEN|Unit|none|none'
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Dollar-Delimited (Alternative):**
|
|
407
|
+
```typescript
|
|
408
|
+
'GALA$Unit$none$none'
|
|
409
|
+
'GUSDC$Unit$none$none'
|
|
410
|
+
'MYTOKEN$Unit$none$none'
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### Migration Checklist
|
|
414
|
+
|
|
415
|
+
- [ ] Search codebase for plain token strings: `'GALA'`, `'GUSDC'`, etc.
|
|
416
|
+
- [ ] Replace with delimited format: `'GALA|Unit|none|none'`, `'GUSDC|Unit|none|none'`
|
|
417
|
+
- [ ] Update all SDK method calls that pass token parameters
|
|
418
|
+
- [ ] Test thoroughly - TypeScript strict mode will catch most issues
|
|
419
|
+
- [ ] Update internal token handling code
|
|
420
|
+
|
|
421
|
+
#### Affected Methods
|
|
422
|
+
|
|
423
|
+
The following methods now require delimited token format:
|
|
424
|
+
- `getSwapQuoteExactInput(token0, token1, amount)`
|
|
425
|
+
- `getSwapQuoteExactOutput(token0, token1, amount)`
|
|
426
|
+
- `executeSwap(token0, token1, ...)`
|
|
427
|
+
- `addSwapLiquidityByPrice({token0, token1, ...})`
|
|
428
|
+
- `addSwapLiquidityByTicks({token0, token1, ...})`
|
|
429
|
+
- `removeSwapLiquidity({token0, token1, ...})`
|
|
430
|
+
- `getSwapPoolInfo(token0, token1)`
|
|
431
|
+
|
|
432
|
+
#### Security Rationale
|
|
433
|
+
|
|
434
|
+
This breaking change enforces **strict token format validation** to:
|
|
435
|
+
- ✅ **Prevent injection attacks** via token string manipulation
|
|
436
|
+
- ✅ **Ensure deterministic parsing** with no ambiguous fallbacks
|
|
437
|
+
- ✅ **Eliminate security gaps** from loose string handling
|
|
438
|
+
- ✅ **Force explicit token specification** with full TokenClassKey structure
|
|
439
|
+
|
|
440
|
+
Plain string support created a dangerous "escape hatch" where ambiguous token identifiers could be accepted. v3.33.0 eliminates this by requiring all tokens be properly delimited.
|
|
441
|
+
|
|
442
|
+
## Upgrading to v4.0.0
|
|
443
|
+
|
|
444
|
+
### Breaking Changes: Removed Deprecated Methods
|
|
445
|
+
|
|
446
|
+
**v4.0.0 removes one deprecated method** that was superseded in v3.22.7. This is a clean removal with **minimal migration effort** - most users will not be affected.
|
|
447
|
+
|
|
448
|
+
#### Removed Method: `fetchLaunchpadTokenSpotPrice()`
|
|
449
|
+
|
|
450
|
+
This method was deprecated in v3.22.7 in favor of the more flexible `fetchTokenPrice()` method.
|
|
451
|
+
|
|
452
|
+
**Old Code (v3.35.x and below) - NO LONGER WORKS:**
|
|
453
|
+
```typescript
|
|
454
|
+
// ❌ REMOVED in v4.0.0
|
|
455
|
+
const price = await sdk.fetchLaunchpadTokenSpotPrice('anime');
|
|
456
|
+
console.log(`Price: ${price} USD`);
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
**New Code (v4.0.0+) - REQUIRED:**
|
|
460
|
+
```typescript
|
|
461
|
+
// ✅ REQUIRED - Works for both launchpad and DEX tokens
|
|
462
|
+
const price = await sdk.fetchTokenPrice('anime');
|
|
463
|
+
console.log(`Price: ${price} USD`);
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
#### Why This Change?
|
|
467
|
+
|
|
468
|
+
The new `fetchTokenPrice()` method:
|
|
469
|
+
- ✅ **Unified pricing** - Works for both launchpad tokens and DEX-graduated tokens
|
|
470
|
+
- ✅ **Automatic routing** - Detects token type and fetches from correct backend
|
|
471
|
+
- ✅ **Better performance** - Single method instead of specialized variants
|
|
472
|
+
- ✅ **Cleaner API** - Less method duplication in SDK
|
|
473
|
+
|
|
474
|
+
#### Migration Checklist
|
|
475
|
+
|
|
476
|
+
- [ ] Search codebase for `fetchLaunchpadTokenSpotPrice(`
|
|
477
|
+
- [ ] Replace all occurrences with `fetchTokenPrice(`
|
|
478
|
+
- [ ] Test with both launchpad tokens (e.g., `'anime'`) and DEX tokens
|
|
479
|
+
- [ ] Verify price results haven't changed (same calculation logic)
|
|
480
|
+
|
|
481
|
+
#### Impact Assessment
|
|
482
|
+
|
|
483
|
+
**Affected Users:**
|
|
484
|
+
- ⚠️ **Only if you explicitly called** `fetchLaunchpadTokenSpotPrice()`
|
|
485
|
+
- ✅ **Not affected if you** used `fetchTokenPrice()` or `fetchTokenSpotPrice()` methods
|
|
486
|
+
- ✅ **Not affected if you** never queried token prices
|
|
487
|
+
|
|
488
|
+
**Migration Effort:**
|
|
489
|
+
- ⏱️ **5 minutes** - Simple find/replace across codebase
|
|
490
|
+
- ⚙️ **Zero logic changes** - Functionality remains identical
|
|
491
|
+
- 🎯 **Low risk** - Price calculation algorithm unchanged
|
|
492
|
+
|
|
493
|
+
### New Features: Service Clients Documentation
|
|
494
|
+
|
|
495
|
+
v4.0.0 adds internal service client documentation for advanced users who need direct access to underlying blockchain services.
|
|
496
|
+
|
|
497
|
+
```typescript
|
|
498
|
+
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
499
|
+
|
|
500
|
+
const sdk = createLaunchpadSDK({
|
|
501
|
+
wallet: 'your-private-key'
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
// Advanced: Direct access to DEX Backend API
|
|
505
|
+
// Use case: Custom swap parameters or debugging
|
|
506
|
+
const quote = await sdk.dexBackendClient.querySwapQuote({
|
|
507
|
+
orderedTokens: [...],
|
|
508
|
+
zeroForOne: false,
|
|
509
|
+
inputAmount: '10',
|
|
510
|
+
// ... additional parameters
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// Advanced: Direct access to GalaChain Gateway
|
|
514
|
+
// Use case: Custom transaction building
|
|
515
|
+
const result = await sdk.galaChainGatewayClient.callContract({
|
|
516
|
+
address: 'contract-address',
|
|
517
|
+
method: 'transfer',
|
|
518
|
+
// ... parameters
|
|
519
|
+
});
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
**⚠️ Important:** Service clients are internal implementation details. For standard operations, always use public SDK methods:
|
|
523
|
+
- ✅ Use `sdk.buy()` instead of `sdk.galaChainGatewayClient`
|
|
524
|
+
- ✅ Use `sdk.executeSwap()` instead of `sdk.dexBackendClient`
|
|
525
|
+
- ✅ These public methods provide better error handling and validation
|
|
526
|
+
|
|
527
|
+
For detailed service client documentation, see [docs/API-REFERENCE.md#service-clients](./docs/API-REFERENCE.md#service-clients).
|
|
528
|
+
|
|
529
|
+
### Migration Summary
|
|
530
|
+
|
|
531
|
+
**For Most Users:** Nothing to do! v4.0.0 is backward compatible except for the removal of `fetchLaunchpadTokenSpotPrice()`.
|
|
532
|
+
|
|
533
|
+
**If You Used `fetchLaunchpadTokenSpotPrice()`:** Replace with `fetchTokenPrice()` - identical functionality, better flexibility.
|
|
534
|
+
|
|
535
|
+
**If You Need Service Client Access:** They're now documented and available for advanced use cases, but use public SDK methods when possible.
|
|
536
|
+
|
|
295
537
|
## DEX Pool Discovery & Analysis
|
|
296
538
|
|
|
297
539
|
### Overview
|
|
@@ -932,6 +1174,62 @@ console.log(`Status: ${tokenTransfer.status}`);
|
|
|
932
1174
|
- **GalaChain Integration**: Direct transfers via GalaChain gateway
|
|
933
1175
|
- **Error Handling**: Detailed error types for different failure scenarios
|
|
934
1176
|
|
|
1177
|
+
## Lock/Unlock Operations
|
|
1178
|
+
|
|
1179
|
+
Lock and unlock tokens on GalaChain for staking, escrow, and vesting mechanisms:
|
|
1180
|
+
|
|
1181
|
+
```typescript
|
|
1182
|
+
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
1183
|
+
|
|
1184
|
+
const sdk = createLaunchpadSDK({
|
|
1185
|
+
wallet: 'your-private-key-or-mnemonic'
|
|
1186
|
+
});
|
|
1187
|
+
|
|
1188
|
+
// Lock tokens - caller becomes lock authority by default
|
|
1189
|
+
const lockResult = await sdk.lockToken({
|
|
1190
|
+
tokenName: 'tinyevil',
|
|
1191
|
+
amount: '1000' // Token amount in smallest unit
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
console.log(`Locked tokens, tx: ${lockResult.transactionId}`);
|
|
1195
|
+
|
|
1196
|
+
// Lock with custom authority and expiration
|
|
1197
|
+
const escrowLock = await sdk.lockToken({
|
|
1198
|
+
tokenName: 'tinyevil',
|
|
1199
|
+
amount: '5000',
|
|
1200
|
+
lockAuthority: 'eth|0xEscrowContract...', // Third party can unlock
|
|
1201
|
+
expires: Date.now() + 7 * 24 * 60 * 60 * 1000, // Auto-release in 1 week
|
|
1202
|
+
name: 'escrow-deal-123' // Named lock for matching
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
// Unlock tokens - must be called by lock authority
|
|
1206
|
+
const unlockResult = await sdk.unlockToken({
|
|
1207
|
+
tokenName: 'tinyevil',
|
|
1208
|
+
amount: '1000'
|
|
1209
|
+
});
|
|
1210
|
+
|
|
1211
|
+
console.log(`Unlocked tokens, tx: ${unlockResult.transactionId}`);
|
|
1212
|
+
|
|
1213
|
+
// Unlock specific named lock
|
|
1214
|
+
await sdk.unlockToken({
|
|
1215
|
+
tokenName: 'tinyevil',
|
|
1216
|
+
amount: '5000',
|
|
1217
|
+
name: 'escrow-deal-123' // Must match lock name
|
|
1218
|
+
});
|
|
1219
|
+
```
|
|
1220
|
+
|
|
1221
|
+
### Lock Features
|
|
1222
|
+
- **Lock Authority**: Specify who can unlock (defaults to caller)
|
|
1223
|
+
- **Expiration**: Optional auto-release timestamp
|
|
1224
|
+
- **Named Locks**: Identify locks by name for targeted unlocks
|
|
1225
|
+
- **EIP-712 Signatures**: Secure blockchain transactions
|
|
1226
|
+
- **Idempotency**: Optional unique keys prevent duplicate operations
|
|
1227
|
+
|
|
1228
|
+
### Use Cases
|
|
1229
|
+
- **Staking**: Lock tokens for reward programs
|
|
1230
|
+
- **Escrow**: Third-party holds tokens until conditions met
|
|
1231
|
+
- **Vesting**: Time-locked token releases with expiration
|
|
1232
|
+
|
|
935
1233
|
## Multi-Wallet Support
|
|
936
1234
|
|
|
937
1235
|
The SDK supports **per-operation wallet overrides** for testing multi-wallet workflows without creating new SDK instances. This is ideal for:
|
|
@@ -1126,7 +1424,7 @@ fetchPoolDetails(tokenName): Promise<PoolDetailsData>
|
|
|
1126
1424
|
|
|
1127
1425
|
fetchTokenDetails(tokenId): Promise<TokenDetails>
|
|
1128
1426
|
// Returns: { symbol, decimals, name, image, verified, network, chainId, contractAddress, tradingEnabled, ... }
|
|
1129
|
-
// Supports flexible tokenId: string ('
|
|
1427
|
+
// Supports flexible tokenId: string ('GUSDC|Unit|none|eth:0x...') or object format
|
|
1130
1428
|
|
|
1131
1429
|
fetchVolumeData(options): Promise<GraphDataResult>
|
|
1132
1430
|
// Returns: { dataPoints }
|
|
@@ -1847,7 +2145,7 @@ getSwapPoolInfo(tokenA, tokenB): Promise<PoolInfo>
|
|
|
1847
2145
|
```
|
|
1848
2146
|
|
|
1849
2147
|
**Key Features:**
|
|
1850
|
-
- ✅ **
|
|
2148
|
+
- ✅ **Strict token format enforcement** (v3.33.0+): All tokens require delimited format (`'GALA|Unit|none|none'` or `'GALA$Unit$none$none'`)
|
|
1851
2149
|
- ✅ **Quote pattern**: Always get quote before executing swap for accurate slippage calculations
|
|
1852
2150
|
- ✅ **Unified WebSocket**: Real-time transaction monitoring via shared LaunchpadSDK WebSocket connection
|
|
1853
2151
|
- ✅ **Environment alignment**: Automatic STAGE/PROD configuration matching
|
|
@@ -2071,6 +2369,54 @@ const testSDK = createTestLaunchpadSDK({
|
|
|
2071
2369
|
});
|
|
2072
2370
|
```
|
|
2073
2371
|
|
|
2372
|
+
### **Position Filter Utilities**
|
|
2373
|
+
|
|
2374
|
+
Helpers for organizing and filtering liquidity positions by various criteria:
|
|
2375
|
+
|
|
2376
|
+
```typescript
|
|
2377
|
+
import {
|
|
2378
|
+
filterByLiquidity, // Remove positions with zero liquidity
|
|
2379
|
+
filterByMinLiquidity, // Keep positions >= threshold
|
|
2380
|
+
filterByTokenPair, // Match specific token pair
|
|
2381
|
+
filterByToken, // Find positions containing a token
|
|
2382
|
+
filterByFeeTier, // Filter by fee tier (500, 3000, 10000)
|
|
2383
|
+
filterByPoolKey, // Match specific pool (token pair + fee)
|
|
2384
|
+
sortByLiquidity, // Sort positions by liquidity amount
|
|
2385
|
+
groupByTokenPair, // Group by "TOKEN0/TOKEN1"
|
|
2386
|
+
groupByFeeTier, // Group by fee tier
|
|
2387
|
+
groupByPoolKey, // Group by "TOKEN0|TOKEN1|FEETIER"
|
|
2388
|
+
} from '@gala-chain/launchpad-sdk';
|
|
2389
|
+
|
|
2390
|
+
// Example: Find active GALA/GUSDC positions and sort by size
|
|
2391
|
+
const allPositions = await sdk.getAllSwapUserLiquidityPositions(address);
|
|
2392
|
+
const active = filterByLiquidity(allPositions); // Remove zero-liquidity
|
|
2393
|
+
const galaPositions = filterByTokenPair(active, 'GALA', 'GUSDC'); // GALA/GUSDC only
|
|
2394
|
+
const sorted = sortByLiquidity(galaPositions, 'desc'); // Largest first
|
|
2395
|
+
|
|
2396
|
+
// Group positions by token pair for portfolio analysis
|
|
2397
|
+
const grouped = groupByTokenPair(active);
|
|
2398
|
+
grouped.forEach((positions, pair) => {
|
|
2399
|
+
console.log(`${pair}: ${positions.length} positions`);
|
|
2400
|
+
});
|
|
2401
|
+
|
|
2402
|
+
// Find positions with significant liquidity
|
|
2403
|
+
const large = filterByMinLiquidity(active, '1000');
|
|
2404
|
+
|
|
2405
|
+
// Organize by pool (pair + fee tier) for advanced analysis
|
|
2406
|
+
const byPool = groupByPoolKey(active);
|
|
2407
|
+
byPool.forEach((positions, poolKey) => {
|
|
2408
|
+
console.log(`Pool ${poolKey}: ${positions.length} LPs`);
|
|
2409
|
+
});
|
|
2410
|
+
```
|
|
2411
|
+
|
|
2412
|
+
**Use Cases:**
|
|
2413
|
+
- Organize positions by token pair or pool
|
|
2414
|
+
- Filter for active positions (non-zero liquidity)
|
|
2415
|
+
- Find positions above minimum liquidity threshold
|
|
2416
|
+
- Analyze portfolio distribution by token or fee tier
|
|
2417
|
+
- Identify opportunities for fee collection
|
|
2418
|
+
- Locate positions in specific pools
|
|
2419
|
+
|
|
2074
2420
|
## Testing
|
|
2075
2421
|
|
|
2076
2422
|
```bash
|
|
@@ -2092,7 +2438,7 @@ npm run lint
|
|
|
2092
2438
|
- [SDK Method Reference](./SDK-METHOD-GRAPH.md) - Complete flat API reference
|
|
2093
2439
|
- [Clean Result Types Migration Guide](./docs/CLEAN_RESULT_TYPES_MIGRATION.md) - Migration guide for clean result types
|
|
2094
2440
|
- [Service Architecture Migration Guide](./docs/SERVICE_ARCHITECTURE_MIGRATION.md) - Guide for v3.1.0 service-based architecture
|
|
2095
|
-
- [API
|
|
2441
|
+
- [API Reference](./docs/API-REFERENCE.md) - Complete reference for all 72 SDK methods with examples
|
|
2096
2442
|
- [Examples](./examples/) - Code examples and demos
|
|
2097
2443
|
|
|
2098
2444
|
### GSwap Liquidity Operations
|
|
@@ -2103,24 +2449,202 @@ npm run lint
|
|
|
2103
2449
|
|
|
2104
2450
|
### Demo Scripts
|
|
2105
2451
|
|
|
2106
|
-
|
|
2452
|
+
The SDK includes 36 comprehensive demo scripts organized into logical categories for easy discovery and learning.
|
|
2453
|
+
|
|
2454
|
+
#### Organized Directory Structure
|
|
2455
|
+
|
|
2456
|
+
```
|
|
2457
|
+
examples/
|
|
2458
|
+
├── core/ # SDK fundamentals and authentication patterns
|
|
2459
|
+
├── liquidity/ # GalaSwap liquidity position management (9 demos)
|
|
2460
|
+
├── bonding-curve/ # Token bonding curve trading operations
|
|
2461
|
+
├── dex/ # DEX trading and pool discovery (6 demos)
|
|
2462
|
+
├── fees/ # Fee generation and collection workflows (5 demos)
|
|
2463
|
+
├── monitoring/ # Real-time event watching (2 demos)
|
|
2464
|
+
├── utilities/ # Balance checks, cache, token supply (5 demos)
|
|
2465
|
+
└── debug/ # Development and troubleshooting tools
|
|
2466
|
+
```
|
|
2467
|
+
|
|
2468
|
+
#### Quick Start Examples
|
|
2469
|
+
|
|
2470
|
+
**Core SDK Operations:**
|
|
2471
|
+
```bash
|
|
2472
|
+
# Complete SDK feature demonstration
|
|
2473
|
+
npm run demo
|
|
2474
|
+
|
|
2475
|
+
# Read-only operations (no wallet required)
|
|
2476
|
+
npm run demo:read-only
|
|
2477
|
+
|
|
2478
|
+
# Authenticated operations (wallet required)
|
|
2479
|
+
npm run demo:authenticated
|
|
2480
|
+
|
|
2481
|
+
# Multi-wallet private key override pattern
|
|
2482
|
+
npm run demo:privatekey-override
|
|
2483
|
+
```
|
|
2484
|
+
|
|
2485
|
+
#### Liquidity Position Management (9 Demos)
|
|
2486
|
+
|
|
2487
|
+
Comprehensive liquidity provision workflows for GalaSwap DEX:
|
|
2488
|
+
|
|
2489
|
+
```bash
|
|
2490
|
+
# Interactive CLI for position management
|
|
2491
|
+
npm run demo:liquidity
|
|
2492
|
+
|
|
2493
|
+
# Run all 9 liquidity demos sequentially
|
|
2494
|
+
npm run demo:liquidity:all
|
|
2495
|
+
|
|
2496
|
+
# Individual demos
|
|
2497
|
+
npm run demo:liquidity:detailed # Detailed position lifecycle
|
|
2498
|
+
npm run demo:liquidity:ticks # Advanced tick-based positions
|
|
2499
|
+
npm run demo:liquidity:portfolio # Multi-position portfolio management
|
|
2500
|
+
npm run demo:liquidity:apr # APR calculation for LP positions
|
|
2501
|
+
npm run demo:liquidity:errors # Error handling patterns
|
|
2502
|
+
npm run demo:liquidity:fetch-all # Fetch all positions with pagination
|
|
2503
|
+
npm run demo:liquidity:positions-with-prices # Position pricing enrichment
|
|
2504
|
+
|
|
2505
|
+
# Complete roundtrip workflow (legacy, use orchestrator instead)
|
|
2506
|
+
npm run demo:dex:roundtrip
|
|
2507
|
+
```
|
|
2508
|
+
|
|
2509
|
+
**Orchestrator Pattern:**
|
|
2510
|
+
The liquidity orchestrator (`npm run demo:liquidity:all`) runs all demos with intelligent error handling:
|
|
2511
|
+
- Skip individual demos: `--skip=detailed,ticks`
|
|
2512
|
+
- Run specific demos only: `--only=portfolio,apr`
|
|
2513
|
+
- See all available demos: `npm run demo:liquidity:all --help`
|
|
2514
|
+
|
|
2515
|
+
#### Bonding Curve Trading (Launchpad Tokens)
|
|
2516
|
+
|
|
2517
|
+
Pre-graduation token trading on bonding curve pools:
|
|
2518
|
+
|
|
2519
|
+
```bash
|
|
2520
|
+
# Basic buy/sell operations with slippage protection
|
|
2521
|
+
npm run demo:trades
|
|
2522
|
+
```
|
|
2523
|
+
|
|
2524
|
+
**Bonding Curve Focus:**
|
|
2525
|
+
8 additional bonding curve demos are available through the orchestrator (in development):
|
|
2526
|
+
- Pool discovery and filtering
|
|
2527
|
+
- Price calculation methods
|
|
2528
|
+
- Graduation simulation
|
|
2529
|
+
- Multi-token analysis
|
|
2530
|
+
- Fee structure exploration
|
|
2531
|
+
- Slippage testing scenarios
|
|
2532
|
+
|
|
2533
|
+
#### DEX Trading Operations (6 Demos)
|
|
2534
|
+
|
|
2535
|
+
Graduated token trading on GalaSwap DEX with full liquidity pool support:
|
|
2536
|
+
|
|
2107
2537
|
```bash
|
|
2108
|
-
#
|
|
2109
|
-
npm run demo:
|
|
2538
|
+
# DEX swap workflow (quote → execute → confirm)
|
|
2539
|
+
npm run demo:dex
|
|
2110
2540
|
|
|
2111
|
-
#
|
|
2112
|
-
npm run demo:
|
|
2541
|
+
# Pool discovery and metrics
|
|
2542
|
+
npm run demo:dex:pools
|
|
2113
2543
|
|
|
2114
|
-
#
|
|
2115
|
-
npm run demo:
|
|
2544
|
+
# Pool pricing and TVL analysis
|
|
2545
|
+
npm run demo:dex:pricing
|
|
2116
2546
|
|
|
2117
|
-
#
|
|
2118
|
-
npm run demo:
|
|
2547
|
+
# Quote comparison (exact input vs exact output)
|
|
2548
|
+
npm run demo:dex:quotes
|
|
2119
2549
|
|
|
2120
|
-
#
|
|
2121
|
-
npm run demo:
|
|
2550
|
+
# Complete swap roundtrip (buy → sell → verify)
|
|
2551
|
+
npm run demo:roundtrip:swap
|
|
2122
2552
|
```
|
|
2123
2553
|
|
|
2554
|
+
#### Fee Generation and Collection (5 Demos)
|
|
2555
|
+
|
|
2556
|
+
Liquidity provider fee workflows with multi-wallet testing:
|
|
2557
|
+
|
|
2558
|
+
```bash
|
|
2559
|
+
# Basic fee generation and collection
|
|
2560
|
+
npm run demo:fees
|
|
2561
|
+
|
|
2562
|
+
# High-volume trading fee accumulation
|
|
2563
|
+
npm run demo:fees:high-volume
|
|
2564
|
+
|
|
2565
|
+
# Complete fee lifecycle test suite
|
|
2566
|
+
npm run demo:fees:test
|
|
2567
|
+
|
|
2568
|
+
# Trade and collect fees in single workflow
|
|
2569
|
+
npm run demo:fees:trade-collect
|
|
2570
|
+
```
|
|
2571
|
+
|
|
2572
|
+
**Note:** `demo-multi-wallet-fee-generation.ts` is available but not exposed in npm scripts (advanced usage).
|
|
2573
|
+
|
|
2574
|
+
#### Real-Time Monitoring (2 Demos)
|
|
2575
|
+
|
|
2576
|
+
WebSocket-based event watchers for pool and token creation:
|
|
2577
|
+
|
|
2578
|
+
```bash
|
|
2579
|
+
# Watch for new DEX pool creation
|
|
2580
|
+
npm run demo:watch
|
|
2581
|
+
|
|
2582
|
+
# Watch for new launchpad token launches
|
|
2583
|
+
npm run demo:watch:tokens
|
|
2584
|
+
```
|
|
2585
|
+
|
|
2586
|
+
#### Utility Operations (5 Demos)
|
|
2587
|
+
|
|
2588
|
+
Balance queries, caching, and token supply information:
|
|
2589
|
+
|
|
2590
|
+
```bash
|
|
2591
|
+
# Metadata cache warming and performance testing
|
|
2592
|
+
npm run demo:cache
|
|
2593
|
+
|
|
2594
|
+
# Token supply metrics from GalaChain
|
|
2595
|
+
npm run demo:token-supply
|
|
2596
|
+
```
|
|
2597
|
+
|
|
2598
|
+
**Additional utilities:**
|
|
2599
|
+
- `balances.ts` - Multi-token balance queries
|
|
2600
|
+
- `balance.ts` - Single token balance check
|
|
2601
|
+
- `price-history.ts` - Historical price data (Node.js only)
|
|
2602
|
+
|
|
2603
|
+
#### Debug and Development Tools
|
|
2604
|
+
|
|
2605
|
+
Advanced troubleshooting and environment testing:
|
|
2606
|
+
|
|
2607
|
+
```bash
|
|
2608
|
+
# Environment alignment verification
|
|
2609
|
+
tsx examples/debug/test-env-alignment.ts
|
|
2610
|
+
|
|
2611
|
+
# Slot0 data debugging
|
|
2612
|
+
tsx examples/debug/debug-getslot0-test.ts
|
|
2613
|
+
|
|
2614
|
+
# DEX simulation with monkey patching
|
|
2615
|
+
tsx examples/debug/demo-dex-monkey-patch-simulation.ts
|
|
2616
|
+
```
|
|
2617
|
+
|
|
2618
|
+
#### Demo Statistics
|
|
2619
|
+
|
|
2620
|
+
- **Total Demos:** 36 working examples
|
|
2621
|
+
- **npm Scripts:** 25 convenient shortcuts
|
|
2622
|
+
- **Categories:** 8 organized directories
|
|
2623
|
+
- **Coverage:** All major SDK features demonstrated
|
|
2624
|
+
|
|
2625
|
+
#### Recommended Learning Path
|
|
2626
|
+
|
|
2627
|
+
1. **Start Here:** `npm run demo` - Complete SDK overview
|
|
2628
|
+
2. **Liquidity Basics:** `npm run demo:liquidity` - Interactive CLI
|
|
2629
|
+
3. **DEX Trading:** `npm run demo:dex` - Swap workflow
|
|
2630
|
+
4. **Fee Management:** `npm run demo:fees` - LP fee collection
|
|
2631
|
+
5. **Advanced:** Explore individual demos by category
|
|
2632
|
+
|
|
2633
|
+
#### Migration Notes
|
|
2634
|
+
|
|
2635
|
+
**Removed Scripts (v3.32.0+):**
|
|
2636
|
+
- `demo:liquidity:simple` - Merged into `demo:liquidity`
|
|
2637
|
+
- `demo:liquidity:workflow` - Replaced by orchestrator pattern
|
|
2638
|
+
- `demo:dex:swap` - Renamed to `demo:dex` for consistency
|
|
2639
|
+
|
|
2640
|
+
**New in v3.32.0+:**
|
|
2641
|
+
- Organized directory structure with 8 categories
|
|
2642
|
+
- Bonding curve orchestrator (in development)
|
|
2643
|
+
- Fee demo npm scripts now exposed
|
|
2644
|
+
- Symmetry: Both bonding-curve and dex have pool discovery demos
|
|
2645
|
+
|
|
2646
|
+
For detailed migration guide, see [docs/DEMO_MIGRATION_GUIDE.md](./docs/DEMO_MIGRATION_GUIDE.md).
|
|
2647
|
+
|
|
2124
2648
|
## Architecture
|
|
2125
2649
|
|
|
2126
2650
|
The SDK uses a **service-based architecture** with backend-aligned services:
|