@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.
- package/dist/{chunk-EY2HJJXY.js → chunk-4V65GQY2.js} +81 -50
- package/dist/chunk-4V65GQY2.js.map +1 -0
- package/dist/{chunk-7C6Q32TG.js → chunk-NTB2Q6NQ.js} +2 -2
- package/dist/index.cjs +80 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/protocol.cjs +80 -49
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.js +2 -2
- package/dist/provider.cjs +80 -49
- package/dist/provider.cjs.map +1 -1
- package/dist/provider.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-EY2HJJXY.js.map +0 -1
- /package/dist/{chunk-7C6Q32TG.js.map → chunk-NTB2Q6NQ.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -161,6 +161,7 @@ function describeJupiterActivity(tx, ctx) {
|
|
|
161
161
|
|
|
162
162
|
// src/provider.ts
|
|
163
163
|
var import_kit2 = require("@solana/kit");
|
|
164
|
+
var import_errors = require("@anywalletkit/protocol-swap2-core/errors");
|
|
164
165
|
var import_util = require("@anywalletkit/protocol-swap2-core/util");
|
|
165
166
|
var DEFAULT_SLIPPAGE_BPS = 50;
|
|
166
167
|
var MAX_SLIPPAGE_BPS = 1e3;
|
|
@@ -170,12 +171,37 @@ var DEFAULT_MAX_CU_PRICE = 2000000n;
|
|
|
170
171
|
var BASE_FEE_LAMPORTS = 5000n;
|
|
171
172
|
var DRY_TAKER = "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM";
|
|
172
173
|
var BASE582 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
174
|
+
var RETRY_AFTER_MAX_MS = 864e5;
|
|
173
175
|
var INTENT_PREFIX = "jup:";
|
|
176
|
+
var notes = (0, import_errors.refusalNotes)();
|
|
177
|
+
function buildRefusal(status, body, retryAfter, rateReset) {
|
|
178
|
+
const byStatus = (0, import_errors.httpRefusal)(status, retryAfter);
|
|
179
|
+
if (byStatus?.reason === "rate_limited") {
|
|
180
|
+
if (byStatus.retryAfterMs !== void 0 || rateReset === null) return byStatus;
|
|
181
|
+
const wait = Number(rateReset) * 1e3 - Date.now();
|
|
182
|
+
return Number.isFinite(wait) && wait > 0 ? { ...byStatus, retryAfterMs: Math.min(Math.ceil(wait), RETRY_AFTER_MAX_MS) } : byStatus;
|
|
183
|
+
}
|
|
184
|
+
const said = answerReason(body);
|
|
185
|
+
return said && said !== byStatus?.reason ? { reason: said } : byStatus;
|
|
186
|
+
}
|
|
187
|
+
function answerReason(body) {
|
|
188
|
+
const b = body;
|
|
189
|
+
const text = `${typeof b?.errorCode === "string" ? b.errorCode : ""} ${typeof b?.error === "string" ? b.error : ""}`;
|
|
190
|
+
if (/COULD_NOT_FIND_ANY_ROUTE|NO_ROUTES_FOUND|could not find any route|no routes? found/i.test(text)) return "no_route";
|
|
191
|
+
if (/ROUTE_PLAN_DOES_NOT_CONSUME_ALL_THE_AMOUNT|liquidity/i.test(text)) return "insufficient_liquidity";
|
|
192
|
+
if (/TOKEN_NOT_TRADABLE|not tradable|MARKET_NOT_FOUND|CIRCULAR_ARBITRAGE|not supported|unsupported/i.test(text)) return "unsupported_pair";
|
|
193
|
+
if (/too small|too low|below the minimum/i.test(text)) return "amount_too_small";
|
|
194
|
+
if (/too large|too big|above the maximum/i.test(text)) return "amount_too_large";
|
|
195
|
+
if (/rate.?limit|too many requests/i.test(text)) return "rate_limited";
|
|
196
|
+
if (/api.?key|unauthori[sz]ed/i.test(text)) return "key_rejected";
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
174
199
|
function jupiterProvider(config = {}) {
|
|
175
200
|
config = Object.freeze({ ...config });
|
|
176
201
|
const base = (config.apiUrl ?? JUPITER_API_DEFAULT).replace(/\/$/, "");
|
|
177
202
|
const maxPrice = config.maxComputeUnitPrice ?? DEFAULT_MAX_CU_PRICE;
|
|
178
203
|
const rpcUrls = config.rpcUrls ?? [];
|
|
204
|
+
const baseIsUrl = /^(?:https?:\/\/[^/\s]+|\/)/i.test(base);
|
|
179
205
|
const get = async (path, signal) => {
|
|
180
206
|
for (let attempt = 0; ; attempt++) {
|
|
181
207
|
const res = await fetch(`${base}${path}`, { headers: { accept: "application/json", ...config.apiKey ? { "x-api-key": config.apiKey } : {} }, signal: signal ?? (0, import_util.timeoutSignal)(12e3) });
|
|
@@ -186,7 +212,7 @@ function jupiterProvider(config = {}) {
|
|
|
186
212
|
await new Promise((r) => setTimeout(r, wait));
|
|
187
213
|
continue;
|
|
188
214
|
}
|
|
189
|
-
return { ok: res.ok, status: res.status, body };
|
|
215
|
+
return { ok: res.ok, status: res.status, body, retryAfter: res.headers?.get?.("retry-after") ?? null, rateReset: res.headers?.get?.("x-ratelimit-reset") ?? null };
|
|
190
216
|
}
|
|
191
217
|
};
|
|
192
218
|
const rpc = async (method, params) => {
|
|
@@ -207,60 +233,63 @@ function jupiterProvider(config = {}) {
|
|
|
207
233
|
const data = fromBase64(ix.data ?? "");
|
|
208
234
|
const acc = (i) => ix.accounts[i]?.pubkey;
|
|
209
235
|
if (ix.programId === ATA_PROGRAM) {
|
|
210
|
-
if (data.length !== 1 || data[0] !== 1) return "an associated-token instruction other than CreateIdempotent";
|
|
211
|
-
if (acc(0) !== want.taker || acc(2) !== want.taker) return "an associated token account for someone else";
|
|
236
|
+
if (data.length !== 1 || data[0] !== 1) return notes.note("an associated-token instruction other than CreateIdempotent", "policy_refused");
|
|
237
|
+
if (acc(0) !== want.taker || acc(2) !== want.taker) return notes.note("an associated token account for someone else", "recipient_mismatch");
|
|
212
238
|
return null;
|
|
213
239
|
}
|
|
214
240
|
if (ix.programId === SYSTEM_PROGRAM) {
|
|
215
|
-
if (data.length !== 12 || data[0] !== 2 || data[1] !== 0 || data[2] !== 0 || data[3] !== 0) return "a System instruction other than Transfer";
|
|
216
|
-
if (want.inputMint !== WSOL_MINT) return "a SOL transfer on a token-source swap";
|
|
241
|
+
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");
|
|
242
|
+
if (want.inputMint !== WSOL_MINT) return notes.note("a SOL transfer on a token-source swap", "policy_refused");
|
|
217
243
|
const lamports = new DataView(data.buffer, data.byteOffset + 4, 8).getBigUint64(0, true);
|
|
218
|
-
if (acc(0) !== want.taker || acc(1) !== want.wsolAta) return `a SOL transfer to ${acc(1)}, not the taker's wSOL account
|
|
219
|
-
if (lamports !== want.amountIn) return `a SOL transfer of ${lamports}, not the ${want.amountIn} input
|
|
244
|
+
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");
|
|
245
|
+
if (lamports !== want.amountIn) return notes.note(`a SOL transfer of ${lamports}, not the ${want.amountIn} input`, "policy_refused");
|
|
220
246
|
return null;
|
|
221
247
|
}
|
|
222
248
|
if (ix.programId === TOKEN_PROGRAM) {
|
|
223
|
-
if (data.length === 1 && data[0] === 17) return acc(0) === want.wsolAta ? null : "SyncNative on another account";
|
|
249
|
+
if (data.length === 1 && data[0] === 17) return acc(0) === want.wsolAta ? null : notes.note("SyncNative on another account", "policy_refused");
|
|
224
250
|
if (data.length === 1 && data[0] === 9) {
|
|
225
|
-
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";
|
|
251
|
+
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");
|
|
226
252
|
}
|
|
227
253
|
if (data.length === 33 && data[0] === 18) {
|
|
228
|
-
return bytesEqual(data.subarray(1), (0, import_kit2.getAddressEncoder)().encode((0, import_kit2.address)(want.taker))) ? null : "a token account initialized for someone else";
|
|
254
|
+
return bytesEqual(data.subarray(1), (0, import_kit2.getAddressEncoder)().encode((0, import_kit2.address)(want.taker))) ? null : notes.note("a token account initialized for someone else", "recipient_mismatch");
|
|
229
255
|
}
|
|
230
|
-
return `a Token instruction (tag ${data[0] ?? "none"}) the swap does not need
|
|
256
|
+
return notes.note(`a Token instruction (tag ${data[0] ?? "none"}) the swap does not need`, "policy_refused");
|
|
231
257
|
}
|
|
232
|
-
if (ix.programId === JUPITER_PROGRAM) return "a second Jupiter instruction";
|
|
233
|
-
return `instruction for program ${ix.programId}
|
|
258
|
+
if (ix.programId === JUPITER_PROGRAM) return notes.note("a second Jupiter instruction", "policy_refused");
|
|
259
|
+
return notes.note(`instruction for program ${ix.programId}`, "policy_refused");
|
|
234
260
|
};
|
|
235
261
|
const vet = (b, want) => {
|
|
236
|
-
if (b.swapMode && b.swapMode !== "ExactIn") throw
|
|
237
|
-
if (b.inputMint !== want.inputMint || b.outputMint !== want.outputMint) throw
|
|
238
|
-
if (b.inAmount !== want.amountIn.toString()) throw
|
|
239
|
-
if (String(b.transactionVersion ?? "0") !== "0") throw
|
|
240
|
-
if (b.tipInstruction) throw
|
|
241
|
-
if (!b.swapInstruction) throw
|
|
242
|
-
if (b.swapInstruction.programId !== JUPITER_PROGRAM) throw
|
|
262
|
+
if (b.swapMode && b.swapMode !== "ExactIn") throw (0, import_errors.refusal)("policy_refused", `swap mode ${b.swapMode}`);
|
|
263
|
+
if (b.inputMint !== want.inputMint || b.outputMint !== want.outputMint) throw (0, import_errors.refusal)("policy_refused", "the answer names other mints");
|
|
264
|
+
if (b.inAmount !== want.amountIn.toString()) throw (0, import_errors.refusal)("policy_refused", `the answer spends ${b.inAmount}, not ${want.amountIn}`);
|
|
265
|
+
if (String(b.transactionVersion ?? "0") !== "0") throw (0, import_errors.refusal)("policy_refused", `transaction version ${b.transactionVersion}`);
|
|
266
|
+
if (b.tipInstruction) throw (0, import_errors.refusal)("policy_refused", "unexpected tip instruction");
|
|
267
|
+
if (!b.swapInstruction) throw (0, import_errors.refusal)("upstream_unavailable", "no swap instruction");
|
|
268
|
+
if (b.swapInstruction.programId !== JUPITER_PROGRAM) throw (0, import_errors.refusal)("vault_mismatch", `swap instruction targets ${b.swapInstruction.programId}`);
|
|
243
269
|
const args = decodeSwapArgs(fromBase64(b.swapInstruction.data));
|
|
244
|
-
if (args.inAmount !== want.amountIn) throw
|
|
245
|
-
if (String(args.quotedOutAmount) !== b.outAmount) throw
|
|
246
|
-
if (args.slippageBps !== want.slippageBps) throw
|
|
247
|
-
if (args.platformFeeBps !== 0 || args.positiveSlippageBps !== 0) throw
|
|
270
|
+
if (args.inAmount !== want.amountIn) throw (0, import_errors.refusal)("policy_refused", `swap instruction spends ${args.inAmount}, not ${want.amountIn}`);
|
|
271
|
+
if (String(args.quotedOutAmount) !== b.outAmount) throw (0, import_errors.refusal)("price_check_failed", "swap instruction's quoted output differs from the answer");
|
|
272
|
+
if (args.slippageBps !== want.slippageBps) throw (0, import_errors.refusal)("price_check_failed", `swap instruction allows ${args.slippageBps} bps slippage, not ${want.slippageBps}`);
|
|
273
|
+
if (args.platformFeeBps !== 0 || args.positiveSlippageBps !== 0) throw (0, import_errors.refusal)("policy_refused", "swap instruction takes a platform fee");
|
|
248
274
|
let price = 0n;
|
|
249
275
|
for (const ix of b.computeBudgetInstructions ?? []) {
|
|
250
|
-
if (ix.programId !== COMPUTE_BUDGET_PROGRAM) throw
|
|
276
|
+
if (ix.programId !== COMPUTE_BUDGET_PROGRAM) throw (0, import_errors.refusal)("policy_refused", `compute-budget slot holds ${ix.programId}`);
|
|
251
277
|
const d = decodeComputeBudget(fromBase64(ix.data));
|
|
252
278
|
if (d.price !== void 0) price = d.price;
|
|
253
279
|
}
|
|
254
280
|
const instructions = [...b.setupInstructions ?? [], b.swapInstruction, ...b.cleanupInstruction ? [b.cleanupInstruction] : [], ...b.otherInstructions ?? []];
|
|
255
281
|
let funded = false;
|
|
256
282
|
for (const ix of instructions) {
|
|
257
|
-
if (!JUPITER_TX_PROGRAMS.has(ix.programId) || ix.programId === COMPUTE_BUDGET_PROGRAM) throw
|
|
258
|
-
for (const a of ix.accounts) if (a.isSigner && a.pubkey !== want.taker) throw
|
|
283
|
+
if (!JUPITER_TX_PROGRAMS.has(ix.programId) || ix.programId === COMPUTE_BUDGET_PROGRAM) throw (0, import_errors.refusal)("policy_refused", `instruction for program ${ix.programId}`);
|
|
284
|
+
for (const a of ix.accounts) if (a.isSigner && a.pubkey !== want.taker) throw (0, import_errors.refusal)("policy_refused", `instruction needs signer ${a.pubkey}`);
|
|
259
285
|
if (ix === b.swapInstruction) continue;
|
|
260
286
|
const why = shapeRefusal(ix, want);
|
|
261
|
-
if (why)
|
|
287
|
+
if (why) {
|
|
288
|
+
const info = notes.reasonOf(why);
|
|
289
|
+
throw info ? (0, import_errors.withReason)(new Error(why), info) : new Error(why);
|
|
290
|
+
}
|
|
262
291
|
if (ix.programId === SYSTEM_PROGRAM) {
|
|
263
|
-
if (funded) throw
|
|
292
|
+
if (funded) throw (0, import_errors.refusal)("policy_refused", "a second SOL transfer");
|
|
264
293
|
funded = true;
|
|
265
294
|
}
|
|
266
295
|
}
|
|
@@ -279,9 +308,9 @@ function jupiterProvider(config = {}) {
|
|
|
279
308
|
const err = JSON.stringify(r.value.err);
|
|
280
309
|
const jupiterCode = /JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 failed/.test(log) ? /"Custom":(\d+)/.exec(err)?.[1] : void 0;
|
|
281
310
|
if (jupiterCode === "6024" || jupiterCode === "6025" || /"Custom":1\}/.test(err) && /Program 11111111111111111111111111111111 failed/.test(log)) {
|
|
282
|
-
throw
|
|
311
|
+
throw (0, import_errors.refusal)("simulation_failed", `not enough of the input token in the wallet${jupiterCode === "6025" ? " (no token account for it)" : ""} \u2014 simulation fails: ${err}`);
|
|
283
312
|
}
|
|
284
|
-
throw
|
|
313
|
+
throw (0, import_errors.refusal)("simulation_failed", `simulation fails: ${err}${log ? ` (${log.slice(0, 160)})` : ""}`);
|
|
285
314
|
}
|
|
286
315
|
const used = r?.value?.unitsConsumed;
|
|
287
316
|
return used ? Math.min(MAX_COMPUTE_UNITS, Math.ceil(used * 1.2)) : null;
|
|
@@ -300,23 +329,25 @@ function jupiterProvider(config = {}) {
|
|
|
300
329
|
},
|
|
301
330
|
async getQuote(params, signal) {
|
|
302
331
|
const dry = params.dry !== false;
|
|
303
|
-
const refuse = (reason) => {
|
|
304
|
-
|
|
332
|
+
const refuse = (reason, why) => {
|
|
333
|
+
const info = typeof why === "string" ? { reason: why } : why;
|
|
334
|
+
if (info) params.onRefusal?.(`jupiter: ${reason}`, info);
|
|
335
|
+
else params.onRefusal?.(`jupiter: ${reason}`);
|
|
305
336
|
return null;
|
|
306
337
|
};
|
|
307
|
-
if (!jupiter.supports(params.sourceChain, params.destChain)) return refuse(`same-chain Solana only (${params.sourceChain} \u2192 ${params.destChain})
|
|
308
|
-
if (params.flex) return refuse("amount-flexible deposits are not supported");
|
|
338
|
+
if (!jupiter.supports(params.sourceChain, params.destChain)) return refuse(`same-chain Solana only (${params.sourceChain} \u2192 ${params.destChain})`, "unsupported_pair");
|
|
339
|
+
if (params.flex) return refuse("amount-flexible deposits are not supported", "unsupported_pair");
|
|
309
340
|
const inputMint = jupiterMint(params.sourceToken), outputMint = jupiterMint(params.destToken);
|
|
310
|
-
if (!inputMint || !outputMint) return refuse(`unknown token (${params.sourceToken} \u2192 ${params.destToken})
|
|
311
|
-
if (inputMint === outputMint) return refuse("same token on both sides");
|
|
341
|
+
if (!inputMint || !outputMint) return refuse(`unknown token (${params.sourceToken} \u2192 ${params.destToken})`, "unsupported_pair");
|
|
342
|
+
if (inputMint === outputMint) return refuse("same token on both sides", "unsupported_pair");
|
|
312
343
|
const amountIn = BigInt(params.amountIn);
|
|
313
|
-
if (amountIn <= 0n) return refuse("amount must be positive");
|
|
344
|
+
if (amountIn <= 0n) return refuse("amount must be positive", "amount_too_small");
|
|
314
345
|
const slippageBps = params.slippageBps ?? config.defaultSlippageBps ?? DEFAULT_SLIPPAGE_BPS;
|
|
315
|
-
if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > MAX_SLIPPAGE_BPS) return refuse(`slippage ${slippageBps} bps is out of range
|
|
346
|
+
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);
|
|
316
347
|
const self = params.refundAddress || params.destAddress;
|
|
317
348
|
if (!dry) {
|
|
318
|
-
if (!self || !BASE582.test(self)) return refuse("live quote without the signer's address");
|
|
319
|
-
if (params.destAddress && params.destAddress !== self) return refuse("the recipient must be the signing wallet (Jupiter pays the taker)");
|
|
349
|
+
if (!self || !BASE582.test(self)) return refuse("live quote without the signer's address", !self ? "policy_refused" : void 0);
|
|
350
|
+
if (params.destAddress && params.destAddress !== self) return refuse("the recipient must be the signing wallet (Jupiter pays the taker)", "unsupported_pair");
|
|
320
351
|
}
|
|
321
352
|
const taker = self && BASE582.test(self) ? self : DRY_TAKER;
|
|
322
353
|
const qs = new URLSearchParams({ inputMint, outputMint, amount: params.amountIn, taker, slippageBps: String(slippageBps) });
|
|
@@ -324,22 +355,22 @@ function jupiterProvider(config = {}) {
|
|
|
324
355
|
let b;
|
|
325
356
|
try {
|
|
326
357
|
const r = await get(`/build?${qs.toString()}`, signal);
|
|
327
|
-
if (!r.ok) return refuse(`build ${r.status}: ${String(r.body?.error ?? "").slice(0, 160)}
|
|
358
|
+
if (!r.ok) return refuse(`build ${r.status}: ${String(r.body?.error ?? "").slice(0, 160)}`, buildRefusal(r.status, r.body, r.retryAfter, r.rateReset));
|
|
328
359
|
b = r.body ?? {};
|
|
329
360
|
} catch (e) {
|
|
330
|
-
return refuse(`build failed: ${e.message.slice(0, 160)}
|
|
361
|
+
return refuse(`build failed: ${e.message.slice(0, 160)}`, signal?.aborted || !baseIsUrl ? void 0 : "upstream_unavailable");
|
|
331
362
|
}
|
|
332
|
-
if (!b.outAmount || !/^\d+$/.test(b.outAmount)) return refuse("answer without an output amount");
|
|
363
|
+
if (!b.outAmount || !/^\d+$/.test(b.outAmount)) return refuse("answer without an output amount", answerReason(b) ?? (signal?.aborted ? void 0 : "upstream_unavailable"));
|
|
333
364
|
let vetted;
|
|
334
365
|
const [wsolAta] = await (0, import_kit2.getProgramDerivedAddress)({ programAddress: (0, import_kit2.address)(ATA_PROGRAM), seeds: [(0, import_kit2.getAddressEncoder)().encode((0, import_kit2.address)(taker)), (0, import_kit2.getAddressEncoder)().encode((0, import_kit2.address)(TOKEN_PROGRAM)), (0, import_kit2.getAddressEncoder)().encode((0, import_kit2.address)(WSOL_MINT))] });
|
|
335
366
|
try {
|
|
336
367
|
vetted = vet(b, { taker, inputMint, outputMint, amountIn, slippageBps, wsolAta });
|
|
337
368
|
} catch (e) {
|
|
338
|
-
return refuse(e.message);
|
|
369
|
+
return refuse(e.message, (0, import_errors.refusalOf)(e) ?? "upstream_unavailable");
|
|
339
370
|
}
|
|
340
371
|
const minOut = minOutOf(vetted.quotedOut, slippageBps);
|
|
341
372
|
if (params.minAmountOut !== void 0 && minOut < BigInt(params.minAmountOut)) {
|
|
342
|
-
return refuse(`guaranteed ${minOut} is below the floor ${params.minAmountOut} at ${slippageBps} bps
|
|
373
|
+
return refuse(`guaranteed ${minOut} is below the floor ${params.minAmountOut} at ${slippageBps} bps`, "price_check_failed");
|
|
343
374
|
}
|
|
344
375
|
const route = (b.routePlan ?? []).map((s) => s.swapInfo?.label).filter(Boolean).join(" + ");
|
|
345
376
|
const impact = Number(b.priceImpactPct ?? 0);
|
|
@@ -360,7 +391,7 @@ function jupiterProvider(config = {}) {
|
|
|
360
391
|
}
|
|
361
392
|
const blockhash = b.blockhashWithMetadata?.blockhash;
|
|
362
393
|
const lastValid = b.blockhashWithMetadata?.lastValidBlockHeight;
|
|
363
|
-
if (!blockhash || blockhash.length !== 32 || !lastValid) return refuse("answer without a blockhash");
|
|
394
|
+
if (!blockhash || blockhash.length !== 32 || !lastValid) return refuse("answer without a blockhash", "upstream_unavailable");
|
|
364
395
|
const assemble = (limit2) => assembleTransaction({
|
|
365
396
|
taker,
|
|
366
397
|
instructions: vetted.instructions,
|
|
@@ -379,7 +410,7 @@ function jupiterProvider(config = {}) {
|
|
|
379
410
|
wire = assemble(units);
|
|
380
411
|
}
|
|
381
412
|
} catch (e) {
|
|
382
|
-
return refuse(e.message.slice(0, 240));
|
|
413
|
+
return refuse(e.message.slice(0, 240), (0, import_errors.refusalOf)(e) ?? "upstream_unavailable");
|
|
383
414
|
}
|
|
384
415
|
const priority = (vetted.price * BigInt(limit) + 999999n) / 1000000n;
|
|
385
416
|
return {
|
|
@@ -393,7 +424,7 @@ function jupiterProvider(config = {}) {
|
|
|
393
424
|
},
|
|
394
425
|
async buildDeposit(quote) {
|
|
395
426
|
const tx = quote.txRequest?.serializedTx;
|
|
396
|
-
if (!tx || quote.intentId.startsWith("dry:")) throw
|
|
427
|
+
if (!tx || quote.intentId.startsWith("dry:")) throw (0, import_errors.refusal)("policy_refused", "jupiter: not a live quote");
|
|
397
428
|
return { chain: SOLANA_CAIP2, to: "", value: quote.txRequest.value ?? "0", serializedTx: tx };
|
|
398
429
|
},
|
|
399
430
|
async trackIntent(ref) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/codec.ts","../src/transaction.ts","../src/activity.ts","../src/provider.ts","../src/protocol.ts"],"sourcesContent":["export * from \"./config.js\";\nexport * from \"./codec.js\";\nexport * from \"./transaction.js\";\nexport * from \"./provider.js\";\nexport {JupiterSwap2Protocol, type JupiterSwap2Config} from \"./protocol.js\";\nexport {JupiterSwap2Protocol as default} from \"./protocol.js\";\nexport * from \"./activity.js\";\n","/**\n * Jupiter (Solana) — Swap API V2, Router path (`GET /swap/v2/build`): Metis on-chain routing, raw instructions, no\n * Jupiter swap fee. The transaction is assembled here and executed by the account's serialized-transaction guard\n * (simulation + balance proof), then broadcast through the wallet's own RPC — Jupiter never lands it for us.\n * Same-chain only: Solana → Solana.\n */\nimport {ccAsset, ccAssetByToken} from \"@anywalletkit/swap2-assets\";\n\nexport const JUPITER_API_DEFAULT = \"https://api.jup.ag/swap/v2\";\n\n/** Jupiter Aggregator v6 — the only program a swap instruction may target. */\nexport const JUPITER_PROGRAM = \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\";\nexport const COMPUTE_BUDGET_PROGRAM = \"ComputeBudget111111111111111111111111111111\";\nexport const SYSTEM_PROGRAM = \"11111111111111111111111111111111\";\nexport const TOKEN_PROGRAM = \"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\";\nexport const TOKEN_2022_PROGRAM = \"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb\";\nexport const ATA_PROGRAM = \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\";\n/** Wrapped SOL: Jupiter's name for native SOL (it wraps / unwraps around the swap). */\nexport const WSOL_MINT = \"So11111111111111111111111111111111111111112\";\n\n/** Programs the /build instructions may invoke; anything else refuses the quote before the wallet sees it. */\nexport const JUPITER_TX_PROGRAMS: ReadonlySet<string> = new Set([JUPITER_PROGRAM, COMPUTE_BUDGET_PROGRAM, SYSTEM_PROGRAM, TOKEN_PROGRAM, TOKEN_2022_PROGRAM, ATA_PROGRAM]);\n\n/** swap2 names Solana `solana:mainnet`; wallet history uses the genesis-hash form. */\nexport const SOLANA_CAIP2 = \"solana:mainnet\";\nexport const SOLANA_CHAINS: ReadonlySet<string> = new Set([SOLANA_CAIP2, \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\"]);\n\nconst BASE58 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\nconst NATIVE = new Set([\"\", \"native\", \"sol\", SYSTEM_PROGRAM, WSOL_MINT.toLowerCase(), \"0x0000000000000000000000000000000000000000\"]);\n\n/** A swap2 token ref on Solana (catalog symbol, mint, or a native marker) → the mint Jupiter quotes; null when unknown. */\nexport function jupiterMint(token: string): string | null {\n if (NATIVE.has(token.toLowerCase()) || /^0x0+$/.test(token)) return WSOL_MINT;\n const bySymbol = ccAsset(SOLANA_CAIP2, token);\n if (bySymbol) return bySymbol.contract ?? WSOL_MINT;\n const byMint = BASE58.test(token) ? ccAssetByToken(SOLANA_CAIP2, token) : undefined;\n if (byMint) return byMint.contract ?? WSOL_MINT;\n return BASE58.test(token) ? token : null;\n}\n\nexport const jupiter = {\n supportsChain: (chain: string) => chain === SOLANA_CAIP2,\n supports: (from: string, to: string) => from === SOLANA_CAIP2 && to === SOLANA_CAIP2,\n};\n","/**\n * Byte-level checks of what `/build` returns. The swap instruction is Jupiter v6's Anchor `route_v2` /\n * `shared_accounts_route_v2` (ExactIn): its arguments carry the input amount, the quoted output, the slippage and the\n * platform-fee split that the program enforces on-chain — so they are read back here and must equal the request\n * before the transaction is assembled. Discriminators = sha256(\"global:<name>\")[0..8] (verified 2026-10-23 against\n * live /build answers).\n */\nimport {base64} from \"@scure/base\";\n\n/** `route_v2(in_amount u64, quoted_out_amount u64, slippage_bps u16, platform_fee_bps u16, positive_slippage_bps u16, route_plan Vec)` */\nexport const ROUTE_V2 = \"bb64facc31c4af14\";\n/** `shared_accounts_route_v2(id u8, …the same arguments…)` */\nexport const SHARED_ACCOUNTS_ROUTE_V2 = \"d19853937cfed8e9\";\n\nexport interface JupiterSwapArgs {\n kind: \"route_v2\" | \"shared_accounts_route_v2\";\n inAmount: bigint;\n quotedOutAmount: bigint;\n slippageBps: number;\n platformFeeBps: number;\n positiveSlippageBps: number;\n}\n\nconst hex = (b: Uint8Array) => Array.from(b, (x) => x.toString(16).padStart(2, \"0\")).join(\"\");\nconst u64 = (d: Uint8Array, o: number) => new DataView(d.buffer, d.byteOffset + o, 8).getBigUint64(0, true);\nconst u16 = (d: Uint8Array, o: number) => new DataView(d.buffer, d.byteOffset + o, 2).getUint16(0, true);\n\nexport const fromBase64 = (s: string): Uint8Array => base64.decode(s);\nexport const toBase64 = (b: Uint8Array): string => base64.encode(b);\n\n/** Decode the swap instruction's fixed arguments; throws for any other instruction (ExactOut, legacy v1 routes…). */\nexport function decodeSwapArgs(data: Uint8Array): JupiterSwapArgs {\n const disc = hex(data.subarray(0, 8));\n const at = disc === ROUTE_V2 ? 8 : disc === SHARED_ACCOUNTS_ROUTE_V2 ? 9 : -1;\n if (at < 0) throw new Error(`unsupported Jupiter instruction ${disc}`);\n if (data.length < at + 22 + 4) throw new Error(\"Jupiter swap instruction is truncated\");\n return {\n kind: at === 8 ? \"route_v2\" : \"shared_accounts_route_v2\",\n inAmount: u64(data, at),\n quotedOutAmount: u64(data, at + 8),\n slippageBps: u16(data, at + 16),\n platformFeeBps: u16(data, at + 18),\n positiveSlippageBps: u16(data, at + 20),\n };\n}\n\n/** The worst output the program accepts: quoted · (10 000 − slippage) / 10 000, rounded down (never above the on-chain check). */\nexport function minOutOf(quotedOut: bigint, slippageBps: number): bigint {\n return (quotedOut * BigInt(10_000 - slippageBps)) / 10_000n;\n}\n\n/** ComputeBudget instructions: 2 = SetComputeUnitLimit(u32), 3 = SetComputeUnitPrice(u64 micro-lamports). */\nexport function decodeComputeBudget(data: Uint8Array): {limit?: number; price?: bigint} {\n if (data[0] === 2 && data.length === 5) return {limit: new DataView(data.buffer, data.byteOffset + 1, 4).getUint32(0, true)};\n if (data[0] === 3 && data.length === 9) return {price: u64(data, 1)};\n throw new Error(`unexpected compute-budget instruction ${data[0]}`);\n}\n\nexport function setComputeUnitLimit(units: number): Uint8Array {\n const d = new Uint8Array(5);\n d[0] = 2;\n new DataView(d.buffer).setUint32(1, units, true);\n return d;\n}\n\nexport function setComputeUnitPrice(microLamports: bigint): Uint8Array {\n const d = new Uint8Array(9);\n d[0] = 3;\n new DataView(d.buffer).setBigUint64(1, microLamports, true);\n return d;\n}\n","/**\n * Assemble the v0 transaction from `/build` instructions: our compute budget (limit + capped price), Jupiter's setup,\n * swap, cleanup and other instructions, compressed with the lookup tables the response names, fee payer = the taker,\n * lifetime = the blockhash Jupiter fetched. Signatures stay empty; the account signs after its own guard.\n */\nimport {\n AccountRole, address, appendTransactionMessageInstructions, compileTransaction, compressTransactionMessageUsingAddressLookupTables,\n createTransactionMessage, getBase58Decoder, getBase64EncodedWireTransaction, pipe, setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash, type Address, type Blockhash, type Instruction,\n} from \"@solana/kit\";\nimport {COMPUTE_BUDGET_PROGRAM} from \"./config.js\";\nimport {fromBase64, setComputeUnitLimit, setComputeUnitPrice} from \"./codec.js\";\n\nexport interface JupiterInstruction {\n programId: string;\n accounts: {pubkey: string; isSigner: boolean; isWritable: boolean}[];\n data: string;\n}\n\nexport interface AssembleInput {\n taker: string;\n /** setup → swap → cleanup → other, in that order; compute-budget instructions are ours and come first. */\n instructions: JupiterInstruction[];\n computeUnitLimit: number;\n computeUnitPrice: bigint;\n blockhash: Uint8Array | string;\n lastValidBlockHeight: number | bigint;\n addressesByLookupTableAddress: Record<string, string[]> | null | undefined;\n}\n\nconst role = (a: {isSigner: boolean; isWritable: boolean}): AccountRole =>\n a.isSigner ? (a.isWritable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER) : a.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;\n\nconst toInstruction = (ix: JupiterInstruction): Instruction => ({\n programAddress: address(ix.programId),\n accounts: ix.accounts.map((a) => ({address: address(a.pubkey), role: role(a)})),\n data: fromBase64(ix.data),\n});\n\n/** The unsigned transaction as base64 wire bytes (what `TxRequest.serializedTx` carries). */\nexport function assembleTransaction(input: AssembleInput): string {\n const budget: Instruction[] = [\n {programAddress: address(COMPUTE_BUDGET_PROGRAM), data: setComputeUnitLimit(input.computeUnitLimit)},\n {programAddress: address(COMPUTE_BUDGET_PROGRAM), data: setComputeUnitPrice(input.computeUnitPrice)},\n ];\n const blockhash = (typeof input.blockhash === \"string\" ? input.blockhash : getBase58Decoder().decode(input.blockhash)) as Blockhash;\n const tables: Record<Address, Address[]> = {};\n for (const [table, list] of Object.entries(input.addressesByLookupTableAddress ?? {})) tables[address(table)] = list.map((a) => address(a));\n const message = pipe(\n createTransactionMessage({version: 0}),\n (m) => setTransactionMessageFeePayer(address(input.taker), m),\n (m) => setTransactionMessageLifetimeUsingBlockhash({blockhash, lastValidBlockHeight: BigInt(input.lastValidBlockHeight)}, m),\n (m) => appendTransactionMessageInstructions([...budget, ...input.instructions.map(toInstruction)], m),\n (m) => (Object.keys(tables).length ? compressTransactionMessageUsingAddressLookupTables(m, tables) : m),\n );\n return getBase64EncodedWireTransaction(compileTransaction(message));\n}\n","/**\n * Activity recognition for Jupiter swaps. Solana history (wallet-solana) names the first non-plumbing program a\n * transaction runs as `call.to`: a swap sent to Jupiter v6 directly (this module's /build transactions, jup.ag) has it\n * there. A route that only passes through Jupiter inside another program (an aggregator or bridge CPI-ing into it) names\n * that program instead and is left to its module. The owner must both give and receive an asset: a leg that only sends\n * (a bridge's source leg with a Jupiter pre-swap) is not called a swap.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {describeSwapLike} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {JUPITER_PROGRAM, SOLANA_CHAINS} from \"./config.js\";\n\nexport const JUPITER_MODULE = \"@anywalletkit/protocol-swap2-jupiter\";\n\nexport function describeJupiterActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n if (!SOLANA_CHAINS.has(tx.chain) || tx.call?.to !== JUPITER_PROGRAM) return null;\n const item = describeSwapLike(tx, ctx, {protocol: JUPITER_MODULE, subtitle: \"Jupiter\", kind: \"swap\", counterparty: JUPITER_PROGRAM});\n if (item && tx.status !== \"failed\" && (item.assetsIn.length === 0 || item.assetsOut.length === 0)) return null;\n return item;\n}\n","/**\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 {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\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\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\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}> => {\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};\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 \"an associated-token instruction other than CreateIdempotent\";\n if (acc(0) !== want.taker || acc(2) !== want.taker) return \"an associated token account for someone else\";\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 \"a System instruction other than Transfer\";\n if (want.inputMint !== WSOL_MINT) return \"a SOL transfer on a token-source swap\";\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 `a SOL transfer to ${acc(1)}, not the taker's wSOL account`;\n if (lamports !== want.amountIn) return `a SOL transfer of ${lamports}, not the ${want.amountIn} input`;\n return null;\n }\n if (ix.programId === TOKEN_PROGRAM) {\n if (data.length === 1 && data[0] === 17) return acc(0) === want.wsolAta ? null : \"SyncNative on another account\"; // 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 : \"a CloseAccount that is not the taker's wSOL account back to the taker\";\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 : \"a token account initialized for someone else\";\n }\n return `a Token instruction (tag ${data[0] ?? \"none\"}) the swap does not need`;\n }\n if (ix.programId === JUPITER_PROGRAM) return \"a second Jupiter instruction\";\n return `instruction for program ${ix.programId}`;\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 new Error(`swap mode ${b.swapMode}`);\n if (b.inputMint !== want.inputMint || b.outputMint !== want.outputMint) throw new Error(\"the answer names other mints\");\n if (b.inAmount !== want.amountIn.toString()) throw new Error(`the answer spends ${b.inAmount}, not ${want.amountIn}`);\n if (String(b.transactionVersion ?? \"0\") !== \"0\") throw new Error(`transaction version ${b.transactionVersion}`);\n if (b.tipInstruction) throw new Error(\"unexpected tip instruction\");\n if (!b.swapInstruction) throw new Error(\"no swap instruction\");\n if (b.swapInstruction.programId !== JUPITER_PROGRAM) throw new Error(`swap instruction targets ${b.swapInstruction.programId}`);\n const args = decodeSwapArgs(fromBase64(b.swapInstruction.data));\n if (args.inAmount !== want.amountIn) throw new Error(`swap instruction spends ${args.inAmount}, not ${want.amountIn}`);\n if (String(args.quotedOutAmount) !== b.outAmount) throw new Error(\"swap instruction's quoted output differs from the answer\");\n if (args.slippageBps !== want.slippageBps) throw new Error(`swap instruction allows ${args.slippageBps} bps slippage, not ${want.slippageBps}`);\n if (args.platformFeeBps !== 0 || args.positiveSlippageBps !== 0) throw new Error(\"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 new Error(`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 new Error(`instruction for program ${ix.programId}`);\n for (const a of ix.accounts) if (a.isSigner && a.pubkey !== want.taker) throw new Error(`instruction needs signer ${a.pubkey}`);\n if (ix === b.swapInstruction) continue;\n const why = shapeRefusal(ix, want);\n if (why) throw new Error(why);\n if (ix.programId === SYSTEM_PROGRAM) {\n if (funded) throw new Error(\"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 new Error(`not enough of the input token in the wallet${jupiterCode === \"6025\" ? \" (no token account for it)\" : \"\"} — simulation fails: ${err}`);\n }\n throw new Error(`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): null => {\n 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})`);\n if (params.flex) return refuse(\"amount-flexible deposits are not supported\");\n const inputMint = jupiterMint(params.sourceToken), outputMint = jupiterMint(params.destToken);\n if (!inputMint || !outputMint) return refuse(`unknown token (${params.sourceToken} → ${params.destToken})`);\n if (inputMint === outputMint) return refuse(\"same token on both sides\");\n const amountIn = BigInt(params.amountIn);\n if (amountIn <= 0n) return refuse(\"amount must be positive\");\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`);\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 if (!self || !BASE58.test(self)) return refuse(\"live quote without the signer's address\");\n if (params.destAddress && params.destAddress !== self) return refuse(\"the recipient must be the signing wallet (Jupiter pays the taker)\");\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 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)}`);\n b = (r.body ?? {}) as BuildResponse;\n } catch (e) { return refuse(`build failed: ${(e as Error).message.slice(0, 160)}`); }\n if (!b.outAmount || !/^\\d+$/.test(b.outAmount)) return refuse(\"answer without an output amount\");\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 try { vetted = vet(b, {taker, inputMint, outputMint, amountIn, slippageBps, wsolAta}); } catch (e) { return refuse((e as Error).message); }\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`);\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\");\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 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)); }\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 new Error(\"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","import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {jupiter as jupCfg} from \"./config.js\";\nimport {jupiterProvider, type JupiterProviderConfig} from \"./provider.js\";\n\nexport interface JupiterSwap2Config extends Swap2EngineConfig, JupiterProviderConfig {}\n\n/** Standalone Jupiter swap2: same-chain Solana swaps (Metis routing, /build, no Jupiter fee). */\nexport class JupiterSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: JupiterSwap2Config) {\n super(account, config);\n this.provider = jupiterProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return jupCfg.supportsChain(caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return jupCfg.supports(fromChain, toChain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,0BAAsC;AAE/B,IAAM,sBAAsB;AAG5B,IAAM,kBAAkB;AACxB,IAAM,yBAAyB;AAC/B,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,cAAc;AAEpB,IAAM,YAAY;AAGlB,IAAM,sBAA2C,oBAAI,IAAI,CAAC,iBAAiB,wBAAwB,gBAAgB,eAAe,oBAAoB,WAAW,CAAC;AAGlK,IAAM,eAAe;AACrB,IAAM,gBAAqC,oBAAI,IAAI,CAAC,cAAc,yCAAyC,CAAC;AAEnH,IAAM,SAAS;AACf,IAAM,SAAS,oBAAI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AAK;AAAA,EACnC;AAAA,EACmB,cAAc,WAAmB,SAA0B;AAC5E,WAAO,QAAO,SAAS,WAAW,OAAO;AAAA,EAC3C;AACF;","names":["import_kit","BASE58","limit"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/codec.ts","../src/transaction.ts","../src/activity.ts","../src/provider.ts","../src/protocol.ts"],"sourcesContent":["export * from \"./config.js\";\nexport * from \"./codec.js\";\nexport * from \"./transaction.js\";\nexport * from \"./provider.js\";\nexport {JupiterSwap2Protocol, type JupiterSwap2Config} from \"./protocol.js\";\nexport {JupiterSwap2Protocol as default} from \"./protocol.js\";\nexport * from \"./activity.js\";\n","/**\n * Jupiter (Solana) — Swap API V2, Router path (`GET /swap/v2/build`): Metis on-chain routing, raw instructions, no\n * Jupiter swap fee. The transaction is assembled here and executed by the account's serialized-transaction guard\n * (simulation + balance proof), then broadcast through the wallet's own RPC — Jupiter never lands it for us.\n * Same-chain only: Solana → Solana.\n */\nimport {ccAsset, ccAssetByToken} from \"@anywalletkit/swap2-assets\";\n\nexport const JUPITER_API_DEFAULT = \"https://api.jup.ag/swap/v2\";\n\n/** Jupiter Aggregator v6 — the only program a swap instruction may target. */\nexport const JUPITER_PROGRAM = \"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4\";\nexport const COMPUTE_BUDGET_PROGRAM = \"ComputeBudget111111111111111111111111111111\";\nexport const SYSTEM_PROGRAM = \"11111111111111111111111111111111\";\nexport const TOKEN_PROGRAM = \"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\";\nexport const TOKEN_2022_PROGRAM = \"TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb\";\nexport const ATA_PROGRAM = \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\";\n/** Wrapped SOL: Jupiter's name for native SOL (it wraps / unwraps around the swap). */\nexport const WSOL_MINT = \"So11111111111111111111111111111111111111112\";\n\n/** Programs the /build instructions may invoke; anything else refuses the quote before the wallet sees it. */\nexport const JUPITER_TX_PROGRAMS: ReadonlySet<string> = new Set([JUPITER_PROGRAM, COMPUTE_BUDGET_PROGRAM, SYSTEM_PROGRAM, TOKEN_PROGRAM, TOKEN_2022_PROGRAM, ATA_PROGRAM]);\n\n/** swap2 names Solana `solana:mainnet`; wallet history uses the genesis-hash form. */\nexport const SOLANA_CAIP2 = \"solana:mainnet\";\nexport const SOLANA_CHAINS: ReadonlySet<string> = new Set([SOLANA_CAIP2, \"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp\"]);\n\nconst BASE58 = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\nconst NATIVE = new Set([\"\", \"native\", \"sol\", SYSTEM_PROGRAM, WSOL_MINT.toLowerCase(), \"0x0000000000000000000000000000000000000000\"]);\n\n/** A swap2 token ref on Solana (catalog symbol, mint, or a native marker) → the mint Jupiter quotes; null when unknown. */\nexport function jupiterMint(token: string): string | null {\n if (NATIVE.has(token.toLowerCase()) || /^0x0+$/.test(token)) return WSOL_MINT;\n const bySymbol = ccAsset(SOLANA_CAIP2, token);\n if (bySymbol) return bySymbol.contract ?? WSOL_MINT;\n const byMint = BASE58.test(token) ? ccAssetByToken(SOLANA_CAIP2, token) : undefined;\n if (byMint) return byMint.contract ?? WSOL_MINT;\n return BASE58.test(token) ? token : null;\n}\n\nexport const jupiter = {\n supportsChain: (chain: string) => chain === SOLANA_CAIP2,\n supports: (from: string, to: string) => from === SOLANA_CAIP2 && to === SOLANA_CAIP2,\n};\n","/**\n * Byte-level checks of what `/build` returns. The swap instruction is Jupiter v6's Anchor `route_v2` /\n * `shared_accounts_route_v2` (ExactIn): its arguments carry the input amount, the quoted output, the slippage and the\n * platform-fee split that the program enforces on-chain — so they are read back here and must equal the request\n * before the transaction is assembled. Discriminators = sha256(\"global:<name>\")[0..8] (verified 2026-10-23 against\n * live /build answers).\n */\nimport {base64} from \"@scure/base\";\n\n/** `route_v2(in_amount u64, quoted_out_amount u64, slippage_bps u16, platform_fee_bps u16, positive_slippage_bps u16, route_plan Vec)` */\nexport const ROUTE_V2 = \"bb64facc31c4af14\";\n/** `shared_accounts_route_v2(id u8, …the same arguments…)` */\nexport const SHARED_ACCOUNTS_ROUTE_V2 = \"d19853937cfed8e9\";\n\nexport interface JupiterSwapArgs {\n kind: \"route_v2\" | \"shared_accounts_route_v2\";\n inAmount: bigint;\n quotedOutAmount: bigint;\n slippageBps: number;\n platformFeeBps: number;\n positiveSlippageBps: number;\n}\n\nconst hex = (b: Uint8Array) => Array.from(b, (x) => x.toString(16).padStart(2, \"0\")).join(\"\");\nconst u64 = (d: Uint8Array, o: number) => new DataView(d.buffer, d.byteOffset + o, 8).getBigUint64(0, true);\nconst u16 = (d: Uint8Array, o: number) => new DataView(d.buffer, d.byteOffset + o, 2).getUint16(0, true);\n\nexport const fromBase64 = (s: string): Uint8Array => base64.decode(s);\nexport const toBase64 = (b: Uint8Array): string => base64.encode(b);\n\n/** Decode the swap instruction's fixed arguments; throws for any other instruction (ExactOut, legacy v1 routes…). */\nexport function decodeSwapArgs(data: Uint8Array): JupiterSwapArgs {\n const disc = hex(data.subarray(0, 8));\n const at = disc === ROUTE_V2 ? 8 : disc === SHARED_ACCOUNTS_ROUTE_V2 ? 9 : -1;\n if (at < 0) throw new Error(`unsupported Jupiter instruction ${disc}`);\n if (data.length < at + 22 + 4) throw new Error(\"Jupiter swap instruction is truncated\");\n return {\n kind: at === 8 ? \"route_v2\" : \"shared_accounts_route_v2\",\n inAmount: u64(data, at),\n quotedOutAmount: u64(data, at + 8),\n slippageBps: u16(data, at + 16),\n platformFeeBps: u16(data, at + 18),\n positiveSlippageBps: u16(data, at + 20),\n };\n}\n\n/** The worst output the program accepts: quoted · (10 000 − slippage) / 10 000, rounded down (never above the on-chain check). */\nexport function minOutOf(quotedOut: bigint, slippageBps: number): bigint {\n return (quotedOut * BigInt(10_000 - slippageBps)) / 10_000n;\n}\n\n/** ComputeBudget instructions: 2 = SetComputeUnitLimit(u32), 3 = SetComputeUnitPrice(u64 micro-lamports). */\nexport function decodeComputeBudget(data: Uint8Array): {limit?: number; price?: bigint} {\n if (data[0] === 2 && data.length === 5) return {limit: new DataView(data.buffer, data.byteOffset + 1, 4).getUint32(0, true)};\n if (data[0] === 3 && data.length === 9) return {price: u64(data, 1)};\n throw new Error(`unexpected compute-budget instruction ${data[0]}`);\n}\n\nexport function setComputeUnitLimit(units: number): Uint8Array {\n const d = new Uint8Array(5);\n d[0] = 2;\n new DataView(d.buffer).setUint32(1, units, true);\n return d;\n}\n\nexport function setComputeUnitPrice(microLamports: bigint): Uint8Array {\n const d = new Uint8Array(9);\n d[0] = 3;\n new DataView(d.buffer).setBigUint64(1, microLamports, true);\n return d;\n}\n","/**\n * Assemble the v0 transaction from `/build` instructions: our compute budget (limit + capped price), Jupiter's setup,\n * swap, cleanup and other instructions, compressed with the lookup tables the response names, fee payer = the taker,\n * lifetime = the blockhash Jupiter fetched. Signatures stay empty; the account signs after its own guard.\n */\nimport {\n AccountRole, address, appendTransactionMessageInstructions, compileTransaction, compressTransactionMessageUsingAddressLookupTables,\n createTransactionMessage, getBase58Decoder, getBase64EncodedWireTransaction, pipe, setTransactionMessageFeePayer,\n setTransactionMessageLifetimeUsingBlockhash, type Address, type Blockhash, type Instruction,\n} from \"@solana/kit\";\nimport {COMPUTE_BUDGET_PROGRAM} from \"./config.js\";\nimport {fromBase64, setComputeUnitLimit, setComputeUnitPrice} from \"./codec.js\";\n\nexport interface JupiterInstruction {\n programId: string;\n accounts: {pubkey: string; isSigner: boolean; isWritable: boolean}[];\n data: string;\n}\n\nexport interface AssembleInput {\n taker: string;\n /** setup → swap → cleanup → other, in that order; compute-budget instructions are ours and come first. */\n instructions: JupiterInstruction[];\n computeUnitLimit: number;\n computeUnitPrice: bigint;\n blockhash: Uint8Array | string;\n lastValidBlockHeight: number | bigint;\n addressesByLookupTableAddress: Record<string, string[]> | null | undefined;\n}\n\nconst role = (a: {isSigner: boolean; isWritable: boolean}): AccountRole =>\n a.isSigner ? (a.isWritable ? AccountRole.WRITABLE_SIGNER : AccountRole.READONLY_SIGNER) : a.isWritable ? AccountRole.WRITABLE : AccountRole.READONLY;\n\nconst toInstruction = (ix: JupiterInstruction): Instruction => ({\n programAddress: address(ix.programId),\n accounts: ix.accounts.map((a) => ({address: address(a.pubkey), role: role(a)})),\n data: fromBase64(ix.data),\n});\n\n/** The unsigned transaction as base64 wire bytes (what `TxRequest.serializedTx` carries). */\nexport function assembleTransaction(input: AssembleInput): string {\n const budget: Instruction[] = [\n {programAddress: address(COMPUTE_BUDGET_PROGRAM), data: setComputeUnitLimit(input.computeUnitLimit)},\n {programAddress: address(COMPUTE_BUDGET_PROGRAM), data: setComputeUnitPrice(input.computeUnitPrice)},\n ];\n const blockhash = (typeof input.blockhash === \"string\" ? input.blockhash : getBase58Decoder().decode(input.blockhash)) as Blockhash;\n const tables: Record<Address, Address[]> = {};\n for (const [table, list] of Object.entries(input.addressesByLookupTableAddress ?? {})) tables[address(table)] = list.map((a) => address(a));\n const message = pipe(\n createTransactionMessage({version: 0}),\n (m) => setTransactionMessageFeePayer(address(input.taker), m),\n (m) => setTransactionMessageLifetimeUsingBlockhash({blockhash, lastValidBlockHeight: BigInt(input.lastValidBlockHeight)}, m),\n (m) => appendTransactionMessageInstructions([...budget, ...input.instructions.map(toInstruction)], m),\n (m) => (Object.keys(tables).length ? compressTransactionMessageUsingAddressLookupTables(m, tables) : m),\n );\n return getBase64EncodedWireTransaction(compileTransaction(message));\n}\n","/**\n * Activity recognition for Jupiter swaps. Solana history (wallet-solana) names the first non-plumbing program a\n * transaction runs as `call.to`: a swap sent to Jupiter v6 directly (this module's /build transactions, jup.ag) has it\n * there. A route that only passes through Jupiter inside another program (an aggregator or bridge CPI-ing into it) names\n * that program instead and is left to its module. The owner must both give and receive an asset: a leg that only sends\n * (a bridge's source leg with a Jupiter pre-swap) is not called a swap.\n */\nimport type {ActivityItem, ChainTx, DescribeActivityContext} from \"@anywalletkit/core\";\nimport {describeSwapLike} from \"@anywalletkit/protocol-swap2-core/activity\";\nimport {JUPITER_PROGRAM, SOLANA_CHAINS} from \"./config.js\";\n\nexport const JUPITER_MODULE = \"@anywalletkit/protocol-swap2-jupiter\";\n\nexport function describeJupiterActivity(tx: ChainTx, ctx: DescribeActivityContext): ActivityItem | null {\n if (!SOLANA_CHAINS.has(tx.chain) || tx.call?.to !== JUPITER_PROGRAM) return null;\n const item = describeSwapLike(tx, ctx, {protocol: JUPITER_MODULE, subtitle: \"Jupiter\", kind: \"swap\", counterparty: JUPITER_PROGRAM});\n if (item && tx.status !== \"failed\" && (item.assetsIn.length === 0 || item.assetsOut.length === 0)) return null;\n return item;\n}\n","/**\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","import {SingleProviderSwap2} from \"@anywalletkit/protocol-swap2-core/swap2/single\";\nimport type {Swap2Account, Swap2EngineConfig} from \"@anywalletkit/protocol-swap2-core/swap2/base\";\nimport {jupiter as jupCfg} from \"./config.js\";\nimport {jupiterProvider, type JupiterProviderConfig} from \"./provider.js\";\n\nexport interface JupiterSwap2Config extends Swap2EngineConfig, JupiterProviderConfig {}\n\n/** Standalone Jupiter swap2: same-chain Solana swaps (Metis routing, /build, no Jupiter fee). */\nexport class JupiterSwap2Protocol extends SingleProviderSwap2 {\n protected readonly provider;\n constructor(account: Swap2Account | undefined, config: JupiterSwap2Config) {\n super(account, config);\n this.provider = jupiterProvider(config);\n }\n protected override chainSupported(caip2: string): boolean {\n return jupCfg.supportsChain(caip2);\n }\n protected override pairSupported(fromChain: string, toChain: string): boolean {\n return jupCfg.supports(fromChain, toChain);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,0BAAsC;AAE/B,IAAM,sBAAsB;AAG5B,IAAM,kBAAkB;AACxB,IAAM,yBAAyB;AAC/B,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,qBAAqB;AAC3B,IAAM,cAAc;AAEpB,IAAM,YAAY;AAGlB,IAAM,sBAA2C,oBAAI,IAAI,CAAC,iBAAiB,wBAAwB,gBAAgB,eAAe,oBAAoB,WAAW,CAAC;AAGlK,IAAM,eAAe;AACrB,IAAM,gBAAqC,oBAAI,IAAI,CAAC,cAAc,yCAAyC,CAAC;AAEnH,IAAM,SAAS;AACf,IAAM,SAAS,oBAAI,IAAI,CAAC,IAAI,UAAU,OAAO,gBAAgB,UAAU,YAAY,GAAG,4CAA4C,CAAC;AAG5H,SAAS,YAAY,OAA8B;AACxD,MAAI,OAAO,IAAI,MAAM,YAAY,CAAC,KAAK,SAAS,KAAK,KAAK,EAAG,QAAO;AACpE,QAAM,eAAW,6BAAQ,cAAc,KAAK;AAC5C,MAAI,SAAU,QAAO,SAAS,YAAY;AAC1C,QAAM,SAAS,OAAO,KAAK,KAAK,QAAI,oCAAe,cAAc,KAAK,IAAI;AAC1E,MAAI,OAAQ,QAAO,OAAO,YAAY;AACtC,SAAO,OAAO,KAAK,KAAK,IAAI,QAAQ;AACtC;AAEO,IAAM,UAAU;AAAA,EACrB,eAAe,CAAC,UAAkB,UAAU;AAAA,EAC5C,UAAU,CAAC,MAAc,OAAe,SAAS,g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