@anywalletkit/protocol-swap2-kyberswap 0.1.0 → 0.2.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/README.md +39 -2
- package/dist/activity.cjs +4 -0
- package/dist/activity.cjs.map +1 -1
- package/dist/activity.js +2 -2
- package/dist/{chunk-FWC6K553.js → chunk-5ZMVXS7P.js} +2 -2
- package/dist/{chunk-PIC4PYGN.js → chunk-LO4G4NX7.js} +3 -3
- package/dist/{chunk-WOVGN3FL.js → chunk-OHBN7OQI.js} +6 -1
- package/dist/{chunk-WOVGN3FL.js.map → chunk-OHBN7OQI.js.map} +1 -1
- package/dist/{chunk-DEWODPQQ.js → chunk-RZ2CCM34.js} +13 -3
- package/dist/chunk-RZ2CCM34.js.map +1 -0
- package/dist/index.cjs +14 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -4
- package/dist/protocol.cjs +12 -0
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.js +4 -4
- package/dist/provider.cjs +13 -0
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.d.cts +8 -1
- package/dist/provider.d.ts +8 -1
- package/dist/provider.js +5 -3
- package/dist/router.cjs +5 -0
- package/dist/router.cjs.map +1 -1
- package/dist/router.d.cts +9 -1
- package/dist/router.d.ts +9 -1
- package/dist/router.js +3 -1
- package/package.json +5 -5
- package/dist/chunk-DEWODPQQ.js.map +0 -1
- /package/dist/{chunk-FWC6K553.js.map → chunk-5ZMVXS7P.js.map} +0 -0
- /package/dist/{chunk-PIC4PYGN.js.map → chunk-LO4G4NX7.js.map} +0 -0
package/dist/router.d.cts
CHANGED
|
@@ -170,6 +170,14 @@ declare function kyberApiSlippage(amountOut: bigint, bps: number): number | null
|
|
|
170
170
|
* pass {@link checkKyberTransaction} against this app's request. A dry quote carries no transaction. The reason it fails, or null.
|
|
171
171
|
*/
|
|
172
172
|
declare function kyberVerifyQuote(params: QuoteParams, quote: Quote): string | null;
|
|
173
|
+
/**
|
|
174
|
+
* The provider's `exactAllowanceOnly` (protocol-swap2-core): true on the chains whose router is the `generic` build —
|
|
175
|
+
* `swapGeneric` behind an owner-managed executor whitelist, so the router's owner (a single key on all but Linea) could
|
|
176
|
+
* make it spend an allowance left on it. The engine then approves exactly the input and revokes it when the swap does
|
|
177
|
+
* not spend it, whatever the app's `allowanceReuse` / `revokeUnspentApproval` say. False on the `lite` chains; true
|
|
178
|
+
* for a chain this module does not know (fail closed).
|
|
179
|
+
*/
|
|
180
|
+
declare function kyberExactAllowanceOnly(chain: string): boolean;
|
|
173
181
|
/**
|
|
174
182
|
* The router a KyberSwap swap calls and approves, and {@link kyberVerifyQuote}: the app's side of
|
|
175
183
|
* `remoteProvider({name: "kyberswap", baseUrl, ...kyberPins})`, so a backend's quote is checked against the pinned
|
|
@@ -177,4 +185,4 @@ declare function kyberVerifyQuote(params: QuoteParams, quote: Quote): string | n
|
|
|
177
185
|
*/
|
|
178
186
|
declare const kyberPins: RemotePins;
|
|
179
187
|
|
|
180
|
-
export { type DecodedKyberSwap, type EncodedTx, type ExpectedKyberSwap, KYBER_CHAINS, KYBER_EXECUTOR, KYBER_FLAGS_ALLOWED, KYBER_NATIVE, KYBER_REFUSED_SELECTORS, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, KYBER_SWAP_SELECTOR, type KyberRouterBuild, KyberTransactionError, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberMinimum, kyberNativeSwaps, kyberPins, kyberVerifyQuote };
|
|
188
|
+
export { type DecodedKyberSwap, type EncodedTx, type ExpectedKyberSwap, KYBER_CHAINS, KYBER_EXECUTOR, KYBER_FLAGS_ALLOWED, KYBER_NATIVE, KYBER_REFUSED_SELECTORS, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, KYBER_SWAP_SELECTOR, type KyberRouterBuild, KyberTransactionError, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberExactAllowanceOnly, kyberMinimum, kyberNativeSwaps, kyberPins, kyberVerifyQuote };
|
package/dist/router.d.ts
CHANGED
|
@@ -170,6 +170,14 @@ declare function kyberApiSlippage(amountOut: bigint, bps: number): number | null
|
|
|
170
170
|
* pass {@link checkKyberTransaction} against this app's request. A dry quote carries no transaction. The reason it fails, or null.
|
|
171
171
|
*/
|
|
172
172
|
declare function kyberVerifyQuote(params: QuoteParams, quote: Quote): string | null;
|
|
173
|
+
/**
|
|
174
|
+
* The provider's `exactAllowanceOnly` (protocol-swap2-core): true on the chains whose router is the `generic` build —
|
|
175
|
+
* `swapGeneric` behind an owner-managed executor whitelist, so the router's owner (a single key on all but Linea) could
|
|
176
|
+
* make it spend an allowance left on it. The engine then approves exactly the input and revokes it when the swap does
|
|
177
|
+
* not spend it, whatever the app's `allowanceReuse` / `revokeUnspentApproval` say. False on the `lite` chains; true
|
|
178
|
+
* for a chain this module does not know (fail closed).
|
|
179
|
+
*/
|
|
180
|
+
declare function kyberExactAllowanceOnly(chain: string): boolean;
|
|
173
181
|
/**
|
|
174
182
|
* The router a KyberSwap swap calls and approves, and {@link kyberVerifyQuote}: the app's side of
|
|
175
183
|
* `remoteProvider({name: "kyberswap", baseUrl, ...kyberPins})`, so a backend's quote is checked against the pinned
|
|
@@ -177,4 +185,4 @@ declare function kyberVerifyQuote(params: QuoteParams, quote: Quote): string | n
|
|
|
177
185
|
*/
|
|
178
186
|
declare const kyberPins: RemotePins;
|
|
179
187
|
|
|
180
|
-
export { type DecodedKyberSwap, type EncodedTx, type ExpectedKyberSwap, KYBER_CHAINS, KYBER_EXECUTOR, KYBER_FLAGS_ALLOWED, KYBER_NATIVE, KYBER_REFUSED_SELECTORS, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, KYBER_SWAP_SELECTOR, type KyberRouterBuild, KyberTransactionError, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberMinimum, kyberNativeSwaps, kyberPins, kyberVerifyQuote };
|
|
188
|
+
export { type DecodedKyberSwap, type EncodedTx, type ExpectedKyberSwap, KYBER_CHAINS, KYBER_EXECUTOR, KYBER_FLAGS_ALLOWED, KYBER_NATIVE, KYBER_REFUSED_SELECTORS, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, KYBER_SWAP_SELECTOR, type KyberRouterBuild, KyberTransactionError, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberExactAllowanceOnly, kyberMinimum, kyberNativeSwaps, kyberPins, kyberVerifyQuote };
|
package/dist/router.js
CHANGED
|
@@ -12,11 +12,12 @@ import {
|
|
|
12
12
|
checkKyberTransaction,
|
|
13
13
|
kyberApiSlippage,
|
|
14
14
|
kyberChain,
|
|
15
|
+
kyberExactAllowanceOnly,
|
|
15
16
|
kyberMinimum,
|
|
16
17
|
kyberNativeSwaps,
|
|
17
18
|
kyberPins,
|
|
18
19
|
kyberVerifyQuote
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-OHBN7OQI.js";
|
|
20
21
|
export {
|
|
21
22
|
KYBER_CHAINS,
|
|
22
23
|
KYBER_EXECUTOR,
|
|
@@ -31,6 +32,7 @@ export {
|
|
|
31
32
|
checkKyberTransaction,
|
|
32
33
|
kyberApiSlippage,
|
|
33
34
|
kyberChain,
|
|
35
|
+
kyberExactAllowanceOnly,
|
|
34
36
|
kyberMinimum,
|
|
35
37
|
kyberNativeSwaps,
|
|
36
38
|
kyberPins,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anywalletkit/protocol-swap2-kyberswap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "KyberSwap Aggregator same-chain swaps for Any Wallet Kit: exact-input routes on 18 EVM chains, settled through MetaAggregationRouterV2, with the encoded transaction decoded strictly and checked against the request before signing.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://docs.anywallet.tech",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"viem": "^2.57.2",
|
|
58
|
-
"@anywalletkit/protocol-swap2-core": "0.
|
|
58
|
+
"@anywalletkit/protocol-swap2-core": "0.18.0",
|
|
59
59
|
"@anywalletkit/swap2-assets": "0.3.0",
|
|
60
|
-
"@anywalletkit/protocol-swap2-wrap": "0.
|
|
60
|
+
"@anywalletkit/protocol-swap2-wrap": "0.5.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@anywalletkit/core": "0.9.0"
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^22",
|
|
67
67
|
"vitest": "^5.1.0",
|
|
68
|
-
"@anywalletkit/
|
|
69
|
-
"@anywalletkit/
|
|
68
|
+
"@anywalletkit/core": "0.9.0",
|
|
69
|
+
"@anywalletkit/conformance": "0.6.1"
|
|
70
70
|
},
|
|
71
71
|
"keywords": [
|
|
72
72
|
"swap2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/provider.ts"],"sourcesContent":["import {decodeErrorResult, decodeFunctionData, encodeFunctionData, getAddress, parseAbi, type Hex} from \"viem\";\nimport {evmRef, isEvm, timeoutSignal, sourceAssetOf} from \"@anywalletkit/protocol-swap2-core/util\";\nimport {httpRefusal, refusal, refusalOf, withReason, type Swap2RefusalInfo, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\nimport {ccAssetByToken} from \"@anywalletkit/swap2-assets\";\nimport {WRAPPED_NATIVE} from \"@anywalletkit/protocol-swap2-wrap/provider\";\nimport {describeKyberActivity} from \"./activity.js\";\nimport {KYBER_NATIVE, KYBER_ROUTER_ABI, KYBER_ROUTER_V2, KYBER_ROUTER_V3, checkKyberTransaction, kyberApiSlippage, kyberChain, kyberMinimum, kyberNativeSwaps} from \"./router.js\";\n\n/**\n * KyberSwap Aggregator (docs.kyberswap.com) as a same-chain swap2 provider: exact-input swaps on the chains in\n * `KYBER_CHAINS`, routed by KyberSwap and settled through MetaAggregationRouterV2.\n *\n * A dry quote is `GET /routes` only. An execution quote (the engine's, with `dry: false`) also calls\n * `POST /route/build` and returns the encoded transaction, checked field by field against the request\n * (`checkKyberTransaction`): the build endpoint encodes whatever route summary it is sent, fee entries included, so\n * nothing in its answer is taken on trust. Before the transaction is signed it is simulated from the account at the\n * latest block; with no RPC answering, the swap is refused.\n *\n * Keyless by default (the public API, 3 requests per second per IP). With `apiKey`, requests go to KyberSwap's API\n * gateway instead. No integrator fee is ever charged; KyberSwap keeps any output above the quote (positive slippage).\n */\n\nconst ZERO = \"0x0000000000000000000000000000000000000000\";\nconst PUBLIC_BASE_URL = \"https://aggregator-api.kyberswap.com\";\nconst GATEWAY_BASE_URL = \"https://api.kyberswap.com/swap\";\nconst DEFAULT_SLIPPAGE_BPS = 50;\n/** How long a quote stays executable for the engine: the user's review fits, an approval mined meanwhile gets one re-quote. */\nconst DEFAULT_TTL_MS = 30_000;\n/** A dry route is reused this long for the same request (KyberSwap asks not to cache routes for more than 5–10 s). */\nconst DRY_CACHE_MS = 5_000;\n/** The executor's own deadline for a built swap (the build endpoint's default). */\nconst BUILD_DEADLINE_S = 20 * 60;\n\n/**\n * KyberSwap's error codes (docs.kyberswap.com, aggregator API errors) → refusal reasons. 4222: the route quoted\n * under KyberSwap's own estimate; 4227: its gas estimation failed.\n */\nconst ERROR_REASONS: Readonly<Record<number, Swap2RefusalReason>> = {\n 4000: \"policy_refused\", 4001: \"policy_refused\", 4002: \"policy_refused\", 4005: \"policy_refused\", 4007: \"policy_refused\", 40017: \"policy_refused\",\n 4008: \"no_route\", 40011: \"no_route\",\n 4009: \"insufficient_liquidity\", 4010: \"insufficient_liquidity\",\n 4011: \"unsupported_pair\", 4221: \"unsupported_pair\",\n 4222: \"price_check_failed\",\n 4227: \"simulation_failed\",\n};\nconst errorReason = (code: unknown): Swap2RefusalReason | undefined =>\n typeof code === \"number\" && Object.prototype.hasOwnProperty.call(ERROR_REASONS, code) ? ERROR_REASONS[code] : undefined;\n\nexport interface KyberswapProviderConfig {\n enabled?: boolean;\n /** `x-client-id` and the build's `source` (written on-chain in the swap's `clientData`). Default \"anywalletkit\". */\n clientId?: string;\n /** KyberSwap API-gateway key (`X-Api-Key`); keep it on a server. Without it the keyless public API is used. */\n apiKey?: string;\n /** Override the API base (`{baseUrl}/{chain}/api/v1/...`). */\n baseUrl?: string;\n /** JSON-RPC endpoints per chain id: required for execution (pre-broadcast simulation) and receipts. */\n rpcUrls?: Readonly<Record<number, readonly string[]>>;\n /** Chains to quote on (default: every chain in `KYBER_CHAINS`). */\n enabledChains?: readonly number[];\n defaultSlippageBps?: number;\n quoteTtlMs?: number;\n timeoutMs?: number;\n /** Leave RFQ / private-market-maker sources out of routes (short-lived quotes; default true). */\n excludeRfqSources?: boolean;\n /** KyberSwap source ids to leave out of routes. */\n excludedSources?: readonly string[];\n}\n\ninterface RouteSummary {\n tokenIn?: string;\n amountIn?: string;\n tokenOut?: string;\n amountOut?: string;\n amountInUsd?: string;\n amountOutUsd?: string;\n gas?: string;\n extraFee?: {feeAmount?: string; feeReceiver?: string; chargeFeeBy?: string; isInBps?: boolean};\n route?: {pool?: string; exchange?: string}[][];\n routeID?: string;\n [k: string]: unknown;\n}\n\nconst uint = (v: unknown): bigint | null => (typeof v === \"string\" && /^\\d{1,78}$/.test(v) ? BigInt(v) : typeof v === \"number\" && Number.isSafeInteger(v) && v >= 0 ? BigInt(v) : null);\nconst isAddr = (a: unknown): a is string => typeof a === \"string\" && /^0x[0-9a-fA-F]{40}$/.test(a);\nconst same = (a: unknown, b: string): boolean => isAddr(a) && a.toLowerCase() === b.toLowerCase();\nconst sameText = (a: string, b: string): boolean => a.length === b.length && a.toLowerCase() === b.toLowerCase();\nconst sameAmount = (a: string, b: string): boolean => /^\\d{1,80}$/.test(a) && /^\\d{1,80}$/.test(b) && BigInt(a) === BigInt(b);\nconst apiToken = (t: string): string => (t === ZERO ? KYBER_NATIVE : t);\n/** An API text as it may appear in a refusal: one line, at most 120 characters. */\nconst short = (s: unknown): string => String(s ?? \"\").replace(/\\s+/g, \" \").slice(0, 120);\n\nconst ERC20_READS = parseAbi([\"function balanceOf(address) view returns (uint256)\", \"function allowance(address, address) view returns (uint256)\", \"function approve(address, uint256) returns (bool)\"]);\n\n/** The revert data an RPC error carries, at most 4 KB of it. */\nfunction revertData(e: unknown): Hex | null {\n const err = e as {data?: unknown; message?: unknown};\n const nested = err.data && typeof err.data === \"object\" ? (err.data as {data?: unknown}).data : undefined;\n for (const v of [err.data, nested]) if (typeof v === \"string\" && /^0x(?:[0-9a-fA-F]{2}){4,4096}$/.test(v)) return v as Hex;\n return null;\n}\n/**\n * KyberSwap's own USD value of the output against the input, as basis points lost (pool impact and pool fees together).\n * Information for the user's \"be careful\" warning, never a refusal. null when KyberSwap does not price either side\n * (\"0\" means unpriced, not worthless) or the numbers are not plain decimals.\n */\nexport function kyberValueLossBps(amountInUsd: unknown, amountOutUsd: unknown): number | null {\n const num = (v: unknown) => (typeof v === \"string\" && /^\\d{1,15}(\\.\\d{1,30})?$/.test(v) ? Number(v) : null);\n const vin = num(amountInUsd), vout = num(amountOutUsd);\n if (vin === null || vout === null || vin <= 0 || vout <= 0) return null;\n return Math.min(10_000, Math.max(0, Math.round(((vin - vout) / vin) * 10_000)));\n}\n\n/** `Error(string)` from revert data, if that is what it is. */\nfunction revertString(e: unknown): string | null {\n const data = revertData(e);\n if (data) {\n try {\n // viem knows Error(string) and Panic(uint256) without an ABI.\n const r = decodeErrorResult({abi: [], data});\n if (r.errorName === \"Error\" && typeof r.args?.[0] === \"string\") return r.args[0].slice(0, 200);\n } catch {\n // not a plain revert string\n }\n }\n const m = e instanceof Error ? /execution reverted:?\\s*([^\\n]{1,160})/.exec(e.message) : null;\n return m ? m[1]! : null;\n}\n\nexport function kyberswapProvider(config: KyberswapProviderConfig = {}): CrossChainProvider {\n const baseUrl = (config.baseUrl ?? (config.apiKey ? GATEWAY_BASE_URL : PUBLIC_BASE_URL)).replace(/\\/+$/, \"\");\n const clientId = config.clientId ?? \"anywalletkit\";\n const slippageDefault = config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;\n const ttl = config.quoteTtlMs ?? DEFAULT_TTL_MS;\n const timeoutMs = config.timeoutMs ?? 10_000;\n const enabledChains = config.enabledChains ? new Set(config.enabledChains) : null;\n // KyberSwap asked (2026-11-25): with a key, send X-Api-Key only, without x-client-id.\n // The build's `source` still carries the client id on-chain.\n const headers: Record<string, string> = config.apiKey ? {\"x-api-key\": config.apiKey} : {\"x-client-id\": clientId};\n const dryCache = new Map<string, {at: number; value: Promise<RoutesResult>}>();\n\n const chainIdOf = (caip2: string): number | null => {\n if (!isEvm(caip2)) return null;\n const id = evmRef(caip2);\n return kyberChain(id) && (!enabledChains || enabledChains.has(id)) ? id : null;\n };\n\n async function rpc(chainId: number, method: string, params: unknown[]): Promise<unknown> {\n let lastErr: unknown;\n for (const url of config.rpcUrls?.[chainId] ?? []) {\n try {\n const res = await fetch(url, {method: \"POST\", headers: {\"content-type\": \"application/json\"}, body: JSON.stringify({jsonrpc: \"2.0\", id: 1, method, params}), signal: timeoutSignal(12_000)});\n if (!res.ok) {\n const error = new Error(`HTTP ${res.status}`);\n const info = httpRefusal(res.status, res.headers?.get?.(\"retry-after\"));\n throw info ? withReason(error, info) : error;\n }\n const body = (await res.json()) as {result?: unknown; error?: {message?: string; data?: unknown}};\n if (body.error) throw Object.assign(new Error(body.error.message ?? \"rpc error\"), {rpc: true, data: body.error.data});\n return body.result ?? null;\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) throw e;\n lastErr = e;\n }\n }\n throw withReason(new Error(`kyberswap: no RPC answered on chain ${chainId} (${lastErr instanceof Error ? lastErr.message : String(lastErr ?? \"none configured\")})`), refusalOf(lastErr) ?? \"upstream_unavailable\");\n }\n\n type ApiResult = {ok: true; data: Record<string, unknown>} | {ok: false; why: string; info?: Swap2RefusalReason | Swap2RefusalInfo};\n async function api(url: string, init: RequestInit, signal?: AbortSignal): Promise<ApiResult> {\n let res: Response;\n try {\n res = await fetch(url, {...init, headers: {...headers, ...(init.body ? {\"content-type\": \"application/json\"} : {})}, signal: signal ?? timeoutSignal(timeoutMs)});\n } catch (e) {\n return {ok: false, why: `API unreachable (${e instanceof Error ? e.name : \"error\"})`, ...(signal?.aborted ? {} : {info: \"upstream_unavailable\" as const})};\n }\n type Body = {code?: unknown; message?: unknown; data?: unknown};\n let body: Body | null;\n try {\n const parsed: unknown = await res.json();\n body = parsed && typeof parsed === \"object\" ? (parsed as Body) : null;\n } catch {\n body = null;\n }\n if (res.status === 429) return {ok: false, why: \"rate limited (HTTP 429)\", info: httpRefusal(429, res.headers?.get?.(\"retry-after\")) ?? \"rate_limited\"};\n if (res.status === 401 || res.status === 403) return {ok: false, why: `API key rejected (HTTP ${res.status})`, info: httpRefusal(res.status) ?? \"policy_refused\"};\n if (res.status === 404 && !body?.code) return {ok: false, why: \"KyberSwap does not serve this chain (HTTP 404)\", info: \"unsupported_pair\"};\n if (!res.ok || body?.code !== 0) {\n const code = typeof body?.code === \"number\" ? body.code : undefined;\n const reason = errorReason(code) ?? (res.status >= 500 ? \"upstream_unavailable\" : undefined);\n return {ok: false, why: `${code !== undefined ? `error ${code}` : `HTTP ${res.status}`}${body?.message ? `: ${short(body.message)}` : \"\"}`, ...(reason ? {info: reason} : {})};\n }\n if (!body?.data || typeof body.data !== \"object\") return {ok: false, why: \"malformed API response\", info: \"upstream_unavailable\"};\n return {ok: true, data: body.data as Record<string, unknown>};\n }\n\n type RoutesResult = {ok: true; summary: RouteSummary; amountOut: bigint; sources: string[]} | {ok: false; why: string; info?: Swap2RefusalReason | Swap2RefusalInfo};\n async function routes(chainId: number, tokenIn: string, tokenOut: string, amountIn: bigint, signal?: AbortSignal): Promise<RoutesResult> {\n const q = new URLSearchParams({tokenIn: apiToken(tokenIn), tokenOut: apiToken(tokenOut), amountIn: amountIn.toString(), gasInclude: \"true\"});\n if (config.excludeRfqSources ?? true) q.set(\"excludeRFQSources\", \"true\");\n if (config.excludedSources?.length) q.set(\"excludedSources\", config.excludedSources.join(\",\"));\n const r = await api(`${baseUrl}/${kyberChain(chainId)!.slug}/api/v1/routes?${q}`, {method: \"GET\"}, signal);\n if (!r.ok) return r;\n const summary = r.data.routeSummary as RouteSummary | undefined;\n const router = r.data.routerAddress;\n if (!summary || typeof summary !== \"object\") return {ok: false, why: \"malformed API response (no route)\", info: \"upstream_unavailable\"};\n if (same(router, KYBER_ROUTER_V3)) return {ok: false, why: \"Kyber router V3 not supported yet\", info: \"policy_refused\"};\n if (!same(router, KYBER_ROUTER_V2)) return {ok: false, why: \"the route settles through another router than the pinned one\", info: \"vault_mismatch\"};\n if (!same(summary.tokenIn, apiToken(tokenIn)) || !same(summary.tokenOut, apiToken(tokenOut))) return {ok: false, why: \"the route swaps other tokens than requested\", info: \"policy_refused\"};\n if (uint(summary.amountIn) !== amountIn) return {ok: false, why: \"the route prices another amount\", info: \"price_check_failed\"};\n const fee = summary.extraFee;\n // No fee is ever asked for: the API answers with empty fields (\"\" amount, \"\" receiver); anything else is refused.\n if (fee !== undefined && fee !== null) {\n const amount = fee.feeAmount === \"\" || fee.feeAmount === undefined ? 0n : uint(fee.feeAmount);\n if (typeof fee !== \"object\" || amount !== 0n || (fee.feeReceiver !== undefined && fee.feeReceiver !== \"\")) return {ok: false, why: \"the route carries an integrator fee\", info: \"policy_refused\"};\n }\n const amountOut = uint(summary.amountOut);\n if (amountOut === null || amountOut <= 0n) return {ok: false, why: \"the route pays nothing\", info: \"no_route\"};\n const sources = [...new Set((summary.route ?? []).flat().map((h) => h?.exchange).filter((x): x is string => typeof x === \"string\"))].slice(0, 6).map((s) => s.slice(0, 40));\n return {ok: true, summary, amountOut, sources};\n }\n\n /** Why the swap reverts for `sender` now: the price (the router's minimum check), the wallet's input, or the revert as it is. */\n async function revertReason(chainId: number, sender: string, quoted: NonNullable<Quote[\"txRequest\"]>, e: unknown): Promise<Error> {\n const text = revertString(e);\n if (text && /return amount is not enough|min return/i.test(text)) {\n return refusal(\"price_check_failed\", \"kyberswap: the price moved past your minimum. Nothing was sent; refresh the quote.\");\n }\n const lack = await inputShortfall(chainId, sender, quoted).catch(() => null);\n if (lack) return refusal(\"simulation_failed\", lack);\n return refusal(\"simulation_failed\", `kyberswap: the swap would revert now (${short(text ?? (e instanceof Error ? e.message : \"revert\"))}). Nothing was sent; refresh the quote.`);\n }\n\n async function inputShortfall(chainId: number, sender: string, quoted: NonNullable<Quote[\"txRequest\"]>): Promise<string | null> {\n const call = decodeFunctionData({abi: KYBER_ROUTER_ABI, data: quoted.data as Hex});\n const desc = (call.args[0] as {desc: {srcToken: string; amount: bigint}}).desc;\n const word = (v: unknown): bigint | null => (typeof v === \"string\" && /^0x[0-9a-fA-F]{1,64}$/.test(v) ? BigInt(v) : null);\n if (same(desc.srcToken, KYBER_NATIVE)) {\n const balance = word(await rpc(chainId, \"eth_getBalance\", [sender, \"latest\"]));\n return balance !== null && balance < desc.amount ? `kyberswap: the wallet's balance is below the amount (${balance} < ${desc.amount}). Nothing was sent.` : null;\n }\n const read = (data: Hex) => rpc(chainId, \"eth_call\", [{to: desc.srcToken, data}, \"latest\"]);\n const [balance, allowance] = (await Promise.all([\n read(encodeFunctionData({abi: ERC20_READS, functionName: \"balanceOf\", args: [sender as Hex]})),\n read(encodeFunctionData({abi: ERC20_READS, functionName: \"allowance\", args: [sender as Hex, KYBER_ROUTER_V2]})),\n ])).map(word);\n if (balance != null && balance < desc.amount) return `kyberswap: the wallet's balance is below the amount (${balance} < ${desc.amount}). Nothing was sent.`;\n if (allowance != null && allowance < desc.amount) return \"kyberswap: the token approval is not visible on-chain yet. Nothing was sent; try again in a moment.\";\n return null;\n }\n\n /**\n * A token sale is checked before the user pays for an approval: with the allowance already in place the exact call\n * runs against the latest block; without it the approval and the swap run as one simulated block (eth_simulateV1),\n * so a route that reverts never asks for an approval. A wallet without the input, or an RPC that cannot simulate a\n * block, skips the check (`null` with the reason in `skipped`) — preflightDeposit still simulates before signing.\n */\n async function tokenSwapCheck(chainId: number, sender: string, token: string, amount: bigint, data: Hex): Promise<{refusal: ReturnType<typeof refuseRevert> | null; simulated: string}> {\n const word = (v: unknown): bigint | null => (typeof v === \"string\" && /^0x[0-9a-fA-F]{1,64}$/.test(v) ? BigInt(v) : null);\n const read = (call: Hex) => rpc(chainId, \"eth_call\", [{to: token, data: call}, \"latest\"]);\n const [balance, allowance] = (await Promise.all([\n read(encodeFunctionData({abi: ERC20_READS, functionName: \"balanceOf\", args: [sender as Hex]})),\n read(encodeFunctionData({abi: ERC20_READS, functionName: \"allowance\", args: [sender as Hex, KYBER_ROUTER_V2]})),\n ])).map(word);\n if (balance == null || allowance == null) return {refusal: null, simulated: \"none\"};\n if (balance < amount) return {refusal: null, simulated: \"none\"};\n if (allowance >= amount) {\n try {\n await rpc(chainId, \"eth_call\", [{from: sender, to: KYBER_ROUTER_V2, data, value: \"0x0\"}, \"latest\"]);\n return {refusal: null, simulated: \"swap\"};\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) return {refusal: refuseRevert(revertString(e)), simulated: \"swap\"};\n throw e;\n }\n }\n const approve = (n: bigint) => ({from: sender, to: token, data: encodeFunctionData({abi: ERC20_READS, functionName: \"approve\", args: [KYBER_ROUTER_V2, n]})});\n // A token that refuses to change a non-zero allowance (USDT) is reset first, as the wallet's own approval does.\n const calls = [...(allowance > 0n ? [approve(0n)] : []), approve(amount), {from: sender, to: KYBER_ROUTER_V2, data, value: \"0x0\"}];\n let result: unknown;\n try {\n result = await rpc(chainId, \"eth_simulateV1\", [{blockStateCalls: [{calls}], validation: false}, \"latest\"]);\n } catch {\n return {refusal: null, simulated: \"none\"};\n }\n type Call = {status?: unknown; returnData?: unknown; error?: {message?: unknown; data?: unknown}};\n const out = (Array.isArray(result) ? (result[0] as {calls?: Call[]} | undefined)?.calls : undefined) ?? [];\n if (out.length !== calls.length || out.slice(0, -1).some((c) => c.status !== \"0x1\")) return {refusal: null, simulated: \"none\"};\n const swap = out[out.length - 1]!;\n if (swap.status === \"0x1\") return {refusal: null, simulated: \"approve+swap\"};\n const err = {data: swap.error?.data ?? swap.returnData, message: typeof swap.error?.message === \"string\" ? swap.error.message : \"\"};\n return {refusal: refuseRevert(revertString(Object.assign(new Error(err.message), {data: err.data}))), simulated: \"approve+swap\"};\n }\n\n function refuseRevert(why: string | null): {why: string; reason: Swap2RefusalReason} {\n return {\n why: `the route does not execute on-chain right now${why ? ` (${short(why)})` : \"\"}`,\n reason: why && /return amount is not enough/i.test(why) ? \"price_check_failed\" : \"simulation_failed\",\n };\n }\n\n return {\n name: \"kyberswap\",\n describeActivity: describeKyberActivity,\n supportsSameChain: true,\n // The account's own estimate of the exact call, never the API's gas model.\n ownGasEstimate: true,\n enabled: () => config.enabled ?? true,\n supportsChain: (caip2: string) => chainIdOf(caip2) !== null,\n supportsChainPair: (from: string, to: string) => from === to && chainIdOf(from) !== null,\n supportsRoute: (from: Asset, to: Asset) => {\n if (from.chain !== to.chain) return false;\n const id = chainIdOf(from.chain);\n if (id === null) return false;\n // Native ↔ wrapped is a wrap (the Wrap provider's), which KyberSwap does not route: no request is spent on it.\n const wrapped = Object.prototype.hasOwnProperty.call(WRAPPED_NATIVE, id) ? WRAPPED_NATIVE[id]!.address : null;\n const isNative = (t: string) => /^0x0+$/.test(t) || same(t, KYBER_NATIVE) || t === ccAssetByToken(from.chain, ZERO)?.symbol;\n const isWrapped = (t: string) => !!wrapped && (same(t, wrapped) || t === WRAPPED_NATIVE[id]!.symbol);\n return !((isNative(from.token) && isWrapped(to.token)) || (isWrapped(from.token) && isNative(to.token)));\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n const refuse = (why: string, info?: Swap2RefusalReason | Swap2RefusalInfo): null => {\n params.onRefusal?.(`kyberswap: ${why}`, typeof info === \"string\" ? {reason: info} : info);\n return null;\n };\n if (params.flex) return refuse(\"amount-flexible deposits are not supported\", \"unsupported_pair\");\n if (params.sourceChain !== params.destChain) return refuse(\"same-chain swaps only\", \"unsupported_pair\");\n const chainId = chainIdOf(params.sourceChain);\n if (chainId === null) return refuse(`KyberSwap is not enabled for ${params.sourceChain}`, \"unsupported_pair\");\n const chain = kyberChain(chainId)!;\n const src = sourceAssetOf(params);\n if (!src) return refuse(`unknown source token ${params.sourceToken}`, \"unsupported_pair\");\n const tokenIn = src.contract ? getAddress(src.contract) : ZERO;\n const nativeOut = /^0x0+$/.test(params.destToken) || same(params.destToken, KYBER_NATIVE);\n if (!nativeOut && !isAddr(params.destToken)) return refuse(\"destination token must be an EVM address\", \"unsupported_pair\");\n const tokenOut = nativeOut ? ZERO : getAddress(params.destToken);\n // Refused before any request: a useless call spends the shared keyless quota.\n if (tokenIn === tokenOut) return refuse(\"same token in and out\", \"unsupported_pair\");\n if ((tokenIn === ZERO || tokenOut === ZERO) && !kyberNativeSwaps(chainId)) return refuse(`the native coin on ${chain.name} is not a catalog asset here; swap its ERC-20 instead`, \"unsupported_pair\");\n let amountIn: bigint;\n try {\n amountIn = BigInt(params.amountIn);\n } catch {\n return refuse(\"amount is not an integer\");\n }\n if (amountIn <= 0n) return refuse(\"amount must be positive\");\n const bps = params.slippageBps ?? slippageDefault;\n if (!Number.isInteger(bps) || bps <= 0 || bps >= 2_000) return refuse(\"invalid slippage (KyberSwap accepts under 20%)\", \"price_check_failed\");\n let floor = 0n;\n if (params.minAmountOut !== undefined) {\n const f = uint(params.minAmountOut);\n if (f === null) return refuse(\"minimum output is not an integer\");\n floor = f;\n }\n const dry = params.dry !== false;\n if (!dry && !isAddr(params.destAddress)) return refuse(\"recipient must be an EVM address\", \"recipient_mismatch\");\n if (!dry && !config.rpcUrls?.[chainId]?.length) return refuse(`no RPC configured for ${chain.name}: a KyberSwap swap is simulated before it is signed`, \"upstream_unavailable\");\n\n // Dry quotes for the same request share one route for a few seconds; an execution quote always asks afresh.\n let r: RoutesResult;\n if (dry) {\n const key = `${chainId}|${tokenIn}|${tokenOut}|${amountIn}`;\n const hit = dryCache.get(key);\n if (hit && Date.now() - hit.at < DRY_CACHE_MS) r = await hit.value;\n else {\n const value = routes(chainId, tokenIn, tokenOut, amountIn, signal);\n dryCache.set(key, {at: Date.now(), value});\n if (dryCache.size > 64) for (const [k, v] of dryCache) if (Date.now() - v.at >= DRY_CACHE_MS) dryCache.delete(k);\n r = await value;\n if (!r.ok) dryCache.delete(key);\n }\n } else r = await routes(chainId, tokenIn, tokenOut, amountIn, signal);\n if (!r.ok) return refuse(r.why, r.info);\n // KyberSwap's minimum lands one unit under the plain floor; asking for a hair less slippage keeps it at or\n // above the engine's floor for the user's slippage (a tiny output needs more than 1 bps for that unit).\n const apiBps = kyberApiSlippage(r.amountOut, bps);\n if (apiBps === null) return refuse(\"the output is too small to carry a minimum\", \"amount_too_small\");\n const minOut = kyberMinimum(r.amountOut, apiBps);\n if (minOut < floor) return refuse(`floor breach (min=${minOut} < floor=${floor})`, \"price_check_failed\");\n\n const base = {\n provider: \"kyberswap\",\n intentId: `kyberswap:${chainId}`,\n depositAddress: \"\",\n depositMemo: null,\n sourceAmount: amountIn.toString(),\n // KyberSwap's amountOut is the route's ceiling, not an average: the executed output came 1.5–7.4 bps under it.\n destAmount: r.amountOut.toString(),\n minDestAmount: minOut.toString(),\n feeUsd: 0,\n etaSeconds: 15,\n reliability: 0.95,\n validUntilMs: Date.now() + ttl,\n } satisfies Partial<Quote>;\n const providerData: Record<string, string> = {\n amountOut: r.amountOut.toString(),\n minOut: minOut.toString(),\n apiSlippageBps: String(apiBps),\n ...(typeof r.summary.routeID === \"string\" ? {routeId: r.summary.routeID.slice(0, 80)} : {}),\n ...(r.sources.length ? {sources: r.sources.join(\",\")} : {}),\n };\n // The router's quoteValues reads priceImpactBps into the user's \"be careful\" warning (Unichain USDC → JUP: −78 %).\n const lossBps = kyberValueLossBps(r.summary.amountInUsd, r.summary.amountOutUsd);\n if (lossBps !== null) providerData.priceImpactBps = String(lossBps);\n if (dry) {\n // A token sale approves the router first; the auction's gas estimate reads the spender from here.\n return {...base, providerData: tokenIn === ZERO ? providerData : {...providerData, approvalAddress: KYBER_ROUTER_V2}};\n }\n\n const receiver = getAddress(params.destAddress);\n const signer = isAddr(params.sender) ? params.sender : isAddr(params.refundAddress) ? params.refundAddress : params.destAddress;\n const sender = getAddress(signer);\n const built = await api(`${baseUrl}/${chain.slug}/api/v1/route/build`, {\n method: \"POST\",\n body: JSON.stringify({\n routeSummary: r.summary,\n sender,\n recipient: receiver,\n slippageTolerance: apiBps,\n deadline: Math.floor(Date.now() / 1000) + BUILD_DEADLINE_S,\n source: clientId,\n }),\n }, signal);\n if (!built.ok) return refuse(`build: ${built.why}`, built.info);\n const b = built.data;\n if (uint(b.amountIn) !== amountIn) return refuse(\"the build spends another amount\", \"price_check_failed\");\n if (same(b.routerAddress, KYBER_ROUTER_V3)) return refuse(\"Kyber router V3 not supported yet\", \"policy_refused\");\n const value = uint(b.transactionValue ?? \"0\");\n if (value === null || typeof b.data !== \"string\") return refuse(\"malformed build response\", \"upstream_unavailable\");\n const tx = {to: typeof b.routerAddress === \"string\" ? b.routerAddress : \"\", value, data: b.data};\n let decoded;\n try {\n decoded = checkKyberTransaction(tx, {chainId, tokenIn, tokenOut, amountIn, receiver, minAmountOut: minOut > floor ? minOut : floor});\n } catch (e) {\n return refuse(e instanceof Error ? e.message.replace(/^kyberswap: /, \"\") : String(e), refusalOf(e));\n }\n // Native input needs no allowance: the exact call runs against the latest block now, so a route that would revert\n // never reaches the user. Token input is checked the same way before any approval (tokenSwapCheck).\n let simulated = \"swap\";\n if (tokenIn !== ZERO) {\n try {\n const check = await tokenSwapCheck(chainId, sender, tokenIn, amountIn, tx.data as Hex);\n if (check.refusal) return refuse(check.refusal.why, check.refusal.reason);\n simulated = check.simulated;\n } catch (e) {\n return refuse(e instanceof Error ? e.message.replace(/^kyberswap: /, \"\") : String(e), refusalOf(e) ?? \"upstream_unavailable\");\n }\n }\n if (tokenIn === ZERO) {\n try {\n await rpc(chainId, \"eth_call\", [{from: sender, to: KYBER_ROUTER_V2, data: tx.data, value: `0x${value.toString(16)}`}, \"latest\", {[sender]: {balance: `0x${(value + 10n ** 18n).toString(16)}`}}]);\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) {\n const why = revertString(e);\n return refuse(`the route does not execute on-chain right now${why ? ` (${short(why)})` : \"\"}`, why && /return amount is not enough/i.test(why) ? \"price_check_failed\" : \"simulation_failed\");\n }\n return refuse(e instanceof Error ? e.message.replace(/^kyberswap: /, \"\") : String(e), refusalOf(e) ?? \"upstream_unavailable\");\n }\n }\n return {\n ...base,\n minDestAmount: decoded.minReturnAmount.toString(),\n txRequest: {\n to: KYBER_ROUTER_V2,\n data: tx.data,\n value: value.toString(),\n chainId,\n ...(tokenIn === ZERO ? {} : {approvalAddress: KYBER_ROUTER_V2}),\n },\n providerData: {...providerData, sender, minOut: decoded.minReturnAmount.toString(), simulated},\n };\n },\n\n /**\n * Simulate the exact quoted transaction from the account at the latest block (approval in place) and refuse when\n * it would revert or when no RPC answers — the API is not trusted, so an unsimulated swap is not sent.\n * Only the quote's own transaction is simulated, never a caller's.\n */\n async preflightDeposit(quote: Quote, tx: UnsignedTx): Promise<void> {\n const chainId = Number(quote.intentId.split(\":\")[1]);\n const sender = quote.providerData?.sender;\n const quoted = quote.txRequest;\n if (!kyberChain(chainId) || !isAddr(sender)) throw refusal(\"policy_refused\", \"kyberswap: the quote is not an execution quote. Nothing was sent; refresh the quote.\");\n if (!quoted?.to || !quoted.data || !sameText(tx.to, quoted.to) || !sameText(tx.data ?? \"\", quoted.data) || !sameAmount(tx.value || \"0\", quoted.value ?? \"0\")) {\n throw refusal(\"policy_refused\", \"kyberswap: the transaction is not the quoted swap. Nothing was sent; refresh the quote.\");\n }\n try {\n await rpc(chainId, \"eth_call\", [{from: sender, to: quoted.to, data: quoted.data, value: `0x${BigInt(quoted.value ?? \"0\").toString(16)}`}, \"latest\"]);\n } catch (e) {\n if ((e as {rpc?: boolean}).rpc) throw await revertReason(chainId, sender, quoted, e);\n throw withReason(new Error(\"kyberswap: the swap cannot be simulated (no RPC answered). Nothing was sent; try again.\"), refusalOf(e) ?? \"upstream_unavailable\");\n }\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest;\n if (!tx?.to || !tx.data) throw refusal(\"policy_refused\", \"swap2: KyberSwap quote has no transaction request (a dry quote cannot be executed)\");\n return {chain: \"\", to: tx.to, value: tx.value ?? \"0\", data: tx.data, ...(tx.chainId !== undefined ? {chainId: tx.chainId} : {}), ...(tx.approvalAddress ? {approvalAddress: tx.approvalAddress} : {})};\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (!ref.sourceTxHash) return {state: \"pending\"};\n const chainId = Number(ref.intentId.split(\":\")[1]);\n if (!kyberChain(chainId) || !config.rpcUrls?.[chainId]?.length) return {state: \"pending\"};\n try {\n const receipt = (await rpc(chainId, \"eth_getTransactionReceipt\", [ref.sourceTxHash])) as {status?: string} | null;\n if (!receipt) return {state: \"pending\"};\n return receipt.status === \"0x1\" ? {state: \"completed\", destTxHash: ref.sourceTxHash} : {state: \"failed\"};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAQ,mBAAmB,oBAAoB,oBAAoB,YAAY,gBAAyB;AACxG,SAAQ,QAAQ,OAAO,eAAe,qBAAoB;AAC1D,SAAQ,aAAa,SAAS,WAAW,kBAAiE;AAE1G,SAAQ,sBAAqB;AAC7B,SAAQ,sBAAqB;AAkB7B,IAAM,OAAO;AACb,IAAM,kBAAkB;AACxB,IAAM,mBAAmB;AACzB,IAAM,uBAAuB;AAE7B,IAAM,iBAAiB;AAEvB,IAAM,eAAe;AAErB,I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