Skip to main content

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​

ParameterType
options?GSwapOptions

Returns​

GSwap

Example​

const gSwap = new GSwap({ env: 'stage' });
const symbols = await gSwap.symbols.list();

Properties​

PropertyModifierTypeDescription
assetsreadonlyAssetsUser token balances.
chainCallTimeoutMsreadonlynumberThe request timeout in milliseconds (default 30 000; Infinity arms no timer).
dexBackendBaseUrlreadonlystringThe swap backend base URL every request goes to, without a trailing slash.
dexBackendWsUrlreadonlystringThe realtime stream endpoint GSwap.stream connects to.
feesreadonlyDexFeesNetwork-fee quotes (DryRun) signed with this client's signer.
gatewayreadonlyChainGatewayThe chain-gateway client every other service reads and writes through.
leaderboardreadonlyLeaderboardTrading-competition seasons and rankings.
marketreadonlyMarketUSD prices, price series and the platform volume totals.
onramperreadonlyOnramperThe Onramper (fiat on-ramp) widget URL.
poolsreadonlyPoolsPool, slot0 and composite-pool reads.
positionsreadonlyPositionsPosition reads, liquidity estimates and liquidity / pool-creation writes.
quotingreadonlyQuotingRead-only exact-input and exact-output quotes.
signerreadonlyGalaChainSigner | undefinedThe signer given at construction, if any.
swapsreadonlySwapsQueued swaps (RequestTrade), dark swaps and swap confirmation.
symbolsreadonlySymbolsThe trading-symbol registry.
walletAddressreadonlystring | undefinedThe account given at construction, if any, in the gateway's spelling (eth|<EIP-55>; client|<id> as given).

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​

GdexStreamService