gSwap SDK 2.0.0-rc.4
The TypeScript SDK for the GalaChain DEX contract: quoting, queued swaps, liquidity positions, market data and the realtime stream.
This is the moving next documentation of @gala-chain/gswap-sdk (2.0.0-rc.4, dist-tag next), rebuilt from the latest commit.
Install
npm install @gala-chain/gswap-sdk@next
Peer dependencies
| Package | Range |
|---|---|
@gala-chain/gala-core-sdk | >=1.0.0-rc.7 <2 |
At a glance
- Guide and reference pages: 23
- API reference pages: 241
- Public exports: 240
- Documentation built from commit
d9a73068dce0
Pages
Agents
- Agent guide: For an AI agent: which package for which job, task recipes (quote, swap, confirm, add liquidity), the invariants with the test that enforces each, and error codes with their fix.
Guides
- gSwap SDK: What the SDK is and its public surface (quoting, swaps, pools, positions, assets, symbols), how to install it (@next while only release candidates exist), a quick start for quoting and swapping, environment presets and the signers.
- Getting started: Install, construct a GSwap client with a signer, and run a first quote and swap.
- gSwap for Uniswap users: How gSwap's contract and transaction model differ from Uniswap V3 for someone who knows Uniswap.
Tutorial
- Quoting: Quote exact-input and exact-output swaps against live pools and read the fee tier and amounts.
- Trading: Submit a queued swap, keep its unique key, confirm the applied outcome and recover an unknown one.
- Asset balances: Read a user's token balances from the backend's public user-assets endpoint.
- Market data and leaderboard: Prices, price series, platform volume and the trading-competition seasons and rankings, all public reads.
- Liquidity management: Add, adjust, remove and collect fees from liquidity positions, identified by owner, tokens, fee and tick range.
- Realtime stream: Subscribe to live swaps, liquidity events, pool and balance changes over the JSON-RPC websocket stream.
- Transaction status: Read the status of a submitted transaction and interpret the applied or rejected outcome.
Pool concepts
- Slippage: What slippage is and how amountOutMinimum protects a swap from it.
- Price impact: How a trade moves a pool's price and how that differs from slippage.
- Liquidity concentration: How concentrated liquidity in a tick range works in gSwap, based on Uniswap V3.
- Fees: The pool fee tiers, in hundredths of a basis point, that the current contract supports.
Reference
- Error handling: The DEX error catalog: every code, its params, phase and what an app should do; branch on code, never message.
- Signing and identity: How the SDK signs the unsigned DTO, which signer uses which scheme and how the chain resolves identity.
- App and wallet integration: Platform-neutral building blocks for wallets and apps: confirmation polling, pending-swap storage, fee quotes, shadow swaps.
- Tick and price math: The exported tick arithmetic, exact to 60 significant digits, including the contract's in-range rule.
- Branded types: The TypeScript branded types that prevent mixing prices and amounts.
- Bundle size: Keeping an app shell small: the core wallet subpath and the shell-safe helpers.
- Security notes: The production dependency audit and when read logging is safe to enable.
Upgrading
-
Migrating from earlier versions: Upgrading between published versions: 0.x to 1.0, the 1.2.x to 2.0.0 move of signing into gala-core-sdk, and the changes between release candidates.
-
API reference: generated from the package's TSDoc.