@0dotxyz/p0-ts-sdk 2.2.7 → 2.3.0-alpha.1
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 +3955 -2909
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +371 -2
- package/dist/index.d.ts +371 -2
- package/dist/index.js +2892 -1867
- package/dist/index.js.map +1 -1
- package/dist/jupiter.cjs +13 -4
- package/dist/jupiter.cjs.map +1 -1
- package/dist/jupiter.d.cts +47 -1
- package/dist/jupiter.d.ts +47 -1
- package/dist/jupiter.js +13 -4
- package/dist/jupiter.js.map +1 -1
- package/dist/merge.types-BS8s5Ck0.d.cts +137 -0
- package/dist/merge.types-BS8s5Ck0.d.ts +137 -0
- package/dist/vendor.cjs +7507 -1
- package/dist/vendor.cjs.map +1 -1
- package/dist/vendor.d.cts +759 -4
- package/dist/vendor.d.ts +759 -4
- package/dist/vendor.js +7487 -3
- package/dist/vendor.js.map +1 -1
- package/package.json +4 -1
- package/dist/index-BDDVBMdM.d.cts +0 -48
- package/dist/index-BDDVBMdM.d.ts +0 -48
package/dist/jupiter.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/vendor/jupiter/client.ts
|
|
4
4
|
var DEFAULT_BASE_PATH = "https://lite-api.jup.ag/swap/v1";
|
|
5
|
+
var DEFAULT_ROUTER_BASE_PATH = "https://api.jup.ag/swap/v2";
|
|
5
6
|
var JupiterApiError = class _JupiterApiError extends Error {
|
|
6
7
|
status;
|
|
7
8
|
body;
|
|
@@ -27,10 +28,11 @@ function buildQuoteSearchParams(request) {
|
|
|
27
28
|
}
|
|
28
29
|
function createJupiterClient(config = {}) {
|
|
29
30
|
const basePath = (config.basePath ?? DEFAULT_BASE_PATH).replace(/\/+$/, "");
|
|
31
|
+
const routerBasePath = (config.routerBasePath ?? DEFAULT_ROUTER_BASE_PATH).replace(/\/+$/, "");
|
|
30
32
|
const baseHeaders = { ...config.headers };
|
|
31
33
|
if (config.apiKey) baseHeaders["x-api-key"] = config.apiKey;
|
|
32
|
-
const
|
|
33
|
-
const response = await fetch(`${
|
|
34
|
+
const requestAt = async (base, path, init) => {
|
|
35
|
+
const response = await fetch(`${base}${path}`, init);
|
|
34
36
|
if (!response.ok) {
|
|
35
37
|
const body = await response.text().catch(() => "");
|
|
36
38
|
throw new JupiterApiError(response.status, body);
|
|
@@ -40,17 +42,24 @@ function createJupiterClient(config = {}) {
|
|
|
40
42
|
return {
|
|
41
43
|
quoteGet(quoteRequest) {
|
|
42
44
|
const search = buildQuoteSearchParams(quoteRequest);
|
|
43
|
-
return
|
|
45
|
+
return requestAt(basePath, `/quote?${search.toString()}`, {
|
|
44
46
|
method: "GET",
|
|
45
47
|
headers: baseHeaders
|
|
46
48
|
});
|
|
47
49
|
},
|
|
48
50
|
swapInstructionsPost({ swapRequest }) {
|
|
49
|
-
return
|
|
51
|
+
return requestAt(basePath, `/swap-instructions`, {
|
|
50
52
|
method: "POST",
|
|
51
53
|
headers: { ...baseHeaders, "content-type": "application/json" },
|
|
52
54
|
body: JSON.stringify(swapRequest)
|
|
53
55
|
});
|
|
56
|
+
},
|
|
57
|
+
buildGet(buildRequest) {
|
|
58
|
+
const search = buildQuoteSearchParams(buildRequest);
|
|
59
|
+
return requestAt(routerBasePath, `/build?${search.toString()}`, {
|
|
60
|
+
method: "GET",
|
|
61
|
+
headers: baseHeaders
|
|
62
|
+
});
|
|
54
63
|
}
|
|
55
64
|
};
|
|
56
65
|
}
|
package/dist/jupiter.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vendor/jupiter/client.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/vendor/jupiter/client.ts"],"names":[],"mappings":";;;AAmBA,IAAM,iBAAA,GAAoB,iCAAA;AAI1B,IAAM,wBAAA,GAA2B,4BAAA;AAa1B,IAAM,eAAA,GAAN,MAAM,gBA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,MAAA,GAAS,uBAAuB,YAAY,CAAA;AAClD,MAAA,OAAO,UAAyB,cAAA,EAAgB,CAAA,OAAA,EAAU,MAAA,CAAO,QAAA,EAAU,CAAA,CAAA,EAAI;AAAA,QAC7E,MAAA,EAAQ,KAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACV,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"jupiter.cjs","sourcesContent":["// Minimal Jupiter Swap API client — replaces the runtime of @jup-ag/api.\n//\n// The generated @jup-ag/api client hardcodes the legacy\n// `https://quote-api.jup.ag/v6` base URL and ignores a caller-supplied\n// basePath, so we reimplement the two endpoints the SDK uses against Jupiter's\n// current Swap API (https://dev.jup.ag/docs/swap-api). Only `GET /quote` and\n// `POST /swap-instructions` are implemented.\n\nimport type {\n BuildGetRequest,\n BuildResponse,\n QuoteGetRequest,\n QuoteResponse,\n SwapInstructionsResponse,\n SwapRequest,\n} from \"./types\";\n\n// Free tier. Callers with an API key typically override this with the paid\n// base `https://api.jup.ag/swap/v1` via `basePath`.\nconst DEFAULT_BASE_PATH = \"https://lite-api.jup.ag/swap/v1\";\n\n// Router base for the `/build` endpoint (paid). The Router lives under\n// `/swap/v2`, distinct from the Metis `/swap/v1` base above.\nconst DEFAULT_ROUTER_BASE_PATH = \"https://api.jup.ag/swap/v2\";\n\nexport interface JupiterClientConfig {\n /** Override the API base URL (e.g. the paid `https://api.jup.ag/swap/v1`). */\n basePath?: string;\n /** Override the Router base URL for `/build` (default `.../swap/v2`). */\n routerBasePath?: string;\n /** API key, sent as the `x-api-key` header. */\n apiKey?: string;\n /** Extra headers applied to every request. */\n headers?: Record<string, string>;\n}\n\nexport class JupiterApiError extends Error {\n status: number;\n body: string;\n\n constructor(status: number, body: string) {\n super(`Jupiter API request failed with status ${status}: ${body}`);\n this.name = \"JupiterApiError\";\n Object.setPrototypeOf(this, JupiterApiError.prototype);\n this.status = status;\n this.body = body;\n }\n}\n\nfunction buildQuoteSearchParams(request: object): URLSearchParams {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(request)) {\n if (value === undefined || value === null) continue;\n // Arrays (dexes/excludeDexes) are comma-separated per the Jupiter spec.\n if (Array.isArray(value)) {\n if (value.length > 0) params.append(key, value.join(\",\"));\n continue;\n }\n params.append(key, String(value));\n }\n return params;\n}\n\nexport interface JupiterClient {\n quoteGet(request: QuoteGetRequest): Promise<QuoteResponse>;\n swapInstructionsPost(request: { swapRequest: SwapRequest }): Promise<SwapInstructionsResponse>;\n /** Router: one-call quote + raw instructions. ExactIn only. */\n buildGet(request: BuildGetRequest): Promise<BuildResponse>;\n}\n\nexport function createJupiterClient(config: JupiterClientConfig = {}): JupiterClient {\n const basePath = (config.basePath ?? DEFAULT_BASE_PATH).replace(/\\/+$/, \"\");\n const routerBasePath = (config.routerBasePath ?? DEFAULT_ROUTER_BASE_PATH).replace(/\\/+$/, \"\");\n const baseHeaders: Record<string, string> = { ...config.headers };\n if (config.apiKey) baseHeaders[\"x-api-key\"] = config.apiKey;\n\n const requestAt = async <T>(base: string, path: string, init: RequestInit): Promise<T> => {\n const response = await fetch(`${base}${path}`, init);\n if (!response.ok) {\n const body = await response.text().catch(() => \"\");\n throw new JupiterApiError(response.status, body);\n }\n return (await response.json()) as T;\n };\n\n return {\n quoteGet(quoteRequest) {\n const search = buildQuoteSearchParams(quoteRequest);\n return requestAt<QuoteResponse>(basePath, `/quote?${search.toString()}`, {\n method: \"GET\",\n headers: baseHeaders,\n });\n },\n swapInstructionsPost({ swapRequest }) {\n return requestAt<SwapInstructionsResponse>(basePath, `/swap-instructions`, {\n method: \"POST\",\n headers: { ...baseHeaders, \"content-type\": \"application/json\" },\n body: JSON.stringify(swapRequest),\n });\n },\n buildGet(buildRequest) {\n const search = buildQuoteSearchParams(buildRequest);\n return requestAt<BuildResponse>(routerBasePath, `/build?${search.toString()}`, {\n method: \"GET\",\n headers: baseHeaders,\n });\n },\n };\n}\n"]}
|
package/dist/jupiter.d.cts
CHANGED
|
@@ -99,10 +99,54 @@ interface SwapInstructionsResponse {
|
|
|
99
99
|
cleanupInstruction?: Instruction;
|
|
100
100
|
addressLookupTableAddresses: Array<string>;
|
|
101
101
|
}
|
|
102
|
+
/** Query parameters for `GET /swap/v2/build`. */
|
|
103
|
+
interface BuildGetRequest {
|
|
104
|
+
inputMint: string;
|
|
105
|
+
outputMint: string;
|
|
106
|
+
amount: number;
|
|
107
|
+
/** The account performing the swap (replaces Metis `userPublicKey`). */
|
|
108
|
+
taker: string;
|
|
109
|
+
slippageBps?: number;
|
|
110
|
+
/** "fast" trades route optimality for lower latency. */
|
|
111
|
+
mode?: "fast";
|
|
112
|
+
dexes?: Array<string>;
|
|
113
|
+
excludeDexes?: Array<string>;
|
|
114
|
+
platformFeeBps?: number;
|
|
115
|
+
feeAccount?: string;
|
|
116
|
+
maxAccounts?: number;
|
|
117
|
+
payer?: string;
|
|
118
|
+
wrapAndUnwrapSol?: boolean;
|
|
119
|
+
destinationTokenAccount?: string;
|
|
120
|
+
}
|
|
121
|
+
/** Response from `GET /swap/v2/build`. */
|
|
122
|
+
interface BuildResponse {
|
|
123
|
+
inputMint: string;
|
|
124
|
+
outputMint: string;
|
|
125
|
+
inAmount: string;
|
|
126
|
+
outAmount: string;
|
|
127
|
+
otherAmountThreshold: string;
|
|
128
|
+
swapMode: string;
|
|
129
|
+
slippageBps: number;
|
|
130
|
+
routePlan: Array<RoutePlanStep>;
|
|
131
|
+
computeBudgetInstructions: Array<Instruction>;
|
|
132
|
+
setupInstructions: Array<Instruction>;
|
|
133
|
+
swapInstruction: Instruction;
|
|
134
|
+
cleanupInstruction?: Instruction | null;
|
|
135
|
+
otherInstructions?: Array<Instruction>;
|
|
136
|
+
tipInstruction?: Instruction | null;
|
|
137
|
+
/** Map of ALT address -> the addresses stored inside it (in order). */
|
|
138
|
+
addressesByLookupTableAddress?: Record<string, string[]> | null;
|
|
139
|
+
blockhashWithMetadata?: {
|
|
140
|
+
blockhash: number[];
|
|
141
|
+
lastValidBlockHeight: number;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
102
144
|
|
|
103
145
|
interface JupiterClientConfig {
|
|
104
146
|
/** Override the API base URL (e.g. the paid `https://api.jup.ag/swap/v1`). */
|
|
105
147
|
basePath?: string;
|
|
148
|
+
/** Override the Router base URL for `/build` (default `.../swap/v2`). */
|
|
149
|
+
routerBasePath?: string;
|
|
106
150
|
/** API key, sent as the `x-api-key` header. */
|
|
107
151
|
apiKey?: string;
|
|
108
152
|
/** Extra headers applied to every request. */
|
|
@@ -118,7 +162,9 @@ interface JupiterClient {
|
|
|
118
162
|
swapInstructionsPost(request: {
|
|
119
163
|
swapRequest: SwapRequest;
|
|
120
164
|
}): Promise<SwapInstructionsResponse>;
|
|
165
|
+
/** Router: one-call quote + raw instructions. ExactIn only. */
|
|
166
|
+
buildGet(request: BuildGetRequest): Promise<BuildResponse>;
|
|
121
167
|
}
|
|
122
168
|
declare function createJupiterClient(config?: JupiterClientConfig): JupiterClient;
|
|
123
169
|
|
|
124
|
-
export { type AccountMeta, type Instruction, type InstructionVersion, JupiterApiError, type JupiterClient, type JupiterClientConfig, type PlatformFee, type QuoteGetRequest, type QuoteResponse, type RoutePlanStep, type SwapInfo, type SwapInstructionsResponse, type SwapMode, type SwapRequest, createJupiterClient };
|
|
170
|
+
export { type AccountMeta, type BuildGetRequest, type BuildResponse, type Instruction, type InstructionVersion, JupiterApiError, type JupiterClient, type JupiterClientConfig, type PlatformFee, type QuoteGetRequest, type QuoteResponse, type RoutePlanStep, type SwapInfo, type SwapInstructionsResponse, type SwapMode, type SwapRequest, createJupiterClient };
|
package/dist/jupiter.d.ts
CHANGED
|
@@ -99,10 +99,54 @@ interface SwapInstructionsResponse {
|
|
|
99
99
|
cleanupInstruction?: Instruction;
|
|
100
100
|
addressLookupTableAddresses: Array<string>;
|
|
101
101
|
}
|
|
102
|
+
/** Query parameters for `GET /swap/v2/build`. */
|
|
103
|
+
interface BuildGetRequest {
|
|
104
|
+
inputMint: string;
|
|
105
|
+
outputMint: string;
|
|
106
|
+
amount: number;
|
|
107
|
+
/** The account performing the swap (replaces Metis `userPublicKey`). */
|
|
108
|
+
taker: string;
|
|
109
|
+
slippageBps?: number;
|
|
110
|
+
/** "fast" trades route optimality for lower latency. */
|
|
111
|
+
mode?: "fast";
|
|
112
|
+
dexes?: Array<string>;
|
|
113
|
+
excludeDexes?: Array<string>;
|
|
114
|
+
platformFeeBps?: number;
|
|
115
|
+
feeAccount?: string;
|
|
116
|
+
maxAccounts?: number;
|
|
117
|
+
payer?: string;
|
|
118
|
+
wrapAndUnwrapSol?: boolean;
|
|
119
|
+
destinationTokenAccount?: string;
|
|
120
|
+
}
|
|
121
|
+
/** Response from `GET /swap/v2/build`. */
|
|
122
|
+
interface BuildResponse {
|
|
123
|
+
inputMint: string;
|
|
124
|
+
outputMint: string;
|
|
125
|
+
inAmount: string;
|
|
126
|
+
outAmount: string;
|
|
127
|
+
otherAmountThreshold: string;
|
|
128
|
+
swapMode: string;
|
|
129
|
+
slippageBps: number;
|
|
130
|
+
routePlan: Array<RoutePlanStep>;
|
|
131
|
+
computeBudgetInstructions: Array<Instruction>;
|
|
132
|
+
setupInstructions: Array<Instruction>;
|
|
133
|
+
swapInstruction: Instruction;
|
|
134
|
+
cleanupInstruction?: Instruction | null;
|
|
135
|
+
otherInstructions?: Array<Instruction>;
|
|
136
|
+
tipInstruction?: Instruction | null;
|
|
137
|
+
/** Map of ALT address -> the addresses stored inside it (in order). */
|
|
138
|
+
addressesByLookupTableAddress?: Record<string, string[]> | null;
|
|
139
|
+
blockhashWithMetadata?: {
|
|
140
|
+
blockhash: number[];
|
|
141
|
+
lastValidBlockHeight: number;
|
|
142
|
+
};
|
|
143
|
+
}
|
|
102
144
|
|
|
103
145
|
interface JupiterClientConfig {
|
|
104
146
|
/** Override the API base URL (e.g. the paid `https://api.jup.ag/swap/v1`). */
|
|
105
147
|
basePath?: string;
|
|
148
|
+
/** Override the Router base URL for `/build` (default `.../swap/v2`). */
|
|
149
|
+
routerBasePath?: string;
|
|
106
150
|
/** API key, sent as the `x-api-key` header. */
|
|
107
151
|
apiKey?: string;
|
|
108
152
|
/** Extra headers applied to every request. */
|
|
@@ -118,7 +162,9 @@ interface JupiterClient {
|
|
|
118
162
|
swapInstructionsPost(request: {
|
|
119
163
|
swapRequest: SwapRequest;
|
|
120
164
|
}): Promise<SwapInstructionsResponse>;
|
|
165
|
+
/** Router: one-call quote + raw instructions. ExactIn only. */
|
|
166
|
+
buildGet(request: BuildGetRequest): Promise<BuildResponse>;
|
|
121
167
|
}
|
|
122
168
|
declare function createJupiterClient(config?: JupiterClientConfig): JupiterClient;
|
|
123
169
|
|
|
124
|
-
export { type AccountMeta, type Instruction, type InstructionVersion, JupiterApiError, type JupiterClient, type JupiterClientConfig, type PlatformFee, type QuoteGetRequest, type QuoteResponse, type RoutePlanStep, type SwapInfo, type SwapInstructionsResponse, type SwapMode, type SwapRequest, createJupiterClient };
|
|
170
|
+
export { type AccountMeta, type BuildGetRequest, type BuildResponse, type Instruction, type InstructionVersion, JupiterApiError, type JupiterClient, type JupiterClientConfig, type PlatformFee, type QuoteGetRequest, type QuoteResponse, type RoutePlanStep, type SwapInfo, type SwapInstructionsResponse, type SwapMode, type SwapRequest, createJupiterClient };
|
package/dist/jupiter.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/vendor/jupiter/client.ts
|
|
2
2
|
var DEFAULT_BASE_PATH = "https://lite-api.jup.ag/swap/v1";
|
|
3
|
+
var DEFAULT_ROUTER_BASE_PATH = "https://api.jup.ag/swap/v2";
|
|
3
4
|
var JupiterApiError = class _JupiterApiError extends Error {
|
|
4
5
|
status;
|
|
5
6
|
body;
|
|
@@ -25,10 +26,11 @@ function buildQuoteSearchParams(request) {
|
|
|
25
26
|
}
|
|
26
27
|
function createJupiterClient(config = {}) {
|
|
27
28
|
const basePath = (config.basePath ?? DEFAULT_BASE_PATH).replace(/\/+$/, "");
|
|
29
|
+
const routerBasePath = (config.routerBasePath ?? DEFAULT_ROUTER_BASE_PATH).replace(/\/+$/, "");
|
|
28
30
|
const baseHeaders = { ...config.headers };
|
|
29
31
|
if (config.apiKey) baseHeaders["x-api-key"] = config.apiKey;
|
|
30
|
-
const
|
|
31
|
-
const response = await fetch(`${
|
|
32
|
+
const requestAt = async (base, path, init) => {
|
|
33
|
+
const response = await fetch(`${base}${path}`, init);
|
|
32
34
|
if (!response.ok) {
|
|
33
35
|
const body = await response.text().catch(() => "");
|
|
34
36
|
throw new JupiterApiError(response.status, body);
|
|
@@ -38,17 +40,24 @@ function createJupiterClient(config = {}) {
|
|
|
38
40
|
return {
|
|
39
41
|
quoteGet(quoteRequest) {
|
|
40
42
|
const search = buildQuoteSearchParams(quoteRequest);
|
|
41
|
-
return
|
|
43
|
+
return requestAt(basePath, `/quote?${search.toString()}`, {
|
|
42
44
|
method: "GET",
|
|
43
45
|
headers: baseHeaders
|
|
44
46
|
});
|
|
45
47
|
},
|
|
46
48
|
swapInstructionsPost({ swapRequest }) {
|
|
47
|
-
return
|
|
49
|
+
return requestAt(basePath, `/swap-instructions`, {
|
|
48
50
|
method: "POST",
|
|
49
51
|
headers: { ...baseHeaders, "content-type": "application/json" },
|
|
50
52
|
body: JSON.stringify(swapRequest)
|
|
51
53
|
});
|
|
54
|
+
},
|
|
55
|
+
buildGet(buildRequest) {
|
|
56
|
+
const search = buildQuoteSearchParams(buildRequest);
|
|
57
|
+
return requestAt(routerBasePath, `/build?${search.toString()}`, {
|
|
58
|
+
method: "GET",
|
|
59
|
+
headers: baseHeaders
|
|
60
|
+
});
|
|
52
61
|
}
|
|
53
62
|
};
|
|
54
63
|
}
|
package/dist/jupiter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/vendor/jupiter/client.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"sources":["../src/vendor/jupiter/client.ts"],"names":[],"mappings":";AAmBA,IAAM,iBAAA,GAAoB,iCAAA;AAI1B,IAAM,wBAAA,GAA2B,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A,IACA,SAAS,YAAA,EAAc;AACrB,MAAA,MAAM,MAAA,GAAS,uBAAuB,YAAY,CAAA;AAClD,MAAA,OAAO,UAAyB,cAAA,EAAgB,CAAA,OAAA,EAAU,MAAA,CAAO,QAAA,EAAU,CAAA,CAAA,EAAI;AAAA,QAC7E,MAAA,EAAQ,KAAA;AAAA,QACR,OAAA,EAAS;AAAA,OACV,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"jupiter.js","sourcesContent":["// Minimal Jupiter Swap API client — replaces the runtime of @jup-ag/api.\n//\n// The generated @jup-ag/api client hardcodes the legacy\n// `https://quote-api.jup.ag/v6` base URL and ignores a caller-supplied\n// basePath, so we reimplement the two endpoints the SDK uses against Jupiter's\n// current Swap API (https://dev.jup.ag/docs/swap-api). Only `GET /quote` and\n// `POST /swap-instructions` are implemented.\n\nimport type {\n BuildGetRequest,\n BuildResponse,\n QuoteGetRequest,\n QuoteResponse,\n SwapInstructionsResponse,\n SwapRequest,\n} from \"./types\";\n\n// Free tier. Callers with an API key typically override this with the paid\n// base `https://api.jup.ag/swap/v1` via `basePath`.\nconst DEFAULT_BASE_PATH = \"https://lite-api.jup.ag/swap/v1\";\n\n// Router base for the `/build` endpoint (paid). The Router lives under\n// `/swap/v2`, distinct from the Metis `/swap/v1` base above.\nconst DEFAULT_ROUTER_BASE_PATH = \"https://api.jup.ag/swap/v2\";\n\nexport interface JupiterClientConfig {\n /** Override the API base URL (e.g. the paid `https://api.jup.ag/swap/v1`). */\n basePath?: string;\n /** Override the Router base URL for `/build` (default `.../swap/v2`). */\n routerBasePath?: string;\n /** API key, sent as the `x-api-key` header. */\n apiKey?: string;\n /** Extra headers applied to every request. */\n headers?: Record<string, string>;\n}\n\nexport class JupiterApiError extends Error {\n status: number;\n body: string;\n\n constructor(status: number, body: string) {\n super(`Jupiter API request failed with status ${status}: ${body}`);\n this.name = \"JupiterApiError\";\n Object.setPrototypeOf(this, JupiterApiError.prototype);\n this.status = status;\n this.body = body;\n }\n}\n\nfunction buildQuoteSearchParams(request: object): URLSearchParams {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(request)) {\n if (value === undefined || value === null) continue;\n // Arrays (dexes/excludeDexes) are comma-separated per the Jupiter spec.\n if (Array.isArray(value)) {\n if (value.length > 0) params.append(key, value.join(\",\"));\n continue;\n }\n params.append(key, String(value));\n }\n return params;\n}\n\nexport interface JupiterClient {\n quoteGet(request: QuoteGetRequest): Promise<QuoteResponse>;\n swapInstructionsPost(request: { swapRequest: SwapRequest }): Promise<SwapInstructionsResponse>;\n /** Router: one-call quote + raw instructions. ExactIn only. */\n buildGet(request: BuildGetRequest): Promise<BuildResponse>;\n}\n\nexport function createJupiterClient(config: JupiterClientConfig = {}): JupiterClient {\n const basePath = (config.basePath ?? DEFAULT_BASE_PATH).replace(/\\/+$/, \"\");\n const routerBasePath = (config.routerBasePath ?? DEFAULT_ROUTER_BASE_PATH).replace(/\\/+$/, \"\");\n const baseHeaders: Record<string, string> = { ...config.headers };\n if (config.apiKey) baseHeaders[\"x-api-key\"] = config.apiKey;\n\n const requestAt = async <T>(base: string, path: string, init: RequestInit): Promise<T> => {\n const response = await fetch(`${base}${path}`, init);\n if (!response.ok) {\n const body = await response.text().catch(() => \"\");\n throw new JupiterApiError(response.status, body);\n }\n return (await response.json()) as T;\n };\n\n return {\n quoteGet(quoteRequest) {\n const search = buildQuoteSearchParams(quoteRequest);\n return requestAt<QuoteResponse>(basePath, `/quote?${search.toString()}`, {\n method: \"GET\",\n headers: baseHeaders,\n });\n },\n swapInstructionsPost({ swapRequest }) {\n return requestAt<SwapInstructionsResponse>(basePath, `/swap-instructions`, {\n method: \"POST\",\n headers: { ...baseHeaders, \"content-type\": \"application/json\" },\n body: JSON.stringify(swapRequest),\n });\n },\n buildGet(buildRequest) {\n const search = buildQuoteSearchParams(buildRequest);\n return requestAt<BuildResponse>(routerBasePath, `/build?${search.toString()}`, {\n method: \"GET\",\n headers: baseHeaders,\n });\n },\n };\n}\n"]}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { PublicKey, Connection } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
6
|
+
interface CurrentResult {
|
|
7
|
+
value: BN;
|
|
8
|
+
std_dev: BN;
|
|
9
|
+
mean: BN;
|
|
10
|
+
range: BN;
|
|
11
|
+
min_value: BN;
|
|
12
|
+
max_vaalue: BN;
|
|
13
|
+
slot: BN;
|
|
14
|
+
min_slot: BN;
|
|
15
|
+
max_slot: BN;
|
|
16
|
+
}
|
|
17
|
+
interface OracleSubmission {
|
|
18
|
+
oracle: PublicKey;
|
|
19
|
+
slot: BN;
|
|
20
|
+
value: BN;
|
|
21
|
+
}
|
|
22
|
+
interface PullFeedAccountData {
|
|
23
|
+
submissions: OracleSubmission[];
|
|
24
|
+
authority: PublicKey;
|
|
25
|
+
queue: PublicKey;
|
|
26
|
+
feed_hash: Buffer;
|
|
27
|
+
initialized_at: BN;
|
|
28
|
+
permissions: BN;
|
|
29
|
+
max_variance: BN;
|
|
30
|
+
min_responses: number;
|
|
31
|
+
name: Buffer;
|
|
32
|
+
sample_size: number;
|
|
33
|
+
last_update_timestamp: BN;
|
|
34
|
+
lut_slot: BN;
|
|
35
|
+
result: CurrentResult;
|
|
36
|
+
max_staleness: number;
|
|
37
|
+
min_sample_size: number;
|
|
38
|
+
}
|
|
39
|
+
type CrossbarSimulatePayload = FeedResponse[];
|
|
40
|
+
interface FeedResponse {
|
|
41
|
+
feedHash: string;
|
|
42
|
+
results: number[];
|
|
43
|
+
}
|
|
44
|
+
declare const switchboardAccountCoder: BorshCoder<string, string>;
|
|
45
|
+
declare function getSwitchboardProgram(provider: Provider): Program;
|
|
46
|
+
declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
|
|
47
|
+
|
|
48
|
+
/** The subset of Exponent's `Vault` account that `merge` / the roll needs. */
|
|
49
|
+
interface ExponentVault {
|
|
50
|
+
/** Vault signer authority (`merge.authority`, via `has_one = authority`). */
|
|
51
|
+
authority: PublicKey;
|
|
52
|
+
syProgram: PublicKey;
|
|
53
|
+
mintSy: PublicKey;
|
|
54
|
+
mintYt: PublicKey;
|
|
55
|
+
mintPt: PublicKey;
|
|
56
|
+
escrowSy: PublicKey;
|
|
57
|
+
yieldPosition: PublicKey;
|
|
58
|
+
addressLookupTable: PublicKey;
|
|
59
|
+
/** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber. */
|
|
60
|
+
finalSyExchangeRate: BigNumber;
|
|
61
|
+
/** Raw status byte. */
|
|
62
|
+
status: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Accounts required by `merge`. Most are read off the maturity's `Vault` account
|
|
67
|
+
* (`mintYt`, `mintPt`, `escrowSy`, `syProgram`, `addressLookupTable`, `yieldPosition`,
|
|
68
|
+
* `authority`); the `*Ata` accounts are the owner's token accounts.
|
|
69
|
+
*
|
|
70
|
+
* After maturity, `merge` burns PT only (the YT burn is skipped because the vault is
|
|
71
|
+
* inactive) — but the YT accounts are still required by the instruction, so `ytSrcAta`
|
|
72
|
+
* must be a valid (possibly empty, freshly-created) YT token account.
|
|
73
|
+
*/
|
|
74
|
+
interface ExponentMergeAccounts {
|
|
75
|
+
/** Position owner / signer (the marginfi account authority). */
|
|
76
|
+
owner: PublicKey;
|
|
77
|
+
/** Vault signer authority (`Vault.authority`). */
|
|
78
|
+
authority: PublicKey;
|
|
79
|
+
/** The maturity vault address. */
|
|
80
|
+
vault: PublicKey;
|
|
81
|
+
/** Owner's SY token account (destination of the redeemed SY). */
|
|
82
|
+
sySrcDstAta: PublicKey;
|
|
83
|
+
/** `Vault.escrow_sy`. */
|
|
84
|
+
escrowSy: PublicKey;
|
|
85
|
+
/** Owner's YT token account (source; empty/0 after maturity). */
|
|
86
|
+
ytSrcAta: PublicKey;
|
|
87
|
+
/** Owner's PT token account (source; holds the withdrawn PT). */
|
|
88
|
+
ptSrcAta: PublicKey;
|
|
89
|
+
/** `Vault.mint_yt`. */
|
|
90
|
+
mintYt: PublicKey;
|
|
91
|
+
/** `Vault.mint_pt`. */
|
|
92
|
+
mintPt: PublicKey;
|
|
93
|
+
/** `Vault.sy_program`. */
|
|
94
|
+
syProgram: PublicKey;
|
|
95
|
+
/** `Vault.address_lookup_table`. */
|
|
96
|
+
addressLookupTable: PublicKey;
|
|
97
|
+
/** `Vault.yield_position`. */
|
|
98
|
+
yieldPosition: PublicKey;
|
|
99
|
+
/** SPL token program for PT/YT/SY mints (defaults to the classic token program). */
|
|
100
|
+
tokenProgram?: PublicKey;
|
|
101
|
+
}
|
|
102
|
+
interface ResolveExponentMergeContextParams {
|
|
103
|
+
connection: Connection;
|
|
104
|
+
/** Position owner / signer (the marginfi account authority). */
|
|
105
|
+
owner: PublicKey;
|
|
106
|
+
/** The maturity vault, or… */
|
|
107
|
+
vault?: PublicKey;
|
|
108
|
+
/** …the `MarketTwo` address (its `vault` will be read). One of `vault`/`market` is required. */
|
|
109
|
+
market?: PublicKey;
|
|
110
|
+
/** Token program for the PT/YT mints (Exponent's `merge` uses the classic Token program). */
|
|
111
|
+
ptYtTokenProgram?: PublicKey;
|
|
112
|
+
/** Token program for the SY mint (may be token-2022). Defaults to classic Token. */
|
|
113
|
+
syTokenProgram?: PublicKey;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolved inputs for `makeRollPtTx`, derived from the maturity `Vault`: the `merge`
|
|
117
|
+
* accounts, the SY (underlying) token the swap leg consumes, and a helper to size the
|
|
118
|
+
* redeemed SY amount from `Vault.final_sy_exchange_rate`.
|
|
119
|
+
*/
|
|
120
|
+
interface ExponentMergeContext {
|
|
121
|
+
vaultAddress: PublicKey;
|
|
122
|
+
vault: ExponentVault;
|
|
123
|
+
mergeAccounts: ExponentMergeAccounts;
|
|
124
|
+
underlying: {
|
|
125
|
+
mint: PublicKey;
|
|
126
|
+
decimals: number;
|
|
127
|
+
tokenProgram: PublicKey;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Native SY that `merge` yields for a given native PT amount, at the matured rate:
|
|
131
|
+
* `floor(ptAmountNative × final_sy_exchange_rate)`. Assumes PT and SY share decimals
|
|
132
|
+
* (true for Exponent vaults). Feed its result into `MakeRollPtTxParams.redeemedAmountNative`.
|
|
133
|
+
*/
|
|
134
|
+
computeRedeemedAmountNative(ptAmountNative: bigint): bigint;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { type CurrentResult as C, type ExponentVault as E, type FeedResponse as F, type OracleSubmission as O, type PullFeedAccountData as P, type ResolveExponentMergeContextParams as R, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type ExponentMergeContext as a, type ExponentMergeAccounts as b, type CrossbarSimulatePayload as c, decodeSwitchboardPullFeedData as d, getSwitchboardProgram as g, switchboardAccountCoder as s };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { BorshCoder, Provider, Program } from '@coral-xyz/anchor';
|
|
2
|
+
import BN from 'bn.js';
|
|
3
|
+
import { PublicKey, Connection } from '@solana/web3.js';
|
|
4
|
+
|
|
5
|
+
declare const SWITCHBOARD_ONDEMANDE_PRICE_PRECISION = 18;
|
|
6
|
+
interface CurrentResult {
|
|
7
|
+
value: BN;
|
|
8
|
+
std_dev: BN;
|
|
9
|
+
mean: BN;
|
|
10
|
+
range: BN;
|
|
11
|
+
min_value: BN;
|
|
12
|
+
max_vaalue: BN;
|
|
13
|
+
slot: BN;
|
|
14
|
+
min_slot: BN;
|
|
15
|
+
max_slot: BN;
|
|
16
|
+
}
|
|
17
|
+
interface OracleSubmission {
|
|
18
|
+
oracle: PublicKey;
|
|
19
|
+
slot: BN;
|
|
20
|
+
value: BN;
|
|
21
|
+
}
|
|
22
|
+
interface PullFeedAccountData {
|
|
23
|
+
submissions: OracleSubmission[];
|
|
24
|
+
authority: PublicKey;
|
|
25
|
+
queue: PublicKey;
|
|
26
|
+
feed_hash: Buffer;
|
|
27
|
+
initialized_at: BN;
|
|
28
|
+
permissions: BN;
|
|
29
|
+
max_variance: BN;
|
|
30
|
+
min_responses: number;
|
|
31
|
+
name: Buffer;
|
|
32
|
+
sample_size: number;
|
|
33
|
+
last_update_timestamp: BN;
|
|
34
|
+
lut_slot: BN;
|
|
35
|
+
result: CurrentResult;
|
|
36
|
+
max_staleness: number;
|
|
37
|
+
min_sample_size: number;
|
|
38
|
+
}
|
|
39
|
+
type CrossbarSimulatePayload = FeedResponse[];
|
|
40
|
+
interface FeedResponse {
|
|
41
|
+
feedHash: string;
|
|
42
|
+
results: number[];
|
|
43
|
+
}
|
|
44
|
+
declare const switchboardAccountCoder: BorshCoder<string, string>;
|
|
45
|
+
declare function getSwitchboardProgram(provider: Provider): Program;
|
|
46
|
+
declare function decodeSwitchboardPullFeedData(data: Buffer): PullFeedAccountData;
|
|
47
|
+
|
|
48
|
+
/** The subset of Exponent's `Vault` account that `merge` / the roll needs. */
|
|
49
|
+
interface ExponentVault {
|
|
50
|
+
/** Vault signer authority (`merge.authority`, via `has_one = authority`). */
|
|
51
|
+
authority: PublicKey;
|
|
52
|
+
syProgram: PublicKey;
|
|
53
|
+
mintSy: PublicKey;
|
|
54
|
+
mintYt: PublicKey;
|
|
55
|
+
mintPt: PublicKey;
|
|
56
|
+
escrowSy: PublicKey;
|
|
57
|
+
yieldPosition: PublicKey;
|
|
58
|
+
addressLookupTable: PublicKey;
|
|
59
|
+
/** Final (maturity) SY exchange rate, already scaled by 1e12 → BigNumber. */
|
|
60
|
+
finalSyExchangeRate: BigNumber;
|
|
61
|
+
/** Raw status byte. */
|
|
62
|
+
status: number;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Accounts required by `merge`. Most are read off the maturity's `Vault` account
|
|
67
|
+
* (`mintYt`, `mintPt`, `escrowSy`, `syProgram`, `addressLookupTable`, `yieldPosition`,
|
|
68
|
+
* `authority`); the `*Ata` accounts are the owner's token accounts.
|
|
69
|
+
*
|
|
70
|
+
* After maturity, `merge` burns PT only (the YT burn is skipped because the vault is
|
|
71
|
+
* inactive) — but the YT accounts are still required by the instruction, so `ytSrcAta`
|
|
72
|
+
* must be a valid (possibly empty, freshly-created) YT token account.
|
|
73
|
+
*/
|
|
74
|
+
interface ExponentMergeAccounts {
|
|
75
|
+
/** Position owner / signer (the marginfi account authority). */
|
|
76
|
+
owner: PublicKey;
|
|
77
|
+
/** Vault signer authority (`Vault.authority`). */
|
|
78
|
+
authority: PublicKey;
|
|
79
|
+
/** The maturity vault address. */
|
|
80
|
+
vault: PublicKey;
|
|
81
|
+
/** Owner's SY token account (destination of the redeemed SY). */
|
|
82
|
+
sySrcDstAta: PublicKey;
|
|
83
|
+
/** `Vault.escrow_sy`. */
|
|
84
|
+
escrowSy: PublicKey;
|
|
85
|
+
/** Owner's YT token account (source; empty/0 after maturity). */
|
|
86
|
+
ytSrcAta: PublicKey;
|
|
87
|
+
/** Owner's PT token account (source; holds the withdrawn PT). */
|
|
88
|
+
ptSrcAta: PublicKey;
|
|
89
|
+
/** `Vault.mint_yt`. */
|
|
90
|
+
mintYt: PublicKey;
|
|
91
|
+
/** `Vault.mint_pt`. */
|
|
92
|
+
mintPt: PublicKey;
|
|
93
|
+
/** `Vault.sy_program`. */
|
|
94
|
+
syProgram: PublicKey;
|
|
95
|
+
/** `Vault.address_lookup_table`. */
|
|
96
|
+
addressLookupTable: PublicKey;
|
|
97
|
+
/** `Vault.yield_position`. */
|
|
98
|
+
yieldPosition: PublicKey;
|
|
99
|
+
/** SPL token program for PT/YT/SY mints (defaults to the classic token program). */
|
|
100
|
+
tokenProgram?: PublicKey;
|
|
101
|
+
}
|
|
102
|
+
interface ResolveExponentMergeContextParams {
|
|
103
|
+
connection: Connection;
|
|
104
|
+
/** Position owner / signer (the marginfi account authority). */
|
|
105
|
+
owner: PublicKey;
|
|
106
|
+
/** The maturity vault, or… */
|
|
107
|
+
vault?: PublicKey;
|
|
108
|
+
/** …the `MarketTwo` address (its `vault` will be read). One of `vault`/`market` is required. */
|
|
109
|
+
market?: PublicKey;
|
|
110
|
+
/** Token program for the PT/YT mints (Exponent's `merge` uses the classic Token program). */
|
|
111
|
+
ptYtTokenProgram?: PublicKey;
|
|
112
|
+
/** Token program for the SY mint (may be token-2022). Defaults to classic Token. */
|
|
113
|
+
syTokenProgram?: PublicKey;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Resolved inputs for `makeRollPtTx`, derived from the maturity `Vault`: the `merge`
|
|
117
|
+
* accounts, the SY (underlying) token the swap leg consumes, and a helper to size the
|
|
118
|
+
* redeemed SY amount from `Vault.final_sy_exchange_rate`.
|
|
119
|
+
*/
|
|
120
|
+
interface ExponentMergeContext {
|
|
121
|
+
vaultAddress: PublicKey;
|
|
122
|
+
vault: ExponentVault;
|
|
123
|
+
mergeAccounts: ExponentMergeAccounts;
|
|
124
|
+
underlying: {
|
|
125
|
+
mint: PublicKey;
|
|
126
|
+
decimals: number;
|
|
127
|
+
tokenProgram: PublicKey;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Native SY that `merge` yields for a given native PT amount, at the matured rate:
|
|
131
|
+
* `floor(ptAmountNative × final_sy_exchange_rate)`. Assumes PT and SY share decimals
|
|
132
|
+
* (true for Exponent vaults). Feed its result into `MakeRollPtTxParams.redeemedAmountNative`.
|
|
133
|
+
*/
|
|
134
|
+
computeRedeemedAmountNative(ptAmountNative: bigint): bigint;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { type CurrentResult as C, type ExponentVault as E, type FeedResponse as F, type OracleSubmission as O, type PullFeedAccountData as P, type ResolveExponentMergeContextParams as R, SWITCHBOARD_ONDEMANDE_PRICE_PRECISION as S, type ExponentMergeContext as a, type ExponentMergeAccounts as b, type CrossbarSimulatePayload as c, decodeSwitchboardPullFeedData as d, getSwitchboardProgram as g, switchboardAccountCoder as s };
|