@gala-chain/gswap-sdk 2.0.0-rc.0 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/dist/browser/classes/gswap.js +1 -1
- package/dist/browser/classes/gswap.js.map +1 -1
- package/dist/browser/classes/onramper.js +2 -0
- package/dist/browser/classes/onramper.js.map +1 -0
- package/dist/browser/index.js +1 -1
- package/dist/index.cjs +145 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -1
- package/dist/index.d.ts +102 -1
- package/dist/index.mjs +143 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Gateway. Swap requests are queued for later application.
|
|
|
11
11
|
npm install @gala-chain/gswap-sdk@next @gala-chain/gala-core-sdk@next
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
`@gala-chain/gala-core-sdk` is a peer dependency (range `>=1.0.0-rc.
|
|
14
|
+
`@gala-chain/gala-core-sdk` is a peer dependency (range `>=1.0.0-rc.6 <2`):
|
|
15
15
|
install it next to the SDK. 2.0 is a release candidate under the `next`
|
|
16
16
|
dist-tag; `latest` is still 1.2.0, so an install without `@next` gets 1.x.
|
|
17
17
|
Pin exact versions for a wallet or app build.
|
|
@@ -73,6 +73,19 @@ const series = await gSwap.market.getPriceSeries('GALA$Unit$none$none', '1W');
|
|
|
73
73
|
const season = await gSwap.leaderboard.getCurrentSeason(); // null between seasons
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
## Onramper widget URL
|
|
77
|
+
|
|
78
|
+
`gSwap.onramper.generateWidgetUrl(request)` asks the swap backend for a signed Onramper (fiat
|
|
79
|
+
on-ramp) widget URL. The route is public: the request carries no `Authorization` header. An app that
|
|
80
|
+
needs only this builds the small service without a whole client:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { createOnramper } from '@gala-chain/gswap-sdk';
|
|
84
|
+
|
|
85
|
+
const onramper = createOnramper({ dexBackendBaseUrl: 'https://dex-backend-prod1.defi.gala.com' });
|
|
86
|
+
const url = await onramper.generateWidgetUrl({ walletAddress: '0x…', defaultCrypto: 'gala', mode: 'buy' });
|
|
87
|
+
```
|
|
88
|
+
|
|
76
89
|
## Hosts and environment presets
|
|
77
90
|
|
|
78
91
|
The SDK has one network boundary: the swap backend. It does not call public
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.js";import{Assets as t}from"./assets.js";import{DexFees as n}from"./dex_fees.js";import{ChainGateway as r}from"./gateway.js";import{GSWAP_ENVIRONMENTS as i}from"../types/env.js";import{GdexStreamService as a}from"./gdex_stream.js";import{HttpClient as o}from"./http_client.js";import{Leaderboard as s}from"./leaderboard.js";import{Market as c}from"./market.js";import{CanonicalSymbols as
|
|
1
|
+
import e from"../_virtual/_@oxc-project_runtime@0.153.0/helpers/esm/defineProperty.js";import{Assets as t}from"./assets.js";import{DexFees as n}from"./dex_fees.js";import{ChainGateway as r}from"./gateway.js";import{GSWAP_ENVIRONMENTS as i}from"../types/env.js";import{GdexStreamService as a}from"./gdex_stream.js";import{HttpClient as o}from"./http_client.js";import{Leaderboard as s}from"./leaderboard.js";import{Market as c}from"./market.js";import{Onramper as l}from"./onramper.js";import{CanonicalSymbols as u,Symbols as d}from"./symbols.js";import{Pools as f}from"./pools.js";import{Positions as p}from"./positions.js";import{Quoting as m}from"./quoting.js";import{Swaps as h}from"./swaps.js";var g=class{constructor(a){e(this,`dexBackendBaseUrl`,void 0),e(this,`chainCallTimeoutMs`,void 0),e(this,`signer`,void 0),e(this,`walletAddress`,void 0),e(this,`gateway`,void 0),e(this,`symbols`,void 0),e(this,`quoting`,void 0),e(this,`pools`,void 0),e(this,`positions`,void 0),e(this,`swaps`,void 0),e(this,`assets`,void 0),e(this,`market`,void 0),e(this,`leaderboard`,void 0),e(this,`onramper`,void 0),e(this,`fees`,void 0),e(this,`dexBackendWsUrl`,void 0),e(this,`webSocketImpl`,void 0),e(this,`streamApiKey`,void 0),e(this,`streamClient`,void 0);let g=i[a?.env??`prod`];this.dexBackendBaseUrl=_(a?.dexBackendBaseUrl??g.dexBackendBaseUrl),this.chainCallTimeoutMs=a?.chainCallTimeoutMs??3e4,this.signer=a?.signer,this.walletAddress=a?.walletAddress;let v=new o(a?.httpRequestor,this.chainCallTimeoutMs,a?.wire);this.gateway=new r({dexBackendBaseUrl:this.dexBackendBaseUrl,chainCallTimeoutMs:this.chainCallTimeoutMs,...a?.wire===void 0?{}:{wire:a.wire},...a?.httpRequestor===void 0?{}:{httpRequestor:a.httpRequestor},...this.walletAddress===void 0?{}:{walletAddress:this.walletAddress}});let y={onInvalidEntry:a?.onInvalidEntry};this.symbols=new d(this.gateway,y);let b=a?.symbolResolution===`canonical`?new u:this.symbols;this.quoting=new m(this.gateway,b),this.pools=new f(this.gateway,b,y);let x={uniqueKeyPrefix:a?.uniqueKeyPrefix,...y};this.positions=new p(this.gateway,b,this.signer,this.walletAddress,x),this.swaps=new h(this.gateway,b,this.signer,this.walletAddress,x),this.assets=new t(this.dexBackendBaseUrl,v),this.market=new c(this.dexBackendBaseUrl,v,y),this.leaderboard=new s(this.dexBackendBaseUrl,v,y),this.onramper=new l(this.dexBackendBaseUrl,v),this.fees=new n(this.gateway,this.signer),this.dexBackendWsUrl=a?.dexBackendWsUrl??(a?.dexBackendBaseUrl===void 0?g.dexBackendWsUrl:`${this.dexBackendBaseUrl.replace(/^http/u,`ws`)}/ws`),this.webSocketImpl=a?.webSocketImpl,this.streamApiKey=a?.streamApiKey}get stream(){return this.streamClient??(this.streamClient=new a({url:this.dexBackendWsUrl,...this.webSocketImpl===void 0?{}:{webSocketImpl:this.webSocketImpl},...this.streamApiKey===void 0?{}:{apiKey:this.streamApiKey}})),this.streamClient}};function _(e){return e.replace(/\/$/u,``)}export{g as GSwap};
|
|
2
2
|
//# sourceMappingURL=gswap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gswap.js","names":["_defineProperty","GSwap","environment","GSWAP_ENVIRONMENTS","options","trimTrailingSlash","httpClient","HttpClient","ChainGateway","lenient","Symbols","resolver","CanonicalSymbols","Quoting","Pools","keyOptions","Positions","Swaps","Assets","Market","Leaderboard","DexFees","GdexStreamService","value"],"sources":["../../../src/classes/gswap.ts"],"sourcesContent":["import { Assets } from './assets.js';\nimport { DexFees } from './dex_fees.js';\nimport { ChainGateway } from './gateway.js';\nimport { GdexStreamService } from './gdex_stream.js';\nimport { HttpClient } from './http_client.js';\nimport { Leaderboard } from './leaderboard.js';\nimport { Market } from './market.js';\nimport { Pools } from './pools.js';\nimport { Positions } from './positions.js';\nimport { Quoting } from './quoting.js';\nimport type { GalaChainSigner, HttpRequestor, WireOptions } from '@gala-chain/gala-core-sdk';\nimport { CanonicalSymbols, Symbols } from './symbols.js';\nimport type { InvalidEntryHandler } from '../utils/lenient.js';\nimport { Swaps } from './swaps.js';\nimport type { GSwapEnv } from '../types/env.js';\nimport { GSWAP_ENVIRONMENTS } from '../types/env.js';\n\n/** Options for constructing a backend-routed SDK client. */\nexport interface GSwapOptions {\n /** Signs every write. Without one, reads work and any write throws `NO_SIGNER`. */\n signer?: GalaChainSigner | undefined;\n /**\n * The selected account, sent as `X-Wallet-Address` on writes (attribution only; the chain\n * recovers the signer from the signature). Required for shadow writes.\n */\n walletAddress?: string | undefined;\n /** `'stage'` or `'prod'` swap backend preset; defaults to `'prod'`. */\n env?: GSwapEnv | undefined;\n /** Overrides the preset's swap backend base URL (a test or private deployment). */\n dexBackendBaseUrl?: string | undefined;\n /** HTTP transport for every request; defaults to the global `fetch`. */\n httpRequestor?: HttpRequestor | undefined;\n /** Request timeout in milliseconds (default 30 000); `Infinity` arms no timer. */\n chainCallTimeoutMs?: number | undefined;\n /** Query encoding and `User-Agent` of the read requests (see {@link WireOptions}). */\n wire?: WireOptions | undefined;\n /**\n * How tokens are turned into trading symbols. `'registry'` (default) reads the symbol registry\n * once (`GET /v2/trade/symbols`, cached) and accepts symbols or class keys. `'canonical'` makes\n * no registry request: the caller passes the backend's canonical trading symbols (from a quote,\n * an estimate or a position), reads send tokens and ticks exactly as given (composite keys\n * included) and the backend orients the pair; see {@link CanonicalSymbols}.\n */\n symbolResolution?: 'registry' | 'canonical' | undefined;\n /**\n * Told about every row of a pool, symbol, position, price, price-series, season or leaderboard\n * answer that was skipped as unusable (see {@link InvalidEntryHandler}); without it such rows are\n * skipped silently.\n */\n onInvalidEntry?: InvalidEntryHandler | undefined;\n /** Realtime stream endpoint. Defaults to the environment's, or is derived from `dexBackendBaseUrl`. */\n dexBackendWsUrl?: string | undefined;\n /** WebSocket constructor for the realtime stream; required on Node.js older than 22. */\n webSocketImpl?: unknown;\n /**\n * `x-api-key` for the privileged stream view; server-side only, and it requires `webSocketImpl`\n * (see `GdexStreamConfig.apiKey`).\n */\n streamApiKey?: string | undefined;\n /**\n * Prefix of every write's `uniqueKey` (`<prefix><uuid>`). Defaults to `galaswap-operation-`,\n * what frontend_v2 and wallet_extension send; defi-backend does not depend on it.\n */\n uniqueKeyPrefix?: string | undefined;\n}\n\n/**\n * Main entry point for the current GalaChainDex SDK: one client bundling the services that read\n * and write through the swap backend (`quoting`, `swaps`, `pools`, `positions`, `assets`,\n * `market`, `leaderboard`, `symbols`, `fees`, `stream`). See {@link GSwapOptions} for\n * configuration.\n */\nexport class GSwap {\n /** The swap backend base URL every request goes to, without a trailing slash. */\n public readonly dexBackendBaseUrl: string;\n /** The request timeout in milliseconds (default 30 000; `Infinity` arms no timer). */\n public readonly chainCallTimeoutMs: number;\n /** The signer given at construction, if any. */\n public readonly signer: GalaChainSigner | undefined;\n /** The account given at construction, if any. */\n public readonly walletAddress: string | undefined;\n /** The chain-gateway client every other service reads and writes through. */\n public readonly gateway: ChainGateway;\n /** The trading-symbol registry. */\n public readonly symbols: Symbols;\n /** Read-only exact-input and exact-output quotes. */\n public readonly quoting: Quoting;\n /** Pool, slot0 and composite-pool reads. */\n public readonly pools: Pools;\n /** Position reads, liquidity estimates and liquidity / pool-creation writes. */\n public readonly positions: Positions;\n /** Queued swaps (`RequestTrade`), dark swaps and swap confirmation. */\n public readonly swaps: Swaps;\n /** User token balances. */\n public readonly assets: Assets;\n /** USD prices, price series and the platform volume totals. */\n public readonly market: Market;\n /** Trading-competition seasons and rankings. */\n public readonly leaderboard: Leaderboard;\n /** Network-fee quotes (DryRun) signed with this client's signer. */\n public readonly fees: DexFees;\n /** The realtime stream endpoint {@link GSwap.stream} connects to. */\n public readonly dexBackendWsUrl: string;\n private readonly webSocketImpl: unknown;\n private readonly streamApiKey: string | undefined;\n private streamClient: GdexStreamService | undefined;\n\n /**\n * Create an SDK client for prod (the default) or stage, or for a `dexBackendBaseUrl` of your own.\n *\n * @example\n * ```typescript\n * const gSwap = new GSwap({ env: 'stage' });\n * const symbols = await gSwap.symbols.list();\n * ```\n */\n constructor(options?: GSwapOptions) {\n const environment = GSWAP_ENVIRONMENTS[options?.env ?? 'prod'];\n this.dexBackendBaseUrl = trimTrailingSlash(\n options?.dexBackendBaseUrl ?? environment.dexBackendBaseUrl,\n );\n this.chainCallTimeoutMs = options?.chainCallTimeoutMs ?? 30_000;\n this.signer = options?.signer;\n this.walletAddress = options?.walletAddress;\n\n const httpClient = new HttpClient(\n options?.httpRequestor,\n this.chainCallTimeoutMs,\n options?.wire,\n );\n this.gateway = new ChainGateway({\n dexBackendBaseUrl: this.dexBackendBaseUrl,\n chainCallTimeoutMs: this.chainCallTimeoutMs,\n ...(options?.wire === undefined ? {} : { wire: options.wire }),\n ...(options?.httpRequestor === undefined ? {} : { httpRequestor: options.httpRequestor }),\n ...(this.walletAddress === undefined ? {} : { walletAddress: this.walletAddress }),\n });\n const lenient = { onInvalidEntry: options?.onInvalidEntry };\n this.symbols = new Symbols(this.gateway, lenient);\n // The services resolve tokens through the registry by default; the offline resolver sends the\n // caller's canonical symbols and keys as they are and never reads the registry.\n const resolver =\n options?.symbolResolution === 'canonical' ? new CanonicalSymbols() : this.symbols;\n this.quoting = new Quoting(this.gateway, resolver);\n this.pools = new Pools(this.gateway, resolver, lenient);\n const keyOptions = { uniqueKeyPrefix: options?.uniqueKeyPrefix, ...lenient };\n this.positions = new Positions(\n this.gateway,\n resolver,\n this.signer,\n this.walletAddress,\n keyOptions,\n );\n this.swaps = new Swaps(this.gateway, resolver, this.signer, this.walletAddress, keyOptions);\n this.assets = new Assets(this.dexBackendBaseUrl, httpClient);\n this.market = new Market(this.dexBackendBaseUrl, httpClient, lenient);\n this.leaderboard = new Leaderboard(this.dexBackendBaseUrl, httpClient, lenient);\n this.fees = new DexFees(this.gateway, this.signer);\n this.dexBackendWsUrl =\n options?.dexBackendWsUrl ??\n (options?.dexBackendBaseUrl === undefined\n ? environment.dexBackendWsUrl\n : `${this.dexBackendBaseUrl.replace(/^http/u, 'ws')}/ws`);\n this.webSocketImpl = options?.webSocketImpl;\n this.streamApiKey = options?.streamApiKey;\n }\n\n /**\n * The realtime stream client for this environment (created on first use, not connected until you\n * call `connect()`).\n *\n * @example\n * ```typescript\n * const gSwap = new GSwap({ env: 'stage' });\n * await gSwap.stream.connect();\n * await gSwap.stream.subscribeLiquidity((event) => console.log(event.action, event.amount0));\n * ```\n */\n get stream(): GdexStreamService {\n this.streamClient ??= new GdexStreamService({\n url: this.dexBackendWsUrl,\n ...(this.webSocketImpl === undefined ? {} : { webSocketImpl: this.webSocketImpl }),\n ...(this.streamApiKey === undefined ? {} : { apiKey: this.streamApiKey }),\n });\n return this.streamClient;\n }\n}\n\nfunction trimTrailingSlash(value: string): string {\n return value.replace(/\\/$/u, '');\n}\n"],"mappings":"ipBAwEA,IAAaC,EAAb,KAAmB,CA4CjB,YAAY,EAAwB,CA1CpBD,EAAA,KAAA,oBAAA,IAAA,EAAA,EAEAA,EAAA,KAAA,qBAAA,IAAA,EAAA,EAEAA,EAAA,KAAA,SAAA,IAAA,EAAA,EAEAA,EAAA,KAAA,gBAAA,IAAA,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IAAIQ,EAAqB,KAAK,QAC5E,KAAK,QAAU,IAAIC,EAAQ,KAAK,QAASF,CAAQ,EACjD,KAAK,MAAQ,IAAIG,EAAM,KAAK,QAASH,EAAUF,CAAO,EACtD,IAAMM,EAAa,CAAE,gBAAiBX,GAAS,gBAAiB,GAAGK,CAAQ,EAC3E,KAAK,UAAY,IAAIO,EACnB,KAAK,QACLL,EACA,KAAK,OACL,KAAK,cACLI,CACF,EACA,KAAK,MAAQ,IAAIE,EAAM,KAAK,QAASN,EAAU,KAAK,OAAQ,KAAK,cAAeI,CAAU,EAC1F,KAAK,OAAS,IAAIG,EAAO,KAAK,kBAAmBZ,CAAU,EAC3D,KAAK,OAAS,IAAIa,EAAO,KAAK,kBAAmBb,EAAYG,CAAO,EACpE,KAAK,YAAc,IAAIW,EAAY,KAAK,kBAAmBd,EAAYG,CAAO,EAC9E,KAAK,KAAO,IAAIY,EAAQ,KAAK,QAAS,KAAK,MAAM,EACjD,KAAK,gBACHjB,GAAS,kBACRA,GAAS,oBAAsB,IAAA,GAC5BF,EAAY,gBACZ,GAAG,KAAK,kBAAkB,QAAQ,SAAU,IAAI,EAAE,MACxD,KAAK,cAAgBE,GAAS,cAC9B,KAAK,aAAeA,GAAS,YAC/B,CAaA,IAAI,QAA4B,CAM9B,OALA,KAAK,eAAL,KAAK,aAAiB,IAAIkB,EAAkB,CAC1C,IAAK,KAAK,gBACV,GAAI,KAAK,gBAAkB,IAAA,GAAY,CAAC,EAAI,CAAE,cAAe,KAAK,aAAc,EAChF,GAAI,KAAK,eAAiB,IAAA,GAAY,CAAC,EAAI,CAAE,OAAQ,KAAK,YAAa,CACzE,CAAC,GACM,KAAK,YACd,CACF,EAEA,SAASjB,EAAkB,EAAuB,CAChD,OAAOkB,EAAM,QAAQ,OAAQ,EAAE,CACjC"}
|
|
1
|
+
{"version":3,"file":"gswap.js","names":["_defineProperty","GSwap","environment","GSWAP_ENVIRONMENTS","options","trimTrailingSlash","httpClient","HttpClient","ChainGateway","lenient","Symbols","resolver","CanonicalSymbols","Quoting","Pools","keyOptions","Positions","Swaps","Assets","Market","Leaderboard","Onramper","DexFees","GdexStreamService","value"],"sources":["../../../src/classes/gswap.ts"],"sourcesContent":["import { Assets } from './assets.js';\nimport { DexFees } from './dex_fees.js';\nimport { ChainGateway } from './gateway.js';\nimport { GdexStreamService } from './gdex_stream.js';\nimport { HttpClient } from './http_client.js';\nimport { Leaderboard } from './leaderboard.js';\nimport { Market } from './market.js';\nimport { Onramper } from './onramper.js';\nimport { Pools } from './pools.js';\nimport { Positions } from './positions.js';\nimport { Quoting } from './quoting.js';\nimport type { GalaChainSigner, HttpRequestor, WireOptions } from '@gala-chain/gala-core-sdk';\nimport { CanonicalSymbols, Symbols } from './symbols.js';\nimport type { InvalidEntryHandler } from '../utils/lenient.js';\nimport { Swaps } from './swaps.js';\nimport type { GSwapEnv } from '../types/env.js';\nimport { GSWAP_ENVIRONMENTS } from '../types/env.js';\n\n/** Options for constructing a backend-routed SDK client. */\nexport interface GSwapOptions {\n /** Signs every write. Without one, reads work and any write throws `NO_SIGNER`. */\n signer?: GalaChainSigner | undefined;\n /**\n * The selected account, sent as `X-Wallet-Address` on writes (attribution only; the chain\n * recovers the signer from the signature). Required for shadow writes.\n */\n walletAddress?: string | undefined;\n /** `'stage'` or `'prod'` swap backend preset; defaults to `'prod'`. */\n env?: GSwapEnv | undefined;\n /** Overrides the preset's swap backend base URL (a test or private deployment). */\n dexBackendBaseUrl?: string | undefined;\n /** HTTP transport for every request; defaults to the global `fetch`. */\n httpRequestor?: HttpRequestor | undefined;\n /** Request timeout in milliseconds (default 30 000); `Infinity` arms no timer. */\n chainCallTimeoutMs?: number | undefined;\n /** Query encoding and `User-Agent` of the read requests (see {@link WireOptions}). */\n wire?: WireOptions | undefined;\n /**\n * How tokens are turned into trading symbols. `'registry'` (default) reads the symbol registry\n * once (`GET /v2/trade/symbols`, cached) and accepts symbols or class keys. `'canonical'` makes\n * no registry request: the caller passes the backend's canonical trading symbols (from a quote,\n * an estimate or a position), reads send tokens and ticks exactly as given (composite keys\n * included) and the backend orients the pair; see {@link CanonicalSymbols}.\n */\n symbolResolution?: 'registry' | 'canonical' | undefined;\n /**\n * Told about every row of a pool, symbol, position, price, price-series, season or leaderboard\n * answer that was skipped as unusable (see {@link InvalidEntryHandler}); without it such rows are\n * skipped silently.\n */\n onInvalidEntry?: InvalidEntryHandler | undefined;\n /** Realtime stream endpoint. Defaults to the environment's, or is derived from `dexBackendBaseUrl`. */\n dexBackendWsUrl?: string | undefined;\n /** WebSocket constructor for the realtime stream; required on Node.js older than 22. */\n webSocketImpl?: unknown;\n /**\n * `x-api-key` for the privileged stream view; server-side only, and it requires `webSocketImpl`\n * (see `GdexStreamConfig.apiKey`).\n */\n streamApiKey?: string | undefined;\n /**\n * Prefix of every write's `uniqueKey` (`<prefix><uuid>`). Defaults to `galaswap-operation-`,\n * what frontend_v2 and wallet_extension send; defi-backend does not depend on it.\n */\n uniqueKeyPrefix?: string | undefined;\n}\n\n/**\n * Main entry point for the current GalaChainDex SDK: one client bundling the services that read\n * and write through the swap backend (`quoting`, `swaps`, `pools`, `positions`, `assets`,\n * `market`, `leaderboard`, `onramper`, `symbols`, `fees`, `stream`). See {@link GSwapOptions} for\n * configuration.\n */\nexport class GSwap {\n /** The swap backend base URL every request goes to, without a trailing slash. */\n public readonly dexBackendBaseUrl: string;\n /** The request timeout in milliseconds (default 30 000; `Infinity` arms no timer). */\n public readonly chainCallTimeoutMs: number;\n /** The signer given at construction, if any. */\n public readonly signer: GalaChainSigner | undefined;\n /** The account given at construction, if any. */\n public readonly walletAddress: string | undefined;\n /** The chain-gateway client every other service reads and writes through. */\n public readonly gateway: ChainGateway;\n /** The trading-symbol registry. */\n public readonly symbols: Symbols;\n /** Read-only exact-input and exact-output quotes. */\n public readonly quoting: Quoting;\n /** Pool, slot0 and composite-pool reads. */\n public readonly pools: Pools;\n /** Position reads, liquidity estimates and liquidity / pool-creation writes. */\n public readonly positions: Positions;\n /** Queued swaps (`RequestTrade`), dark swaps and swap confirmation. */\n public readonly swaps: Swaps;\n /** User token balances. */\n public readonly assets: Assets;\n /** USD prices, price series and the platform volume totals. */\n public readonly market: Market;\n /** Trading-competition seasons and rankings. */\n public readonly leaderboard: Leaderboard;\n /** The Onramper (fiat on-ramp) widget URL. */\n public readonly onramper: Onramper;\n /** Network-fee quotes (DryRun) signed with this client's signer. */\n public readonly fees: DexFees;\n /** The realtime stream endpoint {@link GSwap.stream} connects to. */\n public readonly dexBackendWsUrl: string;\n private readonly webSocketImpl: unknown;\n private readonly streamApiKey: string | undefined;\n private streamClient: GdexStreamService | undefined;\n\n /**\n * Create an SDK client for prod (the default) or stage, or for a `dexBackendBaseUrl` of your own.\n *\n * @example\n * ```typescript\n * const gSwap = new GSwap({ env: 'stage' });\n * const symbols = await gSwap.symbols.list();\n * ```\n */\n constructor(options?: GSwapOptions) {\n const environment = GSWAP_ENVIRONMENTS[options?.env ?? 'prod'];\n this.dexBackendBaseUrl = trimTrailingSlash(\n options?.dexBackendBaseUrl ?? environment.dexBackendBaseUrl,\n );\n this.chainCallTimeoutMs = options?.chainCallTimeoutMs ?? 30_000;\n this.signer = options?.signer;\n this.walletAddress = options?.walletAddress;\n\n const httpClient = new HttpClient(\n options?.httpRequestor,\n this.chainCallTimeoutMs,\n options?.wire,\n );\n this.gateway = new ChainGateway({\n dexBackendBaseUrl: this.dexBackendBaseUrl,\n chainCallTimeoutMs: this.chainCallTimeoutMs,\n ...(options?.wire === undefined ? {} : { wire: options.wire }),\n ...(options?.httpRequestor === undefined ? {} : { httpRequestor: options.httpRequestor }),\n ...(this.walletAddress === undefined ? {} : { walletAddress: this.walletAddress }),\n });\n const lenient = { onInvalidEntry: options?.onInvalidEntry };\n this.symbols = new Symbols(this.gateway, lenient);\n // The services resolve tokens through the registry by default; the offline resolver sends the\n // caller's canonical symbols and keys as they are and never reads the registry.\n const resolver =\n options?.symbolResolution === 'canonical' ? new CanonicalSymbols() : this.symbols;\n this.quoting = new Quoting(this.gateway, resolver);\n this.pools = new Pools(this.gateway, resolver, lenient);\n const keyOptions = { uniqueKeyPrefix: options?.uniqueKeyPrefix, ...lenient };\n this.positions = new Positions(\n this.gateway,\n resolver,\n this.signer,\n this.walletAddress,\n keyOptions,\n );\n this.swaps = new Swaps(this.gateway, resolver, this.signer, this.walletAddress, keyOptions);\n this.assets = new Assets(this.dexBackendBaseUrl, httpClient);\n this.market = new Market(this.dexBackendBaseUrl, httpClient, lenient);\n this.leaderboard = new Leaderboard(this.dexBackendBaseUrl, httpClient, lenient);\n this.onramper = new Onramper(this.dexBackendBaseUrl, httpClient);\n this.fees = new DexFees(this.gateway, this.signer);\n this.dexBackendWsUrl =\n options?.dexBackendWsUrl ??\n (options?.dexBackendBaseUrl === undefined\n ? environment.dexBackendWsUrl\n : `${this.dexBackendBaseUrl.replace(/^http/u, 'ws')}/ws`);\n this.webSocketImpl = options?.webSocketImpl;\n this.streamApiKey = options?.streamApiKey;\n }\n\n /**\n * The realtime stream client for this environment (created on first use, not connected until you\n * call `connect()`).\n *\n * @example\n * ```typescript\n * const gSwap = new GSwap({ env: 'stage' });\n * await gSwap.stream.connect();\n * await gSwap.stream.subscribeLiquidity((event) => console.log(event.action, event.amount0));\n * ```\n */\n get stream(): GdexStreamService {\n this.streamClient ??= new GdexStreamService({\n url: this.dexBackendWsUrl,\n ...(this.webSocketImpl === undefined ? {} : { webSocketImpl: this.webSocketImpl }),\n ...(this.streamApiKey === undefined ? {} : { apiKey: this.streamApiKey }),\n });\n return this.streamClient;\n }\n}\n\nfunction trimTrailingSlash(value: string): string {\n return value.replace(/\\/$/u, '');\n}\n"],"mappings":"0rBAyEA,IAAaC,EAAb,KAAmB,CA8CjB,YAAY,EAAwB,CA5CpBD,EAAA,KAAA,oBAAA,IAAA,EAAA,EAEAA,EAAA,KAAA,qBAAA,IAAA,EAAA,EAEAA,EAAA,KAAA,SAAA,IAAA,EAAA,EAEAA,EAAA,KAAA,gBAAA,IAAA,EAAA,EAEA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
1
|
+
import{GSwapSDKError as e}from"./gswap_sdk_error.js";import{HttpClient as t}from"./http_client.js";import{asEntryRecord as n}from"../utils/lenient.js";const r=[`buy`,`sell`,`swap`],i=[`defaultFiat`,`onlyCryptoNetworks`,`defaultPaymentMethod`,`defaultCrypto`,`onlyPaymentMethods`,`excludePaymentMethods`,`onlyFiat`,`excludeFiat`,`isAddressEditable`,`networkPrefix`],a=[`defaultAmount`,`sellDefaultAmount`];function o(t,n){return new e(`INVALID_DTO`,{method:`onramper.generateWidgetUrl`,field:t,expected:n})}function s(e){if(typeof e!=`object`||!e)throw o(`request`,`an object`);if(typeof e.walletAddress!=`string`||e.walletAddress.trim()===``)throw o(`walletAddress`,`a non-empty string`);let t={walletAddress:e.walletAddress};if(e.mode!==void 0){if(!r.includes(e.mode))throw o(`mode`,r.join(`, `));t.mode=e.mode}for(let n of i){let r=e[n];if(r!==void 0){if(typeof r!=`string`)throw o(n,`a string`);t[n]=r}}for(let n of a){let r=e[n];if(r!==void 0){if(typeof r!=`number`||!Number.isFinite(r)||r<0)throw o(n,`a finite number, 0 or more`);t[n]=r}}return t}function c(t){let r=n(n(t)?.data)?.url;if(typeof r==`string`&&r!==``)try{return new URL(r),r}catch{}throw new e(`INVALID_CHAIN_RESPONSE`,{resource:`onramper widget url`},{body:t,write:!1})}var l=class{constructor(e,t){this.dexBackendBaseUrl=e,this.httpClient=t}async generateWidgetUrl(e){let t=s(e);return c(await this.httpClient.sendPostRequest(this.dexBackendBaseUrl,`/api/v1/onramper`,`/generate-widget-url`,t))}};function u(e){return new l(e.dexBackendBaseUrl.replace(/\/$/u,``),new t(e.httpRequestor,e.timeoutMs,e.wire))}export{r as ONRAMPER_MODES,l as Onramper,u as createOnramper};
|
|
2
|
+
//# sourceMappingURL=onramper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onramper.js","names":["ONRAMPER_MODES","TEXT_FIELDS","AMOUNT_FIELDS","invalidField","GSwapSDKError","widgetBody","request","body","\"mode\"","field","value","widgetUrlOf","url","asEntryRecord","response","\"data\"","\"url\"","Onramper","dexBackendBaseUrl","httpClient","createOnramper","options","HttpClient"],"sources":["../../../src/classes/onramper.ts"],"sourcesContent":["import type { HttpRequestor, WireOptions } from '@gala-chain/gala-core-sdk';\nimport { asEntryRecord } from '../utils/lenient.js';\nimport { GSwapSDKError } from './gswap_sdk_error.js';\nimport { HttpClient } from './http_client.js';\n\n/** What the Onramper widget does. */\nexport const ONRAMPER_MODES = ['buy', 'sell', 'swap'] as const;\n\n/** One of {@link ONRAMPER_MODES}. */\nexport type OnramperMode = (typeof ONRAMPER_MODES)[number];\n\n/**\n * The request of {@link Onramper.generateWidgetUrl}: the fields of the swap backend's\n * `GenerateWidgetUrlDto`, no others (the backend refuses a field it does not know). A field left\n * out is the backend's default (`mode` `buy`, `defaultFiat` `USD`, `defaultAmount` 100,\n * `sellDefaultAmount` 1, `onlyCryptoNetworks` `gala`, `defaultPaymentMethod` `creditcard`,\n * `networkPrefix` `gala_gala`).\n */\nexport interface OnramperWidgetRequest {\n /** The wallet that receives the crypto, sent as given (the backend wants an `0x` Ethereum address). */\n walletAddress: string;\n mode?: OnramperMode | undefined;\n defaultFiat?: string | undefined;\n /** The fiat amount the widget opens with (the backend accepts 15 to 15 000, at most 2 decimals). */\n defaultAmount?: number | undefined;\n /** The crypto amount a sell opens with (0.000001 to 1 000 000, at most 18 decimals). */\n sellDefaultAmount?: number | undefined;\n onlyCryptoNetworks?: string | undefined;\n defaultPaymentMethod?: string | undefined;\n defaultCrypto?: string | undefined;\n onlyPaymentMethods?: string | undefined;\n excludePaymentMethods?: string | undefined;\n onlyFiat?: string | undefined;\n excludeFiat?: string | undefined;\n isAddressEditable?: string | undefined;\n networkPrefix?: string | undefined;\n}\n\n/** The request fields that are text, besides `walletAddress` and `mode`. */\nconst TEXT_FIELDS = [\n 'defaultFiat',\n 'onlyCryptoNetworks',\n 'defaultPaymentMethod',\n 'defaultCrypto',\n 'onlyPaymentMethods',\n 'excludePaymentMethods',\n 'onlyFiat',\n 'excludeFiat',\n 'isAddressEditable',\n 'networkPrefix',\n] as const;\n\n/** The request fields that are amounts. */\nconst AMOUNT_FIELDS = ['defaultAmount', 'sellDefaultAmount'] as const;\n\nconst METHOD = 'onramper.generateWidgetUrl';\n\nfunction invalidField(field: string, expected: string): GSwapSDKError {\n return new GSwapSDKError('INVALID_DTO', { method: METHOD, field, expected });\n}\n\n/**\n * The body to send: the fields the caller gave, checked. A field left out (or `undefined`) is not\n * sent, so the backend's default applies. An amount that is not a finite number is refused here:\n * `JSON.stringify` would turn `NaN` into `null`, which the backend reads as \"not given\" and\n * silently replaces with its default amount.\n */\nfunction widgetBody(request: OnramperWidgetRequest): Record<string, string | number> {\n if (typeof request !== 'object' || request === null) {\n throw invalidField('request', 'an object');\n }\n if (typeof request.walletAddress !== 'string' || request.walletAddress.trim() === '') {\n throw invalidField('walletAddress', 'a non-empty string');\n }\n const body: Record<string, string | number> = { walletAddress: request.walletAddress };\n if (request.mode !== undefined) {\n if (!(ONRAMPER_MODES as readonly unknown[]).includes(request.mode)) {\n throw invalidField('mode', ONRAMPER_MODES.join(', '));\n }\n body['mode'] = request.mode;\n }\n for (const field of TEXT_FIELDS) {\n const value: unknown = request[field];\n if (value === undefined) continue;\n if (typeof value !== 'string') throw invalidField(field, 'a string');\n body[field] = value;\n }\n for (const field of AMOUNT_FIELDS) {\n const value: unknown = request[field];\n if (value === undefined) continue;\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0) {\n throw invalidField(field, 'a finite number, 0 or more');\n }\n body[field] = value;\n }\n return body;\n}\n\n/** The widget URL of the backend's `{ status, error, message, data: { url } }` answer. */\nfunction widgetUrlOf(response: unknown): string {\n const data = asEntryRecord(asEntryRecord(response)?.['data']);\n const url = data?.['url'];\n if (typeof url === 'string' && url !== '') {\n try {\n // Only to know it is an absolute URL; the backend's text is returned as it is.\n void new URL(url);\n return url;\n } catch {\n // Falls through to the invalid-answer error below.\n }\n }\n throw new GSwapSDKError(\n 'INVALID_CHAIN_RESPONSE',\n { resource: 'onramper widget url' },\n { body: response, write: false },\n );\n}\n\n/**\n * The swap backend's Onramper (fiat on-ramp) widget URL. The route is PUBLIC: the request carries\n * no `Authorization` header and no signature, whatever session the app has, so no token can leak to\n * it. The backend signs the wallet into the URL; the app adds its own look (theme query parameters)\n * to the returned URL.\n */\nexport class Onramper {\n /**\n * Creates the service. To get one without building a whole {@link GSwap} client, use\n * {@link createOnramper}.\n *\n * @example\n * ```ts\n * const onramper = new Onramper('https://dex-backend-prod1.defi.gala.com', httpClient);\n * ```\n */\n constructor(\n private readonly dexBackendBaseUrl: string,\n private readonly httpClient: HttpClient,\n ) {}\n\n /**\n * Asks the backend for a signed Onramper widget URL for `request.walletAddress`.\n *\n * @returns The widget URL.\n * @throws GSwapSDKError `INVALID_DTO` (before anything is sent: no wallet address, an unknown\n * `mode`, a text field that is not text, an amount that is not a finite number of 0 or more),\n * `HTTP_ERROR` (the backend refused: `serverMessage` is its message, e.g. \"Failed to generate\n * widget URL. Check server configuration.\" for a 500, its validation message for a 400, the\n * throttle for a 429), `REQUEST_FAILED` (no answer), `INVALID_CHAIN_RESPONSE` (an answer without\n * a usable `data.url`).\n *\n * @example\n * ```ts\n * const url = await gSwap.onramper.generateWidgetUrl({\n * walletAddress: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',\n * defaultCrypto: 'gala',\n * onlyCryptoNetworks: 'gala',\n * mode: 'buy',\n * });\n * window.open(url);\n * ```\n */\n public async generateWidgetUrl(request: OnramperWidgetRequest): Promise<string> {\n const body = widgetBody(request);\n const response = await this.httpClient.sendPostRequest<unknown>(\n this.dexBackendBaseUrl,\n '/api/v1/onramper',\n '/generate-widget-url',\n body,\n );\n return widgetUrlOf(response);\n }\n}\n\n/** Options of {@link createOnramper}. */\nexport interface OnramperOptions {\n /** The swap backend's base URL (no trailing slash needed). */\n dexBackendBaseUrl: string;\n /** Your own HTTP requestor instead of `fetch`. */\n httpRequestor?: HttpRequestor | undefined;\n /** Request timeout in milliseconds (default 30 000). */\n timeoutMs?: number | undefined;\n /** Query encoding and `User-Agent` of the requests. */\n wire?: WireOptions | undefined;\n}\n\n/**\n * An {@link Onramper} for a swap backend, without building a {@link GSwap} client (no signer, no\n * wallet, no pool or stream services): the call for an app that only needs the widget URL.\n *\n * @example\n * ```ts\n * import { createOnramper } from '@gala-chain/gswap-sdk';\n *\n * const onramper = createOnramper({ dexBackendBaseUrl: 'https://dex-backend-prod1.defi.gala.com' });\n * const url = await onramper.generateWidgetUrl({ walletAddress, mode: 'buy' });\n * ```\n */\nexport function createOnramper(options: OnramperOptions): Onramper {\n return new Onramper(\n options.dexBackendBaseUrl.replace(/\\/$/u, ''),\n new HttpClient(options.httpRequestor, options.timeoutMs, options.wire),\n );\n}\n"],"mappings":"uJAMA,MAAaA,EAAiB,CAAC,MAAO,OAAQ,MAAM,EAiC9CC,EAAc,CAClB,cACA,qBACA,uBACA,gBACA,qBACA,wBACA,WACA,cACA,oBACA,eACF,EAGMC,EAAgB,CAAC,gBAAiB,mBAAmB,EAI3D,SAASC,EAAa,EAAe,EAAiC,CACpE,OAAO,IAAIC,EAAc,cAAe,CAAE,OAAQ,6BAAQ,QAAO,UAAS,CAAC,CAC7E,CAQA,SAASC,EAAW,EAAiE,CACnF,GAAI,OAAOC,GAAY,WAAYA,EACjC,MAAMH,EAAa,UAAW,WAAW,EAE3C,GAAI,OAAOG,EAAQ,eAAkB,UAAYA,EAAQ,cAAc,KAAK,IAAM,GAChF,MAAMH,EAAa,gBAAiB,oBAAoB,EAE1D,IAAMI,EAAwC,CAAE,cAAeD,EAAQ,aAAc,EACrF,GAAIA,EAAQ,OAAS,IAAA,GAAW,CAC9B,GAAI,CAAEN,EAAsC,SAASM,EAAQ,IAAI,EAC/D,MAAMH,EAAa,OAAQH,EAAe,KAAK,IAAI,CAAC,EAEtD,EAAKQ,KAAUF,EAAQ,IACzB,CACA,IAAK,IAAMG,KAASR,EAAa,CAC/B,IAA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as n}from"./classes/gswap_error_catalog.js";import{GSWAP_ERROR_PHASE_BY_CODE as r}from"./classes/gswap_error_phase_table.js";import{GSwapSDKError as i,UPDATE_REQUIRED_STATUS as a,getObjectProperty as o,getStringProperty as s,isGSwapError as c,isPreSendError as l}from"./classes/gswap_sdk_error.js";import{AppliedTradeError as u,confirmAppliedTrade as d}from"./classes/apply_results.js";import{ALL_FEE_TIERS as f,FEE_TIER as p,TICK_SPACING_BY_FEE as m}from"./types/fees.js";import{isTickInRange as h}from"./utils/tick_range.js";import{GC_MAX_TICK as g,GC_MIN_TICK as _,isSqrtPriceInRange as v,sqrtPriceToTick as y,tickFromPrice as b,tickToPrice as x,tickToSqrtPrice as S}from"./utils/tick_math.js";import{assertCanonicalPair as C,isProposableTradingSymbol as w,validateFee as T,validateNumericAmount as E,validatePriceValues as D,validateTickRange as O,validateTickSpacing as k,validateTokenDecimals as A,validateWalletAddress as j}from"./utils/validation.js";import{Assets as M}from"./classes/assets.js";import{DEX_FEE_METHODS as N,DRY_RUN_METHOD as P,DRY_RUN_UNIQUE_KEY_PREFIX as F,DexFees as I,buildDryRunWrapper as L,isCurrentContractDexMessage as R,isDexFeeMethod as z,toChainDto as B}from"./classes/dex_fees.js";import{isShadowError as V}from"./utils/shadow_errors.js";import{SubmittedTransaction as H}from"./classes/submitted_transaction.js";import{ChainGateway as U}from"./classes/gateway.js";import{GSWAP_ENVIRONMENTS as W}from"./types/env.js";import{GdexStreamError as G,GdexStreamService as K,isGdexLiquidityEvent as q}from"./classes/gdex_stream.js";import{Leaderboard as J}from"./classes/leaderboard.js";import{MARKET_PRICE_BATCH_LIMIT as Y,PRICE_SERIES_TIMEFRAMES as X}from"./types/market.js";import{MARKET_PRICE_QUERY_BYTES as Z,Market as Q,priceBatches as $}from"./classes/market.js";import{
|
|
1
|
+
import{GSWAP_ERROR_CATALOG as e,SUBMISSION_OUTCOME_UNKNOWN_REASONS as t,gswapErrorTemplates as n}from"./classes/gswap_error_catalog.js";import{GSWAP_ERROR_PHASE_BY_CODE as r}from"./classes/gswap_error_phase_table.js";import{GSwapSDKError as i,UPDATE_REQUIRED_STATUS as a,getObjectProperty as o,getStringProperty as s,isGSwapError as c,isPreSendError as l}from"./classes/gswap_sdk_error.js";import{AppliedTradeError as u,confirmAppliedTrade as d}from"./classes/apply_results.js";import{ALL_FEE_TIERS as f,FEE_TIER as p,TICK_SPACING_BY_FEE as m}from"./types/fees.js";import{isTickInRange as h}from"./utils/tick_range.js";import{GC_MAX_TICK as g,GC_MIN_TICK as _,isSqrtPriceInRange as v,sqrtPriceToTick as y,tickFromPrice as b,tickToPrice as x,tickToSqrtPrice as S}from"./utils/tick_math.js";import{assertCanonicalPair as C,isProposableTradingSymbol as w,validateFee as T,validateNumericAmount as E,validatePriceValues as D,validateTickRange as O,validateTickSpacing as k,validateTokenDecimals as A,validateWalletAddress as j}from"./utils/validation.js";import{Assets as M}from"./classes/assets.js";import{DEX_FEE_METHODS as N,DRY_RUN_METHOD as P,DRY_RUN_UNIQUE_KEY_PREFIX as F,DexFees as I,buildDryRunWrapper as L,isCurrentContractDexMessage as R,isDexFeeMethod as z,toChainDto as B}from"./classes/dex_fees.js";import{isShadowError as V}from"./utils/shadow_errors.js";import{SubmittedTransaction as H}from"./classes/submitted_transaction.js";import{ChainGateway as U}from"./classes/gateway.js";import{GSWAP_ENVIRONMENTS as W}from"./types/env.js";import{GdexStreamError as G,GdexStreamService as K,isGdexLiquidityEvent as q}from"./classes/gdex_stream.js";import{Leaderboard as J}from"./classes/leaderboard.js";import{MARKET_PRICE_BATCH_LIMIT as Y,PRICE_SERIES_TIMEFRAMES as X}from"./types/market.js";import{MARKET_PRICE_QUERY_BYTES as Z,Market as Q,priceBatches as $}from"./classes/market.js";import{ONRAMPER_MODES as ee,Onramper as te,createOnramper as ne}from"./classes/onramper.js";import{orderSymbols as re,parseTokenClassKey as ie,readOrderedSymbols as ae}from"./utils/ordering.js";import{CanonicalSymbols as oe,Symbols as se,queryTokenOf as ce,rawTokenOf as le,tradingSymbolOf as ue}from"./classes/symbols.js";import{Pools as de}from"./classes/pools.js";import{alignTickDownOrNaN as fe,alignTickUpOrNaN as pe}from"./utils/tick_align.js";import{alignTickDown as me,alignTickUp as he,assertTickRange as ge,frameSlot0 as _e}from"./utils/ticks.js";import{assertCanonicalV2Dto as ve,buildAddLiquidityDto as ye,buildCollectPositionFeesDto as be,buildCreatePoolDto as xe,buildRemoveLiquidityDto as Se,buildRequestTradeDto as Ce}from"./utils/dto_builders.js";import{Positions as we}from"./classes/positions.js";import{Quoting as Te}from"./classes/quoting.js";import{SHADOW_FAILURE_KINDS as Ee,SHADOW_SUBMIT_CODES as De,classifyShadowSubmitError as Oe,classifyShadowSubmitStatus as ke,readShadowSubmitOutcome as Ae}from"./classes/shadow_submit.js";import{Swaps as je,swapRouteFromQuote as Me}from"./classes/swaps.js";import{GSwap as Ne}from"./classes/gswap.js";import{NOT_QUEUED_FINAL as Pe,classification as Fe,notSentClassification as Ie}from"./utils/classification.js";import{classifyFailure as Le,mayHaveBeenQueued as Re}from"./utils/failure_classification.js";import{PENDING_SWAP_FATES as ze,pendingSwapFateFor as Be,pendingSwapFateOfOutcome as Ve}from"./classes/pending_swap_fate.js";import{PENDING_SWAPS_STORAGE_KEY as He,PENDING_SWAP_EXPIRY_MS as Ue,PENDING_SWAP_PRUNE_REASONS as We,PendingSwapStore as Ge}from"./classes/pending_swaps.js";import{storageAdapterFromChromeStorage as Ke,webStorageAdapter as qe}from"./classes/storage_adapters.js";import{confirmationStateOf as Je,isConfirmationAborted as Ye,isConfirmationTimeout as Xe}from"./utils/confirmation_state.js";import{chainErrorKeyOf as Ze,isNoMarket as Qe,isRelayableRefusal as $e,isUninterpretedAnswer as et,isUniqueKeyConsumed as tt,isUnprovenAcknowledgement as nt}from"./utils/failure_guards.js";import{classifySubmitEnvelope as rt,isSubmitExecuted as it,isSubmitQueued as at,isSubmitRejected as ot}from"./utils/submit_state.js";export{f as ALL_FEE_TIERS,u as AppliedTradeError,M as Assets,oe as CanonicalSymbols,U as ChainGateway,N as DEX_FEE_METHODS,P as DRY_RUN_METHOD,F as DRY_RUN_UNIQUE_KEY_PREFIX,I as DexFees,p as FEE_TIER,g as GC_MAX_TICK,_ as GC_MIN_TICK,W as GSWAP_ENVIRONMENTS,e as GSWAP_ERROR_CATALOG,r as GSWAP_ERROR_PHASE_BY_CODE,Ne as GSwap,i as GSwapSDKError,G as GdexStreamError,K as GdexStreamService,J as Leaderboard,Y as MARKET_PRICE_BATCH_LIMIT,Z as MARKET_PRICE_QUERY_BYTES,Q as Market,Pe as NOT_QUEUED_FINAL,ee as ONRAMPER_MODES,te as Onramper,He as PENDING_SWAPS_STORAGE_KEY,Ue as PENDING_SWAP_EXPIRY_MS,ze as PENDING_SWAP_FATES,We as PENDING_SWAP_PRUNE_REASONS,X as PRICE_SERIES_TIMEFRAMES,Ge as PendingSwapStore,de as Pools,we as Positions,Te as Quoting,Ee as SHADOW_FAILURE_KINDS,De as SHADOW_SUBMIT_CODES,t as SUBMISSION_OUTCOME_UNKNOWN_REASONS,H as SubmittedTransaction,je as Swaps,se as Symbols,m as TICK_SPACING_BY_FEE,a as UPDATE_REQUIRED_STATUS,me as alignTickDown,fe as alignTickDownOrNaN,he as alignTickUp,pe as alignTickUpOrNaN,C as assertCanonicalPair,ve as assertCanonicalV2Dto,ge as assertTickRange,ye as buildAddLiquidityDto,be as buildCollectPositionFeesDto,xe as buildCreatePoolDto,L as buildDryRunWrapper,Se as buildRemoveLiquidityDto,Ce as buildRequestTradeDto,Ze as chainErrorKeyOf,Fe as classification,Le as classifyFailure,Oe as classifyShadowSubmitError,ke as classifyShadowSubmitStatus,rt as classifySubmitEnvelope,d as confirmAppliedTrade,Je as confirmationStateOf,ne as createOnramper,_e as frameSlot0,o as getObjectProperty,s as getStringProperty,n as gswapErrorTemplates,Ye as isConfirmationAborted,Xe as isConfirmationTimeout,R as isCurrentContractDexMessage,z as isDexFeeMethod,c as isGSwapError,q as isGdexLiquidityEvent,Qe as isNoMarket,l as isPreSendError,w as isProposableTradingSymbol,$e as isRelayableRefusal,V as isShadowError,v as isSqrtPriceInRange,it as isSubmitExecuted,at as isSubmitQueued,ot as isSubmitRejected,h as isTickInRange,et as isUninterpretedAnswer,tt as isUniqueKeyConsumed,nt as isUnprovenAcknowledgement,Re as mayHaveBeenQueued,Ie as notSentClassification,re as orderSymbols,ie as parseTokenClassKey,Be as pendingSwapFateFor,Ve as pendingSwapFateOfOutcome,$ as priceBatches,ce as queryTokenOf,le as rawTokenOf,ae as readOrderedSymbols,Ae as readShadowSubmitOutcome,y as sqrtPriceToTick,Ke as storageAdapterFromChromeStorage,Me as swapRouteFromQuote,b as tickFromPrice,x as tickToPrice,S as tickToSqrtPrice,B as toChainDto,ue as tradingSymbolOf,T as validateFee,E as validateNumericAmount,D as validatePriceValues,O as validateTickRange,k as validateTickSpacing,A as validateTokenDecimals,j as validateWalletAddress,qe as webStorageAdapter};
|
package/dist/index.cjs
CHANGED
|
@@ -3331,6 +3331,144 @@ function parseVolumeSummary(data) {
|
|
|
3331
3331
|
return summary;
|
|
3332
3332
|
}
|
|
3333
3333
|
|
|
3334
|
+
//#endregion
|
|
3335
|
+
//#region src/classes/onramper.ts
|
|
3336
|
+
/** What the Onramper widget does. */
|
|
3337
|
+
const ONRAMPER_MODES = [
|
|
3338
|
+
"buy",
|
|
3339
|
+
"sell",
|
|
3340
|
+
"swap"
|
|
3341
|
+
];
|
|
3342
|
+
/** The request fields that are text, besides `walletAddress` and `mode`. */
|
|
3343
|
+
const TEXT_FIELDS = [
|
|
3344
|
+
"defaultFiat",
|
|
3345
|
+
"onlyCryptoNetworks",
|
|
3346
|
+
"defaultPaymentMethod",
|
|
3347
|
+
"defaultCrypto",
|
|
3348
|
+
"onlyPaymentMethods",
|
|
3349
|
+
"excludePaymentMethods",
|
|
3350
|
+
"onlyFiat",
|
|
3351
|
+
"excludeFiat",
|
|
3352
|
+
"isAddressEditable",
|
|
3353
|
+
"networkPrefix"
|
|
3354
|
+
];
|
|
3355
|
+
/** The request fields that are amounts. */
|
|
3356
|
+
const AMOUNT_FIELDS = ["defaultAmount", "sellDefaultAmount"];
|
|
3357
|
+
const METHOD = "onramper.generateWidgetUrl";
|
|
3358
|
+
function invalidField(field, expected) {
|
|
3359
|
+
return new GSwapSDKError("INVALID_DTO", {
|
|
3360
|
+
method: METHOD,
|
|
3361
|
+
field,
|
|
3362
|
+
expected
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
/**
|
|
3366
|
+
* The body to send: the fields the caller gave, checked. A field left out (or `undefined`) is not
|
|
3367
|
+
* sent, so the backend's default applies. An amount that is not a finite number is refused here:
|
|
3368
|
+
* `JSON.stringify` would turn `NaN` into `null`, which the backend reads as "not given" and
|
|
3369
|
+
* silently replaces with its default amount.
|
|
3370
|
+
*/
|
|
3371
|
+
function widgetBody(request) {
|
|
3372
|
+
if (typeof request !== "object" || request === null) throw invalidField("request", "an object");
|
|
3373
|
+
if (typeof request.walletAddress !== "string" || request.walletAddress.trim() === "") throw invalidField("walletAddress", "a non-empty string");
|
|
3374
|
+
const body = { walletAddress: request.walletAddress };
|
|
3375
|
+
if (request.mode !== void 0) {
|
|
3376
|
+
if (!ONRAMPER_MODES.includes(request.mode)) throw invalidField("mode", ONRAMPER_MODES.join(", "));
|
|
3377
|
+
body["mode"] = request.mode;
|
|
3378
|
+
}
|
|
3379
|
+
for (const field of TEXT_FIELDS) {
|
|
3380
|
+
const value = request[field];
|
|
3381
|
+
if (value === void 0) continue;
|
|
3382
|
+
if (typeof value !== "string") throw invalidField(field, "a string");
|
|
3383
|
+
body[field] = value;
|
|
3384
|
+
}
|
|
3385
|
+
for (const field of AMOUNT_FIELDS) {
|
|
3386
|
+
const value = request[field];
|
|
3387
|
+
if (value === void 0) continue;
|
|
3388
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) throw invalidField(field, "a finite number, 0 or more");
|
|
3389
|
+
body[field] = value;
|
|
3390
|
+
}
|
|
3391
|
+
return body;
|
|
3392
|
+
}
|
|
3393
|
+
/** The widget URL of the backend's `{ status, error, message, data: { url } }` answer. */
|
|
3394
|
+
function widgetUrlOf(response) {
|
|
3395
|
+
var _asEntryRecord;
|
|
3396
|
+
const data = asEntryRecord((_asEntryRecord = asEntryRecord(response)) === null || _asEntryRecord === void 0 ? void 0 : _asEntryRecord["data"]);
|
|
3397
|
+
const url = data === null || data === void 0 ? void 0 : data["url"];
|
|
3398
|
+
if (typeof url === "string" && url !== "") try {
|
|
3399
|
+
new URL(url);
|
|
3400
|
+
return url;
|
|
3401
|
+
} catch {}
|
|
3402
|
+
throw new GSwapSDKError("INVALID_CHAIN_RESPONSE", { resource: "onramper widget url" }, {
|
|
3403
|
+
body: response,
|
|
3404
|
+
write: false
|
|
3405
|
+
});
|
|
3406
|
+
}
|
|
3407
|
+
/**
|
|
3408
|
+
* The swap backend's Onramper (fiat on-ramp) widget URL. The route is PUBLIC: the request carries
|
|
3409
|
+
* no `Authorization` header and no signature, whatever session the app has, so no token can leak to
|
|
3410
|
+
* it. The backend signs the wallet into the URL; the app adds its own look (theme query parameters)
|
|
3411
|
+
* to the returned URL.
|
|
3412
|
+
*/
|
|
3413
|
+
var Onramper = class {
|
|
3414
|
+
dexBackendBaseUrl;
|
|
3415
|
+
httpClient;
|
|
3416
|
+
/**
|
|
3417
|
+
* Creates the service. To get one without building a whole {@link GSwap} client, use
|
|
3418
|
+
* {@link createOnramper}.
|
|
3419
|
+
*
|
|
3420
|
+
* @example
|
|
3421
|
+
* ```ts
|
|
3422
|
+
* const onramper = new Onramper('https://dex-backend-prod1.defi.gala.com', httpClient);
|
|
3423
|
+
* ```
|
|
3424
|
+
*/
|
|
3425
|
+
constructor(dexBackendBaseUrl, httpClient) {
|
|
3426
|
+
this.dexBackendBaseUrl = dexBackendBaseUrl;
|
|
3427
|
+
this.httpClient = httpClient;
|
|
3428
|
+
}
|
|
3429
|
+
/**
|
|
3430
|
+
* Asks the backend for a signed Onramper widget URL for `request.walletAddress`.
|
|
3431
|
+
*
|
|
3432
|
+
* @returns The widget URL.
|
|
3433
|
+
* @throws GSwapSDKError `INVALID_DTO` (before anything is sent: no wallet address, an unknown
|
|
3434
|
+
* `mode`, a text field that is not text, an amount that is not a finite number of 0 or more),
|
|
3435
|
+
* `HTTP_ERROR` (the backend refused: `serverMessage` is its message, e.g. "Failed to generate
|
|
3436
|
+
* widget URL. Check server configuration." for a 500, its validation message for a 400, the
|
|
3437
|
+
* throttle for a 429), `REQUEST_FAILED` (no answer), `INVALID_CHAIN_RESPONSE` (an answer without
|
|
3438
|
+
* a usable `data.url`).
|
|
3439
|
+
*
|
|
3440
|
+
* @example
|
|
3441
|
+
* ```ts
|
|
3442
|
+
* const url = await gSwap.onramper.generateWidgetUrl({
|
|
3443
|
+
* walletAddress: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
|
|
3444
|
+
* defaultCrypto: 'gala',
|
|
3445
|
+
* onlyCryptoNetworks: 'gala',
|
|
3446
|
+
* mode: 'buy',
|
|
3447
|
+
* });
|
|
3448
|
+
* window.open(url);
|
|
3449
|
+
* ```
|
|
3450
|
+
*/
|
|
3451
|
+
async generateWidgetUrl(request) {
|
|
3452
|
+
const body = widgetBody(request);
|
|
3453
|
+
return widgetUrlOf(await this.httpClient.sendPostRequest(this.dexBackendBaseUrl, "/api/v1/onramper", "/generate-widget-url", body));
|
|
3454
|
+
}
|
|
3455
|
+
};
|
|
3456
|
+
/**
|
|
3457
|
+
* An {@link Onramper} for a swap backend, without building a {@link GSwap} client (no signer, no
|
|
3458
|
+
* wallet, no pool or stream services): the call for an app that only needs the widget URL.
|
|
3459
|
+
*
|
|
3460
|
+
* @example
|
|
3461
|
+
* ```ts
|
|
3462
|
+
* import { createOnramper } from '@gala-chain/gswap-sdk';
|
|
3463
|
+
*
|
|
3464
|
+
* const onramper = createOnramper({ dexBackendBaseUrl: 'https://dex-backend-prod1.defi.gala.com' });
|
|
3465
|
+
* const url = await onramper.generateWidgetUrl({ walletAddress, mode: 'buy' });
|
|
3466
|
+
* ```
|
|
3467
|
+
*/
|
|
3468
|
+
function createOnramper(options) {
|
|
3469
|
+
return new Onramper(options.dexBackendBaseUrl.replace(/\/$/u, ""), new HttpClient(options.httpRequestor, options.timeoutMs, options.wire));
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3334
3472
|
//#endregion
|
|
3335
3473
|
//#region src/utils/ordering.ts
|
|
3336
3474
|
/** Return two trading symbols in the contract's plain-string order. */
|
|
@@ -5497,7 +5635,7 @@ var Swaps = class {
|
|
|
5497
5635
|
/**
|
|
5498
5636
|
* Main entry point for the current GalaChainDex SDK: one client bundling the services that read
|
|
5499
5637
|
* and write through the swap backend (`quoting`, `swaps`, `pools`, `positions`, `assets`,
|
|
5500
|
-
* `market`, `leaderboard`, `symbols`, `fees`, `stream`). See {@link GSwapOptions} for
|
|
5638
|
+
* `market`, `leaderboard`, `onramper`, `symbols`, `fees`, `stream`). See {@link GSwapOptions} for
|
|
5501
5639
|
* configuration.
|
|
5502
5640
|
*/
|
|
5503
5641
|
var GSwap = class {
|
|
@@ -5527,6 +5665,8 @@ var GSwap = class {
|
|
|
5527
5665
|
market;
|
|
5528
5666
|
/** Trading-competition seasons and rankings. */
|
|
5529
5667
|
leaderboard;
|
|
5668
|
+
/** The Onramper (fiat on-ramp) widget URL. */
|
|
5669
|
+
onramper;
|
|
5530
5670
|
/** Network-fee quotes (DryRun) signed with this client's signer. */
|
|
5531
5671
|
fees;
|
|
5532
5672
|
/** The realtime stream endpoint {@link GSwap.stream} connects to. */
|
|
@@ -5571,6 +5711,7 @@ var GSwap = class {
|
|
|
5571
5711
|
this.assets = new Assets(this.dexBackendBaseUrl, httpClient);
|
|
5572
5712
|
this.market = new Market(this.dexBackendBaseUrl, httpClient, lenient);
|
|
5573
5713
|
this.leaderboard = new Leaderboard(this.dexBackendBaseUrl, httpClient, lenient);
|
|
5714
|
+
this.onramper = new Onramper(this.dexBackendBaseUrl, httpClient);
|
|
5574
5715
|
this.fees = new DexFees(this.gateway, this.signer);
|
|
5575
5716
|
this.dexBackendWsUrl = (options === null || options === void 0 ? void 0 : options.dexBackendWsUrl) ?? ((options === null || options === void 0 ? void 0 : options.dexBackendBaseUrl) === void 0 ? environment.dexBackendWsUrl : `${this.dexBackendBaseUrl.replace(/^http/u, "ws")}/ws`);
|
|
5576
5717
|
this.webSocketImpl = options === null || options === void 0 ? void 0 : options.webSocketImpl;
|
|
@@ -6506,6 +6647,8 @@ exports.MARKET_PRICE_BATCH_LIMIT = MARKET_PRICE_BATCH_LIMIT;
|
|
|
6506
6647
|
exports.MARKET_PRICE_QUERY_BYTES = MARKET_PRICE_QUERY_BYTES;
|
|
6507
6648
|
exports.Market = Market;
|
|
6508
6649
|
exports.NOT_QUEUED_FINAL = NOT_QUEUED_FINAL;
|
|
6650
|
+
exports.ONRAMPER_MODES = ONRAMPER_MODES;
|
|
6651
|
+
exports.Onramper = Onramper;
|
|
6509
6652
|
exports.PENDING_SWAPS_STORAGE_KEY = PENDING_SWAPS_STORAGE_KEY;
|
|
6510
6653
|
exports.PENDING_SWAP_EXPIRY_MS = PENDING_SWAP_EXPIRY_MS;
|
|
6511
6654
|
exports.PENDING_SWAP_FATES = PENDING_SWAP_FATES;
|
|
@@ -6544,6 +6687,7 @@ exports.classifyShadowSubmitStatus = classifyShadowSubmitStatus;
|
|
|
6544
6687
|
exports.classifySubmitEnvelope = classifySubmitEnvelope;
|
|
6545
6688
|
exports.confirmAppliedTrade = confirmAppliedTrade;
|
|
6546
6689
|
exports.confirmationStateOf = confirmationStateOf;
|
|
6690
|
+
exports.createOnramper = createOnramper;
|
|
6547
6691
|
exports.frameSlot0 = frameSlot0;
|
|
6548
6692
|
exports.getObjectProperty = getObjectProperty;
|
|
6549
6693
|
exports.getStringProperty = getStringProperty;
|