@meteora-ag/zap-sdk 2.0.0-rc.0 → 2.0.0-rc.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/README.md +2 -2
- package/dist/index.d.mts +60 -91
- package/dist/index.d.ts +60 -91
- package/dist/index.js +322 -403
- package/dist/index.mjs +328 -393
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,10 +12,10 @@ Zap In is a **multi-step** flow. Intermediate **swap** transactions are Jupiter
|
|
|
12
12
|
|
|
13
13
|
- `simulateTransaction` with no `err` only means the swap will land. It does **not** mean `outAmount` is a reasonable market vs the input size.
|
|
14
14
|
- Jupiter `slippageBps` bounds fill vs **that quote / that route**, not input-vs-output fair value. See [Jupiter customer support](https://developers.jup.ag/docs/resources/support#customer-support).
|
|
15
|
-
-
|
|
15
|
+
- Zap-in helpers send Jupiter their slippage argument plus the Jupiter query parameters you pass in the optional `jupiterQuoteOptions`, and Jupiter uses its own defaults for the rest. A low `maxAccounts` (the examples use `40` or `50`) can return a much thinner route than the Jupiter UI.
|
|
16
16
|
- The Meteora **UI** applies extra output-amount / USD / extreme-impact checks. This SDK does not. Examples are starting points for specific pools and sizes, not production-safe defaults for every token.
|
|
17
17
|
|
|
18
|
-
Before sending: compare quoted output to a reference price, reject extreme impact, simulate **wallet token deltas**, and if
|
|
18
|
+
Before sending: compare quoted output to a reference price, reject extreme impact, simulate **wallet token deltas**, and if the quote is far worse than the Jupiter UI quote, raise `maxAccounts` or skip the zap.
|
|
19
19
|
|
|
20
20
|
## Installation
|
|
21
21
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1892,37 +1892,30 @@ interface ZapOutThroughJupiterParams {
|
|
|
1892
1892
|
outputMint: PublicKey;
|
|
1893
1893
|
inputTokenProgram: PublicKey;
|
|
1894
1894
|
outputTokenProgram: PublicKey;
|
|
1895
|
-
|
|
1895
|
+
/** Its `setupInstructions`, when present, add the token accounts the swap needs that the zap does not create. */
|
|
1896
|
+
jupiterSwapResponse: Pick<JupiterSwapInstructionResponse, "swapInstruction"> & Partial<Pick<JupiterSwapInstructions, "setupInstructions">> & JupiterAddressLookupTableFields;
|
|
1896
1897
|
maxSwapAmount: BN;
|
|
1897
1898
|
percentageToZapOut: number;
|
|
1898
1899
|
}
|
|
1900
|
+
/** Jupiter query parameter values. The SDK converts each value to a string. */
|
|
1901
|
+
type JupiterQueryParams = Record<string, string | number | boolean>;
|
|
1899
1902
|
type GetJupiterQuoteParams = {
|
|
1900
1903
|
inputMint: PublicKey;
|
|
1901
1904
|
outputMint: PublicKey;
|
|
1902
1905
|
amount: BN;
|
|
1903
1906
|
/** Wallet the swap is built for. Sent as `taker` under v2, unused under v1. */
|
|
1904
1907
|
user: PublicKey;
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1908
|
+
/**
|
|
1909
|
+
* Any other Jupiter query parameter, such as `slippageBps` or `maxAccounts`. The SDK forwards them
|
|
1910
|
+
* to Jupiter as-is and sends nothing else, so Jupiter uses its own default for every parameter not
|
|
1911
|
+
* given here. `inputMint`, `outputMint`, `amount` and, under v2, `taker` always come from the fields
|
|
1912
|
+
* above, even when they are also given here.
|
|
1913
|
+
* Jupiter's API docs are the source of truth for the accepted parameters:
|
|
1914
|
+
* - v1 `GET /swap/v1/quote`: https://developers.jup.ag/docs/api-reference/swap/v1/quote
|
|
1915
|
+
* - v2 `GET /swap/v2/build`: https://developers.jup.ag/docs/api-reference/swap/build
|
|
1916
|
+
*/
|
|
1917
|
+
queryParams?: JupiterQueryParams;
|
|
1912
1918
|
};
|
|
1913
|
-
/**
|
|
1914
|
-
* Jupiter options for the quote request. The SDK forwards them to Jupiter as-is and does not decide
|
|
1915
|
-
* which ones Jupiter honours, because Jupiter also accepts options it does not document.
|
|
1916
|
-
* Jupiter's API docs are the source of truth for what each option does:
|
|
1917
|
-
* - v1 `GET /swap/v1/quote`: https://developers.jup.ag/docs/api-reference/swap/v1/quote
|
|
1918
|
-
* - v2 `GET /swap/v2/build`: https://developers.jup.ag/docs/api-reference/swap/build
|
|
1919
|
-
*
|
|
1920
|
-
* `dynamicSlippage`, `onlyDirectRoutes`, `restrictIntermediateTokens` and `forJitoBundle` fall back to
|
|
1921
|
-
* `DEFAULT_JUPITER_QUOTE_OPTIONS` when omitted.
|
|
1922
|
-
* `additionalQueryParams` holds any other Jupiter query parameter, as a name to string value map. It is
|
|
1923
|
-
* added last, so it overrides parameters the SDK sets, except `taker` under v2.
|
|
1924
|
-
*/
|
|
1925
|
-
type JupiterQuoteOptions = Pick<GetJupiterQuoteParams, "dynamicSlippage" | "onlyDirectRoutes" | "restrictIntermediateTokens" | "forJitoBundle" | "additionalQueryParams">;
|
|
1926
1919
|
type GetJupAndDammV2QuotesParams = {
|
|
1927
1920
|
connection: Connection;
|
|
1928
1921
|
user: PublicKey;
|
|
@@ -1932,8 +1925,11 @@ type GetJupAndDammV2QuotesParams = {
|
|
|
1932
1925
|
tokenBDecimal: number;
|
|
1933
1926
|
dammV2SlippageBps: number;
|
|
1934
1927
|
jupSlippageBps: number;
|
|
1935
|
-
|
|
1936
|
-
|
|
1928
|
+
/**
|
|
1929
|
+
* Jupiter query parameters for the quotes this helper requests, see `GetJupiterQuoteParams.queryParams`.
|
|
1930
|
+
* The helper sends its slippage argument as `slippageBps`, and these parameters override it.
|
|
1931
|
+
*/
|
|
1932
|
+
jupiterQuoteOptions?: JupiterQueryParams;
|
|
1937
1933
|
config?: ZapConfig;
|
|
1938
1934
|
};
|
|
1939
1935
|
/** Quote fields shared by v1 `/quote` and v2 `/build` responses. */
|
|
@@ -2049,7 +2045,6 @@ type GetZapInDammV2DirectPoolParams = {
|
|
|
2049
2045
|
positionNftMint: PublicKey;
|
|
2050
2046
|
maxSqrtPriceChangeBps: number;
|
|
2051
2047
|
maxTransferAmountExtendPercentage: number;
|
|
2052
|
-
maxAccounts: number;
|
|
2053
2048
|
slippageBps: number;
|
|
2054
2049
|
dammV2Quote: {
|
|
2055
2050
|
swapInAmount: BN;
|
|
@@ -2060,7 +2055,11 @@ type GetZapInDammV2DirectPoolParams = {
|
|
|
2060
2055
|
priceImpact: Decimal;
|
|
2061
2056
|
} | null;
|
|
2062
2057
|
jupiterQuote: JupiterQuoteResponse | null;
|
|
2063
|
-
|
|
2058
|
+
/**
|
|
2059
|
+
* Jupiter query parameters for the quotes this helper requests, see `GetJupiterQuoteParams.queryParams`.
|
|
2060
|
+
* The helper sends its slippage argument as `slippageBps`, and these parameters override it.
|
|
2061
|
+
*/
|
|
2062
|
+
jupiterQuoteOptions?: JupiterQueryParams;
|
|
2064
2063
|
};
|
|
2065
2064
|
type GetZapInDammV2IndirectPoolParams = {
|
|
2066
2065
|
user: PublicKey;
|
|
@@ -2070,11 +2069,14 @@ type GetZapInDammV2IndirectPoolParams = {
|
|
|
2070
2069
|
positionNftMint: PublicKey;
|
|
2071
2070
|
maxSqrtPriceChangeBps: number;
|
|
2072
2071
|
maxTransferAmountExtendPercentage: number;
|
|
2073
|
-
maxAccounts: number;
|
|
2074
2072
|
slippageBps: number;
|
|
2075
2073
|
jupiterQuoteToA: JupiterQuoteResponse | null;
|
|
2076
2074
|
jupiterQuoteToB: JupiterQuoteResponse | null;
|
|
2077
|
-
|
|
2075
|
+
/**
|
|
2076
|
+
* Jupiter query parameters for the quotes this helper requests, see `GetJupiterQuoteParams.queryParams`.
|
|
2077
|
+
* The helper sends its slippage argument as `slippageBps`, and these parameters override it.
|
|
2078
|
+
*/
|
|
2079
|
+
jupiterQuoteOptions?: JupiterQueryParams;
|
|
2078
2080
|
};
|
|
2079
2081
|
declare enum ZapInDammV2PoolSwapRoute {
|
|
2080
2082
|
Jupiter = "jupiter",
|
|
@@ -2167,7 +2169,11 @@ interface EstimateDlmmDirectSwapParams {
|
|
|
2167
2169
|
maxDeltaId: number;
|
|
2168
2170
|
strategy: StrategyType;
|
|
2169
2171
|
singleSided?: DlmmSingleSided;
|
|
2170
|
-
|
|
2172
|
+
/**
|
|
2173
|
+
* Jupiter query parameters for the quotes this helper requests, see `GetJupiterQuoteParams.queryParams`.
|
|
2174
|
+
* The helper sends its slippage argument as `slippageBps`, and these parameters override it.
|
|
2175
|
+
*/
|
|
2176
|
+
jupiterQuoteOptions?: JupiterQueryParams;
|
|
2171
2177
|
config?: ZapConfig;
|
|
2172
2178
|
}
|
|
2173
2179
|
interface DlmmDirectSwapEstimateContext {
|
|
@@ -2202,7 +2208,11 @@ interface EstimateDlmmRebalanceSwapParams {
|
|
|
2202
2208
|
maxDeltaId: number;
|
|
2203
2209
|
swapSlippageBps: number;
|
|
2204
2210
|
strategy: StrategyType;
|
|
2205
|
-
|
|
2211
|
+
/**
|
|
2212
|
+
* Jupiter query parameters for the quotes this helper requests, see `GetJupiterQuoteParams.queryParams`.
|
|
2213
|
+
* The helper sends its slippage argument as `slippageBps`, and these parameters override it.
|
|
2214
|
+
*/
|
|
2215
|
+
jupiterQuoteOptions?: JupiterQueryParams;
|
|
2206
2216
|
config?: ZapConfig;
|
|
2207
2217
|
}
|
|
2208
2218
|
interface DlmmDirectRebalanceEstimateContext {
|
|
@@ -2230,7 +2240,11 @@ interface EstimateDlmmIndirectSwapParams {
|
|
|
2230
2240
|
maxDeltaId: number;
|
|
2231
2241
|
strategy: StrategyType;
|
|
2232
2242
|
singleSided?: DlmmSingleSided;
|
|
2233
|
-
|
|
2243
|
+
/**
|
|
2244
|
+
* Jupiter query parameters for the quotes this helper requests, see `GetJupiterQuoteParams.queryParams`.
|
|
2245
|
+
* The helper sends its slippage argument as `slippageBps`, and these parameters override it.
|
|
2246
|
+
*/
|
|
2247
|
+
jupiterQuoteOptions?: JupiterQueryParams;
|
|
2234
2248
|
config?: ZapConfig;
|
|
2235
2249
|
}
|
|
2236
2250
|
interface DlmmIndirectSwapEstimateResult {
|
|
@@ -2266,7 +2280,6 @@ interface RebalanceDlmmPositionParams {
|
|
|
2266
2280
|
strategy: StrategyType;
|
|
2267
2281
|
favorXInActiveId: boolean;
|
|
2268
2282
|
directSwapEstimate: DlmmDirectEstimateResult;
|
|
2269
|
-
maxAccounts?: number;
|
|
2270
2283
|
}
|
|
2271
2284
|
interface RebalanceDlmmPositionResponse extends ZapInstructionsResponse {
|
|
2272
2285
|
estimation: {
|
|
@@ -2290,7 +2303,6 @@ interface GetZapInDlmmIndirectParams {
|
|
|
2290
2303
|
maxDeltaId: number;
|
|
2291
2304
|
strategy: StrategyType;
|
|
2292
2305
|
favorXInActiveId: boolean;
|
|
2293
|
-
maxAccounts: number;
|
|
2294
2306
|
swapSlippageBps: number;
|
|
2295
2307
|
maxTransferAmountExtendPercentage: number;
|
|
2296
2308
|
indirectSwapEstimate: DlmmIndirectSwapEstimateResult;
|
|
@@ -2306,7 +2318,6 @@ interface GetZapInDlmmDirectParams {
|
|
|
2306
2318
|
maxDeltaId: number;
|
|
2307
2319
|
strategy: StrategyType;
|
|
2308
2320
|
favorXInActiveId: boolean;
|
|
2309
|
-
maxAccounts: number;
|
|
2310
2321
|
swapSlippageBps: number;
|
|
2311
2322
|
maxTransferAmountExtendPercentage: number;
|
|
2312
2323
|
directSwapEstimate: DlmmDirectEstimateResult;
|
|
@@ -2391,13 +2402,12 @@ declare class Zap {
|
|
|
2391
2402
|
* @param params.amountIn - The amount of input token
|
|
2392
2403
|
* @param params.inputTokenMint - The input token mint
|
|
2393
2404
|
* @param params.positionNftMint - The position NFT mint account's public key
|
|
2394
|
-
* @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
|
|
2395
2405
|
* @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
|
|
2396
2406
|
* @param params.slippageBps - The swap slippage tolerance in basis points
|
|
2397
2407
|
* @param params.dammV2Quote - The DAMM V2 swap quote for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
|
|
2398
2408
|
* @param params.jupiterQuote - The Jupiter swap quote for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
|
|
2399
2409
|
* @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
|
|
2400
|
-
* @param params.jupiterQuoteOptions - Optional Jupiter
|
|
2410
|
+
* @param params.jupiterQuoteOptions - Optional Jupiter query parameters, see `GetJupiterQuoteParams.queryParams`
|
|
2401
2411
|
* @returns The zap-in transaction parameters for a DAMM V2 direct pool
|
|
2402
2412
|
* @throws if input token mint matches either tokenA or tokenB in the pool
|
|
2403
2413
|
* @throws if failed to get both Jupiter and DAMM v2 swap quotes
|
|
@@ -2414,13 +2424,12 @@ declare class Zap {
|
|
|
2414
2424
|
* @param params.amountIn - The amount of input token
|
|
2415
2425
|
* @param params.inputTokenMint - The input token mint
|
|
2416
2426
|
* @param params.positionNftMint - The position NFT mint account's public key
|
|
2417
|
-
* @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
|
|
2418
2427
|
* @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
|
|
2419
2428
|
* @param params.slippageBps - The swap slippage tolerance in basis points
|
|
2420
2429
|
* @param params.jupiterQuoteToA - The Jupiter quote for swapping to tokenA for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
|
|
2421
2430
|
* @param params.jupiterQuoteToB - The Jupiter quote for swapping to tokenB for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
|
|
2422
2431
|
* @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
|
|
2423
|
-
* @param params.jupiterQuoteOptions - Optional Jupiter
|
|
2432
|
+
* @param params.jupiterQuoteOptions - Optional Jupiter query parameters, see `GetJupiterQuoteParams.queryParams`
|
|
2424
2433
|
* @returns The zap-in transaction parameters for a DAMM V2 indirect pool
|
|
2425
2434
|
* @throws if input token mint matches either tokenA or tokenB in the pool
|
|
2426
2435
|
* @throws if no Jupiter quote provided for both tokens
|
|
@@ -2449,7 +2458,7 @@ declare class Zap {
|
|
|
2449
2458
|
* @param params.amount - The amount to deposit
|
|
2450
2459
|
* @param params.preSqrtPrice - The sqrt price before the operation
|
|
2451
2460
|
* @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
|
|
2452
|
-
* @param params.preInstructions - Instructions to run before the zap in
|
|
2461
|
+
* @param params.preInstructions - Instructions to run before the zap in, including the token accounts the Jupiter swaps need. Token account creation repeated here is removed
|
|
2453
2462
|
* @param params.swapInstructions - Swap instructions to execute
|
|
2454
2463
|
* @param params.addressLookupTableAccounts - Lookup tables used by the swap instructions
|
|
2455
2464
|
* @param params.cleanUpInstructions - Instructions to run after the zap in
|
|
@@ -2469,7 +2478,6 @@ declare class Zap {
|
|
|
2469
2478
|
* @param params.maxDeltaId - The bin delta relative to the active bin for the upper bin position
|
|
2470
2479
|
* @param params.strategy - The liquidity distribution strategy
|
|
2471
2480
|
* @param params.favorXInActiveId - Whether to favor token X in the active bin
|
|
2472
|
-
* @param params.maxAccounts - Max accounts for the Jupiter swap query. Example value is `50`; this is not safe for every pool/size. Combined with Direct estimators (`onlyDirectRoutes=true`) this can select a much thinner route than Jupiter UI.
|
|
2473
2481
|
* @param params.swapSlippageBps - Swap slippage vs the **quoted route**, not vs a fair input/output price. Validate `directSwapEstimate` / `outAmount` before send.
|
|
2474
2482
|
* @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
|
|
2475
2483
|
* @param params.maxActiveBinSlippage - The maximum active bin slippage
|
|
@@ -2494,7 +2502,6 @@ declare class Zap {
|
|
|
2494
2502
|
* @param params.strategy - The liquidity distribution strategy
|
|
2495
2503
|
* @param params.favorXInActiveId - Whether to favor token X in the active bin
|
|
2496
2504
|
* @param params.indirectSwapEstimate - The result from the indirect swap estimate
|
|
2497
|
-
* @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
|
|
2498
2505
|
* @param params.swapSlippageBps - The swap slippage tolerance in basis points
|
|
2499
2506
|
* @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
|
|
2500
2507
|
* @param params.maxActiveBinSlippage - The maximum active bin slippage
|
|
@@ -2525,7 +2532,7 @@ declare class Zap {
|
|
|
2525
2532
|
* @param params.maxActiveBinSlippage - The maximum active bin slippage
|
|
2526
2533
|
* @param params.favorXInActiveId - Whether to favor token X in the active bin
|
|
2527
2534
|
* @param params.strategy - The liquidity distribution strategy
|
|
2528
|
-
* @param params.preInstructions - Instructions to run before the zap in
|
|
2535
|
+
* @param params.preInstructions - Instructions to run before the zap in, including the token accounts the Jupiter swaps need. Token account creation repeated here is removed
|
|
2529
2536
|
* @param params.swapInstructions - Swap instructions to execute
|
|
2530
2537
|
* @param params.addressLookupTableAccounts - Lookup tables used by the swap instructions
|
|
2531
2538
|
* @param params.cleanUpInstructions - Instructions to run after the zap in
|
|
@@ -2560,7 +2567,6 @@ declare class Zap {
|
|
|
2560
2567
|
* @param params.strategy - The strategy to use for the rebalance
|
|
2561
2568
|
* @param params.favorXInActiveId - Whether to favor token X in the active bin
|
|
2562
2569
|
* @param params.directSwapEstimate - The estimate of the direct swap operation
|
|
2563
|
-
* @param params.maxAccounts - The maximum number of accounts to use for the swap operation
|
|
2564
2570
|
* @returns The ordered instructions, the lookup tables they use, and the estimated balances
|
|
2565
2571
|
* @throws if fail to get jupiter quote or jupiter swap instruction
|
|
2566
2572
|
*/
|
|
@@ -2628,18 +2634,6 @@ declare class Zap {
|
|
|
2628
2634
|
zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<ZapInstructionsResponse>;
|
|
2629
2635
|
}
|
|
2630
2636
|
|
|
2631
|
-
declare function resolveJupiterConfig(config?: ZapConfig): {
|
|
2632
|
-
url: string;
|
|
2633
|
-
apiKey: string;
|
|
2634
|
-
version: JupiterApiVersion;
|
|
2635
|
-
};
|
|
2636
|
-
declare function getJupiterInstructionLayout(data: Buffer): JupiterInstructionLayout;
|
|
2637
|
-
declare function isJupiterBuildResponse(quoteResponse: JupiterQuoteResponse): quoteResponse is JupiterBuildResponse;
|
|
2638
|
-
/**
|
|
2639
|
-
* Whether the swap instruction was built for `user`, i.e. `user` is its user transfer authority.
|
|
2640
|
-
* Throws for an unknown Jupiter instruction discriminator.
|
|
2641
|
-
*/
|
|
2642
|
-
declare function isJupiterSwapInstructionForUser(swapInstruction: JupiterInstruction, user: PublicKey): boolean;
|
|
2643
2637
|
/**
|
|
2644
2638
|
* Get a Jupiter quote.
|
|
2645
2639
|
* - v1: `GET /swap/v1/quote`, returns the quote only.
|
|
@@ -2647,8 +2641,8 @@ declare function isJupiterSwapInstructionForUser(swapInstruction: JupiterInstruc
|
|
|
2647
2641
|
* (a `JupiterBuildResponse`), so no second request is needed for the swap.
|
|
2648
2642
|
* Returns null when the request fails.
|
|
2649
2643
|
*
|
|
2650
|
-
* `
|
|
2651
|
-
* give a much thinner route than a Jupiter UI quote
|
|
2644
|
+
* `params.queryParams` is forwarded to Jupiter as-is, and Jupiter uses its own default for every
|
|
2645
|
+
* parameter not given. A low `maxAccounts` can give a much thinner route than a Jupiter UI quote.
|
|
2652
2646
|
* `slippageBps` only bounds execution against this quote. It does not mean `outAmount` is a fair
|
|
2653
2647
|
* price for the input size, so validate the output, price impact or simulated token balance
|
|
2654
2648
|
* changes before sending.
|
|
@@ -2663,35 +2657,17 @@ declare function getJupiterQuote(params: GetJupiterQuoteParams, config?: ZapConf
|
|
|
2663
2657
|
* Throws when the request fails, or under v2 when `quoteResponse` has no swap instructions built for `userPublicKey`.
|
|
2664
2658
|
*/
|
|
2665
2659
|
declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: JupiterQuoteResponse, config?: ZapConfig): Promise<JupiterSwapInstructions>;
|
|
2666
|
-
/**
|
|
2667
|
-
* Build lookup table accounts from Jupiter v2's `addressesByLookupTableAddress` without an RPC call.
|
|
2668
|
-
* Only `key` and `state.addresses` are real. The other state fields are placeholders, because
|
|
2669
|
-
* `compileToV0Message` does not read them, so `isActive()` on the result does not reflect the chain.
|
|
2670
|
-
*/
|
|
2671
|
-
declare function toAddressLookupTableAccounts(addressesByLookupTableAddress: Record<string, string[]> | null): AddressLookupTableAccount[];
|
|
2672
|
-
/**
|
|
2673
|
-
* Fetch lookup table accounts by address with one RPC call. Used for Jupiter v1, which returns
|
|
2674
|
-
* only `addressLookupTableAddresses`.
|
|
2675
|
-
* Throws when a table does not exist or is not owned by the address lookup table program.
|
|
2676
|
-
*/
|
|
2677
|
-
declare function fetchAddressLookupTableAccounts(connection: Connection, addresses: string[]): Promise<AddressLookupTableAccount[]>;
|
|
2678
|
-
/** Merge lookup table lists, keeping the first occurrence of each table key. */
|
|
2679
|
-
declare function mergeAddressLookupTableAccounts(...lists: AddressLookupTableAccount[][]): AddressLookupTableAccount[];
|
|
2680
|
-
/**
|
|
2681
|
-
* Resolve the lookup tables a Jupiter swap instruction needs.
|
|
2682
|
-
* - v2 (`addressesByLookupTableAddress`): built from the response, no RPC call.
|
|
2683
|
-
* - v1 (`addressLookupTableAddresses` only): fetched with one RPC call.
|
|
2684
|
-
* Returns an empty array when the response carries neither.
|
|
2685
|
-
*/
|
|
2686
|
-
declare function getJupiterAddressLookupTableAccounts(connection: Connection, response: JupiterAddressLookupTableFields): Promise<AddressLookupTableAccount[]>;
|
|
2687
2660
|
/**
|
|
2688
2661
|
* Get the Jupiter swap instruction for swapping `amount` of `inputMint` to `outputMint`, and the lookup tables it uses.
|
|
2689
2662
|
* When `jupiterQuoteResponse` is given it is executed as is, and it must be a quote for `amount` by `user`.
|
|
2690
|
-
* Otherwise a new quote is fetched with `
|
|
2663
|
+
* Otherwise a new quote is fetched with `slippageBps`, which `jupiterQuoteOptions` can override.
|
|
2664
|
+
* `setupInstructions` holds all of Jupiter's setup instructions. Their token account create instructions must run
|
|
2665
|
+
* before the swap. The rest wrap SOL, which the zap does itself.
|
|
2691
2666
|
* Throws when the quote does not match the swap, or when the quote, swap instruction or lookup tables cannot be fetched.
|
|
2692
2667
|
*/
|
|
2693
|
-
declare function buildJupiterSwapTransaction(connection: Connection, user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN,
|
|
2668
|
+
declare function buildJupiterSwapTransaction(connection: Connection, user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, slippageBps: number, jupiterQuoteResponse?: JupiterQuoteResponse, config?: ZapConfig, jupiterQuoteOptions?: JupiterQueryParams): Promise<{
|
|
2694
2669
|
instruction: TransactionInstruction;
|
|
2670
|
+
setupInstructions: TransactionInstruction[];
|
|
2695
2671
|
addressLookupTableAccounts: AddressLookupTableAccount[];
|
|
2696
2672
|
quoteResponse: JupiterQuoteResponse;
|
|
2697
2673
|
}>;
|
|
@@ -2729,7 +2705,6 @@ declare function deriveDlmmEventAuthority(): PublicKey;
|
|
|
2729
2705
|
declare function getTokenProgramFromMint(connection: Connection, mint: PublicKey): Promise<PublicKey>;
|
|
2730
2706
|
declare function convertLamportsToUiAmount(amount: Decimal, decimals: number): Decimal;
|
|
2731
2707
|
declare function convertUiAmountToLamports(amount: Decimal, decimals: number): Decimal;
|
|
2732
|
-
declare function filterOutComputeBudgetInstructions(instructions: TransactionInstruction[]): TransactionInstruction[];
|
|
2733
2708
|
|
|
2734
2709
|
/**
|
|
2735
2710
|
* Get or create a token account
|
|
@@ -2823,7 +2798,7 @@ declare function getExtraAccountMetasForTransferHook(connection: Connection, min
|
|
|
2823
2798
|
* @param params.maxDeltaId - Maximum bin delta from active bin
|
|
2824
2799
|
* @param params.strategy - Strategy type for the position
|
|
2825
2800
|
* @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
|
|
2826
|
-
* @param params.jupiterQuoteOptions - Optional Jupiter
|
|
2801
|
+
* @param params.jupiterQuoteOptions - Optional Jupiter query parameters, see `GetJupiterQuoteParams.queryParams`
|
|
2827
2802
|
* @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
|
|
2828
2803
|
* @returns IndirectSwapEstimate with swap details and post-swap token amounts
|
|
2829
2804
|
* @throws if inputTokenMint matches any token in the DLMM pool
|
|
@@ -2846,7 +2821,7 @@ declare function estimateDlmmIndirectSwap({ user, amountIn, inputTokenMint, lbPa
|
|
|
2846
2821
|
* @param params.maxDeltaId - Maximum bin delta from active bin
|
|
2847
2822
|
* @param params.strategy - Strategy type for the position
|
|
2848
2823
|
* @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
|
|
2849
|
-
* @param params.jupiterQuoteOptions - Optional Jupiter
|
|
2824
|
+
* @param params.jupiterQuoteOptions - Optional Jupiter query parameters, see `GetJupiterQuoteParams.queryParams`
|
|
2850
2825
|
* @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
|
|
2851
2826
|
* @returns DirectSwapEstimate with swap details and post-swap token amounts
|
|
2852
2827
|
* @throws if failed to get both Jupiter and DLMM swap quotes
|
|
@@ -2866,7 +2841,7 @@ declare function estimateDlmmDirectSwap({ user, amountIn, inputTokenMint, lbPair
|
|
|
2866
2841
|
* @param params.minDeltaId - Minimum bin delta from active bin
|
|
2867
2842
|
* @param params.maxDeltaId - Maximum bin delta from active bin
|
|
2868
2843
|
* @param params.strategy - Strategy type for the position
|
|
2869
|
-
* @param params.jupiterQuoteOptions - Optional Jupiter
|
|
2844
|
+
* @param params.jupiterQuoteOptions - Optional Jupiter query parameters, see `GetJupiterQuoteParams.queryParams`
|
|
2870
2845
|
* @param params.config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
|
|
2871
2846
|
* @returns DirectSwapEstimate with swap details and post-swap token amounts
|
|
2872
2847
|
* @throws if failed to get both Jupiter and DLMM swap quotes
|
|
@@ -2893,21 +2868,15 @@ declare const AccountsType: {
|
|
|
2893
2868
|
declare const DLMM_SWAP_DISCRIMINATOR: number[];
|
|
2894
2869
|
declare const AMOUNT_IN_DLMM_OFFSET = 8;
|
|
2895
2870
|
/**
|
|
2896
|
-
* @deprecated
|
|
2871
|
+
* @deprecated Only correct for the `route` and `shared_accounts_route` Jupiter instructions. The offset depends on the instruction variant, and the SDK finds it for each one itself.
|
|
2897
2872
|
* Offset for amount_in in reverse order of jupiter Route instruction data:
|
|
2898
2873
|
* amount_in(u64) + quoted_out_amount(64) + slippage_bps(u16) + platform_fee_bps(u8) = 19 bytes
|
|
2899
2874
|
*/
|
|
2900
2875
|
declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
|
|
2901
|
-
declare const JUP_V6_ROUTE_DISCRIMINATOR: number[];
|
|
2902
|
-
declare const JUP_V6_SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR: number[];
|
|
2903
|
-
declare const JUP_V6_ROUTE_V2_DISCRIMINATOR: number[];
|
|
2904
|
-
declare const JUP_V6_SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR: number[];
|
|
2905
|
-
declare const JUPITER_INSTRUCTION_LAYOUTS: Record<string, JupiterInstructionLayout>;
|
|
2906
2876
|
declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
|
|
2907
2877
|
declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
|
|
2908
2878
|
declare const DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
|
|
2909
2879
|
declare const DEFAULT_JUPITER_API_VERSION = JupiterApiVersion.V2;
|
|
2910
|
-
declare const DEFAULT_JUPITER_QUOTE_OPTIONS: Required<Omit<JupiterQuoteOptions, "additionalQueryParams">>;
|
|
2911
2880
|
|
|
2912
2881
|
var address = "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz";
|
|
2913
2882
|
var metadata = {
|
|
@@ -4745,4 +4714,4 @@ var idl = {
|
|
|
4745
4714
|
constants: constants
|
|
4746
4715
|
};
|
|
4747
4716
|
|
|
4748
|
-
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DEFAULT_JUPITER_API_URL, DEFAULT_JUPITER_API_VERSION,
|
|
4717
|
+
export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DEFAULT_JUPITER_API_URL, DEFAULT_JUPITER_API_VERSION, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, type DlmmDirectEstimateResult, type DlmmDirectRebalanceEstimate, type DlmmDirectRebalanceEstimateContext, type DlmmDirectSwapEstimate, type DlmmDirectSwapEstimateContext, DlmmDirectSwapQuoteRoute, type DlmmIndirectSwapEstimate, type DlmmIndirectSwapEstimateContext, type DlmmIndirectSwapEstimateResult, DlmmSingleSided, DlmmSwapType, type EstimateDlmmDirectSwapParams, type EstimateDlmmIndirectSwapParams, type EstimateDlmmRebalanceSwapParams, type GetJupAndDammV2QuotesParams, type GetJupiterQuoteParams, type GetZapInDammV2DirectPoolParams, type GetZapInDammV2IndirectPoolParams, type GetZapInDlmmDirectParams, type GetZapInDlmmIndirectParams, JUP_V6_PROGRAM_ID, type JupiterAddressLookupTableFields, JupiterApiVersion, type JupiterBlockhashWithMetadata, type JupiterBuildResponse, type JupiterInstruction, type JupiterInstructionLayout, type JupiterQueryParams, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, type JupiterSwapInstructions, MEMO_PROGRAM_ID, type ProgramStrategyType, type RebalanceDlmmPositionParams, type RebalanceDlmmPositionResponse, SwapExternalType, type SwapQuoteResult, ZAP_PROGRAM_ID, Zap, type ZapConfig, idl as ZapIdl, type ZapInDammV2DirectPoolParam, type ZapInDammV2IndirectPoolParam, ZapInDammV2PoolSwapRoute, type ZapInDlmmDirectPoolParam, type ZapInDlmmIndirectPoolParam, type ZapInstructionsResponse, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, type Zap$1 as ZapTypes, buildJupiterSwapTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDlmmDirectSwap, estimateDlmmIndirectSwap, estimateDlmmRebalanceSwap, filterOutCloseSplTokenAccountInstructions, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, isSingleSidedA, isSingleSidedB, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };
|