Class: GSwap
Main entry point for the current GalaChainDex SDK: one client bundling the services that read
and write through the swap backend (quoting, swaps, pools, positions, assets,
market, leaderboard, onramper, symbols, fees, stream). See GSwapOptions for
configuration.
Constructors
Constructor
new GSwap(
options?):GSwap
Create an SDK client for prod (the default) or stage, or for a dexBackendBaseUrl of your own.
Parameters
| Parameter | Type |
|---|---|
options? | GSwapOptions |
Returns
GSwap
Example
const gSwap = new GSwap({ env: 'stage' });
const symbols = await gSwap.symbols.list();
dex backend base url swap options
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
assets | readonly | Assets | User token balances. |
chainCallTimeoutMs | readonly | number | The request timeout in milliseconds (default 30 000; Infinity arms no timer). |
dexBackendBaseUrl | readonly | string | The swap backend base URL every request goes to, without a trailing slash. |
dexBackendWsUrl | readonly | string | The realtime stream endpoint GSwap.stream connects to. |
fees | readonly | DexFees | Network-fee quotes (DryRun) signed with this client's signer. |
gateway | readonly | ChainGateway | The chain-gateway client every other service reads and writes through. |
leaderboard | readonly | Leaderboard | Trading-competition seasons and rankings. |
market | readonly | Market | USD prices, price series and the platform volume totals. |
onramper | readonly | Onramper | The Onramper (fiat on-ramp) widget URL. |
pools | readonly | Pools | Pool, slot0 and composite-pool reads. |
positions | readonly | Positions | Position reads, liquidity estimates and liquidity / pool-creation writes. |
quoting | readonly | Quoting | Read-only exact-input and exact-output quotes. |
signer | readonly | GalaChainSigner | undefined | The signer given at construction, if any. |
swaps | readonly | Swaps | Queued swaps (RequestTrade), dark swaps and swap confirmation. |
symbols | readonly | Symbols | The trading-symbol registry. |
walletAddress | readonly | string | undefined | The account given at construction, if any, in the gateway's spelling (eth|<EIP-55>; client|<id> as given). |
chain call timeout ms dex backend base url ws fees gateway gala signer request trade wallet address
Accessors
stream
Get Signature
get stream():
GdexStreamService
The realtime stream client for this environment (created on first use, not connected until you
call connect()).
Example
const gSwap = new GSwap({ env: 'stage' });
await gSwap.stream.connect();
await gSwap.stream.subscribeLiquidity((event) => console.log(event.action, event.amount0));
Returns
gdex stream service