@gala-chain/gswap-sdk 1.0.0-rc.3 → 1.0.0

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/dist/index.d.cts CHANGED
@@ -1,330 +1,334 @@
1
- import BigNumber from 'bignumber.js';
2
-
1
+ import BigNumber from "bignumber.js";
2
+ //#region src/types/v2_results.d.ts
3
3
  /** Pool metadata returned by GalaChainDex. */
4
- interface PoolInfo {
5
- token0: string;
6
- token1: string;
7
- fee: number;
8
- name?: string;
9
- token0Key: string;
10
- token1Key: string;
11
- tickSpacing: number;
12
- protocolFees: number;
13
- tradingFees: number;
14
- creator?: string;
15
- isPrivate?: boolean;
16
- flippedFromRequest?: boolean;
4
+ export interface PoolInfo {
5
+ token0: string;
6
+ token1: string;
7
+ fee: number;
8
+ name?: string;
9
+ token0Key: string;
10
+ token1Key: string;
11
+ tickSpacing: number;
12
+ protocolFees: number;
13
+ tradingFees: number;
14
+ creator?: string;
15
+ isPrivate?: boolean;
16
+ flippedFromRequest?: boolean;
17
17
  }
18
18
  /** Pool summary returned by the backend pool-list route. */
19
- interface PoolListInfo {
20
- contractVersion: 'v2';
21
- token0: string;
22
- token1: string;
23
- token0CompositeKey?: string | undefined;
24
- token1CompositeKey?: string | undefined;
25
- fee: number;
26
- poolName: string;
27
- poolRef: string;
28
- tickSpacing: number;
29
- protocolFees: number;
30
- tradingFees: number;
31
- creator?: string | undefined;
32
- price?: string | undefined;
33
- sqrtPrice?: string | undefined;
34
- tick?: number | undefined;
35
- token0Tvl?: string | undefined;
36
- token1Tvl?: string | undefined;
37
- tvlUsd?: number | undefined;
38
- volume1d?: number | undefined;
39
- volume7d?: number | undefined;
40
- volume30d?: number | undefined;
41
- trades1d?: number | undefined;
42
- fee24h?: number | undefined;
43
- apr1d?: number | undefined;
44
- token0Price?: number | undefined;
45
- token1Price?: number | undefined;
19
+ export interface PoolListInfo {
20
+ contractVersion: 'v2';
21
+ token0: string;
22
+ token1: string;
23
+ token0CompositeKey?: string | undefined;
24
+ token1CompositeKey?: string | undefined;
25
+ fee: number;
26
+ poolName: string;
27
+ poolRef: string;
28
+ tickSpacing: number;
29
+ protocolFees: number;
30
+ tradingFees: number;
31
+ creator?: string | undefined;
32
+ price?: string | undefined;
33
+ sqrtPrice?: string | undefined;
34
+ tick?: number | undefined;
35
+ token0Tvl?: string | undefined;
36
+ token1Tvl?: string | undefined;
37
+ tvlUsd?: number | undefined;
38
+ volume1d?: number | undefined;
39
+ volume7d?: number | undefined;
40
+ volume30d?: number | undefined;
41
+ trades1d?: number | undefined;
42
+ fee24h?: number | undefined;
43
+ apr1d?: number | undefined;
44
+ token0Price?: number | undefined;
45
+ token1Price?: number | undefined;
46
46
  }
47
47
  /** Current pool price state. */
48
- interface Slot0 {
49
- token0: string;
50
- token1: string;
51
- fee: number;
52
- price: string;
53
- sqrtPrice: string;
54
- tick: number;
55
- flippedFromRequest?: boolean;
48
+ export interface Slot0 {
49
+ token0: string;
50
+ token1: string;
51
+ fee: number;
52
+ price: string;
53
+ sqrtPrice: string;
54
+ tick: number;
55
+ flippedFromRequest?: boolean;
56
56
  }
57
57
  /** Full raw composite pool snapshot returned by the contract. */
58
- interface CompositePool {
59
- pool: PoolInfo;
60
- currentTradingPrice: Slot0;
61
- initializedTicks?: Array<{
62
- pool: string;
63
- lexigraphicTickIndex: string;
64
- }>;
65
- reverseInitializedTicks?: Array<{
66
- pool: string;
67
- lexigraphicTickIndex: string;
68
- }>;
69
- positionBoundaries?: unknown[];
70
- positions?: Array<{
71
- pool: string;
72
- lexigraphicTickIndexLow: string;
73
- lexigraphicTickIndexHigh: string;
74
- owner: string;
75
- liquidity: string;
76
- }>;
77
- token0TradingSymbol?: {
78
- symbol: string;
79
- decimals: number;
80
- };
81
- token1TradingSymbol?: {
82
- symbol: string;
83
- decimals: number;
84
- };
85
- token0LiquidityBalance?: TokenBalance;
86
- token1LiquidityBalance?: TokenBalance;
87
- token0ProtocolFeesBalance?: TokenBalance;
88
- token1ProtocolFeesBalance?: TokenBalance;
58
+ export interface CompositePool {
59
+ pool: PoolInfo;
60
+ currentTradingPrice: Slot0;
61
+ initializedTicks?: Array<{
62
+ pool: string;
63
+ lexigraphicTickIndex: string;
64
+ }>;
65
+ reverseInitializedTicks?: Array<{
66
+ pool: string;
67
+ lexigraphicTickIndex: string;
68
+ }>;
69
+ positionBoundaries?: unknown[];
70
+ positions?: Array<{
71
+ pool: string;
72
+ lexigraphicTickIndexLow: string;
73
+ lexigraphicTickIndexHigh: string;
74
+ owner: string;
75
+ liquidity: string;
76
+ }>;
77
+ token0TradingSymbol?: {
78
+ symbol: string;
79
+ decimals: number;
80
+ };
81
+ token1TradingSymbol?: {
82
+ symbol: string;
83
+ decimals: number;
84
+ };
85
+ token0LiquidityBalance?: TokenBalance;
86
+ token1LiquidityBalance?: TokenBalance;
87
+ token0ProtocolFeesBalance?: TokenBalance;
88
+ token1ProtocolFeesBalance?: TokenBalance;
89
89
  }
90
90
  /** A token balance embedded in a composite pool result. */
91
- interface TokenBalance {
92
- collection?: string;
93
- category?: string;
94
- type?: string;
95
- additionalKey?: string;
96
- quantity?: string;
97
- owner?: string;
91
+ export interface TokenBalance {
92
+ collection?: string;
93
+ category?: string;
94
+ type?: string;
95
+ additionalKey?: string;
96
+ quantity?: string;
97
+ owner?: string;
98
98
  }
99
99
  /** A normalized current-contract liquidity position. */
100
- interface Position {
101
- pool: string;
102
- token0Symbol: string;
103
- token1Symbol: string;
104
- token0CompositeKey?: string;
105
- token1CompositeKey?: string;
106
- fee: number;
107
- tickLower: number;
108
- tickUpper: number;
109
- owner: string;
110
- liquidity: string;
111
- amount0: string;
112
- amount1: string;
113
- inRange: boolean;
114
- currentTick?: number;
115
- sqrtPrice?: string;
116
- fees0?: string;
117
- fees1?: string;
100
+ export interface Position {
101
+ pool: string;
102
+ token0Symbol: string;
103
+ token1Symbol: string;
104
+ token0CompositeKey?: string;
105
+ token1CompositeKey?: string;
106
+ fee: number;
107
+ tickLower: number;
108
+ tickUpper: number;
109
+ owner: string;
110
+ liquidity: string;
111
+ amount0: string;
112
+ amount1: string;
113
+ inRange: boolean;
114
+ currentTick?: number;
115
+ sqrtPrice?: string;
116
+ fees0?: string;
117
+ fees1?: string;
118
118
  }
119
119
  /** Quote response returned by `/v2/trade/quote`. */
120
- interface QuoteResult {
121
- contractVersion: 'v2';
122
- fee: number;
123
- amountIn: string;
124
- amountOut: string;
125
- currentSqrtPrice?: string;
126
- newSqrtPrice?: string;
127
- newTick: number;
128
- tradingFees: string;
129
- protocolFees: string;
130
- totalFees: string;
131
- feeTokenSymbol: string;
132
- token0Symbol: string;
133
- token1Symbol: string;
134
- tokenInIsToken0: boolean;
135
- feeTier: number;
136
- currentPrice?: BigNumber;
137
- newPrice?: BigNumber;
138
- priceImpact?: BigNumber;
120
+ export interface QuoteResult {
121
+ contractVersion: 'v2';
122
+ fee: number;
123
+ amountIn: string;
124
+ amountOut: string;
125
+ currentSqrtPrice?: string;
126
+ newSqrtPrice?: string;
127
+ newTick: number;
128
+ tradingFees: string;
129
+ protocolFees: string;
130
+ totalFees: string;
131
+ feeTokenSymbol: string;
132
+ token0Symbol: string;
133
+ token1Symbol: string;
134
+ tokenInIsToken0: boolean;
135
+ feeTier: number;
136
+ currentPrice?: BigNumber;
137
+ newPrice?: BigNumber;
138
+ priceImpact?: BigNumber;
139
139
  }
140
140
  /** The executed trade as reported by the ApplyRequests result (contract Trade response). */
141
- interface TradeExecution {
142
- token0: string;
143
- token1: string;
144
- fee: number;
145
- sell0Qty?: string;
146
- sell1Qty?: string;
147
- buy0Qty?: string;
148
- buy1Qty?: string;
149
- tradingFees?: string;
150
- protocolFees?: string;
151
- totalFees?: string;
141
+ export interface TradeExecution {
142
+ token0: string;
143
+ token1: string;
144
+ fee: number;
145
+ sell0Qty?: string;
146
+ sell1Qty?: string;
147
+ buy0Qty?: string;
148
+ buy1Qty?: string;
149
+ tradingFees?: string;
150
+ protocolFees?: string;
151
+ totalFees?: string;
152
152
  }
153
153
  /** Terminal outcome of a queued RequestTrade, read from apply-results. */
154
- interface AppliedTrade {
155
- uniqueKey: string;
156
- /** The ApplyRequests transaction that executed the trade (x-apply-transaction-id), when reported. */
157
- transactionId: string | null;
158
- /** Block of the ApplyRequests transaction (x-apply-block-number), when reported. */
159
- blockNumber: number | null;
160
- /** The RequestTrade transaction that queued it, when the gateway reported one. */
161
- requestTransactionId: string | null;
162
- result: TradeExecution;
154
+ export interface AppliedTrade {
155
+ uniqueKey: string;
156
+ /** The ApplyRequests transaction that executed the trade (x-apply-transaction-id), when reported. */
157
+ transactionId: string | null;
158
+ /** Block of the ApplyRequests transaction (x-apply-block-number), when reported. */
159
+ blockNumber: number | null;
160
+ /** The RequestTrade transaction that queued it, when the gateway reported one. */
161
+ requestTransactionId: string | null;
162
+ result: TradeExecution;
163
163
  }
164
164
  /** A token balance returned by the backend user-assets route. */
165
- interface UserAsset {
166
- image: string;
167
- name: string;
168
- decimals: number;
169
- verify: boolean;
170
- symbol: string;
171
- quantity: string;
165
+ export interface UserAsset {
166
+ image: string;
167
+ name: string;
168
+ decimals: number;
169
+ verify: boolean;
170
+ symbol: string;
171
+ quantity: string;
172
172
  }
173
173
  /** User token balances returned by the backend. */
174
- interface UserAssetsResult {
175
- tokens: UserAsset[];
176
- count: number;
174
+ export interface UserAssetsResult {
175
+ tokens: UserAsset[];
176
+ count: number;
177
177
  }
178
178
  /** Backend add-liquidity estimate. */
179
- interface AddLiquidityEstimate {
180
- amount0: string;
181
- amount1: string;
182
- liquidity: string;
183
- token0Symbol: string;
184
- token1Symbol: string;
185
- tickLower: number;
186
- tickUpper: number;
187
- amountIsCanonicalToken0: boolean;
179
+ export interface AddLiquidityEstimate {
180
+ amount0: string;
181
+ amount1: string;
182
+ liquidity: string;
183
+ token0Symbol: string;
184
+ token1Symbol: string;
185
+ tickLower: number;
186
+ tickUpper: number;
187
+ amountIsCanonicalToken0: boolean;
188
188
  }
189
189
  /** Backend remove-liquidity estimate. */
190
- interface RemoveLiquidityEstimate {
191
- amount0: string;
192
- amount1: string;
190
+ export interface RemoveLiquidityEstimate {
191
+ amount0: string;
192
+ amount1: string;
193
193
  }
194
194
  /** A symbol registry entry returned by FetchTokenTradingSymbols. */
195
- interface TradingSymbol {
196
- symbol: string;
197
- collection: string;
198
- category: string;
199
- type: string;
200
- additionalKey: string;
201
- decimals: number;
195
+ export interface TradingSymbol {
196
+ symbol: string;
197
+ collection: string;
198
+ category: string;
199
+ type: string;
200
+ additionalKey: string;
201
+ decimals: number;
202
202
  }
203
203
  /** Result envelope returned by the chain gateway for a submitted write; queued RequestTrade has no result. */
204
- interface ChainSubmissionResult {
205
- transactionId?: string;
206
- blockNumber?: number | null;
207
- mode: 'sync' | 'queued';
208
- result?: unknown;
209
- uniqueKey?: string;
204
+ export interface ChainSubmissionResult {
205
+ transactionId?: string;
206
+ blockNumber?: number | null;
207
+ mode: 'sync' | 'queued';
208
+ result?: unknown;
209
+ uniqueKey?: string;
210
210
  }
211
-
211
+ //#endregion
212
+ //#region src/types/http_requestor.d.ts
212
213
  type FetchReturnValue = Awaited<ReturnType<typeof fetch>>;
213
214
  interface HTTPResponse {
214
- ok: FetchReturnValue['ok'];
215
- status: FetchReturnValue['status'];
216
- json: FetchReturnValue['json'];
217
- text: FetchReturnValue['text'];
218
- headers?: {
219
- get(name: string): string | null;
220
- } | Record<string, string | undefined>;
215
+ ok: FetchReturnValue['ok'];
216
+ status: FetchReturnValue['status'];
217
+ json: FetchReturnValue['json'];
218
+ text: FetchReturnValue['text'];
219
+ headers?: {
220
+ get(name: string): string | null;
221
+ } | Record<string, string | undefined>;
221
222
  }
222
223
  type HttpRequestor = (uri: string, options?: Parameters<typeof fetch>[1]) => Promise<HTTPResponse>;
223
-
224
+ //#endregion
225
+ //#region src/classes/http_client.d.ts
224
226
  declare class HttpClient {
225
- private readonly httpRequestor;
226
- private readonly timeoutMs;
227
- /** Create an HTTP client around fetch or an injected requestor. */
228
- constructor(httpRequestor?: HttpRequestor, timeoutMs?: number);
229
- private sendRequest;
230
- /** Send a JSON POST request and decode its response. */
231
- sendPostRequest<TReturnType>(baseUrl: string, basePath: string, endpoint: string, body: unknown): Promise<TReturnType>;
232
- /** Send a GET request with URL-encoded query parameters and decode its response. */
233
- sendGetRequest<TReturnType>(baseUrl: string, basePath: string, endpoint: string, params?: Record<string, string>, options?: Pick<RequestInit, 'signal'>): Promise<TReturnType>;
227
+ private readonly httpRequestor;
228
+ private readonly timeoutMs;
229
+ /** Create an HTTP client around fetch or an injected requestor. */
230
+ constructor(httpRequestor?: HttpRequestor, timeoutMs?: number);
231
+ private sendRequest;
232
+ /** Send a JSON POST request and decode its response. */
233
+ sendPostRequest<TReturnType>(baseUrl: string, basePath: string, endpoint: string, body: unknown): Promise<TReturnType>;
234
+ /** Send a GET request with URL-encoded query parameters and decode its response. */
235
+ sendGetRequest<TReturnType>(baseUrl: string, basePath: string, endpoint: string, params?: Record<string, string>, options?: Pick<RequestInit, 'signal'>): Promise<TReturnType>;
234
236
  }
235
-
237
+ //#endregion
238
+ //#region src/classes/assets.d.ts
236
239
  /**
237
240
  * Service for handling user asset operations.
238
241
  * Provides functionality to retrieve user token balances and asset information.
239
242
  */
240
- declare class Assets {
241
- private readonly dexBackendBaseUrl;
242
- private readonly httpClient;
243
- constructor(dexBackendBaseUrl: string, httpClient: HttpClient);
244
- /**
245
- * Gets all token assets owned by a user with their balances.
246
- * @param ownerAddress - The wallet address to get assets for.
247
- * @param page - Page number for pagination (default: 1).
248
- * @param limit - Maximum number of assets to return per page (default: 10).
249
- * @returns User assets including token information and balances.
250
- * @example
251
- * ```typescript
252
- * const assets = await assetsService.getUserAssets('eth|123...abc', 1, 20);
253
- * console.log(`User has ${assets.count} different tokens`);
254
- * assets.tokens.forEach(token => {
255
- * console.log(`${token.symbol}: ${token.quantity}`);
256
- * });
257
- * ```
258
- */
259
- getUserAssets(ownerAddress: string, page?: number, limit?: number): Promise<UserAssetsResult>;
243
+ export declare class Assets {
244
+ private readonly dexBackendBaseUrl;
245
+ private readonly httpClient;
246
+ constructor(dexBackendBaseUrl: string, httpClient: HttpClient);
247
+ /**
248
+ * Gets all token assets owned by a user with their balances.
249
+ * @param ownerAddress - The wallet address to get assets for.
250
+ * @param page - Page number for pagination (default: 1).
251
+ * @param limit - Maximum number of assets to return per page (default: 10).
252
+ * @returns User assets including token information and balances.
253
+ * @example
254
+ * ```typescript
255
+ * const assets = await assetsService.getUserAssets('eth|123...abc', 1, 20);
256
+ * console.log(`User has ${assets.count} different tokens`);
257
+ * assets.tokens.forEach(token => {
258
+ * console.log(`${token.symbol}: ${token.quantity}`);
259
+ * });
260
+ * ```
261
+ */
262
+ getUserAssets(ownerAddress: string, page?: number, limit?: number): Promise<UserAssetsResult>;
260
263
  }
261
-
264
+ //#endregion
265
+ //#region src/classes/submitted_transaction.d.ts
262
266
  /** Result of one position-confirmation poll. */
263
- type PositionConfirmationResult = {
264
- confirmed: true;
265
- position: Position | null;
267
+ export type PositionConfirmationResult = {
268
+ confirmed: true;
269
+ position: Position | null;
266
270
  } | {
267
- confirmed: false;
268
- position?: Position | null;
271
+ confirmed: false;
272
+ position?: Position | null;
269
273
  };
270
274
  /** A submitted v2 transaction whose confirmation mode is explicit in the gateway response. */
271
- declare class SubmittedTransaction<TConfirmation = AppliedTrade | Position | null> {
272
- readonly method: string;
273
- readonly uniqueKey: string;
274
- readonly transactionId: string | null;
275
- readonly blockNumber: number | null;
276
- readonly mode: 'sync' | 'queued';
277
- /** The synchronous gateway result, or `undefined` when `mode === 'queued'`. */
278
- readonly result: unknown;
279
- private readonly backendBaseUrl;
280
- private readonly requestor;
281
- private readonly requestTimeoutMs;
282
- private readonly positionConfirmation;
283
- /** Construct a submitted transaction from a successful gateway response.
284
- *
285
- * @example
286
- * ```ts
287
- * const transaction = new SubmittedTransaction({
288
- * method: 'RequestTrade', mode: 'queued', uniqueKey: 'swap-1',
289
- * transactionId: 'request-tx', result: undefined,
290
- * dexBackendBaseUrl: 'https://dex.example', httpRequestor,
291
- * });
292
- * ```
293
- */
294
- constructor(options: {
295
- method: string;
296
- uniqueKey: string;
297
- transactionId: string | null;
298
- mode: 'sync' | 'queued';
299
- result: unknown;
300
- dexBackendBaseUrl: string;
301
- httpRequestor: HttpRequestor;
302
- blockNumber?: number | null | undefined;
303
- requestTimeoutMs?: number | undefined;
304
- positionConfirmation?: ((signal: AbortSignal) => Promise<PositionConfirmationResult>) | undefined;
305
- });
306
- /** Confirm a queued RequestTrade or prove the affected position for a liquidity write.
307
- *
308
- * For RequestTrade, calling this method is required to learn the outcome: the queued
309
- * acknowledgement proves acceptance, not execution.
310
- *
311
- * @example
312
- * ```ts
313
- * const applied = await submitted.confirm({ initialDelayMs: 3_000 });
314
- * ```
315
- */
316
- confirm(options?: ConfirmOptions): Promise<TConfirmation>;
317
- private confirmApplied;
318
- private readAppliedResult;
319
- /** Confirm a liquidity write against the position's observable effect.
320
- *
321
- * @returns The position after the write, or `null` for a confirmed full close.
322
- * @example
323
- * ```ts
324
- * const position = await submitted.confirm({ timeoutMs: 60_000 });
325
- * ```
326
- */
327
- private confirmPosition;
275
+ export declare class SubmittedTransaction<TConfirmation = AppliedTrade | Position | null> {
276
+ readonly method: string;
277
+ readonly uniqueKey: string;
278
+ readonly transactionId: string | null;
279
+ readonly blockNumber: number | null;
280
+ readonly mode: 'sync' | 'queued';
281
+ /** The synchronous gateway result, or `undefined` when `mode === 'queued'`. */
282
+ readonly result: unknown;
283
+ private readonly backendBaseUrl;
284
+ private readonly requestor;
285
+ private readonly requestTimeoutMs;
286
+ private readonly positionConfirmation;
287
+ /** Construct a submitted transaction from a successful gateway response.
288
+ *
289
+ * @example
290
+ * ```ts
291
+ * const transaction = new SubmittedTransaction({
292
+ * method: 'RequestTrade', mode: 'queued', uniqueKey: 'swap-1',
293
+ * transactionId: 'request-tx', result: undefined,
294
+ * dexBackendBaseUrl: 'https://dex.example', httpRequestor,
295
+ * });
296
+ * ```
297
+ */
298
+ constructor(options: {
299
+ method: string;
300
+ uniqueKey: string;
301
+ transactionId: string | null;
302
+ mode: 'sync' | 'queued';
303
+ result: unknown;
304
+ dexBackendBaseUrl: string;
305
+ httpRequestor: HttpRequestor;
306
+ blockNumber?: number | null | undefined;
307
+ requestTimeoutMs?: number | undefined;
308
+ positionConfirmation?: ((signal: AbortSignal) => Promise<PositionConfirmationResult>) | undefined;
309
+ });
310
+ /** Confirm a queued RequestTrade or prove the affected position for a liquidity write.
311
+ *
312
+ * For RequestTrade, calling this method is required to learn the outcome: the queued
313
+ * acknowledgement proves acceptance, not execution.
314
+ *
315
+ * @example
316
+ * ```ts
317
+ * const applied = await submitted.confirm({ initialDelayMs: 3_000 });
318
+ * ```
319
+ */
320
+ confirm(options?: ConfirmOptions): Promise<TConfirmation>;
321
+ private confirmApplied;
322
+ private readAppliedResult;
323
+ /** Confirm a liquidity write against the position's observable effect.
324
+ *
325
+ * @returns The position after the write, or `null` for a confirmed full close.
326
+ * @example
327
+ * ```ts
328
+ * const position = await submitted.confirm({ timeoutMs: 60_000 });
329
+ * ```
330
+ */
331
+ private confirmPosition;
328
332
  }
329
333
  /**
330
334
  * Controls timeout and polling behavior for confirmation.
@@ -335,69 +339,73 @@ declare class SubmittedTransaction<TConfirmation = AppliedTrade | Position | nul
335
339
  * - `initialDelayMs`: wait before the first read. Defaults to 3 000 for a queued RequestTrade
336
340
  * (the AutoApplier needs a few seconds) and 0 for liquidity writes (already executed).
337
341
  */
338
- interface ConfirmOptions {
339
- timeoutMs?: number | undefined;
340
- pollIntervalMs?: number | undefined;
341
- initialDelayMs?: number | undefined;
342
+ export interface ConfirmOptions {
343
+ timeoutMs?: number | undefined;
344
+ pollIntervalMs?: number | undefined;
345
+ initialDelayMs?: number | undefined;
342
346
  }
343
-
347
+ //#endregion
348
+ //#region src/classes/gateway.d.ts
344
349
  /** Options for a chain-gateway client. */
345
- interface ChainGatewayOptions {
346
- dexBackendBaseUrl: string;
347
- httpRequestor?: HttpRequestor | undefined;
348
- walletAddress?: string | undefined;
349
- chainCallTimeoutMs?: number | undefined;
350
+ export interface ChainGatewayOptions {
351
+ dexBackendBaseUrl: string;
352
+ httpRequestor?: HttpRequestor | undefined;
353
+ walletAddress?: string | undefined;
354
+ chainCallTimeoutMs?: number | undefined;
350
355
  }
351
356
  /** Optional attribution and operation-specific confirmation hooks for a write. */
352
- interface ChainSubmitOptions {
353
- walletAddress?: string | undefined;
354
- positionConfirmation?: ((signal: AbortSignal) => Promise<PositionConfirmationResult>) | undefined;
357
+ export interface ChainSubmitOptions {
358
+ walletAddress?: string | undefined;
359
+ positionConfirmation?: ((signal: AbortSignal) => Promise<PositionConfirmationResult>) | undefined;
355
360
  }
356
361
  /** Thin client for backend-routed v2 writes: synchronous liquidity writes and queued RequestTrade. */
357
- declare class ChainGateway {
358
- private readonly requestor;
359
- private readonly walletAddress;
360
- private readonly chainCallTimeoutMs;
361
- readonly requestTimeoutMs: number;
362
- readonly dexBackendBaseUrl: string;
363
- /** Create a chain gateway client. */
364
- constructor(options: ChainGatewayOptions);
365
- /** Submit a signed v2 DTO through the chain gateway. */
366
- submit(method: 'RequestTrade', signedBody: Record<string, unknown>, options?: ChainSubmitOptions): Promise<SubmittedTransaction<AppliedTrade>>;
367
- submit(method: string, signedBody: Record<string, unknown>, options?: ChainSubmitOptions): Promise<SubmittedTransaction<Position | null>>;
368
- /** Expose the requestor for sibling read services that share this gateway transport. */
369
- get httpRequestor(): HttpRequestor;
362
+ export declare class ChainGateway {
363
+ private readonly requestor;
364
+ private readonly walletAddress;
365
+ private readonly chainCallTimeoutMs;
366
+ readonly requestTimeoutMs: number;
367
+ readonly dexBackendBaseUrl: string;
368
+ /** Create a chain gateway client. */
369
+ constructor(options: ChainGatewayOptions);
370
+ /** Submit a signed v2 DTO through the chain gateway. */
371
+ submit(method: 'RequestTrade', signedBody: Record<string, unknown>, options?: ChainSubmitOptions): Promise<SubmittedTransaction<AppliedTrade>>;
372
+ submit(method: string, signedBody: Record<string, unknown>, options?: ChainSubmitOptions): Promise<SubmittedTransaction<Position | null>>;
373
+ /** Expose the requestor for sibling read services that share this gateway transport. */
374
+ get httpRequestor(): HttpRequestor;
370
375
  }
371
-
376
+ //#endregion
377
+ //#region src/types/fees.d.ts
372
378
  /**
373
379
  * Fee tiers for pools.
374
380
  */
375
- declare enum FEE_TIER {
376
- /** No trading fee. */
377
- PERCENT_00_00 = 0,
378
- /** 0.05% fee tier */
379
- PERCENT_00_05 = 500,
380
- /** 0.3% fee tier */
381
- PERCENT_00_30 = 3000,
382
- /** 1.0% fee tier */
383
- PERCENT_01_00 = 10000
381
+ export declare enum FEE_TIER {
382
+ /** No trading fee. */
383
+ PERCENT_00_00 = 0,
384
+ /** 0.05% fee tier */
385
+ PERCENT_00_05 = 500,
386
+ /** 0.3% fee tier */
387
+ PERCENT_00_30 = 3000,
388
+ /** 1.0% fee tier */
389
+ PERCENT_01_00 = 10000
384
390
  }
385
391
  /** Tick spacing required by the current GalaChainDex contract for each fee tier. */
386
- declare const TICK_SPACING_BY_FEE: Readonly<Record<FEE_TIER, number>>;
392
+ export declare const TICK_SPACING_BY_FEE: Readonly<Record<FEE_TIER, number>>;
387
393
  /** All fee tiers supported by the current GalaChainDex contract. */
388
- declare const ALL_FEE_TIERS: readonly FEE_TIER[];
389
-
390
- interface GalaChainTokenClassKey {
391
- collection: string;
392
- category: string;
393
- type: string;
394
- additionalKey: string;
394
+ export declare const ALL_FEE_TIERS: readonly FEE_TIER[];
395
+ //#endregion
396
+ //#region src/types/token.d.ts
397
+ export interface GalaChainTokenClassKey {
398
+ collection: string;
399
+ category: string;
400
+ type: string;
401
+ additionalKey: string;
395
402
  }
396
-
403
+ //#endregion
404
+ //#region src/utils/ordering.d.ts
397
405
  /** A symbol or a GalaChain token class key accepted by v2 operations. */
398
- type TokenRef = string | GalaChainTokenClassKey;
406
+ export type TokenRef = string | GalaChainTokenClassKey;
399
407
  /** Return two trading symbols in the contract's plain-string order. */
400
- declare function orderSymbols(a: string, b: string): [string, string];
408
+ export declare function orderSymbols(a: string, b: string): [string, string];
401
409
  /** Read an ordered symbol pair from a tuple or object returned by a boundary helper.
402
410
  *
403
411
  * @example
@@ -406,131 +414,147 @@ declare function orderSymbols(a: string, b: string): [string, string];
406
414
  * console.log(pair.token0);
407
415
  * ```
408
416
  */
409
- declare function readOrderedSymbols(value: unknown): {
410
- token0: string;
411
- token1: string;
417
+ export declare function readOrderedSymbols(value: unknown): {
418
+ token0: string;
419
+ token1: string;
412
420
  };
413
421
  /** Return the `$`-joined composite key used by GalaChain object identities. */
414
- declare function compositeKeyOf(token: GalaChainTokenClassKey): string;
415
- /** Parse a pipe- or dollar-separated token class key. */
416
- declare function parseTokenClassKey(tokenClassKey: TokenRef): GalaChainTokenClassKey;
417
-
422
+ export declare function compositeKeyOf(token: GalaChainTokenClassKey): string;
423
+ /**
424
+ * Parse a pipe- or dollar-separated token class key.
425
+ *
426
+ * The LAST three segments are always `category`, `type` and `additionalKey`; everything before
427
+ * them is the `collection`. Parsing from the right is required because real collections contain
428
+ * the `$` delimiter themselves (for example `$GMUSIC`), so a plain left-to-right `split('$')`
429
+ * shifts every field. Nothing here says anything about the token's symbol: a class key carries
430
+ * no symbol, which must come from the token class or trading-symbol registry.
431
+ *
432
+ * @example
433
+ * ```ts
434
+ * parseTokenClassKey('$GMUSIC$Unit$none$none').collection; // '$GMUSIC'
435
+ * ```
436
+ */
437
+ export declare function parseTokenClassKey(tokenClassKey: TokenRef): GalaChainTokenClassKey;
438
+ //#endregion
439
+ //#region src/classes/symbols.d.ts
418
440
  /** Symbol registry client for the current GalaChainDex contract. */
419
- declare class Symbols {
420
- private readonly gateway;
421
- private cachedSymbols;
422
- private cachedAt;
423
- private refreshInFlight;
424
- private readonly http;
425
- /** Create a symbol service backed by the swap backend. */
426
- constructor(gateway: Pick<ChainGateway, 'httpRequestor' | 'dexBackendBaseUrl'> & {
427
- requestTimeoutMs?: number | undefined;
428
- });
429
- /** List all registered GalaChainDex trading symbols, cached for 60 seconds. */
430
- list(): Promise<TradingSymbol[]>;
431
- /** Invalidate the cached symbol registry after a write changes registration state.
432
- *
433
- * @example
434
- * ```ts
435
- * gSwap.symbols.invalidate();
436
- * ```
437
- */
438
- invalidate(): void;
439
- /** Force one registry refresh, bypassing the cache.
440
- *
441
- * @example
442
- * ```ts
443
- * const symbols = await gSwap.symbols.refresh();
444
- * ```
445
- */
446
- refresh(): Promise<TradingSymbol[]>;
447
- /** Resolve a symbol or token class key to its registered symbol metadata. */
448
- resolve(ref: TokenRef): Promise<TradingSymbol>;
449
- /** Resolve and put two token references in canonical trading-symbol order. */
450
- orderPair(a: TokenRef, b: TokenRef): Promise<{
451
- token0: TradingSymbol;
452
- token1: TradingSymbol;
453
- flipped: boolean;
454
- }>;
441
+ export declare class Symbols {
442
+ private readonly gateway;
443
+ private cachedSymbols;
444
+ private cachedAt;
445
+ private refreshInFlight;
446
+ private readonly http;
447
+ /** Create a symbol service backed by the swap backend. */
448
+ constructor(gateway: Pick<ChainGateway, 'httpRequestor' | 'dexBackendBaseUrl'> & {
449
+ requestTimeoutMs?: number | undefined;
450
+ });
451
+ /** List all registered GalaChainDex trading symbols, cached for 60 seconds. */
452
+ list(): Promise<TradingSymbol[]>;
453
+ /** Invalidate the cached symbol registry after a write changes registration state.
454
+ *
455
+ * @example
456
+ * ```ts
457
+ * gSwap.symbols.invalidate();
458
+ * ```
459
+ */
460
+ invalidate(): void;
461
+ /** Force one registry refresh, bypassing the cache.
462
+ *
463
+ * @example
464
+ * ```ts
465
+ * const symbols = await gSwap.symbols.refresh();
466
+ * ```
467
+ */
468
+ refresh(): Promise<TradingSymbol[]>;
469
+ /** Resolve a symbol or token class key to its registered symbol metadata. */
470
+ resolve(ref: TokenRef): Promise<TradingSymbol>;
471
+ /** Resolve and put two token references in canonical trading-symbol order. */
472
+ orderPair(a: TokenRef, b: TokenRef): Promise<{
473
+ token0: TradingSymbol;
474
+ token1: TradingSymbol;
475
+ flipped: boolean;
476
+ }>;
455
477
  }
456
478
  /** Alias exported for callers that use the contract's shorter type name. */
457
- type TokenClassKey = GalaChainTokenClassKey;
458
-
479
+ export type TokenClassKey = GalaChainTokenClassKey;
480
+ //#endregion
481
+ //#region src/classes/pools.d.ts
459
482
  type PoolGateway = Pick<ChainGateway, 'httpRequestor' | 'dexBackendBaseUrl'> & {
460
- requestTimeoutMs?: number | undefined;
483
+ requestTimeoutMs?: number | undefined;
461
484
  };
462
485
  type PoolSymbols = Pick<Symbols, 'resolve'>;
463
486
  /** Read-only pool and current-price access for the current GalaChainDex contract. */
464
- declare class Pools {
465
- private readonly gateway;
466
- private readonly symbols;
467
- /**
468
- * Creates a pool service.
469
- *
470
- * @example
471
- * ```ts
472
- * const pools = new Pools(gateway, symbols);
473
- * ```
474
- */
475
- constructor(gateway: PoolGateway, symbols: PoolSymbols);
476
- private readonly http;
477
- /**
478
- * Fetches every current-contract pool from the swap backend.
479
- *
480
- * @example
481
- * ```ts
482
- * const pools = await service.getPools();
483
- * console.log(pools.length);
484
- * ```
485
- */
486
- getPools(options?: {
487
- signal?: AbortSignal | undefined;
488
- }): Promise<PoolListInfo[]>;
489
- /**
490
- * Fetches one pool from the backend, preserving whether the request order was flipped.
491
- *
492
- * @example
493
- * ```ts
494
- * const pool = await service.getPool('GUSDC', 'GALA', 3000);
495
- * console.log(pool.flippedFromRequest);
496
- * ```
497
- */
498
- getPool(token0: TokenRef, token1: TokenRef, fee: FEE_TIER): Promise<PoolInfo>;
499
- /**
500
- * Fetches the current sqrt price, price, and tick for one pool.
501
- *
502
- * @example
503
- * ```ts
504
- * const slot0 = await service.getSlot0('GALA', 'GUSDC', 3000);
505
- * console.log(slot0.tick);
506
- * ```
507
- */
508
- getSlot0(token0: TokenRef, token1: TokenRef, fee: FEE_TIER): Promise<Slot0>;
509
- /**
510
- * Fetches the complete chain composite pool snapshot, in canonical symbol order.
511
- *
512
- * @example
513
- * ```ts
514
- * const composite = await service.getCompositePool('GALA', 'GUSDC', 3000);
515
- * console.log(composite.positions?.length ?? 0);
516
- * ```
517
- */
518
- getCompositePool(token0: TokenRef, token1: TokenRef, fee: FEE_TIER): Promise<CompositePool>;
519
- private backendParams;
520
- private getBackend;
487
+ export declare class Pools {
488
+ private readonly gateway;
489
+ private readonly symbols;
490
+ /**
491
+ * Creates a pool service.
492
+ *
493
+ * @example
494
+ * ```ts
495
+ * const pools = new Pools(gateway, symbols);
496
+ * ```
497
+ */
498
+ constructor(gateway: PoolGateway, symbols: PoolSymbols);
499
+ private readonly http;
500
+ /**
501
+ * Fetches every current-contract pool from the swap backend.
502
+ *
503
+ * @example
504
+ * ```ts
505
+ * const pools = await service.getPools();
506
+ * console.log(pools.length);
507
+ * ```
508
+ */
509
+ getPools(options?: {
510
+ signal?: AbortSignal | undefined;
511
+ }): Promise<PoolListInfo[]>;
512
+ /**
513
+ * Fetches one pool from the backend, preserving whether the request order was flipped.
514
+ *
515
+ * @example
516
+ * ```ts
517
+ * const pool = await service.getPool('GUSDC', 'GALA', 3000);
518
+ * console.log(pool.flippedFromRequest);
519
+ * ```
520
+ */
521
+ getPool(token0: TokenRef, token1: TokenRef, fee: FEE_TIER): Promise<PoolInfo>;
522
+ /**
523
+ * Fetches the current sqrt price, price, and tick for one pool.
524
+ *
525
+ * @example
526
+ * ```ts
527
+ * const slot0 = await service.getSlot0('GALA', 'GUSDC', 3000);
528
+ * console.log(slot0.tick);
529
+ * ```
530
+ */
531
+ getSlot0(token0: TokenRef, token1: TokenRef, fee: FEE_TIER): Promise<Slot0>;
532
+ /**
533
+ * Fetches the complete chain composite pool snapshot, in canonical symbol order.
534
+ *
535
+ * @example
536
+ * ```ts
537
+ * const composite = await service.getCompositePool('GALA', 'GUSDC', 3000);
538
+ * console.log(composite.positions?.length ?? 0);
539
+ * ```
540
+ */
541
+ getCompositePool(token0: TokenRef, token1: TokenRef, fee: FEE_TIER): Promise<CompositePool>;
542
+ private backendParams;
543
+ private getBackend;
521
544
  }
522
-
545
+ //#endregion
546
+ //#region src/classes/signers.d.ts
523
547
  /** The signing schemes supported by the Gala Wallet signer. */
524
- type GalaWalletScheme = 'native' | 'personal-sign';
548
+ export type GalaWalletScheme = 'native' | 'personal-sign';
525
549
  /** The request surface used by an EIP-1193 browser wallet. */
526
- interface BrowserWalletProvider {
527
- request(args: {
528
- method: string;
529
- params?: unknown[];
530
- }): Promise<unknown>;
550
+ export interface BrowserWalletProvider {
551
+ request(args: {
552
+ method: string;
553
+ params?: unknown[];
554
+ }): Promise<unknown>;
531
555
  }
532
556
  type SignedDto<T extends Record<string, unknown>> = T & {
533
- signature: string;
557
+ signature: string;
534
558
  };
535
559
  /**
536
560
  * A signer for complete GalaChain write bodies.
@@ -539,16 +563,16 @@ type SignedDto<T extends Record<string, unknown>> = T & {
539
563
  * gateway request body. Signer identity is recovered from that signature; implementations do
540
564
  * not add signer hints, typed-data metadata, or a domain.
541
565
  */
542
- interface GalaChainSigner {
543
- /**
544
- * Signs a DTO for a named GalaChain contract method.
545
- *
546
- * @example
547
- * ```typescript
548
- * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
549
- * ```
550
- */
551
- signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
566
+ export interface GalaChainSigner {
567
+ /**
568
+ * Signs a DTO for a named GalaChain contract method.
569
+ *
570
+ * @example
571
+ * ```typescript
572
+ * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
573
+ * ```
574
+ */
575
+ signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
552
576
  }
553
577
  /**
554
578
  * A GalaChain native signer backed by a secp256k1 private key.
@@ -556,31 +580,31 @@ interface GalaChainSigner {
556
580
  * Native signing produces the bare GalaChain signature format, without a personal-sign prefix
557
581
  * or EIP-712 metadata. The private-key identity is recovered by the chain.
558
582
  */
559
- declare class PrivateKeySigner implements GalaChainSigner {
560
- private readonly keyBuffer;
561
- /**
562
- * Creates a native signer from a hex or base64 secp256k1 private key.
563
- *
564
- * @example
565
- * ```typescript
566
- * const signer = new PrivateKeySigner('1'.padStart(64, '0'));
567
- * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
568
- * ```
569
- */
570
- constructor(privateKey: string);
571
- /**
572
- * Signs the DTO with GalaChain native signing.
573
- *
574
- * @example
575
- * ```typescript
576
- * const signed = await signer.signObject('RequestTrade', {
577
- * token0: 'GALA',
578
- * token1: 'GUSDC',
579
- * fee: 3000,
580
- * });
581
- * ```
582
- */
583
- signObject<T extends Record<string, unknown>>(_methodName: string, dto: T): Promise<SignedDto<T>>;
583
+ export declare class PrivateKeySigner implements GalaChainSigner {
584
+ private readonly keyBuffer;
585
+ /**
586
+ * Creates a native signer from a hex or base64 secp256k1 private key.
587
+ *
588
+ * @example
589
+ * ```typescript
590
+ * const signer = new PrivateKeySigner('1'.padStart(64, '0'));
591
+ * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
592
+ * ```
593
+ */
594
+ constructor(privateKey: string);
595
+ /**
596
+ * Signs the DTO with GalaChain native signing.
597
+ *
598
+ * @example
599
+ * ```typescript
600
+ * const signed = await signer.signObject('RequestTrade', {
601
+ * token0: 'GALA',
602
+ * token1: 'GUSDC',
603
+ * fee: 3000,
604
+ * });
605
+ * ```
606
+ */
607
+ signObject<T extends Record<string, unknown>>(_methodName: string, dto: T): Promise<SignedDto<T>>;
584
608
  }
585
609
  /**
586
610
  * A Gala Wallet signer using native GalaChain signing, with an opt-in personal-sign mode and
@@ -590,41 +614,41 @@ declare class PrivateKeySigner implements GalaChainSigner {
590
614
  * `eth|` identity; the legacy EIP-712 `eth_signTypedData` path is not used. The fallback calls
591
615
  * `gala_signChainDto([serialize({ ...dto, prefix }), walletAddress, methodName])`.
592
616
  */
593
- declare class GalaWalletSigner implements GalaChainSigner {
594
- /** The wallet address supplied to Gala Wallet for each signing request. */
595
- readonly walletAddress: string;
596
- /** The scheme currently used, including any automatic native-to-personal fallback. */
597
- effectiveScheme: GalaWalletScheme;
598
- /**
599
- * Creates a Gala Wallet signer.
600
- *
601
- * @example
602
- * ```typescript
603
- * const signer = new GalaWalletSigner('0x0123456789012345678901234567890123456789');
604
- * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
605
- * ```
606
- *
607
- * @param walletAddress - The selected Ethereum account (`0x` plus 40 hex digits); Gala Wallet's
608
- * `eth|0x...` form is also accepted and normalized.
609
- * @param options - Select native signing or personal-sign explicitly.
610
- */
611
- constructor(walletAddress: string, options?: {
612
- scheme?: GalaWalletScheme | undefined;
613
- });
614
- /**
615
- * Signs a DTO through `gala_signChainDto`.
616
- *
617
- * @example
618
- * ```typescript
619
- * const signed = await signer.signObject('AddLiquidity', {
620
- * token0: 'GALA',
621
- * token1: 'GUSDC',
622
- * tickLower: -60,
623
- * tickUpper: 60,
624
- * });
625
- * ```
626
- */
627
- signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
617
+ export declare class GalaWalletSigner implements GalaChainSigner {
618
+ /** The wallet address supplied to Gala Wallet for each signing request. */
619
+ readonly walletAddress: string;
620
+ /** The scheme currently used, including any automatic native-to-personal fallback. */
621
+ effectiveScheme: GalaWalletScheme;
622
+ /**
623
+ * Creates a Gala Wallet signer.
624
+ *
625
+ * @example
626
+ * ```typescript
627
+ * const signer = new GalaWalletSigner('0x0123456789012345678901234567890123456789');
628
+ * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
629
+ * ```
630
+ *
631
+ * @param walletAddress - The selected Ethereum account (`0x` plus 40 hex digits); Gala Wallet's
632
+ * `eth|0x...` form is also accepted and normalized.
633
+ * @param options - Select native signing or personal-sign explicitly.
634
+ */
635
+ constructor(walletAddress: string, options?: {
636
+ scheme?: GalaWalletScheme | undefined;
637
+ });
638
+ /**
639
+ * Signs a DTO through `gala_signChainDto`.
640
+ *
641
+ * @example
642
+ * ```typescript
643
+ * const signed = await signer.signObject('AddLiquidity', {
644
+ * token0: 'GALA',
645
+ * token1: 'GUSDC',
646
+ * tickLower: -60,
647
+ * tickUpper: 60,
648
+ * });
649
+ * ```
650
+ */
651
+ signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
628
652
  }
629
653
  /**
630
654
  * A personal-sign signer for MetaMask and other EIP-1193 browser wallets.
@@ -633,69 +657,72 @@ declare class GalaWalletSigner implements GalaChainSigner {
633
657
  * `personal_sign`. This is the browser-wallet path used by the v2 frontend and resolves the
634
658
  * bare `eth|` identity.
635
659
  */
636
- declare class BrowserWalletSigner implements GalaChainSigner {
637
- private readonly provider;
638
- /**
639
- * Creates a browser-wallet signer.
640
- *
641
- * Defaults to `personal_sign` — unchanged from every existing integration, since it only ever
642
- * resolves the bare `eth|` identity and changing that silently would be a real behavior
643
- * break for anyone already depending on it. Pass `{ scheme: 'eip712' }` to correctly resolve
644
- * a registered `client|` alias instead, for `RequestTrade`/`AddLiquidity`/`RemoveLiquidity`/
645
- * `CollectPositionFees` (`EIP712_CAPABLE_METHODS`) — `CreatePool` and any other method still
646
- * falls back to `personal_sign` even in `'eip712'` mode, since its EIP-712 signing is a
647
- * separate, unsolved chain-side problem.
648
- *
649
- * @example
650
- * ```typescript
651
- * const signer = new BrowserWalletSigner(window.ethereum, '0x0123456789012345678901234567890123456789');
652
- * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
653
- * ```
654
- * @example
655
- * ```typescript
656
- * // Correctly resolves a registered client| alias instead of the bare eth| address.
657
- * const signer = new BrowserWalletSigner(window.ethereum, walletAddress, { scheme: 'eip712' });
658
- * ```
659
- */
660
- constructor(provider: BrowserWalletProvider, walletAddress: string, options?: {
661
- scheme?: 'personal-sign' | 'eip712';
662
- });
663
- readonly walletAddress: string;
664
- private readonly scheme;
665
- /**
666
- * Signs the DTO with `eth_signTypedData_v4` (when constructed with `{ scheme: 'eip712' }` and
667
- * `methodName` is in `EIP712_CAPABLE_METHODS`) or the EIP-1193 `personal_sign` method
668
- * (otherwise — the default).
669
- *
670
- * @example
671
- * ```typescript
672
- * const signed = await signer.signObject('RequestTrade', {
673
- * token0: 'GALA',
674
- * token1: 'GUSDC',
675
- * fee: 3000,
676
- * });
677
- * ```
678
- */
679
- signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
660
+ export declare class BrowserWalletSigner implements GalaChainSigner {
661
+ private readonly provider;
662
+ /**
663
+ * Creates a browser-wallet signer.
664
+ *
665
+ * Defaults to `personal_sign` — unchanged from every existing integration, since it only ever
666
+ * resolves the bare `eth|` identity and changing that silently would be a real behavior
667
+ * break for anyone already depending on it. Pass `{ scheme: 'eip712' }` to correctly resolve
668
+ * a registered `client|` alias instead, for `RequestTrade`/`AddLiquidity`/`RemoveLiquidity`/
669
+ * `CollectPositionFees` (`EIP712_CAPABLE_METHODS`) — `CreatePool` and any other method still
670
+ * falls back to `personal_sign` even in `'eip712'` mode, since its EIP-712 signing is a
671
+ * separate, unsolved chain-side problem.
672
+ *
673
+ * @example
674
+ * ```typescript
675
+ * const signer = new BrowserWalletSigner(window.ethereum, '0x0123456789012345678901234567890123456789');
676
+ * const signed = await signer.signObject('RequestTrade', { token0: 'GALA', token1: 'GUSDC' });
677
+ * ```
678
+ * @example
679
+ * ```typescript
680
+ * // Correctly resolves a registered client| alias instead of the bare eth| address.
681
+ * const signer = new BrowserWalletSigner(window.ethereum, walletAddress, { scheme: 'eip712' });
682
+ * ```
683
+ */
684
+ constructor(provider: BrowserWalletProvider, walletAddress: string, options?: {
685
+ scheme?: 'personal-sign' | 'eip712';
686
+ });
687
+ readonly walletAddress: string;
688
+ private readonly scheme;
689
+ /**
690
+ * Signs the DTO with `eth_signTypedData_v4` (when constructed with `{ scheme: 'eip712' }` and
691
+ * `methodName` is in `EIP712_CAPABLE_METHODS`) or the EIP-1193 `personal_sign` method
692
+ * (otherwise — the default).
693
+ *
694
+ * @example
695
+ * ```typescript
696
+ * const signed = await signer.signObject('RequestTrade', {
697
+ * token0: 'GALA',
698
+ * token1: 'GUSDC',
699
+ * fee: 3000,
700
+ * });
701
+ * ```
702
+ */
703
+ signObject<T extends Record<string, unknown>>(methodName: string, dto: T): Promise<SignedDto<T>>;
680
704
  }
681
-
705
+ //#endregion
706
+ //#region src/types/branding.d.ts
682
707
  interface Branding<BrandT> {
683
- _type: BrandT;
708
+ _type: BrandT;
684
709
  }
685
710
  type Brand<T, BrandT> = T & Branding<BrandT>;
686
-
687
- type NumericAmount = string | BigNumber;
688
- type SqrtPrice = Brand<BigNumber, 'SqrtPrice'>;
689
- type SqrtPriceIn = Brand<NumericAmount, 'SqrtPriceIn'> | SqrtPrice;
690
- type Price = Brand<BigNumber, 'Price'>;
691
- type PriceIn = Brand<NumericAmount, 'PriceIn'> | Price;
692
-
711
+ //#endregion
712
+ //#region src/types/amounts.d.ts
713
+ export type NumericAmount = string | BigNumber;
714
+ export type SqrtPrice = Brand<BigNumber, 'SqrtPrice'>;
715
+ export type SqrtPriceIn = Brand<NumericAmount, 'SqrtPriceIn'> | SqrtPrice;
716
+ export type Price = Brand<BigNumber, 'Price'>;
717
+ export type PriceIn = Brand<NumericAmount, 'PriceIn'> | Price;
718
+ //#endregion
719
+ //#region src/classes/positions.d.ts
693
720
  type PositionGateway = Pick<ChainGateway, 'httpRequestor' | 'dexBackendBaseUrl'> & {
694
- submit: (method: string, signedBody: Record<string, unknown>, options?: ChainSubmitOptions) => Promise<SubmittedTransaction<Position | null>>;
695
- requestTimeoutMs?: number | undefined;
721
+ submit: (method: string, signedBody: Record<string, unknown>, options?: ChainSubmitOptions) => Promise<SubmittedTransaction<Position | null>>;
722
+ requestTimeoutMs?: number | undefined;
696
723
  };
697
724
  type PositionSymbols = Pick<Symbols, 'resolve' | 'orderPair'> & {
698
- invalidate?: () => void;
725
+ invalidate?: () => void;
699
726
  };
700
727
  /**
701
728
  * Manages current-contract concentrated-liquidity positions.
@@ -707,529 +734,546 @@ type PositionSymbols = Pick<Symbols, 'resolve' | 'orderPair'> & {
707
734
  * console.log(mine.length);
708
735
  * ```
709
736
  */
710
- declare class Positions {
711
- private readonly gateway;
712
- private readonly symbols;
713
- private readonly signer?;
714
- private readonly walletAddress?;
715
- constructor(gateway: PositionGateway, symbols: PositionSymbols, signer?: GalaChainSigner | undefined, walletAddress?: string | undefined);
716
- private readonly http;
717
- /**
718
- * Gets all current-contract positions owned by an address.
719
- *
720
- * @param owner - GalaChain owner identity.
721
- * @returns Enriched positions from the v2 trade backend.
722
- * @example
723
- * ```typescript
724
- * const positions = await gSwap.positions.getUserPositions('client|012345678901234567890123');
725
- * ```
726
- */
727
- getUserPositions(owner: string): Promise<Position[]>;
728
- /**
729
- * Gets one position, normalizing a caller-supplied reversed pair to canonical symbol order.
730
- * Reversed pairs also invert the price axis, so `[lower, upper]` becomes `[-upper, -lower]`.
731
- *
732
- * @param args - Pair, owner, fee, and position tick range.
733
- * @returns The position, or `null` when the backend returns 404.
734
- * @example
735
- * ```typescript
736
- * const position = await gSwap.positions.getPosition({
737
- * token0: 'GALA', token1: 'GUSDC', owner: 'client|012345678901234567890123',
738
- * fee: 3000, tickLower: -19200, tickUpper: 12000,
739
- * });
740
- * ```
741
- */
742
- getPosition(args: {
743
- token0: TokenRef;
744
- token1: TokenRef;
745
- fee: FEE_TIER;
746
- owner: string;
747
- tickLower: number;
748
- tickUpper: number;
749
- }, signal?: AbortSignal): Promise<Position | null>;
750
- /**
751
- * Estimates the other token amount and resulting liquidity for a deposit.
752
- *
753
- * @param args - Pair, tick range, deposit amount, and the amount's caller-side token index.
754
- * @returns Backend liquidity estimate.
755
- * @example
756
- * ```typescript
757
- * const estimate = await gSwap.positions.estimateAddLiquidity({
758
- * token0: 'GALA', token1: 'GUSDC', fee: 3000,
759
- * tickLower: -19200, tickUpper: 12000, amount: '100', amountIsToken0: true,
760
- * });
761
- * ```
762
- */
763
- estimateAddLiquidity(args: {
764
- token0: TokenRef;
765
- token1: TokenRef;
766
- fee: FEE_TIER;
767
- tickLower: number;
768
- tickUpper: number;
769
- amount: NumericAmount;
770
- amountIsToken0: boolean;
771
- }): Promise<AddLiquidityEstimate>;
772
- /**
773
- * Estimates token amounts released by burning liquidity.
774
- *
775
- * @param args - Pair, tick range, fee tier, and liquidity quantity.
776
- * @returns Estimated token0 and token1 quantities.
777
- * @example
778
- * ```typescript
779
- * const estimate = await gSwap.positions.estimateRemoveLiquidity({
780
- * token0: 'GALA', token1: 'GUSDC', fee: 3000,
781
- * tickLower: -19200, tickUpper: 12000, liquidity: '1000',
782
- * });
783
- * ```
784
- */
785
- estimateRemoveLiquidity(args: {
786
- token0: TokenRef;
787
- token1: TokenRef;
788
- fee: FEE_TIER;
789
- tickLower: number;
790
- tickUpper: number;
791
- liquidity: NumericAmount;
792
- }): Promise<RemoveLiquidityEstimate>;
793
- /**
794
- * Adds liquidity using an explicit tick range. Exactly one canonical deposit field is emitted.
795
- *
796
- * @param args - Pair, fee, range, deposit amount, and caller-side token index.
797
- * @returns The synchronously submitted transaction.
798
- * @example
799
- * ```typescript
800
- * const tx = await gSwap.positions.addLiquidityByTicks({
801
- * token0: 'GALA', token1: 'GUSDC', fee: 3000,
802
- * tickLower: -19200, tickUpper: 12000, amount: '100', amountIsToken0: true,
803
- * });
804
- * await tx.confirm();
805
- * ```
806
- */
807
- addLiquidityByTicks(args: {
808
- token0: TokenRef;
809
- token1: TokenRef;
810
- fee: FEE_TIER;
811
- tickLower: number;
812
- tickUpper: number;
813
- amount: NumericAmount;
814
- amountIsToken0: boolean;
815
- }): Promise<SubmittedTransaction<Position | null>>;
816
- /**
817
- * Adds liquidity from prices, flooring the lower tick and ceiling the upper tick to fee spacing.
818
- * The resulting range is therefore no narrower than the requested price interval.
819
- *
820
- * @param args - Pair, fee, price range, deposit amount, and caller-side token index.
821
- * @returns The synchronously submitted transaction.
822
- * @example
823
- * ```typescript
824
- * const tx = await gSwap.positions.addLiquidityByPrice({
825
- * token0: 'GALA', token1: 'GUSDC', fee: 3000,
826
- * minPrice: '0.14', maxPrice: '0.16', amount: '100', amountIsToken0: true,
827
- * });
828
- * ```
829
- */
830
- addLiquidityByPrice(args: {
831
- token0: TokenRef;
832
- token1: TokenRef;
833
- fee: FEE_TIER;
834
- minPrice: PriceIn;
835
- maxPrice: PriceIn;
836
- amount: NumericAmount;
837
- amountIsToken0: boolean;
838
- }): Promise<SubmittedTransaction<Position | null>>;
839
- /**
840
- * Removes liquidity by withdrawing at most one canonical token quantity.
841
- * Omitting both amounts closes the position and sweeps all accrued fees.
842
- *
843
- * @param args - Pair, fee, range, and optional caller-side withdrawal amount.
844
- * @returns The synchronously submitted transaction.
845
- * @example
846
- * ```typescript
847
- * const tx = await gSwap.positions.removeLiquidity({
848
- * token0: 'GALA', token1: 'GUSDC', fee: 3000,
849
- * tickLower: -19200, tickUpper: 12000,
850
- * });
851
- * ```
852
- */
853
- removeLiquidity(args: {
854
- token0: TokenRef;
855
- token1: TokenRef;
856
- fee: FEE_TIER;
857
- tickLower: number;
858
- tickUpper: number;
859
- amount0?: NumericAmount | undefined;
860
- amount1?: NumericAmount | undefined;
861
- }): Promise<SubmittedTransaction<Position | null>>;
862
- /**
863
- * Collects all accrued fees for a position; the contract does not support partial collection.
864
- *
865
- * @param args - Pair, fee, and tick range identifying the position.
866
- * @returns The synchronously submitted transaction.
867
- * @example
868
- * ```typescript
869
- * const tx = await gSwap.positions.collectPositionFees({
870
- * token0: 'GALA', token1: 'GUSDC', fee: 3000,
871
- * tickLower: -19200, tickUpper: 12000,
872
- * });
873
- * ```
874
- */
875
- collectPositionFees(args: {
876
- token0: TokenRef;
877
- token1: TokenRef;
878
- fee: FEE_TIER;
879
- tickLower: number;
880
- tickUpper: number;
881
- }): Promise<SubmittedTransaction<Position | null>>;
882
- /**
883
- * Creates a pool, resolving registered trading symbols and falling back to class collections.
884
- * Reversed symbol order inverts the supplied starting price or square-root price.
885
- *
886
- * @param args - Token class keys or references, fee, exactly one starting price field, and privacy options.
887
- * @returns The synchronously submitted transaction.
888
- * @example
889
- * ```typescript
890
- * const tx = await gSwap.positions.createPool({
891
- * token0: 'GALA|Unit|none|none', token1: 'GUSDC|Unit|none|none', fee: 3000,
892
- * startingPrice: '0.15',
893
- * });
894
- * ```
895
- */
896
- createPool(args: {
897
- token0: TokenRef;
898
- token1: TokenRef;
899
- fee: FEE_TIER;
900
- startingPrice?: NumericAmount | undefined;
901
- startingSqrtPrice?: NumericAmount | undefined;
902
- isPrivate?: boolean | undefined;
903
- privateAccess?: string[] | undefined;
904
- }): Promise<SubmittedTransaction<Position | null>>;
905
- private submit;
906
- /**
907
- * Builds a confirmation closure that proves the write's own effect, not just that a
908
- * position row exists (true before most of these writes run too, for any operation on a
909
- * pre-existing position — existence alone would false-confirm before the write executes,
910
- * and would never confirm a full close, whose whole point is that the position stops
911
- * existing).
912
- *
913
- * The "before" state is captured lazily, on the confirmation closure's own first poll —
914
- * not eagerly here in `submit()` — so confirming a write never adds an extra round-trip to
915
- * the write itself; the cost of establishing the baseline is paid by `confirm()`, only if
916
- * and when the caller actually asks to confirm.
917
- */
918
- private buildPositionConfirmation;
919
- private get;
920
- private getNullable;
921
- private isNotFound;
922
- private mapPosition;
923
- private requestToken;
924
- private canonicalTicks;
925
- private tickSpacing;
926
- private rejectNumber;
927
- private uniqueKey;
928
- private resolveCreateToken;
929
- private tryParseClassKey;
737
+ export declare class Positions {
738
+ private readonly gateway;
739
+ private readonly symbols;
740
+ private readonly signer?;
741
+ private readonly walletAddress?;
742
+ constructor(gateway: PositionGateway, symbols: PositionSymbols, signer?: GalaChainSigner | undefined, walletAddress?: string | undefined);
743
+ private readonly http;
744
+ /**
745
+ * Gets all current-contract positions owned by an address.
746
+ *
747
+ * @param owner - GalaChain owner identity.
748
+ * @returns Enriched positions from the v2 trade backend.
749
+ * @example
750
+ * ```typescript
751
+ * const positions = await gSwap.positions.getUserPositions('client|012345678901234567890123');
752
+ * ```
753
+ */
754
+ getUserPositions(owner: string): Promise<Position[]>;
755
+ /**
756
+ * Gets one position, normalizing a caller-supplied reversed pair to canonical symbol order.
757
+ * Reversed pairs also invert the price axis, so `[lower, upper]` becomes `[-upper, -lower]`.
758
+ *
759
+ * @param args - Pair, owner, fee, and position tick range.
760
+ * @returns The position, or `null` when the backend returns 404.
761
+ * @example
762
+ * ```typescript
763
+ * const position = await gSwap.positions.getPosition({
764
+ * token0: 'GALA', token1: 'GUSDC', owner: 'client|012345678901234567890123',
765
+ * fee: 3000, tickLower: -19200, tickUpper: 12000,
766
+ * });
767
+ * ```
768
+ */
769
+ getPosition(args: {
770
+ token0: TokenRef;
771
+ token1: TokenRef;
772
+ fee: FEE_TIER;
773
+ owner: string;
774
+ tickLower: number;
775
+ tickUpper: number;
776
+ }, signal?: AbortSignal): Promise<Position | null>;
777
+ /**
778
+ * Estimates the other token amount and resulting liquidity for a deposit.
779
+ *
780
+ * @param args - Pair, tick range, deposit amount, and the amount's caller-side token index.
781
+ * @returns Backend liquidity estimate.
782
+ * @example
783
+ * ```typescript
784
+ * const estimate = await gSwap.positions.estimateAddLiquidity({
785
+ * token0: 'GALA', token1: 'GUSDC', fee: 3000,
786
+ * tickLower: -19200, tickUpper: 12000, amount: '100', amountIsToken0: true,
787
+ * });
788
+ * ```
789
+ */
790
+ estimateAddLiquidity(args: {
791
+ token0: TokenRef;
792
+ token1: TokenRef;
793
+ fee: FEE_TIER;
794
+ tickLower: number;
795
+ tickUpper: number;
796
+ amount: NumericAmount;
797
+ amountIsToken0: boolean;
798
+ }): Promise<AddLiquidityEstimate>;
799
+ /**
800
+ * Estimates token amounts released by burning liquidity.
801
+ *
802
+ * @param args - Pair, tick range, fee tier, and liquidity quantity.
803
+ * @returns Estimated token0 and token1 quantities.
804
+ * @example
805
+ * ```typescript
806
+ * const estimate = await gSwap.positions.estimateRemoveLiquidity({
807
+ * token0: 'GALA', token1: 'GUSDC', fee: 3000,
808
+ * tickLower: -19200, tickUpper: 12000, liquidity: '1000',
809
+ * });
810
+ * ```
811
+ */
812
+ estimateRemoveLiquidity(args: {
813
+ token0: TokenRef;
814
+ token1: TokenRef;
815
+ fee: FEE_TIER;
816
+ tickLower: number;
817
+ tickUpper: number;
818
+ liquidity: NumericAmount;
819
+ }): Promise<RemoveLiquidityEstimate>;
820
+ /**
821
+ * Adds liquidity using an explicit tick range. Exactly one canonical deposit field is emitted.
822
+ *
823
+ * @param args - Pair, fee, range, deposit amount, and caller-side token index.
824
+ * @returns The synchronously submitted transaction.
825
+ * @example
826
+ * ```typescript
827
+ * const tx = await gSwap.positions.addLiquidityByTicks({
828
+ * token0: 'GALA', token1: 'GUSDC', fee: 3000,
829
+ * tickLower: -19200, tickUpper: 12000, amount: '100', amountIsToken0: true,
830
+ * });
831
+ * await tx.confirm();
832
+ * ```
833
+ */
834
+ addLiquidityByTicks(args: {
835
+ token0: TokenRef;
836
+ token1: TokenRef;
837
+ fee: FEE_TIER;
838
+ tickLower: number;
839
+ tickUpper: number;
840
+ amount: NumericAmount;
841
+ amountIsToken0: boolean;
842
+ }): Promise<SubmittedTransaction<Position | null>>;
843
+ /**
844
+ * Adds liquidity from prices, flooring the lower tick and ceiling the upper tick to fee spacing.
845
+ * The resulting range is therefore no narrower than the requested price interval.
846
+ *
847
+ * @param args - Pair, fee, price range, deposit amount, and caller-side token index.
848
+ * @returns The synchronously submitted transaction.
849
+ * @example
850
+ * ```typescript
851
+ * const tx = await gSwap.positions.addLiquidityByPrice({
852
+ * token0: 'GALA', token1: 'GUSDC', fee: 3000,
853
+ * minPrice: '0.14', maxPrice: '0.16', amount: '100', amountIsToken0: true,
854
+ * });
855
+ * ```
856
+ */
857
+ addLiquidityByPrice(args: {
858
+ token0: TokenRef;
859
+ token1: TokenRef;
860
+ fee: FEE_TIER;
861
+ minPrice: PriceIn;
862
+ maxPrice: PriceIn;
863
+ amount: NumericAmount;
864
+ amountIsToken0: boolean;
865
+ }): Promise<SubmittedTransaction<Position | null>>;
866
+ /**
867
+ * Removes liquidity by withdrawing at most one canonical token quantity.
868
+ * Omitting both amounts closes the position and sweeps all accrued fees.
869
+ *
870
+ * @param args - Pair, fee, range, and optional caller-side withdrawal amount.
871
+ * @returns The synchronously submitted transaction.
872
+ * @example
873
+ * ```typescript
874
+ * const tx = await gSwap.positions.removeLiquidity({
875
+ * token0: 'GALA', token1: 'GUSDC', fee: 3000,
876
+ * tickLower: -19200, tickUpper: 12000,
877
+ * });
878
+ * ```
879
+ */
880
+ removeLiquidity(args: {
881
+ token0: TokenRef;
882
+ token1: TokenRef;
883
+ fee: FEE_TIER;
884
+ tickLower: number;
885
+ tickUpper: number;
886
+ amount0?: NumericAmount | undefined;
887
+ amount1?: NumericAmount | undefined;
888
+ }): Promise<SubmittedTransaction<Position | null>>;
889
+ /**
890
+ * Collects all accrued fees for a position; the contract does not support partial collection.
891
+ *
892
+ * @param args - Pair, fee, and tick range identifying the position.
893
+ * @returns The synchronously submitted transaction.
894
+ * @example
895
+ * ```typescript
896
+ * const tx = await gSwap.positions.collectPositionFees({
897
+ * token0: 'GALA', token1: 'GUSDC', fee: 3000,
898
+ * tickLower: -19200, tickUpper: 12000,
899
+ * });
900
+ * ```
901
+ */
902
+ collectPositionFees(args: {
903
+ token0: TokenRef;
904
+ token1: TokenRef;
905
+ fee: FEE_TIER;
906
+ tickLower: number;
907
+ tickUpper: number;
908
+ }): Promise<SubmittedTransaction<Position | null>>;
909
+ /**
910
+ * Creates a pool, resolving registered trading symbols.
911
+ * Reversed symbol order inverts the supplied starting price or square-root price.
912
+ *
913
+ * A token class key carries no symbol, so for a token being proposed into the v2
914
+ * trading-symbol registry for the first time (no existing pool has registered it yet) the
915
+ * caller MUST pass `token0Symbol`/`token1Symbol` (the token class's symbol, from the token
916
+ * list or FetchTokenClasses). The SDK never derives a symbol from the key, and throws a
917
+ * VALIDATION_ERROR when an unregistered token has none. For an already-registered token a
918
+ * supplied symbol must match the registered one.
919
+ *
920
+ * @param args - Token class keys or references, fee, exactly one starting price field, and privacy options.
921
+ * @returns The synchronously submitted transaction.
922
+ * @example
923
+ * ```typescript
924
+ * const tx = await gSwap.positions.createPool({
925
+ * token0: 'GALA|Unit|none|none', token1: 'GUSDC|Unit|none|none', fee: 3000,
926
+ * startingPrice: '0.15',
927
+ * });
928
+ * ```
929
+ */
930
+ createPool(args: {
931
+ token0: TokenRef;
932
+ token1: TokenRef;
933
+ token0Symbol?: string | undefined;
934
+ token1Symbol?: string | undefined;
935
+ fee: FEE_TIER;
936
+ startingPrice?: NumericAmount | undefined;
937
+ startingSqrtPrice?: NumericAmount | undefined;
938
+ isPrivate?: boolean | undefined;
939
+ privateAccess?: string[] | undefined;
940
+ }): Promise<SubmittedTransaction<Position | null>>;
941
+ private submit;
942
+ /**
943
+ * Builds a confirmation closure that proves the write's own effect, not just that a
944
+ * position row exists (true before most of these writes run too, for any operation on a
945
+ * pre-existing position — existence alone would false-confirm before the write executes,
946
+ * and would never confirm a full close, whose whole point is that the position stops
947
+ * existing).
948
+ *
949
+ * The "before" state is captured lazily, on the confirmation closure's own first poll —
950
+ * not eagerly here in `submit()` — so confirming a write never adds an extra round-trip to
951
+ * the write itself; the cost of establishing the baseline is paid by `confirm()`, only if
952
+ * and when the caller actually asks to confirm.
953
+ */
954
+ private buildPositionConfirmation;
955
+ private get;
956
+ private getNullable;
957
+ private isNotFound;
958
+ private mapPosition;
959
+ private requestToken;
960
+ private canonicalTicks;
961
+ private tickSpacing;
962
+ private rejectNumber;
963
+ private uniqueKey;
964
+ private resolveCreateToken;
965
+ private tryParseClassKey;
930
966
  }
931
-
967
+ //#endregion
968
+ //#region src/classes/quoting.d.ts
932
969
  type QuoteSymbols = Pick<Symbols, 'resolve'>;
933
970
  /** Read-only quote service backed by the v2 offline quote engine. */
934
- declare class Quoting {
935
- private readonly dexBackendBaseUrl;
936
- private readonly http;
937
- private readonly symbols;
938
- /**
939
- * Creates a quote service.
940
- *
941
- * @example
942
- * ```ts
943
- * const quoting = new Quoting('https://swap-backend.stage.defi.ovh.gala.com', http, symbols);
944
- * ```
945
- */
946
- constructor(dexBackendBaseUrl: string, http: HttpClient, symbols: QuoteSymbols);
947
- /**
948
- * Quotes the output for a positive exact-input amount.
949
- *
950
- * @example
951
- * ```ts
952
- * const quote = await quoting.quoteExactInput('GALA', 'GUSDC', '100');
953
- * console.log(quote.amountOut);
954
- * ```
955
- */
956
- quoteExactInput(tokenIn: TokenRef, tokenOut: TokenRef, amountIn: NumericAmount, fee?: FEE_TIER): Promise<QuoteResult>;
957
- /**
958
- * Quotes the input for a positive exact-output amount.
959
- *
960
- * @example
961
- * ```ts
962
- * const quote = await quoting.quoteExactOutput('GALA', 'GUSDC', '10', 3000);
963
- * console.log(quote.amountIn);
964
- * ```
965
- */
966
- quoteExactOutput(tokenIn: TokenRef, tokenOut: TokenRef, amountOut: NumericAmount, fee?: FEE_TIER): Promise<QuoteResult>;
967
- private quote;
971
+ export declare class Quoting {
972
+ private readonly dexBackendBaseUrl;
973
+ private readonly http;
974
+ private readonly symbols;
975
+ /**
976
+ * Creates a quote service.
977
+ *
978
+ * @example
979
+ * ```ts
980
+ * const quoting = new Quoting('https://swap-backend.stage.defi.ovh.gala.com', http, symbols);
981
+ * ```
982
+ */
983
+ constructor(dexBackendBaseUrl: string, http: HttpClient, symbols: QuoteSymbols);
984
+ /**
985
+ * Quotes the output for a positive exact-input amount.
986
+ *
987
+ * @example
988
+ * ```ts
989
+ * const quote = await quoting.quoteExactInput('GALA', 'GUSDC', '100');
990
+ * console.log(quote.amountOut);
991
+ * ```
992
+ */
993
+ quoteExactInput(tokenIn: TokenRef, tokenOut: TokenRef, amountIn: NumericAmount, fee?: FEE_TIER): Promise<QuoteResult>;
994
+ /**
995
+ * Quotes the input for a positive exact-output amount.
996
+ *
997
+ * @example
998
+ * ```ts
999
+ * const quote = await quoting.quoteExactOutput('GALA', 'GUSDC', '10', 3000);
1000
+ * console.log(quote.amountIn);
1001
+ * ```
1002
+ */
1003
+ quoteExactOutput(tokenIn: TokenRef, tokenOut: TokenRef, amountOut: NumericAmount, fee?: FEE_TIER): Promise<QuoteResult>;
1004
+ private quote;
968
1005
  }
969
-
970
- type SwapAmount = {
971
- exactIn: NumericAmount;
972
- exactOut?: undefined;
973
- amountOutMinimum?: NumericAmount | undefined;
974
- amountInMaximum?: undefined;
1006
+ //#endregion
1007
+ //#region src/classes/swaps.d.ts
1008
+ export type SwapAmount = {
1009
+ exactIn: NumericAmount;
1010
+ exactOut?: undefined;
1011
+ amountOutMinimum?: NumericAmount | undefined;
1012
+ amountInMaximum?: undefined;
975
1013
  } | {
976
- exactIn?: undefined;
977
- exactOut: NumericAmount;
978
- amountOutMinimum?: undefined;
979
- amountInMaximum?: NumericAmount | undefined;
1014
+ exactIn?: undefined;
1015
+ exactOut: NumericAmount;
1016
+ amountOutMinimum?: undefined;
1017
+ amountInMaximum?: NumericAmount | undefined;
980
1018
  };
981
1019
  interface SwapGateway {
982
- submit: (method: 'RequestTrade', signedBody: Record<string, unknown>, options?: ChainSubmitOptions) => Promise<SubmittedTransaction<AppliedTrade>>;
983
- readonly dexBackendBaseUrl: string;
984
- readonly httpRequestor: HttpRequestor;
985
- readonly requestTimeoutMs: number;
1020
+ submit: (method: 'RequestTrade', signedBody: Record<string, unknown>, options?: ChainSubmitOptions) => Promise<SubmittedTransaction<AppliedTrade>>;
1021
+ readonly dexBackendBaseUrl: string;
1022
+ readonly httpRequestor: HttpRequestor;
1023
+ readonly requestTimeoutMs: number;
986
1024
  }
987
1025
  type SwapSymbols = Pick<Symbols, 'resolve'>;
988
1026
  /** Executes queued current-contract RequestTrade operations through the Chain Gateway. */
989
- declare class Swaps {
990
- private readonly gateway;
991
- private readonly symbols;
992
- private readonly signer?;
993
- private readonly walletAddress?;
994
- /**
995
- * Creates a swap service.
996
- *
997
- * @example
998
- * ```ts
999
- * const swaps = new Swaps(gateway, symbols, signer, 'client|alice');
1000
- * ```
1001
- */
1002
- constructor(gateway: SwapGateway, symbols: SwapSymbols, signer?: GalaChainSigner | undefined, walletAddress?: string | undefined);
1003
- /**
1004
- * Signs and submits an exact-input or exact-output RequestTrade DTO. The returned transaction
1005
- * is QUEUED; call `await tx.confirm()` to obtain the executed trade or chain rejection.
1006
- *
1007
- * @example
1008
- * ```ts
1009
- * const submitted = await swaps.swap('GALA', 'GUSDC', 3000, {
1010
- * exactIn: '100',
1011
- * amountOutMinimum: '14',
1012
- * });
1013
- * ```
1014
- */
1015
- swap(tokenIn: TokenRef, tokenOut: TokenRef, fee: FEE_TIER, amount: SwapAmount): Promise<SubmittedTransaction<AppliedTrade>>;
1016
- /**
1017
- * Confirm a swap by its durable `uniqueKey` without resubmitting it. This is the recovery
1018
- * path after a `CONFIRMATION_TIMEOUT`, a `SUBMISSION_OUTCOME_UNKNOWN`, a `409` replay
1019
- * conflict, or a process restart: it reads the same apply-results record that
1020
- * `SubmittedTransaction.confirm()` reads (retained for 7 days) and resolves the applied trade
1021
- * or throws the chain's rejection. The first read happens immediately unless
1022
- * `initialDelayMs` is given.
1023
- *
1024
- * @example
1025
- * ```ts
1026
- * const applied = await swaps.confirmSwap('gswap-sdk-2f1c…');
1027
- * ```
1028
- */
1029
- confirmSwap(uniqueKey: string, options?: ConfirmOptions): Promise<AppliedTrade>;
1030
- private buildRequestTradeDto;
1027
+ export declare class Swaps {
1028
+ private readonly gateway;
1029
+ private readonly symbols;
1030
+ private readonly signer?;
1031
+ private readonly walletAddress?;
1032
+ /**
1033
+ * Creates a swap service.
1034
+ *
1035
+ * @example
1036
+ * ```ts
1037
+ * const swaps = new Swaps(gateway, symbols, signer, 'client|alice');
1038
+ * ```
1039
+ */
1040
+ constructor(gateway: SwapGateway, symbols: SwapSymbols, signer?: GalaChainSigner | undefined, walletAddress?: string | undefined);
1041
+ /**
1042
+ * Signs and submits an exact-input or exact-output RequestTrade DTO. The returned transaction
1043
+ * is QUEUED; call `await tx.confirm()` to obtain the executed trade or chain rejection.
1044
+ *
1045
+ * @example
1046
+ * ```ts
1047
+ * const submitted = await swaps.swap('GALA', 'GUSDC', 3000, {
1048
+ * exactIn: '100',
1049
+ * amountOutMinimum: '14',
1050
+ * });
1051
+ * ```
1052
+ */
1053
+ swap(tokenIn: TokenRef, tokenOut: TokenRef, fee: FEE_TIER, amount: SwapAmount): Promise<SubmittedTransaction<AppliedTrade>>;
1054
+ /**
1055
+ * Confirm a swap by its durable `uniqueKey` without resubmitting it. This is the recovery
1056
+ * path after a `CONFIRMATION_TIMEOUT`, a `SUBMISSION_OUTCOME_UNKNOWN`, a `409` replay
1057
+ * conflict, or a process restart: it reads the same apply-results record that
1058
+ * `SubmittedTransaction.confirm()` reads (retained for 7 days) and resolves the applied trade
1059
+ * or throws the chain's rejection. The first read happens immediately unless
1060
+ * `initialDelayMs` is given.
1061
+ *
1062
+ * @example
1063
+ * ```ts
1064
+ * const applied = await swaps.confirmSwap('gswap-sdk-2f1c…');
1065
+ * ```
1066
+ */
1067
+ confirmSwap(uniqueKey: string, options?: ConfirmOptions): Promise<AppliedTrade>;
1068
+ private buildRequestTradeDto;
1031
1069
  }
1032
-
1070
+ //#endregion
1071
+ //#region src/types/env.d.ts
1033
1072
  /** SDK deployment environment. */
1034
- type GSwapEnv = 'prod' | 'stage';
1073
+ export type GSwapEnv = 'prod' | 'stage';
1035
1074
  /** Backend URL used by one SDK deployment environment. */
1036
- interface GSwapEnvironmentConfig {
1037
- dexBackendBaseUrl: string;
1075
+ export interface GSwapEnvironmentConfig {
1076
+ dexBackendBaseUrl: string;
1038
1077
  }
1039
1078
  /** Built-in GalaSwap deployment environments. */
1040
- declare const GSWAP_ENVIRONMENTS: Readonly<Record<GSwapEnv, GSwapEnvironmentConfig>>;
1041
-
1079
+ export declare const GSWAP_ENVIRONMENTS: Readonly<Record<GSwapEnv, GSwapEnvironmentConfig>>;
1080
+ //#endregion
1081
+ //#region src/classes/gswap.d.ts
1042
1082
  /** Options for constructing a backend-routed SDK client. */
1043
- interface GSwapOptions {
1044
- signer?: GalaChainSigner | undefined;
1045
- walletAddress?: string | undefined;
1046
- env?: GSwapEnv | undefined;
1047
- dexBackendBaseUrl?: string | undefined;
1048
- httpRequestor?: HttpRequestor | undefined;
1049
- chainCallTimeoutMs?: number | undefined;
1083
+ export interface GSwapOptions {
1084
+ signer?: GalaChainSigner | undefined;
1085
+ walletAddress?: string | undefined;
1086
+ env?: GSwapEnv | undefined;
1087
+ dexBackendBaseUrl?: string | undefined;
1088
+ httpRequestor?: HttpRequestor | undefined;
1089
+ chainCallTimeoutMs?: number | undefined;
1050
1090
  }
1051
1091
  /** Main entry point for the current GalaChainDex SDK. */
1052
- declare class GSwap {
1053
- readonly dexBackendBaseUrl: string;
1054
- readonly chainCallTimeoutMs: number;
1055
- readonly signer: GalaChainSigner | undefined;
1056
- readonly walletAddress: string | undefined;
1057
- readonly gateway: ChainGateway;
1058
- readonly symbols: Symbols;
1059
- readonly quoting: Quoting;
1060
- readonly pools: Pools;
1061
- readonly positions: Positions;
1062
- readonly swaps: Swaps;
1063
- readonly assets: Assets;
1064
- /**
1065
- * Create an SDK client for prod or stage.
1066
- *
1067
- * @example
1068
- * ```typescript
1069
- * const gSwap = new GSwap({ env: 'stage' });
1070
- * const symbols = await gSwap.symbols.list();
1071
- * ```
1072
- */
1073
- constructor(options?: GSwapOptions);
1092
+ export declare class GSwap {
1093
+ readonly dexBackendBaseUrl: string;
1094
+ readonly chainCallTimeoutMs: number;
1095
+ readonly signer: GalaChainSigner | undefined;
1096
+ readonly walletAddress: string | undefined;
1097
+ readonly gateway: ChainGateway;
1098
+ readonly symbols: Symbols;
1099
+ readonly quoting: Quoting;
1100
+ readonly pools: Pools;
1101
+ readonly positions: Positions;
1102
+ readonly swaps: Swaps;
1103
+ readonly assets: Assets;
1104
+ /**
1105
+ * Create an SDK client for prod or stage.
1106
+ *
1107
+ * @example
1108
+ * ```typescript
1109
+ * const gSwap = new GSwap({ env: 'stage' });
1110
+ * const symbols = await gSwap.symbols.list();
1111
+ * ```
1112
+ */
1113
+ constructor(options?: GSwapOptions);
1074
1114
  }
1075
-
1115
+ //#endregion
1116
+ //#region src/classes/gswap_sdk_error.d.ts
1076
1117
  /** Error raised by the SDK for validation, gateway, chain, or transaction failures. */
1077
- declare class GSwapSDKError extends Error {
1078
- readonly code: string;
1079
- readonly details?: Record<string, unknown> | undefined;
1080
- readonly chainMessage: string | undefined;
1081
- readonly retryAfterMs: number | undefined;
1082
- constructor(message: string, code: string, details?: Record<string, unknown> | undefined, chainMessage?: string, retryAfterMs?: number);
1083
- /** Create the standard missing-signer error. */
1084
- static noSignerError(): GSwapSDKError;
1085
- /** Create the error used when confirming a position write without a configured wallet address. */
1086
- static noWalletAddressError(): GSwapSDKError;
1087
- /** Create the error used when no pool can quote the requested pair. */
1088
- static noPoolAvailableError(tokenIn: GalaChainTokenClassKey | string, tokenOut: GalaChainTokenClassKey | string, fee?: number): GSwapSDKError;
1089
- /** Create the error used when a pool lacks liquidity for a quote. */
1090
- static insufficientLiquidityError(tokenIn: GalaChainTokenClassKey | string, tokenOut: GalaChainTokenClassKey | string, fee?: number): GSwapSDKError;
1091
- /** Convert a chain-gateway bounce into a typed SDK error. */
1092
- static fromGatewayBounce(code: string, message: string, status: number, retryAfterMs?: number): GSwapSDKError;
1093
- /** Convert a GalaChain `Status: 0` response into a typed SDK error. */
1094
- static fromChainError(errorKey: string, message: string, details?: Record<string, unknown>): GSwapSDKError;
1095
- /** Create the error used when a token is not registered by the current DEX contract. */
1096
- static unknownTokenError(token: GalaChainTokenClassKey | string): GSwapSDKError;
1097
- /** Create the error used when apply-results confirmation does not arrive in time. */
1098
- static confirmationTimeoutError(uniqueKey: string, cause?: unknown): GSwapSDKError;
1099
- /** Convert an unexpected HTTP response into an SDK error. */
1100
- static fromErrorResponse(url: string, response: HTTPResponse): Promise<GSwapSDKError>;
1118
+ export declare class GSwapSDKError extends Error {
1119
+ readonly code: string;
1120
+ readonly details?: Record<string, unknown> | undefined;
1121
+ readonly chainMessage: string | undefined;
1122
+ readonly retryAfterMs: number | undefined;
1123
+ constructor(message: string, code: string, details?: Record<string, unknown> | undefined, chainMessage?: string, retryAfterMs?: number);
1124
+ /** Create the standard missing-signer error. */
1125
+ static noSignerError(): GSwapSDKError;
1126
+ /** Create the error used when confirming a position write without a configured wallet address. */
1127
+ static noWalletAddressError(): GSwapSDKError;
1128
+ /** Create the error used when no pool can quote the requested pair. */
1129
+ static noPoolAvailableError(tokenIn: GalaChainTokenClassKey | string, tokenOut: GalaChainTokenClassKey | string, fee?: number): GSwapSDKError;
1130
+ /** Create the error used when a pool lacks liquidity for a quote. */
1131
+ static insufficientLiquidityError(tokenIn: GalaChainTokenClassKey | string, tokenOut: GalaChainTokenClassKey | string, fee?: number): GSwapSDKError;
1132
+ /** Convert a chain-gateway bounce into a typed SDK error. */
1133
+ static fromGatewayBounce(code: string, message: string, status: number, retryAfterMs?: number): GSwapSDKError;
1134
+ /** Convert a GalaChain `Status: 0` response into a typed SDK error. */
1135
+ static fromChainError(errorKey: string, message: string, details?: Record<string, unknown>): GSwapSDKError;
1136
+ /** Create the error used when a token is not registered by the current DEX contract. */
1137
+ static unknownTokenError(token: GalaChainTokenClassKey | string): GSwapSDKError;
1138
+ /** Create the error used when apply-results confirmation does not arrive in time. */
1139
+ static confirmationTimeoutError(uniqueKey: string, cause?: unknown): GSwapSDKError;
1140
+ /** Convert an unexpected HTTP response into an SDK error. */
1141
+ static fromErrorResponse(url: string, response: HTTPResponse): Promise<GSwapSDKError>;
1101
1142
  }
1102
1143
  /** Narrow an object property without trusting a cast at a network boundary. */
1103
- declare function getObjectProperty(value: unknown, property: string): Record<string, unknown> | undefined;
1144
+ export declare function getObjectProperty(value: unknown, property: string): Record<string, unknown> | undefined;
1104
1145
  /** Read a string property from an unknown object. */
1105
- declare function getStringProperty(value: unknown, property: string): string | undefined;
1146
+ export declare function getStringProperty(value: unknown, property: string): string | undefined;
1106
1147
  /** Parse a response body, preserving non-JSON text for error reporting. */
1107
- declare function parseJson(text: string): unknown;
1108
-
1148
+ export declare function parseJson(text: string): unknown;
1149
+ //#endregion
1150
+ //#region src/types/v2_dtos.d.ts
1109
1151
  /** Common identity fields for v2 pool writes. */
1110
- interface V2PoolWriteBase {
1111
- token0: string;
1112
- token1: string;
1113
- fee: FEE_TIER;
1114
- uniqueKey: string;
1152
+ export interface V2PoolWriteBase {
1153
+ token0: string;
1154
+ token1: string;
1155
+ fee: FEE_TIER;
1156
+ uniqueKey: string;
1115
1157
  }
1116
1158
  /** A v2 RequestTrade with exactly one selected trade-side quantity. */
1117
- type RequestTradeDTO = V2PoolWriteBase & ({
1118
- sell0Qty: string;
1119
- sell1Qty?: never;
1120
- buy0Qty?: never;
1121
- buy1Qty?: never;
1159
+ export type RequestTradeDTO = V2PoolWriteBase & ({
1160
+ sell0Qty: string;
1161
+ sell1Qty?: never;
1162
+ buy0Qty?: never;
1163
+ buy1Qty?: never;
1122
1164
  } | {
1123
- sell0Qty?: never;
1124
- sell1Qty: string;
1125
- buy0Qty?: never;
1126
- buy1Qty?: never;
1165
+ sell0Qty?: never;
1166
+ sell1Qty: string;
1167
+ buy0Qty?: never;
1168
+ buy1Qty?: never;
1127
1169
  } | {
1128
- sell0Qty?: never;
1129
- sell1Qty?: never;
1130
- buy0Qty: string;
1131
- buy1Qty?: never;
1170
+ sell0Qty?: never;
1171
+ sell1Qty?: never;
1172
+ buy0Qty: string;
1173
+ buy1Qty?: never;
1132
1174
  } | {
1133
- sell0Qty?: never;
1134
- sell1Qty?: never;
1135
- buy0Qty?: never;
1136
- buy1Qty: string;
1175
+ sell0Qty?: never;
1176
+ sell1Qty?: never;
1177
+ buy0Qty?: never;
1178
+ buy1Qty: string;
1137
1179
  }) & {
1138
- amountOutMinimum?: string | undefined;
1139
- amountInMaximum?: string | undefined;
1180
+ amountOutMinimum?: string | undefined;
1181
+ amountInMaximum?: string | undefined;
1140
1182
  };
1141
1183
  /** A v2 liquidity deposit with exactly one selected deposit quantity. */
1142
- type AddLiquidityDTO = V2PoolWriteBase & {
1143
- tickLower: number;
1144
- tickUpper: number;
1184
+ export type AddLiquidityDTO = V2PoolWriteBase & {
1185
+ tickLower: number;
1186
+ tickUpper: number;
1145
1187
  } & ({
1146
- depositQuantityToken0: string;
1147
- depositQuantityToken1?: never;
1188
+ depositQuantityToken0: string;
1189
+ depositQuantityToken1?: never;
1148
1190
  } | {
1149
- depositQuantityToken0?: never;
1150
- depositQuantityToken1: string;
1191
+ depositQuantityToken0?: never;
1192
+ depositQuantityToken1: string;
1151
1193
  });
1152
1194
  /** A v2 liquidity withdrawal; omitting both quantities closes the position. */
1153
- type RemoveLiquidityDTO = V2PoolWriteBase & {
1154
- tickLower: number;
1155
- tickUpper: number;
1195
+ export type RemoveLiquidityDTO = V2PoolWriteBase & {
1196
+ tickLower: number;
1197
+ tickUpper: number;
1156
1198
  } & ({
1157
- withdrawalQuantityToken0: string;
1158
- withdrawalQuantityToken1?: never;
1199
+ withdrawalQuantityToken0: string;
1200
+ withdrawalQuantityToken1?: never;
1159
1201
  } | {
1160
- withdrawalQuantityToken0?: never;
1161
- withdrawalQuantityToken1: string;
1202
+ withdrawalQuantityToken0?: never;
1203
+ withdrawalQuantityToken1: string;
1162
1204
  } | {
1163
- withdrawalQuantityToken0?: never;
1164
- withdrawalQuantityToken1?: never;
1205
+ withdrawalQuantityToken0?: never;
1206
+ withdrawalQuantityToken1?: never;
1165
1207
  });
1166
1208
  /** A v2 request to sweep all fees from one position. */
1167
- interface CollectPositionFeesDTO extends V2PoolWriteBase {
1168
- tickLower: number;
1169
- tickUpper: number;
1209
+ export interface CollectPositionFeesDTO extends V2PoolWriteBase {
1210
+ tickLower: number;
1211
+ tickUpper: number;
1170
1212
  }
1171
1213
  /** A v2 pool creation request with exactly one initial-price representation. */
1172
- type CreatePoolDTO = {
1173
- token0Key: GalaChainTokenClassKey;
1174
- token1Key: GalaChainTokenClassKey;
1175
- token0Symbol: string;
1176
- token1Symbol: string;
1177
- fee: FEE_TIER;
1178
- isPrivate?: boolean | undefined;
1179
- privateAccess?: string[] | undefined;
1180
- uniqueKey: string;
1214
+ export type CreatePoolDTO = {
1215
+ token0Key: GalaChainTokenClassKey;
1216
+ token1Key: GalaChainTokenClassKey;
1217
+ token0Symbol: string;
1218
+ token1Symbol: string;
1219
+ fee: FEE_TIER;
1220
+ isPrivate?: boolean | undefined;
1221
+ privateAccess?: string[] | undefined;
1222
+ uniqueKey: string;
1181
1223
  } & ({
1182
- startingPrice: string;
1183
- startingSqrtPrice?: never;
1224
+ startingPrice: string;
1225
+ startingSqrtPrice?: never;
1184
1226
  } | {
1185
- startingPrice?: never;
1186
- startingSqrtPrice: string;
1227
+ startingPrice?: never;
1228
+ startingSqrtPrice: string;
1187
1229
  });
1188
1230
  /** Optional page cursor accepted by chain read methods. */
1189
- interface PageDTO {
1190
- limit?: number | undefined;
1191
- bookmark?: string | undefined;
1231
+ export interface PageDTO {
1232
+ limit?: number | undefined;
1233
+ bookmark?: string | undefined;
1192
1234
  }
1193
1235
  /** Fetch all registered trading symbols. */
1194
- type FetchTokenTradingSymbolsDTO = PageDTO;
1236
+ export type FetchTokenTradingSymbolsDTO = PageDTO;
1195
1237
  /** Fetch a composite pool snapshot. */
1196
- interface FetchCompositePoolDataDTO {
1197
- token0: string;
1198
- token1: string;
1199
- fee: FEE_TIER;
1238
+ export interface FetchCompositePoolDataDTO {
1239
+ token0: string;
1240
+ token1: string;
1241
+ fee: FEE_TIER;
1200
1242
  }
1201
1243
  /** Fetch one current trading price, or all prices when no pair is supplied. */
1202
- type FetchCurrentTradingPricesDTO = Partial<FetchCompositePoolDataDTO> & PageDTO;
1244
+ export type FetchCurrentTradingPricesDTO = Partial<FetchCompositePoolDataDTO> & PageDTO;
1203
1245
  /** Fetch pools, optionally narrowed to one pair and paged. */
1204
- type FetchPoolsDTO = Partial<FetchCompositePoolDataDTO> & PageDTO;
1246
+ export type FetchPoolsDTO = Partial<FetchCompositePoolDataDTO> & PageDTO;
1205
1247
  /** Fetch all liquidity positions, optionally narrowed to a pool reference. */
1206
- interface FetchLiquidityPositionsDTO extends PageDTO {
1207
- pool?: string | undefined;
1248
+ export interface FetchLiquidityPositionsDTO extends PageDTO {
1249
+ pool?: string | undefined;
1208
1250
  }
1209
-
1251
+ //#endregion
1252
+ //#region src/utils/ticks.d.ts
1210
1253
  /** Minimum tick supported by GalaChainDex. */
1211
- declare const GC_MIN_TICK = -887272;
1254
+ export declare const GC_MIN_TICK = -887272;
1212
1255
  /** Maximum tick supported by GalaChainDex. */
1213
- declare const GC_MAX_TICK = 887272;
1256
+ export declare const GC_MAX_TICK = 887272;
1214
1257
  /** Convert a tick to the corresponding square-root price. */
1215
- declare function tickToSqrtPrice(tick: number): BigNumber;
1258
+ export declare function tickToSqrtPrice(tick: number): BigNumber;
1216
1259
  /** Return the greatest tick whose square-root price is no greater than the input. */
1217
- declare function sqrtPriceToTick(sqrtPrice: BigNumber.Value): number;
1260
+ export declare function sqrtPriceToTick(sqrtPrice: BigNumber.Value): number;
1218
1261
  /** Return the greatest integer tick whose token1/token0 price is no greater than `price`. */
1219
- declare function tickFromPrice(price: BigNumber.Value): number;
1262
+ export declare function tickFromPrice(price: BigNumber.Value): number;
1220
1263
  /** Align a tick down to the nearest multiple of a positive spacing. */
1221
- declare function alignTickDown(tick: number, spacing: number): number;
1264
+ export declare function alignTickDown(tick: number, spacing: number): number;
1222
1265
  /** Align a tick up to the nearest multiple of a positive spacing. */
1223
- declare function alignTickUp(tick: number, spacing: number): number;
1266
+ export declare function alignTickUp(tick: number, spacing: number): number;
1224
1267
  /** Validate a position range against the global tick bounds and fee-tier spacing. */
1225
- declare function assertTickRange(lower: number, upper: number, fee: FEE_TIER): void;
1226
-
1227
- declare function validateNumericAmount(amount: NumericAmount, parameterName: string, allowZero?: boolean): void;
1228
- declare function validatePriceValues(spotPrice: NumericAmount, lowerPrice: NumericAmount, upperPrice: NumericAmount): void;
1229
- declare function validateTokenDecimals(decimals: number, parameterName: string): void;
1230
- declare function validateTickRange(tickLower: number, tickUpper: number): void;
1231
- declare function validateFee(fee: number): asserts fee is FEE_TIER;
1232
- declare function validateTickSpacing(tickSpacing: number): void;
1233
- declare function validateWalletAddress(address?: string): asserts address is string;
1234
-
1235
- export { ALL_FEE_TIERS, type AddLiquidityDTO, type AddLiquidityEstimate, type AppliedTrade, Assets, type BrowserWalletProvider, BrowserWalletSigner, ChainGateway, type ChainGatewayOptions, type ChainSubmissionResult, type ChainSubmitOptions, type CollectPositionFeesDTO, type CompositePool, type ConfirmOptions, type CreatePoolDTO, FEE_TIER, type FetchCompositePoolDataDTO, type FetchCurrentTradingPricesDTO, type FetchLiquidityPositionsDTO, type FetchPoolsDTO, type FetchTokenTradingSymbolsDTO, GC_MAX_TICK, GC_MIN_TICK, GSWAP_ENVIRONMENTS, GSwap, type GSwapEnv, type GSwapEnvironmentConfig, type GSwapOptions, GSwapSDKError, type GalaChainSigner, type GalaChainTokenClassKey, type GalaWalletScheme, GalaWalletSigner, type NumericAmount, type PageDTO, type PoolInfo, type PoolListInfo, Pools, type Position, type PositionConfirmationResult, Positions, type Price, type PriceIn, PrivateKeySigner, type QuoteResult, Quoting, type RemoveLiquidityDTO, type RemoveLiquidityEstimate, type RequestTradeDTO, type Slot0, type SqrtPrice, type SqrtPriceIn, SubmittedTransaction, type SwapAmount, Swaps, Symbols, TICK_SPACING_BY_FEE, type TokenBalance, type TokenClassKey, type TokenRef, type TradeExecution, type TradingSymbol, type UserAsset, type UserAssetsResult, type V2PoolWriteBase, alignTickDown, alignTickUp, assertTickRange, compositeKeyOf, getObjectProperty, getStringProperty, orderSymbols, parseJson, parseTokenClassKey, readOrderedSymbols, sqrtPriceToTick, tickFromPrice, tickToSqrtPrice, validateFee, validateNumericAmount, validatePriceValues, validateTickRange, validateTickSpacing, validateTokenDecimals, validateWalletAddress };
1268
+ export declare function assertTickRange(lower: number, upper: number, fee: FEE_TIER): void;
1269
+ //#endregion
1270
+ //#region src/utils/validation.d.ts
1271
+ export declare function validateNumericAmount(amount: NumericAmount, parameterName: string, allowZero?: boolean): void;
1272
+ export declare function validatePriceValues(spotPrice: NumericAmount, lowerPrice: NumericAmount, upperPrice: NumericAmount): void;
1273
+ export declare function validateTokenDecimals(decimals: number, parameterName: string): void;
1274
+ export declare function validateTickRange(tickLower: number, tickUpper: number): void;
1275
+ export declare function validateFee(fee: number): asserts fee is FEE_TIER;
1276
+ export declare function validateTickSpacing(tickSpacing: number): void;
1277
+ export declare function validateWalletAddress(address?: string): asserts address is string;
1278
+ //#endregion
1279
+ //# sourceMappingURL=index.d.cts.map