@gala-chain/launchpad-sdk 8.1.0 → 9.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +362 -0
- package/EXAMPLES.md +95 -681
- package/MIGRATING-TO-9.0.md +301 -0
- package/README.md +46 -17
- package/dist/LaunchpadSDK.d.ts +138 -413
- package/dist/LaunchpadSDK.d.ts.map +1 -1
- package/dist/api/LaunchpadAPI.d.ts +5 -37
- package/dist/api/LaunchpadAPI.d.ts.map +1 -1
- package/dist/auth/SignatureAuth.d.ts +2 -2
- package/dist/auth/SignatureAuth.d.ts.map +1 -1
- package/dist/auth/types.d.ts +1 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/config/environments.d.ts +7 -2
- package/dist/config/environments.d.ts.map +1 -1
- package/dist/constants/decimals.d.ts +0 -23
- package/dist/constants/decimals.d.ts.map +1 -1
- package/dist/constants/endpoints.d.ts +0 -7
- package/dist/constants/endpoints.d.ts.map +1 -1
- package/dist/constants/version.generated.d.ts +1 -1
- package/dist/constants/version.generated.d.ts.map +1 -1
- package/dist/helpers/sdk.d.ts.map +1 -1
- package/dist/index.browser.d.ts +8 -22
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.esm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.node.d.ts +4 -5
- package/dist/index.node.d.ts.map +1 -1
- package/dist/launchpad/bundle-submission.d.ts +1 -9
- package/dist/launchpad/bundle-submission.d.ts.map +1 -1
- package/dist/launchpad/transport.d.ts +2 -1
- package/dist/launchpad/transport.d.ts.map +1 -1
- package/dist/native.cjs +1 -1
- package/dist/native.d.ts +3 -4
- package/dist/native.d.ts.map +1 -1
- package/dist/native.esm.js +1 -1
- package/dist/schemas/user.d.ts +0 -15
- package/dist/schemas/user.d.ts.map +1 -1
- package/dist/services/AbstractCacheService.d.ts +2 -2
- package/dist/services/GalaChainBalanceService.d.ts +17 -89
- package/dist/services/GalaChainBalanceService.d.ts.map +1 -1
- package/dist/services/GalaChainLockService.d.ts +19 -20
- package/dist/services/GalaChainLockService.d.ts.map +1 -1
- package/dist/services/GalaChainService.d.ts +28 -15
- package/dist/services/GalaChainService.d.ts.map +1 -1
- package/dist/services/GalaChainTokenService.d.ts +25 -53
- package/dist/services/GalaChainTokenService.d.ts.map +1 -1
- package/dist/services/GalaChainTransferService.d.ts +42 -41
- package/dist/services/GalaChainTransferService.d.ts.map +1 -1
- package/dist/services/LaunchpadPriceService.d.ts +66 -0
- package/dist/services/LaunchpadPriceService.d.ts.map +1 -0
- package/dist/services/NftCollectionService.d.ts +22 -6
- package/dist/services/NftCollectionService.d.ts.map +1 -1
- package/dist/services/TokenResolverService.d.ts +5 -5
- package/dist/services/TokenResolverService.d.ts.map +1 -1
- package/dist/services/gateway-transport.d.ts +32 -0
- package/dist/services/gateway-transport.d.ts.map +1 -0
- package/dist/services/gateway-writes.d.ts +83 -0
- package/dist/services/gateway-writes.d.ts.map +1 -0
- package/dist/signing/index.d.ts +2 -3
- package/dist/signing/index.d.ts.map +1 -1
- package/dist/signing/signers.d.ts +7 -8
- package/dist/signing/signers.d.ts.map +1 -1
- package/dist/signing/types.d.ts +7 -10
- package/dist/signing/types.d.ts.map +1 -1
- package/dist/types/burn.dto.d.ts +4 -2
- package/dist/types/burn.dto.d.ts.map +1 -1
- package/dist/types/common.d.ts +2 -23
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/dto.d.ts +0 -5
- package/dist/types/dto.d.ts.map +1 -1
- package/dist/types/launchpad.dto.d.ts +0 -257
- package/dist/types/launchpad.dto.d.ts.map +1 -1
- package/dist/types/lock.dto.d.ts +12 -7
- package/dist/types/lock.dto.d.ts.map +1 -1
- package/dist/types/options.dto.d.ts +8 -34
- package/dist/types/options.dto.d.ts.map +1 -1
- package/dist/types/user.dto.d.ts +7 -62
- package/dist/types/user.dto.d.ts.map +1 -1
- package/dist/utils/address-formatter.d.ts +10 -2
- package/dist/utils/address-formatter.d.ts.map +1 -1
- package/dist/utils/agent-config.d.ts +9 -4
- package/dist/utils/agent-config.d.ts.map +1 -1
- package/dist/utils/auto-pagination.d.ts +6 -239
- package/dist/utils/auto-pagination.d.ts.map +1 -1
- package/dist/utils/bignumber-helpers.d.ts +3 -2
- package/dist/utils/bignumber-helpers.d.ts.map +1 -1
- package/dist/utils/delimiter-parser.d.ts +0 -13
- package/dist/utils/delimiter-parser.d.ts.map +1 -1
- package/dist/utils/error-patterns.d.ts +0 -47
- package/dist/utils/error-patterns.d.ts.map +1 -1
- package/dist/utils/error-wrapper.d.ts +5 -5
- package/dist/utils/errors.d.ts +0 -308
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/http.d.ts +15 -3
- package/dist/utils/http.d.ts.map +1 -1
- package/dist/utils/token-format-converter.d.ts +1 -1
- package/dist/utils/token-parser.d.ts +6 -127
- package/dist/utils/token-parser.d.ts.map +1 -1
- package/dist/utils/token-stringification.d.ts +7 -7
- package/dist/utils/token-stringification.d.ts.map +1 -1
- package/dist/utils/tokenNameNormalizer.d.ts +2 -2
- package/dist/utils/tokenNormalizer.d.ts +5 -29
- package/dist/utils/tokenNormalizer.d.ts.map +1 -1
- package/dist/utils/unique-key-generator.d.ts +7 -134
- package/dist/utils/unique-key-generator.d.ts.map +1 -1
- package/dist/utils/validation-helpers.d.ts +3 -5
- package/dist/utils/validation-helpers.d.ts.map +1 -1
- package/package.json +47 -87
- package/dist/api/dto/BurnTokensDto.d.ts +0 -77
- package/dist/api/dto/BurnTokensDto.d.ts.map +0 -1
- package/dist/api/dto/LockTokenDto.d.ts +0 -85
- package/dist/api/dto/LockTokenDto.d.ts.map +0 -1
- package/dist/api/dto/TransferTokenDto.d.ts +0 -64
- package/dist/api/dto/TransferTokenDto.d.ts.map +0 -1
- package/dist/api/dto/UnlockTokenDto.d.ts +0 -74
- package/dist/api/dto/UnlockTokenDto.d.ts.map +0 -1
- package/dist/bridge/BridgeService.d.ts +0 -484
- package/dist/bridge/BridgeService.d.ts.map +0 -1
- package/dist/bridge/GalaConnectClient.d.ts +0 -170
- package/dist/bridge/GalaConnectClient.d.ts.map +0 -1
- package/dist/bridge/constants/index.d.ts +0 -7
- package/dist/bridge/constants/index.d.ts.map +0 -1
- package/dist/bridge/constants/tokens.d.ts +0 -212
- package/dist/bridge/constants/tokens.d.ts.map +0 -1
- package/dist/bridge/index.d.ts +0 -24
- package/dist/bridge/index.d.ts.map +0 -1
- package/dist/bridge/public-types.d.ts +0 -2
- package/dist/bridge/public-types.d.ts.map +0 -1
- package/dist/bridge/strategies/BridgeStrategy.d.ts +0 -204
- package/dist/bridge/strategies/BridgeStrategy.d.ts.map +0 -1
- package/dist/bridge/strategies/EthereumBridgeStrategy.d.ts +0 -178
- package/dist/bridge/strategies/EthereumBridgeStrategy.d.ts.map +0 -1
- package/dist/bridge/strategies/SolanaBridgeStrategy.d.ts +0 -236
- package/dist/bridge/strategies/SolanaBridgeStrategy.d.ts.map +0 -1
- package/dist/bridge/types/bridge.dto.d.ts +0 -772
- package/dist/bridge/types/bridge.dto.d.ts.map +0 -1
- package/dist/bridge/types/bridgeable-token.dto.d.ts +0 -209
- package/dist/bridge/types/bridgeable-token.dto.d.ts.map +0 -1
- package/dist/bridge/types/eip712.d.ts +0 -66
- package/dist/bridge/types/eip712.d.ts.map +0 -1
- package/dist/bridge/types/index.d.ts +0 -8
- package/dist/bridge/types/index.d.ts.map +0 -1
- package/dist/bridge/utils/RateLimiter.d.ts +0 -34
- package/dist/bridge/utils/RateLimiter.d.ts.map +0 -1
- package/dist/bridge/utils/address-formatter.d.ts +0 -25
- package/dist/bridge/utils/address-formatter.d.ts.map +0 -1
- package/dist/bridge/utils/addressValidation.d.ts +0 -200
- package/dist/bridge/utils/addressValidation.d.ts.map +0 -1
- package/dist/bridge/utils/balanceHelpers.d.ts +0 -215
- package/dist/bridge/utils/balanceHelpers.d.ts.map +0 -1
- package/dist/bridge/utils/bridgeErrors.d.ts +0 -98
- package/dist/bridge/utils/bridgeErrors.d.ts.map +0 -1
- package/dist/bridge/utils/bridgeOutHelpers.d.ts +0 -68
- package/dist/bridge/utils/bridgeOutHelpers.d.ts.map +0 -1
- package/dist/bridge/utils/bridgePayload.d.ts +0 -98
- package/dist/bridge/utils/bridgePayload.d.ts.map +0 -1
- package/dist/bridge/utils/bridgeStatusParser.d.ts +0 -76
- package/dist/bridge/utils/bridgeStatusParser.d.ts.map +0 -1
- package/dist/bridge/utils/eip712Helpers.d.ts +0 -66
- package/dist/bridge/utils/eip712Helpers.d.ts.map +0 -1
- package/dist/bridge/utils/index.d.ts +0 -19
- package/dist/bridge/utils/index.d.ts.map +0 -1
- package/dist/bridge/utils/retry.d.ts +0 -112
- package/dist/bridge/utils/retry.d.ts.map +0 -1
- package/dist/bridge/utils/strategyDelegation.d.ts +0 -126
- package/dist/bridge/utils/strategyDelegation.d.ts.map +0 -1
- package/dist/bridge/utils/tokenIdUtils.d.ts +0 -86
- package/dist/bridge/utils/tokenIdUtils.d.ts.map +0 -1
- package/dist/bridge/utils/tokenMath.d.ts +0 -39
- package/dist/bridge/utils/tokenMath.d.ts.map +0 -1
- package/dist/bridge/utils/tokenMetadataResolver.d.ts +0 -97
- package/dist/bridge/utils/tokenMetadataResolver.d.ts.map +0 -1
- package/dist/helpers/wallet.d.ts +0 -151
- package/dist/helpers/wallet.d.ts.map +0 -1
- package/dist/react/WalletContext.d.ts +0 -60
- package/dist/react/WalletContext.d.ts.map +0 -1
- package/dist/react/index.d.ts +0 -65
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/types.d.ts +0 -76
- package/dist/react/types.d.ts.map +0 -1
- package/dist/react/useWallet.d.ts +0 -123
- package/dist/react/useWallet.d.ts.map +0 -1
- package/dist/react/useWalletConnection.d.ts +0 -89
- package/dist/react/useWalletConnection.d.ts.map +0 -1
- package/dist/react/useWalletDetection.d.ts +0 -81
- package/dist/react/useWalletDetection.d.ts.map +0 -1
- package/dist/react.cjs +0 -1
- package/dist/react.esm.js +0 -1
- package/dist/services/AbstractTokenFetchService.d.ts +0 -150
- package/dist/services/AbstractTokenFetchService.d.ts.map +0 -1
- package/dist/services/BatchedCacheService.d.ts +0 -133
- package/dist/services/BatchedCacheService.d.ts.map +0 -1
- package/dist/services/BridgeableTokenCache.d.ts +0 -120
- package/dist/services/BridgeableTokenCache.d.ts.map +0 -1
- package/dist/services/BridgeableTokenService.d.ts +0 -218
- package/dist/services/BridgeableTokenService.d.ts.map +0 -1
- package/dist/services/DexService.d.ts +0 -440
- package/dist/services/DexService.d.ts.map +0 -1
- package/dist/services/NetworkKeyedCacheService.d.ts +0 -185
- package/dist/services/NetworkKeyedCacheService.d.ts.map +0 -1
- package/dist/services/PriceHistoryService.d.ts +0 -209
- package/dist/services/PriceHistoryService.d.ts.map +0 -1
- package/dist/services/WrapService.d.ts +0 -171
- package/dist/services/WrapService.d.ts.map +0 -1
- package/dist/services/WrappableTokenCache.d.ts +0 -100
- package/dist/services/WrappableTokenCache.d.ts.map +0 -1
- package/dist/services/WrappableTokenService.d.ts +0 -130
- package/dist/services/WrappableTokenService.d.ts.map +0 -1
- package/dist/setup.d.ts +0 -8
- package/dist/setup.d.ts.map +0 -1
- package/dist/tokens/transfers.d.ts +0 -95
- package/dist/tokens/transfers.d.ts.map +0 -1
- package/dist/types/galachain-api.types.d.ts +0 -297
- package/dist/types/galachain-api.types.d.ts.map +0 -1
- package/dist/types/priceHistory.dto.d.ts +0 -134
- package/dist/types/priceHistory.dto.d.ts.map +0 -1
- package/dist/types/token.types.d.ts +0 -359
- package/dist/types/token.types.d.ts.map +0 -1
- package/dist/types/wrappable-token.dto.d.ts +0 -305
- package/dist/types/wrappable-token.dto.d.ts.map +0 -1
- package/dist/utils/crypto-compat.d.ts +0 -40
- package/dist/utils/crypto-compat.d.ts.map +0 -1
- package/dist/utils/load-env.d.ts +0 -31
- package/dist/utils/load-env.d.ts.map +0 -1
- package/dist/utils/token-instance-key.d.ts +0 -57
- package/dist/utils/token-instance-key.d.ts.map +0 -1
- package/dist/utils/wallet.d.ts +0 -166
- package/dist/utils/wallet.d.ts.map +0 -1
- package/dist/wallet/ExternalWalletProvider.d.ts +0 -90
- package/dist/wallet/ExternalWalletProvider.d.ts.map +0 -1
- package/dist/wallet/GalaWalletProvider.d.ts +0 -122
- package/dist/wallet/GalaWalletProvider.d.ts.map +0 -1
- package/dist/wallet/PrivateKeyProvider.d.ts +0 -90
- package/dist/wallet/PrivateKeyProvider.d.ts.map +0 -1
- package/dist/wallet/detection.d.ts +0 -107
- package/dist/wallet/detection.d.ts.map +0 -1
- package/dist/wallet/event-handlers.d.ts +0 -50
- package/dist/wallet/event-handlers.d.ts.map +0 -1
- package/dist/wallet/index.d.ts +0 -51
- package/dist/wallet/index.d.ts.map +0 -1
- package/dist/wallet/signing-operation.d.ts +0 -19
- package/dist/wallet/signing-operation.d.ts.map +0 -1
- package/dist/wallet/typed-data-helpers.d.ts +0 -68
- package/dist/wallet/typed-data-helpers.d.ts.map +0 -1
- package/dist/wallet/types.d.ts +0 -267
- package/dist/wallet/types.d.ts.map +0 -1
- package/dist/wallet/utils.d.ts +0 -117
- package/dist/wallet/utils.d.ts.map +0 -1
- package/dist/wallet.cjs +0 -1
- package/dist/wallet.esm.js +0 -1
package/EXAMPLES.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Gala Launchpad SDK - Usage Examples
|
|
2
2
|
|
|
3
|
-
Practical code examples for
|
|
3
|
+
Practical code examples for the launchpad SDK (9.0.0), organized by category. For complete API documentation, see [API Reference](./docs/API-REFERENCE.md).
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> **9.0 is launchpad-only.** The DEX (quotes, swaps, pools, liquidity, fees, market prices, leaderboards) is
|
|
6
|
+
> `@gala-chain/gswap-sdk`; its runnable demos are in
|
|
7
|
+
> [`packages/gswap-sdk/examples/demos`](../gswap-sdk/examples/demos/README.md). Gateway-generic pieces
|
|
8
|
+
> (signers, wallet providers, React hooks, the bridge) are `@gala-chain/gala-core-sdk`'s. See
|
|
9
|
+
> [MIGRATING-TO-9.0.md](./MIGRATING-TO-9.0.md) for where each removed export went.
|
|
6
10
|
|
|
7
11
|
## Table of Contents
|
|
8
12
|
|
|
9
|
-
- [Token Format Decision Tree](#token-format-decision-tree)
|
|
13
|
+
- [Token Format Decision Tree](#token-format-decision-tree)
|
|
10
14
|
- [Quick Start](#quick-start)
|
|
11
15
|
- [Recommended Learning Path](#recommended-learning-path)
|
|
12
16
|
- [Core Operations](#core-operations)
|
|
13
|
-
- [Liquidity Position Management](#liquidity-position-management)
|
|
14
17
|
- [Bonding Curve Trading](#bonding-curve-trading)
|
|
15
|
-
- [DEX Trading](#dex-trading)
|
|
16
|
-
- [DEX Leaderboard & Volume Analytics](#dex-leaderboard--volume-analytics)
|
|
17
|
-
- [Fee Generation & Collection](#fee-generation--collection)
|
|
18
18
|
- [Real-Time Monitoring](#real-time-monitoring)
|
|
19
19
|
- [Streaming & Chat](#streaming--chat)
|
|
20
20
|
- [Utilities](#utilities)
|
|
@@ -24,95 +24,74 @@ Practical code examples for common SDK operations organized by category. For com
|
|
|
24
24
|
|
|
25
25
|
## Token Format Decision Tree
|
|
26
26
|
|
|
27
|
-
**
|
|
28
|
-
|
|
29
|
-
### Which Format Should I Use?
|
|
27
|
+
**Launchpad tokens are addressed by `tokenName`; standard GalaChain tokens by a token id (`collection|category|type|additionalKey`).**
|
|
30
28
|
|
|
31
29
|
```
|
|
32
30
|
Q: What operation am I performing?
|
|
33
31
|
│
|
|
34
|
-
├── Buying/selling tokens on bonding curve (pre-graduation)?
|
|
32
|
+
├── Buying/selling tokens on the bonding curve (pre-graduation)?
|
|
35
33
|
│ └── Use tokenName: sdk.buy({ tokenName: 'anime', amount: '100', type: 'native' })
|
|
36
34
|
│
|
|
37
|
-
├── Swapping on DEX (GALA, GUSDC, graduated tokens)?
|
|
38
|
-
│ └── Use tokenClassKey: sdk.dex.swaps.swap('GALA|Unit|none|none', 'GUSDC|Unit|none|eth:0xa0b...', fee, { exactIn: '100', amountOutMinimum: '...' }) — queued, then await result.confirm()
|
|
39
|
-
│
|
|
40
|
-
├── Managing liquidity positions on DEX?
|
|
41
|
-
│ └── Use tokenClassKey: sdk.dex.positions.addLiquidityByPrice({ token0: 'GALA|Unit|none|none', ... })
|
|
42
|
-
│
|
|
43
35
|
├── Transferring tokens?
|
|
44
36
|
│ ├── Launchpad token? → sdk.transferToken({ tokenName: 'anime', ... })
|
|
45
37
|
│ └── Standard GalaChain token? → sdk.transferToken({ tokenId: 'GALA|Unit|none|none', ... })
|
|
46
38
|
│
|
|
47
|
-
├── Checking
|
|
48
|
-
│ └──
|
|
49
|
-
│
|
|
39
|
+
├── Checking a launchpad token's price?
|
|
40
|
+
│ └── sdk.fetchTokenPrice({ tokenName: 'anime' }) (bonding curve, or the swap backend once graduated)
|
|
41
|
+
│
|
|
42
|
+
├── Need a launchpad token's class key?
|
|
43
|
+
│ └── await sdk.resolveTokenClassKey('anime') (never construct it by hand)
|
|
44
|
+
│
|
|
45
|
+
├── Trading a graduated token / any other token on the DEX, or a price by token id?
|
|
46
|
+
│ └── @gala-chain/gswap-sdk: gSwap.swaps.swap(...), gSwap.market.getPrice(tokenId)
|
|
50
47
|
│
|
|
51
48
|
└── Graduating a token from bonding curve to DEX?
|
|
52
|
-
└── Use tokenName: sdk.graduateToken(
|
|
49
|
+
└── Use tokenName: sdk.graduateToken('anime')
|
|
53
50
|
```
|
|
54
51
|
|
|
55
52
|
### Format Reference
|
|
56
53
|
|
|
57
54
|
| Format | Pattern | Example | Used For |
|
|
58
55
|
|--------|---------|---------|----------|
|
|
59
|
-
| **tokenName** | Simple lowercase, 3-20 chars | `'anime'` | Bonding curve ops |
|
|
60
|
-
| **
|
|
61
|
-
|
|
62
|
-
### Common Well-Known Tokens
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
// Standard tokens (always use tokenClassKey format)
|
|
66
|
-
const GALA = 'GALA|Unit|none|none';
|
|
67
|
-
const GUSDC = 'GUSDC|Unit|none|eth:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48';
|
|
68
|
-
const WETH = 'GETH|Unit|none|eth:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2';
|
|
69
|
-
```
|
|
56
|
+
| **tokenName** | Simple lowercase, 3-20 chars | `'anime'` | Bonding curve ops, price |
|
|
57
|
+
| **token id / class key** | `collection\|category\|type\|additionalKey` | `'GALA\|Unit\|none\|none'` | Transfers, balances, locks, standard tokens |
|
|
70
58
|
|
|
71
59
|
### Common Mistakes Table
|
|
72
60
|
|
|
73
61
|
| ❌ Wrong | ✅ Correct | Why |
|
|
74
62
|
|----------|------------|-----|
|
|
75
|
-
| `sdk.dex.swaps.swap('anime', ...)` (a launchpad tokenName) | `sdk.dex.swaps.swap('GALA\|Unit\|none\|none', ...)` or a registered symbol like `'GALA'` | DEX resolves registered symbols or full tokenClassKeys via `sdk.dex.symbols.list()` — it does not accept a bonding-curve `tokenName` |
|
|
76
63
|
| `sdk.buy({ tokenName: 'ANIME\|Unit\|...' })` | `sdk.buy({ tokenName: 'anime' })` | Bonding curve uses simple names |
|
|
77
|
-
| `sdk.
|
|
78
|
-
| Assuming `buy()` works for graduated tokens | Check `isGraduated`,
|
|
64
|
+
| `sdk.fetchTokenPrice({ tokenId: 'GALA\|Unit\|none\|none' })` | `gSwap.market.getPrice('GALA\|Unit\|none\|none')` (gswap-sdk) | 9.0 prices launchpad tokens only; a `tokenId` is refused with a `ValidationError` |
|
|
65
|
+
| Assuming `buy()` works for graduated tokens | Check `isGraduated`, trade on the DEX with gswap-sdk if true | Graduated tokens trade on the DEX |
|
|
79
66
|
|
|
80
67
|
### Detecting Graduation Status
|
|
81
68
|
|
|
82
69
|
```typescript
|
|
83
|
-
// Check if a token has graduated from bonding curve to DEX
|
|
84
70
|
const pool = await sdk.fetchPools({ tokenName: 'anime' });
|
|
85
71
|
const isGraduated = pool.items[0]?.isGraduated ?? false;
|
|
86
72
|
|
|
87
73
|
if (isGraduated) {
|
|
88
|
-
// Token is on DEX -
|
|
89
|
-
//
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
console.log(`Use tokenClassKey for DEX: ${tokenClassKey}`);
|
|
74
|
+
// Token is on the DEX: trade it with @gala-chain/gswap-sdk using its class key.
|
|
75
|
+
// Always resolve the key, never construct it: the symbol may differ from the tokenName.
|
|
76
|
+
const tokenClassKey = await sdk.resolveTokenClassKey('anime');
|
|
77
|
+
console.log('Trade on the DEX with', tokenClassKey);
|
|
93
78
|
} else {
|
|
94
|
-
|
|
95
|
-
console.log('Use tokenName for bonding curve: anime');
|
|
79
|
+
console.log('Still on the bonding curve: use sdk.buy / sdk.sell with tokenName "anime"');
|
|
96
80
|
}
|
|
97
81
|
```
|
|
98
82
|
|
|
99
|
-
###
|
|
83
|
+
### Method Reference
|
|
100
84
|
|
|
101
|
-
| Method | tokenName |
|
|
102
|
-
|
|
85
|
+
| Method | tokenName | token id | Notes |
|
|
86
|
+
|--------|:---------:|:--------:|-------|
|
|
103
87
|
| `buy()` | ✅ | ❌ | Bonding curve only |
|
|
104
88
|
| `sell()` | ✅ | ❌ | Bonding curve only |
|
|
105
89
|
| `graduateToken()` | ✅ | ❌ | Triggers DEX migration |
|
|
106
90
|
| `calculateBuyAmount()` | ✅ | ❌ | Pre-trade calculation |
|
|
107
91
|
| `calculateSellAmount()` | ✅ | ❌ | Pre-trade calculation |
|
|
108
92
|
| `fetchPools()` | ✅ | ❌ | Query bonding curve pools |
|
|
109
|
-
| `
|
|
110
|
-
| `
|
|
111
|
-
| `dex.quoting.quoteExactOutput()` | ❌ | ✅ | DEX quotes |
|
|
112
|
-
| `dex.positions.addLiquidityByPrice()` | ❌ | ✅ | LP operations |
|
|
113
|
-
| `dex.positions.removeLiquidity()` | ❌ | ✅ | LP operations |
|
|
114
|
-
| `fetchTokenPrice()` | ✅ | ✅ | Smart router auto-detects |
|
|
115
|
-
| `transferToken()` | ✅ | ✅ | Both work (different paths) |
|
|
93
|
+
| `fetchTokenPrice()` | ✅ | ❌ | Launchpad token price (`{ tokenName }` only) |
|
|
94
|
+
| `transferToken()` | ✅ | ✅ | Both work |
|
|
116
95
|
| `lockTokens()` | ✅ | ✅ | Both work |
|
|
117
96
|
| `fetchTokenBalance()` | ✅ | ✅ | Both work |
|
|
118
97
|
|
|
@@ -125,9 +104,12 @@ if (isGraduated) {
|
|
|
125
104
|
### Installation
|
|
126
105
|
|
|
127
106
|
```bash
|
|
128
|
-
npm install @gala-chain/launchpad-sdk
|
|
107
|
+
npm install @gala-chain/launchpad-sdk@next @gala-chain/gala-core-sdk@next zod
|
|
129
108
|
```
|
|
130
109
|
|
|
110
|
+
`@gala-chain/gala-core-sdk` and `zod` are peer dependencies. 9.0 is a release candidate under the
|
|
111
|
+
`next` dist-tag (an install without `@next` gets 8.1.0).
|
|
112
|
+
|
|
131
113
|
### Basic Setup
|
|
132
114
|
|
|
133
115
|
```typescript
|
|
@@ -149,35 +131,23 @@ const sdkWithWallet = createLaunchpadSDK({
|
|
|
149
131
|
# Complete SDK feature demonstration
|
|
150
132
|
npm run demo
|
|
151
133
|
|
|
152
|
-
#
|
|
153
|
-
npm run demo:
|
|
154
|
-
|
|
155
|
-
# DEX swap workflow
|
|
156
|
-
npm run demo:dex
|
|
134
|
+
# Basic bonding curve buy/sell
|
|
135
|
+
npm run demo:trades
|
|
157
136
|
|
|
158
|
-
#
|
|
159
|
-
npm run demo:
|
|
137
|
+
# Watch for new launchpad token launches
|
|
138
|
+
npm run demo:watch:tokens
|
|
160
139
|
```
|
|
161
140
|
|
|
162
|
-
**Demo Statistics**: 65 comprehensive demos organized into 8 categories covering all SDK features
|
|
163
|
-
|
|
164
141
|
---
|
|
165
142
|
|
|
166
143
|
## Recommended Learning Path
|
|
167
144
|
|
|
168
|
-
Follow this progression to master the SDK:
|
|
169
|
-
|
|
170
145
|
### 1. Start with Core Operations
|
|
171
146
|
|
|
172
147
|
```bash
|
|
173
|
-
# Complete SDK overview
|
|
174
|
-
npm run demo
|
|
175
|
-
|
|
176
|
-
# Read-only operations (no wallet needed)
|
|
177
|
-
npm run demo:read-only
|
|
178
|
-
|
|
179
|
-
# Authenticated operations (wallet required)
|
|
180
|
-
npm run demo:authenticated
|
|
148
|
+
npm run demo # Complete SDK overview
|
|
149
|
+
npm run demo:read-only # Read-only operations (no wallet needed)
|
|
150
|
+
npm run demo:authenticated # Authenticated operations (wallet required)
|
|
181
151
|
```
|
|
182
152
|
|
|
183
153
|
**Learn:** SDK initialization, configuration, read-only vs full-access modes
|
|
@@ -185,89 +155,36 @@ npm run demo:authenticated
|
|
|
185
155
|
### 2. Understand Bonding Curve Trading
|
|
186
156
|
|
|
187
157
|
```bash
|
|
188
|
-
|
|
189
|
-
npm run demo:bonding:
|
|
190
|
-
|
|
191
|
-
# Basic buy/sell operations
|
|
192
|
-
npm run demo:trades
|
|
193
|
-
|
|
194
|
-
# Token graduation workflow
|
|
195
|
-
npm run demo:bonding:graduation
|
|
158
|
+
npm run demo:trades # Basic buy/sell operations
|
|
159
|
+
npm run demo:bonding:graduation # Token graduation workflow
|
|
160
|
+
npm run demo:bonding:pool-discovery # Pool filtering and discovery
|
|
196
161
|
```
|
|
197
162
|
|
|
198
163
|
**Learn:** Pre-graduation token trading, bonding curve mechanics, token launch lifecycle
|
|
199
164
|
|
|
200
|
-
### 3.
|
|
165
|
+
### 3. Try Real-Time Features
|
|
201
166
|
|
|
202
167
|
```bash
|
|
203
|
-
#
|
|
204
|
-
npm run demo:
|
|
205
|
-
|
|
206
|
-
# Run all 12 liquidity demos sequentially
|
|
207
|
-
npm run demo:liquidity:all
|
|
208
|
-
|
|
209
|
-
# Detailed position lifecycle
|
|
210
|
-
npm run demo:liquidity:detailed
|
|
168
|
+
npm run demo:watch:tokens # Watch for new launchpad token launches
|
|
169
|
+
npm run demo:monitoring:websocket-events
|
|
211
170
|
```
|
|
212
171
|
|
|
213
|
-
**Learn:**
|
|
172
|
+
**Learn:** WebSocket event monitoring, token discovery
|
|
214
173
|
|
|
215
|
-
### 4.
|
|
174
|
+
### 4. Explore Advanced Topics
|
|
216
175
|
|
|
217
176
|
```bash
|
|
218
|
-
|
|
219
|
-
npm run demo:
|
|
220
|
-
|
|
221
|
-
# Pool discovery and metrics
|
|
222
|
-
npm run demo:dex:pools
|
|
223
|
-
|
|
224
|
-
# Quote comparison (exact input vs exact output)
|
|
225
|
-
npm run demo:dex:quotes
|
|
177
|
+
npm run demo:cache # Metadata cache performance
|
|
178
|
+
npm run demo:token-supply # Token supply metrics from GalaChain
|
|
226
179
|
```
|
|
227
180
|
|
|
228
|
-
**Learn:**
|
|
181
|
+
**Learn:** Performance optimization, token supply queries
|
|
229
182
|
|
|
230
|
-
### 5.
|
|
183
|
+
### 5. The DEX
|
|
231
184
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
# High-volume trading fee accumulation
|
|
237
|
-
npm run demo:fees:high-volume
|
|
238
|
-
|
|
239
|
-
# Complete fee lifecycle test
|
|
240
|
-
npm run demo:fees:test
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Learn:** LP fee generation, collection strategies, multi-wallet workflows
|
|
244
|
-
|
|
245
|
-
### 6. Try Real-Time Features
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
# Watch for new DEX pool creation
|
|
249
|
-
npm run demo:watch
|
|
250
|
-
|
|
251
|
-
# Watch for new launchpad token launches
|
|
252
|
-
npm run demo:watch:tokens
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
**Learn:** WebSocket event monitoring, pool/token discovery
|
|
256
|
-
|
|
257
|
-
### 7. Explore Advanced Topics
|
|
258
|
-
|
|
259
|
-
```bash
|
|
260
|
-
# Metadata cache performance
|
|
261
|
-
npm run demo:cache
|
|
262
|
-
|
|
263
|
-
# Token supply metrics from GalaChain
|
|
264
|
-
npm run demo:token-supply
|
|
265
|
-
|
|
266
|
-
# Advanced tick-based positions
|
|
267
|
-
npm run demo:liquidity:ticks
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
**Learn:** Performance optimization, token supply queries, advanced LP strategies
|
|
185
|
+
Swaps, liquidity, fees, pools and market data are `@gala-chain/gswap-sdk`'s. Its demos:
|
|
186
|
+
[`packages/gswap-sdk/examples/demos/README.md`](../gswap-sdk/examples/demos/README.md)
|
|
187
|
+
(`npx tsx src/<dir>/<file>.ts`).
|
|
271
188
|
|
|
272
189
|
---
|
|
273
190
|
|
|
@@ -285,8 +202,8 @@ const sdk = createLaunchpadSDK({
|
|
|
285
202
|
});
|
|
286
203
|
|
|
287
204
|
// Query operations work without wallet
|
|
288
|
-
const pools = await sdk.
|
|
289
|
-
const
|
|
205
|
+
const pools = await sdk.fetchPools({ type: 'popular', limit: 10 });
|
|
206
|
+
const price = await sdk.fetchTokenPrice({ tokenName: 'anime' });
|
|
290
207
|
```
|
|
291
208
|
|
|
292
209
|
**Full-Access Mode** (with wallet for trading):
|
|
@@ -297,8 +214,8 @@ const sdk = createLaunchpadSDK({
|
|
|
297
214
|
privateKey: process.env.WALLET_PRIVATE_KEY
|
|
298
215
|
});
|
|
299
216
|
|
|
300
|
-
// Now you can submit trades
|
|
301
|
-
const result = await sdk.
|
|
217
|
+
// Now you can submit trades
|
|
218
|
+
const result = await sdk.buy({ tokenName: 'anime', amount: '100', type: 'native', expectedAmount: '1' });
|
|
302
219
|
```
|
|
303
220
|
|
|
304
221
|
**Dynamic Wallet Configuration:**
|
|
@@ -321,150 +238,6 @@ const result = await sdk.buy({ tokenName: 'anime', amount: '100', ... });
|
|
|
321
238
|
|
|
322
239
|
---
|
|
323
240
|
|
|
324
|
-
## Liquidity Position Management
|
|
325
|
-
|
|
326
|
-
Provide liquidity to GalaSwap DEX pools and earn trading fees.
|
|
327
|
-
|
|
328
|
-
### View All Liquidity Positions
|
|
329
|
-
|
|
330
|
-
```typescript
|
|
331
|
-
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
|
|
332
|
-
|
|
333
|
-
const sdk = createLaunchpadSDK({
|
|
334
|
-
env: 'prod',
|
|
335
|
-
privateKey: process.env.WALLET_PRIVATE_KEY
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
// Get all current-contract positions for the owner
|
|
339
|
-
const positions = await sdk.dex.positions.getUserPositions('eth|0x...');
|
|
340
|
-
|
|
341
|
-
console.log(`Total positions: ${positions.length}`);
|
|
342
|
-
|
|
343
|
-
// Analyze position performance
|
|
344
|
-
let totalLiquidity = 0;
|
|
345
|
-
let totalFees = 0;
|
|
346
|
-
|
|
347
|
-
positions.forEach(pos => {
|
|
348
|
-
totalLiquidity += parseFloat(pos.liquidity || '0');
|
|
349
|
-
|
|
350
|
-
const fee0 = parseFloat(pos.fees0 || '0');
|
|
351
|
-
const fee1 = parseFloat(pos.fees1 || '0');
|
|
352
|
-
totalFees += fee0 + fee1;
|
|
353
|
-
|
|
354
|
-
console.log(`
|
|
355
|
-
Pool: ${pos.token0Symbol}/${pos.token1Symbol}
|
|
356
|
-
Liquidity: ${pos.liquidity}
|
|
357
|
-
Fees: ${pos.fees0} ${pos.token0Symbol} + ${pos.fees1} ${pos.token1Symbol}
|
|
358
|
-
`);
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
console.log(`\nTotal Liquidity: ${totalLiquidity}`);
|
|
362
|
-
console.log(`Total Fees Earned: ${totalFees}`);
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
### Create Liquidity Position (Price Range)
|
|
366
|
-
|
|
367
|
-
```typescript
|
|
368
|
-
// Create position with user-friendly price range (v3.33.0+ requires delimited token format)
|
|
369
|
-
const submitted = await sdk.dex.positions.addLiquidityByPrice({
|
|
370
|
-
token0: 'GALA|Unit|none|none',
|
|
371
|
-
token1: 'GUSDC|Unit|none|none',
|
|
372
|
-
fee: 3000, // 0.30% fee tier
|
|
373
|
-
minPrice: '0.95', // Active range: 0.95 - 1.05
|
|
374
|
-
maxPrice: '1.05',
|
|
375
|
-
amount: '1000', // Amount of the token below
|
|
376
|
-
amountIsToken0: true, // Provide 1000 GALA (token0)
|
|
377
|
-
});
|
|
378
|
-
|
|
379
|
-
console.log(`Submitted: ${submitted.transactionId} (mode: ${submitted.mode})`);
|
|
380
|
-
|
|
381
|
-
// Wait for confirmation — resolves the created/refreshed position
|
|
382
|
-
const position = await submitted.confirm();
|
|
383
|
-
console.log(`✓ Position confirmed. Liquidity: ${position?.liquidity}`);
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
### Collect Fees Periodically
|
|
387
|
-
|
|
388
|
-
```typescript
|
|
389
|
-
// Harvest accumulated fees without closing position (the contract does not support partial collection)
|
|
390
|
-
const submitted = await sdk.dex.positions.collectPositionFees({
|
|
391
|
-
token0: 'GALA|Unit|none|none',
|
|
392
|
-
token1: 'GUSDC|Unit|none|none',
|
|
393
|
-
fee: 3000,
|
|
394
|
-
tickLower: position.tickLower,
|
|
395
|
-
tickUpper: position.tickUpper,
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
const collected = await submitted.confirm();
|
|
399
|
-
|
|
400
|
-
console.log(`Collected fees:`);
|
|
401
|
-
console.log(` ${collected?.fees0} GALA`);
|
|
402
|
-
console.log(` ${collected?.fees1} GUSDC`);
|
|
403
|
-
|
|
404
|
-
// Position remains active and continues earning fees
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
### Remove Liquidity & Close Position
|
|
408
|
-
|
|
409
|
-
```typescript
|
|
410
|
-
// Step 1: Preview what you'll receive
|
|
411
|
-
const estimate = await sdk.dex.positions.estimateRemoveLiquidity({
|
|
412
|
-
token0: 'GALA|Unit|none|none',
|
|
413
|
-
token1: 'GUSDC|Unit|none|none',
|
|
414
|
-
fee: 3000,
|
|
415
|
-
tickLower: position.tickLower,
|
|
416
|
-
tickUpper: position.tickUpper,
|
|
417
|
-
liquidity: position.liquidity,
|
|
418
|
-
});
|
|
419
|
-
|
|
420
|
-
console.log(`Will receive:`);
|
|
421
|
-
console.log(` ${estimate.amount0} GALA`);
|
|
422
|
-
console.log(` ${estimate.amount1} GUSDC`);
|
|
423
|
-
|
|
424
|
-
// Step 2: Remove full liquidity (omitting both amount0/amount1 closes the position)
|
|
425
|
-
const submitted = await sdk.dex.positions.removeLiquidity({
|
|
426
|
-
token0: 'GALA|Unit|none|none',
|
|
427
|
-
token1: 'GUSDC|Unit|none|none',
|
|
428
|
-
fee: 3000,
|
|
429
|
-
tickLower: position.tickLower,
|
|
430
|
-
tickUpper: position.tickUpper,
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
const closed = await submitted.confirm();
|
|
434
|
-
|
|
435
|
-
console.log(`Position closed!`);
|
|
436
|
-
console.log(`Withdrawn: ${estimate.amount0} GALA + ${estimate.amount1} GUSDC`);
|
|
437
|
-
```
|
|
438
|
-
|
|
439
|
-
**Liquidity Demos (12 total):**
|
|
440
|
-
- `npm run demo:liquidity` - Interactive CLI
|
|
441
|
-
- `npm run demo:liquidity:all` - Run all 12 demos (orchestrator)
|
|
442
|
-
- `npm run demo:liquidity:detailed` - Complete lifecycle
|
|
443
|
-
- `npm run demo:liquidity:ticks` - Advanced tick positions
|
|
444
|
-
- `npm run demo:liquidity:portfolio` - Multi-position management
|
|
445
|
-
- `npm run demo:liquidity:apr` - APR calculations
|
|
446
|
-
- `npm run demo:liquidity:errors` - Error handling
|
|
447
|
-
- `npm run demo:liquidity:fetch-all` - Pagination example
|
|
448
|
-
- `npm run demo:liquidity:positions-with-prices` - Price enrichment
|
|
449
|
-
- `npm run demo:liquidity:removal` - Position removal workflow
|
|
450
|
-
- `npm run demo:liquidity:fee-collection` - Fee collection strategies
|
|
451
|
-
- `npm run demo:liquidity:price-range` - Price range optimization
|
|
452
|
-
|
|
453
|
-
**Orchestrator Usage:**
|
|
454
|
-
|
|
455
|
-
```bash
|
|
456
|
-
# Run all liquidity demos
|
|
457
|
-
npm run demo:liquidity:all
|
|
458
|
-
|
|
459
|
-
# Skip specific demos
|
|
460
|
-
npm run demo:liquidity:all -- --skip=detailed,ticks
|
|
461
|
-
|
|
462
|
-
# Run only specific demos
|
|
463
|
-
npm run demo:liquidity:all -- --only=portfolio,apr
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
---
|
|
467
|
-
|
|
468
241
|
## Bonding Curve Trading
|
|
469
242
|
|
|
470
243
|
Trade tokens that are still in bonding curve pools (pre-graduation).
|
|
@@ -486,8 +259,7 @@ const quote = await sdk.calculateBuyAmount({
|
|
|
486
259
|
|
|
487
260
|
console.log(`For 100 GALA:`);
|
|
488
261
|
console.log(` Receive: ${quote.amount} tokens`);
|
|
489
|
-
console.log(`
|
|
490
|
-
console.log(` Total cost: ${quote.totalCost} GALA`);
|
|
262
|
+
console.log(` Fees: ${quote.transactionFee} GALA transaction, ${quote.gasFee} GALA gas`);
|
|
491
263
|
|
|
492
264
|
// Execute purchase
|
|
493
265
|
const result = await sdk.buy({
|
|
@@ -527,8 +299,7 @@ const result = await sdk.sell({
|
|
|
527
299
|
console.log(`✓ Sale completed: ${result.transactionId}`);
|
|
528
300
|
```
|
|
529
301
|
|
|
530
|
-
**Bonding Curve Demos
|
|
531
|
-
- `npm run demo:bonding:orchestrator` - Run all 8 bonding curve demos (orchestrator)
|
|
302
|
+
**Bonding Curve Demos:**
|
|
532
303
|
- `npm run demo:trades` - Basic buy/sell operations
|
|
533
304
|
- `npm run demo:bonding:graduation` - Token graduation workflow and simulation
|
|
534
305
|
- `npm run demo:bonding:pool-discovery` - Pool filtering and discovery
|
|
@@ -536,290 +307,16 @@ console.log(`✓ Sale completed: ${result.transactionId}`);
|
|
|
536
307
|
- `npm run demo:bonding:token-launch` - Token launch lifecycle demonstration
|
|
537
308
|
- `npm run demo:bonding:volume-trading` - High-volume trading simulation
|
|
538
309
|
- `npm run demo:bonding:pool-analysis` - Deep pool analytics and metrics
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
```bash
|
|
543
|
-
# Run all bonding curve demos
|
|
544
|
-
npm run demo:bonding:orchestrator
|
|
545
|
-
|
|
546
|
-
# Skip specific demos
|
|
547
|
-
npm run demo:bonding:orchestrator -- --skip=graduation,volume-trading
|
|
548
|
-
|
|
549
|
-
# Run only specific demos
|
|
550
|
-
npm run demo:bonding:orchestrator -- --only=pool-discovery,price-impact
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
---
|
|
554
|
-
|
|
555
|
-
## DEX Trading
|
|
556
|
-
|
|
557
|
-
Trade graduated tokens on the GalaSwap DEX.
|
|
558
|
-
|
|
559
|
-
### Get Swap Quote
|
|
560
|
-
|
|
561
|
-
```typescript
|
|
562
|
-
const sdk = createLaunchpadSDK({ env: 'prod' });
|
|
563
|
-
|
|
564
|
-
// Quote for exact input (how many GUSDC for 100 GALA?)
|
|
565
|
-
// v3.33.0+ requires delimited token format
|
|
566
|
-
const quoteInput = await sdk.dex.quoting.quoteExactInput('GALA|Unit|none|none', 'GUSDC|Unit|none|none', '100');
|
|
567
|
-
|
|
568
|
-
console.log(`Spend 100 GALA → Receive ~${quoteInput.amountOut} GUSDC`);
|
|
569
|
-
console.log(`Price impact: ${quoteInput.priceImpact ?? 'n/a'}`);
|
|
570
|
-
console.log(`Fee tier: ${quoteInput.feeTier} bps`);
|
|
571
|
-
|
|
572
|
-
// Quote for exact output (how much GALA to get 100 GUSDC?)
|
|
573
|
-
const quoteOutput = await sdk.dex.quoting.quoteExactOutput('GALA|Unit|none|none', 'GUSDC|Unit|none|none', '100');
|
|
574
|
-
|
|
575
|
-
console.log(`Need ${quoteOutput.amountIn} GALA → Get 100 GUSDC`);
|
|
576
|
-
console.log(`Price impact: ${quoteOutput.priceImpact ?? 'n/a'}`);
|
|
577
|
-
```
|
|
578
|
-
|
|
579
|
-
### Submit and Confirm a Swap
|
|
580
|
-
|
|
581
|
-
```typescript
|
|
582
|
-
const sdk = createLaunchpadSDK({
|
|
583
|
-
env: 'prod',
|
|
584
|
-
privateKey: process.env.WALLET_PRIVATE_KEY
|
|
585
|
-
});
|
|
586
|
-
|
|
587
|
-
// Step 1: Get quote (v3.33.0+ requires delimited token format)
|
|
588
|
-
const quote = await sdk.dex.quoting.quoteExactInput('GALA|Unit|none|none', 'GUSDC|Unit|none|none', '100');
|
|
589
|
-
|
|
590
|
-
// Step 2: Submit the queued RequestTrade with 1% slippage protection
|
|
591
|
-
const submitted = await sdk.dex.swaps.swap(
|
|
592
|
-
'GALA|Unit|none|none',
|
|
593
|
-
'GUSDC|Unit|none|none',
|
|
594
|
-
quote.feeTier,
|
|
595
|
-
{ exactIn: '100', amountOutMinimum: quote.amountOut } // amountOutMinimum should include your own slippage buffer
|
|
596
|
-
);
|
|
597
|
-
|
|
598
|
-
console.log(`Swap queued: ${submitted.transactionId} (mode: ${submitted.mode})`);
|
|
599
|
-
console.log(`Expected output: ~${quote.amountOut} GUSDC`);
|
|
600
|
-
|
|
601
|
-
// Step 3: Wait for the applied trade, or catch the chain's rejection
|
|
602
|
-
const applied = await submitted.confirm();
|
|
603
|
-
|
|
604
|
-
console.log(`✓ Swap applied!`);
|
|
605
|
-
console.log(`Applied transaction: ${applied.transactionId}`);
|
|
606
|
-
console.log(`Result: ${JSON.stringify(applied.result)}`);
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
### Discover DEX Pools
|
|
610
|
-
|
|
611
|
-
```typescript
|
|
612
|
-
// Fetch every current-contract pool, then filter/sort client-side
|
|
613
|
-
const pools = await sdk.dex.pools.getPools();
|
|
614
|
-
|
|
615
|
-
const topGalaPools = pools
|
|
616
|
-
.filter(pool => pool.token0 === 'GALA' || pool.token1 === 'GALA')
|
|
617
|
-
.sort((a, b) => (b.tvlUsd ?? 0) - (a.tvlUsd ?? 0))
|
|
618
|
-
.slice(0, 10);
|
|
619
|
-
|
|
620
|
-
topGalaPools.forEach(pool => {
|
|
621
|
-
console.log(`${pool.poolName}: $${(pool.tvlUsd ?? 0).toLocaleString()} TVL`);
|
|
622
|
-
console.log(` 24h Volume: $${(pool.volume1d ?? 0).toLocaleString()}`);
|
|
623
|
-
console.log(` APR: ${(pool.apr1d ?? 0).toFixed(2)}%`);
|
|
624
|
-
});
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
**DEX Demos (8 total):**
|
|
628
|
-
- `npm run demo:dex` - Swap workflow (quote → execute → confirm)
|
|
629
|
-
- `npm run demo:dex:pools` - Pool discovery and metrics
|
|
630
|
-
- `npm run demo:dex:pricing` - Pool pricing and TVL analysis
|
|
631
|
-
- `npm run demo:dex:quotes` - Quote comparison
|
|
632
|
-
- `npm run demo:dex:roundtrip` - Complete liquidity workflow
|
|
633
|
-
- `npm run demo:roundtrip:swap` - Buy → Sell → Verify
|
|
634
|
-
- `npm run demo:dex:leaderboard` - Seasonal leaderboard queries and XP rankings
|
|
635
|
-
- `npm run demo:dex:volume-summary` - Platform volume metrics and trend analysis
|
|
636
|
-
|
|
637
|
-
**Symmetry Note:** Both `bonding-curve/` and `dex/` categories have pool discovery demos for consistent learning patterns.
|
|
638
|
-
|
|
639
|
-
---
|
|
640
|
-
|
|
641
|
-
## DEX Leaderboard & Volume Analytics
|
|
642
|
-
|
|
643
|
-
Competitive DEX leaderboard system with achievement tracking and platform-wide volume metrics.
|
|
644
|
-
|
|
645
|
-
### Fetch All Seasons
|
|
646
|
-
|
|
647
|
-
```typescript
|
|
648
|
-
const sdk = createLaunchpadSDK({ env: 'prod' });
|
|
649
|
-
|
|
650
|
-
// Get all available competitive seasons
|
|
651
|
-
const seasons = await sdk.fetchAllDexSeasons();
|
|
652
|
-
|
|
653
|
-
console.log(`Total seasons: ${seasons.length}`);
|
|
654
|
-
seasons.forEach(season => {
|
|
655
|
-
const days = Math.ceil((new Date(season.end).getTime() - new Date(season.start).getTime()) / (1000 * 60 * 60 * 24));
|
|
656
|
-
console.log(`${season.name} (ID: ${season.id}): ${days} days`);
|
|
657
|
-
});
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
### Get Current Season & Leaderboard
|
|
661
|
-
|
|
662
|
-
```typescript
|
|
663
|
-
// Get current active season
|
|
664
|
-
const currentSeason = await sdk.fetchCurrentDexSeason();
|
|
665
|
-
console.log(`Active: ${currentSeason.name}`);
|
|
666
|
-
|
|
667
|
-
// Get current season leaderboard (top 10)
|
|
668
|
-
const leaderboard = await sdk.fetchCurrentDexLeaderboard({ limit: 10 });
|
|
669
|
-
|
|
670
|
-
console.log(`🏆 Top Traders (${currentSeason.name}):`);
|
|
671
|
-
leaderboard.rankings.forEach(entry => {
|
|
672
|
-
const titles = entry.masteryTitles.map(t => t.name).join(', ');
|
|
673
|
-
console.log(`${entry.rank}. ${entry.wallet.slice(0, 12)}...`);
|
|
674
|
-
console.log(` XP: ${entry.totalXp} | Distribution: ${entry.distributionPercent}%`);
|
|
675
|
-
console.log(` Trading: ${entry.tradingXp} | Liquidity: ${entry.liquidityXp}`);
|
|
676
|
-
if (titles) console.log(` Achievements: ${titles}`);
|
|
677
|
-
});
|
|
678
|
-
```
|
|
679
|
-
|
|
680
|
-
### Query Historic Season Leaderboard
|
|
681
|
-
|
|
682
|
-
```typescript
|
|
683
|
-
// Get leaderboard from a specific season (e.g., Season 1, ID=4)
|
|
684
|
-
const historicLeaderboard = await sdk.fetchDexLeaderboardBySeasonId(4, { limit: 5 });
|
|
685
|
-
|
|
686
|
-
console.log(`Season 1 Final Rankings:`);
|
|
687
|
-
historicLeaderboard.rankings.forEach(entry => {
|
|
688
|
-
console.log(`${entry.rank}. ${entry.wallet}: ${entry.totalXp} XP`);
|
|
689
|
-
});
|
|
690
|
-
```
|
|
691
|
-
|
|
692
|
-
### Platform Volume Metrics
|
|
693
|
-
|
|
694
|
-
```typescript
|
|
695
|
-
// Get platform-wide DEX volume summary
|
|
696
|
-
const volume = await sdk.fetchDexAggregatedVolumeSummary();
|
|
697
|
-
|
|
698
|
-
console.log(`📊 DEX Platform Volume:`);
|
|
699
|
-
console.log(` 24h: $${volume.volume1d.toFixed(2)} (${(volume.volume1dDelta * 100).toFixed(1)}%)`);
|
|
700
|
-
console.log(` 7d: $${volume.volume7d.toFixed(2)} (${(volume.volume7dDelta * 100).toFixed(1)}%)`);
|
|
701
|
-
console.log(` 30d: $${volume.volume30d.toFixed(2)} (${(volume.volume30dDelta * 100).toFixed(1)}%)`);
|
|
702
|
-
|
|
703
|
-
// Trend analysis
|
|
704
|
-
if (volume.volume1dDelta > volume.volume7dDelta) {
|
|
705
|
-
console.log(`📈 Accelerating: 24h growth stronger than 7d avg`);
|
|
706
|
-
} else if (volume.volume1dDelta < -0.1) {
|
|
707
|
-
console.log(`📉 Warning: Significant 24h decline (${(volume.volume1dDelta * 100).toFixed(1)}%)`);
|
|
708
|
-
}
|
|
709
|
-
```
|
|
710
|
-
|
|
711
|
-
**DEX Leaderboard & Volume Demos (3 total):**
|
|
712
|
-
- `npm run demo:dex:leaderboard` - Seasonal leaderboard queries and XP rankings
|
|
713
|
-
- `npm run demo:dex:volume-summary` - Platform volume metrics and trend analysis
|
|
714
|
-
- `npm run demo:dex:all` - Orchestrator managing all DEX demos (pools, pricing, swap, leaderboard, volume)
|
|
715
|
-
|
|
716
|
-
---
|
|
717
|
-
|
|
718
|
-
## Fee Generation & Collection
|
|
719
|
-
|
|
720
|
-
Liquidity provider fee workflows with multi-wallet testing.
|
|
721
|
-
|
|
722
|
-
### Basic Fee Generation
|
|
723
|
-
|
|
724
|
-
```typescript
|
|
725
|
-
const sdk = createLaunchpadSDK({
|
|
726
|
-
env: 'prod',
|
|
727
|
-
privateKey: process.env.WALLET_PRIVATE_KEY
|
|
728
|
-
});
|
|
729
|
-
|
|
730
|
-
// Step 1: Create liquidity position (v3.33.0+ requires delimited token format)
|
|
731
|
-
const positionTx = await sdk.dex.positions.addLiquidityByPrice({
|
|
732
|
-
token0: 'GALA|Unit|none|none',
|
|
733
|
-
token1: 'GUSDC|Unit|none|none',
|
|
734
|
-
fee: 3000,
|
|
735
|
-
minPrice: '0.95',
|
|
736
|
-
maxPrice: '1.05',
|
|
737
|
-
amount: '1000',
|
|
738
|
-
amountIsToken0: true,
|
|
739
|
-
});
|
|
740
|
-
|
|
741
|
-
const position = await positionTx.confirm();
|
|
742
|
-
if (!position) throw new Error('Position confirmation returned null');
|
|
743
|
-
console.log(`Position confirmed. Ticks: ${position.tickLower}..${position.tickUpper}`);
|
|
744
|
-
|
|
745
|
-
// Step 2: Submit swaps to generate fees (each is a queued RequestTrade; confirm each)
|
|
746
|
-
for (let i = 0; i < 10; i++) {
|
|
747
|
-
const swapTx = await sdk.dex.swaps.swap('GALA|Unit|none|none', 'GUSDC|Unit|none|none', 3000, { exactIn: '10' });
|
|
748
|
-
await swapTx.confirm();
|
|
749
|
-
console.log(`Swap ${i + 1} completed`);
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
// Step 3: Check accumulated fees
|
|
753
|
-
const positionData = await sdk.dex.positions.getPosition({
|
|
754
|
-
token0: 'GALA|Unit|none|none',
|
|
755
|
-
token1: 'GUSDC|Unit|none|none',
|
|
756
|
-
fee: 3000,
|
|
757
|
-
owner: 'eth|0x...',
|
|
758
|
-
tickLower: position.tickLower,
|
|
759
|
-
tickUpper: position.tickUpper,
|
|
760
|
-
});
|
|
761
|
-
|
|
762
|
-
console.log(`Fees accumulated:`);
|
|
763
|
-
console.log(` ${positionData?.fees0} GALA`);
|
|
764
|
-
console.log(` ${positionData?.fees1} GUSDC`);
|
|
765
|
-
|
|
766
|
-
// Step 4: Collect fees
|
|
767
|
-
const collectTx = await sdk.dex.positions.collectPositionFees({
|
|
768
|
-
token0: 'GALA|Unit|none|none',
|
|
769
|
-
token1: 'GUSDC|Unit|none|none',
|
|
770
|
-
fee: 3000,
|
|
771
|
-
tickLower: position.tickLower,
|
|
772
|
-
tickUpper: position.tickUpper,
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
const collected = await collectTx.confirm();
|
|
776
|
-
console.log(`✓ Collected: ${collected?.fees0} GALA + ${collected?.fees1} GUSDC`);
|
|
777
|
-
```
|
|
778
|
-
|
|
779
|
-
### High-Volume Fee Testing
|
|
780
|
-
|
|
781
|
-
```typescript
|
|
782
|
-
// Simulate high trading volume to test fee accumulation
|
|
783
|
-
const highVolumeSwaps = 100;
|
|
784
|
-
const swapAmount = '50'; // 50 GALA per swap
|
|
785
|
-
|
|
786
|
-
console.log(`Generating ${highVolumeSwaps} swaps...`);
|
|
787
|
-
|
|
788
|
-
for (let i = 0; i < highVolumeSwaps; i++) {
|
|
789
|
-
const quote = await sdk.dex.quoting.quoteExactInput('GALA|Unit|none|none', 'GUSDC|Unit|none|none', swapAmount);
|
|
790
|
-
const swapTx = await sdk.dex.swaps.swap('GALA|Unit|none|none', 'GUSDC|Unit|none|none', quote.feeTier, {
|
|
791
|
-
exactIn: swapAmount,
|
|
792
|
-
amountOutMinimum: quote.amountOut,
|
|
793
|
-
});
|
|
794
|
-
await swapTx.confirm();
|
|
795
|
-
|
|
796
|
-
if ((i + 1) % 10 === 0) {
|
|
797
|
-
console.log(`${i + 1}/${highVolumeSwaps} swaps completed`);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
console.log(`✓ High-volume testing complete`);
|
|
802
|
-
```
|
|
803
|
-
|
|
804
|
-
**Fee Demos (5 total):**
|
|
805
|
-
- `npm run demo:fees` - Basic fee generation and collection
|
|
806
|
-
- `npm run demo:fees:high-volume` - High-volume trading simulation
|
|
807
|
-
- `npm run demo:fees:test` - Complete fee lifecycle test suite
|
|
808
|
-
- `npm run demo:fees:trade-collect` - Single workflow (trade + collect)
|
|
809
|
-
|
|
810
|
-
**Advanced (not exposed as npm script):**
|
|
811
|
-
- `tsx examples/fees/demo-multi-wallet-fee-generation.ts` - Multi-wallet fee workflows
|
|
310
|
+
- `npm run demo:bonding:user-holder` - Holder context
|
|
311
|
+
- `npm run demo:bonding:pagination-variants` - Pagination variants
|
|
312
|
+
- `npm run demo:bonding:pool-creator-filtering` - Creator filtering
|
|
812
313
|
|
|
813
314
|
---
|
|
814
315
|
|
|
815
316
|
## Real-Time Monitoring
|
|
816
317
|
|
|
817
|
-
Monitor
|
|
818
|
-
|
|
819
|
-
### Watch for DEX Pool Creation
|
|
820
|
-
|
|
821
|
-
`sdk.onDexPoolCreation()` no longer exists. The gSwap realtime stream client now lives in
|
|
822
|
-
@gala-chain/gswap-sdk (`new GSwap().stream`).
|
|
318
|
+
Monitor token creation events with the SDK's watchers. (New DEX pools are gswap-sdk's:
|
|
319
|
+
`gSwap.pools.watchNewPools()`.)
|
|
823
320
|
|
|
824
321
|
### Watch for Launchpad Token Creation
|
|
825
322
|
|
|
@@ -845,9 +342,11 @@ setTimeout(() => {
|
|
|
845
342
|
}, 120000);
|
|
846
343
|
```
|
|
847
344
|
|
|
848
|
-
**Monitoring Demos
|
|
849
|
-
- `npm run demo:watch` - Watch for new DEX pool creation
|
|
345
|
+
**Monitoring Demos:**
|
|
850
346
|
- `npm run demo:watch:tokens` - Watch for new launchpad token launches
|
|
347
|
+
- `npm run demo:watch:integration` - Token creation integration
|
|
348
|
+
- `npm run demo:monitoring:stream-events` - Stream events
|
|
349
|
+
- `npm run demo:monitoring:websocket-events` - WebSocket event handlers
|
|
851
350
|
|
|
852
351
|
---
|
|
853
352
|
|
|
@@ -955,15 +454,15 @@ await sdk.connectStreamWebSocket({
|
|
|
955
454
|
});
|
|
956
455
|
```
|
|
957
456
|
|
|
958
|
-
**Streaming & Chat Demos (
|
|
457
|
+
**Streaming & Chat Demos (a selection; `npm run demo:list` shows all):**
|
|
959
458
|
- `npm run demo:streaming` - Basic stream management
|
|
960
459
|
- `npm run demo:streaming:recordings` - Recording management
|
|
961
460
|
- `npm run demo:streaming:simulcast` - Simulcast target management
|
|
962
|
-
- `npm run demo:streaming:engagement` - Engagement statistics
|
|
963
461
|
- `npm run demo:chat` - REST chat operations
|
|
964
462
|
- `npm run demo:chat:websocket` - WebSocket real-time chat
|
|
965
463
|
- `npm run demo:chat:typing-indicators` - Typing indicator demo
|
|
966
464
|
|
|
465
|
+
|
|
967
466
|
---
|
|
968
467
|
|
|
969
468
|
## Utilities
|
|
@@ -975,15 +474,7 @@ const sdk = createLaunchpadSDK({ env: 'prod' });
|
|
|
975
474
|
|
|
976
475
|
// GALA balance
|
|
977
476
|
const galaBalance = await sdk.fetchGalaBalance('eth|0x...');
|
|
978
|
-
console.log(`GALA: ${galaBalance
|
|
979
|
-
|
|
980
|
-
// Token balance on DEX
|
|
981
|
-
const assets = await sdk.dex.assets.getUserAssets('eth|0x...');
|
|
982
|
-
|
|
983
|
-
console.log('DEX Assets:');
|
|
984
|
-
assets.tokens.forEach(asset => {
|
|
985
|
-
console.log(` ${asset.symbol}: ${asset.quantity}`);
|
|
986
|
-
});
|
|
477
|
+
console.log(`GALA: ${galaBalance?.balance}`);
|
|
987
478
|
|
|
988
479
|
// Tokens you hold
|
|
989
480
|
const held = await sdk.fetchTokensHeld({
|
|
@@ -992,7 +483,7 @@ const held = await sdk.fetchTokensHeld({
|
|
|
992
483
|
});
|
|
993
484
|
|
|
994
485
|
console.log('Tokens held:');
|
|
995
|
-
held.forEach(token => {
|
|
486
|
+
held.tokens.forEach(token => {
|
|
996
487
|
console.log(` ${token.symbol}: ${token.balance}`);
|
|
997
488
|
});
|
|
998
489
|
```
|
|
@@ -1064,29 +555,16 @@ console.timeEnd('Batch Calculations');
|
|
|
1064
555
|
// Output: Batch Calculations: ~50ms (vs ~2000ms without cache)
|
|
1065
556
|
```
|
|
1066
557
|
|
|
1067
|
-
|
|
558
|
+
|
|
559
|
+
**Utility Demos:**
|
|
1068
560
|
- `npm run demo:cache` - Metadata cache warming and performance
|
|
1069
561
|
- `npm run demo:token-supply` - Token supply metrics from GalaChain
|
|
1070
|
-
- `npm run demo:utilities:balances` - Multi-token balance queries
|
|
1071
562
|
- `npm run demo:utilities:balance` - Single token balance check
|
|
1072
|
-
- `npm run demo:utilities:
|
|
1073
|
-
|
|
1074
|
-
**Key Features:**
|
|
563
|
+
- `npm run demo:utilities:multi-token-portfolio` - Multi-token portfolio
|
|
564
|
+
- `npm run demo:utilities:trade-history` - Trade history
|
|
1075
565
|
|
|
1076
|
-
|
|
1077
|
-
-
|
|
1078
|
-
- Useful for portfolio overview and batch queries
|
|
1079
|
-
- Example: Query all token holdings at once
|
|
1080
|
-
|
|
1081
|
-
**Single Token Balance** (`demo:utilities:balance`):
|
|
1082
|
-
- Check balance for a specific token
|
|
1083
|
-
- Fast, focused balance query
|
|
1084
|
-
- Example: Verify GALA balance before trade
|
|
1085
|
-
|
|
1086
|
-
**Price History** (`demo:utilities:price-history`):
|
|
1087
|
-
- Fetch historical price data for technical analysis
|
|
1088
|
-
- Node.js only (requires file system access)
|
|
1089
|
-
- Example: Download price data for charting and trend analysis
|
|
566
|
+
Wallet balances and price history on the DEX are gswap-sdk's (`src/assets/balances.ts`,
|
|
567
|
+
`src/market/price-history.ts` in its demos).
|
|
1090
568
|
|
|
1091
569
|
---
|
|
1092
570
|
|
|
@@ -1094,24 +572,6 @@ console.timeEnd('Batch Calculations');
|
|
|
1094
572
|
|
|
1095
573
|
Common error patterns and solutions.
|
|
1096
574
|
|
|
1097
|
-
### Network Errors
|
|
1098
|
-
|
|
1099
|
-
```typescript
|
|
1100
|
-
try {
|
|
1101
|
-
const quote = await sdk.dex.quoting.quoteExactInput('GALA', 'INVALID', '100');
|
|
1102
|
-
} catch (error) {
|
|
1103
|
-
if (error.message.includes('Pool not found')) {
|
|
1104
|
-
console.log('Token pair not available on DEX');
|
|
1105
|
-
} else if (error.message.includes('Invalid token')) {
|
|
1106
|
-
console.log('Check token symbol format');
|
|
1107
|
-
} else if (error.message.includes('timeout')) {
|
|
1108
|
-
console.log('Network request timeout - try again');
|
|
1109
|
-
} else {
|
|
1110
|
-
console.log(`Error: ${error.message}`);
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
```
|
|
1114
|
-
|
|
1115
575
|
### Wallet Requirements
|
|
1116
576
|
|
|
1117
577
|
```typescript
|
|
@@ -1134,74 +594,28 @@ try {
|
|
|
1134
594
|
|
|
1135
595
|
```typescript
|
|
1136
596
|
try {
|
|
1137
|
-
const quote = await sdk.
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
'
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
);
|
|
1146
|
-
const applied = await submitted.confirm();
|
|
597
|
+
const quote = await sdk.calculateBuyAmount({ tokenName: 'anime', amount: '1000', type: 'native' });
|
|
598
|
+
await sdk.buy({
|
|
599
|
+
tokenName: 'anime',
|
|
600
|
+
amount: '1000',
|
|
601
|
+
type: 'native',
|
|
602
|
+
expectedAmount: quote.amount,
|
|
603
|
+
slippageToleranceFactor: 0.01
|
|
604
|
+
});
|
|
1147
605
|
} catch (error) {
|
|
1148
606
|
if (error.message.includes('slippage')) {
|
|
1149
607
|
console.log('Price moved beyond slippage tolerance');
|
|
1150
|
-
console.log('Increase slippage or retry with fresh quote');
|
|
608
|
+
console.log('Increase slippage or retry with a fresh quote');
|
|
1151
609
|
}
|
|
1152
610
|
}
|
|
1153
611
|
```
|
|
1154
612
|
|
|
1155
|
-
**Error Handling Demo:**
|
|
1156
|
-
- `npm run demo:liquidity:errors` - Comprehensive error scenarios
|
|
1157
|
-
|
|
1158
613
|
---
|
|
1159
614
|
|
|
1160
615
|
## More Examples
|
|
1161
616
|
|
|
1162
|
-
See the `examples/` directory for
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
examples/
|
|
1166
|
-
├── api-keys/ # 2 demos - API key management
|
|
1167
|
-
├── bans/ # 1 demo - User ban management
|
|
1168
|
-
├── bonding-curve/ # 8 demos - Pre-graduation trading
|
|
1169
|
-
├── bridge/ # 23 demos - Cross-chain bridging
|
|
1170
|
-
├── chat/ # 3 demos - REST & WebSocket chat
|
|
1171
|
-
├── content-flags/ # 1 demo - Content flag management
|
|
1172
|
-
├── core/ # 6 demos - SDK fundamentals
|
|
1173
|
-
├── dex/ # 8 demos - DEX trading & leaderboard
|
|
1174
|
-
├── fees/ # 5 demos - Fee workflows
|
|
1175
|
-
├── liquidity/ # 12 demos - LP position management
|
|
1176
|
-
├── locks/ # 2 demos - Token locking
|
|
1177
|
-
├── moderators/ # 1 demo - Moderator invites
|
|
1178
|
-
├── monitoring/ # 11 demos - Real-time events
|
|
1179
|
-
├── overseers/ # 1 demo - Overseer management
|
|
1180
|
-
├── streaming/ # 4 demos - Stream management & engagement
|
|
1181
|
-
├── utilities/ # 7 demos - Helper operations
|
|
1182
|
-
└── debug/ # 5 tools - Development utilities (not in npm scripts)
|
|
1183
|
-
```
|
|
1184
|
-
|
|
1185
|
-
**Total:** 99 demos covering all major SDK features (+ 5 debug tools)
|
|
1186
|
-
|
|
1187
|
-
**Category Breakdown:**
|
|
1188
|
-
- **API Key Management**: 2 demos for API key CRUD operations
|
|
1189
|
-
- **Ban Management**: 1 demo for user ban/unban workflows
|
|
1190
|
-
- **Bonding Curve Trading**: 8 demos for pre-graduation token trading (orchestrator + 7 specialized)
|
|
1191
|
-
- **Cross-Chain Bridge**: 23 demos for GalaChain ↔ Ethereum/Solana bridging
|
|
1192
|
-
- **Chat**: 3 demos for REST chat, WebSocket chat, and typing indicators
|
|
1193
|
-
- **Content Flags**: 1 demo for content flag/report management
|
|
1194
|
-
- **Core Operations**: 6 demos covering SDK setup, configuration, and multi-wallet testing
|
|
1195
|
-
- **DEX Trading**: 8 demos for swaps, pools, leaderboard, and volume analytics
|
|
1196
|
-
- **Fee Management**: 5 demos for fee generation and collection workflows
|
|
1197
|
-
- **Liquidity Management**: 12 demos for LP positions (orchestrator + 11 specialized)
|
|
1198
|
-
- **Token Locking**: 2 demos for lock/unlock workflows
|
|
1199
|
-
- **Moderators**: 1 demo for moderator invite management
|
|
1200
|
-
- **Real-Time Monitoring**: 11 demos for pool/token creation watchers
|
|
1201
|
-
- **Overseers**: 1 demo for overseer management
|
|
1202
|
-
- **Streaming**: 4 demos for stream management, recordings, simulcast, and engagement stats
|
|
1203
|
-
- **Swap Monitoring**: 4 demos for DEX swap event tracking
|
|
1204
|
-
- **Utilities**: 7 demos for balances, cache, supply, and price history
|
|
1205
|
-
- **Debug Tools**: 5 development utilities (not exposed as npm scripts)
|
|
617
|
+
See the `examples/` directory for the working demos by category (`examples/README.md` lists them);
|
|
618
|
+
`npm run demo:list` browses them. DEX demos live in
|
|
619
|
+
[`packages/gswap-sdk/examples/demos`](../gswap-sdk/examples/demos/README.md).
|
|
1206
620
|
|
|
1207
621
|
For migration from old demo structure, see [docs/DEMO_MIGRATION_GUIDE.md](./docs/DEMO_MIGRATION_GUIDE.md).
|