Skip to main content

Class: CanonicalSymbols

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​

PropertyModifierTypeDefault valueDescription
passthroughreadonlytruetrueTrue 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.

Methods​

invalidate()​

invalidate(): void

There is no registry state to drop.

Returns​

void


orderPair()​

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

Put two symbols in canonical (string) order.

Parameters​

ParameterType
aTokenRef
bTokenRef

Returns​

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


resolve()​

resolve(ref): Promise<TradingSymbol>

Resolve a bare trading symbol to itself.

Parameters​

ParameterType
refTokenRef

Returns​

Promise<TradingSymbol>

Implementation of​

TokenResolver.resolve