@anywalletkit/protocol-swap2-jupiter 0.3.7 → 0.3.8

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.
@@ -26,6 +26,7 @@ import {
26
26
 
27
27
  // src/provider.ts
28
28
  import { address, getAddressEncoder, getProgramDerivedAddress } from "@solana/kit";
29
+ import { httpRefusal, refusal, refusalNotes, refusalOf, withReason } from "@anywalletkit/protocol-swap2-core/errors";
29
30
  import { timeoutSignal } from "@anywalletkit/protocol-swap2-core/util";
30
31
  var DEFAULT_SLIPPAGE_BPS = 50;
31
32
  var MAX_SLIPPAGE_BPS = 1e3;
@@ -35,12 +36,37 @@ var DEFAULT_MAX_CU_PRICE = 2000000n;
35
36
  var BASE_FEE_LAMPORTS = 5000n;
36
37
  var DRY_TAKER = "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM";
37
38
  var BASE58 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
39
+ var RETRY_AFTER_MAX_MS = 864e5;
38
40
  var INTENT_PREFIX = "jup:";
41
+ var notes = refusalNotes();
42
+ function buildRefusal(status, body, retryAfter, rateReset) {
43
+ const byStatus = httpRefusal(status, retryAfter);
44
+ if (byStatus?.reason === "rate_limited") {
45
+ if (byStatus.retryAfterMs !== void 0 || rateReset === null) return byStatus;
46
+ const wait = Number(rateReset) * 1e3 - Date.now();
47
+ return Number.isFinite(wait) && wait > 0 ? { ...byStatus, retryAfterMs: Math.min(Math.ceil(wait), RETRY_AFTER_MAX_MS) } : byStatus;
48
+ }
49
+ const said = answerReason(body);
50
+ return said && said !== byStatus?.reason ? { reason: said } : byStatus;
51
+ }
52
+ function answerReason(body) {
53
+ const b = body;
54
+ const text = `${typeof b?.errorCode === "string" ? b.errorCode : ""} ${typeof b?.error === "string" ? b.error : ""}`;
55
+ if (/COULD_NOT_FIND_ANY_ROUTE|NO_ROUTES_FOUND|could not find any route|no routes? found/i.test(text)) return "no_route";
56
+ if (/ROUTE_PLAN_DOES_NOT_CONSUME_ALL_THE_AMOUNT|liquidity/i.test(text)) return "insufficient_liquidity";
57
+ if (/TOKEN_NOT_TRADABLE|not tradable|MARKET_NOT_FOUND|CIRCULAR_ARBITRAGE|not supported|unsupported/i.test(text)) return "unsupported_pair";
58
+ if (/too small|too low|below the minimum/i.test(text)) return "amount_too_small";
59
+ if (/too large|too big|above the maximum/i.test(text)) return "amount_too_large";
60
+ if (/rate.?limit|too many requests/i.test(text)) return "rate_limited";
61
+ if (/api.?key|unauthori[sz]ed/i.test(text)) return "key_rejected";
62
+ return void 0;
63
+ }
39
64
  function jupiterProvider(config = {}) {
40
65
  config = Object.freeze({ ...config });
41
66
  const base = (config.apiUrl ?? JUPITER_API_DEFAULT).replace(/\/$/, "");
42
67
  const maxPrice = config.maxComputeUnitPrice ?? DEFAULT_MAX_CU_PRICE;
43
68
  const rpcUrls = config.rpcUrls ?? [];
69
+ const baseIsUrl = /^(?:https?:\/\/[^/\s]+|\/)/i.test(base);
44
70
  const get = async (path, signal) => {
45
71
  for (let attempt = 0; ; attempt++) {
46
72
  const res = await fetch(`${base}${path}`, { headers: { accept: "application/json", ...config.apiKey ? { "x-api-key": config.apiKey } : {} }, signal: signal ?? timeoutSignal(12e3) });
@@ -51,7 +77,7 @@ function jupiterProvider(config = {}) {
51
77
  await new Promise((r) => setTimeout(r, wait));
52
78
  continue;
53
79
  }
54
- return { ok: res.ok, status: res.status, body };
80
+ return { ok: res.ok, status: res.status, body, retryAfter: res.headers?.get?.("retry-after") ?? null, rateReset: res.headers?.get?.("x-ratelimit-reset") ?? null };
55
81
  }
56
82
  };
57
83
  const rpc = async (method, params) => {
@@ -72,60 +98,63 @@ function jupiterProvider(config = {}) {
72
98
  const data = fromBase64(ix.data ?? "");
73
99
  const acc = (i) => ix.accounts[i]?.pubkey;
74
100
  if (ix.programId === ATA_PROGRAM) {
75
- if (data.length !== 1 || data[0] !== 1) return "an associated-token instruction other than CreateIdempotent";
76
- if (acc(0) !== want.taker || acc(2) !== want.taker) return "an associated token account for someone else";
101
+ if (data.length !== 1 || data[0] !== 1) return notes.note("an associated-token instruction other than CreateIdempotent", "policy_refused");
102
+ if (acc(0) !== want.taker || acc(2) !== want.taker) return notes.note("an associated token account for someone else", "recipient_mismatch");
77
103
  return null;
78
104
  }
79
105
  if (ix.programId === SYSTEM_PROGRAM) {
80
- if (data.length !== 12 || data[0] !== 2 || data[1] !== 0 || data[2] !== 0 || data[3] !== 0) return "a System instruction other than Transfer";
81
- if (want.inputMint !== WSOL_MINT) return "a SOL transfer on a token-source swap";
106
+ if (data.length !== 12 || data[0] !== 2 || data[1] !== 0 || data[2] !== 0 || data[3] !== 0) return notes.note("a System instruction other than Transfer", "policy_refused");
107
+ if (want.inputMint !== WSOL_MINT) return notes.note("a SOL transfer on a token-source swap", "policy_refused");
82
108
  const lamports = new DataView(data.buffer, data.byteOffset + 4, 8).getBigUint64(0, true);
83
- if (acc(0) !== want.taker || acc(1) !== want.wsolAta) return `a SOL transfer to ${acc(1)}, not the taker's wSOL account`;
84
- if (lamports !== want.amountIn) return `a SOL transfer of ${lamports}, not the ${want.amountIn} input`;
109
+ if (acc(0) !== want.taker || acc(1) !== want.wsolAta) return notes.note(`a SOL transfer to ${acc(1)}, not the taker's wSOL account`, "recipient_mismatch");
110
+ if (lamports !== want.amountIn) return notes.note(`a SOL transfer of ${lamports}, not the ${want.amountIn} input`, "policy_refused");
85
111
  return null;
86
112
  }
87
113
  if (ix.programId === TOKEN_PROGRAM) {
88
- if (data.length === 1 && data[0] === 17) return acc(0) === want.wsolAta ? null : "SyncNative on another account";
114
+ if (data.length === 1 && data[0] === 17) return acc(0) === want.wsolAta ? null : notes.note("SyncNative on another account", "policy_refused");
89
115
  if (data.length === 1 && data[0] === 9) {
90
- return acc(0) === want.wsolAta && acc(1) === want.taker && acc(2) === want.taker ? null : "a CloseAccount that is not the taker's wSOL account back to the taker";
116
+ return acc(0) === want.wsolAta && acc(1) === want.taker && acc(2) === want.taker ? null : notes.note("a CloseAccount that is not the taker's wSOL account back to the taker", "recipient_mismatch");
91
117
  }
92
118
  if (data.length === 33 && data[0] === 18) {
93
- return bytesEqual(data.subarray(1), getAddressEncoder().encode(address(want.taker))) ? null : "a token account initialized for someone else";
119
+ return bytesEqual(data.subarray(1), getAddressEncoder().encode(address(want.taker))) ? null : notes.note("a token account initialized for someone else", "recipient_mismatch");
94
120
  }
95
- return `a Token instruction (tag ${data[0] ?? "none"}) the swap does not need`;
121
+ return notes.note(`a Token instruction (tag ${data[0] ?? "none"}) the swap does not need`, "policy_refused");
96
122
  }
97
- if (ix.programId === JUPITER_PROGRAM) return "a second Jupiter instruction";
98
- return `instruction for program ${ix.programId}`;
123
+ if (ix.programId === JUPITER_PROGRAM) return notes.note("a second Jupiter instruction", "policy_refused");
124
+ return notes.note(`instruction for program ${ix.programId}`, "policy_refused");
99
125
  };
100
126
  const vet = (b, want) => {
101
- if (b.swapMode && b.swapMode !== "ExactIn") throw new Error(`swap mode ${b.swapMode}`);
102
- if (b.inputMint !== want.inputMint || b.outputMint !== want.outputMint) throw new Error("the answer names other mints");
103
- if (b.inAmount !== want.amountIn.toString()) throw new Error(`the answer spends ${b.inAmount}, not ${want.amountIn}`);
104
- if (String(b.transactionVersion ?? "0") !== "0") throw new Error(`transaction version ${b.transactionVersion}`);
105
- if (b.tipInstruction) throw new Error("unexpected tip instruction");
106
- if (!b.swapInstruction) throw new Error("no swap instruction");
107
- if (b.swapInstruction.programId !== JUPITER_PROGRAM) throw new Error(`swap instruction targets ${b.swapInstruction.programId}`);
127
+ if (b.swapMode && b.swapMode !== "ExactIn") throw refusal("policy_refused", `swap mode ${b.swapMode}`);
128
+ if (b.inputMint !== want.inputMint || b.outputMint !== want.outputMint) throw refusal("policy_refused", "the answer names other mints");
129
+ if (b.inAmount !== want.amountIn.toString()) throw refusal("policy_refused", `the answer spends ${b.inAmount}, not ${want.amountIn}`);
130
+ if (String(b.transactionVersion ?? "0") !== "0") throw refusal("policy_refused", `transaction version ${b.transactionVersion}`);
131
+ if (b.tipInstruction) throw refusal("policy_refused", "unexpected tip instruction");
132
+ if (!b.swapInstruction) throw refusal("upstream_unavailable", "no swap instruction");
133
+ if (b.swapInstruction.programId !== JUPITER_PROGRAM) throw refusal("vault_mismatch", `swap instruction targets ${b.swapInstruction.programId}`);
108
134
  const args = decodeSwapArgs(fromBase64(b.swapInstruction.data));
109
- if (args.inAmount !== want.amountIn) throw new Error(`swap instruction spends ${args.inAmount}, not ${want.amountIn}`);
110
- if (String(args.quotedOutAmount) !== b.outAmount) throw new Error("swap instruction's quoted output differs from the answer");
111
- if (args.slippageBps !== want.slippageBps) throw new Error(`swap instruction allows ${args.slippageBps} bps slippage, not ${want.slippageBps}`);
112
- if (args.platformFeeBps !== 0 || args.positiveSlippageBps !== 0) throw new Error("swap instruction takes a platform fee");
135
+ if (args.inAmount !== want.amountIn) throw refusal("policy_refused", `swap instruction spends ${args.inAmount}, not ${want.amountIn}`);
136
+ if (String(args.quotedOutAmount) !== b.outAmount) throw refusal("price_check_failed", "swap instruction's quoted output differs from the answer");
137
+ if (args.slippageBps !== want.slippageBps) throw refusal("price_check_failed", `swap instruction allows ${args.slippageBps} bps slippage, not ${want.slippageBps}`);
138
+ if (args.platformFeeBps !== 0 || args.positiveSlippageBps !== 0) throw refusal("policy_refused", "swap instruction takes a platform fee");
113
139
  let price = 0n;
114
140
  for (const ix of b.computeBudgetInstructions ?? []) {
115
- if (ix.programId !== COMPUTE_BUDGET_PROGRAM) throw new Error(`compute-budget slot holds ${ix.programId}`);
141
+ if (ix.programId !== COMPUTE_BUDGET_PROGRAM) throw refusal("policy_refused", `compute-budget slot holds ${ix.programId}`);
116
142
  const d = decodeComputeBudget(fromBase64(ix.data));
117
143
  if (d.price !== void 0) price = d.price;
118
144
  }
119
145
  const instructions = [...b.setupInstructions ?? [], b.swapInstruction, ...b.cleanupInstruction ? [b.cleanupInstruction] : [], ...b.otherInstructions ?? []];
120
146
  let funded = false;
121
147
  for (const ix of instructions) {
122
- if (!JUPITER_TX_PROGRAMS.has(ix.programId) || ix.programId === COMPUTE_BUDGET_PROGRAM) throw new Error(`instruction for program ${ix.programId}`);
123
- for (const a of ix.accounts) if (a.isSigner && a.pubkey !== want.taker) throw new Error(`instruction needs signer ${a.pubkey}`);
148
+ if (!JUPITER_TX_PROGRAMS.has(ix.programId) || ix.programId === COMPUTE_BUDGET_PROGRAM) throw refusal("policy_refused", `instruction for program ${ix.programId}`);
149
+ for (const a of ix.accounts) if (a.isSigner && a.pubkey !== want.taker) throw refusal("policy_refused", `instruction needs signer ${a.pubkey}`);
124
150
  if (ix === b.swapInstruction) continue;
125
151
  const why = shapeRefusal(ix, want);
126
- if (why) throw new Error(why);
152
+ if (why) {
153
+ const info = notes.reasonOf(why);
154
+ throw info ? withReason(new Error(why), info) : new Error(why);
155
+ }
127
156
  if (ix.programId === SYSTEM_PROGRAM) {
128
- if (funded) throw new Error("a second SOL transfer");
157
+ if (funded) throw refusal("policy_refused", "a second SOL transfer");
129
158
  funded = true;
130
159
  }
131
160
  }
@@ -144,9 +173,9 @@ function jupiterProvider(config = {}) {
144
173
  const err = JSON.stringify(r.value.err);
145
174
  const jupiterCode = /JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 failed/.test(log) ? /"Custom":(\d+)/.exec(err)?.[1] : void 0;
146
175
  if (jupiterCode === "6024" || jupiterCode === "6025" || /"Custom":1\}/.test(err) && /Program 11111111111111111111111111111111 failed/.test(log)) {
147
- throw new Error(`not enough of the input token in the wallet${jupiterCode === "6025" ? " (no token account for it)" : ""} \u2014 simulation fails: ${err}`);
176
+ throw refusal("simulation_failed", `not enough of the input token in the wallet${jupiterCode === "6025" ? " (no token account for it)" : ""} \u2014 simulation fails: ${err}`);
148
177
  }
149
- throw new Error(`simulation fails: ${err}${log ? ` (${log.slice(0, 160)})` : ""}`);
178
+ throw refusal("simulation_failed", `simulation fails: ${err}${log ? ` (${log.slice(0, 160)})` : ""}`);
150
179
  }
151
180
  const used = r?.value?.unitsConsumed;
152
181
  return used ? Math.min(MAX_COMPUTE_UNITS, Math.ceil(used * 1.2)) : null;
@@ -165,23 +194,25 @@ function jupiterProvider(config = {}) {
165
194
  },
166
195
  async getQuote(params, signal) {
167
196
  const dry = params.dry !== false;
168
- const refuse = (reason) => {
169
- params.onRefusal?.(`jupiter: ${reason}`);
197
+ const refuse = (reason, why) => {
198
+ const info = typeof why === "string" ? { reason: why } : why;
199
+ if (info) params.onRefusal?.(`jupiter: ${reason}`, info);
200
+ else params.onRefusal?.(`jupiter: ${reason}`);
170
201
  return null;
171
202
  };
172
- if (!jupiter.supports(params.sourceChain, params.destChain)) return refuse(`same-chain Solana only (${params.sourceChain} \u2192 ${params.destChain})`);
173
- if (params.flex) return refuse("amount-flexible deposits are not supported");
203
+ if (!jupiter.supports(params.sourceChain, params.destChain)) return refuse(`same-chain Solana only (${params.sourceChain} \u2192 ${params.destChain})`, "unsupported_pair");
204
+ if (params.flex) return refuse("amount-flexible deposits are not supported", "unsupported_pair");
174
205
  const inputMint = jupiterMint(params.sourceToken), outputMint = jupiterMint(params.destToken);
175
- if (!inputMint || !outputMint) return refuse(`unknown token (${params.sourceToken} \u2192 ${params.destToken})`);
176
- if (inputMint === outputMint) return refuse("same token on both sides");
206
+ if (!inputMint || !outputMint) return refuse(`unknown token (${params.sourceToken} \u2192 ${params.destToken})`, "unsupported_pair");
207
+ if (inputMint === outputMint) return refuse("same token on both sides", "unsupported_pair");
177
208
  const amountIn = BigInt(params.amountIn);
178
- if (amountIn <= 0n) return refuse("amount must be positive");
209
+ if (amountIn <= 0n) return refuse("amount must be positive", "amount_too_small");
179
210
  const slippageBps = params.slippageBps ?? config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;
180
- if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > MAX_SLIPPAGE_BPS) return refuse(`slippage ${slippageBps} bps is out of range`);
211
+ if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > MAX_SLIPPAGE_BPS) return refuse(`slippage ${slippageBps} bps is out of range`, params.slippageBps !== void 0 && Number.isInteger(slippageBps) && slippageBps > MAX_SLIPPAGE_BPS ? "policy_refused" : void 0);
181
212
  const self = params.refundAddress || params.destAddress;
182
213
  if (!dry) {
183
- if (!self || !BASE58.test(self)) return refuse("live quote without the signer's address");
184
- if (params.destAddress && params.destAddress !== self) return refuse("the recipient must be the signing wallet (Jupiter pays the taker)");
214
+ if (!self || !BASE58.test(self)) return refuse("live quote without the signer's address", !self ? "policy_refused" : void 0);
215
+ if (params.destAddress && params.destAddress !== self) return refuse("the recipient must be the signing wallet (Jupiter pays the taker)", "unsupported_pair");
185
216
  }
186
217
  const taker = self && BASE58.test(self) ? self : DRY_TAKER;
187
218
  const qs = new URLSearchParams({ inputMint, outputMint, amount: params.amountIn, taker, slippageBps: String(slippageBps) });
@@ -189,22 +220,22 @@ function jupiterProvider(config = {}) {
189
220
  let b;
190
221
  try {
191
222
  const r = await get(`/build?${qs.toString()}`, signal);
192
- if (!r.ok) return refuse(`build ${r.status}: ${String(r.body?.error ?? "").slice(0, 160)}`);
223
+ if (!r.ok) return refuse(`build ${r.status}: ${String(r.body?.error ?? "").slice(0, 160)}`, buildRefusal(r.status, r.body, r.retryAfter, r.rateReset));
193
224
  b = r.body ?? {};
194
225
  } catch (e) {
195
- return refuse(`build failed: ${e.message.slice(0, 160)}`);
226
+ return refuse(`build failed: ${e.message.slice(0, 160)}`, signal?.aborted || !baseIsUrl ? void 0 : "upstream_unavailable");
196
227
  }
197
- if (!b.outAmount || !/^\d+$/.test(b.outAmount)) return refuse("answer without an output amount");
228
+ if (!b.outAmount || !/^\d+$/.test(b.outAmount)) return refuse("answer without an output amount", answerReason(b) ?? (signal?.aborted ? void 0 : "upstream_unavailable"));
198
229
  let vetted;
199
230
  const [wsolAta] = await getProgramDerivedAddress({ programAddress: address(ATA_PROGRAM), seeds: [getAddressEncoder().encode(address(taker)), getAddressEncoder().encode(address(TOKEN_PROGRAM)), getAddressEncoder().encode(address(WSOL_MINT))] });
200
231
  try {
201
232
  vetted = vet(b, { taker, inputMint, outputMint, amountIn, slippageBps, wsolAta });
202
233
  } catch (e) {
203
- return refuse(e.message);
234
+ return refuse(e.message, refusalOf(e) ?? "upstream_unavailable");
204
235
  }
205
236
  const minOut = minOutOf(vetted.quotedOut, slippageBps);
206
237
  if (params.minAmountOut !== void 0 && minOut < BigInt(params.minAmountOut)) {
207
- return refuse(`guaranteed ${minOut} is below the floor ${params.minAmountOut} at ${slippageBps} bps`);
238
+ return refuse(`guaranteed ${minOut} is below the floor ${params.minAmountOut} at ${slippageBps} bps`, "price_check_failed");
208
239
  }
209
240
  const route = (b.routePlan ?? []).map((s) => s.swapInfo?.label).filter(Boolean).join(" + ");
210
241
  const impact = Number(b.priceImpactPct ?? 0);
@@ -225,7 +256,7 @@ function jupiterProvider(config = {}) {
225
256
  }
226
257
  const blockhash = b.blockhashWithMetadata?.blockhash;
227
258
  const lastValid = b.blockhashWithMetadata?.lastValidBlockHeight;
228
- if (!blockhash || blockhash.length !== 32 || !lastValid) return refuse("answer without a blockhash");
259
+ if (!blockhash || blockhash.length !== 32 || !lastValid) return refuse("answer without a blockhash", "upstream_unavailable");
229
260
  const assemble = (limit2) => assembleTransaction({
230
261
  taker,
231
262
  instructions: vetted.instructions,
@@ -244,7 +275,7 @@ function jupiterProvider(config = {}) {
244
275
  wire = assemble(units);
245
276
  }
246
277
  } catch (e) {
247
- return refuse(e.message.slice(0, 240));
278
+ return refuse(e.message.slice(0, 240), refusalOf(e) ?? "upstream_unavailable");
248
279
  }
249
280
  const priority = (vetted.price * BigInt(limit) + 999999n) / 1000000n;
250
281
  return {
@@ -258,7 +289,7 @@ function jupiterProvider(config = {}) {
258
289
  },
259
290
  async buildDeposit(quote) {
260
291
  const tx = quote.txRequest?.serializedTx;
261
- if (!tx || quote.intentId.startsWith("dry:")) throw new Error("jupiter: not a live quote");
292
+ if (!tx || quote.intentId.startsWith("dry:")) throw refusal("policy_refused", "jupiter: not a live quote");
262
293
  return { chain: SOLANA_CAIP2, to: "", value: quote.txRequest.value ?? "0", serializedTx: tx };
263
294
  },
264
295
  async trackIntent(ref) {
@@ -284,4 +315,4 @@ function bytesEqual(a, b) {
284
315
  export {
285
316
  jupiterProvider
286
317
  };
287
- //# sourceMappingURL=chunk-EY2HJJXY.js.map
318
+ //# sourceMappingURL=chunk-4V65GQY2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/provider.ts"],"sourcesContent":["/**\n * Jupiter provider — Swap API V2 Router path, same-chain Solana swaps:\n * quote + instructions GET /swap/v2/build?inputMint&outputMint&amount&taker&slippageBps\n * status getSignatureStatuses on the caller's own Solana RPC (optional)\n * Routing is Metis (Jupiter's on-chain router); the Router path charges no Jupiter swap fee. Keyless access works at\n * 0.5 RPS; pass `apiKey` (sent as `x-api-key`) for a plan's rate limit.\n *\n * Nothing from the API is trusted as-is. Before a live quote is handed out, every instruction is checked: only the\n * Jupiter program and the token / system / ATA / compute-budget plumbing, the taker is the only signer, no tip, and\n * the swap instruction's own arguments (decoded) carry exactly our input amount, the quoted output, our slippage and\n * a zero platform fee — those are what the program enforces on-chain. The compute budget is rebuilt here: a unit price\n * capped by `maxComputeUnitPrice`, and a unit limit from a simulation (1.2× the units used) when `rpcUrls` is given.\n * The account then executes the assembled transaction through its serialized-transaction guard (simulation +\n * balance proof against the quote) and broadcasts it through its own RPC.\n */\nimport {describeJupiterActivity} from \"./activity.js\";\nimport {ATA_PROGRAM, JUPITER_API_DEFAULT, JUPITER_PROGRAM, JUPITER_TX_PROGRAMS, COMPUTE_BUDGET_PROGRAM, SOLANA_CAIP2, SYSTEM_PROGRAM, TOKEN_PROGRAM, WSOL_MINT, jupiter as cfg, jupiterMint} from \"./config.js\";\nimport {address, getAddressEncoder, getProgramDerivedAddress} from \"@solana/kit\";\nimport {decodeComputeBudget, decodeSwapArgs, fromBase64, minOutOf} from \"./codec.js\";\nimport {assembleTransaction, type JupiterInstruction} from \"./transaction.js\";\nimport {httpRefusal, refusal, refusalNotes, refusalOf, withReason, type Swap2RefusalInfo, type Swap2RefusalReason} from \"@anywalletkit/protocol-swap2-core/errors\";\nimport {timeoutSignal} from \"@anywalletkit/protocol-swap2-core/util\";\nimport type {Asset, CrossChainProvider, IntentRef, IntentStatus, Quote, QuoteParams, UnsignedTx} from \"@anywalletkit/protocol-swap2-core/types\";\n\nconst DEFAULT_SLIPPAGE_BPS = 50;\nconst MAX_SLIPPAGE_BPS = 1_000;\n/** A /build blockhash lives ~60–90 s; the quote must be signed well inside it. */\nconst QUOTE_TTL_MS = 30_000;\nconst MAX_COMPUTE_UNITS = 1_400_000;\n/** 2 000 000 µlamports/CU: at 1.4 M CU the priority fee is ≤ 0.0028 SOL. */\nconst DEFAULT_MAX_CU_PRICE = 2_000_000n;\nconst BASE_FEE_LAMPORTS = 5_000n;\n/** Taker for a dry quote with no address yet: /build needs one, the price does not depend on it. */\nconst DRY_TAKER = \"9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM\";\nconst BASE58 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\n/** Longest `retryAfterMs` passed on: a day, core's own ceiling. */\nconst RETRY_AFTER_MAX_MS = 86_400_000;\n\nexport interface JupiterProviderConfig {\n enabled?: boolean;\n /** Swap API base (default https://api.jup.ag/swap/v2). */\n apiUrl?: string;\n /** Jupiter Developer Platform key, sent as `x-api-key`. Keyless works at 0.5 RPS. */\n apiKey?: string;\n /** Solana JSON-RPC endpoints: compute-unit simulation and status. Without them the limit is 1.4 M CU and status stays pending. */\n rpcUrls?: readonly string[];\n /** Ceiling on the compute-unit price Jupiter suggests, micro-lamports (default 2 000 000). */\n maxComputeUnitPrice?: bigint;\n /** Passed to /build: \"medium\" | \"high\" | \"veryHigh\" or a percentile in bps (default: Jupiter's 50th percentile). */\n computeUnitPricePercentile?: string;\n /** Slippage when the caller names none, bps (default 50). */\n defaultSlippageBps?: number;\n}\n\ninterface BuildResponse {\n inputMint?: string;\n outputMint?: string;\n inAmount?: string;\n outAmount?: string;\n otherAmountThreshold?: string;\n swapMode?: string;\n slippageBps?: number;\n priceImpactPct?: string;\n routePlan?: {bps?: number; swapInfo?: {label?: string}}[];\n computeBudgetInstructions?: JupiterInstruction[];\n setupInstructions?: JupiterInstruction[];\n swapInstruction?: JupiterInstruction;\n cleanupInstruction?: JupiterInstruction | null;\n otherInstructions?: JupiterInstruction[];\n tipInstruction?: JupiterInstruction | null;\n addressesByLookupTableAddress?: Record<string, string[]> | null;\n transactionVersion?: number | string;\n blockhashWithMetadata?: {blockhash?: number[]; lastValidBlockHeight?: number};\n error?: string;\n}\n\nconst INTENT_PREFIX = \"jup:\";\n\n/** The reason behind each text `shapeRefusal` returns. */\nconst notes = refusalNotes();\n\n/**\n * What a failed /build answer means: Jupiter's own error first (no route, an untradable token, too little liquidity,\n * limits), else the status (429 with Retry-After or `x-ratelimit-reset`, 401 / 403, 408 / 425 / 5xx). Undefined when\n * neither says.\n */\nfunction buildRefusal(status: number, body: unknown, retryAfter: string | null, rateReset: string | null): Swap2RefusalInfo | undefined {\n const byStatus = httpRefusal(status, retryAfter);\n if (byStatus?.reason === \"rate_limited\") {\n if (byStatus.retryAfterMs !== undefined || rateReset === null) return byStatus;\n const wait = Number(rateReset) * 1000 - Date.now();\n // Capped at a day like core's Retry-After: a reset far ahead (or given in milliseconds) is no wait of centuries.\n return Number.isFinite(wait) && wait > 0 ? {...byStatus, retryAfterMs: Math.min(Math.ceil(wait), RETRY_AFTER_MAX_MS)} : byStatus;\n }\n const said = answerReason(body);\n return said && said !== byStatus?.reason ? {reason: said} : byStatus;\n}\nfunction answerReason(body: unknown): Swap2RefusalReason | undefined {\n const b = body as {error?: unknown; errorCode?: unknown} | null;\n const text = `${typeof b?.errorCode === \"string\" ? b.errorCode : \"\"} ${typeof b?.error === \"string\" ? b.error : \"\"}`;\n if (/COULD_NOT_FIND_ANY_ROUTE|NO_ROUTES_FOUND|could not find any route|no routes? found/i.test(text)) return \"no_route\";\n if (/ROUTE_PLAN_DOES_NOT_CONSUME_ALL_THE_AMOUNT|liquidity/i.test(text)) return \"insufficient_liquidity\";\n if (/TOKEN_NOT_TRADABLE|not tradable|MARKET_NOT_FOUND|CIRCULAR_ARBITRAGE|not supported|unsupported/i.test(text)) return \"unsupported_pair\";\n if (/too small|too low|below the minimum/i.test(text)) return \"amount_too_small\";\n if (/too large|too big|above the maximum/i.test(text)) return \"amount_too_large\";\n if (/rate.?limit|too many requests/i.test(text)) return \"rate_limited\";\n if (/api.?key|unauthori[sz]ed/i.test(text)) return \"key_rejected\";\n return undefined;\n}\n\nexport function jupiterProvider(config: JupiterProviderConfig = {}): CrossChainProvider {\n config = Object.freeze({...config});\n const base = (config.apiUrl ?? JUPITER_API_DEFAULT).replace(/\\/$/, \"\");\n const maxPrice = config.maxComputeUnitPrice ?? DEFAULT_MAX_CU_PRICE;\n const rpcUrls = config.rpcUrls ?? [];\n // An apiUrl that is neither an http(s) URL nor a same-origin path is a configuration error: its fetch failures are no refusal.\n const baseIsUrl = /^(?:https?:\\/\\/[^/\\s]+|\\/)/i.test(base);\n\n /** One GET with a single back-off on 429 (keyless traffic is 0.5 RPS), waiting for `x-ratelimit-reset` when given. */\n const get = async (path: string, signal?: AbortSignal): Promise<{ok: boolean; status: number; body: unknown; retryAfter: string | null; rateReset: string | null}> => {\n for (let attempt = 0; ; attempt++) {\n const res = await fetch(`${base}${path}`, {headers: {accept: \"application/json\", ...(config.apiKey ? {\"x-api-key\": config.apiKey} : {})}, signal: signal ?? timeoutSignal(12_000)});\n const body = await res.json().catch(() => null);\n if (res.status === 429 && attempt === 0 && !signal?.aborted) {\n const reset = Number(res.headers.get(\"x-ratelimit-reset\"));\n const wait = Number.isFinite(reset) && reset > 0 ? Math.min(3_000, Math.max(250, reset * 1000 - Date.now())) : 1_200;\n await new Promise((r) => setTimeout(r, wait));\n continue;\n }\n return {ok: res.ok, status: res.status, body, retryAfter: res.headers?.get?.(\"retry-after\") ?? null, rateReset: res.headers?.get?.(\"x-ratelimit-reset\") ?? null};\n }\n };\n\n const rpc = async (method: string, params: unknown[]): Promise<unknown> => {\n let last: unknown = new Error(\"no Solana RPC configured\");\n for (const url of rpcUrls) {\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(10_000)});\n const body = (await res.json()) as {result?: unknown; error?: {message?: string}};\n if (body.error) throw new Error(body.error.message ?? \"rpc error\");\n return body.result;\n } catch (e) { last = e; }\n }\n throw last;\n };\n\n /**\n * The setup / cleanup / other instructions /build may carry, by exact shape (scan 2026-10-27 modules, F32/F33):\n * creating the taker's own ATAs, funding the taker's wSOL account with exactly the input (a SOL source), syncing and\n * closing it back to the taker. Anything else — a System transfer elsewhere, a token transfer, a second Jupiter call —\n * is refused; the wallet's balance proof alone let a few hundredths of a SOL and the slippage band leave per swap.\n */\n const shapeRefusal = (ix: JupiterInstruction, want: {taker: string; inputMint: string; amountIn: bigint; wsolAta: string}): string | null => {\n const data = fromBase64(ix.data ?? \"\");\n const acc = (i: number) => ix.accounts[i]?.pubkey;\n if (ix.programId === ATA_PROGRAM) {\n // CreateIdempotent: [payer, ata, owner, mint, system, token program] — the taker pays for its own account.\n if (data.length !== 1 || data[0] !== 1) return notes.note(\"an associated-token instruction other than CreateIdempotent\", \"policy_refused\");\n if (acc(0) !== want.taker || acc(2) !== want.taker) return notes.note(\"an associated token account for someone else\", \"recipient_mismatch\");\n return null;\n }\n if (ix.programId === SYSTEM_PROGRAM) {\n // Transfer: u32 LE 2 + u64 lamports, [from, to] — only the input, into the taker's own wSOL account.\n if (data.length !== 12 || data[0] !== 2 || data[1] !== 0 || data[2] !== 0 || data[3] !== 0) return notes.note(\"a System instruction other than Transfer\", \"policy_refused\");\n if (want.inputMint !== WSOL_MINT) return notes.note(\"a SOL transfer on a token-source swap\", \"policy_refused\");\n const lamports = new DataView(data.buffer, data.byteOffset + 4, 8).getBigUint64(0, true);\n if (acc(0) !== want.taker || acc(1) !== want.wsolAta) return notes.note(`a SOL transfer to ${acc(1)}, not the taker's wSOL account`, \"recipient_mismatch\");\n if (lamports !== want.amountIn) return notes.note(`a SOL transfer of ${lamports}, not the ${want.amountIn} input`, \"policy_refused\");\n return null;\n }\n if (ix.programId === TOKEN_PROGRAM) {\n if (data.length === 1 && data[0] === 17) return acc(0) === want.wsolAta ? null : notes.note(\"SyncNative on another account\", \"policy_refused\"); // SyncNative\n if (data.length === 1 && data[0] === 9) { // CloseAccount: [account, destination, owner]\n return acc(0) === want.wsolAta && acc(1) === want.taker && acc(2) === want.taker ? null : notes.note(\"a CloseAccount that is not the taker's wSOL account back to the taker\", \"recipient_mismatch\");\n }\n if (data.length === 33 && data[0] === 18) { // InitializeAccount3(owner): an account the taker owns\n return bytesEqual(data.subarray(1), getAddressEncoder().encode(address(want.taker))) ? null : notes.note(\"a token account initialized for someone else\", \"recipient_mismatch\");\n }\n return notes.note(`a Token instruction (tag ${data[0] ?? \"none\"}) the swap does not need`, \"policy_refused\");\n }\n if (ix.programId === JUPITER_PROGRAM) return notes.note(\"a second Jupiter instruction\", \"policy_refused\");\n return notes.note(`instruction for program ${ix.programId}`, \"policy_refused\");\n };\n\n /** Every instruction the API returned, checked; returns the ordered list to assemble and the suggested unit price. */\n const vet = (b: BuildResponse, want: {taker: string; inputMint: string; outputMint: string; amountIn: bigint; slippageBps: number; wsolAta: string}): {instructions: JupiterInstruction[]; price: bigint; quotedOut: bigint} => {\n if (b.swapMode && b.swapMode !== \"ExactIn\") throw refusal(\"policy_refused\", `swap mode ${b.swapMode}`);\n if (b.inputMint !== want.inputMint || b.outputMint !== want.outputMint) throw refusal(\"policy_refused\", \"the answer names other mints\");\n if (b.inAmount !== want.amountIn.toString()) throw refusal(\"policy_refused\", `the answer spends ${b.inAmount}, not ${want.amountIn}`);\n if (String(b.transactionVersion ?? \"0\") !== \"0\") throw refusal(\"policy_refused\", `transaction version ${b.transactionVersion}`);\n if (b.tipInstruction) throw refusal(\"policy_refused\", \"unexpected tip instruction\");\n if (!b.swapInstruction) throw refusal(\"upstream_unavailable\", \"no swap instruction\");\n if (b.swapInstruction.programId !== JUPITER_PROGRAM) throw refusal(\"vault_mismatch\", `swap instruction targets ${b.swapInstruction.programId}`);\n const args = decodeSwapArgs(fromBase64(b.swapInstruction.data));\n if (args.inAmount !== want.amountIn) throw refusal(\"policy_refused\", `swap instruction spends ${args.inAmount}, not ${want.amountIn}`);\n if (String(args.quotedOutAmount) !== b.outAmount) throw refusal(\"price_check_failed\", \"swap instruction's quoted output differs from the answer\");\n if (args.slippageBps !== want.slippageBps) throw refusal(\"price_check_failed\", `swap instruction allows ${args.slippageBps} bps slippage, not ${want.slippageBps}`);\n if (args.platformFeeBps !== 0 || args.positiveSlippageBps !== 0) throw refusal(\"policy_refused\", \"swap instruction takes a platform fee\");\n let price = 0n;\n for (const ix of b.computeBudgetInstructions ?? []) {\n if (ix.programId !== COMPUTE_BUDGET_PROGRAM) throw refusal(\"policy_refused\", `compute-budget slot holds ${ix.programId}`);\n const d = decodeComputeBudget(fromBase64(ix.data));\n if (d.price !== undefined) price = d.price;\n }\n const instructions = [...(b.setupInstructions ?? []), b.swapInstruction, ...(b.cleanupInstruction ? [b.cleanupInstruction] : []), ...(b.otherInstructions ?? [])];\n let funded = false;\n for (const ix of instructions) {\n if (!JUPITER_TX_PROGRAMS.has(ix.programId) || ix.programId === COMPUTE_BUDGET_PROGRAM) throw refusal(\"policy_refused\", `instruction for program ${ix.programId}`);\n for (const a of ix.accounts) if (a.isSigner && a.pubkey !== want.taker) throw refusal(\"policy_refused\", `instruction needs signer ${a.pubkey}`);\n if (ix === b.swapInstruction) continue;\n const why = shapeRefusal(ix, want);\n if (why) {\n const info = notes.reasonOf(why);\n throw info ? withReason(new Error(why), info) : new Error(why);\n }\n if (ix.programId === SYSTEM_PROGRAM) {\n if (funded) throw refusal(\"policy_refused\", \"a second SOL transfer\");\n funded = true;\n }\n }\n return {instructions, price: price > maxPrice ? maxPrice : price, quotedOut: args.quotedOutAmount};\n };\n\n /** 1.2× the units a simulation uses (capped); null when no RPC answers. A failing simulation refuses the quote. */\n const simulateUnits = async (wire: string): Promise<number | null> => {\n if (!rpcUrls.length) return null;\n let r: {value?: {err?: unknown; unitsConsumed?: number; logs?: string[]}};\n try {\n r = (await rpc(\"simulateTransaction\", [wire, {encoding: \"base64\", sigVerify: false, replaceRecentBlockhash: true, commitment: \"processed\"}])) as typeof r;\n } catch {\n return null;\n }\n if (r?.value?.err) {\n const log = (r.value.logs ?? []).filter((l) => /error|failed|insufficient/i.test(l)).slice(-1)[0] ?? \"\";\n const err = JSON.stringify(r.value.err);\n // The usual reason, said plainly: the wallet lacks the input. Confirmed 2026-10-24 by building the same\n // USDS / LINK / WBTC → USDC swaps from an empty wallet (6025) and from real holders (built fine).\n // Jupiter 6024 = insufficient funds, 6025 = no token account for the input; System Program 1 = not enough SOL.\n const jupiterCode = /JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 failed/.test(log) ? /\"Custom\":(\\d+)/.exec(err)?.[1] : undefined;\n if (jupiterCode === \"6024\" || jupiterCode === \"6025\" || (/\"Custom\":1\\}/.test(err) && /Program 11111111111111111111111111111111 failed/.test(log))) {\n throw refusal(\"simulation_failed\", `not enough of the input token in the wallet${jupiterCode === \"6025\" ? \" (no token account for it)\" : \"\"} — simulation fails: ${err}`);\n }\n throw refusal(\"simulation_failed\", `simulation fails: ${err}${log ? ` (${log.slice(0, 160)})` : \"\"}`);\n }\n const used = r?.value?.unitsConsumed;\n return used ? Math.min(MAX_COMPUTE_UNITS, Math.ceil(used * 1.2)) : null;\n };\n\n return {\n name: \"jupiter\",\n describeActivity: describeJupiterActivity,\n enabled: () => config.enabled ?? true,\n supportsSameChain: true,\n supportsChain: (chain: string) => cfg.supportsChain(chain),\n supportsChainPair: (from: string, to: string) => cfg.supports(from, to),\n supportsRoute(from: Asset, to: Asset): boolean {\n if (!cfg.supports(from.chain, to.chain)) return false;\n const a = jupiterMint(from.token), b = jupiterMint(to.token);\n return !!a && !!b && a !== b;\n },\n\n async getQuote(params: QuoteParams, signal?: AbortSignal): Promise<Quote | null> {\n const dry = params.dry !== false;\n const refuse = (reason: string, why?: Swap2RefusalReason | Swap2RefusalInfo): null => {\n const info = typeof why === \"string\" ? {reason: why} : why;\n if (info) params.onRefusal?.(`jupiter: ${reason}`, info);\n else params.onRefusal?.(`jupiter: ${reason}`);\n return null;\n };\n if (!cfg.supports(params.sourceChain, params.destChain)) return refuse(`same-chain Solana only (${params.sourceChain} → ${params.destChain})`, \"unsupported_pair\");\n if (params.flex) return refuse(\"amount-flexible deposits are not supported\", \"unsupported_pair\");\n const inputMint = jupiterMint(params.sourceToken), outputMint = jupiterMint(params.destToken);\n if (!inputMint || !outputMint) return refuse(`unknown token (${params.sourceToken} → ${params.destToken})`, \"unsupported_pair\");\n if (inputMint === outputMint) return refuse(\"same token on both sides\", \"unsupported_pair\");\n const amountIn = BigInt(params.amountIn);\n if (amountIn <= 0n) return refuse(\"amount must be positive\", \"amount_too_small\");\n const slippageBps = params.slippageBps ?? config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;\n if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > MAX_SLIPPAGE_BPS) return refuse(`slippage ${slippageBps} bps is out of range`, params.slippageBps !== undefined && Number.isInteger(slippageBps) && slippageBps > MAX_SLIPPAGE_BPS ? \"policy_refused\" : undefined);\n\n // The swap pays the taker's own token account: a live quote must be for the signer's own address.\n const self = params.refundAddress || params.destAddress;\n if (!dry) {\n // No address at all is the policy; one that is not a Solana address is the caller's argument (unclassified).\n if (!self || !BASE58.test(self)) return refuse(\"live quote without the signer's address\", !self ? \"policy_refused\" : undefined);\n if (params.destAddress && params.destAddress !== self) return refuse(\"the recipient must be the signing wallet (Jupiter pays the taker)\", \"unsupported_pair\");\n }\n const taker = self && BASE58.test(self) ? self : DRY_TAKER;\n\n const qs = new URLSearchParams({inputMint, outputMint, amount: params.amountIn, taker, slippageBps: String(slippageBps)});\n if (config.computeUnitPricePercentile) qs.set(\"computeUnitPricePercentile\", config.computeUnitPricePercentile);\n let b: BuildResponse;\n // A network failure or our own timeout is Jupiter's; the caller's abort is not.\n try {\n const r = await get(`/build?${qs.toString()}`, signal);\n if (!r.ok) return refuse(`build ${r.status}: ${String((r.body as BuildResponse | null)?.error ?? \"\").slice(0, 160)}`, buildRefusal(r.status, r.body, r.retryAfter, r.rateReset));\n b = (r.body ?? {}) as BuildResponse;\n } catch (e) { return refuse(`build failed: ${(e as Error).message.slice(0, 160)}`, signal?.aborted || !baseIsUrl ? undefined : \"upstream_unavailable\"); }\n // A body the caller's abort cut short reads as null: that is no answer of another shape.\n if (!b.outAmount || !/^\\d+$/.test(b.outAmount)) return refuse(\"answer without an output amount\", answerReason(b) ?? (signal?.aborted ? undefined : \"upstream_unavailable\"));\n\n let vetted: ReturnType<typeof vet>;\n const [wsolAta] = await getProgramDerivedAddress({programAddress: address(ATA_PROGRAM), seeds: [getAddressEncoder().encode(address(taker)), getAddressEncoder().encode(address(TOKEN_PROGRAM)), getAddressEncoder().encode(address(WSOL_MINT))]});\n // A check that fails names its reason; an answer the decoders cannot read is one of another shape.\n try { vetted = vet(b, {taker, inputMint, outputMint, amountIn, slippageBps, wsolAta}); } catch (e) { return refuse((e as Error).message, refusalOf(e) ?? \"upstream_unavailable\"); }\n const minOut = minOutOf(vetted.quotedOut, slippageBps);\n if (params.minAmountOut !== undefined && minOut < BigInt(params.minAmountOut)) {\n return refuse(`guaranteed ${minOut} is below the floor ${params.minAmountOut} at ${slippageBps} bps`, \"price_check_failed\");\n }\n const route = (b.routePlan ?? []).map((s) => s.swapInfo?.label).filter(Boolean).join(\" + \");\n const impact = Number(b.priceImpactPct ?? 0);\n const common = {\n provider: \"jupiter\",\n depositAddress: \"\",\n depositMemo: null,\n sourceAmount: params.amountIn,\n destAmount: b.outAmount,\n minDestAmount: minOut.toString(),\n feeUsd: 0,\n etaSeconds: 15,\n reliability: impact > 0.05 ? 0.8 : 0.97,\n validUntilMs: Date.now() + QUOTE_TTL_MS,\n };\n if (dry) {\n return {...common, intentId: `dry:${INTENT_PREFIX}${Date.now().toString(36)}`, fees: [{type: \"network\" as const, amount: BASE_FEE_LAMPORTS.toString(), token: \"native\", included: false, description: \"Solana base fee\"}], ...(route ? {providerData: {route}} : {})};\n }\n\n const blockhash = b.blockhashWithMetadata?.blockhash;\n const lastValid = b.blockhashWithMetadata?.lastValidBlockHeight;\n if (!blockhash || blockhash.length !== 32 || !lastValid) return refuse(\"answer without a blockhash\", \"upstream_unavailable\");\n const assemble = (limit: number) => assembleTransaction({\n taker, instructions: vetted.instructions, computeUnitLimit: limit, computeUnitPrice: vetted.price,\n blockhash: Uint8Array.from(blockhash), lastValidBlockHeight: lastValid, addressesByLookupTableAddress: b.addressesByLookupTableAddress,\n });\n let wire: string, limit = MAX_COMPUTE_UNITS;\n // The simulation's verdict, else a transaction the answer's instructions or lookup tables cannot assemble.\n try {\n wire = assemble(MAX_COMPUTE_UNITS);\n const units = await simulateUnits(wire);\n if (units) { limit = units; wire = assemble(units); }\n } catch (e) { return refuse((e as Error).message.slice(0, 240), refusalOf(e) ?? \"upstream_unavailable\"); }\n const priority = (vetted.price * BigInt(limit) + 999_999n) / 1_000_000n;\n return {\n ...common,\n intentId: `${INTENT_PREFIX}${lastValid}:${Date.now().toString(36)}`,\n // `value` declares the native SOL the transaction may take: the input for a SOL source (Jupiter wraps it), none for a token.\n txRequest: {serializedTx: wire, value: inputMint === WSOL_MINT ? params.amountIn : \"0\"},\n fees: [{type: \"network\", amount: (BASE_FEE_LAMPORTS + priority).toString(), token: \"native\", included: false, description: `Solana base + priority fee (${limit} CU at ${vetted.price} µlamports)`}],\n providerData: {inputMint, outputMint, slippageBps: String(slippageBps), computeUnits: String(limit), ...(route ? {route} : {})},\n };\n },\n\n async buildDeposit(quote: Quote): Promise<UnsignedTx> {\n const tx = quote.txRequest?.serializedTx;\n if (!tx || quote.intentId.startsWith(\"dry:\")) throw refusal(\"policy_refused\", \"jupiter: not a live quote\");\n return {chain: SOLANA_CAIP2, to: \"\", value: quote.txRequest!.value ?? \"0\", serializedTx: tx};\n },\n\n async trackIntent(ref: IntentRef): Promise<IntentStatus> {\n if (!ref.sourceTxHash || !rpcUrls.length) return {state: \"pending\"};\n try {\n const r = (await rpc(\"getSignatureStatuses\", [[ref.sourceTxHash], {searchTransactionHistory: true}])) as {value?: ({err?: unknown; confirmationStatus?: string} | null)[]};\n const s = r?.value?.[0];\n if (!s) return {state: \"pending\"};\n if (s.err) return {state: \"failed\"};\n return s.confirmationStatus === \"confirmed\" || s.confirmationStatus === \"finalized\" ? {state: \"completed\", destTxHash: ref.sourceTxHash} : {state: \"pending\"};\n } catch {\n return {state: \"pending\"};\n }\n },\n };\n}\n\nfunction bytesEqual(a: ArrayLike<number>, b: ArrayLike<number>): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,SAAQ,SAAS,mBAAmB,gCAA+B;AAGnE,SAAQ,aAAa,SAAS,cAAc,WAAW,kBAAiE;AACxH,SAAQ,qBAAoB;AAG5B,IAAM,uBAAuB;AAC7B,IAAM,mBAAmB;AAEzB,IAAM,eAAe;AACrB,IAAM,oBAAoB;AAE1B,IAAM,uBAAuB;AAC7B,IAAM,oBAAoB;AAE1B,IAAM,YAAY;AAClB,IAAM,SAAS;AAEf,IAAM,qBAAqB;AAwC3B,IAAM,gBAAgB;AAGtB,IAAM,QAAQ,aAAa;AAO3B,SAAS,aAAa,QAAgB,MAAe,YAA2B,WAAwD;AACtI,QAAM,WAAW,YAAY,QAAQ,UAAU;AAC/C,MAAI,UAAU,WAAW,gBAAgB;AACvC,QAAI,SAAS,iBAAiB,UAAa,cAAc,KAAM,QAAO;AACtE,UAAM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
5
5
  jupiter
6
6
  } from "./chunk-OVLAYYGP.js";
@@ -24,4 +24,4 @@ var JupiterSwap2Protocol = class extends SingleProviderSwap2 {
24
24
  export {
25
25
  JupiterSwap2Protocol
26
26
  };
27
- //# sourceMappingURL=chunk-7C6Q32TG.js.map
27
+ //# sourceMappingURL=chunk-NTB2Q6NQ.js.map