@provable-games/ekubo-sdk 0.1.0 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +199 -0
- package/dist/client-DPSUVYSv.d.cts +659 -0
- package/dist/client-DPSUVYSv.d.ts +659 -0
- package/dist/index.d.cts +3 -658
- package/dist/index.d.ts +3 -658
- package/dist/react.cjs +2132 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +403 -0
- package/dist/react.d.ts +403 -0
- package/dist/react.js +2122 -0
- package/dist/react.js.map +1 -0
- package/package.json +18 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,426 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
interface PoolKey {
|
|
5
|
-
token0: string;
|
|
6
|
-
token1: string;
|
|
7
|
-
fee: string;
|
|
8
|
-
tick_spacing: number;
|
|
9
|
-
extension: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* A single hop in a swap route through one pool
|
|
13
|
-
*/
|
|
14
|
-
interface RouteNode {
|
|
15
|
-
pool_key: PoolKey;
|
|
16
|
-
sqrt_ratio_limit: string;
|
|
17
|
-
skip_ahead: number;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A split in a multi-route swap, representing one path through liquidity pools
|
|
21
|
-
*/
|
|
22
|
-
interface SwapSplit {
|
|
23
|
-
amount_specified: string;
|
|
24
|
-
route: RouteNode[];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A complete swap quote from the Ekubo API
|
|
28
|
-
*/
|
|
29
|
-
interface SwapQuote {
|
|
30
|
-
/** Price impact as a decimal (e.g., 0.01 = 1%) */
|
|
31
|
-
impact: number;
|
|
32
|
-
/** Total amount to send or receive (always positive) */
|
|
33
|
-
total: bigint;
|
|
34
|
-
/** Individual route splits for multi-path swaps */
|
|
35
|
-
splits: SwapSplit[];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Raw API response format (before transformation)
|
|
39
|
-
*/
|
|
40
|
-
interface SwapQuoteApiResponse {
|
|
41
|
-
price_impact: number;
|
|
42
|
-
total_calculated: string | number;
|
|
43
|
-
splits: SwapSplit[];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Error response from the Ekubo API
|
|
47
|
-
*/
|
|
48
|
-
interface SwapQuoteErrorResponse {
|
|
49
|
-
error: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Token information for registry and resolution
|
|
54
|
-
*/
|
|
55
|
-
interface TokenInfo {
|
|
56
|
-
/** Token symbol (e.g., "ETH", "STRK") */
|
|
57
|
-
symbol: string;
|
|
58
|
-
/** Contract address (hex string) */
|
|
59
|
-
address: string;
|
|
60
|
-
/** Token decimals (default: 18) */
|
|
61
|
-
decimals?: number;
|
|
62
|
-
/** Human-readable name */
|
|
63
|
-
name?: string;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Configuration for fetch operations with retry logic
|
|
68
|
-
*/
|
|
69
|
-
interface FetchConfig {
|
|
70
|
-
/** Request timeout in milliseconds (default: 10000) */
|
|
71
|
-
timeout?: number;
|
|
72
|
-
/** Maximum number of retry attempts (default: 3) */
|
|
73
|
-
maxRetries?: number;
|
|
74
|
-
/** Base backoff delay in milliseconds (default: 1000) */
|
|
75
|
-
baseBackoff?: number;
|
|
76
|
-
/** Maximum backoff delay in milliseconds (default: 5000) */
|
|
77
|
-
maxBackoff?: number;
|
|
78
|
-
/** Custom fetch function (for SSR or custom implementations) */
|
|
79
|
-
fetch?: typeof globalThis.fetch;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Configuration for quote polling
|
|
83
|
-
*/
|
|
84
|
-
interface PollingConfig {
|
|
85
|
-
/** Polling interval in milliseconds (default: 5000) */
|
|
86
|
-
interval?: number;
|
|
87
|
-
/** Maximum consecutive errors before auto-stopping (default: 3) */
|
|
88
|
-
maxConsecutiveErrors?: number;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Main configuration for EkuboClient
|
|
92
|
-
*/
|
|
93
|
-
interface EkuboClientConfig {
|
|
94
|
-
/** Chain shorthand: 'mainnet' or 'sepolia' */
|
|
95
|
-
chain?: "mainnet" | "sepolia";
|
|
96
|
-
/** Custom chain ID (overrides chain setting) */
|
|
97
|
-
chainId?: string;
|
|
98
|
-
/** Custom quoter API URL (for swap quotes) */
|
|
99
|
-
quoterApiUrl?: string;
|
|
100
|
-
/** Custom API URL (for tokens, prices, stats, etc.) */
|
|
101
|
-
apiUrl?: string;
|
|
102
|
-
/** Custom router contract address */
|
|
103
|
-
routerAddress?: string;
|
|
104
|
-
/** Default slippage percentage as bigint (default: 5n = 5%) */
|
|
105
|
-
defaultSlippagePercent?: bigint;
|
|
106
|
-
/** Fetch configuration */
|
|
107
|
-
fetch?: FetchConfig;
|
|
108
|
-
/** Polling configuration */
|
|
109
|
-
polling?: PollingConfig;
|
|
110
|
-
/** Additional custom tokens to register */
|
|
111
|
-
customTokens?: TokenInfo[];
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Resolved configuration with all defaults applied
|
|
115
|
-
*/
|
|
116
|
-
interface ResolvedConfig {
|
|
117
|
-
chainId: string;
|
|
118
|
-
quoterApiUrl: string;
|
|
119
|
-
apiUrl: string;
|
|
120
|
-
routerAddress: string;
|
|
121
|
-
defaultSlippagePercent: bigint;
|
|
122
|
-
fetch: Required<FetchConfig>;
|
|
123
|
-
polling: Required<PollingConfig>;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* A single Starknet call (compatible with starknet.js Call type)
|
|
128
|
-
*/
|
|
129
|
-
interface SwapCall {
|
|
130
|
-
contractAddress: string;
|
|
131
|
-
entrypoint: string;
|
|
132
|
-
calldata: string[];
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Result of swap call generation
|
|
136
|
-
*/
|
|
137
|
-
interface SwapCallsResult {
|
|
138
|
-
/** Transfer call to send tokens to router */
|
|
139
|
-
transferCall: SwapCall;
|
|
140
|
-
/** Swap execution calls */
|
|
141
|
-
swapCalls: SwapCall[];
|
|
142
|
-
/** Clear remaining tokens call */
|
|
143
|
-
clearCall: SwapCall;
|
|
144
|
-
/** All calls in execution order */
|
|
145
|
-
allCalls: SwapCall[];
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Parameters for fetching a swap quote
|
|
149
|
-
*/
|
|
150
|
-
interface FetchQuoteParams {
|
|
151
|
-
/** Amount to swap (in smallest unit) */
|
|
152
|
-
amount: bigint;
|
|
153
|
-
/** Token to sell (address or symbol) */
|
|
154
|
-
tokenFrom: string;
|
|
155
|
-
/** Token to buy (address or symbol) */
|
|
156
|
-
tokenTo: string;
|
|
157
|
-
/** Optional abort signal for cancellation */
|
|
158
|
-
signal?: AbortSignal;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Price history data point
|
|
163
|
-
*/
|
|
164
|
-
interface PriceDataPoint {
|
|
165
|
-
timestamp: number;
|
|
166
|
-
price: number;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Price history response
|
|
170
|
-
*/
|
|
171
|
-
interface PriceHistoryResponse {
|
|
172
|
-
data: PriceDataPoint[];
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Parameters for getPriceHistory
|
|
176
|
-
*/
|
|
177
|
-
interface GetPriceHistoryParams {
|
|
178
|
-
/** Token to get price for */
|
|
179
|
-
token: string;
|
|
180
|
-
/** Quote token (e.g., USDC) */
|
|
181
|
-
otherToken: string;
|
|
182
|
-
/** Chain ID (Ekubo format) */
|
|
183
|
-
chainId?: string;
|
|
184
|
-
/** Time interval in seconds */
|
|
185
|
-
interval?: number;
|
|
186
|
-
/** API base URL */
|
|
187
|
-
apiUrl?: string;
|
|
188
|
-
/** Fetch configuration */
|
|
189
|
-
fetchConfig?: FetchConfig;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Fetch price history from Ekubo API
|
|
193
|
-
*/
|
|
194
|
-
declare function getPriceHistory(params: GetPriceHistoryParams): Promise<PriceHistoryResponse>;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Token metadata from Ekubo API
|
|
198
|
-
*/
|
|
199
|
-
interface ApiTokenInfo {
|
|
200
|
-
/** Token contract address */
|
|
201
|
-
address: string;
|
|
202
|
-
/** Token name */
|
|
203
|
-
name: string;
|
|
204
|
-
/** Token symbol */
|
|
205
|
-
symbol: string;
|
|
206
|
-
/** Token decimals */
|
|
207
|
-
decimals: number;
|
|
208
|
-
/** Logo URI (optional) */
|
|
209
|
-
logo_uri?: string;
|
|
210
|
-
/** Whether token is verified/trusted */
|
|
211
|
-
verified?: boolean;
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Parameters for fetching tokens
|
|
215
|
-
*/
|
|
216
|
-
interface FetchTokensParams {
|
|
217
|
-
/** Chain ID (Ekubo format) */
|
|
218
|
-
chainId?: string;
|
|
219
|
-
/** API base URL */
|
|
220
|
-
apiUrl?: string;
|
|
221
|
-
/** Fetch configuration */
|
|
222
|
-
fetchConfig?: FetchConfig;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Parameters for fetching a single token
|
|
226
|
-
*/
|
|
227
|
-
interface FetchTokenParams extends FetchTokensParams {
|
|
228
|
-
/** Token contract address */
|
|
229
|
-
tokenAddress: string;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Parameters for batch fetching tokens
|
|
233
|
-
*/
|
|
234
|
-
interface FetchTokensBatchParams extends FetchTokensParams {
|
|
235
|
-
/** Token contract addresses */
|
|
236
|
-
tokenAddresses: string[];
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* Fetch list of all tokens for a chain
|
|
240
|
-
*/
|
|
241
|
-
declare function fetchTokens(params?: FetchTokensParams): Promise<ApiTokenInfo[]>;
|
|
242
|
-
/**
|
|
243
|
-
* Fetch metadata for a single token
|
|
244
|
-
*/
|
|
245
|
-
declare function fetchToken(params: FetchTokenParams): Promise<ApiTokenInfo | null>;
|
|
246
|
-
/**
|
|
247
|
-
* Fetch metadata for multiple tokens at once
|
|
248
|
-
*/
|
|
249
|
-
declare function fetchTokensBatch(params: FetchTokensBatchParams): Promise<ApiTokenInfo[]>;
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Trading pair statistics
|
|
253
|
-
*/
|
|
254
|
-
interface PairStats {
|
|
255
|
-
token0: string;
|
|
256
|
-
token1: string;
|
|
257
|
-
tvl_usd: number;
|
|
258
|
-
volume_24h_usd: number;
|
|
259
|
-
fees_24h_usd: number;
|
|
260
|
-
price: number;
|
|
261
|
-
price_change_24h: number;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Overview statistics response
|
|
265
|
-
*/
|
|
266
|
-
interface OverviewStats {
|
|
267
|
-
tvl_usd: number;
|
|
268
|
-
volume_24h_usd: number;
|
|
269
|
-
fees_24h_usd: number;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Pool information
|
|
273
|
-
*/
|
|
274
|
-
interface PoolInfo {
|
|
275
|
-
key_hash: string;
|
|
276
|
-
token0: string;
|
|
277
|
-
token1: string;
|
|
278
|
-
fee: string;
|
|
279
|
-
tick_spacing: number;
|
|
280
|
-
extension: string;
|
|
281
|
-
tvl_usd: number;
|
|
282
|
-
volume_24h_usd: number;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* TVL data point
|
|
286
|
-
*/
|
|
287
|
-
interface TvlDataPoint {
|
|
288
|
-
timestamp: number;
|
|
289
|
-
tvl_usd: number;
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Volume data point
|
|
293
|
-
*/
|
|
294
|
-
interface VolumeDataPoint {
|
|
295
|
-
timestamp: number;
|
|
296
|
-
volume_usd: number;
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Base parameters for stats API calls
|
|
300
|
-
*/
|
|
301
|
-
interface StatsBaseParams {
|
|
302
|
-
/** Chain ID (Ekubo format) */
|
|
303
|
-
chainId?: string;
|
|
304
|
-
/** API base URL */
|
|
305
|
-
apiUrl?: string;
|
|
306
|
-
/** Fetch configuration */
|
|
307
|
-
fetchConfig?: FetchConfig;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Parameters for pair-specific queries
|
|
311
|
-
*/
|
|
312
|
-
interface PairStatsParams extends StatsBaseParams {
|
|
313
|
-
/** First token address */
|
|
314
|
-
tokenA: string;
|
|
315
|
-
/** Second token address */
|
|
316
|
-
tokenB: string;
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Fetch overview of top trading pairs
|
|
320
|
-
*/
|
|
321
|
-
declare function fetchTopPairs(params?: StatsBaseParams): Promise<PairStats[]>;
|
|
322
|
-
/**
|
|
323
|
-
* Fetch protocol TVL overview
|
|
324
|
-
*/
|
|
325
|
-
declare function fetchTvl(params?: StatsBaseParams): Promise<OverviewStats>;
|
|
326
|
-
/**
|
|
327
|
-
* Fetch protocol volume overview
|
|
328
|
-
*/
|
|
329
|
-
declare function fetchVolume(params?: StatsBaseParams): Promise<OverviewStats>;
|
|
330
|
-
/**
|
|
331
|
-
* Fetch TVL for a specific trading pair
|
|
332
|
-
*/
|
|
333
|
-
declare function fetchPairTvl(params: PairStatsParams): Promise<TvlDataPoint[]>;
|
|
334
|
-
/**
|
|
335
|
-
* Fetch volume for a specific trading pair
|
|
336
|
-
*/
|
|
337
|
-
declare function fetchPairVolume(params: PairStatsParams): Promise<VolumeDataPoint[]>;
|
|
338
|
-
/**
|
|
339
|
-
* Fetch pools for a specific trading pair
|
|
340
|
-
*/
|
|
341
|
-
declare function fetchPairPools(params: PairStatsParams): Promise<PoolInfo[]>;
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Parameters for generating swap calls
|
|
345
|
-
*/
|
|
346
|
-
interface GenerateSwapCallsParams {
|
|
347
|
-
/** Token being sold (address) */
|
|
348
|
-
sellToken: string;
|
|
349
|
-
/** Token being bought (address) */
|
|
350
|
-
buyToken: string;
|
|
351
|
-
/** Minimum amount of buyToken to receive */
|
|
352
|
-
minimumReceived: bigint;
|
|
353
|
-
/** Quote from Ekubo API */
|
|
354
|
-
quote: SwapQuote;
|
|
355
|
-
/** Chain ID (Ekubo format) */
|
|
356
|
-
chainId?: string;
|
|
357
|
-
/** Router contract address (overrides chainId lookup) */
|
|
358
|
-
routerAddress?: string;
|
|
359
|
-
/** Slippage percentage for transfer amount (default: 5n = 5%) */
|
|
360
|
-
slippagePercent?: bigint;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Generate swap calls for Ekubo router
|
|
364
|
-
*
|
|
365
|
-
* This generates the calls needed to execute a swap:
|
|
366
|
-
* 1. Transfer tokens to router
|
|
367
|
-
* 2. Execute multihop_swap or multi_multihop_swap
|
|
368
|
-
* 3. Clear minimum profits
|
|
369
|
-
* 4. Clear remaining tokens
|
|
370
|
-
*/
|
|
371
|
-
declare function generateSwapCalls(params: GenerateSwapCallsParams): SwapCallsResult;
|
|
372
|
-
/**
|
|
373
|
-
* Prepare swap calls with approval included
|
|
374
|
-
* This is a convenience wrapper that adds the ERC20 approve call
|
|
375
|
-
*/
|
|
376
|
-
declare function prepareSwapCalls(params: GenerateSwapCallsParams): SwapCallsResult & {
|
|
377
|
-
approveCall: SwapCall;
|
|
378
|
-
};
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Token registry for managing token information and symbol-to-address resolution
|
|
382
|
-
*/
|
|
383
|
-
declare class TokenRegistry {
|
|
384
|
-
private symbolMap;
|
|
385
|
-
private addressMap;
|
|
386
|
-
constructor(tokens?: TokenInfo[]);
|
|
387
|
-
/**
|
|
388
|
-
* Register a token
|
|
389
|
-
*/
|
|
390
|
-
register(token: TokenInfo): void;
|
|
391
|
-
/**
|
|
392
|
-
* Get token by symbol (case-insensitive)
|
|
393
|
-
*/
|
|
394
|
-
getBySymbol(symbol: string): TokenInfo | undefined;
|
|
395
|
-
/**
|
|
396
|
-
* Get token by address (normalized)
|
|
397
|
-
*/
|
|
398
|
-
getByAddress(address: string): TokenInfo | undefined;
|
|
399
|
-
/**
|
|
400
|
-
* Check if a token exists by symbol
|
|
401
|
-
*/
|
|
402
|
-
hasSymbol(symbol: string): boolean;
|
|
403
|
-
/**
|
|
404
|
-
* Check if a token exists by address
|
|
405
|
-
*/
|
|
406
|
-
hasAddress(address: string): boolean;
|
|
407
|
-
/**
|
|
408
|
-
* Get all registered tokens
|
|
409
|
-
*/
|
|
410
|
-
getAll(): TokenInfo[];
|
|
411
|
-
/**
|
|
412
|
-
* Get all registered symbols
|
|
413
|
-
*/
|
|
414
|
-
getSymbols(): string[];
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* Get the default token registry (singleton)
|
|
418
|
-
*/
|
|
419
|
-
declare function getDefaultRegistry(): TokenRegistry;
|
|
420
|
-
/**
|
|
421
|
-
* Create a new token registry with custom tokens
|
|
422
|
-
*/
|
|
423
|
-
declare function createTokenRegistry(customTokens?: TokenInfo[]): TokenRegistry;
|
|
1
|
+
import { T as TokenRegistry, a as TokenInfo, F as FetchConfig, S as SwapQuote, R as RouteNode } from './client-DPSUVYSv.js';
|
|
2
|
+
export { A as ApiTokenInfo, D as DEFAULT_POLLING_CONFIG, E as EkuboClient, b as EkuboClientConfig, c as FetchQuoteParams, d as FetchTokenParams, e as FetchTokensBatchParams, f as FetchTokensParams, G as GenerateSwapCallsParams, g as GetPriceHistoryParams, O as OverviewStats, P as PairStats, h as PairStatsParams, i as PollingConfig, j as PoolInfo, k as PoolKey, l as PriceDataPoint, m as PriceHistoryResponse, Q as QuotePoller, n as QuotePollerCallbacks, o as QuotePollerParams, p as ResolvedConfig, q as StatsBaseParams, r as SwapCall, s as SwapCallsResult, t as SwapQuoteApiResponse, u as SwapQuoteErrorResponse, v as SwapSplit, w as TvlDataPoint, V as VolumeDataPoint, x as createEkuboClient, y as createQuotePoller, z as createTokenRegistry, B as fetchPairPools, C as fetchPairTvl, H as fetchPairVolume, I as fetchToken, J as fetchTokens, K as fetchTokensBatch, L as fetchTopPairs, M as fetchTvl, N as fetchVolume, U as generateSwapCalls, W as getDefaultRegistry, X as getPriceHistory, Y as prepareSwapCalls } from './client-DPSUVYSv.js';
|
|
424
3
|
|
|
425
4
|
/**
|
|
426
5
|
* Resolve a token identifier (symbol or address) to a normalized address
|
|
@@ -453,240 +32,6 @@ declare const MAINNET_TOKENS: TokenInfo[];
|
|
|
453
32
|
*/
|
|
454
33
|
declare function getMainnetTokensMap(): Map<string, TokenInfo>;
|
|
455
34
|
|
|
456
|
-
/**
|
|
457
|
-
* Default polling configuration
|
|
458
|
-
*/
|
|
459
|
-
declare const DEFAULT_POLLING_CONFIG: Required<PollingConfig>;
|
|
460
|
-
/**
|
|
461
|
-
* Quote poller callbacks
|
|
462
|
-
*/
|
|
463
|
-
interface QuotePollerCallbacks {
|
|
464
|
-
/** Called when a new quote is received */
|
|
465
|
-
onQuote: (quote: SwapQuote) => void;
|
|
466
|
-
/** Called when an error occurs */
|
|
467
|
-
onError?: (error: Error) => void;
|
|
468
|
-
/** Called when polling stops (due to errors or manually) */
|
|
469
|
-
onStop?: (reason: "manual" | "errors") => void;
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Parameters for quote polling
|
|
473
|
-
*/
|
|
474
|
-
interface QuotePollerParams {
|
|
475
|
-
/** Amount to swap */
|
|
476
|
-
amount: bigint;
|
|
477
|
-
/** Token to sell (address) */
|
|
478
|
-
tokenFrom: string;
|
|
479
|
-
/** Token to buy (address) */
|
|
480
|
-
tokenTo: string;
|
|
481
|
-
/** Chain ID (Ekubo format) */
|
|
482
|
-
chainId?: string;
|
|
483
|
-
}
|
|
484
|
-
/**
|
|
485
|
-
* QuotePoller class for real-time quote updates
|
|
486
|
-
*/
|
|
487
|
-
declare class QuotePoller {
|
|
488
|
-
private intervalId;
|
|
489
|
-
private abortController;
|
|
490
|
-
private consecutiveErrors;
|
|
491
|
-
private isRunning;
|
|
492
|
-
private readonly params;
|
|
493
|
-
private readonly callbacks;
|
|
494
|
-
private readonly config;
|
|
495
|
-
private readonly fetchConfig?;
|
|
496
|
-
constructor(params: QuotePollerParams, callbacks: QuotePollerCallbacks, config?: PollingConfig, fetchConfig?: FetchConfig);
|
|
497
|
-
/**
|
|
498
|
-
* Start polling for quotes
|
|
499
|
-
*/
|
|
500
|
-
start(): void;
|
|
501
|
-
/**
|
|
502
|
-
* Stop polling
|
|
503
|
-
*/
|
|
504
|
-
stop(): void;
|
|
505
|
-
/**
|
|
506
|
-
* Check if currently polling
|
|
507
|
-
*/
|
|
508
|
-
get running(): boolean;
|
|
509
|
-
/**
|
|
510
|
-
* Update polling parameters (requires restart)
|
|
511
|
-
*/
|
|
512
|
-
updateParams(params: Partial<QuotePollerParams>): void;
|
|
513
|
-
/**
|
|
514
|
-
* Fetch a quote
|
|
515
|
-
*/
|
|
516
|
-
private fetchQuote;
|
|
517
|
-
/**
|
|
518
|
-
* Stop due to consecutive errors
|
|
519
|
-
*/
|
|
520
|
-
private stopDueToErrors;
|
|
521
|
-
}
|
|
522
|
-
/**
|
|
523
|
-
* Create a quote poller instance
|
|
524
|
-
*/
|
|
525
|
-
declare function createQuotePoller(params: QuotePollerParams, callbacks: QuotePollerCallbacks, config?: PollingConfig, fetchConfig?: FetchConfig): QuotePoller;
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* Main Ekubo SDK client
|
|
529
|
-
*
|
|
530
|
-
* Provides a high-level interface for:
|
|
531
|
-
* - Fetching swap quotes
|
|
532
|
-
* - Generating swap calls
|
|
533
|
-
* - Token symbol resolution
|
|
534
|
-
* - Quote polling
|
|
535
|
-
* - Protocol statistics (TVL, volume, pairs)
|
|
536
|
-
* - Dynamic token list fetching
|
|
537
|
-
*/
|
|
538
|
-
declare class EkuboClient {
|
|
539
|
-
private readonly config;
|
|
540
|
-
private readonly tokenRegistry;
|
|
541
|
-
constructor(config?: EkuboClientConfig);
|
|
542
|
-
/**
|
|
543
|
-
* Resolve configuration with defaults
|
|
544
|
-
*/
|
|
545
|
-
private resolveConfig;
|
|
546
|
-
/**
|
|
547
|
-
* Get the current chain ID
|
|
548
|
-
*/
|
|
549
|
-
get chainId(): string;
|
|
550
|
-
/**
|
|
551
|
-
* Get the router contract address
|
|
552
|
-
*/
|
|
553
|
-
get routerAddress(): string;
|
|
554
|
-
/**
|
|
555
|
-
* Get the token registry
|
|
556
|
-
*/
|
|
557
|
-
get tokens(): TokenRegistry;
|
|
558
|
-
/**
|
|
559
|
-
* Resolve a token identifier (symbol or address) to an address
|
|
560
|
-
*/
|
|
561
|
-
resolveToken(tokenIdentifier: string): string;
|
|
562
|
-
/**
|
|
563
|
-
* Fetch a swap quote
|
|
564
|
-
*
|
|
565
|
-
* @param params - Quote parameters (supports symbols or addresses)
|
|
566
|
-
* @returns Swap quote
|
|
567
|
-
*/
|
|
568
|
-
getQuote(params: FetchQuoteParams): Promise<SwapQuote>;
|
|
569
|
-
/**
|
|
570
|
-
* Fetch a token price in USDC
|
|
571
|
-
*
|
|
572
|
-
* @param tokenIdentifier - Token symbol or address
|
|
573
|
-
* @param amount - Amount of token
|
|
574
|
-
* @param signal - Optional abort signal
|
|
575
|
-
* @returns Price in USDC (as bigint)
|
|
576
|
-
*/
|
|
577
|
-
getUsdcPrice(tokenIdentifier: string, amount: bigint, signal?: AbortSignal): Promise<bigint>;
|
|
578
|
-
/**
|
|
579
|
-
* Fetch price history
|
|
580
|
-
*
|
|
581
|
-
* @param token - Token symbol or address
|
|
582
|
-
* @param otherToken - Quote token symbol or address
|
|
583
|
-
* @param interval - Time interval in seconds (default: 7000)
|
|
584
|
-
* @returns Price history data
|
|
585
|
-
*/
|
|
586
|
-
getPriceHistory(token: string, otherToken: string, interval?: number): Promise<PriceHistoryResponse>;
|
|
587
|
-
/**
|
|
588
|
-
* Generate swap calls from a quote
|
|
589
|
-
*
|
|
590
|
-
* @param params - Call generation parameters (supports symbols or addresses)
|
|
591
|
-
* @returns Swap calls result
|
|
592
|
-
*/
|
|
593
|
-
generateSwapCalls(params: Omit<GenerateSwapCallsParams, "chainId" | "routerAddress">): SwapCallsResult;
|
|
594
|
-
/**
|
|
595
|
-
* Prepare swap calls with approval included
|
|
596
|
-
*
|
|
597
|
-
* @param params - Call generation parameters (supports symbols or addresses)
|
|
598
|
-
* @returns Swap calls result with approve call
|
|
599
|
-
*/
|
|
600
|
-
prepareSwapCalls(params: Omit<GenerateSwapCallsParams, "chainId" | "routerAddress">): SwapCallsResult & {
|
|
601
|
-
approveCall: SwapCall;
|
|
602
|
-
};
|
|
603
|
-
/**
|
|
604
|
-
* Create a quote poller for real-time updates
|
|
605
|
-
*
|
|
606
|
-
* @param params - Quote parameters (supports symbols or addresses)
|
|
607
|
-
* @param callbacks - Poller callbacks
|
|
608
|
-
* @param config - Optional polling configuration
|
|
609
|
-
* @returns QuotePoller instance
|
|
610
|
-
*/
|
|
611
|
-
createQuotePoller(params: Omit<FetchQuoteParams, "signal">, callbacks: QuotePollerCallbacks, config?: PollingConfig): QuotePoller;
|
|
612
|
-
/**
|
|
613
|
-
* Register a custom token in the local registry
|
|
614
|
-
*/
|
|
615
|
-
registerToken(token: TokenInfo): void;
|
|
616
|
-
/**
|
|
617
|
-
* Fetch all tokens from the Ekubo API
|
|
618
|
-
*
|
|
619
|
-
* @returns Array of token metadata from the API
|
|
620
|
-
*/
|
|
621
|
-
fetchTokens(): Promise<ApiTokenInfo[]>;
|
|
622
|
-
/**
|
|
623
|
-
* Fetch metadata for a single token from the API
|
|
624
|
-
*
|
|
625
|
-
* @param tokenAddress - Token contract address
|
|
626
|
-
* @returns Token metadata or null if not found
|
|
627
|
-
*/
|
|
628
|
-
fetchToken(tokenAddress: string): Promise<ApiTokenInfo | null>;
|
|
629
|
-
/**
|
|
630
|
-
* Fetch metadata for multiple tokens at once
|
|
631
|
-
*
|
|
632
|
-
* @param tokenAddresses - Array of token addresses
|
|
633
|
-
* @returns Array of token metadata
|
|
634
|
-
*/
|
|
635
|
-
fetchTokensBatch(tokenAddresses: string[]): Promise<ApiTokenInfo[]>;
|
|
636
|
-
/**
|
|
637
|
-
* Fetch tokens from API and register them in the local registry
|
|
638
|
-
*
|
|
639
|
-
* @returns Number of tokens registered
|
|
640
|
-
*/
|
|
641
|
-
syncTokensFromApi(): Promise<number>;
|
|
642
|
-
/**
|
|
643
|
-
* Fetch top trading pairs by volume
|
|
644
|
-
*
|
|
645
|
-
* @returns Array of pair statistics
|
|
646
|
-
*/
|
|
647
|
-
getTopPairs(): Promise<PairStats[]>;
|
|
648
|
-
/**
|
|
649
|
-
* Fetch protocol TVL overview
|
|
650
|
-
*
|
|
651
|
-
* @returns TVL statistics
|
|
652
|
-
*/
|
|
653
|
-
getTvl(): Promise<OverviewStats>;
|
|
654
|
-
/**
|
|
655
|
-
* Fetch protocol volume overview
|
|
656
|
-
*
|
|
657
|
-
* @returns Volume statistics
|
|
658
|
-
*/
|
|
659
|
-
getVolume(): Promise<OverviewStats>;
|
|
660
|
-
/**
|
|
661
|
-
* Fetch TVL history for a trading pair
|
|
662
|
-
*
|
|
663
|
-
* @param tokenA - First token (symbol or address)
|
|
664
|
-
* @param tokenB - Second token (symbol or address)
|
|
665
|
-
* @returns TVL data points
|
|
666
|
-
*/
|
|
667
|
-
getPairTvl(tokenA: string, tokenB: string): Promise<TvlDataPoint[]>;
|
|
668
|
-
/**
|
|
669
|
-
* Fetch volume history for a trading pair
|
|
670
|
-
*
|
|
671
|
-
* @param tokenA - First token (symbol or address)
|
|
672
|
-
* @param tokenB - Second token (symbol or address)
|
|
673
|
-
* @returns Volume data points
|
|
674
|
-
*/
|
|
675
|
-
getPairVolume(tokenA: string, tokenB: string): Promise<VolumeDataPoint[]>;
|
|
676
|
-
/**
|
|
677
|
-
* Fetch pools for a trading pair
|
|
678
|
-
*
|
|
679
|
-
* @param tokenA - First token (symbol or address)
|
|
680
|
-
* @param tokenB - Second token (symbol or address)
|
|
681
|
-
* @returns Pool information
|
|
682
|
-
*/
|
|
683
|
-
getPairPools(tokenA: string, tokenB: string): Promise<PoolInfo[]>;
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Create an EkuboClient instance
|
|
687
|
-
*/
|
|
688
|
-
declare function createEkuboClient(config?: EkuboClientConfig): EkuboClient;
|
|
689
|
-
|
|
690
35
|
/**
|
|
691
36
|
* Parameters for fetchSwapQuote
|
|
692
37
|
*/
|
|
@@ -924,4 +269,4 @@ declare class InvalidChainError extends EkuboError {
|
|
|
924
269
|
*/
|
|
925
270
|
declare function isNonRetryableError(error: unknown): boolean;
|
|
926
271
|
|
|
927
|
-
export { API_URLS, AbortError, ApiError,
|
|
272
|
+
export { API_URLS, AbortError, ApiError, CHAIN_CONFIGS, CHAIN_IDS, type ChainConfig, EkuboError, type EncodedRoute, FetchConfig, type FetchSwapQuoteParams, InsufficientLiquidityError, InvalidChainError, MAINNET_TOKENS, ROUTER_ADDRESSES, RateLimitError, type RetryOptions, RouteNode, STARKNET_CHAIN_IDS, STARKNET_TO_EKUBO_CHAIN, SwapQuote, TimeoutError, TokenInfo, TokenNotFoundError, TokenRegistry, USDC_ADDRESSES, abs, addSlippage, calculateBackoff, canResolveToken, encodeRoute, encodeRouteNode, fetchSwapQuote, fetchSwapQuoteInUsdc, getChainConfig, getEkuboChainId, getMainnetTokensMap, isAddress, isNonRetryableError, normalizeAddress, parseTotalCalculated, resolveToken, resolveTokenInfo, sleep, splitU256, subtractSlippage, toHex, withRetry };
|