@gala-chain/launchpad-mcp-server 5.0.5-beta.2 → 5.0.5-beta.9
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/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/prompts/advanced-pools.d.ts +1 -7
- package/dist/prompts/advanced-pools.d.ts.map +1 -1
- package/dist/prompts/advanced-pools.js +4 -79
- package/dist/prompts/advanced-pools.js.map +1 -1
- package/dist/prompts/analysis.d.ts +0 -4
- package/dist/prompts/analysis.d.ts.map +1 -1
- package/dist/prompts/analysis.js +2 -67
- package/dist/prompts/analysis.js.map +1 -1
- package/dist/prompts/balances.js.map +1 -1
- package/dist/prompts/bridge.d.ts +0 -8
- package/dist/prompts/bridge.d.ts.map +1 -1
- package/dist/prompts/bridge.js +3 -54
- package/dist/prompts/bridge.js.map +1 -1
- package/dist/prompts/comments.js.map +1 -1
- package/dist/prompts/factories/filtered-list-prompt-factory.js.map +1 -1
- package/dist/prompts/factories/invite-management-factory.js +2 -2
- package/dist/prompts/factories/invite-management-factory.js.map +1 -1
- package/dist/prompts/liquidity-positions.d.ts +0 -12
- package/dist/prompts/liquidity-positions.d.ts.map +1 -1
- package/dist/prompts/liquidity-positions.js +2 -98
- package/dist/prompts/liquidity-positions.js.map +1 -1
- package/dist/prompts/manifest.d.ts +33 -0
- package/dist/prompts/manifest.d.ts.map +1 -0
- package/dist/prompts/manifest.js +2062 -0
- package/dist/prompts/manifest.js.map +1 -0
- package/dist/prompts/overseers.d.ts.map +1 -1
- package/dist/prompts/overseers.js +17 -2
- package/dist/prompts/overseers.js.map +1 -1
- package/dist/prompts/pools.d.ts +0 -20
- package/dist/prompts/pools.d.ts.map +1 -1
- package/dist/prompts/pools.js +4 -162
- package/dist/prompts/pools.js.map +1 -1
- package/dist/prompts/referrals.js.map +1 -1
- package/dist/prompts/trading.d.ts +0 -8
- package/dist/prompts/trading.d.ts.map +1 -1
- package/dist/prompts/trading.js +3 -51
- package/dist/prompts/trading.js.map +1 -1
- package/dist/prompts/utility-tools.js.map +1 -1
- package/dist/prompts/utils/pagination-helpers.d.ts +10 -24
- package/dist/prompts/utils/pagination-helpers.d.ts.map +1 -1
- package/dist/prompts/utils/pagination-helpers.js +11 -32
- package/dist/prompts/utils/pagination-helpers.js.map +1 -1
- package/dist/prompts/utils/workflowTemplates.d.ts.map +1 -1
- package/dist/prompts/utils/workflowTemplates.js +4 -2
- package/dist/prompts/utils/workflowTemplates.js.map +1 -1
- package/dist/prompts/validate-manifest.d.ts +42 -0
- package/dist/prompts/validate-manifest.d.ts.map +1 -0
- package/dist/prompts/validate-manifest.js +157 -0
- package/dist/prompts/validate-manifest.js.map +1 -0
- package/dist/schemas/common-schemas.d.ts +32 -39
- package/dist/schemas/common-schemas.d.ts.map +1 -1
- package/dist/schemas/common-schemas.js +109 -116
- package/dist/schemas/common-schemas.js.map +1 -1
- package/dist/scripts/test-all-prompts.d.ts +1 -17
- package/dist/scripts/test-all-prompts.d.ts.map +1 -1
- package/dist/scripts/test-all-prompts.js +16 -6
- package/dist/scripts/test-all-prompts.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/setup.d.ts +7 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +33 -0
- package/dist/setup.js.map +1 -0
- package/dist/tools/api-keys/index.js +13 -13
- package/dist/tools/api-keys/index.js.map +1 -1
- package/dist/tools/auth/index.js +4 -4
- package/dist/tools/auth/index.js.map +1 -1
- package/dist/tools/balance/helpers/format-balance.js +1 -1
- package/dist/tools/balance/helpers/format-balance.js.map +1 -1
- package/dist/tools/balance/index.js +9 -9
- package/dist/tools/balance/index.js.map +1 -1
- package/dist/tools/ban/index.d.ts.map +1 -1
- package/dist/tools/ban/index.js +23 -18
- package/dist/tools/ban/index.js.map +1 -1
- package/dist/tools/ban/onBanEnforcement.d.ts +9 -0
- package/dist/tools/ban/onBanEnforcement.d.ts.map +1 -0
- package/dist/tools/ban/onBanEnforcement.js +54 -0
- package/dist/tools/ban/onBanEnforcement.js.map +1 -0
- package/dist/tools/bridge/helpers/external-chain-balance-tools.js +4 -4
- package/dist/tools/bridge/helpers/external-chain-balance-tools.js.map +1 -1
- package/dist/tools/bridge/index.d.ts +10 -0
- package/dist/tools/bridge/index.d.ts.map +1 -1
- package/dist/tools/bridge/index.js +47 -39
- package/dist/tools/bridge/index.js.map +1 -1
- package/dist/tools/chat/index.d.ts +3 -2
- package/dist/tools/chat/index.d.ts.map +1 -1
- package/dist/tools/chat/index.js +12 -18
- package/dist/tools/chat/index.js.map +1 -1
- package/dist/tools/chat/pinChatMessage.js +2 -2
- package/dist/tools/chat/pinChatMessage.js.map +1 -1
- package/dist/tools/chat/unpinChatMessage.js +1 -1
- package/dist/tools/chat/unpinChatMessage.js.map +1 -1
- package/dist/tools/chat-messages/index.js +11 -11
- package/dist/tools/chat-messages/index.js.map +1 -1
- package/dist/tools/comments/index.d.ts +1 -1
- package/dist/tools/comments/index.d.ts.map +1 -1
- package/dist/tools/comments/index.js +13 -11
- package/dist/tools/comments/index.js.map +1 -1
- package/dist/tools/comments/onCommentCreated.d.ts +9 -0
- package/dist/tools/comments/onCommentCreated.d.ts.map +1 -0
- package/dist/tools/comments/onCommentCreated.js +50 -0
- package/dist/tools/comments/onCommentCreated.js.map +1 -0
- package/dist/tools/content-flags/index.js +14 -14
- package/dist/tools/content-flags/index.js.map +1 -1
- package/dist/tools/content-reactions/index.js +6 -6
- package/dist/tools/content-reactions/index.js.map +1 -1
- package/dist/tools/creation/index.js +14 -14
- package/dist/tools/creation/index.js.map +1 -1
- package/dist/tools/dex/helpers.d.ts +1 -1
- package/dist/tools/dex/helpers.js +1 -1
- package/dist/tools/dex/index.js +9 -9
- package/dist/tools/dex/index.js.map +1 -1
- package/dist/tools/dex-analytics/index.d.ts.map +1 -1
- package/dist/tools/dex-analytics/index.js +6 -6
- package/dist/tools/dex-analytics/index.js.map +1 -1
- package/dist/tools/dex-liquidity/index.d.ts.map +1 -1
- package/dist/tools/dex-liquidity/index.js +30 -30
- package/dist/tools/dex-liquidity/index.js.map +1 -1
- package/dist/tools/dex-pools/index.d.ts.map +1 -1
- package/dist/tools/dex-pools/index.js +17 -18
- package/dist/tools/dex-pools/index.js.map +1 -1
- package/dist/tools/handler-factories.d.ts +22 -48
- package/dist/tools/handler-factories.d.ts.map +1 -1
- package/dist/tools/handler-factories.js +15 -35
- package/dist/tools/handler-factories.js.map +1 -1
- package/dist/tools/holders/index.d.ts +55 -0
- package/dist/tools/holders/index.d.ts.map +1 -0
- package/dist/tools/holders/index.js +269 -0
- package/dist/tools/holders/index.js.map +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +86 -65
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/manifest.d.ts +33 -0
- package/dist/tools/manifest.d.ts.map +1 -0
- package/dist/tools/manifest.js +2945 -0
- package/dist/tools/manifest.js.map +1 -0
- package/dist/tools/messages/createMessage.d.ts +16 -0
- package/dist/tools/messages/createMessage.d.ts.map +1 -0
- package/dist/tools/messages/createMessage.js +79 -0
- package/dist/tools/messages/createMessage.js.map +1 -0
- package/dist/tools/messages/deleteMessage.d.ts +16 -0
- package/dist/tools/messages/deleteMessage.d.ts.map +1 -0
- package/dist/tools/messages/deleteMessage.js +45 -0
- package/dist/tools/messages/deleteMessage.js.map +1 -0
- package/dist/tools/messages/fetchMessages.d.ts +17 -0
- package/dist/tools/messages/fetchMessages.d.ts.map +1 -0
- package/dist/tools/messages/fetchMessages.js +82 -0
- package/dist/tools/messages/fetchMessages.js.map +1 -0
- package/dist/tools/messages/getPinnedMessage.d.ts +15 -0
- package/dist/tools/messages/getPinnedMessage.d.ts.map +1 -0
- package/dist/tools/messages/getPinnedMessage.js +42 -0
- package/dist/tools/messages/getPinnedMessage.js.map +1 -0
- package/dist/tools/messages/index.d.ts +38 -0
- package/dist/tools/messages/index.d.ts.map +1 -0
- package/dist/tools/messages/index.js +56 -0
- package/dist/tools/messages/index.js.map +1 -0
- package/dist/tools/messages/pinMessage.d.ts +15 -0
- package/dist/tools/messages/pinMessage.d.ts.map +1 -0
- package/dist/tools/messages/pinMessage.js +44 -0
- package/dist/tools/messages/pinMessage.js.map +1 -0
- package/dist/tools/messages/unpinMessage.d.ts +15 -0
- package/dist/tools/messages/unpinMessage.d.ts.map +1 -0
- package/dist/tools/messages/unpinMessage.js +43 -0
- package/dist/tools/messages/unpinMessage.js.map +1 -0
- package/dist/tools/messages/updateMessage.d.ts +16 -0
- package/dist/tools/messages/updateMessage.d.ts.map +1 -0
- package/dist/tools/messages/updateMessage.js +55 -0
- package/dist/tools/messages/updateMessage.js.map +1 -0
- package/dist/tools/moderators/getActiveModerators.d.ts +10 -0
- package/dist/tools/moderators/getActiveModerators.d.ts.map +1 -0
- package/dist/tools/moderators/getActiveModerators.js +44 -0
- package/dist/tools/moderators/getActiveModerators.js.map +1 -0
- package/dist/tools/moderators/index.d.ts.map +1 -1
- package/dist/tools/moderators/index.js +25 -17
- package/dist/tools/moderators/index.js.map +1 -1
- package/dist/tools/moderators/onModeratorChanged.d.ts +9 -0
- package/dist/tools/moderators/onModeratorChanged.d.ts.map +1 -0
- package/dist/tools/moderators/onModeratorChanged.js +49 -0
- package/dist/tools/moderators/onModeratorChanged.js.map +1 -0
- package/dist/tools/nft/index.js +21 -21
- package/dist/tools/nft/index.js.map +1 -1
- package/dist/tools/overseers/getOverseerUserSummary.js +2 -2
- package/dist/tools/overseers/getOverseerUserSummary.js.map +1 -1
- package/dist/tools/overseers/index.d.ts.map +1 -1
- package/dist/tools/overseers/index.js +26 -24
- package/dist/tools/overseers/index.js.map +1 -1
- package/dist/tools/overseers/listOverseerUsers.d.ts +1 -0
- package/dist/tools/overseers/listOverseerUsers.d.ts.map +1 -1
- package/dist/tools/overseers/listOverseerUsers.js +16 -11
- package/dist/tools/overseers/listOverseerUsers.js.map +1 -1
- package/dist/tools/pagination-handler-factory.d.ts +30 -28
- package/dist/tools/pagination-handler-factory.d.ts.map +1 -1
- package/dist/tools/pagination-handler-factory.js +42 -36
- package/dist/tools/pagination-handler-factory.js.map +1 -1
- package/dist/tools/pools/checkPoolExists.js +3 -3
- package/dist/tools/pools/checkPoolExists.js.map +1 -1
- package/dist/tools/pools/fetchAllPools.js +5 -5
- package/dist/tools/pools/fetchAllPools.js.map +1 -1
- package/dist/tools/pools/fetchAllPriceHistory.js +3 -3
- package/dist/tools/pools/fetchAllPriceHistory.js.map +1 -1
- package/dist/tools/pools/fetchPoolDetails.js +1 -1
- package/dist/tools/pools/fetchPoolDetails.js.map +1 -1
- package/dist/tools/pools/fetchPools.d.ts.map +1 -1
- package/dist/tools/pools/fetchPools.js +10 -11
- package/dist/tools/pools/fetchPools.js.map +1 -1
- package/dist/tools/pools/fetchPriceHistory.js +7 -7
- package/dist/tools/pools/fetchPriceHistory.js.map +1 -1
- package/dist/tools/pools/fetchTokenDetails.js +1 -1
- package/dist/tools/pools/fetchTokenDetails.js.map +1 -1
- package/dist/tools/pools/getPoolRealtimeState.d.ts +10 -0
- package/dist/tools/pools/getPoolRealtimeState.d.ts.map +1 -0
- package/dist/tools/pools/getPoolRealtimeState.js +45 -0
- package/dist/tools/pools/getPoolRealtimeState.js.map +1 -0
- package/dist/tools/pools/index.d.ts.map +1 -1
- package/dist/tools/pools/index.js +37 -27
- package/dist/tools/pools/index.js.map +1 -1
- package/dist/tools/pools/onDexPoolCreation.js +3 -3
- package/dist/tools/pools/onDexPoolCreation.js.map +1 -1
- package/dist/tools/pools/onHolderCountChanged.d.ts +9 -0
- package/dist/tools/pools/onHolderCountChanged.d.ts.map +1 -0
- package/dist/tools/pools/onHolderCountChanged.js +44 -0
- package/dist/tools/pools/onHolderCountChanged.js.map +1 -0
- package/dist/tools/pools/onLaunchpadTokenCreation.js +2 -2
- package/dist/tools/pools/onLaunchpadTokenCreation.js.map +1 -1
- package/dist/tools/pools/onPoolUpdated.d.ts +9 -0
- package/dist/tools/pools/onPoolUpdated.d.ts.map +1 -0
- package/dist/tools/pools/onPoolUpdated.js +44 -0
- package/dist/tools/pools/onPoolUpdated.js.map +1 -0
- package/dist/tools/pools/updateTokenConfig.d.ts +15 -0
- package/dist/tools/pools/updateTokenConfig.d.ts.map +1 -0
- package/dist/tools/pools/updateTokenConfig.js +61 -0
- package/dist/tools/pools/updateTokenConfig.js.map +1 -0
- package/dist/tools/pools/updateTokenSocials.js +9 -9
- package/dist/tools/pools/updateTokenSocials.js.map +1 -1
- package/dist/tools/pools/validateToken.d.ts +8 -0
- package/dist/tools/pools/validateToken.d.ts.map +1 -0
- package/dist/tools/pools/validateToken.js +42 -0
- package/dist/tools/pools/validateToken.js.map +1 -0
- package/dist/tools/recordings/index.d.ts +28 -0
- package/dist/tools/recordings/index.d.ts.map +1 -0
- package/dist/tools/recordings/index.js +113 -0
- package/dist/tools/recordings/index.js.map +1 -0
- package/dist/tools/referrals/index.js +9 -9
- package/dist/tools/referrals/index.js.map +1 -1
- package/dist/tools/restricted-names/getRestrictedNames.d.ts +16 -0
- package/dist/tools/restricted-names/getRestrictedNames.d.ts.map +1 -0
- package/dist/tools/restricted-names/getRestrictedNames.js +47 -0
- package/dist/tools/restricted-names/getRestrictedNames.js.map +1 -0
- package/dist/tools/restricted-names/index.d.ts +22 -0
- package/dist/tools/restricted-names/index.d.ts.map +1 -0
- package/dist/tools/restricted-names/index.js +28 -0
- package/dist/tools/restricted-names/index.js.map +1 -0
- package/dist/tools/restricted-names/updateRestrictedNames.d.ts +16 -0
- package/dist/tools/restricted-names/updateRestrictedNames.d.ts.map +1 -0
- package/dist/tools/restricted-names/updateRestrictedNames.js +56 -0
- package/dist/tools/restricted-names/updateRestrictedNames.js.map +1 -0
- package/dist/tools/simulcasts/index.d.ts +25 -0
- package/dist/tools/simulcasts/index.d.ts.map +1 -0
- package/dist/tools/simulcasts/index.js +143 -0
- package/dist/tools/simulcasts/index.js.map +1 -0
- package/dist/tools/streaming/index.d.ts +4 -37
- package/dist/tools/streaming/index.d.ts.map +1 -1
- package/dist/tools/streaming/index.js +7 -240
- package/dist/tools/streaming/index.js.map +1 -1
- package/dist/tools/streaming/setNextLiveStreamCountdown.js +2 -2
- package/dist/tools/streaming/setNextLiveStreamCountdown.js.map +1 -1
- package/dist/tools/token-ban/index.d.ts.map +1 -1
- package/dist/tools/token-ban/index.js +14 -12
- package/dist/tools/token-ban/index.js.map +1 -1
- package/dist/tools/token-ban/onTokenBanChanged.d.ts +9 -0
- package/dist/tools/token-ban/onTokenBanChanged.d.ts.map +1 -0
- package/dist/tools/token-ban/onTokenBanChanged.js +43 -0
- package/dist/tools/token-ban/onTokenBanChanged.js.map +1 -0
- package/dist/tools/tool-factory.d.ts +6 -6
- package/dist/tools/tool-factory.js +8 -8
- package/dist/tools/tool-factory.js.map +1 -1
- package/dist/tools/trades/getRecentTrades.d.ts +10 -0
- package/dist/tools/trades/getRecentTrades.d.ts.map +1 -0
- package/dist/tools/trades/getRecentTrades.js +57 -0
- package/dist/tools/trades/getRecentTrades.js.map +1 -0
- package/dist/tools/trades/index.d.ts +1 -1
- package/dist/tools/trades/index.d.ts.map +1 -1
- package/dist/tools/trades/index.js +18 -14
- package/dist/tools/trades/index.js.map +1 -1
- package/dist/tools/trades/onTradeExecuted.d.ts +9 -0
- package/dist/tools/trades/onTradeExecuted.d.ts.map +1 -0
- package/dist/tools/trades/onTradeExecuted.js +52 -0
- package/dist/tools/trades/onTradeExecuted.js.map +1 -0
- package/dist/tools/trading/helpers/arg-extractors.d.ts +5 -5
- package/dist/tools/trading/helpers/arg-extractors.d.ts.map +1 -1
- package/dist/tools/trading/helpers/arg-extractors.js +1 -1
- package/dist/tools/trading/helpers/arg-extractors.js.map +1 -1
- package/dist/tools/trading/helpers/trading-schemas.d.ts +1 -1
- package/dist/tools/trading/helpers/trading-schemas.js +13 -13
- package/dist/tools/trading/helpers/trading-schemas.js.map +1 -1
- package/dist/tools/trading/index.d.ts.map +1 -1
- package/dist/tools/trading/index.js +20 -17
- package/dist/tools/trading/index.js.map +1 -1
- package/dist/tools/transfers/index.js +2 -2
- package/dist/tools/transfers/index.js.map +1 -1
- package/dist/tools/utils/clearCache.d.ts.map +1 -1
- package/dist/tools/utils/clearCache.js +1 -1
- package/dist/tools/utils/clearCache.js.map +1 -1
- package/dist/tools/utils/explainSdkUsage.d.ts.map +1 -1
- package/dist/tools/utils/explainSdkUsage.js +171 -585
- package/dist/tools/utils/explainSdkUsage.js.map +1 -1
- package/dist/tools/utils/explainWebSocketEvents.d.ts +10 -0
- package/dist/tools/utils/explainWebSocketEvents.d.ts.map +1 -0
- package/dist/tools/utils/explainWebSocketEvents.js +97 -0
- package/dist/tools/utils/explainWebSocketEvents.js.map +1 -0
- package/dist/tools/utils/getEthereumAddressFromPrivateKey.js +1 -1
- package/dist/tools/utils/getEthereumAddressFromPrivateKey.js.map +1 -1
- package/dist/tools/utils/getEventSchema.d.ts +10 -0
- package/dist/tools/utils/getEventSchema.d.ts.map +1 -0
- package/dist/tools/utils/getEventSchema.js +168 -0
- package/dist/tools/utils/getEventSchema.js.map +1 -0
- package/dist/tools/utils/getPlatformStatus.d.ts +10 -0
- package/dist/tools/utils/getPlatformStatus.d.ts.map +1 -0
- package/dist/tools/utils/getPlatformStatus.js +35 -0
- package/dist/tools/utils/getPlatformStatus.js.map +1 -0
- package/dist/tools/utils/getPublicKeyFromPrivateKey.js +1 -1
- package/dist/tools/utils/getPublicKeyFromPrivateKey.js.map +1 -1
- package/dist/tools/utils/index.d.ts.map +1 -1
- package/dist/tools/utils/index.js +6 -0
- package/dist/tools/utils/index.js.map +1 -1
- package/dist/tools/utils/setWallet.js +1 -1
- package/dist/tools/utils/setWallet.js.map +1 -1
- package/dist/tools/utils/switchEnvironment.js +1 -1
- package/dist/tools/utils/switchEnvironment.js.map +1 -1
- package/dist/tools/validate-manifest.d.ts +35 -0
- package/dist/tools/validate-manifest.d.ts.map +1 -0
- package/dist/tools/validate-manifest.js +122 -0
- package/dist/tools/validate-manifest.js.map +1 -0
- package/dist/utils/default-values.d.ts +0 -40
- package/dist/utils/default-values.d.ts.map +1 -1
- package/dist/utils/default-values.js +2 -45
- package/dist/utils/default-values.js.map +1 -1
- package/dist/utils/handler-args.d.ts +8 -0
- package/dist/utils/handler-args.d.ts.map +1 -0
- package/dist/utils/handler-args.js +28 -0
- package/dist/utils/handler-args.js.map +1 -0
- package/package.json +10 -10
|
@@ -34,14 +34,14 @@ exports.TOPIC_METHOD_MAPPING = {
|
|
|
34
34
|
'token-distribution': ['fetchTokenDistribution', 'fetchUserHolderContext'],
|
|
35
35
|
'token-status': ['isTokenGraduated', 'onDexPoolCreation', 'onLaunchpadTokenCreation'],
|
|
36
36
|
// Portfolio Management
|
|
37
|
-
'multi-wallet': [], // Composite workflow topic
|
|
37
|
+
'multi-wallet': ['getAddress'], // Composite workflow topic
|
|
38
38
|
'transfers': ['transferGala', 'transferToken'],
|
|
39
39
|
'locks': ['lockTokens', 'unlockTokens', 'burnTokens', 'fetchLockedBalance'],
|
|
40
40
|
// DEX Trading
|
|
41
41
|
'dex-trading': ['getSwapQuoteExactInput', 'getSwapQuoteExactOutput', 'executeSwap', 'getSwapUserAssets', 'getAllSwapUserAssets', 'getSwapPoolInfo'],
|
|
42
|
-
'error-handling': [], // Cross-cutting concern
|
|
42
|
+
'error-handling': ['getBundlerTransactionResult'], // Cross-cutting concern
|
|
43
43
|
// Developer Tools
|
|
44
|
-
'installation': [], // Setup topic
|
|
44
|
+
'installation': ['getVersion'], // Setup topic
|
|
45
45
|
'local-calculations': ['calculateBuyAmountLocal', 'calculateSellAmountLocal', 'calculateBuyAmountExternal', 'calculateSellAmountExternal', 'calculateInitialBuyAmount'],
|
|
46
46
|
// Market Data
|
|
47
47
|
'price-history': ['fetchPriceHistory', 'fetchAllPriceHistory'],
|
|
@@ -65,7 +65,7 @@ exports.TOPIC_METHOD_MAPPING = {
|
|
|
65
65
|
// Event Subscriptions
|
|
66
66
|
'event-subscriptions': ['subscribeToStream', 'unsubscribeFromStream', 'onStreamStatusChanged', 'onUserBanned', 'onUserUnbanned', 'onBanEnforcement', 'onContentFlagged', 'onFlagResolved', 'onStreamChatMessage', 'onStreamChatUpdated', 'onStreamChatDeleted', 'onStreamChatPinned', 'onStreamChatUnpinned', 'onChatStatusChanged', 'onViewerCountChanged', 'onRecordingStatusChanged', 'onSimulcastStatusChanged', 'onDownloadReady', 'onUserTyping', 'onStreamReaction', 'onContentReactionAdded', 'onContentReactionRemoved', 'onStreamCountdownUpdated', 'onStreamLanguageUpdated', 'onStreamControlStatusChanged', 'onConnection', 'onAuthenticated', 'onTokenSubscribed', 'onTokenUnsubscribed', 'onRoomSubscribed', 'onRoomLeft', 'onDexPoolCreation', 'onLaunchpadTokenCreation'],
|
|
67
67
|
// MCP Integration
|
|
68
|
-
'mcp-to-sdk-mapping': [], // Composite workflow topic
|
|
68
|
+
'mcp-to-sdk-mapping': ['explainSdkUsage'], // Composite workflow topic
|
|
69
69
|
// Bridge Operations
|
|
70
70
|
'bridge-operations': [
|
|
71
71
|
'estimateBridgeFee', 'bridgeOut', 'bridgeIn', 'getBridgeStatus',
|
|
@@ -113,7 +113,7 @@ exports.TOPIC_METHOD_MAPPING = {
|
|
|
113
113
|
],
|
|
114
114
|
// Stream Chat
|
|
115
115
|
'stream-chat': [
|
|
116
|
-
'
|
|
116
|
+
'getChatStatus', 'disableChat', 'enableChat',
|
|
117
117
|
'getGlobalChatStatus', 'setGlobalChatEnabled',
|
|
118
118
|
'connectStreamWebSocket', 'authenticateStreamWebSocket', 'subscribeToStream',
|
|
119
119
|
'unsubscribeFromStream', 'sendStreamChatViaWebSocket', 'sendStreamReaction', 'disconnectStreamWebSocket',
|
|
@@ -220,10 +220,6 @@ async function buyTokens() {
|
|
|
220
220
|
type: 'native' // 'native' = GALA amount, 'exact' = token amount
|
|
221
221
|
});
|
|
222
222
|
|
|
223
|
-
console.log('Expected tokens:', calculation.amount);
|
|
224
|
-
console.log('RBC Fee:', calculation.reverseBondingCurveFee);
|
|
225
|
-
console.log('Transaction fee:', calculation.transactionFee);
|
|
226
|
-
|
|
227
223
|
// 3. Execute buy with slippage protection
|
|
228
224
|
const result = await sdk.buy({
|
|
229
225
|
tokenName: 'dragnrkti',
|
|
@@ -234,10 +230,6 @@ async function buyTokens() {
|
|
|
234
230
|
slippageToleranceFactor: 0.01 // 1% slippage tolerance (REQUIRED)
|
|
235
231
|
});
|
|
236
232
|
|
|
237
|
-
console.log('Transaction ID:', result.transactionId);
|
|
238
|
-
console.log('GALA spent:', result.inputAmount);
|
|
239
|
-
console.log('Tokens received:', result.outputAmount);
|
|
240
|
-
console.log('Total fees:', result.totalFees);
|
|
241
233
|
}
|
|
242
234
|
\`\`\`
|
|
243
235
|
|
|
@@ -266,9 +258,6 @@ async function sellTokens() {
|
|
|
266
258
|
type: 'exact' // 'exact' = exact tokens, 'native' = target GALA amount
|
|
267
259
|
});
|
|
268
260
|
|
|
269
|
-
console.log('Expected GALA:', calculation.amount);
|
|
270
|
-
console.log('RBC Fee:', calculation.reverseBondingCurveFee);
|
|
271
|
-
|
|
272
261
|
// 3. Execute sell with slippage protection
|
|
273
262
|
const result = await sdk.sell({
|
|
274
263
|
tokenName: 'dragnrkti',
|
|
@@ -279,8 +268,6 @@ async function sellTokens() {
|
|
|
279
268
|
slippageToleranceFactor: 0.01 // 1% slippage
|
|
280
269
|
});
|
|
281
270
|
|
|
282
|
-
console.log('Tokens sold:', result.inputAmount);
|
|
283
|
-
console.log('GALA received:', result.outputAmount);
|
|
284
271
|
}
|
|
285
272
|
\`\`\`
|
|
286
273
|
|
|
@@ -304,10 +291,6 @@ async function graduatePool() {
|
|
|
304
291
|
// Option 1: Calculate graduation cost first (recommended)
|
|
305
292
|
const calculation = await sdk.calculateBuyAmountForGraduation('dragnrkti');
|
|
306
293
|
|
|
307
|
-
console.log('GALA cost to graduate:', calculation.amount);
|
|
308
|
-
console.log('RBC Fee:', calculation.reverseBondingCurveFee);
|
|
309
|
-
console.log('Transaction fee:', calculation.transactionFee);
|
|
310
|
-
|
|
311
294
|
// Check if you have enough balance
|
|
312
295
|
const balance = await sdk.fetchGalaBalance();
|
|
313
296
|
// Use compareAmounts() instead of parseFloat for precision with currency amounts
|
|
@@ -321,10 +304,6 @@ async function graduatePool() {
|
|
|
321
304
|
slippageToleranceFactor: 0.01 // Optional: defaults to SDK config
|
|
322
305
|
});
|
|
323
306
|
|
|
324
|
-
console.log('Pool graduated!');
|
|
325
|
-
console.log('Transaction ID:', result.transactionId);
|
|
326
|
-
console.log('Total GALA spent:', result.inputAmount);
|
|
327
|
-
console.log('Tokens received:', result.outputAmount);
|
|
328
307
|
}
|
|
329
308
|
\`\`\`
|
|
330
309
|
|
|
@@ -367,9 +346,8 @@ async function basicPoolFetching() {
|
|
|
367
346
|
page: 1
|
|
368
347
|
});
|
|
369
348
|
|
|
370
|
-
console.log(\`Found \${pools.total} pools, page \${pools.page} of \${pools.totalPages}\`);
|
|
371
349
|
pools.pools.forEach(pool => {
|
|
372
|
-
|
|
350
|
+
|
|
373
351
|
});
|
|
374
352
|
}
|
|
375
353
|
|
|
@@ -382,7 +360,6 @@ async function fetchAllPools() {
|
|
|
382
360
|
type: 'recent'
|
|
383
361
|
});
|
|
384
362
|
|
|
385
|
-
console.log(\`Total pools: \${allPools.pools.length}\`);
|
|
386
363
|
}
|
|
387
364
|
|
|
388
365
|
// 3. POOL DETAILS - Complete information
|
|
@@ -391,10 +368,6 @@ async function getPoolDetails(tokenName) {
|
|
|
391
368
|
|
|
392
369
|
const details = await sdk.fetchPoolDetails(tokenName);
|
|
393
370
|
|
|
394
|
-
console.log('Sale status:', details.saleStatus); // 'Ongoing' or 'Completed'
|
|
395
|
-
console.log('Base price:', details.basePrice);
|
|
396
|
-
console.log('Max supply:', details.maxSupply);
|
|
397
|
-
console.log('Remaining tokens:', details.sellingTokenQuantity);
|
|
398
371
|
}
|
|
399
372
|
|
|
400
373
|
// 4. POOL DETAILS FOR CALCULATIONS - Optimized for math
|
|
@@ -404,10 +377,6 @@ async function getOptimizedPoolDetails(tokenName) {
|
|
|
404
377
|
// Returns only fields needed for bonding curve calculations
|
|
405
378
|
const poolData = await sdk.fetchPoolDetailsForCalculation(tokenName);
|
|
406
379
|
|
|
407
|
-
console.log('Current supply:', poolData.currentSupply);
|
|
408
|
-
console.log('Remaining tokens:', poolData.remainingTokens);
|
|
409
|
-
console.log('Max supply:', poolData.maxSupply);
|
|
410
|
-
console.log('Reverse bonding curve max fee:', poolData.reverseBondingCurveMaxFeeFactor);
|
|
411
380
|
}
|
|
412
381
|
|
|
413
382
|
// 5. VOLUME & OHLCV DATA - Historical candlestick data
|
|
@@ -423,7 +392,7 @@ async function getVolumeData(tokenName) {
|
|
|
423
392
|
});
|
|
424
393
|
|
|
425
394
|
volumeData.forEach(candle => {
|
|
426
|
-
|
|
395
|
+
|
|
427
396
|
});
|
|
428
397
|
}
|
|
429
398
|
|
|
@@ -434,9 +403,6 @@ async function getDexTokenPrices() {
|
|
|
434
403
|
// Fetch prices for multiple DEX tokens
|
|
435
404
|
const prices = await sdk.fetchTokenPrice(['GALA', 'SILK', 'MUSIC']);
|
|
436
405
|
|
|
437
|
-
console.log(\`GALA: $\${prices.GALA}\`);
|
|
438
|
-
console.log(\`SILK: $\${prices.SILK}\`);
|
|
439
|
-
console.log(\`MUSIC: $\${prices.MUSIC}\`);
|
|
440
406
|
}
|
|
441
407
|
|
|
442
408
|
// 7. LAUNCHPAD TOKEN SPOT PRICES (via smart router)
|
|
@@ -446,7 +412,6 @@ async function getLaunchpadTokenPrice(tokenName) {
|
|
|
446
412
|
// Get USD spot price for a launchpad token (anime, woohoo, etc.)
|
|
447
413
|
const price = await sdk.fetchTokenPrice({ tokenName });
|
|
448
414
|
|
|
449
|
-
console.log(\`\${tokenName} price: $\${price.price}\`);
|
|
450
415
|
}
|
|
451
416
|
|
|
452
417
|
// 8. RESOLVE UTILITY ADDRESSES
|
|
@@ -455,11 +420,10 @@ async function resolveAddresses(tokenName) {
|
|
|
455
420
|
|
|
456
421
|
// Get GalaChain vault address for token
|
|
457
422
|
const vaultAddress = await sdk.resolveVaultAddress(tokenName);
|
|
458
|
-
console.log(\`Vault address: \${vaultAddress}\`);
|
|
459
423
|
|
|
460
424
|
// Get TokenClassKey for token
|
|
461
425
|
const tokenClassKey = await sdk.resolveTokenClassKey(tokenName);
|
|
462
|
-
|
|
426
|
+
|
|
463
427
|
}
|
|
464
428
|
|
|
465
429
|
// 9. COMPLETE INVESTMENT ANALYSIS WORKFLOW
|
|
@@ -475,14 +439,11 @@ async function analyzeToken(tokenName) {
|
|
|
475
439
|
]);
|
|
476
440
|
|
|
477
441
|
// Analyze status
|
|
478
|
-
console.log(\`Pool Status: \${details.saleStatus}\`);
|
|
479
|
-
console.log(\`Supply: \${details.currentSupply} / \${details.maxSupply}\`);
|
|
480
442
|
|
|
481
443
|
// Analyze volume trend
|
|
482
444
|
// Note: For analytics/aggregation, we use safeParseFloat for performance. For trades, use BigNumber via SDK
|
|
483
445
|
const volumes = volumeData.map(v => safeParseFloat(v.volume, 0));
|
|
484
446
|
const avgVolume = volumes.reduce((a, b) => a + b, 0) / volumes.length;
|
|
485
|
-
console.log(\`Avg daily volume: $\${toBigNumberFixed(avgVolume, 2)}\`);
|
|
486
447
|
|
|
487
448
|
// Analyze distribution
|
|
488
449
|
// Use compareAmounts for precise balance comparisons
|
|
@@ -490,10 +451,9 @@ async function analyzeToken(tokenName) {
|
|
|
490
451
|
.sort((a, b) => compareAmounts(b.balance, a.balance) > 0 ? 1 : -1)
|
|
491
452
|
.slice(0, 5)
|
|
492
453
|
.reduce((sum, h) => sum + h.percentage, 0);
|
|
493
|
-
console.log(\`Top 5 holders: \${toBigNumberFixed(top5Ownership, 2)}%\`);
|
|
494
454
|
|
|
495
455
|
// Check badges
|
|
496
|
-
|
|
456
|
+
|
|
497
457
|
}
|
|
498
458
|
\`\`\`
|
|
499
459
|
|
|
@@ -530,9 +490,6 @@ async function checkBalances() {
|
|
|
530
490
|
|
|
531
491
|
// Check GALA balance
|
|
532
492
|
const galaBalance = await sdk.fetchGalaBalance();
|
|
533
|
-
console.log(\`GALA: \${galaBalance.balance}\`);
|
|
534
|
-
console.log(\`Decimals: \${galaBalance.decimals}\`);
|
|
535
|
-
console.log(\`Last updated: \${galaBalance.lastUpdated.toISOString()}\`);
|
|
536
493
|
|
|
537
494
|
// Check specific token balance
|
|
538
495
|
const tokenBalance = await sdk.fetchTokenBalance({
|
|
@@ -540,19 +497,14 @@ async function checkBalances() {
|
|
|
540
497
|
address: sdk.getAddress()
|
|
541
498
|
});
|
|
542
499
|
|
|
543
|
-
console.log(\`Token: \${tokenBalance.quantity}\`);
|
|
544
|
-
console.log(\`USD value: $\${tokenBalance.holdingPriceUsd}\`);
|
|
545
|
-
console.log(\`GALA value: \${tokenBalance.holdingPriceGala}\`);
|
|
546
|
-
|
|
547
500
|
// Check all tokens held
|
|
548
501
|
const portfolio = await sdk.fetchTokensHeld({
|
|
549
502
|
address: sdk.getAddress(),
|
|
550
503
|
limit: 20
|
|
551
504
|
});
|
|
552
505
|
|
|
553
|
-
console.log(\`Holding \${portfolio.total} different tokens\`);
|
|
554
506
|
portfolio.tokens.forEach(token => {
|
|
555
|
-
|
|
507
|
+
|
|
556
508
|
});
|
|
557
509
|
|
|
558
510
|
// Check tokens created by this wallet
|
|
@@ -561,18 +513,16 @@ async function checkBalances() {
|
|
|
561
513
|
limit: 10
|
|
562
514
|
});
|
|
563
515
|
|
|
564
|
-
console.log(\`Created \${createdTokens.total} tokens\`);
|
|
565
516
|
createdTokens.tokens.forEach(token => {
|
|
566
|
-
|
|
517
|
+
|
|
567
518
|
});
|
|
568
519
|
|
|
569
520
|
// Get user profile
|
|
570
521
|
const profile = await sdk.fetchProfile();
|
|
571
|
-
console.log(\`Profile: \${profile.fullName}\`);
|
|
572
522
|
|
|
573
523
|
// Check profile of another user
|
|
574
524
|
const otherProfile = await sdk.fetchProfile('eth|0x...');
|
|
575
|
-
|
|
525
|
+
|
|
576
526
|
}
|
|
577
527
|
\`\`\`
|
|
578
528
|
|
|
@@ -600,8 +550,6 @@ const locked = await sdk.fetchLockedTokens({
|
|
|
600
550
|
address: walletAddress
|
|
601
551
|
});
|
|
602
552
|
|
|
603
|
-
console.log('Available:', available.quantity);
|
|
604
|
-
console.log('Locked:', locked.lockedQuantity);
|
|
605
553
|
\`\`\`
|
|
606
554
|
`,
|
|
607
555
|
// ============================================================================
|
|
@@ -639,7 +587,6 @@ async function launchToken() {
|
|
|
639
587
|
|
|
640
588
|
// 2. Check launch fee
|
|
641
589
|
const launchFee = await sdk.fetchLaunchTokenFee();
|
|
642
|
-
console.log(\`Launch fee: \${launchFee} GALA\`);
|
|
643
590
|
|
|
644
591
|
// 3. Upload token image (Node.js only)
|
|
645
592
|
const imageUpload = await sdk.uploadTokenImage({
|
|
@@ -658,12 +605,9 @@ async function launchToken() {
|
|
|
658
605
|
preBuyQuantity: '100' // Optional: pre-buy with GALA
|
|
659
606
|
});
|
|
660
607
|
|
|
661
|
-
console.log('Token launched!');
|
|
662
|
-
console.log('Transaction ID:', result.transactionId);
|
|
663
|
-
|
|
664
608
|
// Get frontend URL
|
|
665
609
|
const url = sdk.getUrlByTokenName('mytoken');
|
|
666
|
-
|
|
610
|
+
|
|
667
611
|
}
|
|
668
612
|
\`\`\`
|
|
669
613
|
|
|
@@ -699,7 +643,6 @@ async function multiWalletExample() {
|
|
|
699
643
|
|
|
700
644
|
// Create a test wallet
|
|
701
645
|
const testWallet = createWallet();
|
|
702
|
-
console.log('Test wallet:', testWallet.address);
|
|
703
646
|
|
|
704
647
|
// 1. Fund test wallet from main wallet
|
|
705
648
|
await sdk.transferGala({
|
|
@@ -723,14 +666,10 @@ async function multiWalletExample() {
|
|
|
723
666
|
privateKey: testWallet.privateKey // Override to use test wallet
|
|
724
667
|
});
|
|
725
668
|
|
|
726
|
-
console.log('Test wallet bought tokens');
|
|
727
|
-
|
|
728
669
|
// 3. Check balances for both wallets
|
|
729
670
|
const mainBalance = await sdk.fetchGalaBalance(); // Main wallet
|
|
730
671
|
const testBalance = await sdk.fetchGalaBalance(testWallet.address); // Test wallet
|
|
731
672
|
|
|
732
|
-
console.log(\`Main wallet: \${mainBalance.balance} GALA\`);
|
|
733
|
-
console.log(\`Test wallet: \${testBalance.balance} GALA\`);
|
|
734
673
|
}
|
|
735
674
|
\`\`\`
|
|
736
675
|
|
|
@@ -761,9 +700,6 @@ async function transferTokens() {
|
|
|
761
700
|
uniqueKey: 'galaconnect-operation-my-transfer-123' // Optional idempotency
|
|
762
701
|
});
|
|
763
702
|
|
|
764
|
-
console.log('GALA transfer ID:', galaTransfer.transactionId);
|
|
765
|
-
console.log('Status:', galaTransfer.status);
|
|
766
|
-
|
|
767
703
|
// Transfer launchpad tokens
|
|
768
704
|
const tokenTransfer = await sdk.transferToken({
|
|
769
705
|
to: 'eth|5678...',
|
|
@@ -772,7 +708,6 @@ async function transferTokens() {
|
|
|
772
708
|
uniqueKey: 'galaconnect-operation-token-456'
|
|
773
709
|
});
|
|
774
710
|
|
|
775
|
-
console.log('Token transfer ID:', tokenTransfer.transactionId);
|
|
776
711
|
}
|
|
777
712
|
\`\`\`
|
|
778
713
|
|
|
@@ -817,9 +752,6 @@ async function tokenLockingAndBurning() {
|
|
|
817
752
|
}]
|
|
818
753
|
});
|
|
819
754
|
|
|
820
|
-
console.log('Lock transaction ID:', lockResult.transactionId);
|
|
821
|
-
console.log('Locked entries:', lockResult.locked);
|
|
822
|
-
|
|
823
755
|
// ============================================================================
|
|
824
756
|
// LOCK TOKENS - Multiple tokens in one transaction (batch)
|
|
825
757
|
// ============================================================================
|
|
@@ -833,8 +765,6 @@ async function tokenLockingAndBurning() {
|
|
|
833
765
|
]
|
|
834
766
|
});
|
|
835
767
|
|
|
836
|
-
console.log('Batch lock completed:', batchLock.locked.length, 'tokens locked');
|
|
837
|
-
|
|
838
768
|
// ============================================================================
|
|
839
769
|
// LOCK TOKENS - Advanced options
|
|
840
770
|
// ============================================================================
|
|
@@ -850,8 +780,6 @@ async function tokenLockingAndBurning() {
|
|
|
850
780
|
}]
|
|
851
781
|
});
|
|
852
782
|
|
|
853
|
-
console.log('Escrow lock created');
|
|
854
|
-
|
|
855
783
|
// Lock for time-based vesting
|
|
856
784
|
const vestingLock = await sdk.lockTokens({
|
|
857
785
|
tokens: [{
|
|
@@ -862,8 +790,6 @@ async function tokenLockingAndBurning() {
|
|
|
862
790
|
}]
|
|
863
791
|
});
|
|
864
792
|
|
|
865
|
-
console.log('Vesting lock created with expiry');
|
|
866
|
-
|
|
867
793
|
// ============================================================================
|
|
868
794
|
// UNLOCK TOKENS - Release locked tokens
|
|
869
795
|
// ============================================================================
|
|
@@ -876,9 +802,6 @@ async function tokenLockingAndBurning() {
|
|
|
876
802
|
}]
|
|
877
803
|
});
|
|
878
804
|
|
|
879
|
-
console.log('Unlock transaction ID:', unlockResult.transactionId);
|
|
880
|
-
console.log('Unlocked entries:', unlockResult.unlocked);
|
|
881
|
-
|
|
882
805
|
// Unlock multiple tokens in one transaction
|
|
883
806
|
const batchUnlock = await sdk.unlockTokens({
|
|
884
807
|
tokens: [
|
|
@@ -887,8 +810,6 @@ async function tokenLockingAndBurning() {
|
|
|
887
810
|
]
|
|
888
811
|
});
|
|
889
812
|
|
|
890
|
-
console.log('Batch unlock completed');
|
|
891
|
-
|
|
892
813
|
// ============================================================================
|
|
893
814
|
// BURN TOKENS - Permanently destroy (IRREVERSIBLE!)
|
|
894
815
|
// ============================================================================
|
|
@@ -901,9 +822,6 @@ async function tokenLockingAndBurning() {
|
|
|
901
822
|
}]
|
|
902
823
|
});
|
|
903
824
|
|
|
904
|
-
console.log('Burn transaction ID:', burnResult.transactionId);
|
|
905
|
-
console.log('Burned:', burnResult.burned);
|
|
906
|
-
|
|
907
825
|
// Batch burn multiple token types
|
|
908
826
|
const batchBurn = await sdk.burnTokens({
|
|
909
827
|
tokens: [
|
|
@@ -912,8 +830,6 @@ async function tokenLockingAndBurning() {
|
|
|
912
830
|
]
|
|
913
831
|
});
|
|
914
832
|
|
|
915
|
-
console.log('Batch burn completed:', batchBurn.burned.length, 'token types burned');
|
|
916
|
-
|
|
917
833
|
// ============================================================================
|
|
918
834
|
// QUERY LOCKED TOKENS - Check lock status
|
|
919
835
|
// ============================================================================
|
|
@@ -923,15 +839,11 @@ async function tokenLockingAndBurning() {
|
|
|
923
839
|
address: sdk.getAddress()
|
|
924
840
|
});
|
|
925
841
|
|
|
926
|
-
console.log('Locked quantity:', lockedTokens.lockedQuantity);
|
|
927
|
-
console.log('Active holds:', lockedTokens.holds);
|
|
928
|
-
|
|
929
842
|
// Each hold contains: lockAuthority, expires, name, quantity
|
|
930
843
|
for (const hold of lockedTokens.holds) {
|
|
931
|
-
|
|
932
|
-
if (hold.expires)
|
|
933
|
-
if (hold.name)
|
|
934
|
-
}
|
|
844
|
+
|
|
845
|
+
if (hold.expires) }\`);
|
|
846
|
+
if (hold.name) }
|
|
935
847
|
|
|
936
848
|
// ============================================================================
|
|
937
849
|
// STAKING WORKFLOW EXAMPLE
|
|
@@ -948,8 +860,6 @@ async function tokenLockingAndBurning() {
|
|
|
948
860
|
}]
|
|
949
861
|
});
|
|
950
862
|
|
|
951
|
-
console.log('Staked 5000 tokens for 90 days');
|
|
952
|
-
|
|
953
863
|
// Step 2: After staking period expires, unlock
|
|
954
864
|
const unstake = await sdk.unlockTokens({
|
|
955
865
|
tokens: [{
|
|
@@ -959,7 +869,6 @@ async function tokenLockingAndBurning() {
|
|
|
959
869
|
}]
|
|
960
870
|
});
|
|
961
871
|
|
|
962
|
-
console.log('Unstaked tokens after staking period');
|
|
963
872
|
return { stake, unstake };
|
|
964
873
|
}
|
|
965
874
|
|
|
@@ -978,8 +887,6 @@ async function tokenLockingAndBurning() {
|
|
|
978
887
|
}]
|
|
979
888
|
});
|
|
980
889
|
|
|
981
|
-
console.log('Escrow created: seller can release payment upon delivery');
|
|
982
|
-
|
|
983
890
|
// Step 2: Seller releases escrow after delivery (seller calls unlock)
|
|
984
891
|
// This would be executed by the seller's SDK instance
|
|
985
892
|
// const release = await sellerSdk.unlockTokens({
|
|
@@ -1075,13 +982,9 @@ async function dexTradingExample() {
|
|
|
1075
982
|
|
|
1076
983
|
// Quote 1: Exact input (spend known GALA amount)
|
|
1077
984
|
const quoteIn = await sdk.getSwapQuoteExactInput('GALA', 'GUSDC', '100');
|
|
1078
|
-
console.log('Spend 100 GALA → get ~' + quoteIn.estimatedOutput + ' GUSDC');
|
|
1079
|
-
console.log('Price impact: ' + quoteIn.priceImpact + '%');
|
|
1080
|
-
console.log('Fee tier: ' + quoteIn.feeTier + ' bps');
|
|
1081
985
|
|
|
1082
986
|
// Quote 2: Exact output (get known token amount)
|
|
1083
987
|
const quoteOut = await sdk.getSwapQuoteExactOutput('GALA', 'GUSDC', '100');
|
|
1084
|
-
console.log('Get exactly 100 GUSDC → need ~' + quoteOut.inputAmount + ' GALA');
|
|
1085
988
|
|
|
1086
989
|
// ============================================================================
|
|
1087
990
|
// EXECUTE: Perform the swap with slippage protection
|
|
@@ -1096,18 +999,14 @@ async function dexTradingExample() {
|
|
|
1096
999
|
0.01 // 1% slippage tolerance
|
|
1097
1000
|
);
|
|
1098
1001
|
|
|
1099
|
-
console.log('Transaction ID: ' + result.transactionId);
|
|
1100
|
-
console.log('Status: ' + result.status);
|
|
1101
|
-
console.log('Received: ' + result.outputAmount + ' ' + result.toToken);
|
|
1102
|
-
|
|
1103
1002
|
// ============================================================================
|
|
1104
1003
|
// PORTFOLIO: Check balances and assets
|
|
1105
1004
|
// ============================================================================
|
|
1106
1005
|
|
|
1107
1006
|
const assets = await sdk.getSwapUserAssets(sdk.getEthereumAddress());
|
|
1108
|
-
|
|
1007
|
+
|
|
1109
1008
|
assets.forEach(asset => {
|
|
1110
|
-
|
|
1009
|
+
|
|
1111
1010
|
});
|
|
1112
1011
|
|
|
1113
1012
|
// ============================================================================
|
|
@@ -1115,10 +1014,9 @@ async function dexTradingExample() {
|
|
|
1115
1014
|
// ============================================================================
|
|
1116
1015
|
|
|
1117
1016
|
const allAssets = await sdk.getAllSwapUserAssets(sdk.getEthereumAddress());
|
|
1118
|
-
|
|
1119
|
-
console.log('Total assets: ' + allAssets.length);
|
|
1017
|
+
|
|
1120
1018
|
allAssets.forEach(asset => {
|
|
1121
|
-
|
|
1019
|
+
|
|
1122
1020
|
});
|
|
1123
1021
|
|
|
1124
1022
|
// ============================================================================
|
|
@@ -1126,10 +1024,7 @@ async function dexTradingExample() {
|
|
|
1126
1024
|
// ============================================================================
|
|
1127
1025
|
|
|
1128
1026
|
const pool = await sdk.getSwapPoolInfo('GALA', 'GUSDC');
|
|
1129
|
-
|
|
1130
|
-
console.log(' Liquidity: ' + pool.liquidity);
|
|
1131
|
-
console.log(' Available fee tiers: ' + pool.feeTiers.join(', ') + ' bps');
|
|
1132
|
-
console.log(' 24h swaps: ' + pool.swapCount);
|
|
1027
|
+
|
|
1133
1028
|
}
|
|
1134
1029
|
\`\`\`
|
|
1135
1030
|
|
|
@@ -1181,8 +1076,6 @@ async function errorHandlingExample() {
|
|
|
1181
1076
|
slippageToleranceFactor: 0.01
|
|
1182
1077
|
});
|
|
1183
1078
|
|
|
1184
|
-
console.log('Success:', result.transactionId);
|
|
1185
|
-
|
|
1186
1079
|
} catch (error) {
|
|
1187
1080
|
if (error instanceof ValidationError) {
|
|
1188
1081
|
console.error('Invalid input:', error.message);
|
|
@@ -1322,12 +1215,6 @@ async function localCalculationsExample() {
|
|
|
1322
1215
|
type: 'native' // 'native' = GALA amount, 'exact' = token amount
|
|
1323
1216
|
});
|
|
1324
1217
|
|
|
1325
|
-
console.log('LOCAL Buy Quote (instant):');
|
|
1326
|
-
console.log(' Tokens received:', localBuy.amount);
|
|
1327
|
-
console.log(' Transaction fee:', localBuy.transactionFee);
|
|
1328
|
-
console.log(' RBC Fee:', localBuy.reverseBondingCurveFee); // Always "0" for buys
|
|
1329
|
-
console.log(' Gas fee:', localBuy.gasFee);
|
|
1330
|
-
|
|
1331
1218
|
// 2. Sell calculation (local, requires pool details)
|
|
1332
1219
|
const poolDetails = await sdk.fetchPoolDetails('dragnrkti');
|
|
1333
1220
|
|
|
@@ -1341,11 +1228,6 @@ async function localCalculationsExample() {
|
|
|
1341
1228
|
maxFeePortion: poolDetails.reverseBondingCurveMaxFeeFactor || 0
|
|
1342
1229
|
});
|
|
1343
1230
|
|
|
1344
|
-
console.log('LOCAL Sell Quote (instant):');
|
|
1345
|
-
console.log(' GALA received:', localSell.amount);
|
|
1346
|
-
console.log(' RBC Fee:', localSell.reverseBondingCurveFee);
|
|
1347
|
-
console.log(' Transaction fee:', localSell.transactionFee);
|
|
1348
|
-
|
|
1349
1231
|
// ============================================================================
|
|
1350
1232
|
// EXTERNAL CALCULATIONS - Real-time network queries (explicit)
|
|
1351
1233
|
// ============================================================================
|
|
@@ -1357,9 +1239,6 @@ async function localCalculationsExample() {
|
|
|
1357
1239
|
type: 'native'
|
|
1358
1240
|
});
|
|
1359
1241
|
|
|
1360
|
-
console.log('EXTERNAL Buy Quote (network):');
|
|
1361
|
-
console.log(' Tokens received:', externalBuy.amount);
|
|
1362
|
-
|
|
1363
1242
|
// 4. External sell (explicit network call)
|
|
1364
1243
|
const externalSell = await sdk.calculateSellAmountExternal({
|
|
1365
1244
|
tokenName: 'dragnrkti',
|
|
@@ -1367,9 +1246,6 @@ async function localCalculationsExample() {
|
|
|
1367
1246
|
type: 'exact'
|
|
1368
1247
|
});
|
|
1369
1248
|
|
|
1370
|
-
console.log('EXTERNAL Sell Quote (network):');
|
|
1371
|
-
console.log(' GALA received:', externalSell.amount);
|
|
1372
|
-
|
|
1373
1249
|
// ============================================================================
|
|
1374
1250
|
// A/B COMPARISON - Verify local accuracy
|
|
1375
1251
|
// ============================================================================
|
|
@@ -1379,9 +1255,6 @@ async function localCalculationsExample() {
|
|
|
1379
1255
|
const buyDiff = Math.abs(safeParseNumber(localBuy.amount, 0) - safeParseNumber(externalBuy.amount, 0));
|
|
1380
1256
|
const buyPct = (buyDiff / safeParseNumber(externalBuy.amount, 1)) * 100;
|
|
1381
1257
|
|
|
1382
|
-
console.log('Local vs External Accuracy:');
|
|
1383
|
-
console.log(\` Buy difference: \${toBigNumberFixed(buyPct, 4)}% (should be <0.01%)\`);
|
|
1384
|
-
|
|
1385
1258
|
// ============================================================================
|
|
1386
1259
|
// PERFORMANCE BENEFIT - Local is instant
|
|
1387
1260
|
// ============================================================================
|
|
@@ -1444,9 +1317,6 @@ async function analyzePriceHistory() {
|
|
|
1444
1317
|
limit: 50
|
|
1445
1318
|
});
|
|
1446
1319
|
|
|
1447
|
-
console.log(\`Found \${history.snapshots.length} snapshots\`);
|
|
1448
|
-
console.log(\`Total available: \${history.total} (page \${history.page} of \${history.totalPages})\`);
|
|
1449
|
-
|
|
1450
1320
|
// Auto-paginated complete history
|
|
1451
1321
|
const allHistory = await sdk.fetchAllPriceHistory({
|
|
1452
1322
|
tokenId: 'GWETH|Unit|none|none',
|
|
@@ -1461,14 +1331,11 @@ async function analyzePriceHistory() {
|
|
|
1461
1331
|
const variance = prices.reduce((sum, p) => sum + Math.pow(p - avg, 2), 0) / prices.length;
|
|
1462
1332
|
const volatility = Math.sqrt(variance);
|
|
1463
1333
|
|
|
1464
|
-
console.log(\`Average: $\${toBigNumberFixed(avg, 4)}, Volatility: $\${toBigNumberFixed(volatility, 4)}\`);
|
|
1465
|
-
|
|
1466
1334
|
// Data export (CSV)
|
|
1467
1335
|
const csv = ['timestamp,price'].concat(
|
|
1468
1336
|
allHistory.snapshots.map(s => \`\${s.timestamp.toISOString()},\${s.price}\`)
|
|
1469
1337
|
).join('\\n');
|
|
1470
1338
|
|
|
1471
|
-
console.log('CSV export:', csv.split('\\n').slice(0, 3).join('\\n'));
|
|
1472
1339
|
}
|
|
1473
1340
|
\`\`\`
|
|
1474
1341
|
|
|
@@ -1513,15 +1380,6 @@ async function analyzeTokenDetails() {
|
|
|
1513
1380
|
// Fetch token metadata
|
|
1514
1381
|
const details = await sdk.fetchTokenDetails('GUSDC|Unit|none|eth:0x...');
|
|
1515
1382
|
|
|
1516
|
-
console.log('Token Information:');
|
|
1517
|
-
console.log(\` Name: \${details.name}\`);
|
|
1518
|
-
console.log(\` Symbol: \${details.symbol}\`);
|
|
1519
|
-
console.log(\` Decimals: \${details.decimals}\`);
|
|
1520
|
-
console.log(\` Verified: \${details.verified}\`);
|
|
1521
|
-
console.log(\` Trading: \${details.tradingEnabled}\`);
|
|
1522
|
-
console.log(\` Network: \${details.network}\`);
|
|
1523
|
-
console.log(\` Image: \${details.image}\`);
|
|
1524
|
-
|
|
1525
1383
|
// Pre-trading validation
|
|
1526
1384
|
async function validateBeforeTrade(tokenId: string) {
|
|
1527
1385
|
const token = await sdk.fetchTokenDetails(tokenId);
|
|
@@ -1548,7 +1406,7 @@ async function analyzeTokenDetails() {
|
|
|
1548
1406
|
);
|
|
1549
1407
|
|
|
1550
1408
|
const verified = details_list.filter(t => t?.verified).length;
|
|
1551
|
-
|
|
1409
|
+
|
|
1552
1410
|
}
|
|
1553
1411
|
\`\`\`
|
|
1554
1412
|
|
|
@@ -1595,40 +1453,37 @@ async function tokenPricing() {
|
|
|
1595
1453
|
// OPTION 1: SMART ROUTING (Recommended) - Automatic backend selection
|
|
1596
1454
|
// Use tokenId for ANY token (graduated or ungraduated)
|
|
1597
1455
|
// SDK automatically detects and routes to correct backend
|
|
1598
|
-
|
|
1456
|
+
|
|
1599
1457
|
const smartPrice = await sdk.fetchTokenPrice({
|
|
1600
1458
|
tokenId: 'Token|Unit|ANIME|eth:0x...' // Works for ANY token!
|
|
1601
1459
|
});
|
|
1602
|
-
|
|
1460
|
+
|
|
1603
1461
|
// ✅ Handles graduated tokens (DEX) automatically
|
|
1604
1462
|
// ✅ Handles ungraduated tokens (Launchpad) automatically
|
|
1605
1463
|
// ✅ No need to know token status beforehand
|
|
1606
1464
|
|
|
1607
1465
|
// OPTION 2: EXPLICIT DEX PRICING - Graduated tokens only
|
|
1608
1466
|
// Use tokenId directly for DEX tokens
|
|
1609
|
-
|
|
1467
|
+
|
|
1610
1468
|
const dexPrices = await sdk.fetchTokenPrice({
|
|
1611
1469
|
tokenId: 'GALA|Unit|none|none' // Or other DEX token
|
|
1612
1470
|
});
|
|
1613
|
-
console.log(\`DEX Token GALA: $\${dexPrices}\`);
|
|
1614
1471
|
|
|
1615
1472
|
// OPTION 3: TOKEN NAME PRICING - For launchpad tokens by name
|
|
1616
1473
|
// Use tokenName for simple lookup of launchpad tokens
|
|
1617
|
-
|
|
1474
|
+
|
|
1618
1475
|
const launchpadPrice = await sdk.fetchTokenPrice({ tokenName: 'anime' });
|
|
1619
|
-
console.log(\`Launchpad token anime: $\${launchpadPrice.price}\`);
|
|
1620
1476
|
|
|
1621
1477
|
// ADVANCED: The smart router handles fallback automatically!
|
|
1622
1478
|
// No need for manual fallback - fetchTokenPrice with tokenId detects
|
|
1623
1479
|
// ungraduated tokens and automatically falls back to launchpad pricing
|
|
1624
|
-
|
|
1480
|
+
|
|
1625
1481
|
const autoPrice = await sdk.fetchTokenPrice({
|
|
1626
1482
|
tokenId: 'Token|Unit|ANIME|eth:0x...' // Auto-fallback if ungraduated
|
|
1627
1483
|
});
|
|
1628
|
-
console.log(\`Auto-routed price: $\${autoPrice.price}\`);
|
|
1629
1484
|
|
|
1630
1485
|
// USECASE: Price comparison and discovery
|
|
1631
|
-
|
|
1486
|
+
|
|
1632
1487
|
async function comparePrices(tokenName: string) {
|
|
1633
1488
|
const launchpadPrice = await sdk.fetchTokenPrice({ tokenName });
|
|
1634
1489
|
|
|
@@ -1639,10 +1494,10 @@ async function tokenPricing() {
|
|
|
1639
1494
|
const dexPrice = await sdk.fetchTokenPrice({
|
|
1640
1495
|
tokenId: \`Token|Unit|\${tokenName.toUpperCase()}|eth:0x...\`
|
|
1641
1496
|
});
|
|
1642
|
-
|
|
1497
|
+
|
|
1643
1498
|
return { launchpadPrice, dexPrice, graduated: true };
|
|
1644
1499
|
} else {
|
|
1645
|
-
|
|
1500
|
+
|
|
1646
1501
|
return { launchpadPrice, graduated: false };
|
|
1647
1502
|
}
|
|
1648
1503
|
}
|
|
@@ -1692,7 +1547,7 @@ async function safePriceQuery(tokenId: string) {
|
|
|
1692
1547
|
return await sdk.fetchTokenPrice({ tokenId });
|
|
1693
1548
|
} catch (error) {
|
|
1694
1549
|
if (error.message.includes('not found')) {
|
|
1695
|
-
|
|
1550
|
+
|
|
1696
1551
|
// Could try fallback to launchpad pricing here
|
|
1697
1552
|
}
|
|
1698
1553
|
throw error;
|
|
@@ -1728,12 +1583,9 @@ async function manageUserProfiles() {
|
|
|
1728
1583
|
|
|
1729
1584
|
// Fetch current user profile
|
|
1730
1585
|
const myProfile = await sdk.fetchProfile();
|
|
1731
|
-
console.log(\`Name: \${myProfile.fullName}\`);
|
|
1732
|
-
console.log(\`Avatar: \${myProfile.profileImage}\`);
|
|
1733
1586
|
|
|
1734
1587
|
// Fetch another user's profile
|
|
1735
1588
|
const other = await sdk.fetchProfile('eth|0x...');
|
|
1736
|
-
console.log(\`Other user: \${other.fullName}\`);
|
|
1737
1589
|
|
|
1738
1590
|
// Update profile
|
|
1739
1591
|
const updated = await sdk.updateProfile({
|
|
@@ -1742,8 +1594,6 @@ async function manageUserProfiles() {
|
|
|
1742
1594
|
address: sdk.getAddress()
|
|
1743
1595
|
});
|
|
1744
1596
|
|
|
1745
|
-
console.log(\`Updated: \${updated.fullName}\`);
|
|
1746
|
-
|
|
1747
1597
|
// Upload profile image (Node.js only)
|
|
1748
1598
|
const imgResult = await sdk.uploadProfileImage({
|
|
1749
1599
|
imagePath: '/path/to/avatar.png'
|
|
@@ -1790,7 +1640,6 @@ async function manageUserProfiles() {
|
|
|
1790
1640
|
addresses.map(addr => sdk.fetchProfile(addr).catch(() => null))
|
|
1791
1641
|
);
|
|
1792
1642
|
|
|
1793
|
-
console.log('Profiles:', profiles.filter(p => p).map(p => p.fullName));
|
|
1794
1643
|
}
|
|
1795
1644
|
\`\`\`
|
|
1796
1645
|
|
|
@@ -1838,19 +1687,13 @@ async function analyzeTokenDistribution() {
|
|
|
1838
1687
|
// Fetch complete token distribution (all holders, non-paginated)
|
|
1839
1688
|
const distribution = await sdk.fetchTokenDistribution('anime');
|
|
1840
1689
|
|
|
1841
|
-
console.log(\`Total holders: \${distribution.totalHolders}\`);
|
|
1842
|
-
console.log(\`Total supply: \${distribution.totalSupply}\`);
|
|
1843
|
-
console.log(\`Last updated: \${distribution.lastUpdated.toISOString()}\`);
|
|
1844
|
-
|
|
1845
1690
|
// Analyze top holders
|
|
1846
1691
|
// Use compareAmounts for precise balance sorting with large numbers
|
|
1847
1692
|
distribution.holders
|
|
1848
1693
|
.sort((a, b) => compareAmounts(b.balance, a.balance) > 0 ? 1 : -1)
|
|
1849
1694
|
.slice(0, 5)
|
|
1850
1695
|
.forEach((holder, index) => {
|
|
1851
|
-
|
|
1852
|
-
console.log(\` Balance: \${holder.balance}\`);
|
|
1853
|
-
console.log(\` Ownership: \${toBigNumberFixed(holder.percentage, 2)}%\`);
|
|
1696
|
+
|
|
1854
1697
|
});
|
|
1855
1698
|
|
|
1856
1699
|
// Check concentration risk (e.g., top 5 holders own >80%)
|
|
@@ -1859,24 +1702,20 @@ async function analyzeTokenDistribution() {
|
|
|
1859
1702
|
.slice(0, 5)
|
|
1860
1703
|
.reduce((sum, holder) => sum + holder.percentage, 0);
|
|
1861
1704
|
|
|
1862
|
-
console.log(\`Top 5 holders control: \${toBigNumberFixed(top5Ownership, 2)}%\`);
|
|
1863
|
-
|
|
1864
1705
|
// Find specific holder
|
|
1865
1706
|
const myAddress = sdk.getAddress();
|
|
1866
1707
|
const myHolding = distribution.holders.find(h => h.address === myAddress);
|
|
1867
1708
|
|
|
1868
1709
|
if (myHolding) {
|
|
1869
|
-
|
|
1870
|
-
console.log(\`Your balance: \${myHolding.balance}\`);
|
|
1710
|
+
|
|
1871
1711
|
}
|
|
1872
1712
|
|
|
1873
1713
|
// Calculate concentration metrics
|
|
1874
1714
|
const giniCoefficient = calculateGini(distribution.holders);
|
|
1875
|
-
console.log(\`Gini coefficient: \${toBigNumberFixed(giniCoefficient, 4)}\`);
|
|
1876
1715
|
|
|
1877
1716
|
// Count whales (holders with >5%)
|
|
1878
1717
|
const whales = distribution.holders.filter(h => h.percentage > 5);
|
|
1879
|
-
|
|
1718
|
+
|
|
1880
1719
|
}
|
|
1881
1720
|
|
|
1882
1721
|
// Helper: Calculate Gini coefficient for wealth distribution
|
|
@@ -1941,15 +1780,13 @@ async function getUserCard() {
|
|
|
1941
1780
|
// }
|
|
1942
1781
|
|
|
1943
1782
|
if (holderContext.quantity !== null) {
|
|
1944
|
-
|
|
1945
|
-
console.log(\`Holder Tier: \${holderContext.holderTier?.tierName}\`);
|
|
1946
|
-
console.log(\`Owns: \${holderContext.percentage ? toBigNumberFixed(holderContext.percentage, 4) : 'N/A'}%\`);
|
|
1783
|
+
|
|
1947
1784
|
} else {
|
|
1948
|
-
|
|
1785
|
+
|
|
1949
1786
|
}
|
|
1950
1787
|
|
|
1951
1788
|
if (holderContext.isCreator) {
|
|
1952
|
-
|
|
1789
|
+
|
|
1953
1790
|
}
|
|
1954
1791
|
}
|
|
1955
1792
|
\`\`\`
|
|
@@ -2037,11 +1874,9 @@ Use \`getAllSwapUserLiquidityPositions()\` to fetch all positions without manual
|
|
|
2037
1874
|
// Fetch ALL positions automatically (handles pagination internally)
|
|
2038
1875
|
const allPositions = await sdk.getAllSwapUserLiquidityPositions(ownerAddress);
|
|
2039
1876
|
|
|
2040
|
-
console.log(\`Total positions: \${allPositions.length}\`);
|
|
2041
1877
|
allPositions.forEach(position => {
|
|
2042
1878
|
const fees = position.fees0 + position.fees1; // Total accumulated fees
|
|
2043
|
-
|
|
2044
|
-
console.log(\`Accumulated fees: \${fees}\`);
|
|
1879
|
+
|
|
2045
1880
|
});
|
|
2046
1881
|
\`\`\`
|
|
2047
1882
|
|
|
@@ -2080,9 +1915,7 @@ async function advancedDexAnalysis() {
|
|
|
2080
1915
|
const composite = await sdk.fetchCompositePoolData('anime');
|
|
2081
1916
|
|
|
2082
1917
|
if (composite.isGraduated) {
|
|
2083
|
-
|
|
2084
|
-
console.log('DEX Pool TVL:', composite.dexPool.tvl);
|
|
2085
|
-
console.log('DEX 24h Volume:', composite.dexPool.volume1d);
|
|
1918
|
+
|
|
2086
1919
|
}
|
|
2087
1920
|
|
|
2088
1921
|
// Step 2: Compare local vs external price calculations
|
|
@@ -2098,9 +1931,6 @@ async function advancedDexAnalysis() {
|
|
|
2098
1931
|
'100'
|
|
2099
1932
|
);
|
|
2100
1933
|
|
|
2101
|
-
console.log('Local calculation:', localQuote.outputAmount);
|
|
2102
|
-
console.log('External API:', externalQuote.outputAmount);
|
|
2103
|
-
console.log('Price difference:',
|
|
2104
1934
|
Math.abs(safeParseFloat(localQuote.outputAmount, 0) - safeParseFloat(externalQuote.outputAmount, 0))
|
|
2105
1935
|
);
|
|
2106
1936
|
|
|
@@ -2111,8 +1941,6 @@ async function advancedDexAnalysis() {
|
|
|
2111
1941
|
'100'
|
|
2112
1942
|
);
|
|
2113
1943
|
|
|
2114
|
-
console.log('Best route:', bestQuote.route); // 'local' or 'external'
|
|
2115
|
-
console.log('Best price:', bestQuote.outputAmount);
|
|
2116
1944
|
}
|
|
2117
1945
|
\`\`\`
|
|
2118
1946
|
|
|
@@ -2150,20 +1978,14 @@ async function tradingAnalytics() {
|
|
|
2150
1978
|
page: 1
|
|
2151
1979
|
});
|
|
2152
1980
|
|
|
2153
|
-
console.log(\`Analyzing \${trades.total} trades\`);
|
|
2154
|
-
|
|
2155
1981
|
// Calculate analytics
|
|
2156
1982
|
const totalVolume = trades.trades.reduce((sum, t) => sum + safeParseFloat(t.galaAmount, 0), 0);
|
|
2157
1983
|
const averageTradeSize = totalVolume / trades.trades.length;
|
|
2158
1984
|
const whaleTrades = trades.trades.filter(t => safeParseFloat(t.galaAmount, 0) > 1000);
|
|
2159
1985
|
|
|
2160
|
-
console.log(\`Total volume: \${totalVolume} GALA\`);
|
|
2161
|
-
console.log(\`Average trade size: \${averageTradeSize} GALA\`);
|
|
2162
|
-
console.log(\`Whale trades (>1000 GALA): \${whaleTrades.length}\`);
|
|
2163
|
-
|
|
2164
1986
|
// Most recent trades
|
|
2165
1987
|
trades.trades.slice(0, 10).forEach(trade => {
|
|
2166
|
-
|
|
1988
|
+
|
|
2167
1989
|
});
|
|
2168
1990
|
}
|
|
2169
1991
|
|
|
@@ -2173,13 +1995,11 @@ async function queryTradesV1() {
|
|
|
2173
1995
|
|
|
2174
1996
|
// Query all trades for a specific token
|
|
2175
1997
|
const { trades, meta } = await sdk.getV1Trades({ tokenName: 'anime' });
|
|
2176
|
-
console.log(\`Found \${meta.totalItems} trades for anime\`);
|
|
2177
1998
|
|
|
2178
1999
|
// Query all trades by a specific user
|
|
2179
2000
|
const userTrades = await sdk.getV1Trades({
|
|
2180
2001
|
userAddress: 'eth|1234567890abcdef...'
|
|
2181
2002
|
});
|
|
2182
|
-
console.log(\`User has \${userTrades.meta.totalItems} trades across all tokens\`);
|
|
2183
2003
|
|
|
2184
2004
|
// Query a user's trades on a specific token with pagination
|
|
2185
2005
|
const filteredTrades = await sdk.getV1Trades({
|
|
@@ -2188,11 +2008,10 @@ async function queryTradesV1() {
|
|
|
2188
2008
|
page: 2,
|
|
2189
2009
|
limit: 20
|
|
2190
2010
|
});
|
|
2191
|
-
console.log(\`Page \${filteredTrades.meta.currentPage} of \${filteredTrades.meta.totalPages}\`);
|
|
2192
2011
|
|
|
2193
2012
|
// Analyze trade types
|
|
2194
2013
|
filteredTrades.trades.forEach(trade => {
|
|
2195
|
-
|
|
2014
|
+
|
|
2196
2015
|
});
|
|
2197
2016
|
}
|
|
2198
2017
|
\`\`\`
|
|
@@ -2225,12 +2044,11 @@ Essential helper methods for development, debugging, and special use cases.
|
|
|
2225
2044
|
\`\`\`typescript
|
|
2226
2045
|
// Get current GALA price in USD
|
|
2227
2046
|
const galaPrice = await sdk.fetchGalaPrice();
|
|
2228
|
-
console.log(\`GALA: $\${galaPrice}\`);
|
|
2229
2047
|
|
|
2230
2048
|
// Get token supply metrics from GalaChain
|
|
2231
2049
|
const supplies = await sdk.fetchTokenClassesWithSupply();
|
|
2232
2050
|
supplies.forEach(token => {
|
|
2233
|
-
|
|
2051
|
+
|
|
2234
2052
|
});
|
|
2235
2053
|
\`\`\`
|
|
2236
2054
|
|
|
@@ -2239,7 +2057,7 @@ supplies.forEach(token => {
|
|
|
2239
2057
|
\`\`\`typescript
|
|
2240
2058
|
// Check transaction status
|
|
2241
2059
|
const status = await sdk.getBundlerTransactionResult('tx-id-123');
|
|
2242
|
-
|
|
2060
|
+
|
|
2243
2061
|
\`\`\`
|
|
2244
2062
|
|
|
2245
2063
|
### Advanced Swap Queries
|
|
@@ -2247,11 +2065,9 @@ console.log('Status:', status.status); // 'pending' | 'success' | 'failed'
|
|
|
2247
2065
|
\`\`\`typescript
|
|
2248
2066
|
// Get pool price without full quote
|
|
2249
2067
|
const price = await sdk.getSwapPoolPrice('GALA|Unit|none|none', 'GUSDC|Unit|none|none');
|
|
2250
|
-
console.log(\`Pool price: \${price}\`);
|
|
2251
2068
|
|
|
2252
2069
|
// Auto-paginated asset fetch
|
|
2253
2070
|
const allAssets = await sdk.getAllSwapUserAssets('eth|0x...', { limit: 100 });
|
|
2254
|
-
console.log(\`Total assets: \${allAssets.length}\`);
|
|
2255
2071
|
|
|
2256
2072
|
// Direct position lookup (if you have compound key)
|
|
2257
2073
|
const position = await sdk.fetchSwapPositionDirect({
|
|
@@ -2267,7 +2083,7 @@ const position = await sdk.fetchSwapPositionDirect({
|
|
|
2267
2083
|
\`\`\`typescript
|
|
2268
2084
|
// Calculate initial buy amount for token launch
|
|
2269
2085
|
const buyAmount = await sdk.calculateInitialBuyAmount('100');
|
|
2270
|
-
|
|
2086
|
+
|
|
2271
2087
|
\`\`\`
|
|
2272
2088
|
|
|
2273
2089
|
### SDK Cleanup
|
|
@@ -2285,7 +2101,6 @@ const tradeResult = await sdk.buy({ tokenName, amount, type: 'native', expectedA
|
|
|
2285
2101
|
|
|
2286
2102
|
// Poll for completion
|
|
2287
2103
|
const status = await sdk.getBundlerTransactionResult(tradeResult.transactionId);
|
|
2288
|
-
console.log('Status:', status.status); // PENDING, PROCESSING, COMPLETED, FAILED
|
|
2289
2104
|
|
|
2290
2105
|
// Wait with polling
|
|
2291
2106
|
let attempts = 0;
|
|
@@ -2334,22 +2149,21 @@ async function manageDexSeasons() {
|
|
|
2334
2149
|
|
|
2335
2150
|
// Display season information
|
|
2336
2151
|
seasons.forEach(season => {
|
|
2337
|
-
|
|
2338
|
-
console.log(\`Duration: \${season.start} to \${season.end}\`);
|
|
2152
|
+
|
|
2339
2153
|
});
|
|
2340
2154
|
|
|
2341
2155
|
// Get current season
|
|
2342
2156
|
const activeSeason = await sdk.fetchCurrentDexSeason();
|
|
2343
2157
|
if (activeSeason) {
|
|
2344
|
-
|
|
2158
|
+
|
|
2345
2159
|
} else {
|
|
2346
|
-
|
|
2160
|
+
|
|
2347
2161
|
}
|
|
2348
2162
|
|
|
2349
2163
|
// Verify season is active
|
|
2350
2164
|
const now = new Date();
|
|
2351
2165
|
const isActive = activeSeason && now >= activeSeason.start && now <= activeSeason.end;
|
|
2352
|
-
|
|
2166
|
+
|
|
2353
2167
|
}
|
|
2354
2168
|
\`\`\`
|
|
2355
2169
|
|
|
@@ -2376,29 +2190,26 @@ async function viewLeaderboards() {
|
|
|
2376
2190
|
const leaderboard = await sdk.fetchDexLeaderboardBySeasonId(4);
|
|
2377
2191
|
|
|
2378
2192
|
// Display top 10 ranked players
|
|
2379
|
-
|
|
2193
|
+
|
|
2380
2194
|
leaderboard.entries.slice(0, 10).forEach(entry => {
|
|
2381
|
-
|
|
2382
|
-
console.log(\` XP: \${entry.totalXp} (Liquidity: \${entry.liquidityXp}, Trading: \${entry.tradingXp})\`);
|
|
2195
|
+
|
|
2383
2196
|
});
|
|
2384
2197
|
|
|
2385
2198
|
// Analyze mastery titles
|
|
2386
2199
|
const topPlayer = leaderboard.entries[0];
|
|
2387
2200
|
topPlayer.masteryTitles.forEach(title => {
|
|
2388
|
-
|
|
2201
|
+
|
|
2389
2202
|
});
|
|
2390
2203
|
|
|
2391
2204
|
// Option 2: Get current leaderboard (convenience method)
|
|
2392
2205
|
const currentBoard = await sdk.fetchCurrentDexLeaderboard();
|
|
2393
2206
|
|
|
2394
2207
|
if (currentBoard) {
|
|
2395
|
-
console.log(\`Season \${currentBoard.seasonId} is active\`);
|
|
2396
|
-
console.log(\`Total participants: \${currentBoard.entries.length}\`);
|
|
2397
2208
|
|
|
2398
2209
|
// Top 3 performers
|
|
2399
2210
|
const topThree = currentBoard.entries.slice(0, 3);
|
|
2400
2211
|
topThree.forEach(entry => {
|
|
2401
|
-
|
|
2212
|
+
|
|
2402
2213
|
});
|
|
2403
2214
|
}
|
|
2404
2215
|
}
|
|
@@ -2426,24 +2237,17 @@ async function analyzeVolumeTrends() {
|
|
|
2426
2237
|
const summary = await sdk.fetchDexAggregatedVolumeSummary();
|
|
2427
2238
|
|
|
2428
2239
|
// Display volumes
|
|
2429
|
-
console.log(\`1-Day Volume: $\${summary.volume1d.toLocaleString()}\`);
|
|
2430
|
-
console.log(\`7-Day Volume: $\${summary.volume7d.toLocaleString()}\`);
|
|
2431
|
-
console.log(\`30-Day Volume: $\${summary.volume30d.toLocaleString()}\`);
|
|
2432
2240
|
|
|
2433
2241
|
// Analyze trends
|
|
2434
2242
|
const trend1d = summary.volume1dDelta > 0 ? '📈 UP' : '📉 DOWN';
|
|
2435
2243
|
const trend7d = summary.volume7dDelta > 0 ? '📈 UP' : '📉 DOWN';
|
|
2436
2244
|
const trend30d = summary.volume30dDelta > 0 ? '📈 UP' : '📉 DOWN';
|
|
2437
2245
|
|
|
2438
|
-
console.log(\`1-Day Trend: \${trend1d} (\${toBigNumberFixed(summary.volume1dDelta * 100, 2)}%)\`);
|
|
2439
|
-
console.log(\`7-Day Trend: \${trend7d} (\${toBigNumberFixed(summary.volume7dDelta * 100, 2)}%)\`);
|
|
2440
|
-
console.log(\`30-Day Trend: \${trend30d} (\${toBigNumberFixed(summary.volume30dDelta * 100, 2)}%)\`);
|
|
2441
|
-
|
|
2442
2246
|
// Growth analysis
|
|
2443
2247
|
if (summary.volume30dDelta > 0.1) {
|
|
2444
|
-
|
|
2248
|
+
|
|
2445
2249
|
} else if (summary.volume30dDelta < -0.1) {
|
|
2446
|
-
|
|
2250
|
+
|
|
2447
2251
|
}
|
|
2448
2252
|
}
|
|
2449
2253
|
\`\`\`
|
|
@@ -2468,26 +2272,23 @@ async function queryDexPools() {
|
|
|
2468
2272
|
// Option 1: Fetch pools with pagination
|
|
2469
2273
|
const pools = await sdk.fetchDexPools({
|
|
2470
2274
|
search: 'GALA',
|
|
2471
|
-
sortBy: '
|
|
2275
|
+
sortBy: 'TVL', // Sort by: TVL, volume30d, volume1d
|
|
2472
2276
|
limit: 20,
|
|
2473
2277
|
page: 1
|
|
2474
2278
|
});
|
|
2475
2279
|
|
|
2476
|
-
console.log(\`Found \${pools.total} pools, page \${pools.page} of \${pools.totalPages}\`);
|
|
2477
2280
|
pools.pools.forEach(pool => {
|
|
2478
|
-
|
|
2281
|
+
|
|
2479
2282
|
});
|
|
2480
2283
|
|
|
2481
2284
|
// Option 2: Fetch ALL pools automatically (handles pagination)
|
|
2482
2285
|
const allPools = await sdk.fetchAllDexPools({
|
|
2483
|
-
sortBy: '
|
|
2286
|
+
sortBy: 'TVL'
|
|
2484
2287
|
});
|
|
2485
2288
|
|
|
2486
|
-
console.log(\`Total pools: \${allPools.pools.length}\`);
|
|
2487
|
-
|
|
2488
2289
|
// Analyze pool metrics
|
|
2489
|
-
const avgTvl = allPools.pools.reduce((sum, p) => sum + safeParseFloat(p.
|
|
2490
|
-
|
|
2290
|
+
const avgTvl = allPools.pools.reduce((sum, p) => sum + safeParseFloat(p.TVL, 0), 0) / allPools.pools.length;
|
|
2291
|
+
|
|
2491
2292
|
}
|
|
2492
2293
|
\`\`\`
|
|
2493
2294
|
|
|
@@ -2530,10 +2331,10 @@ async function monitorTokenStatus() {
|
|
|
2530
2331
|
const isGraduated = await sdk.isTokenGraduated('anime');
|
|
2531
2332
|
|
|
2532
2333
|
if (isGraduated) {
|
|
2533
|
-
|
|
2334
|
+
|
|
2534
2335
|
// Use DEX trading methods: executeSwap(), getSwapQuoteExactInput(), etc.
|
|
2535
2336
|
} else {
|
|
2536
|
-
|
|
2337
|
+
|
|
2537
2338
|
// Use bonding curve methods: buy(), sell(), calculateBuyAmount(), etc.
|
|
2538
2339
|
}
|
|
2539
2340
|
|
|
@@ -2543,12 +2344,6 @@ async function monitorTokenStatus() {
|
|
|
2543
2344
|
|
|
2544
2345
|
// Set up listener for new DEX pools
|
|
2545
2346
|
const cleanupDexPool = sdk.onDexPoolCreation((poolData) => {
|
|
2546
|
-
console.log('New DEX pool created!');
|
|
2547
|
-
console.log(\` Token: \${poolData.tokenName}\`);
|
|
2548
|
-
console.log(\` Token0: \${poolData.token0}\`);
|
|
2549
|
-
console.log(\` Token1: \${poolData.token1}\`);
|
|
2550
|
-
console.log(\` Fee Tier: \${poolData.feeTier}\`);
|
|
2551
|
-
console.log(\` Initial TVL: \${poolData.tvl}\`);
|
|
2552
2347
|
|
|
2553
2348
|
// Take action on new pool
|
|
2554
2349
|
// Example: Automatically provide liquidity or execute arbitrage
|
|
@@ -2560,12 +2355,6 @@ async function monitorTokenStatus() {
|
|
|
2560
2355
|
|
|
2561
2356
|
// Set up listener for new token launches
|
|
2562
2357
|
const cleanupTokenCreation = sdk.onLaunchpadTokenCreation((tokenData) => {
|
|
2563
|
-
console.log('New token launched!');
|
|
2564
|
-
console.log(\` Name: \${tokenData.tokenName}\`);
|
|
2565
|
-
console.log(\` Symbol: \${tokenData.tokenSymbol}\`);
|
|
2566
|
-
console.log(\` Creator: \${tokenData.creator}\`);
|
|
2567
|
-
console.log(\` Max Supply: \${tokenData.maxSupply}\`);
|
|
2568
|
-
console.log(\` Base Price: \${tokenData.basePrice}\`);
|
|
2569
2358
|
|
|
2570
2359
|
// Take action on new token
|
|
2571
2360
|
// Example: Automatically buy early or analyze opportunity
|
|
@@ -2578,7 +2367,6 @@ async function monitorTokenStatus() {
|
|
|
2578
2367
|
async function autoTrade() {
|
|
2579
2368
|
// Monitor new tokens
|
|
2580
2369
|
sdk.onLaunchpadTokenCreation(async (token) => {
|
|
2581
|
-
console.log(\`New token: \${token.tokenName}\`);
|
|
2582
2370
|
|
|
2583
2371
|
// Wait for graduation
|
|
2584
2372
|
const checkGraduation = setInterval(async () => {
|
|
@@ -2586,27 +2374,25 @@ async function monitorTokenStatus() {
|
|
|
2586
2374
|
|
|
2587
2375
|
if (graduated) {
|
|
2588
2376
|
clearInterval(checkGraduation);
|
|
2589
|
-
console.log(\`\${token.tokenName} graduated! Switching to DEX trading.\`);
|
|
2590
2377
|
|
|
2591
2378
|
// Now use DEX methods instead of bonding curve
|
|
2592
2379
|
const quote = await sdk.getSwapQuoteExactInput('GALA', token.tokenName, '100');
|
|
2593
|
-
|
|
2380
|
+
|
|
2594
2381
|
}
|
|
2595
2382
|
}, 60000); // Check every minute
|
|
2596
2383
|
});
|
|
2597
2384
|
|
|
2598
2385
|
// Monitor new DEX pools
|
|
2599
2386
|
sdk.onDexPoolCreation(async (pool) => {
|
|
2600
|
-
console.log(\`New pool: \${pool.tokenName}\`);
|
|
2601
2387
|
|
|
2602
2388
|
// Analyze liquidity opportunity
|
|
2603
2389
|
const poolInfo = await sdk.getSwapPoolInfo(pool.token0, pool.token1);
|
|
2604
|
-
|
|
2390
|
+
|
|
2605
2391
|
});
|
|
2606
2392
|
}
|
|
2607
2393
|
|
|
2608
2394
|
// Keep process running
|
|
2609
|
-
|
|
2395
|
+
|
|
2610
2396
|
await new Promise(() => {}); // Run forever
|
|
2611
2397
|
|
|
2612
2398
|
// Cleanup when done
|
|
@@ -2623,7 +2409,7 @@ async function monitorTokenStatus() {
|
|
|
2623
2409
|
- **Price Discovery**: Track token lifecycle from launch to DEX
|
|
2624
2410
|
|
|
2625
2411
|
**Event Data:**
|
|
2626
|
-
- **DEX Pool Creation**: tokenName, token0, token1, feeTier,
|
|
2412
|
+
- **DEX Pool Creation**: tokenName, token0, token1, feeTier, TVL, timestamp
|
|
2627
2413
|
- **Token Launch**: tokenName, tokenSymbol, creator, maxSupply, basePrice, timestamp
|
|
2628
2414
|
|
|
2629
2415
|
**MCP Tool Equivalents:**
|
|
@@ -2663,11 +2449,9 @@ async function sdkUtilities() {
|
|
|
2663
2449
|
|
|
2664
2450
|
// Get GalaChain address (eth|0x... format)
|
|
2665
2451
|
const galaAddress = sdk.getAddress();
|
|
2666
|
-
console.log(\`GalaChain address: \${galaAddress}\`); // "eth|0x1234..."
|
|
2667
2452
|
|
|
2668
2453
|
// Get Ethereum address (0x... format)
|
|
2669
2454
|
const ethAddress = sdk.getEthereumAddress();
|
|
2670
|
-
console.log(\`Ethereum address: \${ethAddress}\`); // "0x1234..."
|
|
2671
2455
|
|
|
2672
2456
|
// ============================================================================
|
|
2673
2457
|
// WALLET MANAGEMENT - Check and update wallet
|
|
@@ -2675,18 +2459,16 @@ async function sdkUtilities() {
|
|
|
2675
2459
|
|
|
2676
2460
|
// Check if SDK has wallet configured
|
|
2677
2461
|
if (sdk.hasWallet()) {
|
|
2678
|
-
console.log('Wallet configured - can execute trades');
|
|
2679
2462
|
|
|
2680
2463
|
// Get wallet instance (for advanced use)
|
|
2681
2464
|
const wallet = sdk.getWallet();
|
|
2682
|
-
|
|
2465
|
+
|
|
2683
2466
|
} else {
|
|
2684
|
-
|
|
2467
|
+
|
|
2685
2468
|
}
|
|
2686
2469
|
|
|
2687
2470
|
// Update wallet at runtime
|
|
2688
2471
|
sdk.setWallet('new-private-key');
|
|
2689
|
-
console.log(\`New address: \${sdk.getAddress()}\`);
|
|
2690
2472
|
|
|
2691
2473
|
// ============================================================================
|
|
2692
2474
|
// CONFIGURATION ACCESS - Get SDK config
|
|
@@ -2694,10 +2476,6 @@ async function sdkUtilities() {
|
|
|
2694
2476
|
|
|
2695
2477
|
// Get SDK configuration
|
|
2696
2478
|
const config = sdk.getConfig();
|
|
2697
|
-
console.log(\`Base URL: \${config.baseUrl}\`);
|
|
2698
|
-
console.log(\`Environment: \${config.env}\`);
|
|
2699
|
-
console.log(\`Debug: \${config.debug}\`);
|
|
2700
|
-
console.log(\`Timeout: \${config.timeout}ms\`);
|
|
2701
2479
|
|
|
2702
2480
|
// ============================================================================
|
|
2703
2481
|
// VERSION INFORMATION - Get SDK version
|
|
@@ -2705,7 +2483,6 @@ async function sdkUtilities() {
|
|
|
2705
2483
|
|
|
2706
2484
|
// Get SDK version
|
|
2707
2485
|
const version = sdk.getVersion();
|
|
2708
|
-
console.log(\`SDK Version: \${version}\`); // "4.0.4-beta.0"
|
|
2709
2486
|
|
|
2710
2487
|
// ============================================================================
|
|
2711
2488
|
// URL GENERATION - Get frontend URLs for tokens
|
|
@@ -2713,7 +2490,7 @@ async function sdkUtilities() {
|
|
|
2713
2490
|
|
|
2714
2491
|
// Generate frontend URL for token
|
|
2715
2492
|
const url = sdk.getUrlByTokenName('anime');
|
|
2716
|
-
|
|
2493
|
+
|
|
2717
2494
|
// "https://launchpad.gala.com/token/anime" (production)
|
|
2718
2495
|
// "https://lpad-dev1.defi.gala.com/token/anime" (development)
|
|
2719
2496
|
|
|
@@ -2725,7 +2502,6 @@ async function sdkUtilities() {
|
|
|
2725
2502
|
});
|
|
2726
2503
|
|
|
2727
2504
|
const tokenUrl = sdk.getUrlByTokenName('mytoken');
|
|
2728
|
-
console.log(\`Share your token: \${tokenUrl}\`);
|
|
2729
2505
|
|
|
2730
2506
|
// ============================================================================
|
|
2731
2507
|
// MULTI-WALLET SCENARIO - Check multiple addresses
|
|
@@ -2735,15 +2511,10 @@ async function sdkUtilities() {
|
|
|
2735
2511
|
const wallet1 = createLaunchpadSDK({ wallet: 'private-key-1' });
|
|
2736
2512
|
const wallet2 = createLaunchpadSDK({ wallet: 'private-key-2' });
|
|
2737
2513
|
|
|
2738
|
-
console.log(\`Wallet 1: \${wallet1.getAddress()}\`);
|
|
2739
|
-
console.log(\`Wallet 2: \${wallet2.getAddress()}\`);
|
|
2740
|
-
|
|
2741
2514
|
// Compare balances
|
|
2742
2515
|
const balance1 = await wallet1.fetchGalaBalance();
|
|
2743
2516
|
const balance2 = await wallet2.fetchGalaBalance();
|
|
2744
2517
|
|
|
2745
|
-
console.log(\`Wallet 1 balance: \${balance1.balance}\`);
|
|
2746
|
-
console.log(\`Wallet 2 balance: \${balance2.balance}\`);
|
|
2747
2518
|
}
|
|
2748
2519
|
|
|
2749
2520
|
// ============================================================================
|
|
@@ -2754,11 +2525,8 @@ async function sdkUtilities() {
|
|
|
2754
2525
|
// Create SDK without wallet (read-only mode)
|
|
2755
2526
|
const readOnlySdk = createLaunchpadSDK();
|
|
2756
2527
|
|
|
2757
|
-
console.log(\`Has wallet: \${readOnlySdk.hasWallet()}\`); // false
|
|
2758
|
-
|
|
2759
2528
|
// Can fetch public data
|
|
2760
2529
|
const pools = await readOnlySdk.fetchPools({ type: 'recent', limit: 10 });
|
|
2761
|
-
console.log(\`Found \${pools.total} pools\`);
|
|
2762
2530
|
|
|
2763
2531
|
// Cannot execute trades (will throw error)
|
|
2764
2532
|
try {
|
|
@@ -2779,17 +2547,12 @@ async function sdkUtilities() {
|
|
|
2779
2547
|
config: { env: 'production' }
|
|
2780
2548
|
});
|
|
2781
2549
|
|
|
2782
|
-
console.log(\`Prod config: \${prodSdk.getConfig().baseUrl}\`);
|
|
2783
|
-
console.log(\`Prod URL: \${prodSdk.getUrlByTokenName('anime')}\`);
|
|
2784
|
-
|
|
2785
2550
|
// Development SDK
|
|
2786
2551
|
const devSdk = createLaunchpadSDK({
|
|
2787
2552
|
wallet: 'your-private-key',
|
|
2788
2553
|
config: { env: 'development' }
|
|
2789
2554
|
});
|
|
2790
2555
|
|
|
2791
|
-
console.log(\`Dev config: \${devSdk.getConfig().baseUrl}\`);
|
|
2792
|
-
console.log(\`Dev URL: \${devSdk.getUrlByTokenName('anime')}\`);
|
|
2793
2556
|
}
|
|
2794
2557
|
}
|
|
2795
2558
|
\`\`\`
|
|
@@ -2844,30 +2607,17 @@ async function subscribeToEvents() {
|
|
|
2844
2607
|
|
|
2845
2608
|
// Subscribe to liquidity additions
|
|
2846
2609
|
const cleanupAdded = sdk.subscribeToDexLiquidityAdded((event) => {
|
|
2847
|
-
|
|
2848
|
-
console.log(\` Pool: \${event.token0}-\${event.token1}\`);
|
|
2849
|
-
console.log(\` Amount0: \${event.amount0}\`);
|
|
2850
|
-
console.log(\` Amount1: \${event.amount1}\`);
|
|
2851
|
-
console.log(\` Owner: \${event.owner}\`);
|
|
2852
|
-
console.log(\` Position ID: \${event.positionId}\`);
|
|
2610
|
+
|
|
2853
2611
|
});
|
|
2854
2612
|
|
|
2855
2613
|
// Subscribe to liquidity changes (compound events)
|
|
2856
2614
|
const cleanupChanged = sdk.subscribeToDexLiquidityChanged((event) => {
|
|
2857
|
-
|
|
2858
|
-
console.log(\` Type: \${event.type}\`); // 'added', 'removed', 'modified'
|
|
2859
|
-
console.log(\` Pool: \${event.token0}-\${event.token1}\`);
|
|
2860
|
-
console.log(\` Delta: \${event.liquidityDelta}\`);
|
|
2615
|
+
|
|
2861
2616
|
});
|
|
2862
2617
|
|
|
2863
2618
|
// Subscribe to liquidity removals
|
|
2864
2619
|
const cleanupRemoved = sdk.subscribeToDexLiquidityRemoved((event) => {
|
|
2865
|
-
|
|
2866
|
-
console.log(\` Pool: \${event.token0}-\${event.token1}\`);
|
|
2867
|
-
console.log(\` Amount0: \${event.amount0}\`);
|
|
2868
|
-
console.log(\` Amount1: \${event.amount1}\`);
|
|
2869
|
-
console.log(\` Owner: \${event.owner}\`);
|
|
2870
|
-
console.log(\` Fees collected: \${event.fees0}, \${event.fees1}\`);
|
|
2620
|
+
|
|
2871
2621
|
});
|
|
2872
2622
|
|
|
2873
2623
|
// ============================================================================
|
|
@@ -2876,12 +2626,6 @@ async function subscribeToEvents() {
|
|
|
2876
2626
|
|
|
2877
2627
|
// Subscribe to new DEX pool creation
|
|
2878
2628
|
const cleanupPool = sdk.subscribeToDexPoolAdded((pool) => {
|
|
2879
|
-
console.log('New DEX pool created!');
|
|
2880
|
-
console.log(\` Token: \${pool.tokenName}\`);
|
|
2881
|
-
console.log(\` Token0: \${pool.token0}\`);
|
|
2882
|
-
console.log(\` Token1: \${pool.token1}\`);
|
|
2883
|
-
console.log(\` Fee Tier: \${pool.feeTier}\`);
|
|
2884
|
-
console.log(\` Initial TVL: \${pool.tvl}\`);
|
|
2885
2629
|
|
|
2886
2630
|
// Auto-provide liquidity to new pools
|
|
2887
2631
|
sdk.addSwapLiquidityByPrice({
|
|
@@ -2892,7 +2636,7 @@ async function subscribeToEvents() {
|
|
|
2892
2636
|
maxPrice: '1.05',
|
|
2893
2637
|
amount0Desired: '1000',
|
|
2894
2638
|
amount1Desired: '1000'
|
|
2895
|
-
}).then(() =>
|
|
2639
|
+
}).then(() => );
|
|
2896
2640
|
});
|
|
2897
2641
|
|
|
2898
2642
|
// ============================================================================
|
|
@@ -2901,16 +2645,10 @@ async function subscribeToEvents() {
|
|
|
2901
2645
|
|
|
2902
2646
|
// Subscribe to DEX swap executions
|
|
2903
2647
|
const cleanupSwap = sdk.subscribeToDexSwapExecuted((swap) => {
|
|
2904
|
-
console.log('DEX swap executed!');
|
|
2905
|
-
console.log(\` Pair: \${swap.tokenIn} → \${swap.tokenOut}\`);
|
|
2906
|
-
console.log(\` Amount In: \${swap.amountIn}\`);
|
|
2907
|
-
console.log(\` Amount Out: \${swap.amountOut}\`);
|
|
2908
|
-
console.log(\` Trader: \${swap.trader}\`);
|
|
2909
|
-
console.log(\` Fee Tier: \${swap.feeTier}\`);
|
|
2910
2648
|
|
|
2911
2649
|
// Track volume and price impact
|
|
2912
2650
|
const priceImpact = calculatePriceImpact(swap.amountIn, swap.amountOut);
|
|
2913
|
-
|
|
2651
|
+
|
|
2914
2652
|
});
|
|
2915
2653
|
|
|
2916
2654
|
// ============================================================================
|
|
@@ -2919,12 +2657,6 @@ async function subscribeToEvents() {
|
|
|
2919
2657
|
|
|
2920
2658
|
// Subscribe to new token launches
|
|
2921
2659
|
const cleanupToken = sdk.subscribeToTokenCreations((token) => {
|
|
2922
|
-
console.log('New token launched!');
|
|
2923
|
-
console.log(\` Name: \${token.tokenName}\`);
|
|
2924
|
-
console.log(\` Symbol: \${token.tokenSymbol}\`);
|
|
2925
|
-
console.log(\` Creator: \${token.creator}\`);
|
|
2926
|
-
console.log(\` Max Supply: \${token.maxSupply}\`);
|
|
2927
|
-
console.log(\` Base Price: \${token.basePrice}\`);
|
|
2928
2660
|
|
|
2929
2661
|
// Auto-buy new tokens
|
|
2930
2662
|
sdk.buy({
|
|
@@ -2932,7 +2664,7 @@ async function subscribeToEvents() {
|
|
|
2932
2664
|
amount: '100',
|
|
2933
2665
|
type: 'native',
|
|
2934
2666
|
slippageToleranceFactor: 0.01
|
|
2935
|
-
}).then(() =>
|
|
2667
|
+
}).then(() => );
|
|
2936
2668
|
});
|
|
2937
2669
|
|
|
2938
2670
|
// ============================================================================
|
|
@@ -2952,7 +2684,6 @@ async function subscribeToEvents() {
|
|
|
2952
2684
|
|
|
2953
2685
|
if (divergence > 0.01) {
|
|
2954
2686
|
// 1% arbitrage opportunity
|
|
2955
|
-
console.log(\`Arbitrage opportunity: \${divergence * 100}%\`);
|
|
2956
2687
|
|
|
2957
2688
|
// Execute arbitrage trade
|
|
2958
2689
|
await sdk.executeSwap(
|
|
@@ -2968,13 +2699,12 @@ async function subscribeToEvents() {
|
|
|
2968
2699
|
|
|
2969
2700
|
// Monitor liquidity additions for new opportunities
|
|
2970
2701
|
sdk.subscribeToDexLiquidityAdded(async (event) => {
|
|
2971
|
-
console.log(\`New liquidity in \${event.token0}-\${event.token1}\`);
|
|
2972
2702
|
|
|
2973
2703
|
// Check if pool has sufficient depth for arbitrage
|
|
2974
2704
|
const poolInfo = await sdk.getSwapPoolInfo(event.token0, event.token1);
|
|
2975
2705
|
// Use compareAmounts for precise liquidity threshold comparison
|
|
2976
2706
|
if (compareAmounts(poolInfo.liquidity, '100000') > 0) {
|
|
2977
|
-
|
|
2707
|
+
|
|
2978
2708
|
}
|
|
2979
2709
|
});
|
|
2980
2710
|
}
|
|
@@ -2988,7 +2718,6 @@ async function subscribeToEvents() {
|
|
|
2988
2718
|
|
|
2989
2719
|
// Auto-add liquidity to new pools
|
|
2990
2720
|
sdk.subscribeToDexPoolAdded(async (pool) => {
|
|
2991
|
-
console.log(\`New pool: \${pool.tokenName}\`);
|
|
2992
2721
|
|
|
2993
2722
|
// Wait for some initial swaps to establish price
|
|
2994
2723
|
setTimeout(async () => {
|
|
@@ -3007,24 +2736,22 @@ async function subscribeToEvents() {
|
|
|
3007
2736
|
amount1Desired: '10000'
|
|
3008
2737
|
});
|
|
3009
2738
|
|
|
3010
|
-
console.log('Liquidity added to new pool');
|
|
3011
2739
|
}
|
|
3012
2740
|
}, 60000); // Wait 1 minute
|
|
3013
2741
|
});
|
|
3014
2742
|
|
|
3015
2743
|
// Monitor liquidity removals (potential exit signal)
|
|
3016
2744
|
sdk.subscribeToDexLiquidityRemoved((event) => {
|
|
3017
|
-
console.log(\`Large liquidity removal: \${event.amount0}, \${event.amount1}\`);
|
|
3018
2745
|
|
|
3019
2746
|
// Check if we should also exit
|
|
3020
2747
|
if (isLargeRemoval(event)) {
|
|
3021
|
-
|
|
2748
|
+
|
|
3022
2749
|
}
|
|
3023
2750
|
});
|
|
3024
2751
|
}
|
|
3025
2752
|
|
|
3026
2753
|
// Keep subscriptions running
|
|
3027
|
-
|
|
2754
|
+
|
|
3028
2755
|
await new Promise(() => {}); // Run forever
|
|
3029
2756
|
|
|
3030
2757
|
// Cleanup when done
|
|
@@ -3054,7 +2781,7 @@ async function subscribeToEvents() {
|
|
|
3054
2781
|
|
|
3055
2782
|
**DexPoolAdded:**
|
|
3056
2783
|
- tokenName, token0, token1
|
|
3057
|
-
- feeTier,
|
|
2784
|
+
- feeTier, TVL
|
|
3058
2785
|
- timestamp
|
|
3059
2786
|
|
|
3060
2787
|
**SwapExecuted:**
|
|
@@ -3083,10 +2810,10 @@ async function subscribeToEvents() {
|
|
|
3083
2810
|
// Handle connection lifecycle events
|
|
3084
2811
|
await sdk.connectStreamWebSocket({
|
|
3085
2812
|
onConnect: () => {
|
|
3086
|
-
|
|
2813
|
+
|
|
3087
2814
|
},
|
|
3088
2815
|
onDisconnect: (reason) => {
|
|
3089
|
-
|
|
2816
|
+
|
|
3090
2817
|
// Implement reconnection logic if needed
|
|
3091
2818
|
},
|
|
3092
2819
|
onError: (error) => {
|
|
@@ -3096,7 +2823,7 @@ await sdk.connectStreamWebSocket({
|
|
|
3096
2823
|
|
|
3097
2824
|
// Check connection state
|
|
3098
2825
|
if (sdk.isStreamWebSocketConnected()) {
|
|
3099
|
-
|
|
2826
|
+
|
|
3100
2827
|
}
|
|
3101
2828
|
\`\`\`
|
|
3102
2829
|
|
|
@@ -3107,9 +2834,9 @@ if (sdk.isStreamWebSocketConnected()) {
|
|
|
3107
2834
|
await sdk.connectStreamWebSocket({
|
|
3108
2835
|
onTypingIndicator: (event) => {
|
|
3109
2836
|
if (event.isTyping) {
|
|
3110
|
-
|
|
2837
|
+
|
|
3111
2838
|
} else {
|
|
3112
|
-
|
|
2839
|
+
|
|
3113
2840
|
}
|
|
3114
2841
|
}
|
|
3115
2842
|
});
|
|
@@ -3375,41 +3102,30 @@ async function getCurrentSeason() {
|
|
|
3375
3102
|
const currentSeason = await sdk.fetchCurrentDexSeason();
|
|
3376
3103
|
|
|
3377
3104
|
if (currentSeason) {
|
|
3378
|
-
console.log('Current DEX Season:');
|
|
3379
|
-
console.log(\` Season ID: \${currentSeason.id}\`);
|
|
3380
|
-
console.log(\` Name: \${currentSeason.name}\`);
|
|
3381
|
-
console.log(\` Start: \${currentSeason.start.toISOString()}\`);
|
|
3382
|
-
console.log(\` End: \${currentSeason.end.toISOString()}\`);
|
|
3383
3105
|
|
|
3384
3106
|
// Check if season is currently active
|
|
3385
3107
|
const now = new Date();
|
|
3386
3108
|
const isActive = now >= currentSeason.start && now <= currentSeason.end;
|
|
3387
3109
|
|
|
3388
|
-
console.log(\` Active: \${isActive}\`);
|
|
3389
|
-
|
|
3390
3110
|
// Calculate time remaining
|
|
3391
3111
|
const timeRemaining = currentSeason.end.getTime() - now.getTime();
|
|
3392
3112
|
const daysRemaining = Math.floor(timeRemaining / (1000 * 60 * 60 * 24));
|
|
3393
3113
|
|
|
3394
|
-
console.log(\` Days remaining: \${daysRemaining}\`);
|
|
3395
|
-
|
|
3396
3114
|
// Fetch leaderboard for current season
|
|
3397
3115
|
const leaderboard = await sdk.fetchDexLeaderboardBySeasonId(currentSeason.id);
|
|
3398
|
-
console.log(\` Total participants: \${leaderboard.entries.length}\`);
|
|
3399
3116
|
|
|
3400
3117
|
// Show top 3 players
|
|
3401
3118
|
leaderboard.entries.slice(0, 3).forEach((entry, index) => {
|
|
3402
|
-
|
|
3119
|
+
|
|
3403
3120
|
});
|
|
3404
3121
|
} else {
|
|
3405
|
-
console.log('No active season (between seasons)');
|
|
3406
3122
|
|
|
3407
3123
|
// Fetch all seasons to see when next one starts
|
|
3408
3124
|
const allSeasons = await sdk.fetchAllDexSeasons();
|
|
3409
3125
|
const futureSeason = allSeasons.find(s => s.start > new Date());
|
|
3410
3126
|
|
|
3411
3127
|
if (futureSeason) {
|
|
3412
|
-
|
|
3128
|
+
|
|
3413
3129
|
}
|
|
3414
3130
|
}
|
|
3415
3131
|
}
|
|
@@ -3421,7 +3137,6 @@ async function participateInSeason() {
|
|
|
3421
3137
|
const season = await sdk.fetchCurrentDexSeason();
|
|
3422
3138
|
|
|
3423
3139
|
if (season) {
|
|
3424
|
-
console.log(\`Active season: \${season.name}\`);
|
|
3425
3140
|
|
|
3426
3141
|
// Execute trades to earn XP
|
|
3427
3142
|
const quote = await sdk.getSwapQuoteExactInput('GALA', 'GUSDC', '100');
|
|
@@ -3434,8 +3149,6 @@ async function participateInSeason() {
|
|
|
3434
3149
|
0.01
|
|
3435
3150
|
);
|
|
3436
3151
|
|
|
3437
|
-
console.log('Trade executed - XP earned!');
|
|
3438
|
-
|
|
3439
3152
|
// Check updated leaderboard position
|
|
3440
3153
|
const leaderboard = await sdk.fetchCurrentDexLeaderboard();
|
|
3441
3154
|
const myPosition = leaderboard?.entries.find(
|
|
@@ -3443,11 +3156,10 @@ async function participateInSeason() {
|
|
|
3443
3156
|
);
|
|
3444
3157
|
|
|
3445
3158
|
if (myPosition) {
|
|
3446
|
-
|
|
3447
|
-
console.log(\`Total XP: \${myPosition.totalXp}\`);
|
|
3159
|
+
|
|
3448
3160
|
}
|
|
3449
3161
|
} else {
|
|
3450
|
-
|
|
3162
|
+
|
|
3451
3163
|
}
|
|
3452
3164
|
}
|
|
3453
3165
|
\`\`\`
|
|
@@ -3502,11 +3214,9 @@ async function bridgeOperations() {
|
|
|
3502
3214
|
|
|
3503
3215
|
// 2. Get supported bridge tokens
|
|
3504
3216
|
const supportedTokens = await sdk.getSupportedBridgeTokens('Ethereum');
|
|
3505
|
-
console.log('Bridgeable to Ethereum:', supportedTokens.map(t => t.symbol));
|
|
3506
3217
|
|
|
3507
3218
|
// 3. Check if specific token is bridgeable
|
|
3508
3219
|
const canBridge = await sdk.isTokenBridgeableToEthereum('GALA');
|
|
3509
|
-
console.log('GALA bridgeable to Ethereum:', canBridge.bridgeable);
|
|
3510
3220
|
|
|
3511
3221
|
// 4. Estimate bridge fee (calculated externally by GalaConnect API)
|
|
3512
3222
|
const fee = await sdk.estimateBridgeFee({
|
|
@@ -3514,7 +3224,6 @@ async function bridgeOperations() {
|
|
|
3514
3224
|
destinationChain: 'Ethereum',
|
|
3515
3225
|
amount: '100',
|
|
3516
3226
|
});
|
|
3517
|
-
console.log('Bridge fee:', fee.totalFee, 'GALA');
|
|
3518
3227
|
|
|
3519
3228
|
// 5. Bridge Out: GalaChain → Ethereum
|
|
3520
3229
|
const bridgeOutTx = await sdk.bridgeOut({
|
|
@@ -3523,15 +3232,12 @@ async function bridgeOperations() {
|
|
|
3523
3232
|
destinationChain: 'Ethereum',
|
|
3524
3233
|
recipientAddress: '0x5678...',
|
|
3525
3234
|
});
|
|
3526
|
-
console.log('Bridge out TX:', bridgeOutTx.transactionHash);
|
|
3527
3235
|
|
|
3528
3236
|
// 6. Get bridge status
|
|
3529
3237
|
const status = await sdk.getBridgeStatus(bridgeOutTx.transactionHash);
|
|
3530
|
-
console.log('Bridge status:', status.status);
|
|
3531
3238
|
|
|
3532
3239
|
// 7. Get Ethereum transaction status
|
|
3533
3240
|
const ethTxStatus = await sdk.getEthereumTransactionStatus(bridgeOutTx.transactionHash);
|
|
3534
|
-
console.log('ETH TX confirmed:', ethTxStatus.confirmed);
|
|
3535
3241
|
|
|
3536
3242
|
// 8. Query external chain balances
|
|
3537
3243
|
const ethBalance = await sdk.fetchEthereumWalletNativeBalance();
|
|
@@ -3540,7 +3246,7 @@ async function bridgeOperations() {
|
|
|
3540
3246
|
|
|
3541
3247
|
// 9. Discover all bridgeable tokens
|
|
3542
3248
|
const allBridgeable = await sdk.fetchAllBridgeableTokensByNetwork('ETHEREUM');
|
|
3543
|
-
|
|
3249
|
+
|
|
3544
3250
|
}
|
|
3545
3251
|
\`\`\`
|
|
3546
3252
|
|
|
@@ -3589,18 +3295,16 @@ async function discoverDexTokens() {
|
|
|
3589
3295
|
limit: 20
|
|
3590
3296
|
});
|
|
3591
3297
|
|
|
3592
|
-
console.log(\`Found \${tokens.total} tokens, page \${tokens.page} of \${tokens.totalPages}\`);
|
|
3593
3298
|
tokens.items.forEach(token => {
|
|
3594
|
-
|
|
3299
|
+
|
|
3595
3300
|
});
|
|
3596
3301
|
|
|
3597
3302
|
// Option 2: Fetch ALL tokens (auto-pagination)
|
|
3598
3303
|
const allTokens = await sdk.fetchAllAvailableDexTokens();
|
|
3599
|
-
console.log(\`Total DEX tokens: \${allTokens.length}\`);
|
|
3600
3304
|
|
|
3601
3305
|
// Option 3: Search for specific tokens
|
|
3602
3306
|
const searchResults = await sdk.fetchAllAvailableDexTokens({ search: 'USD' });
|
|
3603
|
-
|
|
3307
|
+
|
|
3604
3308
|
}
|
|
3605
3309
|
\`\`\`
|
|
3606
3310
|
|
|
@@ -3641,7 +3345,6 @@ async function wrapToken() {
|
|
|
3641
3345
|
memo: 'Wrapping for DEX trading' // Optional
|
|
3642
3346
|
});
|
|
3643
3347
|
|
|
3644
|
-
console.log('Wrap transaction:', result.transactionId);
|
|
3645
3348
|
}
|
|
3646
3349
|
\`\`\`
|
|
3647
3350
|
|
|
@@ -3659,7 +3362,6 @@ async function unwrapToken() {
|
|
|
3659
3362
|
memo: 'Unwrapping after trading' // Optional
|
|
3660
3363
|
});
|
|
3661
3364
|
|
|
3662
|
-
console.log('Unwrap transaction:', result.transactionId);
|
|
3663
3365
|
}
|
|
3664
3366
|
\`\`\`
|
|
3665
3367
|
|
|
@@ -3671,11 +3373,10 @@ async function estimateFees() {
|
|
|
3671
3373
|
|
|
3672
3374
|
// Estimate wrap fee (uses cross_channel_authorization)
|
|
3673
3375
|
const wrapFee = await sdk.estimateWrapFee('MUSIC', '100');
|
|
3674
|
-
console.log('Wrap fee:', wrapFee);
|
|
3675
3376
|
|
|
3676
3377
|
// Estimate unwrap fee (uses automatic authorization)
|
|
3677
3378
|
const unwrapFee = await sdk.estimateUnwrapFee('GMUSIC', '100');
|
|
3678
|
-
|
|
3379
|
+
|
|
3679
3380
|
}
|
|
3680
3381
|
\`\`\`
|
|
3681
3382
|
|
|
@@ -3686,7 +3387,7 @@ async function checkStatus() {
|
|
|
3686
3387
|
const sdk = createLaunchpadSDK({ wallet: 'your-private-key' });
|
|
3687
3388
|
|
|
3688
3389
|
const status = await sdk.getWrapStatus('transaction-id-here');
|
|
3689
|
-
|
|
3390
|
+
|
|
3690
3391
|
}
|
|
3691
3392
|
\`\`\`
|
|
3692
3393
|
|
|
@@ -3710,7 +3411,7 @@ async function discoverWrappableTokens() {
|
|
|
3710
3411
|
|
|
3711
3412
|
// Check if token is wrappable
|
|
3712
3413
|
const isWrappable = await sdk.isTokenWrappable('$MUSIC|Unit|none|none');
|
|
3713
|
-
|
|
3414
|
+
|
|
3714
3415
|
}
|
|
3715
3416
|
\`\`\`
|
|
3716
3417
|
|
|
@@ -3741,7 +3442,7 @@ async function getReferralUrl() {
|
|
|
3741
3442
|
|
|
3742
3443
|
// Get your unique referral URL
|
|
3743
3444
|
const result = await sdk.fetchReferralUrl();
|
|
3744
|
-
|
|
3445
|
+
|
|
3745
3446
|
}
|
|
3746
3447
|
\`\`\`
|
|
3747
3448
|
|
|
@@ -3758,9 +3459,8 @@ async function fetchReferrals() {
|
|
|
3758
3459
|
limit: 20
|
|
3759
3460
|
});
|
|
3760
3461
|
|
|
3761
|
-
console.log('Total referrals:', referrals.total);
|
|
3762
3462
|
referrals.items.forEach(ref => {
|
|
3763
|
-
|
|
3463
|
+
|
|
3764
3464
|
});
|
|
3765
3465
|
}
|
|
3766
3466
|
\`\`\`
|
|
@@ -3773,7 +3473,7 @@ async function fetchAllReferrals() {
|
|
|
3773
3473
|
|
|
3774
3474
|
// Get ALL referrals with auto-pagination
|
|
3775
3475
|
const allReferrals = await sdk.fetchAllReferrals({ address: '0x...' });
|
|
3776
|
-
|
|
3476
|
+
|
|
3777
3477
|
}
|
|
3778
3478
|
\`\`\`
|
|
3779
3479
|
|
|
@@ -3784,8 +3484,7 @@ async function getReferralSummary() {
|
|
|
3784
3484
|
const sdk = createLaunchpadSDK({ wallet: 'your-private-key' });
|
|
3785
3485
|
|
|
3786
3486
|
const summary = await sdk.fetchReferralsSummary({ address: '0x...' });
|
|
3787
|
-
|
|
3788
|
-
console.log('Total rewards earned:', summary.totalRewards);
|
|
3487
|
+
|
|
3789
3488
|
}
|
|
3790
3489
|
\`\`\`
|
|
3791
3490
|
|
|
@@ -3813,14 +3512,12 @@ async function registerAccount() {
|
|
|
3813
3512
|
|
|
3814
3513
|
// Register the SDK wallet
|
|
3815
3514
|
const result = await sdk.registerAccount();
|
|
3816
|
-
console.log('Account exists:', result.exists);
|
|
3817
|
-
console.log('Wallet alias:', result.walletAlias);
|
|
3818
3515
|
|
|
3819
3516
|
// Register a specific address
|
|
3820
3517
|
const otherResult = await sdk.registerAccount({
|
|
3821
3518
|
address: '0x1234...' // Supports eth|, 0x, or client| formats
|
|
3822
3519
|
});
|
|
3823
|
-
|
|
3520
|
+
|
|
3824
3521
|
}
|
|
3825
3522
|
\`\`\`
|
|
3826
3523
|
|
|
@@ -3858,24 +3555,18 @@ async function manageStream() {
|
|
|
3858
3555
|
|
|
3859
3556
|
// Start a stream for your token
|
|
3860
3557
|
const stream = await sdk.startStream('mytoken');
|
|
3861
|
-
|
|
3862
|
-
console.log('RTMP URL:', stream.rtmpUrl);
|
|
3863
|
-
console.log('Playback URL:', stream.playbackUrl);
|
|
3558
|
+
|
|
3864
3559
|
// Use stream.streamKey in OBS or other RTMP software
|
|
3865
3560
|
|
|
3866
3561
|
// Get stream info (public endpoint)
|
|
3867
3562
|
const info = await sdk.getStreamInfo('mytoken');
|
|
3868
|
-
console.log('Status:', info.status); // IDLE, ACTIVE, DISABLED
|
|
3869
|
-
console.log('Is Live:', info.isLive);
|
|
3870
|
-
console.log('Viewers:', info.viewerCount);
|
|
3871
3563
|
|
|
3872
3564
|
// Stop the stream when done
|
|
3873
3565
|
await sdk.stopStream('mytoken');
|
|
3874
|
-
console.log('Stream stopped');
|
|
3875
3566
|
|
|
3876
3567
|
// Reset stream key if compromised
|
|
3877
3568
|
const newKey = await sdk.resetStreamKey('mytoken');
|
|
3878
|
-
|
|
3569
|
+
|
|
3879
3570
|
}
|
|
3880
3571
|
\`\`\`
|
|
3881
3572
|
|
|
@@ -3891,18 +3582,13 @@ async function manageRecordings() {
|
|
|
3891
3582
|
page: 1,
|
|
3892
3583
|
limit: 20,
|
|
3893
3584
|
});
|
|
3894
|
-
console.log('Total recordings:', recordings.total);
|
|
3895
3585
|
|
|
3896
3586
|
for (const rec of recordings.recordings) {
|
|
3897
|
-
|
|
3898
|
-
console.log('Duration:', rec.duration, 'seconds');
|
|
3899
|
-
console.log('Status:', rec.status); // READY, PROCESSING, ERRORED
|
|
3587
|
+
|
|
3900
3588
|
}
|
|
3901
3589
|
|
|
3902
3590
|
// Get download URL for a recording
|
|
3903
3591
|
const download = await sdk.getRecordingDownload('mytoken', 'asset-123');
|
|
3904
|
-
console.log('Download URL:', download.downloadUrl);
|
|
3905
|
-
console.log('Expires:', download.expiresAt);
|
|
3906
3592
|
|
|
3907
3593
|
// Delete a recording
|
|
3908
3594
|
await sdk.deleteRecording('mytoken', 'asset-123');
|
|
@@ -3919,8 +3605,6 @@ async function manageSimulcast() {
|
|
|
3919
3605
|
|
|
3920
3606
|
// Get existing simulcast targets
|
|
3921
3607
|
const targets = await sdk.getSimulcastTargets('mytoken');
|
|
3922
|
-
console.log('Max targets:', targets.maxTargets);
|
|
3923
|
-
console.log('Current targets:', targets.targets.length);
|
|
3924
3608
|
|
|
3925
3609
|
// Add YouTube simulcast
|
|
3926
3610
|
const youtube = await sdk.addSimulcastTarget({
|
|
@@ -3930,7 +3614,6 @@ async function manageSimulcast() {
|
|
|
3930
3614
|
streamKey: 'your-youtube-stream-key',
|
|
3931
3615
|
name: 'My YouTube Channel',
|
|
3932
3616
|
});
|
|
3933
|
-
console.log('Added target:', youtube.target.targetId);
|
|
3934
3617
|
|
|
3935
3618
|
// Add Twitch simulcast
|
|
3936
3619
|
await sdk.addSimulcastTarget({
|
|
@@ -3965,7 +3648,6 @@ async function adminOperations() {
|
|
|
3965
3648
|
|
|
3966
3649
|
// Get global streaming status
|
|
3967
3650
|
const globalStatus = await sdk.getGlobalStreamingStatus();
|
|
3968
|
-
console.log('Global streaming enabled:', globalStatus.enabled);
|
|
3969
3651
|
|
|
3970
3652
|
// Enable/disable streaming globally (maintenance mode)
|
|
3971
3653
|
await sdk.setGlobalStreamingEnabled(false); // Disable all streams
|
|
@@ -4038,7 +3720,7 @@ async function restChat() {
|
|
|
4038
3720
|
});
|
|
4039
3721
|
|
|
4040
3722
|
for (const msg of messages.messages) {
|
|
4041
|
-
|
|
3723
|
+
|
|
4042
3724
|
}
|
|
4043
3725
|
|
|
4044
3726
|
// Send a chat message via REST
|
|
@@ -4046,20 +3728,18 @@ async function restChat() {
|
|
|
4046
3728
|
tokenName: 'mytoken',
|
|
4047
3729
|
content: 'Hello everyone!',
|
|
4048
3730
|
});
|
|
4049
|
-
console.log('Message ID:', sent.message.messageId);
|
|
4050
3731
|
|
|
4051
3732
|
// Delete a chat message (user can delete own, admin can delete any)
|
|
4052
3733
|
const deleted = await sdk.deleteChatMessage({
|
|
4053
3734
|
tokenName: 'mytoken',
|
|
4054
3735
|
messageId: sent.message.messageId,
|
|
4055
3736
|
});
|
|
4056
|
-
console.log('Message deleted:', deleted.deleted);
|
|
4057
3737
|
|
|
4058
3738
|
// Check chat status
|
|
4059
3739
|
const status = await sdk.getChatStatus('mytoken');
|
|
4060
|
-
|
|
3740
|
+
|
|
4061
3741
|
if (!status.enabled) {
|
|
4062
|
-
|
|
3742
|
+
|
|
4063
3743
|
}
|
|
4064
3744
|
}
|
|
4065
3745
|
\`\`\`
|
|
@@ -4077,17 +3757,17 @@ async function webSocketChat() {
|
|
|
4077
3757
|
|
|
4078
3758
|
// Connect with event callbacks
|
|
4079
3759
|
await sdk.connectStreamWebSocket({
|
|
4080
|
-
onConnect: () =>
|
|
4081
|
-
onDisconnect: (reason) =>
|
|
3760
|
+
onConnect: () => ,
|
|
3761
|
+
onDisconnect: (reason) => ,
|
|
4082
3762
|
onError: (error) => console.error('Error:', error),
|
|
4083
3763
|
onChatMessage: (msg) => {
|
|
4084
|
-
|
|
3764
|
+
|
|
4085
3765
|
},
|
|
4086
3766
|
onViewerCount: (data) => {
|
|
4087
|
-
|
|
3767
|
+
|
|
4088
3768
|
},
|
|
4089
3769
|
onStreamStatus: (status) => {
|
|
4090
|
-
|
|
3770
|
+
|
|
4091
3771
|
},
|
|
4092
3772
|
});
|
|
4093
3773
|
|
|
@@ -4096,7 +3776,6 @@ async function webSocketChat() {
|
|
|
4096
3776
|
|
|
4097
3777
|
// Subscribe to a stream's events
|
|
4098
3778
|
const subscribed = await sdk.subscribeToStream('mytoken');
|
|
4099
|
-
console.log('Subscribed, stream status:', subscribed.status);
|
|
4100
3779
|
|
|
4101
3780
|
// Send message via WebSocket (lower latency)
|
|
4102
3781
|
await sdk.sendStreamChatViaWebSocket('mytoken', 'Hello via WebSocket!');
|
|
@@ -4129,7 +3808,6 @@ async function adminChat() {
|
|
|
4129
3808
|
|
|
4130
3809
|
// Get global chat status
|
|
4131
3810
|
const globalStatus = await sdk.getGlobalChatStatus();
|
|
4132
|
-
console.log('Global chat enabled:', globalStatus.enabled);
|
|
4133
3811
|
|
|
4134
3812
|
// Disable/enable chat globally
|
|
4135
3813
|
await sdk.setGlobalChatEnabled(false); // Disable all chat
|
|
@@ -4199,36 +3877,30 @@ const sdk = createLaunchpadSDK({
|
|
|
4199
3877
|
|
|
4200
3878
|
// 1. Login to get JWT token
|
|
4201
3879
|
const session = await sdk.login();
|
|
4202
|
-
console.log('Authenticated:', session.address);
|
|
4203
|
-
console.log('Token expires in:', session.expiresIn, 'seconds');
|
|
4204
3880
|
|
|
4205
3881
|
// 2. Check authentication status
|
|
4206
3882
|
if (sdk.isAuthenticated()) {
|
|
4207
|
-
|
|
3883
|
+
|
|
4208
3884
|
}
|
|
4209
3885
|
|
|
4210
3886
|
// 3. Get current session info
|
|
4211
3887
|
const info = await sdk.getSession();
|
|
4212
|
-
console.log('Session issued at:', info.issuedAt);
|
|
4213
|
-
console.log('Session expires at:', info.expiresAt);
|
|
4214
3888
|
|
|
4215
3889
|
// 4. Access token directly (for custom requests)
|
|
4216
3890
|
const token = sdk.getAccessToken();
|
|
4217
|
-
console.log('JWT token:', token);
|
|
4218
3891
|
|
|
4219
3892
|
// 5. Refresh token before expiry
|
|
4220
3893
|
if (sdk.shouldRefreshToken()) {
|
|
4221
3894
|
const refreshed = await sdk.refreshToken();
|
|
4222
|
-
|
|
3895
|
+
|
|
4223
3896
|
}
|
|
4224
3897
|
|
|
4225
3898
|
// 6. Ensure valid token (auto-refreshes if needed)
|
|
4226
3899
|
const validToken = await sdk.ensureValidToken();
|
|
4227
|
-
console.log('Valid token obtained');
|
|
4228
3900
|
|
|
4229
3901
|
// 7. Logout when done
|
|
4230
3902
|
sdk.logout();
|
|
4231
|
-
|
|
3903
|
+
|
|
4232
3904
|
\`\`\`
|
|
4233
3905
|
|
|
4234
3906
|
## Auto-Refresh Behavior
|
|
@@ -4351,7 +4023,6 @@ const permanentBan = await sdk.createBan({
|
|
|
4351
4023
|
userAddress: 'eth|0x1234567890abcdef1234567890abcdef12345678',
|
|
4352
4024
|
reason: 'Spamming chat',
|
|
4353
4025
|
});
|
|
4354
|
-
console.log('Permanent ban created:', permanentBan.ban.id);
|
|
4355
4026
|
|
|
4356
4027
|
// Create a temporary ban (1 hour)
|
|
4357
4028
|
const tempBan = await sdk.createBan({
|
|
@@ -4360,14 +4031,13 @@ const tempBan = await sdk.createBan({
|
|
|
4360
4031
|
reason: 'Inappropriate behavior',
|
|
4361
4032
|
durationSeconds: BAN_DURATIONS.ONE_HOUR, // 3600 seconds
|
|
4362
4033
|
});
|
|
4363
|
-
console.log('Temp ban expires:', tempBan.ban.expiresAt);
|
|
4364
4034
|
|
|
4365
4035
|
// Remove a ban (unban user)
|
|
4366
4036
|
const unbanned = await sdk.removeBan({
|
|
4367
4037
|
tokenName: 'mytoken',
|
|
4368
4038
|
userAddress: 'eth|0x1234567890abcdef1234567890abcdef12345678',
|
|
4369
4039
|
});
|
|
4370
|
-
|
|
4040
|
+
|
|
4371
4041
|
\`\`\`
|
|
4372
4042
|
|
|
4373
4043
|
## Duration Presets
|
|
@@ -4398,12 +4068,9 @@ const allBans = await sdk.listBans({
|
|
|
4398
4068
|
page: 1,
|
|
4399
4069
|
limit: 20,
|
|
4400
4070
|
});
|
|
4401
|
-
console.log('Total bans:', allBans.meta.total);
|
|
4402
4071
|
|
|
4403
4072
|
for (const ban of allBans.bans) {
|
|
4404
|
-
|
|
4405
|
-
console.log(\` Permanent: \${ban.isPermanent}\`);
|
|
4406
|
-
console.log(\` Expires: \${ban.expiresAt || 'Never'}\`);
|
|
4073
|
+
|
|
4407
4074
|
}
|
|
4408
4075
|
|
|
4409
4076
|
// Search bans by user
|
|
@@ -4430,12 +4097,9 @@ const status = await sdk.getBanStatus({
|
|
|
4430
4097
|
});
|
|
4431
4098
|
|
|
4432
4099
|
if (status.banned) {
|
|
4433
|
-
|
|
4434
|
-
console.log('Reason:', status.ban?.reason);
|
|
4435
|
-
console.log('Permanent:', status.ban?.isPermanent);
|
|
4436
|
-
console.log('Expires:', status.ban?.expiresAt);
|
|
4100
|
+
|
|
4437
4101
|
} else {
|
|
4438
|
-
|
|
4102
|
+
|
|
4439
4103
|
}
|
|
4440
4104
|
\`\`\`
|
|
4441
4105
|
|
|
@@ -4449,14 +4113,12 @@ const viewers = await sdk.getActiveUsers({
|
|
|
4449
4113
|
tokenName: 'mytoken',
|
|
4450
4114
|
type: ACTIVE_USER_TYPE.VIEWERS, // or 'viewers'
|
|
4451
4115
|
});
|
|
4452
|
-
console.log('Active viewers:', viewers.total);
|
|
4453
4116
|
|
|
4454
4117
|
// Get only chat participants
|
|
4455
4118
|
const chatters = await sdk.getActiveUsers({
|
|
4456
4119
|
tokenName: 'mytoken',
|
|
4457
4120
|
type: ACTIVE_USER_TYPE.CHAT_PARTICIPANTS, // or 'chat_participants'
|
|
4458
4121
|
});
|
|
4459
|
-
console.log('Chat participants:', chatters.total);
|
|
4460
4122
|
|
|
4461
4123
|
// Search active users
|
|
4462
4124
|
const searchActive = await sdk.getActiveUsers({
|
|
@@ -4465,8 +4127,7 @@ const searchActive = await sdk.getActiveUsers({
|
|
|
4465
4127
|
});
|
|
4466
4128
|
|
|
4467
4129
|
for (const user of searchActive.users) {
|
|
4468
|
-
|
|
4469
|
-
console.log(\` In chat: \${user.isChatParticipant}\`);
|
|
4130
|
+
|
|
4470
4131
|
}
|
|
4471
4132
|
\`\`\`
|
|
4472
4133
|
|
|
@@ -4499,17 +4160,14 @@ Ban events are broadcast to affected users via WebSocket:
|
|
|
4499
4160
|
// Listen for ban events
|
|
4500
4161
|
sdk.connectStreamWebSocket({
|
|
4501
4162
|
onUserBanned: (event) => {
|
|
4502
|
-
|
|
4503
|
-
console.log('Reason:', event.reason);
|
|
4504
|
-
console.log('Expires:', event.expiresAt);
|
|
4163
|
+
|
|
4505
4164
|
},
|
|
4506
4165
|
onUserUnbanned: (event) => {
|
|
4507
|
-
|
|
4166
|
+
|
|
4508
4167
|
},
|
|
4509
4168
|
onBanEnforcement: (event) => {
|
|
4510
4169
|
// Received when banned user tries to chat/react
|
|
4511
|
-
|
|
4512
|
-
console.log('Reason:', event.reason);
|
|
4170
|
+
|
|
4513
4171
|
},
|
|
4514
4172
|
});
|
|
4515
4173
|
\`\`\`
|
|
@@ -4555,17 +4213,16 @@ await sdk.login();
|
|
|
4555
4213
|
// Create a moderator key for specific tokens
|
|
4556
4214
|
const result = await sdk.createApiKey({
|
|
4557
4215
|
role: API_KEY_ROLE.MODERATOR,
|
|
4558
|
-
description: 'Chat moderation bot',
|
|
4216
|
+
description: 'Chat moderation bot.',
|
|
4559
4217
|
delegateAllTokens: false,
|
|
4560
4218
|
tokenNames: ['mytoken', 'othertoken'],
|
|
4561
4219
|
expiresAt: '2025-12-31T23:59:59Z', // Optional expiration
|
|
4562
4220
|
});
|
|
4563
4221
|
|
|
4564
4222
|
// CRITICAL: Save this immediately - shown only once!
|
|
4565
|
-
|
|
4223
|
+
|
|
4566
4224
|
// Format: glp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
4567
|
-
|
|
4568
|
-
console.log('Prefix:', result.keyPrefix);
|
|
4225
|
+
|
|
4569
4226
|
\`\`\`
|
|
4570
4227
|
|
|
4571
4228
|
## Role Hierarchy
|
|
@@ -4598,14 +4255,14 @@ const canOwn = roleHasSufficientPermission('MODERATOR', 'OWNER'); // false
|
|
|
4598
4255
|
// Delegate all tokens (current and future)
|
|
4599
4256
|
const allTokensKey = await sdk.createApiKey({
|
|
4600
4257
|
role: API_KEY_ROLE.MODERATOR,
|
|
4601
|
-
description: 'All tokens moderator',
|
|
4258
|
+
description: 'All tokens moderator.',
|
|
4602
4259
|
delegateAllTokens: true,
|
|
4603
4260
|
});
|
|
4604
4261
|
|
|
4605
4262
|
// Delegate specific tokens only
|
|
4606
4263
|
const specificKey = await sdk.createApiKey({
|
|
4607
4264
|
role: API_KEY_ROLE.MANAGER,
|
|
4608
|
-
description: 'Project manager for specific tokens',
|
|
4265
|
+
description: 'Project manager for specific tokens.',
|
|
4609
4266
|
delegateAllTokens: false,
|
|
4610
4267
|
tokenNames: ['token1', 'token2', 'token3'], // Case-insensitive
|
|
4611
4268
|
});
|
|
@@ -4619,18 +4276,14 @@ const list = await sdk.listApiKeys({
|
|
|
4619
4276
|
page: 1,
|
|
4620
4277
|
limit: 20,
|
|
4621
4278
|
});
|
|
4622
|
-
console.log('Total keys:', list.meta.total);
|
|
4623
4279
|
|
|
4624
4280
|
for (const key of list.apiKeys) {
|
|
4625
|
-
|
|
4626
|
-
console.log(\` Description: \${key.description || 'None'}\`);
|
|
4627
|
-
console.log(\` Last used: \${key.lastUsedAt || 'Never'}\`);
|
|
4628
|
-
console.log(\` Expires: \${key.expiresAt || 'Never'}\`);
|
|
4281
|
+
|
|
4629
4282
|
}
|
|
4630
4283
|
|
|
4631
4284
|
// Get single API key by ID
|
|
4632
4285
|
const key = await sdk.getApiKey(123);
|
|
4633
|
-
|
|
4286
|
+
|
|
4634
4287
|
\`\`\`
|
|
4635
4288
|
|
|
4636
4289
|
## Updating API Keys
|
|
@@ -4638,7 +4291,7 @@ console.log('Key details:', key);
|
|
|
4638
4291
|
\`\`\`typescript
|
|
4639
4292
|
// Update description
|
|
4640
4293
|
const updated = await sdk.updateApiKey(123, {
|
|
4641
|
-
description: 'Updated description',
|
|
4294
|
+
description: 'Updated description.',
|
|
4642
4295
|
});
|
|
4643
4296
|
|
|
4644
4297
|
// Upgrade role
|
|
@@ -4673,7 +4326,6 @@ await sdk.updateApiKey(123, {
|
|
|
4673
4326
|
\`\`\`typescript
|
|
4674
4327
|
// Revoke (soft delete) an API key
|
|
4675
4328
|
await sdk.revokeApiKey(123);
|
|
4676
|
-
console.log('API key revoked');
|
|
4677
4329
|
|
|
4678
4330
|
// Key is now unusable - attempts to use it will fail with 401
|
|
4679
4331
|
\`\`\`
|
|
@@ -4683,7 +4335,7 @@ console.log('API key revoked');
|
|
|
4683
4335
|
\`\`\`typescript
|
|
4684
4336
|
// Get list of valid roles
|
|
4685
4337
|
const roles = sdk.getApiKeyRoles();
|
|
4686
|
-
|
|
4338
|
+
|
|
4687
4339
|
// ['MODERATOR', 'TECHNICAL_PRODUCER', 'MANAGER', 'OWNER']
|
|
4688
4340
|
\`\`\`
|
|
4689
4341
|
|
|
@@ -4698,13 +4350,13 @@ import {
|
|
|
4698
4350
|
|
|
4699
4351
|
// Validate role string
|
|
4700
4352
|
if (isValidApiKeyRole('MODERATOR')) {
|
|
4701
|
-
|
|
4353
|
+
|
|
4702
4354
|
}
|
|
4703
4355
|
|
|
4704
4356
|
// Validate creation options
|
|
4705
4357
|
const createErrors = validateCreateApiKeyOptions({
|
|
4706
4358
|
role: 'MODERATOR',
|
|
4707
|
-
description: 'Test key',
|
|
4359
|
+
description: 'Test key.',
|
|
4708
4360
|
});
|
|
4709
4361
|
if (createErrors.length > 0) {
|
|
4710
4362
|
console.error('Validation errors:', createErrors);
|
|
@@ -4767,14 +4419,12 @@ await sdk.login();
|
|
|
4767
4419
|
const result = await sdk.createModeratorInvite({
|
|
4768
4420
|
tokenName: 'mytoken',
|
|
4769
4421
|
role: MODERATOR_ROLE.MODERATOR,
|
|
4770
|
-
description: 'John - Friday stream moderator',
|
|
4422
|
+
description: 'John - Friday stream moderator.',
|
|
4771
4423
|
expiresAt: '2025-12-31T23:59:59Z', // Optional expiration
|
|
4772
4424
|
});
|
|
4773
4425
|
|
|
4774
4426
|
// Share this URL with the intended moderator
|
|
4775
|
-
|
|
4776
|
-
console.log('Invite Code:', result.invite.inviteCode);
|
|
4777
|
-
console.log('Status:', result.invite.status); // PENDING
|
|
4427
|
+
|
|
4778
4428
|
\`\`\`
|
|
4779
4429
|
|
|
4780
4430
|
## Moderator Roles
|
|
@@ -4799,14 +4449,8 @@ const list = await sdk.listModeratorInvites({
|
|
|
4799
4449
|
limit: 20,
|
|
4800
4450
|
});
|
|
4801
4451
|
|
|
4802
|
-
console.log('Total invites:', list.meta.totalItems);
|
|
4803
|
-
|
|
4804
4452
|
for (const invite of list.invites) {
|
|
4805
|
-
|
|
4806
|
-
console.log(\` Status: \${invite.status}\`);
|
|
4807
|
-
console.log(\` Description: \${invite.description || 'None'}\`);
|
|
4808
|
-
console.log(\` Created: \${invite.createdAt}\`);
|
|
4809
|
-
console.log(\` Expires: \${invite.expiresAt || 'Never'}\`);
|
|
4453
|
+
|
|
4810
4454
|
}
|
|
4811
4455
|
\`\`\`
|
|
4812
4456
|
|
|
@@ -4823,9 +4467,6 @@ const result = await sdk.claimModeratorInvite({
|
|
|
4823
4467
|
inviteCode: inviteCode,
|
|
4824
4468
|
});
|
|
4825
4469
|
|
|
4826
|
-
console.log('Claimed token:', result.token.tokenName);
|
|
4827
|
-
console.log('Your role:', result.token.role);
|
|
4828
|
-
console.log('Claimed at:', result.token.claimedAt);
|
|
4829
4470
|
// Token now appears in /studio dashboard
|
|
4830
4471
|
\`\`\`
|
|
4831
4472
|
|
|
@@ -4835,11 +4476,6 @@ console.log('Claimed at:', result.token.claimedAt);
|
|
|
4835
4476
|
// Preview invite details before logging in (public endpoint)
|
|
4836
4477
|
const preview = await sdk.getModeratorInviteByCode('abc123...');
|
|
4837
4478
|
|
|
4838
|
-
console.log('Token:', preview.tokenName);
|
|
4839
|
-
console.log('Symbol:', preview.tokenSymbol);
|
|
4840
|
-
console.log('Role offered:', preview.role);
|
|
4841
|
-
console.log('Status:', preview.status);
|
|
4842
|
-
console.log('Invited by:', preview.invitedBy.fullName);
|
|
4843
4479
|
\`\`\`
|
|
4844
4480
|
|
|
4845
4481
|
## Getting Moderated Tokens (Studio Dashboard)
|
|
@@ -4854,9 +4490,7 @@ const tokens = await sdk.getModeratedTokens({
|
|
|
4854
4490
|
});
|
|
4855
4491
|
|
|
4856
4492
|
for (const token of tokens.tokens) {
|
|
4857
|
-
|
|
4858
|
-
console.log(\` Role: \${token.role}\`);
|
|
4859
|
-
console.log(\` Stream status: \${token.muxStreamStatus}\`);
|
|
4493
|
+
|
|
4860
4494
|
}
|
|
4861
4495
|
\`\`\`
|
|
4862
4496
|
|
|
@@ -4865,7 +4499,6 @@ for (const token of tokens.tokens) {
|
|
|
4865
4499
|
\`\`\`typescript
|
|
4866
4500
|
// Revoke by invite ID (owner only)
|
|
4867
4501
|
await sdk.revokeModeratorInvite(123);
|
|
4868
|
-
console.log('Invite revoked');
|
|
4869
4502
|
|
|
4870
4503
|
// If already claimed, moderator loses access immediately
|
|
4871
4504
|
// If pending, invite can no longer be claimed
|
|
@@ -4917,18 +4550,16 @@ const sdk = createLaunchpadSDK({
|
|
|
4917
4550
|
|
|
4918
4551
|
// Option 1: Using Admin API key
|
|
4919
4552
|
const result = await sdk.createOverseerInvite({
|
|
4920
|
-
description: 'John - Platform Support Team',
|
|
4553
|
+
description: 'John - Platform Support Team.',
|
|
4921
4554
|
expiresAt: '2025-12-31T23:59:59Z', // Optional
|
|
4922
4555
|
});
|
|
4923
4556
|
|
|
4924
4557
|
// Option 2: Using JWT (as existing Overseer)
|
|
4925
4558
|
await sdk.login();
|
|
4926
4559
|
const result = await sdk.createOverseerInvite({
|
|
4927
|
-
description: 'Platform team member',
|
|
4560
|
+
description: 'Platform team member.',
|
|
4928
4561
|
});
|
|
4929
4562
|
|
|
4930
|
-
console.log('Share this link:', result.invite.inviteUrl);
|
|
4931
|
-
console.log('Invite Code:', result.invite.inviteCode);
|
|
4932
4563
|
\`\`\`
|
|
4933
4564
|
|
|
4934
4565
|
## Claiming Overseer Invites
|
|
@@ -4939,13 +4570,10 @@ await sdk.login();
|
|
|
4939
4570
|
|
|
4940
4571
|
// Claim the invite
|
|
4941
4572
|
const claimed = await sdk.claimOverseerInvite('abc123...');
|
|
4942
|
-
console.log('Now an overseer!');
|
|
4943
|
-
console.log('Status:', claimed.invite.status); // CLAIMED
|
|
4944
4573
|
|
|
4945
4574
|
// Check own status
|
|
4946
4575
|
const status = await sdk.getMyOverseerStatus();
|
|
4947
|
-
|
|
4948
|
-
console.log('Granted at:', status.overseer?.createdAt);
|
|
4576
|
+
|
|
4949
4577
|
\`\`\`
|
|
4950
4578
|
|
|
4951
4579
|
## Listing Overseers and Invites
|
|
@@ -4959,9 +4587,7 @@ const invites = await sdk.listOverseerInvites({
|
|
|
4959
4587
|
});
|
|
4960
4588
|
|
|
4961
4589
|
for (const invite of invites.invites) {
|
|
4962
|
-
|
|
4963
|
-
console.log(\` Status: \${invite.status}\`);
|
|
4964
|
-
console.log(\` Created by: \${invite.invitedBy.fullName || invite.invitedBy.address}\`);
|
|
4590
|
+
|
|
4965
4591
|
}
|
|
4966
4592
|
|
|
4967
4593
|
// List all active overseers
|
|
@@ -4972,8 +4598,7 @@ const overseers = await sdk.listOverseers({
|
|
|
4972
4598
|
});
|
|
4973
4599
|
|
|
4974
4600
|
for (const overseer of overseers.overseers) {
|
|
4975
|
-
|
|
4976
|
-
console.log(\` Since: \${overseer.createdAt}\`);
|
|
4601
|
+
|
|
4977
4602
|
}
|
|
4978
4603
|
\`\`\`
|
|
4979
4604
|
|
|
@@ -4983,10 +4608,6 @@ for (const overseer of overseers.overseers) {
|
|
|
4983
4608
|
// Get public info about an invite (no auth required)
|
|
4984
4609
|
const preview = await sdk.getOverseerInviteByCode('abc123...');
|
|
4985
4610
|
|
|
4986
|
-
console.log('Status:', preview.status);
|
|
4987
|
-
console.log('Description:', preview.description);
|
|
4988
|
-
console.log('Invited by:', preview.invitedBy.fullName);
|
|
4989
|
-
console.log('Expires:', preview.expiresAt);
|
|
4990
4611
|
\`\`\`
|
|
4991
4612
|
|
|
4992
4613
|
## Revoking Access
|
|
@@ -4994,11 +4615,10 @@ console.log('Expires:', preview.expiresAt);
|
|
|
4994
4615
|
\`\`\`typescript
|
|
4995
4616
|
// Revoke an invite by ID
|
|
4996
4617
|
await sdk.revokeOverseerInvite(123);
|
|
4997
|
-
console.log('Invite revoked');
|
|
4998
4618
|
|
|
4999
4619
|
// Revoke an overseer by wallet address
|
|
5000
4620
|
await sdk.revokeOverseer('eth|1234567890abcdef...');
|
|
5001
|
-
|
|
4621
|
+
|
|
5002
4622
|
\`\`\`
|
|
5003
4623
|
|
|
5004
4624
|
## SDK Methods Reference
|
|
@@ -5057,8 +4677,6 @@ const flag = await sdk.createFlag({
|
|
|
5057
4677
|
reason: 'Spam/harassment',
|
|
5058
4678
|
});
|
|
5059
4679
|
|
|
5060
|
-
console.log('Flag ID:', flag.id);
|
|
5061
|
-
console.log('Status:', flag.status); // PENDING
|
|
5062
4680
|
\`\`\`
|
|
5063
4681
|
|
|
5064
4682
|
## Listing Flags
|
|
@@ -5073,9 +4691,7 @@ const flags = await sdk.listFlags({
|
|
|
5073
4691
|
});
|
|
5074
4692
|
|
|
5075
4693
|
for (const flag of flags.flags) {
|
|
5076
|
-
|
|
5077
|
-
console.log(\` Reason: \${flag.reason}\`);
|
|
5078
|
-
console.log(\` Reporter: \${flag.reporterAddress}\`);
|
|
4694
|
+
|
|
5079
4695
|
}
|
|
5080
4696
|
\`\`\`
|
|
5081
4697
|
|
|
@@ -5116,14 +4732,12 @@ const comments = await sdk.getComments({
|
|
|
5116
4732
|
});
|
|
5117
4733
|
|
|
5118
4734
|
for (const comment of comments.comments) {
|
|
5119
|
-
console.log(\`ID: \${comment.id}, MessageId: \${comment.messageId}\`);
|
|
5120
|
-
console.log(\`\${comment.userAddress}: \${comment.content}\`);
|
|
5121
4735
|
|
|
5122
4736
|
// Check reactions on this comment
|
|
5123
4737
|
if (comment.reactions) {
|
|
5124
|
-
|
|
4738
|
+
|
|
5125
4739
|
for (const reaction of comment.reactions.reactions) {
|
|
5126
|
-
|
|
4740
|
+
|
|
5127
4741
|
}
|
|
5128
4742
|
}
|
|
5129
4743
|
}
|
|
@@ -5134,7 +4748,6 @@ const newComment = await sdk.createComment({
|
|
|
5134
4748
|
tokenName: 'mytoken',
|
|
5135
4749
|
content: 'Great project! Looking forward to the launch.',
|
|
5136
4750
|
});
|
|
5137
|
-
console.log('Comment messageId:', newComment.comment.messageId);
|
|
5138
4751
|
|
|
5139
4752
|
// Add a reaction to a comment using its messageId
|
|
5140
4753
|
await sdk.addReaction({
|
|
@@ -5196,9 +4809,8 @@ const result = await sdk.getTrades({
|
|
|
5196
4809
|
page: 1
|
|
5197
4810
|
});
|
|
5198
4811
|
|
|
5199
|
-
console.log(\`Found \${result.trades.length} trades\`);
|
|
5200
4812
|
for (const trade of result.trades) {
|
|
5201
|
-
|
|
4813
|
+
|
|
5202
4814
|
}
|
|
5203
4815
|
\`\`\`
|
|
5204
4816
|
|
|
@@ -5248,16 +4860,15 @@ const userTrades = await sdk.getTrades({
|
|
|
5248
4860
|
### Pagination
|
|
5249
4861
|
|
|
5250
4862
|
\`\`\`typescript
|
|
5251
|
-
// Paginate through all trades
|
|
5252
|
-
let
|
|
4863
|
+
// Paginate through all trades using offset-based pagination
|
|
4864
|
+
let offset = 0;
|
|
5253
4865
|
let hasMore = true;
|
|
5254
4866
|
|
|
5255
4867
|
while (hasMore) {
|
|
5256
|
-
const result = await sdk.getTrades({ tokenName: 'anime',
|
|
5257
|
-
console.log(\`Page \${page}: \${result.trades.length} trades\`);
|
|
4868
|
+
const result = await sdk.getTrades({ tokenName: 'anime', offset, limit: 50 });
|
|
5258
4869
|
|
|
5259
4870
|
hasMore = result.trades.length === 50;
|
|
5260
|
-
|
|
4871
|
+
offset += 50;
|
|
5261
4872
|
}
|
|
5262
4873
|
\`\`\`
|
|
5263
4874
|
|
|
@@ -5306,9 +4917,6 @@ const result = await sdk.banToken({
|
|
|
5306
4917
|
tokenName: 'scamtoken',
|
|
5307
4918
|
reason: 'Fraudulent project - reported by multiple users',
|
|
5308
4919
|
});
|
|
5309
|
-
console.log('Token banned:', result.tokenName);
|
|
5310
|
-
console.log('Ban ID:', result.ban.id);
|
|
5311
|
-
console.log('Banned by:', result.ban.bannedBy);
|
|
5312
4920
|
|
|
5313
4921
|
// Ban without reason (optional)
|
|
5314
4922
|
await sdk.banToken({ tokenName: 'problematictoken' });
|
|
@@ -5319,8 +4927,6 @@ await sdk.banToken({ tokenName: 'problematictoken' });
|
|
|
5319
4927
|
\`\`\`typescript
|
|
5320
4928
|
// Remove a token ban
|
|
5321
4929
|
const result = await sdk.unbanToken({ tokenName: 'scamtoken' });
|
|
5322
|
-
console.log('Ban removed:', result.removed); // true
|
|
5323
|
-
console.log('Token:', result.tokenName);
|
|
5324
4930
|
|
|
5325
4931
|
// Token is now:
|
|
5326
4932
|
// - Visible in pool listings again
|
|
@@ -5336,12 +4942,9 @@ console.log('Token:', result.tokenName);
|
|
|
5336
4942
|
const status = await sdk.isTokenBanned({ tokenName: 'sometoken' });
|
|
5337
4943
|
|
|
5338
4944
|
if (status.banned) {
|
|
5339
|
-
|
|
5340
|
-
console.log('Reason:', status.ban?.reason);
|
|
5341
|
-
console.log('Banned by:', status.ban?.bannedBy);
|
|
5342
|
-
console.log('Banned at:', status.ban?.createdAt);
|
|
4945
|
+
|
|
5343
4946
|
} else {
|
|
5344
|
-
|
|
4947
|
+
|
|
5345
4948
|
}
|
|
5346
4949
|
|
|
5347
4950
|
// getTokenBan is an alias - use whichever is more readable
|
|
@@ -5353,12 +4956,9 @@ const details = await sdk.getTokenBan({ tokenName: 'sometoken' });
|
|
|
5353
4956
|
\`\`\`typescript
|
|
5354
4957
|
// Get first page with default limit (20)
|
|
5355
4958
|
const page1 = await sdk.listTokenBans({});
|
|
5356
|
-
console.log('Total banned tokens:', page1.meta.total);
|
|
5357
4959
|
|
|
5358
4960
|
for (const ban of page1.items) {
|
|
5359
|
-
|
|
5360
|
-
console.log(\` Banned by: \${ban.bannedBy}\`);
|
|
5361
|
-
console.log(\` Date: \${ban.createdAt}\`);
|
|
4961
|
+
|
|
5362
4962
|
}
|
|
5363
4963
|
|
|
5364
4964
|
// Search for specific tokens (partial match, case-insensitive)
|
|
@@ -5369,16 +4969,16 @@ const searchResults = await sdk.listTokenBans({
|
|
|
5369
4969
|
});
|
|
5370
4970
|
|
|
5371
4971
|
// Paginate through all banned tokens
|
|
5372
|
-
let
|
|
4972
|
+
let cursor: string | undefined;
|
|
5373
4973
|
let hasMore = true;
|
|
5374
4974
|
while (hasMore) {
|
|
5375
|
-
const results = await sdk.listTokenBans({
|
|
5376
|
-
|
|
4975
|
+
const results = await sdk.listTokenBans({ cursor, limit: 20 });
|
|
4976
|
+
|
|
5377
4977
|
for (const ban of results.items) {
|
|
5378
|
-
|
|
4978
|
+
|
|
5379
4979
|
}
|
|
5380
|
-
hasMore =
|
|
5381
|
-
|
|
4980
|
+
hasMore = results.pageInfo.hasNextPage;
|
|
4981
|
+
cursor = results.pageInfo.nextCursor;
|
|
5382
4982
|
}
|
|
5383
4983
|
\`\`\`
|
|
5384
4984
|
|
|
@@ -5422,11 +5022,10 @@ const sdk = createLaunchpadSDK({ privateKey: 'your-private-key' });
|
|
|
5422
5022
|
|
|
5423
5023
|
// Check if a collection name is available
|
|
5424
5024
|
const available = await sdk.isNftCollectionAvailable('MyEpicNFTs');
|
|
5425
|
-
console.log('Collection available:', available);
|
|
5426
5025
|
|
|
5427
5026
|
// Get fee for claiming a collection
|
|
5428
5027
|
const claimFee = await sdk.getNftCollectionClaimFee();
|
|
5429
|
-
|
|
5028
|
+
|
|
5430
5029
|
\`\`\`
|
|
5431
5030
|
|
|
5432
5031
|
## Claim a Collection
|
|
@@ -5435,16 +5034,13 @@ console.log('Claim fee:', claimFee); // Usually "10000" GALA
|
|
|
5435
5034
|
// Claim an available collection name
|
|
5436
5035
|
const result = await sdk.claimNftCollection({
|
|
5437
5036
|
collectionName: 'MyEpicNFTs',
|
|
5438
|
-
description: 'Epic NFT collection for gaming',
|
|
5037
|
+
description: 'Epic NFT collection for gaming.',
|
|
5439
5038
|
});
|
|
5440
|
-
console.log('Collection claimed:', result.collectionName);
|
|
5441
|
-
console.log('Transaction ID:', result.transactionId);
|
|
5442
5039
|
|
|
5443
5040
|
// Fetch your owned collections
|
|
5444
5041
|
const collections = await sdk.fetchNftCollections(walletAddress);
|
|
5445
5042
|
for (const collection of collections) {
|
|
5446
|
-
|
|
5447
|
-
console.log(\` Status: \${collection.status}\`);
|
|
5043
|
+
|
|
5448
5044
|
}
|
|
5449
5045
|
\`\`\`
|
|
5450
5046
|
|
|
@@ -5453,13 +5049,12 @@ for (const collection of collections) {
|
|
|
5453
5049
|
\`\`\`typescript
|
|
5454
5050
|
// Get fee for creating a token class
|
|
5455
5051
|
const classCreateFee = await sdk.getNftTokenClassCreateFee();
|
|
5456
|
-
console.log('Create fee:', classCreateFee); // Usually "1000" GALA
|
|
5457
5052
|
|
|
5458
5053
|
// Create a token class (rarity tier)
|
|
5459
5054
|
const classResult = await sdk.createNftTokenClass({
|
|
5460
5055
|
collectionName: 'MyEpicNFTs',
|
|
5461
5056
|
tokenClassName: 'LegendaryWizard',
|
|
5462
|
-
description: 'Ultra-rare legendary wizard NFTs',
|
|
5057
|
+
description: 'Ultra-rare legendary wizard NFTs.',
|
|
5463
5058
|
maximumSupply: '100', // Max NFTs of this type
|
|
5464
5059
|
data: {
|
|
5465
5060
|
rarity: 'legendary',
|
|
@@ -5467,15 +5062,13 @@ const classResult = await sdk.createNftTokenClass({
|
|
|
5467
5062
|
power: '9000',
|
|
5468
5063
|
},
|
|
5469
5064
|
});
|
|
5470
|
-
console.log('Token class created:', classResult.tokenClassName);
|
|
5471
5065
|
|
|
5472
5066
|
// Fetch token classes for your collection
|
|
5473
5067
|
const classes = await sdk.fetchNftTokenClasses({
|
|
5474
5068
|
collectionName: 'MyEpicNFTs',
|
|
5475
5069
|
});
|
|
5476
5070
|
for (const tokenClass of classes) {
|
|
5477
|
-
|
|
5478
|
-
console.log(\` Current Supply: \${tokenClass.currentSupply}/\${tokenClass.maxSupply}\`);
|
|
5071
|
+
|
|
5479
5072
|
}
|
|
5480
5073
|
\`\`\`
|
|
5481
5074
|
|
|
@@ -5488,7 +5081,6 @@ const mintFeeEstimate = await sdk.estimateNftMintFee({
|
|
|
5488
5081
|
tokenClassName: 'LegendaryWizard',
|
|
5489
5082
|
quantity: 5,
|
|
5490
5083
|
});
|
|
5491
|
-
console.log('Estimated mint fee:', mintFeeEstimate); // Dynamic fee in GALA
|
|
5492
5084
|
|
|
5493
5085
|
// Estimate multiple operations at once
|
|
5494
5086
|
const bundleFee = await sdk.estimateNftOperationFees({
|
|
@@ -5498,9 +5090,9 @@ const bundleFee = await sdk.estimateNftOperationFees({
|
|
|
5498
5090
|
{ type: 'mint', quantity: 10 },
|
|
5499
5091
|
],
|
|
5500
5092
|
});
|
|
5501
|
-
|
|
5093
|
+
|
|
5502
5094
|
for (const op of bundleFee.breakdown) {
|
|
5503
|
-
|
|
5095
|
+
|
|
5504
5096
|
}
|
|
5505
5097
|
\`\`\`
|
|
5506
5098
|
|
|
@@ -5520,13 +5112,11 @@ const mintResult = await sdk.mintNft({
|
|
|
5520
5112
|
],
|
|
5521
5113
|
},
|
|
5522
5114
|
});
|
|
5523
|
-
console.log('Minted:', mintResult.quantityMinted);
|
|
5524
|
-
console.log('Transaction ID:', mintResult.transactionId);
|
|
5525
5115
|
|
|
5526
5116
|
// Check NFT balances
|
|
5527
5117
|
const balances = await sdk.fetchNftBalances(walletAddress);
|
|
5528
5118
|
for (const balance of balances) {
|
|
5529
|
-
|
|
5119
|
+
|
|
5530
5120
|
}
|
|
5531
5121
|
|
|
5532
5122
|
// Filter by collection
|
|
@@ -5543,18 +5133,16 @@ if (!available) throw new Error('Collection name taken');
|
|
|
5543
5133
|
// 2. Claim collection (10,000 GALA)
|
|
5544
5134
|
const claimResult = await sdk.claimNftCollection({
|
|
5545
5135
|
collectionName: 'MyEpicNFTs',
|
|
5546
|
-
description: 'My epic NFT collection',
|
|
5136
|
+
description: 'My epic NFT collection.',
|
|
5547
5137
|
});
|
|
5548
|
-
console.log('✓ Collection claimed');
|
|
5549
5138
|
|
|
5550
5139
|
// 3. Create token class (1,000 GALA)
|
|
5551
5140
|
const classResult = await sdk.createNftTokenClass({
|
|
5552
5141
|
collectionName: 'MyEpicNFTs',
|
|
5553
5142
|
tokenClassName: 'Legendary',
|
|
5554
|
-
description: 'Legendary tier NFTs',
|
|
5143
|
+
description: 'Legendary tier NFTs.',
|
|
5555
5144
|
maximumSupply: '1000',
|
|
5556
5145
|
});
|
|
5557
|
-
console.log('✓ Token class created');
|
|
5558
5146
|
|
|
5559
5147
|
// 4. Estimate mint fee
|
|
5560
5148
|
const fee = await sdk.estimateNftMintFee({
|
|
@@ -5562,7 +5150,6 @@ const fee = await sdk.estimateNftMintFee({
|
|
|
5562
5150
|
tokenClassName: 'Legendary',
|
|
5563
5151
|
quantity: 100,
|
|
5564
5152
|
});
|
|
5565
|
-
console.log(\`✓ Mint fee: \${fee} GALA\`);
|
|
5566
5153
|
|
|
5567
5154
|
// 5. Mint NFTs
|
|
5568
5155
|
const mintResult = await sdk.mintNft({
|
|
@@ -5571,11 +5158,10 @@ const mintResult = await sdk.mintNft({
|
|
|
5571
5158
|
quantity: 100,
|
|
5572
5159
|
to: userWallet,
|
|
5573
5160
|
});
|
|
5574
|
-
console.log('✓ Minted:', mintResult.quantityMinted);
|
|
5575
5161
|
|
|
5576
5162
|
// 6. Verify ownership
|
|
5577
5163
|
const balances = await sdk.fetchNftBalances(userWallet, 'MyEpicNFTs');
|
|
5578
|
-
|
|
5164
|
+
|
|
5579
5165
|
\`\`\`
|
|
5580
5166
|
|
|
5581
5167
|
**MCP Tool Equivalents:**
|
|
@@ -5597,7 +5183,7 @@ console.log('Total NFTs:', balances.reduce((sum, b) => sum + parseInt(b.quantity
|
|
|
5597
5183
|
*/
|
|
5598
5184
|
exports.explainSdkUsageTool = {
|
|
5599
5185
|
name: 'gala_launchpad_explain_sdk_usage',
|
|
5600
|
-
description: 'Get detailed SDK code examples for all 224 MCP tools (mapping to ~208 SDK methods) organized into 49 composite workflow topics covering: buy-tokens, sell-tokens, pool-graduation, fetch-pools, balances, token-creation, token-status, dex-trading, liquidity-positions, advanced-dex-analysis, price-history, token-details, token-distribution, profile-management, multi-wallet, transfers, locks, trading-analytics, utilities-and-helpers, utilities-system, error-handling, installation, local-calculations, spot-prices-smart-routing, event-subscriptions, mcp-to-sdk-mapping, DEX leaderboards, bridge-operations, dex-token-discovery, wrap-unwrap-operations, referral-system, account-management, session-auth, streaming, stream-chat, ban-management, api-key-management, moderator-invites, overseer-invites, content-flag-management, content-reactions, trade-history, token-ban-management, and nft-collection-management',
|
|
5186
|
+
description: 'Get detailed SDK code examples for all 224 MCP tools (mapping to ~208 SDK methods) organized into 49 composite workflow topics covering: buy-tokens, sell-tokens, pool-graduation, fetch-pools, balances, token-creation, token-status, dex-trading, liquidity-positions, advanced-dex-analysis, price-history, token-details, token-distribution, profile-management, multi-wallet, transfers, locks, trading-analytics, utilities-and-helpers, utilities-system, error-handling, installation, local-calculations, spot-prices-smart-routing, event-subscriptions, mcp-to-sdk-mapping, DEX leaderboards, bridge-operations, dex-token-discovery, wrap-unwrap-operations, referral-system, account-management, session-auth, streaming, stream-chat, ban-management, api-key-management, moderator-invites, overseer-invites, content-flag-management, content-reactions, trade-history, token-ban-management, and nft-collection-management.',
|
|
5601
5187
|
inputSchema: {
|
|
5602
5188
|
type: 'object',
|
|
5603
5189
|
properties: {
|
|
@@ -5654,7 +5240,7 @@ exports.explainSdkUsageTool = {
|
|
|
5654
5240
|
'token-ban-management',
|
|
5655
5241
|
'nft-collection-management',
|
|
5656
5242
|
],
|
|
5657
|
-
description: 'The SDK usage topic to explain',
|
|
5243
|
+
description: 'The SDK usage topic to explain.',
|
|
5658
5244
|
},
|
|
5659
5245
|
},
|
|
5660
5246
|
required: ['topic'],
|