@t402/smart-router 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,454 @@
1
+ import { z } from 'zod';
2
+ import { C as ChainId } from './types-C0ey6WqI.js';
3
+
4
+ /**
5
+ * Gas price data
6
+ */
7
+ declare const GasPrice: z.ZodObject<{
8
+ chain: z.ZodString;
9
+ slow: z.ZodString;
10
+ standard: z.ZodString;
11
+ fast: z.ZodString;
12
+ instant: z.ZodString;
13
+ baseFee: z.ZodOptional<z.ZodString>;
14
+ priorityFee: z.ZodOptional<z.ZodObject<{
15
+ slow: z.ZodString;
16
+ standard: z.ZodString;
17
+ fast: z.ZodString;
18
+ instant: z.ZodString;
19
+ }, "strip", z.ZodTypeAny, {
20
+ slow: string;
21
+ standard: string;
22
+ fast: string;
23
+ instant: string;
24
+ }, {
25
+ slow: string;
26
+ standard: string;
27
+ fast: string;
28
+ instant: string;
29
+ }>>;
30
+ nativeTokenPriceUsd: z.ZodString;
31
+ lastBlock: z.ZodNumber;
32
+ timestamp: z.ZodNumber;
33
+ }, "strip", z.ZodTypeAny, {
34
+ chain: string;
35
+ slow: string;
36
+ standard: string;
37
+ fast: string;
38
+ instant: string;
39
+ nativeTokenPriceUsd: string;
40
+ lastBlock: number;
41
+ timestamp: number;
42
+ baseFee?: string | undefined;
43
+ priorityFee?: {
44
+ slow: string;
45
+ standard: string;
46
+ fast: string;
47
+ instant: string;
48
+ } | undefined;
49
+ }, {
50
+ chain: string;
51
+ slow: string;
52
+ standard: string;
53
+ fast: string;
54
+ instant: string;
55
+ nativeTokenPriceUsd: string;
56
+ lastBlock: number;
57
+ timestamp: number;
58
+ baseFee?: string | undefined;
59
+ priorityFee?: {
60
+ slow: string;
61
+ standard: string;
62
+ fast: string;
63
+ instant: string;
64
+ } | undefined;
65
+ }>;
66
+ type GasPrice = z.infer<typeof GasPrice>;
67
+ /**
68
+ * Token price data
69
+ */
70
+ declare const TokenPrice: z.ZodObject<{
71
+ chain: z.ZodString;
72
+ asset: z.ZodString;
73
+ priceUsd: z.ZodString;
74
+ price24hChange: z.ZodOptional<z.ZodString>;
75
+ volume24h: z.ZodOptional<z.ZodString>;
76
+ source: z.ZodString;
77
+ timestamp: z.ZodNumber;
78
+ confidence: z.ZodNumber;
79
+ }, "strip", z.ZodTypeAny, {
80
+ chain: string;
81
+ confidence: number;
82
+ timestamp: number;
83
+ asset: string;
84
+ priceUsd: string;
85
+ source: string;
86
+ price24hChange?: string | undefined;
87
+ volume24h?: string | undefined;
88
+ }, {
89
+ chain: string;
90
+ confidence: number;
91
+ timestamp: number;
92
+ asset: string;
93
+ priceUsd: string;
94
+ source: string;
95
+ price24hChange?: string | undefined;
96
+ volume24h?: string | undefined;
97
+ }>;
98
+ type TokenPrice = z.infer<typeof TokenPrice>;
99
+ /**
100
+ * Protocol fee structure
101
+ */
102
+ declare const ProtocolFees: z.ZodObject<{
103
+ protocol: z.ZodString;
104
+ chain: z.ZodString;
105
+ swapFee: z.ZodOptional<z.ZodString>;
106
+ bridgeFee: z.ZodOptional<z.ZodObject<{
107
+ percentage: z.ZodString;
108
+ minimum: z.ZodString;
109
+ maximum: z.ZodOptional<z.ZodString>;
110
+ }, "strip", z.ZodTypeAny, {
111
+ minimum: string;
112
+ percentage: string;
113
+ maximum?: string | undefined;
114
+ }, {
115
+ minimum: string;
116
+ percentage: string;
117
+ maximum?: string | undefined;
118
+ }>>;
119
+ gasEstimates: z.ZodRecord<z.ZodString, z.ZodString>;
120
+ timestamp: z.ZodNumber;
121
+ }, "strip", z.ZodTypeAny, {
122
+ chain: string;
123
+ protocol: string;
124
+ timestamp: number;
125
+ gasEstimates: Record<string, string>;
126
+ bridgeFee?: {
127
+ minimum: string;
128
+ percentage: string;
129
+ maximum?: string | undefined;
130
+ } | undefined;
131
+ swapFee?: string | undefined;
132
+ }, {
133
+ chain: string;
134
+ protocol: string;
135
+ timestamp: number;
136
+ gasEstimates: Record<string, string>;
137
+ bridgeFee?: {
138
+ minimum: string;
139
+ percentage: string;
140
+ maximum?: string | undefined;
141
+ } | undefined;
142
+ swapFee?: string | undefined;
143
+ }>;
144
+ type ProtocolFees = z.infer<typeof ProtocolFees>;
145
+ /**
146
+ * Bridge quote
147
+ */
148
+ declare const BridgeQuote: z.ZodObject<{
149
+ bridge: z.ZodString;
150
+ sourceChain: z.ZodString;
151
+ destinationChain: z.ZodString;
152
+ sourceAsset: z.ZodString;
153
+ destinationAsset: z.ZodString;
154
+ inputAmount: z.ZodString;
155
+ outputAmount: z.ZodString;
156
+ fee: z.ZodString;
157
+ feeUsd: z.ZodString;
158
+ estimatedTime: z.ZodNumber;
159
+ confidence: z.ZodNumber;
160
+ expiresAt: z.ZodNumber;
161
+ }, "strip", z.ZodTypeAny, {
162
+ bridge: string;
163
+ sourceChain: string;
164
+ sourceAsset: string;
165
+ destinationChain: string;
166
+ destinationAsset: string;
167
+ inputAmount: string;
168
+ outputAmount: string;
169
+ estimatedTime: number;
170
+ confidence: number;
171
+ expiresAt: number;
172
+ fee: string;
173
+ feeUsd: string;
174
+ }, {
175
+ bridge: string;
176
+ sourceChain: string;
177
+ sourceAsset: string;
178
+ destinationChain: string;
179
+ destinationAsset: string;
180
+ inputAmount: string;
181
+ outputAmount: string;
182
+ estimatedTime: number;
183
+ confidence: number;
184
+ expiresAt: number;
185
+ fee: string;
186
+ feeUsd: string;
187
+ }>;
188
+ type BridgeQuote = z.infer<typeof BridgeQuote>;
189
+ /**
190
+ * Swap quote
191
+ */
192
+ declare const SwapQuote: z.ZodObject<{
193
+ dex: z.ZodString;
194
+ chain: z.ZodString;
195
+ inputAsset: z.ZodString;
196
+ outputAsset: z.ZodString;
197
+ inputAmount: z.ZodString;
198
+ outputAmount: z.ZodString;
199
+ minOutputAmount: z.ZodString;
200
+ priceImpact: z.ZodString;
201
+ fee: z.ZodString;
202
+ feeUsd: z.ZodString;
203
+ route: z.ZodArray<z.ZodString, "many">;
204
+ estimatedGas: z.ZodString;
205
+ expiresAt: z.ZodNumber;
206
+ }, "strip", z.ZodTypeAny, {
207
+ chain: string;
208
+ inputAsset: string;
209
+ outputAsset: string;
210
+ inputAmount: string;
211
+ outputAmount: string;
212
+ minOutputAmount: string;
213
+ estimatedGas: string;
214
+ priceImpact: string;
215
+ expiresAt: number;
216
+ route: string[];
217
+ fee: string;
218
+ feeUsd: string;
219
+ dex: string;
220
+ }, {
221
+ chain: string;
222
+ inputAsset: string;
223
+ outputAsset: string;
224
+ inputAmount: string;
225
+ outputAmount: string;
226
+ minOutputAmount: string;
227
+ estimatedGas: string;
228
+ priceImpact: string;
229
+ expiresAt: number;
230
+ route: string[];
231
+ fee: string;
232
+ feeUsd: string;
233
+ dex: string;
234
+ }>;
235
+ type SwapQuote = z.infer<typeof SwapQuote>;
236
+ /**
237
+ * Fee estimation request
238
+ */
239
+ declare const FeeEstimateRequest: z.ZodObject<{
240
+ chain: z.ZodString;
241
+ operation: z.ZodEnum<["transfer", "swap", "bridge", "approve", "wrap", "unwrap"]>;
242
+ protocol: z.ZodOptional<z.ZodString>;
243
+ inputAsset: z.ZodString;
244
+ outputAsset: z.ZodOptional<z.ZodString>;
245
+ amount: z.ZodString;
246
+ gasSpeed: z.ZodDefault<z.ZodEnum<["slow", "standard", "fast", "instant"]>>;
247
+ }, "strip", z.ZodTypeAny, {
248
+ chain: string;
249
+ inputAsset: string;
250
+ operation: "transfer" | "swap" | "bridge" | "wrap" | "unwrap" | "approve";
251
+ amount: string;
252
+ gasSpeed: "slow" | "standard" | "fast" | "instant";
253
+ protocol?: string | undefined;
254
+ outputAsset?: string | undefined;
255
+ }, {
256
+ chain: string;
257
+ inputAsset: string;
258
+ operation: "transfer" | "swap" | "bridge" | "wrap" | "unwrap" | "approve";
259
+ amount: string;
260
+ protocol?: string | undefined;
261
+ outputAsset?: string | undefined;
262
+ gasSpeed?: "slow" | "standard" | "fast" | "instant" | undefined;
263
+ }>;
264
+ type FeeEstimateRequest = z.infer<typeof FeeEstimateRequest>;
265
+ /**
266
+ * Fee estimation result
267
+ */
268
+ declare const FeeEstimate: z.ZodObject<{
269
+ gasUnits: z.ZodString;
270
+ gasPriceWei: z.ZodString;
271
+ gasCostNative: z.ZodString;
272
+ gasCostUsd: z.ZodString;
273
+ protocolFee: z.ZodString;
274
+ protocolFeeUsd: z.ZodString;
275
+ totalFeeUsd: z.ZodString;
276
+ confidence: z.ZodNumber;
277
+ breakdown: z.ZodArray<z.ZodObject<{
278
+ type: z.ZodString;
279
+ amount: z.ZodString;
280
+ amountUsd: z.ZodString;
281
+ }, "strip", z.ZodTypeAny, {
282
+ type: string;
283
+ amount: string;
284
+ amountUsd: string;
285
+ }, {
286
+ type: string;
287
+ amount: string;
288
+ amountUsd: string;
289
+ }>, "many">;
290
+ }, "strip", z.ZodTypeAny, {
291
+ protocolFee: string;
292
+ confidence: number;
293
+ gasUnits: string;
294
+ gasPriceWei: string;
295
+ gasCostNative: string;
296
+ gasCostUsd: string;
297
+ protocolFeeUsd: string;
298
+ totalFeeUsd: string;
299
+ breakdown: {
300
+ type: string;
301
+ amount: string;
302
+ amountUsd: string;
303
+ }[];
304
+ }, {
305
+ protocolFee: string;
306
+ confidence: number;
307
+ gasUnits: string;
308
+ gasPriceWei: string;
309
+ gasCostNative: string;
310
+ gasCostUsd: string;
311
+ protocolFeeUsd: string;
312
+ totalFeeUsd: string;
313
+ breakdown: {
314
+ type: string;
315
+ amount: string;
316
+ amountUsd: string;
317
+ }[];
318
+ }>;
319
+ type FeeEstimate = z.infer<typeof FeeEstimate>;
320
+ /**
321
+ * Price prediction (for ML-based forecasting)
322
+ */
323
+ declare const PricePrediction: z.ZodObject<{
324
+ chain: z.ZodString;
325
+ asset: z.ZodOptional<z.ZodString>;
326
+ currentPrice: z.ZodString;
327
+ predictions: z.ZodArray<z.ZodObject<{
328
+ timestamp: z.ZodNumber;
329
+ predictedPrice: z.ZodString;
330
+ confidence: z.ZodNumber;
331
+ lowerBound: z.ZodString;
332
+ upperBound: z.ZodString;
333
+ }, "strip", z.ZodTypeAny, {
334
+ confidence: number;
335
+ timestamp: number;
336
+ predictedPrice: string;
337
+ lowerBound: string;
338
+ upperBound: string;
339
+ }, {
340
+ confidence: number;
341
+ timestamp: number;
342
+ predictedPrice: string;
343
+ lowerBound: string;
344
+ upperBound: string;
345
+ }>, "many">;
346
+ model: z.ZodString;
347
+ lastUpdated: z.ZodNumber;
348
+ }, "strip", z.ZodTypeAny, {
349
+ chain: string;
350
+ currentPrice: string;
351
+ predictions: {
352
+ confidence: number;
353
+ timestamp: number;
354
+ predictedPrice: string;
355
+ lowerBound: string;
356
+ upperBound: string;
357
+ }[];
358
+ model: string;
359
+ lastUpdated: number;
360
+ asset?: string | undefined;
361
+ }, {
362
+ chain: string;
363
+ currentPrice: string;
364
+ predictions: {
365
+ confidence: number;
366
+ timestamp: number;
367
+ predictedPrice: string;
368
+ lowerBound: string;
369
+ upperBound: string;
370
+ }[];
371
+ model: string;
372
+ lastUpdated: number;
373
+ asset?: string | undefined;
374
+ }>;
375
+ type PricePrediction = z.infer<typeof PricePrediction>;
376
+
377
+ /**
378
+ * Gas oracle configuration
379
+ */
380
+ interface GasOracleConfig {
381
+ cacheTtl?: number;
382
+ refreshInterval?: number;
383
+ enablePrediction?: boolean;
384
+ }
385
+ /**
386
+ * Gas data provider interface
387
+ */
388
+ interface IGasProvider {
389
+ getGasPrice(chain: ChainId): Promise<GasPrice>;
390
+ supportedChains(): ChainId[];
391
+ }
392
+ /**
393
+ * Gas oracle for multi-chain gas price tracking
394
+ */
395
+ declare class GasOracle {
396
+ private providers;
397
+ private cache;
398
+ private config;
399
+ private history;
400
+ private maxHistorySize;
401
+ constructor(config?: GasOracleConfig);
402
+ /**
403
+ * Register a gas provider for a chain
404
+ */
405
+ registerProvider(chain: ChainId, provider: IGasProvider): void;
406
+ /**
407
+ * Get current gas price for a chain
408
+ */
409
+ getGasPrice(chain: ChainId): Promise<GasPrice>;
410
+ /**
411
+ * Get gas prices for multiple chains
412
+ */
413
+ getMultiChainGasPrices(chains: ChainId[]): Promise<Map<ChainId, GasPrice>>;
414
+ /**
415
+ * Calculate gas cost in USD
416
+ */
417
+ calculateGasCostUsd(chain: ChainId, gasUnits: string, speed?: 'slow' | 'standard' | 'fast' | 'instant'): Promise<{
418
+ costNative: string;
419
+ costUsd: string;
420
+ }>;
421
+ /**
422
+ * Predict future gas prices (simple moving average)
423
+ */
424
+ predictGasPrice(chain: ChainId, horizonMinutes?: number): PricePrediction | null;
425
+ /**
426
+ * Get recommended gas price based on urgency
427
+ */
428
+ getRecommendedGasPrice(chain: ChainId, urgency: 'low' | 'medium' | 'high' | 'critical'): Promise<{
429
+ price: string;
430
+ estimatedTime: number;
431
+ }>;
432
+ /**
433
+ * Get gas history for a chain
434
+ */
435
+ getHistory(chain: ChainId): GasPrice[];
436
+ /**
437
+ * Clear cache
438
+ */
439
+ clearCache(): void;
440
+ private addToHistory;
441
+ private getMockGasPrice;
442
+ }
443
+ /**
444
+ * Mock gas provider for testing
445
+ */
446
+ declare class MockGasProvider implements IGasProvider {
447
+ private chains;
448
+ private volatility;
449
+ constructor(chains: ChainId[], volatility?: number);
450
+ getGasPrice(chain: ChainId): Promise<GasPrice>;
451
+ supportedChains(): ChainId[];
452
+ }
453
+
454
+ export { BridgeQuote as B, FeeEstimateRequest as F, GasPrice as G, type IGasProvider as I, MockGasProvider as M, ProtocolFees as P, SwapQuote as S, TokenPrice as T, FeeEstimate as a, PricePrediction as b, GasOracle as c, type GasOracleConfig as d };
@@ -0,0 +1,7 @@
1
+ export { A as AssetId, C as ChainId, G as GraphEdge, f as GraphNode, O as OptimizationStrategy, P as ProtocolId, c as Route, d as RouteComparison, a as RouteRequest, b as RouteStep, R as RouteStepType, e as RouteValidation, g as RoutingGraph } from './types-C0ey6WqI.js';
2
+ export { COST_CONFIGS, CostConfig, RouterConfig, RoutingEngine, RoutingError, RoutingErrorCode, astar, calculateEdgeCost, dijkstra, kShortestPaths, paretoOptimalPaths } from './routing/index.js';
3
+ export { B as BridgeQuote, a as FeeEstimate, F as FeeEstimateRequest, c as GasOracle, d as GasOracleConfig, G as GasPrice, I as IGasProvider, M as MockGasProvider, b as PricePrediction, P as ProtocolFees, S as SwapQuote, T as TokenPrice } from './gas-CNpJzuy5.js';
4
+ export { FeeEstimator, FeeEstimatorConfig, calculateMinOutput, calculatePriceImpact } from './pricing/index.js';
5
+ export { AggregatorConfig, CrossChainLiquidity, IBridgeProvider, ILiquidityProvider, LiquidityAggregator, LiquidityDepth, LiquidityPool, LiquiditySource, MockBridgeProvider, MockLiquidityProvider, PoolType, SlippageResult } from './liquidity/index.js';
6
+ export { BuilderConfig, BuilderError, BuilderErrorCode, BundleResult, ExecutionContext, ExecutionOptions, ExecutionResult, ExecutionStepResult, FallbackRoute, MevProtection, MevProtectionConfig, MevProtectionStrategy, SignedTransaction, SimulationResult, TransactionBuilder, TransactionReceipt, TransactionRequest, TransactionStatus, createMevProtectedOptions } from './execution/index.js';
7
+ import 'zod';
package/dist/index.js ADDED
@@ -0,0 +1,119 @@
1
+ import {
2
+ BuilderError,
3
+ ExecutionOptions,
4
+ ExecutionResult,
5
+ ExecutionStepResult,
6
+ MevProtection,
7
+ MevProtectionStrategy,
8
+ SignedTransaction,
9
+ SimulationResult,
10
+ TransactionBuilder,
11
+ TransactionReceipt,
12
+ TransactionRequest,
13
+ TransactionStatus,
14
+ createMevProtectedOptions
15
+ } from "./chunk-XKFKUWJY.js";
16
+ import {
17
+ CrossChainLiquidity,
18
+ LiquidityAggregator,
19
+ LiquidityDepth,
20
+ LiquidityPool,
21
+ LiquiditySource,
22
+ MockBridgeProvider,
23
+ MockLiquidityProvider,
24
+ PoolType,
25
+ SlippageResult
26
+ } from "./chunk-PCDWVENA.js";
27
+ import {
28
+ COST_CONFIGS,
29
+ RoutingEngine,
30
+ RoutingError,
31
+ astar,
32
+ calculateEdgeCost,
33
+ dijkstra,
34
+ kShortestPaths,
35
+ paretoOptimalPaths
36
+ } from "./chunk-KJJ2L6TF.js";
37
+ import {
38
+ BridgeQuote,
39
+ FeeEstimate,
40
+ FeeEstimateRequest,
41
+ FeeEstimator,
42
+ GasOracle,
43
+ GasPrice,
44
+ MockGasProvider,
45
+ PricePrediction,
46
+ ProtocolFees,
47
+ SwapQuote,
48
+ TokenPrice,
49
+ calculateMinOutput,
50
+ calculatePriceImpact
51
+ } from "./chunk-BUGQ6VOQ.js";
52
+ import {
53
+ AssetId,
54
+ ChainId,
55
+ OptimizationStrategy,
56
+ ProtocolId,
57
+ Route,
58
+ RouteComparison,
59
+ RouteRequest,
60
+ RouteStep,
61
+ RouteStepType,
62
+ RouteValidation
63
+ } from "./chunk-QIZPPHGB.js";
64
+ export {
65
+ AssetId,
66
+ BridgeQuote,
67
+ BuilderError,
68
+ COST_CONFIGS,
69
+ ChainId,
70
+ CrossChainLiquidity,
71
+ ExecutionOptions,
72
+ ExecutionResult,
73
+ ExecutionStepResult,
74
+ FeeEstimate,
75
+ FeeEstimateRequest,
76
+ FeeEstimator,
77
+ GasOracle,
78
+ GasPrice,
79
+ LiquidityAggregator,
80
+ LiquidityDepth,
81
+ LiquidityPool,
82
+ LiquiditySource,
83
+ MevProtection,
84
+ MevProtectionStrategy,
85
+ MockBridgeProvider,
86
+ MockGasProvider,
87
+ MockLiquidityProvider,
88
+ OptimizationStrategy,
89
+ PoolType,
90
+ PricePrediction,
91
+ ProtocolFees,
92
+ ProtocolId,
93
+ Route,
94
+ RouteComparison,
95
+ RouteRequest,
96
+ RouteStep,
97
+ RouteStepType,
98
+ RouteValidation,
99
+ RoutingEngine,
100
+ RoutingError,
101
+ SignedTransaction,
102
+ SimulationResult,
103
+ SlippageResult,
104
+ SwapQuote,
105
+ TokenPrice,
106
+ TransactionBuilder,
107
+ TransactionReceipt,
108
+ TransactionRequest,
109
+ TransactionStatus,
110
+ astar,
111
+ calculateEdgeCost,
112
+ calculateMinOutput,
113
+ calculatePriceImpact,
114
+ createMevProtectedOptions,
115
+ dijkstra,
116
+ kShortestPaths,
117
+ paretoOptimalPaths
118
+ };
119
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}