@gala-chain/launchpad-mcp-server 1.21.6 → 1.22.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 +84 -0
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/docs/AI-AGENT-PATTERNS.md +555 -0
- package/docs/CONSTRAINTS-REFERENCE.md +454 -0
- package/docs/PROMPT-TOOL-MAPPING.md +352 -0
- package/docs/examples/default-values-pattern.md +240 -0
- package/docs/examples/tool-factory-pattern.md +217 -0
- package/jest.config.js +94 -0
- package/package.json +2 -2
- package/src/__tests__/integration/fetchTokenDetails.integration.test.ts +258 -0
- package/src/__tests__/integration/poolTools.integration.test.ts +185 -0
- package/src/constants/mcpToolNames.ts +141 -0
- package/src/index.ts +19 -0
- package/src/prompts/__tests__/promptStructure.test.ts +137 -0
- package/src/prompts/__tests__/registry.test.ts +191 -0
- package/src/prompts/analysis.ts +429 -0
- package/src/prompts/create-token.ts +123 -0
- package/src/prompts/dex-trading.ts +86 -0
- package/src/prompts/discover-tokens.ts +86 -0
- package/src/prompts/index.ts +154 -0
- package/src/prompts/liquidity-positions.ts +270 -0
- package/src/prompts/portfolio.ts +242 -0
- package/src/prompts/trading.ts +191 -0
- package/src/prompts/utility.ts +43 -0
- package/src/prompts/utils/workflowTemplates.ts +511 -0
- package/src/schemas/common-schemas.ts +393 -0
- package/src/scripts/test-all-prompts.ts +184 -0
- package/src/server.ts +277 -0
- package/src/tools/__tests__/dex-tools.test.ts +562 -0
- package/src/tools/__tests__/liquidity-positions.test.ts +673 -0
- package/src/tools/balance/index.ts +174 -0
- package/src/tools/creation/index.ts +182 -0
- package/src/tools/dex/index.ts +226 -0
- package/src/tools/dex/liquidity-positions.ts +547 -0
- package/src/tools/index.ts +86 -0
- package/src/tools/pools/fetchAllPools.ts +47 -0
- package/src/tools/pools/fetchAllPriceHistory.ts +119 -0
- package/src/tools/pools/fetchPoolDetails.ts +27 -0
- package/src/tools/pools/fetchPoolDetailsForCalculation.ts +22 -0
- package/src/tools/pools/fetchPools.ts +47 -0
- package/src/tools/pools/fetchPriceHistory.ts +124 -0
- package/src/tools/pools/fetchTokenDetails.ts +77 -0
- package/src/tools/pools/index.ts +284 -0
- package/src/tools/social/index.ts +64 -0
- package/src/tools/trading/index.ts +605 -0
- package/src/tools/transfers/index.ts +75 -0
- package/src/tools/utils/clearCache.ts +36 -0
- package/src/tools/utils/createWallet.ts +19 -0
- package/src/tools/utils/explainSdkUsage.ts +1446 -0
- package/src/tools/utils/getAddress.ts +12 -0
- package/src/tools/utils/getCacheInfo.ts +14 -0
- package/src/tools/utils/getConfig.ts +11 -0
- package/src/tools/utils/getEthereumAddress.ts +12 -0
- package/src/tools/utils/getUrlByTokenName.ts +12 -0
- package/src/tools/utils/getVersion.ts +25 -0
- package/src/tools/utils/getWallet.ts +25 -0
- package/src/tools/utils/hasWallet.ts +15 -0
- package/src/tools/utils/index.ts +33 -0
- package/src/tools/utils/isTokenGraduated.ts +16 -0
- package/src/tools/utils/setWallet.ts +41 -0
- package/src/types/mcp.ts +72 -0
- package/src/utils/__tests__/validation.test.ts +147 -0
- package/src/utils/constraints.ts +155 -0
- package/src/utils/default-values.ts +208 -0
- package/src/utils/error-handler.ts +69 -0
- package/src/utils/error-templates.ts +273 -0
- package/src/utils/response-formatter.ts +51 -0
- package/src/utils/tool-factory.ts +257 -0
- package/src/utils/tool-registry.ts +296 -0
- package/src/utils/validation.ts +371 -0
- package/tests/wallet-management-integration.test.ts +284 -0
- package/tsconfig.json +23 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,89 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0a49faf: **GalaSwap Liquidity Position Management (v3.25.0 SDK / v1.20.0 MCP)**
|
|
8
|
+
|
|
9
|
+
Comprehensive liquidity position management for concentrated liquidity provision on GalaSwap DEX.
|
|
10
|
+
Liquidity providers can now earn passive trading fees by providing liquidity within specific price
|
|
11
|
+
ranges.
|
|
12
|
+
|
|
13
|
+
### 8 New SDK Methods (LaunchpadSDK)
|
|
14
|
+
1. **getSwapUserLiquidityPositions(ownerAddress, limit?, bookmark?)** - View all open positions
|
|
15
|
+
for a wallet with pagination support
|
|
16
|
+
2. **getSwapLiquidityPositionById(ownerAddress, positionId)** - Get specific position by UUID
|
|
17
|
+
3. **getSwapLiquidityPosition(ownerAddress, position)** - Get position by token pair and tick
|
|
18
|
+
range
|
|
19
|
+
4. **addSwapLiquidityByPrice(args)** - Create position using user-friendly price ranges (e.g.,
|
|
20
|
+
min: 0.95, max: 1.05)
|
|
21
|
+
5. **addSwapLiquidityByTicks(args)** - Create position using precise tick boundaries (advanced)
|
|
22
|
+
6. **getSwapEstimateRemoveLiquidity(args)** - Preview amounts and fees before executing removal
|
|
23
|
+
7. **removeSwapLiquidity(args)** - Close or reduce position with slippage protection
|
|
24
|
+
8. **collectSwapPositionFees(args)** - Harvest accumulated trading fees without closing position
|
|
25
|
+
|
|
26
|
+
### 8 New MCP Tools
|
|
27
|
+
|
|
28
|
+
All SDK methods exposed as MCP tools with full type validation and privateKey override support:
|
|
29
|
+
- `gala_launchpad_get_user_liquidity_positions` - List positions with pagination
|
|
30
|
+
- `gala_launchpad_get_liquidity_position_by_id` - Get by position ID
|
|
31
|
+
- `gala_launchpad_get_liquidity_position` - Get by token pair
|
|
32
|
+
- `gala_launchpad_add_liquidity_by_price` - Create position (price-based)
|
|
33
|
+
- `gala_launchpad_add_liquidity_by_ticks` - Create position (tick-based)
|
|
34
|
+
- `gala_launchpad_estimate_remove_liquidity` - Estimate removal amounts
|
|
35
|
+
- `gala_launchpad_remove_liquidity` - Execute removal
|
|
36
|
+
- `gala_launchpad_collect_position_fees` - Collect accumulated fees
|
|
37
|
+
|
|
38
|
+
### 4 New Slash Commands (Prompts)
|
|
39
|
+
|
|
40
|
+
Quick-access workflows for Claude Desktop users:
|
|
41
|
+
- `/galachain-launchpad:my-positions` - View all liquidity positions
|
|
42
|
+
- `/galachain-launchpad:add-liquidity` - Create new position (guided workflow)
|
|
43
|
+
- `/galachain-launchpad:remove-liquidity` - Close position (with estimates)
|
|
44
|
+
- `/galachain-launchpad:collect-fees` - Harvest accumulated fees
|
|
45
|
+
|
|
46
|
+
### Key Features
|
|
47
|
+
|
|
48
|
+
**Fee Tiers**: Support for standard GalaSwap fee tiers (500 bps = 0.05%, 3000 bps = 0.30%, 10000
|
|
49
|
+
bps = 1.00%)
|
|
50
|
+
|
|
51
|
+
**Price Range Creation**: User-friendly price range interface (0.95 - 1.05) automatically converts
|
|
52
|
+
to precise tick boundaries
|
|
53
|
+
|
|
54
|
+
**Tick-Based Creation**: Advanced users can create positions using exact tick boundaries for
|
|
55
|
+
precise capital management
|
|
56
|
+
|
|
57
|
+
**Fee Collection**: Harvest passive trading fees without closing position
|
|
58
|
+
|
|
59
|
+
**Estimation**: Preview exact amounts and fees before executing any transaction
|
|
60
|
+
|
|
61
|
+
**Slippage Protection**: Built-in slippage tolerance for all operations
|
|
62
|
+
|
|
63
|
+
**Pagination**: Efficient position listing with bookmark support for large portfolios
|
|
64
|
+
|
|
65
|
+
### Documentation & Examples
|
|
66
|
+
- **Demo Script**: `packages/sdk/examples/demo-liquidity-positions.ts` - Complete workflow
|
|
67
|
+
demonstration
|
|
68
|
+
- **SDK Docs**: `explain_sdk_usage` tool includes `liquidity-positions` topic with runnable
|
|
69
|
+
examples
|
|
70
|
+
- **Integration Guide**: CLAUDE.md includes comprehensive LP integration section
|
|
71
|
+
|
|
72
|
+
### Test Coverage
|
|
73
|
+
- **54 SDK Unit Tests**: Complete test coverage for all 8 methods with edge cases
|
|
74
|
+
- **39 MCP Tool Tests**: Full validation of all 8 MCP tools and input schemas
|
|
75
|
+
- **1401 Total Tests**: Full regression test suite passing
|
|
76
|
+
|
|
77
|
+
### Version Updates
|
|
78
|
+
- SDK: 3.24.2 → 3.25.0 (minor version bump)
|
|
79
|
+
- MCP Server: 1.19.2 → 1.20.0 (minor version bump)
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [0a49faf]
|
|
84
|
+
- Updated dependencies
|
|
85
|
+
- @gala-chain/launchpad-sdk@3.27.0
|
|
86
|
+
|
|
3
87
|
## 1.19.0
|
|
4
88
|
|
|
5
89
|
### Minor Changes
|
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
# AI Agent Patterns for Gala Launchpad MCP Server
|
|
2
|
+
|
|
3
|
+
This guide provides AI agents with common workflows, gotchas, and best practices when using the `galachain-launchpad` MCP server.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Common Workflows](#common-workflows)
|
|
8
|
+
- [Critical Gotchas](#critical-gotchas)
|
|
9
|
+
- [Constraint Reference](#constraint-reference)
|
|
10
|
+
- [Error Troubleshooting](#error-troubleshooting)
|
|
11
|
+
- [Best Practices](#best-practices)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Common Workflows
|
|
16
|
+
|
|
17
|
+
### 1. Token Launch Workflow
|
|
18
|
+
|
|
19
|
+
**Complete token creation from scratch:**
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
// Step 1: Verify token name is available
|
|
23
|
+
gala_launchpad_check_token_name({
|
|
24
|
+
tokenName: 'mytoken'
|
|
25
|
+
})
|
|
26
|
+
// Response: { available: true, message: "Token name is available" }
|
|
27
|
+
|
|
28
|
+
// Step 2: Verify token symbol is available
|
|
29
|
+
gala_launchpad_check_token_symbol({
|
|
30
|
+
symbol: 'MTK'
|
|
31
|
+
})
|
|
32
|
+
// Response: { available: true, message: "Token symbol is available" }
|
|
33
|
+
|
|
34
|
+
// Step 3: Upload token image (optional, can use URL instead)
|
|
35
|
+
gala_launchpad_upload_token_image({
|
|
36
|
+
tokenName: 'mytoken',
|
|
37
|
+
imagePath: '/absolute/path/to/image.png'
|
|
38
|
+
})
|
|
39
|
+
// Response: { url: 'https://launchpad.galachain.com/uploads/mytoken.png' }
|
|
40
|
+
|
|
41
|
+
// Step 4: Launch the token
|
|
42
|
+
gala_launchpad_launch_token({
|
|
43
|
+
tokenName: 'mytoken',
|
|
44
|
+
tokenSymbol: 'MTK',
|
|
45
|
+
tokenDescription: 'My awesome token for the community',
|
|
46
|
+
tokenImage: 'https://launchpad.galachain.com/uploads/mytoken.png',
|
|
47
|
+
preBuyQuantity: '100', // Optional initial buy
|
|
48
|
+
websiteUrl: 'https://mytoken.com',
|
|
49
|
+
twitterUrl: 'https://twitter.com/mytoken'
|
|
50
|
+
})
|
|
51
|
+
// Response: { tokenName: 'mytoken', transactionId: '...' }
|
|
52
|
+
|
|
53
|
+
// Step 5: Get the frontend URL
|
|
54
|
+
gala_launchpad_get_url_by_token_name({
|
|
55
|
+
tokenName: 'mytoken'
|
|
56
|
+
})
|
|
57
|
+
// Response: { url: 'https://launchpad.galachain.com/token/mytoken' }
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 2. Trading Workflow (Buy Tokens)
|
|
61
|
+
|
|
62
|
+
**Two-step process: Calculate → Execute**
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// Step 1: Calculate buy amount (REQUIRED FIRST STEP)
|
|
66
|
+
const calcResult = gala_launchpad_calculate_buy_amount({
|
|
67
|
+
tokenName: 'woohoo',
|
|
68
|
+
amount: '10', // Spending 10 GALA
|
|
69
|
+
type: 'native' // 'native' = GALA amount
|
|
70
|
+
})
|
|
71
|
+
// Response: {
|
|
72
|
+
// amount: '16843.7579794843252', // <- THIS is expectedAmount for buy()
|
|
73
|
+
// reverseBondingCurveFee: '0.059280156', // <- THIS is maxAcceptableReverseBondingCurveFee
|
|
74
|
+
// transactionFee: '0.00141090',
|
|
75
|
+
// gasFee: '1'
|
|
76
|
+
// }
|
|
77
|
+
|
|
78
|
+
// Step 2: Execute buy with calculated expectedAmount AND reverseBondingCurveFee
|
|
79
|
+
gala_launchpad_buy_tokens({
|
|
80
|
+
tokenName: 'woohoo',
|
|
81
|
+
amount: '10', // Same as Step 1
|
|
82
|
+
type: 'native', // Same as Step 1
|
|
83
|
+
expectedAmount: '16843.7579794843252', // <- Use result.amount from Step 1
|
|
84
|
+
maxAcceptableReverseBondingCurveFee: '0.059280156', // <- Use result.reverseBondingCurveFee from Step 1
|
|
85
|
+
slippageToleranceFactor: 0.05 // 5% slippage protection
|
|
86
|
+
})
|
|
87
|
+
// Response: { transactionId: '...', status: 'completed' }
|
|
88
|
+
|
|
89
|
+
// Step 3: Verify trade completed
|
|
90
|
+
gala_launchpad_fetch_trades({
|
|
91
|
+
tokenName: 'woohoo',
|
|
92
|
+
userAddress: 'eth|your-address',
|
|
93
|
+
limit: 1
|
|
94
|
+
})
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**⚠️ CRITICAL:**
|
|
98
|
+
- `expectedAmount` must be `result.amount` from calculate function, NOT your input amount!
|
|
99
|
+
- `maxAcceptableReverseBondingCurveFee` must be `result.reverseBondingCurveFee` from calculate function!
|
|
100
|
+
|
|
101
|
+
### 3. Trading Workflow (Sell Tokens)
|
|
102
|
+
|
|
103
|
+
**Same two-step pattern:**
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
// Step 1: Calculate sell amount
|
|
107
|
+
const calcResult = gala_launchpad_calculate_sell_amount({
|
|
108
|
+
tokenName: 'woohoo',
|
|
109
|
+
amount: '1000', // Selling 1000 tokens
|
|
110
|
+
type: 'exact' // 'exact' = exact token amount
|
|
111
|
+
})
|
|
112
|
+
// Response: {
|
|
113
|
+
// amount: '5.234567', // <- THIS is expectedAmount for sell()
|
|
114
|
+
// reverseBondingCurveFee: '2.617284', // <- THIS is maxAcceptableReverseBondingCurveFee
|
|
115
|
+
// transactionFee: '0.00523457',
|
|
116
|
+
// gasFee: '1'
|
|
117
|
+
// }
|
|
118
|
+
|
|
119
|
+
// Step 2: Execute sell with calculated expectedAmount AND reverseBondingCurveFee
|
|
120
|
+
gala_launchpad_sell_tokens({
|
|
121
|
+
tokenName: 'woohoo',
|
|
122
|
+
amount: '1000',
|
|
123
|
+
type: 'exact',
|
|
124
|
+
expectedAmount: '5.234567', // <- Use result.amount from Step 1
|
|
125
|
+
maxAcceptableReverseBondingCurveFee: '2.617284', // <- Use result.reverseBondingCurveFee from Step 1
|
|
126
|
+
slippageToleranceFactor: 0.05
|
|
127
|
+
})
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 4. Portfolio Management Workflow
|
|
131
|
+
|
|
132
|
+
**Check balances and trading activity:**
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// Get GALA balance
|
|
136
|
+
gala_launchpad_fetch_gala_balance({
|
|
137
|
+
address: 'eth|your-address' // Optional, defaults to authenticated wallet
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
// Get specific token balance (optimized single-token lookup)
|
|
141
|
+
gala_launchpad_fetch_token_balance({
|
|
142
|
+
tokenName: 'woohoo',
|
|
143
|
+
address: 'eth|your-address'
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
// Get all tokens held (with filtering)
|
|
147
|
+
gala_launchpad_fetch_tokens_held({
|
|
148
|
+
address: 'eth|your-address',
|
|
149
|
+
tokenName: 'woohoo', // Optional exact match filter
|
|
150
|
+
limit: 20 // Max 20 for user operations
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
// Get all tokens created by user
|
|
154
|
+
gala_launchpad_fetch_tokens_created({
|
|
155
|
+
address: 'eth|your-address',
|
|
156
|
+
search: 'test', // Optional fuzzy search filter
|
|
157
|
+
limit: 20
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
// Get trade history
|
|
161
|
+
gala_launchpad_fetch_trades({
|
|
162
|
+
tokenName: 'woohoo',
|
|
163
|
+
userAddress: 'eth|your-address',
|
|
164
|
+
tradeType: 'BUY', // Optional: 'BUY' or 'SELL'
|
|
165
|
+
limit: 20, // Max 20 for trade operations
|
|
166
|
+
sortOrder: 'DESC'
|
|
167
|
+
})
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### 5. Pool Analysis Workflow
|
|
171
|
+
|
|
172
|
+
**Discover and analyze token pools:**
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// Fetch recent/trending pools
|
|
176
|
+
gala_launchpad_fetch_pools({
|
|
177
|
+
type: 'trending', // 'recent', 'trending', or 'user'
|
|
178
|
+
limit: 100 // Max 100 for pool operations
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
// Get detailed pool state
|
|
182
|
+
gala_launchpad_fetch_pool_details({
|
|
183
|
+
tokenName: 'woohoo'
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
// Get holder distribution
|
|
187
|
+
gala_launchpad_fetch_token_distribution({
|
|
188
|
+
tokenName: 'woohoo'
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
// Get volume data for charting
|
|
192
|
+
gala_launchpad_fetch_volume_data({
|
|
193
|
+
tokenName: 'woohoo',
|
|
194
|
+
resolution: '1h', // '1m', '5m', '15m', '1h', '4h', '1d'
|
|
195
|
+
from: '2024-01-01T00:00:00Z',
|
|
196
|
+
to: '2024-01-31T23:59:59Z'
|
|
197
|
+
})
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Critical Gotchas
|
|
203
|
+
|
|
204
|
+
### Gotcha #1: Missing reverseBondingCurveFee Parameter ⚠️🔥
|
|
205
|
+
|
|
206
|
+
**Problem:** AI agents forget to pass `maxAcceptableReverseBondingCurveFee`, causing transaction failures.
|
|
207
|
+
|
|
208
|
+
**Wrong:**
|
|
209
|
+
```typescript
|
|
210
|
+
// Step 1: Calculate
|
|
211
|
+
const calc = gala_launchpad_calculate_sell_amount({ tokenName: 'anime', amount: '500', type: 'exact' })
|
|
212
|
+
// calc = { amount: '0.7056532', reverseBondingCurveFee: '0.3528266', ... }
|
|
213
|
+
|
|
214
|
+
// Step 2: Execute - MISSING reverseBondingCurveFee!
|
|
215
|
+
gala_launchpad_sell_tokens({
|
|
216
|
+
tokenName: 'anime',
|
|
217
|
+
amount: '500',
|
|
218
|
+
type: 'exact',
|
|
219
|
+
expectedAmount: '0.7056532', // ✅ Got this right
|
|
220
|
+
// ❌ MISSING: maxAcceptableReverseBondingCurveFee
|
|
221
|
+
slippageToleranceFactor: 0.05
|
|
222
|
+
})
|
|
223
|
+
// Result: Transaction fails with "FAILED" status
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
**Correct:**
|
|
227
|
+
```typescript
|
|
228
|
+
// Step 1: Calculate
|
|
229
|
+
const calc = gala_launchpad_calculate_sell_amount({ tokenName: 'anime', amount: '500', type: 'exact' })
|
|
230
|
+
// calc = { amount: '0.7056532', reverseBondingCurveFee: '0.3528266', ... }
|
|
231
|
+
|
|
232
|
+
// Step 2: Execute - Include BOTH parameters from calculation
|
|
233
|
+
gala_launchpad_sell_tokens({
|
|
234
|
+
tokenName: 'anime',
|
|
235
|
+
amount: '500',
|
|
236
|
+
type: 'exact',
|
|
237
|
+
expectedAmount: '0.7056532', // ✅ From result.amount
|
|
238
|
+
maxAcceptableReverseBondingCurveFee: '0.3528266', // ✅ From result.reverseBondingCurveFee
|
|
239
|
+
slippageToleranceFactor: 0.05
|
|
240
|
+
})
|
|
241
|
+
// Result: Transaction succeeds!
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
**Fix:** Always extract BOTH `result.amount` AND `result.reverseBondingCurveFee` from calculate functions, then pass BOTH to buy/sell.
|
|
245
|
+
|
|
246
|
+
**This applies to both buy AND sell operations!**
|
|
247
|
+
|
|
248
|
+
### Gotcha #2: expectedAmount Parameter Confusion ⚠️
|
|
249
|
+
|
|
250
|
+
**Problem:** AI agents use the input `amount` as `expectedAmount`, causing WebSocket timeouts.
|
|
251
|
+
|
|
252
|
+
**Wrong:**
|
|
253
|
+
```typescript
|
|
254
|
+
gala_launchpad_buy_tokens({
|
|
255
|
+
amount: '10',
|
|
256
|
+
expectedAmount: '10' // ❌ WRONG - This is your input, not the expected output!
|
|
257
|
+
})
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**Correct:**
|
|
261
|
+
```typescript
|
|
262
|
+
// Step 1: Calculate first
|
|
263
|
+
const calc = gala_launchpad_calculate_buy_amount({ amount: '10', ... })
|
|
264
|
+
// calc.amount = '16843.7579794843252'
|
|
265
|
+
|
|
266
|
+
// Step 2: Use calc.amount as expectedAmount
|
|
267
|
+
gala_launchpad_buy_tokens({
|
|
268
|
+
amount: '10',
|
|
269
|
+
expectedAmount: '16843.7579794843252' // ✅ CORRECT - Use result.amount
|
|
270
|
+
})
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Fix:** Always call `calculate*Amount()` first, then use `result.amount` as `expectedAmount`.
|
|
274
|
+
|
|
275
|
+
### Gotcha #3: Limit Validation Errors
|
|
276
|
+
|
|
277
|
+
**Problem:** AI agents hit "Limit must be between 1 and 20" errors when using `limit: 100`.
|
|
278
|
+
|
|
279
|
+
**Root Cause:** Different operations have different maximum limits:
|
|
280
|
+
- Trade operations: Max 20
|
|
281
|
+
- User operations (tokens held/created): Max 20
|
|
282
|
+
- Pool operations: Max 100
|
|
283
|
+
- Comment operations: Max 50
|
|
284
|
+
|
|
285
|
+
**Wrong:**
|
|
286
|
+
```typescript
|
|
287
|
+
gala_launchpad_fetch_trades({
|
|
288
|
+
limit: 100 // ❌ WRONG - Trades max is 20!
|
|
289
|
+
})
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Correct:**
|
|
293
|
+
```typescript
|
|
294
|
+
gala_launchpad_fetch_trades({
|
|
295
|
+
limit: 20 // ✅ CORRECT - Respects constraint
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
gala_launchpad_fetch_pools({
|
|
299
|
+
limit: 100 // ✅ CORRECT - Pools allow 100
|
|
300
|
+
})
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
**Fix:** Use the constraint reference table below for correct limits.
|
|
304
|
+
|
|
305
|
+
### Gotcha #4: Type Parameter Ambiguity
|
|
306
|
+
|
|
307
|
+
**Problem:** Confusion between `type: 'native'` and `type: 'exact'`.
|
|
308
|
+
|
|
309
|
+
**When to use 'native' (GALA amount):**
|
|
310
|
+
- "I want to spend 10 GALA" → `{ amount: '10', type: 'native' }`
|
|
311
|
+
- "I want to receive 5 GALA" → `{ amount: '5', type: 'native' }`
|
|
312
|
+
|
|
313
|
+
**When to use 'exact' (exact token amount):**
|
|
314
|
+
- "I want to buy exactly 1000 tokens" → `{ amount: '1000', type: 'exact' }`
|
|
315
|
+
- "I want to sell exactly 500 tokens" → `{ amount: '500', type: 'exact' }`
|
|
316
|
+
|
|
317
|
+
**Most Common:** Use `'native'` when you know the GALA amount.
|
|
318
|
+
|
|
319
|
+
### Gotcha #5: Token Filtering Confusion
|
|
320
|
+
|
|
321
|
+
**Problem:** Not using the right filter for the task.
|
|
322
|
+
|
|
323
|
+
**Use `tokenName` for exact lookups:**
|
|
324
|
+
```typescript
|
|
325
|
+
gala_launchpad_fetch_tokens_held({
|
|
326
|
+
tokenName: 'anime', // Exact match
|
|
327
|
+
limit: 1 // Only need 1 result
|
|
328
|
+
})
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
**Use `search` for discovery:**
|
|
332
|
+
```typescript
|
|
333
|
+
gala_launchpad_fetch_tokens_held({
|
|
334
|
+
search: 'dragon', // Fuzzy search
|
|
335
|
+
limit: 10 // Get multiple matches
|
|
336
|
+
})
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
**Don't mix both:** If you provide both, `tokenName` takes precedence.
|
|
340
|
+
|
|
341
|
+
### Gotcha #6: Wallet Address Format
|
|
342
|
+
|
|
343
|
+
**Problem:** Wrong wallet address format causes validation errors.
|
|
344
|
+
|
|
345
|
+
**Backend Format (for API):**
|
|
346
|
+
- ✅ `'eth|abc123...'` - Prefixed format
|
|
347
|
+
- ❌ `'0xabc123...'` - Standard Ethereum format
|
|
348
|
+
|
|
349
|
+
**Conversion Pattern:**
|
|
350
|
+
```typescript
|
|
351
|
+
// From standard to backend format
|
|
352
|
+
const backendAddress = address.startsWith('0x')
|
|
353
|
+
? `eth|${address.slice(2)}`
|
|
354
|
+
: address
|
|
355
|
+
|
|
356
|
+
// From backend to standard format
|
|
357
|
+
const standardAddress = address.startsWith('eth|')
|
|
358
|
+
? `0x${address.slice(4)}`
|
|
359
|
+
: address
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Constraint Reference
|
|
365
|
+
|
|
366
|
+
### Pagination Limits by Operation Type
|
|
367
|
+
|
|
368
|
+
| Operation Type | Max Limit | SDK Source |
|
|
369
|
+
|---------------|-----------|------------|
|
|
370
|
+
| **Trade Operations** | 20 | `TRADE_CONSTRAINTS.PAGINATION.MAX_LIMIT` |
|
|
371
|
+
| `fetchTrades` | 20 | packages/sdk/src/types/trade.dto.ts:331 |
|
|
372
|
+
| **User Operations** | 20 | `USER_CONSTRAINTS.PAGINATION.MAX_LIMIT` |
|
|
373
|
+
| `fetchTokensHeld` | 20 | packages/sdk/src/types/user.dto.ts:297 |
|
|
374
|
+
| `fetchTokensCreated` | 20 | packages/sdk/src/types/user.dto.ts:297 |
|
|
375
|
+
| **Pool Operations** | 100 | `PAGINATION_CONSTRAINTS.MAX_LIMIT` |
|
|
376
|
+
| `fetchPools` | 100 | packages/sdk/src/types/launchpad.dto.ts:587 |
|
|
377
|
+
| **Comment Operations** | 50 | `COMMENT_CONSTRAINTS.PAGINATION.MAX_LIMIT` |
|
|
378
|
+
| `fetchComments` | 50 | packages/sdk/src/types/comment.dto.ts:149 |
|
|
379
|
+
|
|
380
|
+
### Common Validation Rules
|
|
381
|
+
|
|
382
|
+
| Parameter | Pattern | Example |
|
|
383
|
+
|-----------|---------|---------|
|
|
384
|
+
| `tokenName` | `^[a-z0-9_-]{2,20}$` | `'mytoken'`, `'test_token'` |
|
|
385
|
+
| `tokenSymbol` | `^[A-Z0-9]{2,10}$` | `'MTK'`, `'TEST123'` |
|
|
386
|
+
| `address` | `^(0x[a-fA-F0-9]{40}\|eth\\|[a-fA-F0-9]{40})$` | `'eth\|abc123...'`, `'0xabc123...'` (auto-normalized) |
|
|
387
|
+
| `amount` | `^[0-9.]+$` | `'10'`, `'100.5'` |
|
|
388
|
+
| `slippageTolerance` | `0-1` (decimal) | `0.05` (5%), `0.01` (1%) |
|
|
389
|
+
|
|
390
|
+
---
|
|
391
|
+
|
|
392
|
+
## Error Troubleshooting
|
|
393
|
+
|
|
394
|
+
### "Limit must be a number between 1 and 20"
|
|
395
|
+
|
|
396
|
+
**Cause:** Using `limit: 100` on trade or user operations.
|
|
397
|
+
|
|
398
|
+
**Solution:**
|
|
399
|
+
```typescript
|
|
400
|
+
// Wrong
|
|
401
|
+
gala_launchpad_fetch_trades({ limit: 100 })
|
|
402
|
+
|
|
403
|
+
// Correct
|
|
404
|
+
gala_launchpad_fetch_trades({ limit: 20 })
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### "WebSocket timeout on trade execution"
|
|
408
|
+
|
|
409
|
+
**Cause:** Using wrong `expectedAmount` (likely using input amount instead of calculated result).
|
|
410
|
+
|
|
411
|
+
**Solution:**
|
|
412
|
+
```typescript
|
|
413
|
+
// Wrong
|
|
414
|
+
const calc = gala_launchpad_calculate_buy_amount({ amount: '10', ... })
|
|
415
|
+
gala_launchpad_buy_tokens({ amount: '10', expectedAmount: '10' })
|
|
416
|
+
|
|
417
|
+
// Correct
|
|
418
|
+
const calc = gala_launchpad_calculate_buy_amount({ amount: '10', ... })
|
|
419
|
+
gala_launchpad_buy_tokens({ amount: '10', expectedAmount: calc.amount })
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### "Token name validation failed"
|
|
423
|
+
|
|
424
|
+
**Cause:** Token name doesn't match pattern `^[a-z0-9_-]{2,20}$`.
|
|
425
|
+
|
|
426
|
+
**Valid:** `'mytoken'`, `'test-token'`, `'token_123'`
|
|
427
|
+
**Invalid:** `'MyToken'` (uppercase), `'a'` (too short), `'my token'` (space)
|
|
428
|
+
|
|
429
|
+
**Solution:** Use lowercase alphanumeric with dashes/underscores, 2-20 characters.
|
|
430
|
+
|
|
431
|
+
### "Token symbol validation failed"
|
|
432
|
+
|
|
433
|
+
**Cause:** Token symbol doesn't match pattern `^[A-Z0-9]{2,10}$`.
|
|
434
|
+
|
|
435
|
+
**Valid:** `'MTK'`, `'TEST123'`, `'ABC'`
|
|
436
|
+
**Invalid:** `'mtk'` (lowercase), `'A'` (too short), `'MY-TOKEN'` (dash)
|
|
437
|
+
|
|
438
|
+
**Solution:** Use uppercase alphanumeric only, 2-10 characters.
|
|
439
|
+
|
|
440
|
+
### "At least one social URL required"
|
|
441
|
+
|
|
442
|
+
**Cause:** Launching token without `websiteUrl`, `twitterUrl`, or `telegramUrl`.
|
|
443
|
+
|
|
444
|
+
**Solution:** Provide at least one social link:
|
|
445
|
+
```typescript
|
|
446
|
+
gala_launchpad_launch_token({
|
|
447
|
+
// ... other params
|
|
448
|
+
websiteUrl: 'https://mytoken.com' // At least one required
|
|
449
|
+
})
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
## Best Practices
|
|
455
|
+
|
|
456
|
+
### 1. Always Calculate Before Trading
|
|
457
|
+
|
|
458
|
+
Never skip the calculate step - it provides:
|
|
459
|
+
- Accurate `expectedAmount` for slippage protection
|
|
460
|
+
- Fee breakdown for transparency
|
|
461
|
+
- Price impact analysis for informed decisions
|
|
462
|
+
|
|
463
|
+
### 2. Use Appropriate Limits
|
|
464
|
+
|
|
465
|
+
Match your `limit` to the operation type:
|
|
466
|
+
- Trades/User operations: Use 20 or less
|
|
467
|
+
- Pools: Can use up to 100
|
|
468
|
+
- Comments: Can use up to 50
|
|
469
|
+
|
|
470
|
+
### 3. Handle Slippage Appropriately
|
|
471
|
+
|
|
472
|
+
Common slippage tolerance factors:
|
|
473
|
+
- `0.01` (1%) - Low volatility, stable pools
|
|
474
|
+
- `0.05` (5%) - Standard for most trades
|
|
475
|
+
- `0.10` (10%) - High volatility, new tokens
|
|
476
|
+
|
|
477
|
+
### 4. Use Token Filtering Efficiently
|
|
478
|
+
|
|
479
|
+
**For single token lookups:**
|
|
480
|
+
```typescript
|
|
481
|
+
gala_launchpad_fetch_token_balance({
|
|
482
|
+
tokenName: 'anime',
|
|
483
|
+
address: 'eth|...'
|
|
484
|
+
})
|
|
485
|
+
// 99% payload reduction vs fetching all tokens
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
**For discovery:**
|
|
489
|
+
```typescript
|
|
490
|
+
gala_launchpad_fetch_tokens_held({
|
|
491
|
+
search: 'dragon',
|
|
492
|
+
limit: 10
|
|
493
|
+
})
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### 5. Verify Trades Complete
|
|
497
|
+
|
|
498
|
+
After executing trades, always verify:
|
|
499
|
+
```typescript
|
|
500
|
+
gala_launchpad_fetch_trades({
|
|
501
|
+
tokenName: 'woohoo',
|
|
502
|
+
userAddress: 'eth|...',
|
|
503
|
+
limit: 1,
|
|
504
|
+
sortOrder: 'DESC'
|
|
505
|
+
})
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
### 6. Check Availability Before Launch
|
|
509
|
+
|
|
510
|
+
Always verify token name and symbol availability before launching:
|
|
511
|
+
```typescript
|
|
512
|
+
// Step 1: Check name
|
|
513
|
+
gala_launchpad_check_token_name({ tokenName: 'mytoken' })
|
|
514
|
+
|
|
515
|
+
// Step 2: Check symbol
|
|
516
|
+
gala_launchpad_check_token_symbol({ symbol: 'MTK' })
|
|
517
|
+
|
|
518
|
+
// Step 3: Launch if both available
|
|
519
|
+
gala_launchpad_launch_token({ ... })
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
---
|
|
523
|
+
|
|
524
|
+
## Quick Reference Card
|
|
525
|
+
|
|
526
|
+
### Trading Flow
|
|
527
|
+
1. `calculate_buy_amount()` or `calculate_sell_amount()`
|
|
528
|
+
2. Extract `result.amount` from response
|
|
529
|
+
3. Use `result.amount` as `expectedAmount` in buy/sell
|
|
530
|
+
4. Verify with `fetch_trades()`
|
|
531
|
+
|
|
532
|
+
### Limit Values
|
|
533
|
+
- Trades: 20 max
|
|
534
|
+
- User ops: 20 max
|
|
535
|
+
- Pools: 100 max
|
|
536
|
+
- Comments: 50 max
|
|
537
|
+
|
|
538
|
+
### Type Parameter
|
|
539
|
+
- `'native'` = GALA amount (most common)
|
|
540
|
+
- `'token'` = Exact token amount
|
|
541
|
+
|
|
542
|
+
### Token Filtering
|
|
543
|
+
- `tokenName` = Exact match (faster)
|
|
544
|
+
- `search` = Fuzzy match (discovery)
|
|
545
|
+
|
|
546
|
+
### Address Format
|
|
547
|
+
- API expects: `'eth|abc123...'`
|
|
548
|
+
- Convert from: `'0xabc123...'`
|
|
549
|
+
|
|
550
|
+
---
|
|
551
|
+
|
|
552
|
+
**For more details, see:**
|
|
553
|
+
- [MCP Server README](../README.md)
|
|
554
|
+
- [SDK Documentation](../../sdk/README.md)
|
|
555
|
+
- [Constraints Reference](./CONSTRAINTS-REFERENCE.md)
|