@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/browser/index.js +4 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/index.cjs +2269 -2371
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1072 -1028
- package/dist/index.d.ts +1072 -1028
- package/dist/index.mjs +2210 -2305
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,330 +1,334 @@
|
|
|
1
|
-
import BigNumber from
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
176
|
-
|
|
174
|
+
export interface UserAssetsResult {
|
|
175
|
+
tokens: UserAsset[];
|
|
176
|
+
count: number;
|
|
177
177
|
}
|
|
178
178
|
/** Backend add-liquidity estimate. */
|
|
179
|
-
interface AddLiquidityEstimate {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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
|
-
|
|
265
|
-
|
|
267
|
+
export type PositionConfirmationResult = {
|
|
268
|
+
confirmed: true;
|
|
269
|
+
position: Position | null;
|
|
266
270
|
} | {
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
354
|
-
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
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
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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
|
-
|
|
411
|
-
|
|
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
|
-
/**
|
|
416
|
-
|
|
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
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
-
|
|
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
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
-
|
|
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
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
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
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
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
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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
|
-
|
|
708
|
+
_type: BrandT;
|
|
684
709
|
}
|
|
685
710
|
type Brand<T, BrandT> = T & Branding<BrandT>;
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
type
|
|
689
|
-
type
|
|
690
|
-
type
|
|
691
|
-
type
|
|
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
|
-
|
|
695
|
-
|
|
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
|
-
|
|
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
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
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
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
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
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1014
|
+
exactIn?: undefined;
|
|
1015
|
+
exactOut: NumericAmount;
|
|
1016
|
+
amountOutMinimum?: undefined;
|
|
1017
|
+
amountInMaximum?: NumericAmount | undefined;
|
|
980
1018
|
};
|
|
981
1019
|
interface SwapGateway {
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
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
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
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
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
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
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
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
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1159
|
+
export type RequestTradeDTO = V2PoolWriteBase & ({
|
|
1160
|
+
sell0Qty: string;
|
|
1161
|
+
sell1Qty?: never;
|
|
1162
|
+
buy0Qty?: never;
|
|
1163
|
+
buy1Qty?: never;
|
|
1122
1164
|
} | {
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1165
|
+
sell0Qty?: never;
|
|
1166
|
+
sell1Qty: string;
|
|
1167
|
+
buy0Qty?: never;
|
|
1168
|
+
buy1Qty?: never;
|
|
1127
1169
|
} | {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1170
|
+
sell0Qty?: never;
|
|
1171
|
+
sell1Qty?: never;
|
|
1172
|
+
buy0Qty: string;
|
|
1173
|
+
buy1Qty?: never;
|
|
1132
1174
|
} | {
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1175
|
+
sell0Qty?: never;
|
|
1176
|
+
sell1Qty?: never;
|
|
1177
|
+
buy0Qty?: never;
|
|
1178
|
+
buy1Qty: string;
|
|
1137
1179
|
}) & {
|
|
1138
|
-
|
|
1139
|
-
|
|
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
|
-
|
|
1144
|
-
|
|
1184
|
+
export type AddLiquidityDTO = V2PoolWriteBase & {
|
|
1185
|
+
tickLower: number;
|
|
1186
|
+
tickUpper: number;
|
|
1145
1187
|
} & ({
|
|
1146
|
-
|
|
1147
|
-
|
|
1188
|
+
depositQuantityToken0: string;
|
|
1189
|
+
depositQuantityToken1?: never;
|
|
1148
1190
|
} | {
|
|
1149
|
-
|
|
1150
|
-
|
|
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
|
-
|
|
1155
|
-
|
|
1195
|
+
export type RemoveLiquidityDTO = V2PoolWriteBase & {
|
|
1196
|
+
tickLower: number;
|
|
1197
|
+
tickUpper: number;
|
|
1156
1198
|
} & ({
|
|
1157
|
-
|
|
1158
|
-
|
|
1199
|
+
withdrawalQuantityToken0: string;
|
|
1200
|
+
withdrawalQuantityToken1?: never;
|
|
1159
1201
|
} | {
|
|
1160
|
-
|
|
1161
|
-
|
|
1202
|
+
withdrawalQuantityToken0?: never;
|
|
1203
|
+
withdrawalQuantityToken1: string;
|
|
1162
1204
|
} | {
|
|
1163
|
-
|
|
1164
|
-
|
|
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
|
-
|
|
1169
|
-
|
|
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
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
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
|
-
|
|
1183
|
-
|
|
1224
|
+
startingPrice: string;
|
|
1225
|
+
startingSqrtPrice?: never;
|
|
1184
1226
|
} | {
|
|
1185
|
-
|
|
1186
|
-
|
|
1227
|
+
startingPrice?: never;
|
|
1228
|
+
startingSqrtPrice: string;
|
|
1187
1229
|
});
|
|
1188
1230
|
/** Optional page cursor accepted by chain read methods. */
|
|
1189
|
-
interface PageDTO {
|
|
1190
|
-
|
|
1191
|
-
|
|
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
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1228
|
-
declare function
|
|
1229
|
-
declare function
|
|
1230
|
-
declare function
|
|
1231
|
-
declare function
|
|
1232
|
-
declare function
|
|
1233
|
-
declare function
|
|
1234
|
-
|
|
1235
|
-
|
|
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
|