@kololabs/router 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ estimateValueInUsd: () => estimateValueInUsd,
24
+ executeSwap: () => executeSwap,
25
+ getQuote: () => getQuote,
26
+ getSwapTransaction: () => getSwapTransaction,
27
+ getTokenPriceInUsd: () => getTokenPriceInUsd
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+ var import_buffer = require("buffer");
31
+ var import_web3 = require("@solana/web3.js");
32
+ var DEFAULT_JUP_API = "https://quote-api.jup.ag/v6";
33
+ var DEFAULT_USDT_MINT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
34
+ async function getQuote(inputMint, amount, options) {
35
+ const outputMint = options?.outputMint ?? DEFAULT_USDT_MINT;
36
+ const slippageBps = options?.slippageBps ?? 50;
37
+ const onlyDirectRoutes = options?.onlyDirectRoutes ?? false;
38
+ const apiBase = options?.apiBase ?? DEFAULT_JUP_API;
39
+ const params = new URLSearchParams({
40
+ inputMint,
41
+ outputMint,
42
+ amount,
43
+ slippageBps: String(slippageBps),
44
+ onlyDirectRoutes: String(onlyDirectRoutes)
45
+ });
46
+ const url = `${apiBase}/quote?${params}`;
47
+ const response = await fetch(url);
48
+ if (!response.ok) {
49
+ const text = await response.text().catch(() => "");
50
+ throw new Error(
51
+ `Jupiter quote error (${response.status}): ${response.statusText}${text ? ` \u2014 ${text}` : ""}`
52
+ );
53
+ }
54
+ return response.json();
55
+ }
56
+ async function getSwapTransaction(quoteResponse, userPublicKey, options) {
57
+ const wrapAndUnwrapSol = options?.wrapAndUnwrapSol ?? true;
58
+ const prioritizationFeeLamports = options?.prioritizationFeeLamports ?? "auto";
59
+ const dynamicComputeUnitLimit = options?.dynamicComputeUnitLimit ?? true;
60
+ const apiBase = options?.apiBase ?? DEFAULT_JUP_API;
61
+ const response = await fetch(`${apiBase}/swap`, {
62
+ method: "POST",
63
+ headers: { "Content-Type": "application/json" },
64
+ body: JSON.stringify({
65
+ quoteResponse,
66
+ userPublicKey,
67
+ wrapAndUnwrapSol,
68
+ dynamicComputeUnitLimit,
69
+ prioritizationFeeLamports
70
+ })
71
+ });
72
+ if (!response.ok) {
73
+ const text = await response.text().catch(() => "");
74
+ throw new Error(
75
+ `Jupiter swap error (${response.status}): ${response.statusText}${text ? ` \u2014 ${text}` : ""}`
76
+ );
77
+ }
78
+ return response.json();
79
+ }
80
+ async function executeSwap(swapResponse, keypair, connection, options) {
81
+ const commitment = options?.commitment ?? "confirmed";
82
+ const txBuffer = import_buffer.Buffer.from(swapResponse.swapTransaction, "base64");
83
+ const transaction = import_web3.VersionedTransaction.deserialize(txBuffer);
84
+ transaction.sign([keypair]);
85
+ const signature = await connection.sendRawTransaction(
86
+ transaction.serialize(),
87
+ { skipPreflight: false, maxRetries: 3 }
88
+ );
89
+ const confirmation = await connection.confirmTransaction(
90
+ signature,
91
+ commitment
92
+ );
93
+ if (confirmation.value.err) {
94
+ throw new Error(`Swap transaction failed: ${confirmation.value.err}`);
95
+ }
96
+ return signature;
97
+ }
98
+ async function getTokenPriceInUsd(mint, options) {
99
+ try {
100
+ const apiBase = options?.apiBase ?? DEFAULT_JUP_API;
101
+ const quoteAmount = 10 ** 6;
102
+ const params = new URLSearchParams({
103
+ inputMint: mint,
104
+ outputMint: DEFAULT_USDT_MINT,
105
+ amount: String(quoteAmount),
106
+ slippageBps: "100",
107
+ onlyDirectRoutes: "true"
108
+ });
109
+ const response = await fetch(`${apiBase}/quote?${params}`);
110
+ if (!response.ok) return null;
111
+ const data = await response.json();
112
+ return parseFloat(data.outAmount) / 1e6;
113
+ } catch {
114
+ return null;
115
+ }
116
+ }
117
+ async function estimateValueInUsd(mint, rawAmount, decimals, options) {
118
+ try {
119
+ const price = await getTokenPriceInUsd(mint, options);
120
+ if (price === null) return null;
121
+ const amount = parseFloat(rawAmount) / 10 ** decimals;
122
+ return amount * price;
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ // Annotate the CommonJS export names for ESM import in node:
128
+ 0 && (module.exports = {
129
+ estimateValueInUsd,
130
+ executeSwap,
131
+ getQuote,
132
+ getSwapTransaction,
133
+ getTokenPriceInUsd
134
+ });
135
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Buffer } from \"buffer\";\nimport { Connection, Keypair, VersionedTransaction } from \"@solana/web3.js\";\n\n// ── Types ──────────────────────────────────────────────────────────\n\n/** Response shape from the Jupiter /quote endpoint. */\nexport interface JupiterQuoteResponse {\n inputMint: string;\n outputMint: string;\n inAmount: string;\n outAmount: string;\n otherAmountThreshold: string;\n priceImpactPct: string;\n routePlan: Array<{\n swapInfo: {\n label: string;\n inputMint: string;\n outputMint: string;\n inAmount: string;\n outAmount: string;\n feeAmount: string;\n feeMint: string;\n };\n }>;\n}\n\n/** Response shape from the Jupiter /swap endpoint. */\nexport interface JupiterSwapResponse {\n swapTransaction: string;\n lastValidBlockHeight: number;\n prioritizationFeeLamports: number;\n computeUnitLimit: number;\n prioritizationType: {\n computeBudget: {\n microLamports: number;\n estimatedMicroLamports: number;\n };\n };\n dynamicSlippageReport: {\n slippageBps: number;\n otherAmount: number;\n simulatedIncurredSlippageBps: number;\n };\n simulationError: string | null;\n}\n\n/** Optional overrides for Jupiter API calls. */\nexport interface JupiterOptions {\n /** Output token mint. Defaults to USDT (Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB). */\n outputMint?: string;\n /** Slippage tolerance in basis points. Default 50 (0.5 %). */\n slippageBps?: number;\n /** Only use direct routes (no multi-hop). Default false. */\n onlyDirectRoutes?: boolean;\n /** Wrap/unwrap native SOL automatically. Default true. */\n wrapAndUnwrapSol?: boolean;\n /** Priority fee in lamports. Use \"auto\" for automatic. */\n prioritizationFeeLamports?: string | number;\n /** Dynamically set compute unit limit. Default true. */\n dynamicComputeUnitLimit?: boolean;\n /** Jupiter API base URL override. */\n apiBase?: string;\n /** Commitment level for transaction confirmation. Default \"confirmed\". */\n commitment?: \"processed\" | \"confirmed\" | \"finalized\";\n}\n\n// ── Defaults ───────────────────────────────────────────────────────\n\nconst DEFAULT_JUP_API = \"https://quote-api.jup.ag/v6\";\nconst DEFAULT_USDT_MINT = \"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB\";\n\n// ── Functions ──────────────────────────────────────────────────────\n\n/**\n * Fetch a swap quote from Jupiter.\n *\n * @param inputMint - The SPL token mint to swap FROM.\n * @param amount - Raw amount in smallest units (e.g. lamports for SOL).\n * @param options - Optional overrides.\n * @returns The Jupiter quote response.\n */\nexport async function getQuote(\n inputMint: string,\n amount: string,\n options?: JupiterOptions\n): Promise<JupiterQuoteResponse> {\n const outputMint = options?.outputMint ?? DEFAULT_USDT_MINT;\n const slippageBps = options?.slippageBps ?? 50;\n const onlyDirectRoutes = options?.onlyDirectRoutes ?? false;\n const apiBase = options?.apiBase ?? DEFAULT_JUP_API;\n\n const params = new URLSearchParams({\n inputMint,\n outputMint,\n amount,\n slippageBps: String(slippageBps),\n onlyDirectRoutes: String(onlyDirectRoutes),\n });\n\n const url = `${apiBase}/quote?${params}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new Error(\n `Jupiter quote error (${response.status}): ${response.statusText}${text ? ` \\u2014 ${text}` : \"\"}`\n );\n }\n\n return response.json() as Promise<JupiterQuoteResponse>;\n}\n\n/**\n * Build a swap transaction using a quote obtained from `getQuote`.\n *\n * @param quoteResponse - The quote to execute.\n * @param userPublicKey - The wallet public key that will sign the tx.\n * @param options - Optional overrides.\n * @returns The swap transaction response containing the serialized tx.\n */\nexport async function getSwapTransaction(\n quoteResponse: JupiterQuoteResponse,\n userPublicKey: string,\n options?: JupiterOptions\n): Promise<JupiterSwapResponse> {\n const wrapAndUnwrapSol = options?.wrapAndUnwrapSol ?? true;\n const prioritizationFeeLamports = options?.prioritizationFeeLamports ?? \"auto\";\n const dynamicComputeUnitLimit = options?.dynamicComputeUnitLimit ?? true;\n const apiBase = options?.apiBase ?? DEFAULT_JUP_API;\n\n const response = await fetch(`${apiBase}/swap`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n quoteResponse,\n userPublicKey,\n wrapAndUnwrapSol,\n dynamicComputeUnitLimit,\n prioritizationFeeLamports,\n }),\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new Error(\n `Jupiter swap error (${response.status}): ${response.statusText}${text ? ` \\u2014 ${text}` : \"\"}`\n );\n }\n\n return response.json() as Promise<JupiterSwapResponse>;\n}\n\n/**\n * Sign, send, and confirm a Jupiter swap transaction on-chain.\n *\n * This is a convenience wrapper that deserializes the swap transaction\n * from `getSwapTransaction`, signs it with the provided keypair, sends\n * it via the RPC connection, and waits for confirmation.\n *\n * @param swapResponse - The swap response from `getSwapTransaction`.\n * @param keypair - The Solana keypair that will sign the transaction.\n * @param connection - A Solana RPC connection.\n * @param options - Optional overrides (commitment level).\n * @returns The confirmed transaction signature (base58).\n */\nexport async function executeSwap(\n swapResponse: JupiterSwapResponse,\n keypair: Keypair,\n connection: Connection,\n options?: Pick<JupiterOptions, \"commitment\">\n): Promise<string> {\n const commitment = options?.commitment ?? \"confirmed\";\n\n // Deserialize the versioned transaction from the base64-encoded wire format\n const txBuffer = Buffer.from(swapResponse.swapTransaction, \"base64\");\n const transaction = VersionedTransaction.deserialize(txBuffer);\n\n // Sign with the user's keypair\n transaction.sign([keypair]);\n\n // Send the signed transaction\n const signature = await connection.sendRawTransaction(\n transaction.serialize(),\n { skipPreflight: false, maxRetries: 3 }\n );\n\n // Wait for confirmation\n const confirmation = await connection.confirmTransaction(\n signature,\n commitment\n );\n\n if (confirmation.value.err) {\n throw new Error(`Swap transaction failed: ${confirmation.value.err}`);\n }\n\n return signature;\n}\n\n/**\n * Get the current USD price of a token by requesting a 1-unit quote.\n *\n * @param mint - The SPL token mint.\n * @param options - Optional overrides.\n * @returns The price in USD, or `null` if unavailable.\n */\nexport async function getTokenPriceInUsd(\n mint: string,\n options?: JupiterOptions\n): Promise<number | null> {\n try {\n const apiBase = options?.apiBase ?? DEFAULT_JUP_API;\n const quoteAmount = 10 ** 6; // 1 USDT unit\n const params = new URLSearchParams({\n inputMint: mint,\n outputMint: DEFAULT_USDT_MINT,\n amount: String(quoteAmount),\n slippageBps: \"100\",\n onlyDirectRoutes: \"true\",\n });\n\n const response = await fetch(`${apiBase}/quote?${params}`);\n if (!response.ok) return null;\n\n const data = (await response.json()) as JupiterQuoteResponse;\n // outAmount is in USDT units (6 decimals)\n return parseFloat(data.outAmount) / 1_000_000;\n } catch {\n return null;\n }\n}\n\n/**\n * Estimate the USD value of a token amount using Jupiter pricing.\n *\n * @param mint - The SPL token mint.\n * @param rawAmount - Raw amount string (includes decimals).\n * @param decimals - Number of decimal places for the token.\n * @param options - Optional overrides.\n * @returns The estimated USD value, or `null` if pricing is unavailable.\n */\nexport async function estimateValueInUsd(\n mint: string,\n rawAmount: string,\n decimals: number,\n options?: JupiterOptions\n): Promise<number | null> {\n try {\n const price = await getTokenPriceInUsd(mint, options);\n if (price === null) return null;\n const amount = parseFloat(rawAmount) / 10 ** decimals;\n return amount * price;\n } catch {\n return null;\n }\n}\n"],"mappings":"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","names":[]}
@@ -0,0 +1,112 @@
1
+ import { Keypair, Connection } from '@solana/web3.js';
2
+
3
+ /** Response shape from the Jupiter /quote endpoint. */
4
+ interface JupiterQuoteResponse {
5
+ inputMint: string;
6
+ outputMint: string;
7
+ inAmount: string;
8
+ outAmount: string;
9
+ otherAmountThreshold: string;
10
+ priceImpactPct: string;
11
+ routePlan: Array<{
12
+ swapInfo: {
13
+ label: string;
14
+ inputMint: string;
15
+ outputMint: string;
16
+ inAmount: string;
17
+ outAmount: string;
18
+ feeAmount: string;
19
+ feeMint: string;
20
+ };
21
+ }>;
22
+ }
23
+ /** Response shape from the Jupiter /swap endpoint. */
24
+ interface JupiterSwapResponse {
25
+ swapTransaction: string;
26
+ lastValidBlockHeight: number;
27
+ prioritizationFeeLamports: number;
28
+ computeUnitLimit: number;
29
+ prioritizationType: {
30
+ computeBudget: {
31
+ microLamports: number;
32
+ estimatedMicroLamports: number;
33
+ };
34
+ };
35
+ dynamicSlippageReport: {
36
+ slippageBps: number;
37
+ otherAmount: number;
38
+ simulatedIncurredSlippageBps: number;
39
+ };
40
+ simulationError: string | null;
41
+ }
42
+ /** Optional overrides for Jupiter API calls. */
43
+ interface JupiterOptions {
44
+ /** Output token mint. Defaults to USDT (Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB). */
45
+ outputMint?: string;
46
+ /** Slippage tolerance in basis points. Default 50 (0.5 %). */
47
+ slippageBps?: number;
48
+ /** Only use direct routes (no multi-hop). Default false. */
49
+ onlyDirectRoutes?: boolean;
50
+ /** Wrap/unwrap native SOL automatically. Default true. */
51
+ wrapAndUnwrapSol?: boolean;
52
+ /** Priority fee in lamports. Use "auto" for automatic. */
53
+ prioritizationFeeLamports?: string | number;
54
+ /** Dynamically set compute unit limit. Default true. */
55
+ dynamicComputeUnitLimit?: boolean;
56
+ /** Jupiter API base URL override. */
57
+ apiBase?: string;
58
+ /** Commitment level for transaction confirmation. Default "confirmed". */
59
+ commitment?: "processed" | "confirmed" | "finalized";
60
+ }
61
+ /**
62
+ * Fetch a swap quote from Jupiter.
63
+ *
64
+ * @param inputMint - The SPL token mint to swap FROM.
65
+ * @param amount - Raw amount in smallest units (e.g. lamports for SOL).
66
+ * @param options - Optional overrides.
67
+ * @returns The Jupiter quote response.
68
+ */
69
+ declare function getQuote(inputMint: string, amount: string, options?: JupiterOptions): Promise<JupiterQuoteResponse>;
70
+ /**
71
+ * Build a swap transaction using a quote obtained from `getQuote`.
72
+ *
73
+ * @param quoteResponse - The quote to execute.
74
+ * @param userPublicKey - The wallet public key that will sign the tx.
75
+ * @param options - Optional overrides.
76
+ * @returns The swap transaction response containing the serialized tx.
77
+ */
78
+ declare function getSwapTransaction(quoteResponse: JupiterQuoteResponse, userPublicKey: string, options?: JupiterOptions): Promise<JupiterSwapResponse>;
79
+ /**
80
+ * Sign, send, and confirm a Jupiter swap transaction on-chain.
81
+ *
82
+ * This is a convenience wrapper that deserializes the swap transaction
83
+ * from `getSwapTransaction`, signs it with the provided keypair, sends
84
+ * it via the RPC connection, and waits for confirmation.
85
+ *
86
+ * @param swapResponse - The swap response from `getSwapTransaction`.
87
+ * @param keypair - The Solana keypair that will sign the transaction.
88
+ * @param connection - A Solana RPC connection.
89
+ * @param options - Optional overrides (commitment level).
90
+ * @returns The confirmed transaction signature (base58).
91
+ */
92
+ declare function executeSwap(swapResponse: JupiterSwapResponse, keypair: Keypair, connection: Connection, options?: Pick<JupiterOptions, "commitment">): Promise<string>;
93
+ /**
94
+ * Get the current USD price of a token by requesting a 1-unit quote.
95
+ *
96
+ * @param mint - The SPL token mint.
97
+ * @param options - Optional overrides.
98
+ * @returns The price in USD, or `null` if unavailable.
99
+ */
100
+ declare function getTokenPriceInUsd(mint: string, options?: JupiterOptions): Promise<number | null>;
101
+ /**
102
+ * Estimate the USD value of a token amount using Jupiter pricing.
103
+ *
104
+ * @param mint - The SPL token mint.
105
+ * @param rawAmount - Raw amount string (includes decimals).
106
+ * @param decimals - Number of decimal places for the token.
107
+ * @param options - Optional overrides.
108
+ * @returns The estimated USD value, or `null` if pricing is unavailable.
109
+ */
110
+ declare function estimateValueInUsd(mint: string, rawAmount: string, decimals: number, options?: JupiterOptions): Promise<number | null>;
111
+
112
+ export { type JupiterOptions, type JupiterQuoteResponse, type JupiterSwapResponse, estimateValueInUsd, executeSwap, getQuote, getSwapTransaction, getTokenPriceInUsd };
@@ -0,0 +1,112 @@
1
+ import { Keypair, Connection } from '@solana/web3.js';
2
+
3
+ /** Response shape from the Jupiter /quote endpoint. */
4
+ interface JupiterQuoteResponse {
5
+ inputMint: string;
6
+ outputMint: string;
7
+ inAmount: string;
8
+ outAmount: string;
9
+ otherAmountThreshold: string;
10
+ priceImpactPct: string;
11
+ routePlan: Array<{
12
+ swapInfo: {
13
+ label: string;
14
+ inputMint: string;
15
+ outputMint: string;
16
+ inAmount: string;
17
+ outAmount: string;
18
+ feeAmount: string;
19
+ feeMint: string;
20
+ };
21
+ }>;
22
+ }
23
+ /** Response shape from the Jupiter /swap endpoint. */
24
+ interface JupiterSwapResponse {
25
+ swapTransaction: string;
26
+ lastValidBlockHeight: number;
27
+ prioritizationFeeLamports: number;
28
+ computeUnitLimit: number;
29
+ prioritizationType: {
30
+ computeBudget: {
31
+ microLamports: number;
32
+ estimatedMicroLamports: number;
33
+ };
34
+ };
35
+ dynamicSlippageReport: {
36
+ slippageBps: number;
37
+ otherAmount: number;
38
+ simulatedIncurredSlippageBps: number;
39
+ };
40
+ simulationError: string | null;
41
+ }
42
+ /** Optional overrides for Jupiter API calls. */
43
+ interface JupiterOptions {
44
+ /** Output token mint. Defaults to USDT (Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB). */
45
+ outputMint?: string;
46
+ /** Slippage tolerance in basis points. Default 50 (0.5 %). */
47
+ slippageBps?: number;
48
+ /** Only use direct routes (no multi-hop). Default false. */
49
+ onlyDirectRoutes?: boolean;
50
+ /** Wrap/unwrap native SOL automatically. Default true. */
51
+ wrapAndUnwrapSol?: boolean;
52
+ /** Priority fee in lamports. Use "auto" for automatic. */
53
+ prioritizationFeeLamports?: string | number;
54
+ /** Dynamically set compute unit limit. Default true. */
55
+ dynamicComputeUnitLimit?: boolean;
56
+ /** Jupiter API base URL override. */
57
+ apiBase?: string;
58
+ /** Commitment level for transaction confirmation. Default "confirmed". */
59
+ commitment?: "processed" | "confirmed" | "finalized";
60
+ }
61
+ /**
62
+ * Fetch a swap quote from Jupiter.
63
+ *
64
+ * @param inputMint - The SPL token mint to swap FROM.
65
+ * @param amount - Raw amount in smallest units (e.g. lamports for SOL).
66
+ * @param options - Optional overrides.
67
+ * @returns The Jupiter quote response.
68
+ */
69
+ declare function getQuote(inputMint: string, amount: string, options?: JupiterOptions): Promise<JupiterQuoteResponse>;
70
+ /**
71
+ * Build a swap transaction using a quote obtained from `getQuote`.
72
+ *
73
+ * @param quoteResponse - The quote to execute.
74
+ * @param userPublicKey - The wallet public key that will sign the tx.
75
+ * @param options - Optional overrides.
76
+ * @returns The swap transaction response containing the serialized tx.
77
+ */
78
+ declare function getSwapTransaction(quoteResponse: JupiterQuoteResponse, userPublicKey: string, options?: JupiterOptions): Promise<JupiterSwapResponse>;
79
+ /**
80
+ * Sign, send, and confirm a Jupiter swap transaction on-chain.
81
+ *
82
+ * This is a convenience wrapper that deserializes the swap transaction
83
+ * from `getSwapTransaction`, signs it with the provided keypair, sends
84
+ * it via the RPC connection, and waits for confirmation.
85
+ *
86
+ * @param swapResponse - The swap response from `getSwapTransaction`.
87
+ * @param keypair - The Solana keypair that will sign the transaction.
88
+ * @param connection - A Solana RPC connection.
89
+ * @param options - Optional overrides (commitment level).
90
+ * @returns The confirmed transaction signature (base58).
91
+ */
92
+ declare function executeSwap(swapResponse: JupiterSwapResponse, keypair: Keypair, connection: Connection, options?: Pick<JupiterOptions, "commitment">): Promise<string>;
93
+ /**
94
+ * Get the current USD price of a token by requesting a 1-unit quote.
95
+ *
96
+ * @param mint - The SPL token mint.
97
+ * @param options - Optional overrides.
98
+ * @returns The price in USD, or `null` if unavailable.
99
+ */
100
+ declare function getTokenPriceInUsd(mint: string, options?: JupiterOptions): Promise<number | null>;
101
+ /**
102
+ * Estimate the USD value of a token amount using Jupiter pricing.
103
+ *
104
+ * @param mint - The SPL token mint.
105
+ * @param rawAmount - Raw amount string (includes decimals).
106
+ * @param decimals - Number of decimal places for the token.
107
+ * @param options - Optional overrides.
108
+ * @returns The estimated USD value, or `null` if pricing is unavailable.
109
+ */
110
+ declare function estimateValueInUsd(mint: string, rawAmount: string, decimals: number, options?: JupiterOptions): Promise<number | null>;
111
+
112
+ export { type JupiterOptions, type JupiterQuoteResponse, type JupiterSwapResponse, estimateValueInUsd, executeSwap, getQuote, getSwapTransaction, getTokenPriceInUsd };
package/dist/index.js ADDED
@@ -0,0 +1,106 @@
1
+ // src/index.ts
2
+ import { Buffer } from "buffer";
3
+ import { VersionedTransaction } from "@solana/web3.js";
4
+ var DEFAULT_JUP_API = "https://quote-api.jup.ag/v6";
5
+ var DEFAULT_USDT_MINT = "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";
6
+ async function getQuote(inputMint, amount, options) {
7
+ const outputMint = options?.outputMint ?? DEFAULT_USDT_MINT;
8
+ const slippageBps = options?.slippageBps ?? 50;
9
+ const onlyDirectRoutes = options?.onlyDirectRoutes ?? false;
10
+ const apiBase = options?.apiBase ?? DEFAULT_JUP_API;
11
+ const params = new URLSearchParams({
12
+ inputMint,
13
+ outputMint,
14
+ amount,
15
+ slippageBps: String(slippageBps),
16
+ onlyDirectRoutes: String(onlyDirectRoutes)
17
+ });
18
+ const url = `${apiBase}/quote?${params}`;
19
+ const response = await fetch(url);
20
+ if (!response.ok) {
21
+ const text = await response.text().catch(() => "");
22
+ throw new Error(
23
+ `Jupiter quote error (${response.status}): ${response.statusText}${text ? ` \u2014 ${text}` : ""}`
24
+ );
25
+ }
26
+ return response.json();
27
+ }
28
+ async function getSwapTransaction(quoteResponse, userPublicKey, options) {
29
+ const wrapAndUnwrapSol = options?.wrapAndUnwrapSol ?? true;
30
+ const prioritizationFeeLamports = options?.prioritizationFeeLamports ?? "auto";
31
+ const dynamicComputeUnitLimit = options?.dynamicComputeUnitLimit ?? true;
32
+ const apiBase = options?.apiBase ?? DEFAULT_JUP_API;
33
+ const response = await fetch(`${apiBase}/swap`, {
34
+ method: "POST",
35
+ headers: { "Content-Type": "application/json" },
36
+ body: JSON.stringify({
37
+ quoteResponse,
38
+ userPublicKey,
39
+ wrapAndUnwrapSol,
40
+ dynamicComputeUnitLimit,
41
+ prioritizationFeeLamports
42
+ })
43
+ });
44
+ if (!response.ok) {
45
+ const text = await response.text().catch(() => "");
46
+ throw new Error(
47
+ `Jupiter swap error (${response.status}): ${response.statusText}${text ? ` \u2014 ${text}` : ""}`
48
+ );
49
+ }
50
+ return response.json();
51
+ }
52
+ async function executeSwap(swapResponse, keypair, connection, options) {
53
+ const commitment = options?.commitment ?? "confirmed";
54
+ const txBuffer = Buffer.from(swapResponse.swapTransaction, "base64");
55
+ const transaction = VersionedTransaction.deserialize(txBuffer);
56
+ transaction.sign([keypair]);
57
+ const signature = await connection.sendRawTransaction(
58
+ transaction.serialize(),
59
+ { skipPreflight: false, maxRetries: 3 }
60
+ );
61
+ const confirmation = await connection.confirmTransaction(
62
+ signature,
63
+ commitment
64
+ );
65
+ if (confirmation.value.err) {
66
+ throw new Error(`Swap transaction failed: ${confirmation.value.err}`);
67
+ }
68
+ return signature;
69
+ }
70
+ async function getTokenPriceInUsd(mint, options) {
71
+ try {
72
+ const apiBase = options?.apiBase ?? DEFAULT_JUP_API;
73
+ const quoteAmount = 10 ** 6;
74
+ const params = new URLSearchParams({
75
+ inputMint: mint,
76
+ outputMint: DEFAULT_USDT_MINT,
77
+ amount: String(quoteAmount),
78
+ slippageBps: "100",
79
+ onlyDirectRoutes: "true"
80
+ });
81
+ const response = await fetch(`${apiBase}/quote?${params}`);
82
+ if (!response.ok) return null;
83
+ const data = await response.json();
84
+ return parseFloat(data.outAmount) / 1e6;
85
+ } catch {
86
+ return null;
87
+ }
88
+ }
89
+ async function estimateValueInUsd(mint, rawAmount, decimals, options) {
90
+ try {
91
+ const price = await getTokenPriceInUsd(mint, options);
92
+ if (price === null) return null;
93
+ const amount = parseFloat(rawAmount) / 10 ** decimals;
94
+ return amount * price;
95
+ } catch {
96
+ return null;
97
+ }
98
+ }
99
+ export {
100
+ estimateValueInUsd,
101
+ executeSwap,
102
+ getQuote,
103
+ getSwapTransaction,
104
+ getTokenPriceInUsd
105
+ };
106
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Buffer } from \"buffer\";\nimport { Connection, Keypair, VersionedTransaction } from \"@solana/web3.js\";\n\n// ── Types ──────────────────────────────────────────────────────────\n\n/** Response shape from the Jupiter /quote endpoint. */\nexport interface JupiterQuoteResponse {\n inputMint: string;\n outputMint: string;\n inAmount: string;\n outAmount: string;\n otherAmountThreshold: string;\n priceImpactPct: string;\n routePlan: Array<{\n swapInfo: {\n label: string;\n inputMint: string;\n outputMint: string;\n inAmount: string;\n outAmount: string;\n feeAmount: string;\n feeMint: string;\n };\n }>;\n}\n\n/** Response shape from the Jupiter /swap endpoint. */\nexport interface JupiterSwapResponse {\n swapTransaction: string;\n lastValidBlockHeight: number;\n prioritizationFeeLamports: number;\n computeUnitLimit: number;\n prioritizationType: {\n computeBudget: {\n microLamports: number;\n estimatedMicroLamports: number;\n };\n };\n dynamicSlippageReport: {\n slippageBps: number;\n otherAmount: number;\n simulatedIncurredSlippageBps: number;\n };\n simulationError: string | null;\n}\n\n/** Optional overrides for Jupiter API calls. */\nexport interface JupiterOptions {\n /** Output token mint. Defaults to USDT (Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB). */\n outputMint?: string;\n /** Slippage tolerance in basis points. Default 50 (0.5 %). */\n slippageBps?: number;\n /** Only use direct routes (no multi-hop). Default false. */\n onlyDirectRoutes?: boolean;\n /** Wrap/unwrap native SOL automatically. Default true. */\n wrapAndUnwrapSol?: boolean;\n /** Priority fee in lamports. Use \"auto\" for automatic. */\n prioritizationFeeLamports?: string | number;\n /** Dynamically set compute unit limit. Default true. */\n dynamicComputeUnitLimit?: boolean;\n /** Jupiter API base URL override. */\n apiBase?: string;\n /** Commitment level for transaction confirmation. Default \"confirmed\". */\n commitment?: \"processed\" | \"confirmed\" | \"finalized\";\n}\n\n// ── Defaults ───────────────────────────────────────────────────────\n\nconst DEFAULT_JUP_API = \"https://quote-api.jup.ag/v6\";\nconst DEFAULT_USDT_MINT = \"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB\";\n\n// ── Functions ──────────────────────────────────────────────────────\n\n/**\n * Fetch a swap quote from Jupiter.\n *\n * @param inputMint - The SPL token mint to swap FROM.\n * @param amount - Raw amount in smallest units (e.g. lamports for SOL).\n * @param options - Optional overrides.\n * @returns The Jupiter quote response.\n */\nexport async function getQuote(\n inputMint: string,\n amount: string,\n options?: JupiterOptions\n): Promise<JupiterQuoteResponse> {\n const outputMint = options?.outputMint ?? DEFAULT_USDT_MINT;\n const slippageBps = options?.slippageBps ?? 50;\n const onlyDirectRoutes = options?.onlyDirectRoutes ?? false;\n const apiBase = options?.apiBase ?? DEFAULT_JUP_API;\n\n const params = new URLSearchParams({\n inputMint,\n outputMint,\n amount,\n slippageBps: String(slippageBps),\n onlyDirectRoutes: String(onlyDirectRoutes),\n });\n\n const url = `${apiBase}/quote?${params}`;\n const response = await fetch(url);\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new Error(\n `Jupiter quote error (${response.status}): ${response.statusText}${text ? ` \\u2014 ${text}` : \"\"}`\n );\n }\n\n return response.json() as Promise<JupiterQuoteResponse>;\n}\n\n/**\n * Build a swap transaction using a quote obtained from `getQuote`.\n *\n * @param quoteResponse - The quote to execute.\n * @param userPublicKey - The wallet public key that will sign the tx.\n * @param options - Optional overrides.\n * @returns The swap transaction response containing the serialized tx.\n */\nexport async function getSwapTransaction(\n quoteResponse: JupiterQuoteResponse,\n userPublicKey: string,\n options?: JupiterOptions\n): Promise<JupiterSwapResponse> {\n const wrapAndUnwrapSol = options?.wrapAndUnwrapSol ?? true;\n const prioritizationFeeLamports = options?.prioritizationFeeLamports ?? \"auto\";\n const dynamicComputeUnitLimit = options?.dynamicComputeUnitLimit ?? true;\n const apiBase = options?.apiBase ?? DEFAULT_JUP_API;\n\n const response = await fetch(`${apiBase}/swap`, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n body: JSON.stringify({\n quoteResponse,\n userPublicKey,\n wrapAndUnwrapSol,\n dynamicComputeUnitLimit,\n prioritizationFeeLamports,\n }),\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new Error(\n `Jupiter swap error (${response.status}): ${response.statusText}${text ? ` \\u2014 ${text}` : \"\"}`\n );\n }\n\n return response.json() as Promise<JupiterSwapResponse>;\n}\n\n/**\n * Sign, send, and confirm a Jupiter swap transaction on-chain.\n *\n * This is a convenience wrapper that deserializes the swap transaction\n * from `getSwapTransaction`, signs it with the provided keypair, sends\n * it via the RPC connection, and waits for confirmation.\n *\n * @param swapResponse - The swap response from `getSwapTransaction`.\n * @param keypair - The Solana keypair that will sign the transaction.\n * @param connection - A Solana RPC connection.\n * @param options - Optional overrides (commitment level).\n * @returns The confirmed transaction signature (base58).\n */\nexport async function executeSwap(\n swapResponse: JupiterSwapResponse,\n keypair: Keypair,\n connection: Connection,\n options?: Pick<JupiterOptions, \"commitment\">\n): Promise<string> {\n const commitment = options?.commitment ?? \"confirmed\";\n\n // Deserialize the versioned transaction from the base64-encoded wire format\n const txBuffer = Buffer.from(swapResponse.swapTransaction, \"base64\");\n const transaction = VersionedTransaction.deserialize(txBuffer);\n\n // Sign with the user's keypair\n transaction.sign([keypair]);\n\n // Send the signed transaction\n const signature = await connection.sendRawTransaction(\n transaction.serialize(),\n { skipPreflight: false, maxRetries: 3 }\n );\n\n // Wait for confirmation\n const confirmation = await connection.confirmTransaction(\n signature,\n commitment\n );\n\n if (confirmation.value.err) {\n throw new Error(`Swap transaction failed: ${confirmation.value.err}`);\n }\n\n return signature;\n}\n\n/**\n * Get the current USD price of a token by requesting a 1-unit quote.\n *\n * @param mint - The SPL token mint.\n * @param options - Optional overrides.\n * @returns The price in USD, or `null` if unavailable.\n */\nexport async function getTokenPriceInUsd(\n mint: string,\n options?: JupiterOptions\n): Promise<number | null> {\n try {\n const apiBase = options?.apiBase ?? DEFAULT_JUP_API;\n const quoteAmount = 10 ** 6; // 1 USDT unit\n const params = new URLSearchParams({\n inputMint: mint,\n outputMint: DEFAULT_USDT_MINT,\n amount: String(quoteAmount),\n slippageBps: \"100\",\n onlyDirectRoutes: \"true\",\n });\n\n const response = await fetch(`${apiBase}/quote?${params}`);\n if (!response.ok) return null;\n\n const data = (await response.json()) as JupiterQuoteResponse;\n // outAmount is in USDT units (6 decimals)\n return parseFloat(data.outAmount) / 1_000_000;\n } catch {\n return null;\n }\n}\n\n/**\n * Estimate the USD value of a token amount using Jupiter pricing.\n *\n * @param mint - The SPL token mint.\n * @param rawAmount - Raw amount string (includes decimals).\n * @param decimals - Number of decimal places for the token.\n * @param options - Optional overrides.\n * @returns The estimated USD value, or `null` if pricing is unavailable.\n */\nexport async function estimateValueInUsd(\n mint: string,\n rawAmount: string,\n decimals: number,\n options?: JupiterOptions\n): Promise<number | null> {\n try {\n const price = await getTokenPriceInUsd(mint, options);\n if (price === null) return null;\n const amount = parseFloat(rawAmount) / 10 ** decimals;\n return amount * price;\n } catch {\n return null;\n }\n}\n"],"mappings":"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","names":[]}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@kololabs/router",
3
+ "version": "1.0.0",
4
+ "private": false,
5
+ "description": "Jupiter swap routing for the Kolo SPL Auto-Convert SDK",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsup",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest",
24
+ "lint": "tsc --noEmit"
25
+ },
26
+ "peerDependencies": {
27
+ "@solana/web3.js": ">=1.98.0"
28
+ },
29
+ "devDependencies": {
30
+ "@solana/web3.js": "^1.98.0",
31
+ "@types/node": "^22.0.0",
32
+ "tsup": "^8.4.0",
33
+ "typescript": "^5.7.0",
34
+ "vitest": "^3.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/poolparty21/SPL-Auto-Convert-SDK.git",
42
+ "directory": "packages/router"
43
+ }
44
+ }