@lumagg/sdk
v0.2.0
Published
TypeScript SDK for LumAgg Stellar DEX Aggregator API
Readme
@lumagg/sdk
TypeScript client for the LumAgg REST API — quote, build unsigned XDR, wallet helpers, submit + poll.
Install
npm install @lumagg/sdk
# or link locally during development:
cd packages/sdk && npm run buildQuick start (< 30 min)
import { LumAggClient } from '@lumagg/sdk';
const client = new LumAggClient({ apiUrl: 'https://api.lumagg.xyz' });
const quote = await client.quote({
tokenIn: 'CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA', // XLM
tokenOut: 'CCW67TSZV3SSS2HXMBQ5JFGCKJNXKZM7UQUWUZPUTHXSTZLEO7SJMI75', // USDC
amountIn: '1000000000', // 100 XLM stroops
slippage: 0.5,
});
const { unsignedTxXdr } = await client.buildTx({
userPublicKey: 'G...',
tokenIn: quote.tokenIn,
tokenOut: quote.tokenOut,
amountIn: quote.amountIn,
minAmountOut: quote.minimumOutput,
subRoutes: quote.subRoutes,
});
// Sign with Freighter / wallet, then:
// const { hash } = await client.submitTx({ signedTxXdr });
// await client.waitForTx(hash);API
| Method | REST | Description |
|--------|------|-------------|
| isHealthy() | GET /health | Liveness |
| listTokens() | GET /tokens | Routable tokens + logos |
| quote() | GET /quote | Best route; optional preferSoroban |
| buildTx() | POST /build_tx | Unsigned envelope XDR |
| quoteAndBuild() | quote + build_tx | One-call integrator flow |
| getBalance() | GET /balance | SAC balance + hasTrustline |
| getBalances() | GET /balances | Common-token batch |
| getAccount() | GET /account | Sequence number |
| getClassicAsset() | GET /classic_asset | SAC → code/issuer |
| getLatestLedger() | GET /ledger/latest | Latest ledger sequence |
| submitTx() | POST /submit_tx | Fast enqueue signed XDR |
| getTxStatus() | GET /tx_status | One-shot status |
| waitForTx() | polls /tx_status | Until SUCCESS / FAILED / timeout |
| getStats() | GET /stats | On-chain indexer rollup; optional CSV |
| listSwaps() / orders / prices | see OpenAPI | |
Partner rate limit: pass apiKey in constructor → X-API-Key header (60 req/s).
Examples
npx tsx packages/sdk/examples/basic-usage.ts
npx tsx packages/sdk/examples/quote-build.ts
npx tsx packages/sdk/examples/stats.ts
# Freighter browser demo (sign + optional submit):
cd packages/sdk/examples/browser-swap && npm install && npm run devDocs
License
Apache-2.0
