Skip to main content

Class: CanonicalSymbols

gSwap SDK 2.0.0-rc.4


gSwap SDK 2.0.0-rc.4 / CanonicalSymbols

Class: CanonicalSymbols

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

The offline resolver for apps that already hold the backend's canonical trading symbols (from /quote, /add-liq-estimate, a position row) and must not make a registry request of their own.

  • resolve accepts a bare trading symbol and returns it as is; a class key (object, $ or | form) is not a symbol and is refused as UNKNOWN_TOKEN. createPool relies on that refusal to fall back to the symbols its caller supplies.
  • orderPair orders two symbols by plain string comparison, as the contract does.
  • Reads are pass-through (see TokenResolver.passthrough): the caller's references go on the wire verbatim, composite keys included, and the backend orients the pair.

Example​

const swaps = new Swaps(gateway, new CanonicalSymbols(), signer, walletAddress);
await swaps.swap('GALA', 'GUSDC', 3000, { exactIn: '10' });

Implements​

Constructors​

Constructor​

new CanonicalSymbols(): CanonicalSymbols

Returns​

CanonicalSymbols

Properties​

passthrough​

readonly passthrough: true = true

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

True when reads send the caller's token references verbatim (a symbol, or a composite key as the caller wrote it) and let the backend resolve and orient the pair — no registry request and no client-side ordering or tick flip.

Implementation of​

TokenResolver.passthrough

Methods​

invalidate()​

invalidate(): void

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

There is no registry state to drop.

Returns​

void


orderPair()​

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

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

Put two symbols in canonical (string) order.

Parameters​

a​

TokenRef

b​

TokenRef

Returns​

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


resolve()​

resolve(ref): Promise<TradingSymbol>

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

Resolve a bare trading symbol to itself.

Parameters​

ref​

TokenRef

Returns​

Promise<TradingSymbol>

Implementation of​

TokenResolver.resolve