@jack-kernel/sdk 1.1.0 → 1.2.2
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 +128 -19
- package/dist/cjs/index.js +83 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lifi/chain-map.js +39 -0
- package/dist/cjs/lifi/chain-map.js.map +1 -0
- package/dist/cjs/lifi/fallback.js +135 -0
- package/dist/cjs/lifi/fallback.js.map +1 -0
- package/dist/cjs/lifi/index.js +34 -0
- package/dist/cjs/lifi/index.js.map +1 -0
- package/dist/cjs/lifi/lifi-provider.js +496 -0
- package/dist/cjs/lifi/lifi-provider.js.map +1 -0
- package/dist/cjs/lifi/token-map.js +75 -0
- package/dist/cjs/lifi/token-map.js.map +1 -0
- package/dist/cjs/lifi/types.js +3 -0
- package/dist/cjs/lifi/types.js.map +1 -0
- package/dist/cjs/lifi/utils.js +45 -0
- package/dist/cjs/lifi/utils.js.map +1 -0
- package/dist/esm/index.js +69 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lifi/chain-map.js +35 -0
- package/dist/esm/lifi/chain-map.js.map +1 -0
- package/dist/esm/lifi/fallback.js +128 -0
- package/dist/esm/lifi/fallback.js.map +1 -0
- package/dist/esm/lifi/index.js +19 -0
- package/dist/esm/lifi/index.js.map +1 -0
- package/dist/esm/lifi/lifi-provider.js +492 -0
- package/dist/esm/lifi/lifi-provider.js.map +1 -0
- package/dist/esm/lifi/token-map.js +71 -0
- package/dist/esm/lifi/token-map.js.map +1 -0
- package/dist/esm/lifi/types.js +2 -0
- package/dist/esm/lifi/types.js.map +1 -0
- package/dist/esm/lifi/utils.js +41 -0
- package/dist/esm/lifi/utils.js.map +1 -0
- package/dist/types/index.d.ts +58 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifi/chain-map.d.ts +27 -0
- package/dist/types/lifi/chain-map.d.ts.map +1 -0
- package/dist/types/lifi/fallback.d.ts +58 -0
- package/dist/types/lifi/fallback.d.ts.map +1 -0
- package/dist/types/lifi/index.d.ts +18 -0
- package/dist/types/lifi/index.d.ts.map +1 -0
- package/dist/types/lifi/lifi-provider.d.ts +133 -0
- package/dist/types/lifi/lifi-provider.d.ts.map +1 -0
- package/dist/types/lifi/token-map.d.ts +34 -0
- package/dist/types/lifi/token-map.d.ts.map +1 -0
- package/dist/types/lifi/types.d.ts +52 -0
- package/dist/types/lifi/types.d.ts.map +1 -0
- package/dist/types/lifi/utils.d.ts +29 -0
- package/dist/types/lifi/utils.d.ts.map +1 -0
- package/package.json +4 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -21,6 +21,9 @@ import { CostTracker } from './costs.js';
|
|
|
21
21
|
import { AgentUtils } from './agent.js';
|
|
22
22
|
import { YellowProvider } from './yellow/yellow-provider.js';
|
|
23
23
|
import type { YellowConfig } from './yellow/yellow-provider.js';
|
|
24
|
+
import { LifiProvider } from './lifi/lifi-provider.js';
|
|
25
|
+
import type { LifiConfig } from './lifi/lifi-provider.js';
|
|
26
|
+
import type { LifiQuotePayload, LifiRoutePayload } from './lifi/types.js';
|
|
24
27
|
import { type ClientConfig, type IntentParams, type Intent } from './types.js';
|
|
25
28
|
import type { WalletClient } from 'viem';
|
|
26
29
|
/**
|
|
@@ -87,6 +90,10 @@ export declare class JACK_SDK {
|
|
|
87
90
|
* **Validates: Requirements 1.6, 1.7**
|
|
88
91
|
*/
|
|
89
92
|
readonly yellow?: YellowProvider;
|
|
93
|
+
/**
|
|
94
|
+
* LI.FI provider - cross-chain quote and route discovery (optional)
|
|
95
|
+
*/
|
|
96
|
+
readonly lifi?: LifiProvider;
|
|
90
97
|
/**
|
|
91
98
|
* Internal HTTP client (exposed for advanced use cases)
|
|
92
99
|
*/
|
|
@@ -99,7 +106,8 @@ export declare class JACK_SDK {
|
|
|
99
106
|
* caching, and custom headers.
|
|
100
107
|
*
|
|
101
108
|
* @param config - Client configuration (baseUrl required, other options optional). Optionally includes
|
|
102
|
-
* a `yellow` field with YellowSDKConfig to enable Yellow Network integration
|
|
109
|
+
* a `yellow` field with YellowSDKConfig to enable Yellow Network integration, and/or a `lifi` field
|
|
110
|
+
* with LifiConfig to enable LI.FI integration.
|
|
103
111
|
* @throws ValidationError if configuration is invalid
|
|
104
112
|
* @throws Error if YellowProvider initialization fails when yellow config is provided
|
|
105
113
|
*
|
|
@@ -129,10 +137,18 @@ export declare class JACK_SDK {
|
|
|
129
137
|
* }
|
|
130
138
|
* });
|
|
131
139
|
* console.log(sdk.yellow); // YellowProvider instance
|
|
140
|
+
*
|
|
141
|
+
* // With LI.FI integration
|
|
142
|
+
* const sdk = new JACK_SDK({
|
|
143
|
+
* baseUrl: 'https://api.jack.example',
|
|
144
|
+
* lifi: { integrator: 'jackkernel' }
|
|
145
|
+
* });
|
|
146
|
+
* console.log(sdk.lifi); // LifiProvider instance
|
|
132
147
|
* ```
|
|
133
148
|
*/
|
|
134
149
|
constructor(config: ClientConfig & {
|
|
135
150
|
yellow?: YellowSDKConfig;
|
|
151
|
+
lifi?: LifiConfig;
|
|
136
152
|
});
|
|
137
153
|
/**
|
|
138
154
|
* Convenience method: Submit a signed intent
|
|
@@ -246,5 +262,46 @@ export declare class JACK_SDK {
|
|
|
246
262
|
* @returns EIP-712 TypedData object
|
|
247
263
|
*/
|
|
248
264
|
getIntentTypedData(params: IntentParams): import("./types.js").TypedData;
|
|
265
|
+
/**
|
|
266
|
+
* Convenience method: Get a LI.FI quote for intent params
|
|
267
|
+
*
|
|
268
|
+
* Delegates to LifiProvider.fetchQuote(). Throws if the SDK was not
|
|
269
|
+
* initialized with a LI.FI configuration.
|
|
270
|
+
*
|
|
271
|
+
* @param params - Intent parameters
|
|
272
|
+
* @returns Promise resolving to a normalized LifiQuotePayload
|
|
273
|
+
* @throws Error if LI.FI is not configured
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* const sdk = new JACK_SDK({ baseUrl: '...', lifi: {} });
|
|
278
|
+
* const quote = await sdk.getLifiQuote(params);
|
|
279
|
+
* console.log('Quote:', quote.quote.amountOut);
|
|
280
|
+
* ```
|
|
281
|
+
*
|
|
282
|
+
* **Validates: Requirements 1.6, 1.7**
|
|
283
|
+
*/
|
|
284
|
+
getLifiQuote(params: IntentParams): Promise<LifiQuotePayload>;
|
|
285
|
+
/**
|
|
286
|
+
* Convenience method: Get a LI.FI route for intent params
|
|
287
|
+
*
|
|
288
|
+
* Delegates to LifiProvider.fetchRoute(). Throws if the SDK was not
|
|
289
|
+
* initialized with a LI.FI configuration.
|
|
290
|
+
*
|
|
291
|
+
* @param params - Intent parameters
|
|
292
|
+
* @returns Promise resolving to a normalized LifiRoutePayload
|
|
293
|
+
* @throws Error if LI.FI is not configured
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const sdk = new JACK_SDK({ baseUrl: '...', lifi: {} });
|
|
298
|
+
* const route = await sdk.getLifiRoute(params);
|
|
299
|
+
* console.log('Route:', route.route?.steps);
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* **Validates: Requirements 1.6, 1.7**
|
|
303
|
+
*/
|
|
304
|
+
getLifiRoute(params: IntentParams): Promise<LifiRoutePayload>;
|
|
249
305
|
}
|
|
306
|
+
export * from './lifi/index.js';
|
|
250
307
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAEV,YAAY,EACZ,MAAM,EACN,aAAa,EAEb,KAAK,EACL,SAAS,EAET,SAAS,EACT,SAAS,EACT,aAAa,EAEb,YAAY,EACZ,cAAc,EACd,WAAW,EAEX,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,YAAY,EACZ,SAAS,EAET,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACP,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,eAAe,E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,GAAG;QAAE,MAAM,CAAC,EAAE,eAAe,CAAC;QAAC,IAAI,CAAC,EAAE,UAAU,CAAA;KAAE;IAqBlF;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI5E;;;;;;;;;;;;;;;;;;OAkBG;IACG,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIlD;;;;;;;;;;;;;;;;;OAiBG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAItC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,MAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAQpF;;;;;;;;;;OAUG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAI3D;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,MAAM,EAAE,YAAY;IAIvC;;;;;;;;;;;;;;;;;;OAkBG;IACG,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAKnE;;;;;;;;;;;;;;;;;;OAkBG;IACG,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAIpE;AAGD,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChainMap — pure mapping module for chain name → chain ID resolution.
|
|
3
|
+
*
|
|
4
|
+
* Lookups are case-insensitive via `name.toLowerCase()`.
|
|
5
|
+
*/
|
|
6
|
+
export type ChainResolution = {
|
|
7
|
+
ok: true;
|
|
8
|
+
chainId: number;
|
|
9
|
+
} | {
|
|
10
|
+
ok: false;
|
|
11
|
+
reason: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a human-readable chain name to its numeric chain ID.
|
|
15
|
+
*
|
|
16
|
+
* @param name - Chain name (case-insensitive), e.g. "Arbitrum", "OPTIMISM"
|
|
17
|
+
* @returns A discriminated union: `{ ok: true, chainId }` on success,
|
|
18
|
+
* `{ ok: false, reason }` when the chain is not supported.
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveChain(name: string): ChainResolution;
|
|
21
|
+
/**
|
|
22
|
+
* Return a copy of the supported chain mappings.
|
|
23
|
+
*
|
|
24
|
+
* @returns A new `Record<string, number>` with all supported chain entries.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getSupportedChains(): Record<string, number>;
|
|
27
|
+
//# sourceMappingURL=chain-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chain-map.d.ts","sourceRoot":"","sources":["../../../src/lifi/chain-map.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAUlC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAM1D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAE3D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FallbackProvider — generates estimated quotes, routes, and statuses when
|
|
3
|
+
* the LI.FI SDK is unavailable or returns errors.
|
|
4
|
+
*
|
|
5
|
+
* Ported from `apps/dashboard/src/lib/lifi.ts` for reuse across the SDK.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { IntentParams } from '../types.js';
|
|
10
|
+
import type { LifiFallback, LifiQuotePayload, LifiRoutePayload, LifiStatusPayload } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Static exchange rates used when the LI.FI SDK is unavailable.
|
|
13
|
+
* Keys are formatted as `TOKENA:TOKENB` (upper-case).
|
|
14
|
+
*/
|
|
15
|
+
export declare const FALLBACK_RATES: Record<string, number>;
|
|
16
|
+
/**
|
|
17
|
+
* Produce a deterministic, human-readable ID from a seed string using the
|
|
18
|
+
* DJB2 hash algorithm.
|
|
19
|
+
*
|
|
20
|
+
* The result has the form `JK-LIFI-{hash}` where `{hash}` is the unsigned
|
|
21
|
+
* 32-bit DJB2 value encoded in upper-case base-36.
|
|
22
|
+
*
|
|
23
|
+
* @param seed - Arbitrary string to hash
|
|
24
|
+
* @returns A deterministic ID of the form `JK-LIFI-[A-Z0-9]+`
|
|
25
|
+
*/
|
|
26
|
+
export declare function deterministicId(seed: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Build a fallback quote payload when the LI.FI SDK is unavailable.
|
|
29
|
+
*
|
|
30
|
+
* Uses static exchange rates from {@link FALLBACK_RATES} to estimate the
|
|
31
|
+
* output amount. If the token pair is not in the static table the rate
|
|
32
|
+
* defaults to `1`.
|
|
33
|
+
*
|
|
34
|
+
* @param params - The original intent parameters
|
|
35
|
+
* @param reason - Fallback metadata describing why the fallback was triggered
|
|
36
|
+
* @returns A complete {@link LifiQuotePayload} with `provider: 'fallback'`
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildFallbackQuote(params: IntentParams, reason: LifiFallback): LifiQuotePayload;
|
|
39
|
+
/**
|
|
40
|
+
* Build a fallback route payload when the LI.FI SDK is unavailable.
|
|
41
|
+
*
|
|
42
|
+
* The route payload contains no execution steps but preserves the chain and
|
|
43
|
+
* token metadata so callers can still display useful information.
|
|
44
|
+
*
|
|
45
|
+
* @param params - The original intent parameters
|
|
46
|
+
* @param reason - Fallback metadata describing why the fallback was triggered
|
|
47
|
+
* @returns A complete {@link LifiRoutePayload} with `provider: 'fallback'`
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildFallbackRoute(params: IntentParams, reason: LifiFallback): LifiRoutePayload;
|
|
50
|
+
/**
|
|
51
|
+
* Build a fallback status payload when the LI.FI SDK is unavailable.
|
|
52
|
+
*
|
|
53
|
+
* @param txHash - The transaction hash being queried (may be `undefined`)
|
|
54
|
+
* @param reason - Fallback metadata describing why the fallback was triggered
|
|
55
|
+
* @returns A complete {@link LifiStatusPayload} with `provider: 'fallback'`
|
|
56
|
+
*/
|
|
57
|
+
export declare function buildFallbackStatus(txHash: string | undefined, reason: LifiFallback): LifiStatusPayload;
|
|
58
|
+
//# sourceMappingURL=fallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../src/lifi/fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGtG;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAOjD,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,GACnB,gBAAgB,CAgClB;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,GACnB,gBAAgB,CAsBlB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,MAAM,EAAE,YAAY,GACnB,iBAAiB,CAUnB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Barrel export for the LI.FI integration submodule.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports all public types, classes, and functions from the lifi submodule
|
|
5
|
+
* so consumers can import from a single entry point.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export { LifiProvider } from './lifi-provider.js';
|
|
10
|
+
export type { LifiConfig } from './lifi-provider.js';
|
|
11
|
+
export type { LifiProviderType, LifiReasonCode, LifiFallback, LifiQuotePayload, LifiRoutePayload, LifiStatusPayload, } from './types.js';
|
|
12
|
+
export { resolveChain, getSupportedChains } from './chain-map.js';
|
|
13
|
+
export type { ChainResolution } from './chain-map.js';
|
|
14
|
+
export { resolveToken, getSupportedTokens } from './token-map.js';
|
|
15
|
+
export type { TokenInfo, TokenResolution } from './token-map.js';
|
|
16
|
+
export { toBaseUnits, fromBaseUnits } from './utils.js';
|
|
17
|
+
export { buildFallbackQuote, buildFallbackRoute, buildFallbackStatus, deterministicId, FALLBACK_RATES, } from './fallback.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lifi/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAGrD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAClE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,cAAc,GACf,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LifiProvider — main entry point for all LI.FI operations.
|
|
3
|
+
*
|
|
4
|
+
* Handles initialization, parameter validation, SDK delegation,
|
|
5
|
+
* response normalization, retry logic, and fallback.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import type { IntentParams } from '../types.js';
|
|
10
|
+
import type { LifiQuotePayload, LifiRoutePayload, LifiStatusPayload } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Configuration options for the LI.FI SDK integration.
|
|
13
|
+
*/
|
|
14
|
+
export interface LifiConfig {
|
|
15
|
+
/** LI.FI integrator identifier (max 23 chars). Default: "jackkernel" */
|
|
16
|
+
integrator?: string;
|
|
17
|
+
/** Optional API key for higher rate limits */
|
|
18
|
+
apiKey?: string;
|
|
19
|
+
/** LI.FI API base URL. Default: "https://li.quest/v1" */
|
|
20
|
+
apiUrl?: string;
|
|
21
|
+
/** Custom RPC URLs per chain ID */
|
|
22
|
+
rpcUrls?: Record<number, string[]>;
|
|
23
|
+
/** Supported chain IDs. Default: [42161, 10, 8453, 137] */
|
|
24
|
+
chains?: number[];
|
|
25
|
+
/** Request timeout in ms. Default: 30000 */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
/** Max retry attempts for retryable errors. Default: 3 */
|
|
28
|
+
maxRetries?: number;
|
|
29
|
+
/** Initial retry delay in ms. Default: 1000 */
|
|
30
|
+
retryDelay?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* LifiProvider wraps the `@lifi/sdk` to provide quote fetching, route
|
|
34
|
+
* discovery, status tracking, and execution capabilities for the JACK SDK.
|
|
35
|
+
*
|
|
36
|
+
* The constructor calls `createConfig` from `@lifi/sdk` with the integrator
|
|
37
|
+
* string "jackkernel" and any user-supplied configuration. Each public method
|
|
38
|
+
* validates input, delegates to the SDK with retry logic, normalizes the
|
|
39
|
+
* response, and falls back to the FallbackProvider on any error.
|
|
40
|
+
*/
|
|
41
|
+
export declare class LifiProvider {
|
|
42
|
+
private readonly config;
|
|
43
|
+
/**
|
|
44
|
+
* Create a new LifiProvider.
|
|
45
|
+
*
|
|
46
|
+
* @param userConfig - Optional configuration overrides
|
|
47
|
+
* @throws If `createConfig` from `@lifi/sdk` fails
|
|
48
|
+
*/
|
|
49
|
+
constructor(userConfig?: LifiConfig);
|
|
50
|
+
/**
|
|
51
|
+
* Fetch a quote for the given intent parameters.
|
|
52
|
+
*
|
|
53
|
+
* Validates params, resolves chains/tokens, calls `getQuote` from `@lifi/sdk`
|
|
54
|
+
* with retry, normalizes the response, and falls back on error.
|
|
55
|
+
*
|
|
56
|
+
* @param params - Intent parameters
|
|
57
|
+
* @returns A normalized {@link LifiQuotePayload}
|
|
58
|
+
*/
|
|
59
|
+
fetchQuote(params: IntentParams): Promise<LifiQuotePayload>;
|
|
60
|
+
/**
|
|
61
|
+
* Fetch the best route for the given intent parameters.
|
|
62
|
+
*
|
|
63
|
+
* Validates params, resolves chains/tokens, calls `getRoutes` from `@lifi/sdk`
|
|
64
|
+
* with retry, selects the best route by output amount, normalizes, and falls
|
|
65
|
+
* back on error.
|
|
66
|
+
*
|
|
67
|
+
* @param params - Intent parameters
|
|
68
|
+
* @returns A normalized {@link LifiRoutePayload}
|
|
69
|
+
*/
|
|
70
|
+
fetchRoute(params: IntentParams): Promise<LifiRoutePayload>;
|
|
71
|
+
/**
|
|
72
|
+
* Check the status of a LI.FI transaction.
|
|
73
|
+
*
|
|
74
|
+
* 1. Checks for missing txHash — returns fallback with 'MISSING_TX_HASH'
|
|
75
|
+
* 2. Calls `getStatus` from `@lifi/sdk` with retry
|
|
76
|
+
* 3. If data is empty/null, returns fallback with 'LIFI_EMPTY_RESPONSE'
|
|
77
|
+
* 4. Normalizes the response into a LifiStatusPayload
|
|
78
|
+
* 5. Catches errors and returns fallback with mapped reason code
|
|
79
|
+
*
|
|
80
|
+
* @param txHash - Transaction hash to query
|
|
81
|
+
* @returns A normalized {@link LifiStatusPayload}
|
|
82
|
+
*/
|
|
83
|
+
fetchStatus(txHash?: string): Promise<LifiStatusPayload>;
|
|
84
|
+
/**
|
|
85
|
+
* Execute a function with exponential backoff retry logic.
|
|
86
|
+
*
|
|
87
|
+
* Retries on rate-limit (429) and server errors (5xx). Non-retryable errors
|
|
88
|
+
* are re-thrown immediately.
|
|
89
|
+
*
|
|
90
|
+
* @param fn - Async function to execute
|
|
91
|
+
* @returns The result of `fn`
|
|
92
|
+
* @throws The last error if all retries are exhausted
|
|
93
|
+
*/
|
|
94
|
+
executeWithRetry<T>(fn: () => Promise<T>): Promise<T>;
|
|
95
|
+
/**
|
|
96
|
+
* Determine whether an error is retryable.
|
|
97
|
+
*
|
|
98
|
+
* Retryable errors:
|
|
99
|
+
* - HTTP 429 (rate limited)
|
|
100
|
+
* - HTTP 5xx (server errors)
|
|
101
|
+
* - Network errors (TypeError, or message containing 'network' / 'fetch')
|
|
102
|
+
*
|
|
103
|
+
* @param error - The caught error
|
|
104
|
+
* @returns `true` if the request should be retried
|
|
105
|
+
*/
|
|
106
|
+
private isRetryable;
|
|
107
|
+
/**
|
|
108
|
+
* Sleep for the given number of milliseconds.
|
|
109
|
+
*
|
|
110
|
+
* @param ms - Duration in milliseconds
|
|
111
|
+
*/
|
|
112
|
+
private sleep;
|
|
113
|
+
/**
|
|
114
|
+
* Validate that all required IntentParams fields are present and valid.
|
|
115
|
+
*
|
|
116
|
+
* @param params - Intent parameters to validate
|
|
117
|
+
* @returns A {@link LifiFallback} if validation fails, or `null` if valid
|
|
118
|
+
*/
|
|
119
|
+
private validateParams;
|
|
120
|
+
/**
|
|
121
|
+
* Map an error to a LI.FI reason code based on HTTP status codes.
|
|
122
|
+
*
|
|
123
|
+
* - 400 or 422 → 'LIFI_BAD_REQUEST'
|
|
124
|
+
* - 429 → 'LIFI_RATE_LIMITED'
|
|
125
|
+
* - >= 500 → 'LIFI_SERVER_ERROR'
|
|
126
|
+
* - Otherwise → 'LIFI_UNAVAILABLE'
|
|
127
|
+
*
|
|
128
|
+
* @param error - The caught error
|
|
129
|
+
* @returns The appropriate {@link LifiReasonCode}
|
|
130
|
+
*/
|
|
131
|
+
private mapErrorToReasonCode;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=lifi-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifi-provider.d.ts","sourceRoot":"","sources":["../../../src/lifi/lifi-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAEV,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,YAAY,CAAC;AAWpB;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAwBD;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IAExC;;;;;OAKG;gBACS,UAAU,CAAC,EAAE,UAAU;IAkCnC;;;;;;;;OAQG;IACG,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmHjE;;;;;;;;;OASG;IACG,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAoIjE;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAwD9D;;;;;;;;;OASG;IACG,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAmB3D;;;;;;;;;;OAUG;IACH,OAAO,CAAC,WAAW;IA0BnB;;;;OAIG;IACH,OAAO,CAAC,KAAK;IAIb;;;;;OAKG;IACH,OAAO,CAAC,cAAc;IAiCtB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,oBAAoB;CAe7B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TokenMap — pure mapping module for token symbol → address resolution.
|
|
3
|
+
*
|
|
4
|
+
* Lookups are case-insensitive via `symbol.toUpperCase()`.
|
|
5
|
+
*/
|
|
6
|
+
export interface TokenInfo {
|
|
7
|
+
address: string;
|
|
8
|
+
decimals: number;
|
|
9
|
+
}
|
|
10
|
+
export type TokenResolution = {
|
|
11
|
+
ok: true;
|
|
12
|
+
token: TokenInfo;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
reason: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Resolve a token symbol on a given chain to its on-chain address and decimal count.
|
|
19
|
+
*
|
|
20
|
+
* @param chainId - Numeric chain ID (e.g. 42161 for Arbitrum)
|
|
21
|
+
* @param symbol - Token symbol (case-insensitive), e.g. "usdc", "WETH"
|
|
22
|
+
* @returns A discriminated union: `{ ok: true, token }` on success,
|
|
23
|
+
* `{ ok: false, reason }` when the token is not supported on the chain.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveToken(chainId: number, symbol: string): TokenResolution;
|
|
26
|
+
/**
|
|
27
|
+
* Return a copy of the token mappings for a given chain.
|
|
28
|
+
*
|
|
29
|
+
* @param chainId - Numeric chain ID
|
|
30
|
+
* @returns A new `Record<string, TokenInfo>` with all supported token entries for the chain,
|
|
31
|
+
* or an empty object if the chain is not supported.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSupportedTokens(chainId: number): Record<string, TokenInfo>;
|
|
34
|
+
//# sourceMappingURL=token-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-map.d.ts","sourceRoot":"","sources":["../../../src/lifi/token-map.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC9B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA8BlC;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,eAAe,CAU7E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAW7E"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export type LifiProviderType = 'lifi' | 'fallback';
|
|
2
|
+
export type LifiReasonCode = 'MISSING_PARAMS' | 'INVALID_AMOUNT' | 'UNSUPPORTED_CHAIN' | 'UNSUPPORTED_TOKEN' | 'LIFI_BAD_REQUEST' | 'LIFI_RATE_LIMITED' | 'LIFI_SERVER_ERROR' | 'LIFI_UNAVAILABLE' | 'LIFI_EMPTY_RESPONSE' | 'MISSING_TX_HASH';
|
|
3
|
+
export interface LifiFallback {
|
|
4
|
+
enabled: true;
|
|
5
|
+
reasonCode: LifiReasonCode;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LifiQuotePayload {
|
|
9
|
+
provider: LifiProviderType;
|
|
10
|
+
routeId: string;
|
|
11
|
+
timestamp: number;
|
|
12
|
+
quote: {
|
|
13
|
+
amountIn: string;
|
|
14
|
+
amountOut: string;
|
|
15
|
+
minAmountOut?: string;
|
|
16
|
+
fromChainId: number;
|
|
17
|
+
toChainId: number;
|
|
18
|
+
fromToken: string;
|
|
19
|
+
toToken: string;
|
|
20
|
+
estimatedGasUsd?: string;
|
|
21
|
+
};
|
|
22
|
+
raw?: unknown;
|
|
23
|
+
fallback?: LifiFallback;
|
|
24
|
+
}
|
|
25
|
+
export interface LifiRoutePayload {
|
|
26
|
+
provider: LifiProviderType;
|
|
27
|
+
routeId: string;
|
|
28
|
+
timestamp: number;
|
|
29
|
+
route?: {
|
|
30
|
+
fromChainId: number;
|
|
31
|
+
toChainId: number;
|
|
32
|
+
fromToken: string;
|
|
33
|
+
toToken: string;
|
|
34
|
+
steps?: unknown[];
|
|
35
|
+
tags?: string[];
|
|
36
|
+
estimatedDuration?: number;
|
|
37
|
+
};
|
|
38
|
+
raw?: unknown;
|
|
39
|
+
fallback?: LifiFallback;
|
|
40
|
+
}
|
|
41
|
+
export interface LifiStatusPayload {
|
|
42
|
+
provider: LifiProviderType;
|
|
43
|
+
timestamp: number;
|
|
44
|
+
status: {
|
|
45
|
+
state: string;
|
|
46
|
+
substatus?: string;
|
|
47
|
+
txHash?: string;
|
|
48
|
+
};
|
|
49
|
+
raw?: unknown;
|
|
50
|
+
fallback?: LifiFallback;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@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,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE;QACN,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit conversion utilities for converting between human-readable token amounts
|
|
3
|
+
* and base unit (wei-like) representations.
|
|
4
|
+
*
|
|
5
|
+
* Ported from apps/dashboard/src/lib/lifi.ts for reuse across the SDK.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Converts a human-readable token amount to its base unit representation.
|
|
9
|
+
*
|
|
10
|
+
* For example, converting "1.5" USDC (6 decimals) produces "1500000",
|
|
11
|
+
* and converting "1.5" ETH (18 decimals) produces "1500000000000000000".
|
|
12
|
+
*
|
|
13
|
+
* @param amount - The human-readable amount as a string (e.g. "1.5", "100", "0.001")
|
|
14
|
+
* @param decimals - The number of decimal places for the token
|
|
15
|
+
* @returns The amount in base units as a string with no decimal point
|
|
16
|
+
*/
|
|
17
|
+
export declare function toBaseUnits(amount: string, decimals: number): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a base unit amount back to a human-readable representation.
|
|
20
|
+
*
|
|
21
|
+
* For example, converting "1500000" with 6 decimals produces "1.5",
|
|
22
|
+
* and converting "1500000000000000000" with 18 decimals produces "1.5".
|
|
23
|
+
*
|
|
24
|
+
* @param amount - The base unit amount as a string (e.g. "1500000", "1000000000000000000")
|
|
25
|
+
* @param decimals - The number of decimal places for the token
|
|
26
|
+
* @returns The human-readable amount as a string with trailing zeros removed
|
|
27
|
+
*/
|
|
28
|
+
export declare function fromBaseUnits(amount: string, decimals: number): string;
|
|
29
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lifi/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMtE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jack-kernel/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "TypeScript SDK for JACK cross-chain execution kernel",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"url": "https://github.com/your-org/jack.git",
|
|
32
32
|
"directory": "packages/sdk"
|
|
33
33
|
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@lifi/sdk": "^3.15.5"
|
|
36
|
+
},
|
|
34
37
|
"peerDependencies": {
|
|
35
38
|
"viem": "^2.0.0"
|
|
36
39
|
},
|