Skip to main content

Class: GSwap

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / GSwap

Class: GSwap

Defined in: packages/gswap-sdk/dist/index.d.ts:3383

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

Defined in: packages/gswap-sdk/dist/index.d.ts:3431

Create an SDK client for prod (the default) or stage, or for a dexBackendBaseUrl of your own.

Parameters​

options?​

GSwapOptions

Returns​

GSwap

Example​

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

Properties​

assets​

readonly assets: Assets

Defined in: packages/gswap-sdk/dist/index.d.ts:3408

User token balances.


chainCallTimeoutMs​

readonly chainCallTimeoutMs: number

Defined in: packages/gswap-sdk/dist/index.d.ts:3387

The request timeout in milliseconds (default 30 000; Infinity arms no timer).


dexBackendBaseUrl​

readonly dexBackendBaseUrl: string

Defined in: packages/gswap-sdk/dist/index.d.ts:3385

The swap backend base URL every request goes to, without a trailing slash.


dexBackendWsUrl​

readonly dexBackendWsUrl: string

Defined in: packages/gswap-sdk/dist/index.d.ts:3418

The realtime stream endpoint GSwap.stream connects to.


fees​

readonly fees: DexFees

Defined in: packages/gswap-sdk/dist/index.d.ts:3416

Network-fee quotes (DryRun) signed with this client's signer.


gateway​

readonly gateway: ChainGateway

Defined in: packages/gswap-sdk/dist/index.d.ts:3396

The chain-gateway client every other service reads and writes through.


leaderboard​

readonly leaderboard: Leaderboard

Defined in: packages/gswap-sdk/dist/index.d.ts:3412

Trading-competition seasons and rankings.


market​

readonly market: Market

Defined in: packages/gswap-sdk/dist/index.d.ts:3410

USD prices, price series and the platform volume totals.


onramper​

readonly onramper: Onramper

Defined in: packages/gswap-sdk/dist/index.d.ts:3414

The Onramper (fiat on-ramp) widget URL.


pools​

readonly pools: Pools

Defined in: packages/gswap-sdk/dist/index.d.ts:3402

Pool, slot0 and composite-pool reads.


positions​

readonly positions: Positions

Defined in: packages/gswap-sdk/dist/index.d.ts:3404

Position reads, liquidity estimates and liquidity / pool-creation writes.


quoting​

readonly quoting: Quoting

Defined in: packages/gswap-sdk/dist/index.d.ts:3400

Read-only exact-input and exact-output quotes.


signer​

readonly signer: GalaChainSigner | undefined

Defined in: packages/gswap-sdk/dist/index.d.ts:3389

The signer given at construction, if any.


swaps​

readonly swaps: Swaps

Defined in: packages/gswap-sdk/dist/index.d.ts:3406

Queued swaps (RequestTrade), dark swaps and swap confirmation.


symbols​

readonly symbols: Symbols

Defined in: packages/gswap-sdk/dist/index.d.ts:3398

The trading-symbol registry.


walletAddress​

readonly walletAddress: string | undefined

Defined in: packages/gswap-sdk/dist/index.d.ts:3394

The 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

Defined in: packages/gswap-sdk/dist/index.d.ts:3443

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