Skip to main content

Class: Symbols

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / Symbols

Class: Symbols

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

Symbol registry client for the current GalaChainDex contract.

Constructors​

Constructor​

new Symbols(gateway, options?): Symbols

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

Create a symbol service backed by the swap backend. onInvalidEntry is told about every registry row that was skipped as unusable (see InvalidEntryHandler).

Parameters​

gateway​

Pick<ChainGateway, "httpRequestor" | "dexBackendBaseUrl"> & object

options?​
onInvalidEntry?​

InvalidEntryHandler

Returns​

Symbols

Methods​

invalidate()​

invalidate(): void

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

Invalidate the cached symbol registry after a write changes registration state.

Returns​

void

Example​

gSwap.symbols.invalidate();

list()​

list(): Promise<TradingSymbol[]>

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

List all registered GalaChainDex trading symbols, cached for 60 seconds. A registry row that is not a usable symbol is skipped (and reported to onInvalidEntry) instead of failing the whole list.

Returns​

Promise<TradingSymbol[]>


orderPair()​

orderPair(a, b): Promise<{ flipped: boolean; token0: TradingSymbol; token1: TradingSymbol; }>

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

Resolve and put two token references in canonical trading-symbol order.

Parameters​

a​

TokenRef

b​

TokenRef

Returns​

Promise<{ flipped: boolean; token0: TradingSymbol; token1: TradingSymbol; }>


proposeSymbol()​

proposeSymbol(classKey, displaySymbol, options?): Promise<string>

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

The trading symbol to put in a token's first CreatePool.

  1. The symbol ALREADY registered for exactly this class key, if any: proposing another one fails the gateway's registry-conflict check.
  2. Otherwise displaySymbol (the token's curated symbol), when it is proposable (isProposableTradingSymbol).
  3. Otherwise a NO_VALID_TRADING_SYMBOL error: a symbol is never derived from the key (BNB's collection is GBNB, a launchpad token's is the reserved word Token).

registryFailure: 'ignore' treats an unreachable registry as an empty one and falls through to step 2 (the gateway still rejects a conflicting symbol); the default 'throw' propagates the failure.

Parameters​

classKey​

GalaChainTokenClassKey

displaySymbol​

string

options?​
registryFailure?​

"throw" | "ignore"

Returns​

Promise<string>

Example​

const symbol = await gSwap.symbols.proposeSymbol(
{ collection: 'GALA_TEST1', category: 'Unit', type: 'none', additionalKey: 'none' },
'GALATEST',
);

refresh()​

refresh(): Promise<TradingSymbol[]>

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

Force one registry refresh, bypassing the cache.

Returns​

Promise<TradingSymbol[]>

Example​

const symbols = await gSwap.symbols.refresh();

resolve()​

resolve(ref): Promise<TradingSymbol>

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

Resolve a symbol or token class key to its registered symbol metadata.

Parameters​

ref​

TokenRef

Returns​

Promise<TradingSymbol>