@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
|
@@ -74,6 +74,80 @@ export interface AutoPaginationResult<T> {
|
|
|
74
74
|
* @since 3.32.0
|
|
75
75
|
*/
|
|
76
76
|
export declare function autoPaginate<T>(fetchFn: (page: number, limit: number) => Promise<PaginatedResult<T>>, options?: AutoPaginationOptions): Promise<AutoPaginationResult<T>>;
|
|
77
|
+
/**
|
|
78
|
+
* Result object from bookmark-based API calls
|
|
79
|
+
* Returned by fetchFn in autoPaginateWithBookmark
|
|
80
|
+
*/
|
|
81
|
+
export interface BookmarkPaginationResult<T> {
|
|
82
|
+
/** Array of items returned from this page */
|
|
83
|
+
items: T[];
|
|
84
|
+
/** Bookmark/cursor for fetching the next page
|
|
85
|
+
* - undefined: field was not present in API response
|
|
86
|
+
* - empty string "": API signals last page reached
|
|
87
|
+
* - non-empty string: bookmark to use for next request
|
|
88
|
+
*/
|
|
89
|
+
nextBookmark: string | undefined;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Options for bookmark-based auto-pagination
|
|
93
|
+
* Used for APIs that use cursor-based pagination (bookmarks) instead of page numbers
|
|
94
|
+
*/
|
|
95
|
+
export interface AutoPaginationWithBookmarkOptions {
|
|
96
|
+
/** Maximum number of pages to fetch (safety limit to prevent infinite loops) */
|
|
97
|
+
maxPages?: number;
|
|
98
|
+
/** Logger instance for debug output */
|
|
99
|
+
logger?: Logger;
|
|
100
|
+
/** Page size to use for each request */
|
|
101
|
+
pageSize?: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Bookmark-based auto-pagination handler
|
|
105
|
+
*
|
|
106
|
+
* Automatically iterates through all pages of bookmark-based paginated API results
|
|
107
|
+
* (cursor-based pagination) and combines them into a single array.
|
|
108
|
+
*
|
|
109
|
+
* Used for APIs that return bookmarks/cursors instead of page numbers (e.g., GSwap positions API).
|
|
110
|
+
* Handles common patterns like:
|
|
111
|
+
* - Safety limits to prevent infinite loops
|
|
112
|
+
* - Empty result detection
|
|
113
|
+
* - Debug logging of pagination progress
|
|
114
|
+
* - Proper bookmark extraction from API responses
|
|
115
|
+
* - Dual completion detection (no nextBookmark OR fewer items than requested)
|
|
116
|
+
*
|
|
117
|
+
* @typeParam T - Type of items being paginated
|
|
118
|
+
* @param fetchFn Function that fetches a single page and returns items with optional nextBookmark.
|
|
119
|
+
* Should return { items: T[], nextBookmark?: string }.
|
|
120
|
+
* If bookmark is undefined, fetches first page.
|
|
121
|
+
* @param options Pagination options (maxPages, logger, pageSize)
|
|
122
|
+
* @returns Promise<AutoPaginationResult> All items combined from all pages
|
|
123
|
+
*
|
|
124
|
+
* @example Basic usage with bookmark-returning API
|
|
125
|
+
* ```typescript
|
|
126
|
+
* const result = await autoPaginateWithBookmark(
|
|
127
|
+
* async (bookmark, pageSize) => {
|
|
128
|
+
* const response = await api.getPositions({ bookmark, limit: pageSize });
|
|
129
|
+
* return {
|
|
130
|
+
* items: response.positions,
|
|
131
|
+
* nextBookmark: response.metadata?.nextBookmark
|
|
132
|
+
* };
|
|
133
|
+
* },
|
|
134
|
+
* { maxPages: 1000, pageSize: 10, logger }
|
|
135
|
+
* );
|
|
136
|
+
* console.log(`Total fetched: ${result.items.length}`);
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @example Legacy: Returns items array directly (uses item count for completion)
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const result = await autoPaginateWithBookmark(
|
|
142
|
+
* (bookmark, pageSize) => service.getPositions(walletAddress, pageSize, bookmark),
|
|
143
|
+
* { maxPages: 1000, pageSize: 10, logger }
|
|
144
|
+
* );
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @since 3.32.0
|
|
148
|
+
* @since 3.33.0 - Enhanced to support true bookmark-based pagination with BookmarkPaginationResult<T>
|
|
149
|
+
*/
|
|
150
|
+
export declare function autoPaginateWithBookmark<T>(fetchFn: (bookmark: string | undefined, pageSize: number) => Promise<BookmarkPaginationResult<T> | T[]>, options?: AutoPaginationWithBookmarkOptions): Promise<AutoPaginationResult<T>>;
|
|
77
151
|
/**
|
|
78
152
|
* Build paginated result object for returning combined auto-paginated data
|
|
79
153
|
*
|
|
@@ -128,5 +202,5 @@ export declare function autoPaginate<T>(fetchFn: (page: number, limit: number) =
|
|
|
128
202
|
*
|
|
129
203
|
* @since 3.32.0 - itemsKey parameter added in 3.32.0 for response structure flexibility
|
|
130
204
|
*/
|
|
131
|
-
export declare function buildPaginatedResult<T>(items: T[], total?: number, itemsKey?: 'items' | 'pools' | 'snapshots' | 'comments' | string): Record<string,
|
|
205
|
+
export declare function buildPaginatedResult<T>(items: T[], total?: number, itemsKey?: 'items' | 'pools' | 'snapshots' | 'comments' | string): Record<string, unknown>;
|
|
132
206
|
//# sourceMappingURL=auto-pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-pagination.d.ts","sourceRoot":"","sources":["../../../src/utils/auto-pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA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AiC;IAChD,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,wBAAwB,CAAC,CAAC,EAC9C,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,wBAAwB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EACvG,OAAO,GAAE,iCAAsC,GAC9C,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAqHlC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,EAAE,EACV,KAAK,GAAE,MAAqB,EAC5B,QAAQ,GAAE,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,UAAU,GAAG,MAAgB,GACxE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAezB"}
|
|
@@ -88,11 +88,11 @@ export declare function calculateSlippageFactor(tolerance?: number): BigNumber;
|
|
|
88
88
|
/**
|
|
89
89
|
* Convert tick to sqrt ratio for liquidity calculations
|
|
90
90
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
91
|
+
* Re-exports tickToSqrtPrice from @gala-chain/dex for Uniswap V3 liquidity calculations.
|
|
92
|
+
* Maintained as a wrapper for backward compatibility.
|
|
93
93
|
*
|
|
94
94
|
* @param tick The tick value from the pool
|
|
95
|
-
* @returns Sqrt
|
|
95
|
+
* @returns Sqrt price in Q64.96 format
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
98
|
* ```typescript
|
|
@@ -100,8 +100,32 @@ export declare function calculateSlippageFactor(tolerance?: number): BigNumber;
|
|
|
100
100
|
* const upperSqrtRatio = tickToSqrtRatio(tickUpper);
|
|
101
101
|
* const liquidityNeeded = calculateLiquidity(lowerSqrtRatio, upperSqrtRatio, ...);
|
|
102
102
|
* ```
|
|
103
|
+
*
|
|
104
|
+
* @deprecated This is a wrapper around @gala-chain/dex's tickToSqrtPrice.
|
|
105
|
+
* Consider importing tickToSqrtPrice directly for new code.
|
|
103
106
|
*/
|
|
104
107
|
export declare function tickToSqrtRatio(tick: number): BigNumber;
|
|
108
|
+
/**
|
|
109
|
+
* Convert a price to tick (Uniswap V3 math)
|
|
110
|
+
*
|
|
111
|
+
* Calculates the tick index from a price using the Uniswap V3 formula.
|
|
112
|
+
* Formula: tick = log_1.0001(price)
|
|
113
|
+
*
|
|
114
|
+
* Converts a human-readable price (e.g., "0.95", "1.05") to its corresponding
|
|
115
|
+
* Uniswap V3 tick index. Uses logarithmic calculation directly, WITHOUT Q96
|
|
116
|
+
* scaling (Q96 is only used for on-chain sqrtPrice encoding, not for human prices).
|
|
117
|
+
*
|
|
118
|
+
* @param price The price value to convert to a tick
|
|
119
|
+
* @returns Tick index (can be negative or positive)
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const tick = priceToTick('1.5'); // Convert price 1.5 to tick
|
|
124
|
+
* const tickFloor = Math.floor(priceToTick('0.99')); // Round down for tickLower
|
|
125
|
+
* const tickCeil = Math.ceil(priceToTick('1.01')); // Round up for tickUpper
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export declare function priceToTick(price: string | number | BigNumber): number;
|
|
105
129
|
/**
|
|
106
130
|
* Invert a price (calculate 1 / price)
|
|
107
131
|
*
|
|
@@ -261,4 +285,56 @@ export declare function increaseByPercentage(value: string | number | BigNumber,
|
|
|
261
285
|
* ```
|
|
262
286
|
*/
|
|
263
287
|
export declare function decreaseByPercentage(value: string | number | BigNumber, percentage: number): BigNumber;
|
|
288
|
+
/**
|
|
289
|
+
* Validates that BigNumber values are strictly positive (> 0).
|
|
290
|
+
*
|
|
291
|
+
* Throws an error if any value is zero or negative. Provides clear error messages
|
|
292
|
+
* with parameter indices for debugging.
|
|
293
|
+
*
|
|
294
|
+
* @param values The values to validate
|
|
295
|
+
* @throws Error if any value is not positive
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* requirePositive(liquidity, amountIn); // Throws if either is <= 0
|
|
300
|
+
* requirePositive(amount); // Single value validation
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export declare function requirePositive(...values: BigNumber[]): void;
|
|
304
|
+
/**
|
|
305
|
+
* Validates that BigNumber values are non-negative (>= 0).
|
|
306
|
+
*
|
|
307
|
+
* Throws an error if any value is negative. Allows zero values, unlike requirePositive.
|
|
308
|
+
* Useful for optional amounts that default to zero.
|
|
309
|
+
*
|
|
310
|
+
* @param values The values to validate
|
|
311
|
+
* @throws Error if any value is negative
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* requireNonNegative(fees, collectedFees); // Allows zero but not negative
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
export declare function requireNonNegative(...values: BigNumber[]): void;
|
|
319
|
+
/**
|
|
320
|
+
* Validates a BigNumber with a custom parameter name and optional context.
|
|
321
|
+
*
|
|
322
|
+
* Provides descriptive error messages for better debugging in specific use cases.
|
|
323
|
+
* Throws an error if value is not positive (> 0).
|
|
324
|
+
*
|
|
325
|
+
* @param value The value to validate
|
|
326
|
+
* @param paramName The parameter name for the error message
|
|
327
|
+
* @param context Optional additional context (e.g., "for swap operation")
|
|
328
|
+
* @throws Error with descriptive message if value is not positive
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* ```typescript
|
|
332
|
+
* requirePositiveWithContext(amount, 'amountIn', 'for swap');
|
|
333
|
+
* // Throws: "amountIn must be positive for swap, got: 0"
|
|
334
|
+
*
|
|
335
|
+
* requirePositiveWithContext(liquidity, 'liquidity');
|
|
336
|
+
* // Throws: "liquidity must be positive, got: -1"
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export declare function requirePositiveWithContext(value: BigNumber, paramName: string, context?: string): void;
|
|
264
340
|
//# sourceMappingURL=bignumber-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bignumber-helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/bignumber-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,EACrD,YAAY,GAAE,MAAM,GAAG,MAAY,GAClC,SAAS,CAKX;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,SAAS,EACrD,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAER;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,+BAA+B,CAC7C,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAC5C,iBAAiB,GAAE,MAAa,GAC/B,SAAS,CAIX;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,MAAa,GAAG,SAAS,CAE3E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAGvD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,CAWtE;AAED;;;;;;;;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AgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,UAAU,EAAE,MAAM,GACjB,SAAS,CAEX;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,EAClC,UAAU,EAAE,MAAM,GACjB,SAAS,CAEX;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAqB5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAqB/D;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,EAChB,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAmBN"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
/**
|
|
3
|
+
* Singleton BigNumber cache for performance optimization.
|
|
4
|
+
*
|
|
5
|
+
* Caches BigNumber instances to avoid repeated parsing of the same values.
|
|
6
|
+
* Typical savings: 2-5ms per swap operation by reusing instances.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Use pre-cached constants
|
|
11
|
+
* const zero = BigNumberPoolCache.ZERO;
|
|
12
|
+
* const minLimit = BigNumberPoolCache.MIN_SQRT_RATIO;
|
|
13
|
+
*
|
|
14
|
+
* // Cache dynamic values
|
|
15
|
+
* const amount = BigNumberPoolCache.getCached('1000000');
|
|
16
|
+
* const amount2 = BigNumberPoolCache.getCached('1000000'); // Same instance!
|
|
17
|
+
*
|
|
18
|
+
* // Memory management (call periodically in long-running processes)
|
|
19
|
+
* BigNumberPoolCache.trimCache(1000); // Keep 1000 most recent entries
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
* Thread-safe for read operations (Map is thread-safe for reads).
|
|
24
|
+
* Cache grows unbounded unless trimCache() is called periodically.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/TickMath.sol | Uniswap V3 TickMath}
|
|
27
|
+
*/
|
|
28
|
+
export declare class BigNumberPoolCache {
|
|
29
|
+
/**
|
|
30
|
+
* Internal cache storage (string key → BigNumber instance)
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
private static readonly CACHE;
|
|
34
|
+
/**
|
|
35
|
+
* Pre-cached zero constant (most frequently used value)
|
|
36
|
+
* @constant
|
|
37
|
+
*/
|
|
38
|
+
static readonly ZERO: BigNumber;
|
|
39
|
+
/**
|
|
40
|
+
* Pre-cached one constant (used in arithmetic operations)
|
|
41
|
+
* @constant
|
|
42
|
+
*/
|
|
43
|
+
static readonly ONE: BigNumber;
|
|
44
|
+
/**
|
|
45
|
+
* Fee denominator for Uniswap V3 (1,000,000 = 1,000,000 pips)
|
|
46
|
+
* Used for fee calculations: actualFee = feeAmount / FEE_PIPS
|
|
47
|
+
* @constant
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Calculate 0.3% fee (3000 fee tier)
|
|
51
|
+
* const fee = new BigNumber(3000).div(BigNumberPoolCache.FEE_PIPS);
|
|
52
|
+
* // fee = 0.003 (0.3%)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
static readonly FEE_PIPS: BigNumber;
|
|
56
|
+
/**
|
|
57
|
+
* Minimum sqrt price ratio (corresponds to tick -887272)
|
|
58
|
+
* Uniswap V3 boundary: sqrtPriceX96 cannot go below this value
|
|
59
|
+
* @constant
|
|
60
|
+
* @see {@link https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/TickMath.sol#L10 | Uniswap V3 MIN_TICK}
|
|
61
|
+
*/
|
|
62
|
+
static readonly MIN_SQRT_RATIO: BigNumber;
|
|
63
|
+
/**
|
|
64
|
+
* Maximum sqrt price ratio (corresponds to tick 887272)
|
|
65
|
+
* Uniswap V3 boundary: sqrtPriceX96 cannot exceed this value
|
|
66
|
+
* @constant
|
|
67
|
+
* @see {@link https://github.com/Uniswap/v3-core/blob/main/contracts/libraries/TickMath.sol#L13 | Uniswap V3 MAX_TICK}
|
|
68
|
+
*/
|
|
69
|
+
static readonly MAX_SQRT_RATIO: BigNumber;
|
|
70
|
+
/**
|
|
71
|
+
* Get or create cached BigNumber instance.
|
|
72
|
+
*
|
|
73
|
+
* Returns the same instance for identical values (referential equality).
|
|
74
|
+
* Avoids redundant parsing overhead for frequently used values.
|
|
75
|
+
*
|
|
76
|
+
* @param value - Numeric value (string or number)
|
|
77
|
+
* @returns Cached BigNumber instance
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const a = BigNumberPoolCache.getCached('1000');
|
|
82
|
+
* const b = BigNumberPoolCache.getCached('1000');
|
|
83
|
+
* console.log(a === b); // true (same instance)
|
|
84
|
+
*
|
|
85
|
+
* const c = BigNumberPoolCache.getCached(1000);
|
|
86
|
+
* console.log(a === c); // true (number coerced to string key)
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @remarks
|
|
90
|
+
* - Keys are normalized to strings via `.toString()`
|
|
91
|
+
* - Cache grows unbounded unless `trimCache()` is called
|
|
92
|
+
* - O(1) lookup complexity (Map hash table)
|
|
93
|
+
*/
|
|
94
|
+
static getCached(value: string | number): BigNumber;
|
|
95
|
+
/**
|
|
96
|
+
* Clear the entire cache (removes all entries).
|
|
97
|
+
*
|
|
98
|
+
* Pre-cached constants (ZERO, ONE, etc.) remain unaffected as they
|
|
99
|
+
* are static properties, not cache entries.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* BigNumberPoolCache.clearCache();
|
|
104
|
+
* console.log(BigNumberPoolCache.getCacheStats().size); // 0
|
|
105
|
+
*
|
|
106
|
+
* // Constants still work
|
|
107
|
+
* console.log(BigNumberPoolCache.ZERO.toString()); // "0"
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @remarks
|
|
111
|
+
* Use sparingly as it discards all cached performance benefits.
|
|
112
|
+
* Prefer `trimCache()` for periodic memory management.
|
|
113
|
+
*/
|
|
114
|
+
static clearCache(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Get cache statistics for monitoring and debugging.
|
|
117
|
+
*
|
|
118
|
+
* @returns Object containing cache size and entry keys
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```typescript
|
|
122
|
+
* const stats = BigNumberPoolCache.getCacheStats();
|
|
123
|
+
* console.log(`Cache size: ${stats.size}`);
|
|
124
|
+
* console.log(`Keys: ${stats.entries.join(', ')}`);
|
|
125
|
+
* ```
|
|
126
|
+
*
|
|
127
|
+
* @remarks
|
|
128
|
+
* Useful for performance profiling and memory leak detection.
|
|
129
|
+
*/
|
|
130
|
+
static getCacheStats(): {
|
|
131
|
+
size: number;
|
|
132
|
+
entries: string[];
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Trim cache to maximum size (FIFO eviction strategy).
|
|
136
|
+
*
|
|
137
|
+
* Keeps the N most recently inserted entries, removes oldest entries.
|
|
138
|
+
* Designed for long-running processes (arbitrage bots, market makers).
|
|
139
|
+
*
|
|
140
|
+
* @param maxSize - Maximum cache entries to retain (default: 1000)
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* // Arbitrage bot memory management pattern
|
|
145
|
+
* let swapCount = 0;
|
|
146
|
+
* async function executeSwap(params: SwapParams) {
|
|
147
|
+
* // ... swap logic using cached BigNumbers ...
|
|
148
|
+
*
|
|
149
|
+
* swapCount++;
|
|
150
|
+
* if (swapCount % 100 === 0) {
|
|
151
|
+
* BigNumberPoolCache.trimCache(1000); // Keep 1000 hot values
|
|
152
|
+
* }
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
156
|
+
* @remarks
|
|
157
|
+
* - Evicts oldest entries first (Map insertion order preserved)
|
|
158
|
+
* - Recommended maxSize: 500-2000 for typical trading bots
|
|
159
|
+
* - Call after every 100-500 operations in hot loops
|
|
160
|
+
* - Does not affect pre-cached constants
|
|
161
|
+
*/
|
|
162
|
+
static trimCache(maxSize?: number): void;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Default export for convenience
|
|
166
|
+
* @see {@link BigNumberPoolCache}
|
|
167
|
+
*/
|
|
168
|
+
export default BigNumberPoolCache;
|
|
169
|
+
//# sourceMappingURL=bignumber-pool-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bignumber-pool-cache.d.ts","sourceRoot":"","sources":["../../../src/utils/bignumber-pool-cache.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,kBAAkB;IAC7B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAqC;IAElE;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,YAAoB;IAExC;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAG,YAAoB;IAEvC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAQ,YAA0B;IAElD;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,YAA+B;IAE7D;;;;;OAKG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,YAE5B;IAEF;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAUnD;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,UAAU,IAAI,IAAI;IAIzB;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,aAAa,IAAI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE;IAO3D;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,GAAE,MAAa,GAAG,IAAI;CAU/C;AAED;;;GAGG;AACH,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bondingCurveCalculations.d.ts","sourceRoot":"","sources":["../../../src/utils/bondingCurveCalculations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGjE;;;;;;;GAOG;AACH,qBAAa,sBAAsB;IACjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,qBAAqB,CAC1B,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,GACpB,uBAAuB;IA+B1B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,sBAAsB,CAC3B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,GACpB,uBAAuB;IA+B1B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,MAAM,CAAC,sBAAsB,CAC3B,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,uBAAuB;IAqC1B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,CAAC,uBAAuB,CAC5B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,uBAAuB;IAuC1B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO;CAIvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cacheWarmingHelpers.d.ts","sourceRoot":"","sources":["../../../src/utils/cacheWarmingHelpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,uCAAuC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wEAAwE;IACxE,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,wEAAwE;IACxE,gCAAgC,CAAC,EAAE,MAAM,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,kBAAkB,EACxB,MAAM,CAAC,EAAE;IAAE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAC5C,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CA2C/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,kBAAkB,CAW/E"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composite Pool Data Converter
|
|
3
|
+
*
|
|
4
|
+
* Converts raw GalaChain GetCompositePool API responses into properly
|
|
5
|
+
* typed objects with BigNumber conversions for offline calculations.
|
|
6
|
+
*
|
|
7
|
+
* Ported from offline-quote-example/quote-local.mjs createCompositePoolDtoFromResponse()
|
|
8
|
+
*
|
|
9
|
+
* ## Runtime Validation Strategy for Type Assertions
|
|
10
|
+
*
|
|
11
|
+
* This module uses strategic `as any` type assertions to work around dependency
|
|
12
|
+
* version conflicts between @gala-chain/api and @gala-chain/dex. To mitigate
|
|
13
|
+
* risks from type assertions, we employ the following validation strategy:
|
|
14
|
+
*
|
|
15
|
+
* ### Type Assertion Patterns Used
|
|
16
|
+
* 1. **TokenBalance Construction** (lines 78-79, 82-83)
|
|
17
|
+
* - Assertion: `new TokenBalance(data as any)`
|
|
18
|
+
* - Reason: SDK may have different @gala-chain/api version than @gala-chain/dex
|
|
19
|
+
* - Runtime Validation: BigNumber.js validates numeric conversions on line 79
|
|
20
|
+
*
|
|
21
|
+
* 2. **TickData Property Assignment** (lines 67-72)
|
|
22
|
+
* - Assertion: `(tickDataInstance as any).propertyName = value`
|
|
23
|
+
* - Reason: TickData constructor only accepts 2 params; properties are set after
|
|
24
|
+
* - Runtime Validation: All values are either boolean or BigNumber conversions
|
|
25
|
+
*
|
|
26
|
+
* 3. **CompositePoolDto Construction** (lines 87-91)
|
|
27
|
+
* - Assertion: `token0Balance as any` and `token1Balance as any`
|
|
28
|
+
* - Reason: TokenBalance versions may differ between dependencies
|
|
29
|
+
* - Runtime Validation: BigNumber.js automatically validates during conversions
|
|
30
|
+
*
|
|
31
|
+
* ### Validation Guarantees
|
|
32
|
+
* - **Numeric Conversions**: BigNumber.js throws when parsing invalid numbers (NaN checks)
|
|
33
|
+
* - **Object Construction**: Pool, TickData, TokenBalance throw on constructor errors
|
|
34
|
+
* - **Property Access**: Type assertions limited to isolated property assignments
|
|
35
|
+
* - **API Contract**: Response structure validated via TypeScript type inference
|
|
36
|
+
*
|
|
37
|
+
* ### When This Strategy Breaks
|
|
38
|
+
* If API response structure changes or contains unexpected data types, errors
|
|
39
|
+
* will occur during BigNumber conversion or object construction with clear
|
|
40
|
+
* error messages indicating what data was invalid.
|
|
41
|
+
*
|
|
42
|
+
* @packageDocumentation
|
|
43
|
+
*/
|
|
44
|
+
import { CompositePoolDto } from '@gala-chain/dex';
|
|
45
|
+
import type { GetCompositePoolResponse, CompositePoolDataResult } from '../types/composite-pool.dto';
|
|
46
|
+
/**
|
|
47
|
+
* Convert GetCompositePool API response to CompositePoolDto
|
|
48
|
+
*
|
|
49
|
+
* Critical conversions:
|
|
50
|
+
* - All numeric string fields → BigNumber
|
|
51
|
+
* - Raw tick data → TickData instances
|
|
52
|
+
* - Raw balances → TokenBalance instances
|
|
53
|
+
*
|
|
54
|
+
* ## BigNumber Precision Strategy
|
|
55
|
+
*
|
|
56
|
+
* All numeric fields are converted to BigNumber.js for arbitrary precision arithmetic.
|
|
57
|
+
* This is critical for DeFi operations where precision loss causes calculation errors.
|
|
58
|
+
*
|
|
59
|
+
* **Key Fields Converted:**
|
|
60
|
+
* - Pool properties: sqrtPrice, grossPoolLiquidity, liquidity, feeGrowthGlobal0/1, protocolFees, maxLiquidityPerTick
|
|
61
|
+
* - Tick data: liquidityNet, liquidityGross, feeGrowthOutside0/1
|
|
62
|
+
* - Token balances: quantity field
|
|
63
|
+
*
|
|
64
|
+
* **Precision Characteristics:**
|
|
65
|
+
* - BigNumber.js maintains arbitrary precision (no floating-point errors)
|
|
66
|
+
* - Supports numbers beyond JavaScript's safe integer limit (2^53-1)
|
|
67
|
+
* - Suitable for token amounts with 18+ decimals (GALA, GUSDC, etc.)
|
|
68
|
+
* - No rounding errors in conversions between formats
|
|
69
|
+
*
|
|
70
|
+
* **Use Cases:**
|
|
71
|
+
* - Bonding curve calculations (exponential formulas)
|
|
72
|
+
* - Swap quote computations (multiplication/division intensive)
|
|
73
|
+
* - Tick-based liquidity calculations (high precision required)
|
|
74
|
+
* - Multi-step DeFi operations (error accumulation must be prevented)
|
|
75
|
+
*
|
|
76
|
+
* @param responseData Raw API response data
|
|
77
|
+
* @returns Fully typed CompositePoolDto with BigNumber conversions
|
|
78
|
+
* @throws Error if response data is invalid or missing required fields
|
|
79
|
+
*
|
|
80
|
+
* @example Offline quote calculation with BigNumber precision
|
|
81
|
+
* ```typescript
|
|
82
|
+
* const response = await axios.post(GCP_URL, getCompositePoolDto);
|
|
83
|
+
* const compositePool = createCompositePoolDtoFromResponse(response.data.Data);
|
|
84
|
+
*
|
|
85
|
+
* // All numeric values are BigNumber instances
|
|
86
|
+
* const sqrtPrice = compositePool.pool.sqrtPrice; // BigNumber - no precision loss
|
|
87
|
+
* const liquidity = compositePool.pool.liquidity; // BigNumber - preserves full precision
|
|
88
|
+
*
|
|
89
|
+
* // Safe calculations without floating-point errors
|
|
90
|
+
* const calculatedAmount = liquidity.times(sqrtPrice).dividedBy(someNumber);
|
|
91
|
+
* // Result is still BigNumber with full precision
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example Accessing pool data safely
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const pool = compositePool.pool;
|
|
97
|
+
*
|
|
98
|
+
* // All these are BigNumber instances - safe for math operations
|
|
99
|
+
* console.log(pool.sqrtPrice.toString()); // Full precision string representation
|
|
100
|
+
* console.log(pool.liquidity.toFixed(0)); // Fixed decimal format
|
|
101
|
+
* console.log(pool.feeGrowthGlobal0.multipliedBy(2)); // Precise multiplication
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* RUNTIME VALIDATION NOTES:
|
|
106
|
+
* This function uses `as any` type assertions only where necessary for dependency
|
|
107
|
+
* compatibility. All type assertions are followed by runtime validation through:
|
|
108
|
+
* - BigNumber construction (throws on NaN or invalid numbers)
|
|
109
|
+
* - Object instantiation (Pool, TickData, TokenBalance throw on errors)
|
|
110
|
+
* - Numeric field assignments (guaranteed via BigNumber.js precision)
|
|
111
|
+
*/
|
|
112
|
+
export declare function createCompositePoolDtoFromResponse(responseData: GetCompositePoolResponse['Data']): CompositePoolDto;
|
|
113
|
+
/**
|
|
114
|
+
* Wrap CompositePoolDto with additional metadata
|
|
115
|
+
*
|
|
116
|
+
* @param compositePoolDto Converted CompositePoolDto
|
|
117
|
+
* @param rawResponse Raw response data for reference
|
|
118
|
+
* @returns CompositePoolDataResult with full metadata
|
|
119
|
+
*/
|
|
120
|
+
export declare function wrapCompositePoolData(compositePoolDto: CompositePoolDto, _rawResponse: GetCompositePoolResponse['Data']): CompositePoolDataResult;
|
|
121
|
+
//# sourceMappingURL=composite-pool-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-pool-converter.d.ts","sourceRoot":"","sources":["../../../src/utils/composite-pool-converter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAEH,OAAO,EAAkB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAInE,OAAO,KAAK,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAErG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AACH;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAChD,YAAY,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAC7C,gBAAgB,CA8ElB;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,gBAAgB,EAClC,YAAY,EAAE,wBAAwB,CAAC,MAAM,CAAC,GAC7C,uBAAuB,CAazB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/date-utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,EAC5C,QAAQ,CAAC,EAAE,IAAI,GACd,IAAI,CA2BN;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACjD,QAAQ,CAAC,EAAE,IAAI,GACd,IAAI,EAAE,CAER;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UA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AAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAoBA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE;QACT,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,OAAO,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAOA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMpE"}
|
|
@@ -389,4 +389,90 @@ export declare class GSwapPositionError extends Error {
|
|
|
389
389
|
*/
|
|
390
390
|
constructor(message: string, originalError: unknown, code?: string | undefined);
|
|
391
391
|
}
|
|
392
|
+
/**
|
|
393
|
+
* Error thrown when DEX quote operations fail
|
|
394
|
+
*
|
|
395
|
+
* This error is thrown during DEX quote calculations (local and external),
|
|
396
|
+
* composite pool data fetching, and related operations. It captures the
|
|
397
|
+
* operation context for debugging and recovery.
|
|
398
|
+
*
|
|
399
|
+
* @example Quote calculation failure
|
|
400
|
+
* ```typescript
|
|
401
|
+
* throw new DexQuoteError(
|
|
402
|
+
* 'Failed to calculate quote for GALA/BENE swap',
|
|
403
|
+
* {
|
|
404
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
405
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
406
|
+
* amount: '1000'
|
|
407
|
+
* }
|
|
408
|
+
* );
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @example Catching quote errors
|
|
412
|
+
* ```typescript
|
|
413
|
+
* try {
|
|
414
|
+
* const quote = await sdk.calculateDexPoolQuoteExactAmountLocal({
|
|
415
|
+
* compositePoolData: composite,
|
|
416
|
+
* fromToken: 'GALA|Unit|none|none',
|
|
417
|
+
* toToken: 'Token|Unit|BENE|client:123',
|
|
418
|
+
* amount: '1000'
|
|
419
|
+
* });
|
|
420
|
+
* } catch (error) {
|
|
421
|
+
* if (error instanceof DexQuoteError) {
|
|
422
|
+
* console.log(`Quote failed: ${error.message}`);
|
|
423
|
+
* if (error.context) {
|
|
424
|
+
* console.log(`Tokens: ${error.context.fromToken} → ${error.context.toToken}`);
|
|
425
|
+
* }
|
|
426
|
+
* }
|
|
427
|
+
* }
|
|
428
|
+
* ```
|
|
429
|
+
*/
|
|
430
|
+
export declare class DexQuoteError extends ValidationError {
|
|
431
|
+
context?: any | undefined;
|
|
432
|
+
/**
|
|
433
|
+
* Creates a new DexQuoteError
|
|
434
|
+
*
|
|
435
|
+
* @param message - Human-readable error message describing what failed
|
|
436
|
+
* @param context - Optional context object with operation details (tokens, amounts, etc.)
|
|
437
|
+
*/
|
|
438
|
+
constructor(message: string, context?: any | undefined);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* Error thrown when a DEX pool is not found
|
|
442
|
+
*
|
|
443
|
+
* This error is thrown when attempting to access or fetch data for a DEX pool
|
|
444
|
+
* that does not exist, typically during composite pool data retrieval or pool
|
|
445
|
+
* discovery operations.
|
|
446
|
+
*
|
|
447
|
+
* @example Pool not found
|
|
448
|
+
* ```typescript
|
|
449
|
+
* throw new DexPoolNotFoundError(
|
|
450
|
+
* 'Pool not found: GALA/BENE with fee 3000'
|
|
451
|
+
* );
|
|
452
|
+
* ```
|
|
453
|
+
*
|
|
454
|
+
* @example Catching pool not found errors
|
|
455
|
+
* ```typescript
|
|
456
|
+
* try {
|
|
457
|
+
* const composite = await sdk.fetchCompositePoolData({
|
|
458
|
+
* token0: 'GALA|Unit|none|none',
|
|
459
|
+
* token1: 'Token|Unit|BENE|client:123',
|
|
460
|
+
* fee: 3000
|
|
461
|
+
* });
|
|
462
|
+
* } catch (error) {
|
|
463
|
+
* if (error instanceof DexPoolNotFoundError) {
|
|
464
|
+
* console.log('Pool does not exist. Create it first with liquidity.');
|
|
465
|
+
* // Implement pool creation or alternative routing
|
|
466
|
+
* }
|
|
467
|
+
* }
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
export declare class DexPoolNotFoundError extends ValidationError {
|
|
471
|
+
/**
|
|
472
|
+
* Creates a new DexPoolNotFoundError
|
|
473
|
+
*
|
|
474
|
+
* @param message - Human-readable error message describing which pool was not found
|
|
475
|
+
*/
|
|
476
|
+
constructor(message: string);
|
|
477
|
+
}
|
|
392
478
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IAU/B,KAAK,CAAC,EAAE,MAAM;IACd,IAAI,CAAC,EAAE,MAAM;IAVtB;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,KAAK,CAAC,EAAE,MAAM,YAAA,EACd,IAAI,CAAC,EAAE,MAAM,YAAA;CAKvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,YAAa,SAAQ,KAAK;IAU5B,UAAU,CAAC,EAAE,MAAM;IACnB,aAAa,CAAC,EAAE,KAAK;IAV9B;;;;;;OAMG;gBAED,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA,EACnB,aAAa,CAAC,EAAE,KAAK,YAAA;CAK/B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IASlC,KAAK,CAAC,EAAE,MAAM;IARvB;;;;;OAKG;gBAED,OAAO,EAAE,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