GalaChain Launchpad SDK - GSwap Pool Inspection & Quotes
Installation
npm install @gala-chain/launchpad-sdk@next @gala-chain/gala-core-sdk@next
Setup
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
const sdk = createLaunchpadSDK({
wallet: process.env.PRIVATE_KEY!,
env: 'prod',
});
Pool Inspection + Live Quotes
The DEX is @gala-chain/gswap-sdk's GSwap client (the MCP server's DEX tools build one from the
same key as the launchpad SDK; launchpad-sdk itself has none). gSwap.pools.getCompositePool
returns a raw contract snapshot (pool info, current price, tick liquidity, and positions) for
inspecting a pool. It is not wired into any offline quote calculator — every quote comes from a
live call to gSwap.quoting.
import BigNumber from 'bignumber.js';
import { PrivateKeySigner } from '@gala-chain/gala-core-sdk';
import { GSwap } from '@gala-chain/gswap-sdk';
const gSwap = new GSwap({
env: 'stage',
signer: new PrivateKeySigner(process.env.PRIVATE_KEY!),
walletAddress: sdk.getAddress(), // the launchpad SDK built with the same key
});
// STEP 1: Inspect the pool's current state (one network call)
const composite = await gSwap.pools.getCompositePool(
'GALA|Unit|none|none',
'GUSDC|Unit|none|none',
3000, // 0.30% fee tier
);
console.log('Current price:', composite.currentTradingPrice.price);
// STEP 2: Get a live quote for the amount you actually want to trade (its own network call)
const quote = await gSwap.quoting.quoteExactInput(
'GALA|Unit|none|none',
'GUSDC|Unit|none|none',
'100',
);
console.log('100 GALA ->', quote.amountOut, 'GUSDC');
// STEP 3: Submit the swap — this queues a RequestTrade, then waits for it to apply
const submitted = await gSwap.swaps.swap(
'GALA|Unit|none|none',
'GUSDC|Unit|none|none',
quote.feeTier,
{
exactIn: '100',
amountOutMinimum: new BigNumber(quote.amountOut).times(0.99).toFixed(), // 1% slippage
},
);
const applied = await submitted.confirm();
console.log('Applied transaction:', applied.transactionId);
Multiple Quotes Example
There is no local/offline calculation path off a cached pool snapshot — each amount you want
priced is its own call to quoteExactInput/quoteExactOutput.
const amounts = ['10', '50', '100', '500', '1000', '5000', '10000'];
for (const amount of amounts) {
const quote = await gSwap.quoting.quoteExactInput(
'GALA|Unit|none|none',
'GUSDC|Unit|none|none',
amount,
);
console.log(`${amount} GALA -> ${quote.amountOut} GUSDC`);
}
Recovering a Swap Whose Outcome Is Unknown
If .confirm() times out or a dispatch failure leaves the outcome unclear, resolve the queued
request by its uniqueKey instead of resubmitting — resubmitting a consumed key is unsafe:
const recovered = await gSwap.swaps.confirmSwap(submitted.uniqueKey);
Fee Tiers
| Value | Rate | Use Case |
|---|---|---|
500 | 0.05% | Stable pairs |
3000 | 0.30% | Standard (default) |
10000 | 1.00% | Volatile pairs |
Token Format
Pipe-delimited: collection|category|type|additionalKey
| Token | Format |
|---|---|
| GALA | GALA|Unit|none|none |
| GUSDC | GUSDC|Unit|none|none |