@meteora-ag/zap-sdk 1.3.1 → 2.0.0-rc.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.js CHANGED
@@ -75,12 +75,20 @@ __export(index_exports, {
75
75
  DAMM_V2_PROGRAM_ID: () => DAMM_V2_PROGRAM_ID,
76
76
  DAMM_V2_SWAP_DISCRIMINATOR: () => DAMM_V2_SWAP_DISCRIMINATOR,
77
77
  DEFAULT_JUPITER_API_URL: () => DEFAULT_JUPITER_API_URL,
78
+ DEFAULT_JUPITER_API_VERSION: () => DEFAULT_JUPITER_API_VERSION,
79
+ DEFAULT_JUPITER_QUOTE_OPTIONS: () => DEFAULT_JUPITER_QUOTE_OPTIONS,
78
80
  DLMM_PROGRAM_ID: () => DLMM_PROGRAM_ID,
79
81
  DLMM_SWAP_DISCRIMINATOR: () => DLMM_SWAP_DISCRIMINATOR,
80
82
  DlmmDirectSwapQuoteRoute: () => DlmmDirectSwapQuoteRoute,
81
83
  DlmmSingleSided: () => DlmmSingleSided,
82
84
  DlmmSwapType: () => DlmmSwapType,
85
+ JUPITER_INSTRUCTION_LAYOUTS: () => JUPITER_INSTRUCTION_LAYOUTS,
83
86
  JUP_V6_PROGRAM_ID: () => JUP_V6_PROGRAM_ID,
87
+ JUP_V6_ROUTE_DISCRIMINATOR: () => JUP_V6_ROUTE_DISCRIMINATOR,
88
+ JUP_V6_ROUTE_V2_DISCRIMINATOR: () => JUP_V6_ROUTE_V2_DISCRIMINATOR,
89
+ JUP_V6_SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR: () => JUP_V6_SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR,
90
+ JUP_V6_SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR: () => JUP_V6_SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR,
91
+ JupiterApiVersion: () => JupiterApiVersion,
84
92
  MEMO_PROGRAM_ID: () => MEMO_PROGRAM_ID,
85
93
  SwapExternalType: () => SwapExternalType,
86
94
  ZAP_PROGRAM_ID: () => ZAP_PROGRAM_ID,
@@ -100,13 +108,17 @@ __export(index_exports, {
100
108
  estimateDlmmDirectSwap: () => estimateDlmmDirectSwap,
101
109
  estimateDlmmIndirectSwap: () => estimateDlmmIndirectSwap,
102
110
  estimateDlmmRebalanceSwap: () => estimateDlmmRebalanceSwap,
111
+ fetchAddressLookupTableAccounts: () => fetchAddressLookupTableAccounts,
103
112
  filterOutCloseSplTokenAccountInstructions: () => filterOutCloseSplTokenAccountInstructions,
113
+ filterOutComputeBudgetInstructions: () => filterOutComputeBudgetInstructions,
104
114
  getBinArrayBitmapExtension: () => getBinArrayBitmapExtension,
105
115
  getBitFromBinArrayIndexInBitmapExtension: () => getBitFromBinArrayIndexInBitmapExtension,
106
116
  getDammV2Pool: () => getDammV2Pool,
107
117
  getDammV2RemainingAccounts: () => getDammV2RemainingAccounts,
108
118
  getDlmmRemainingAccounts: () => getDlmmRemainingAccounts,
109
119
  getExtraAccountMetasForTransferHook: () => getExtraAccountMetasForTransferHook,
120
+ getJupiterAddressLookupTableAccounts: () => getJupiterAddressLookupTableAccounts,
121
+ getJupiterInstructionLayout: () => getJupiterInstructionLayout,
110
122
  getJupiterQuote: () => getJupiterQuote,
111
123
  getJupiterSwapInstruction: () => getJupiterSwapInstruction,
112
124
  getLbPairState: () => getLbPairState,
@@ -114,8 +126,13 @@ __export(index_exports, {
114
126
  getOrCreateATAInstruction: () => getOrCreateATAInstruction,
115
127
  getTokenAccountBalance: () => getTokenAccountBalance,
116
128
  getTokenProgramFromMint: () => getTokenProgramFromMint,
129
+ isJupiterBuildResponse: () => isJupiterBuildResponse,
130
+ isJupiterSwapInstructionForUser: () => isJupiterSwapInstructionForUser,
117
131
  isSingleSidedA: () => isSingleSidedA,
118
132
  isSingleSidedB: () => isSingleSidedB,
133
+ mergeAddressLookupTableAccounts: () => mergeAddressLookupTableAccounts,
134
+ resolveJupiterConfig: () => resolveJupiterConfig,
135
+ toAddressLookupTableAccounts: () => toAddressLookupTableAccounts,
119
136
  toProgramStrategyType: () => toProgramStrategyType,
120
137
  unwrapSOLInstruction: () => unwrapSOLInstruction,
121
138
  wrapSOLInstruction: () => wrapSOLInstruction
@@ -125,21 +142,30 @@ module.exports = __toCommonJS(index_exports);
125
142
  // src/zap.ts
126
143
  var import_web38 = require("@solana/web3.js");
127
144
  var import_invariant2 = __toESM(require("invariant"));
128
- var import_anchor = require("@coral-xyz/anchor");
145
+ var import_core = require("@anchor-lang/core");
129
146
 
130
147
  // src/idl/zap/idl.json
131
148
  var idl_default = {
132
149
  address: "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz",
133
150
  metadata: {
134
151
  name: "zap",
135
- version: "0.2.0",
152
+ version: "0.2.3",
136
153
  spec: "0.1.0",
137
154
  description: "Created with Anchor"
138
155
  },
139
156
  instructions: [
140
157
  {
141
158
  name: "close_ledger_account",
142
- discriminator: [189, 122, 172, 13, 122, 54, 54, 51],
159
+ discriminator: [
160
+ 189,
161
+ 122,
162
+ 172,
163
+ 13,
164
+ 122,
165
+ 54,
166
+ 54,
167
+ 51
168
+ ],
143
169
  accounts: [
144
170
  {
145
171
  name: "ledger",
@@ -148,7 +174,9 @@ var idl_default = {
148
174
  {
149
175
  name: "owner",
150
176
  signer: true,
151
- relations: ["ledger"]
177
+ relations: [
178
+ "ledger"
179
+ ]
152
180
  },
153
181
  {
154
182
  name: "rent_receiver",
@@ -160,7 +188,16 @@ var idl_default = {
160
188
  },
161
189
  {
162
190
  name: "initialize_ledger_account",
163
- discriminator: [120, 69, 30, 74, 76, 242, 153, 162],
191
+ discriminator: [
192
+ 120,
193
+ 69,
194
+ 30,
195
+ 74,
196
+ 76,
197
+ 242,
198
+ 153,
199
+ 162
200
+ ],
164
201
  accounts: [
165
202
  {
166
203
  name: "ledger",
@@ -169,7 +206,19 @@ var idl_default = {
169
206
  seeds: [
170
207
  {
171
208
  kind: "const",
172
- value: [117, 115, 101, 114, 95, 108, 101, 100, 103, 101, 114]
209
+ value: [
210
+ 117,
211
+ 115,
212
+ 101,
213
+ 114,
214
+ 95,
215
+ 108,
216
+ 101,
217
+ 100,
218
+ 103,
219
+ 101,
220
+ 114
221
+ ]
173
222
  },
174
223
  {
175
224
  kind: "account",
@@ -196,7 +245,16 @@ var idl_default = {
196
245
  },
197
246
  {
198
247
  name: "set_ledger_balance",
199
- discriminator: [131, 49, 240, 17, 228, 248, 156, 54],
248
+ discriminator: [
249
+ 131,
250
+ 49,
251
+ 240,
252
+ 17,
253
+ 228,
254
+ 248,
255
+ 156,
256
+ 54
257
+ ],
200
258
  accounts: [
201
259
  {
202
260
  name: "ledger",
@@ -205,7 +263,9 @@ var idl_default = {
205
263
  {
206
264
  name: "owner",
207
265
  signer: true,
208
- relations: ["ledger"]
266
+ relations: [
267
+ "ledger"
268
+ ]
209
269
  }
210
270
  ],
211
271
  args: [
@@ -221,7 +281,16 @@ var idl_default = {
221
281
  },
222
282
  {
223
283
  name: "update_ledger_balance_after_swap",
224
- discriminator: [59, 206, 173, 232, 94, 57, 174, 202],
284
+ discriminator: [
285
+ 59,
286
+ 206,
287
+ 173,
288
+ 232,
289
+ 94,
290
+ 57,
291
+ 174,
292
+ 202
293
+ ],
225
294
  accounts: [
226
295
  {
227
296
  name: "ledger",
@@ -233,7 +302,9 @@ var idl_default = {
233
302
  {
234
303
  name: "owner",
235
304
  signer: true,
236
- relations: ["ledger"]
305
+ relations: [
306
+ "ledger"
307
+ ]
237
308
  }
238
309
  ],
239
310
  args: [
@@ -253,7 +324,16 @@ var idl_default = {
253
324
  },
254
325
  {
255
326
  name: "zap_in_damm_v2",
256
- discriminator: [243, 243, 119, 52, 199, 44, 154, 186],
327
+ discriminator: [
328
+ 243,
329
+ 243,
330
+ 119,
331
+ 52,
332
+ 199,
333
+ 44,
334
+ 154,
335
+ 186
336
+ ],
257
337
  accounts: [
258
338
  {
259
339
  name: "ledger",
@@ -297,9 +377,13 @@ var idl_default = {
297
377
  },
298
378
  {
299
379
  name: "owner",
300
- docs: ["owner of position"],
380
+ docs: [
381
+ "owner of position"
382
+ ],
301
383
  signer: true,
302
- relations: ["ledger"]
384
+ relations: [
385
+ "ledger"
386
+ ]
303
387
  },
304
388
  {
305
389
  name: "token_a_program"
@@ -328,7 +412,16 @@ var idl_default = {
328
412
  },
329
413
  {
330
414
  name: "zap_in_dlmm_for_initialized_position",
331
- discriminator: [184, 71, 198, 231, 129, 110, 193, 67],
415
+ discriminator: [
416
+ 184,
417
+ 71,
418
+ 198,
419
+ 231,
420
+ 129,
421
+ 110,
422
+ 193,
423
+ 67
424
+ ],
332
425
  accounts: [
333
426
  {
334
427
  name: "ledger",
@@ -336,7 +429,9 @@ var idl_default = {
336
429
  },
337
430
  {
338
431
  name: "lb_pair",
339
- docs: ["lb pair"],
432
+ docs: [
433
+ "lb pair"
434
+ ],
340
435
  writable: true
341
436
  },
342
437
  {
@@ -376,9 +471,13 @@ var idl_default = {
376
471
  },
377
472
  {
378
473
  name: "owner",
379
- docs: ["owner of position"],
474
+ docs: [
475
+ "owner of position"
476
+ ],
380
477
  signer: true,
381
- relations: ["ledger"]
478
+ relations: [
479
+ "ledger"
480
+ ]
382
481
  },
383
482
  {
384
483
  name: "rent_payer",
@@ -442,7 +541,16 @@ var idl_default = {
442
541
  },
443
542
  {
444
543
  name: "zap_in_dlmm_for_uninitialized_position",
445
- discriminator: [59, 220, 182, 27, 254, 253, 2, 232],
544
+ discriminator: [
545
+ 59,
546
+ 220,
547
+ 182,
548
+ 27,
549
+ 254,
550
+ 253,
551
+ 2,
552
+ 232
553
+ ],
446
554
  accounts: [
447
555
  {
448
556
  name: "ledger",
@@ -450,7 +558,9 @@ var idl_default = {
450
558
  },
451
559
  {
452
560
  name: "lb_pair",
453
- docs: ["lb pair"],
561
+ docs: [
562
+ "lb pair"
563
+ ],
454
564
  writable: true
455
565
  },
456
566
  {
@@ -495,9 +605,13 @@ var idl_default = {
495
605
  },
496
606
  {
497
607
  name: "owner",
498
- docs: ["owner of position"],
608
+ docs: [
609
+ "owner of position"
610
+ ],
499
611
  signer: true,
500
- relations: ["ledger"]
612
+ relations: [
613
+ "ledger"
614
+ ]
501
615
  },
502
616
  {
503
617
  name: "rent_payer",
@@ -561,7 +675,16 @@ var idl_default = {
561
675
  },
562
676
  {
563
677
  name: "zap_out",
564
- discriminator: [155, 108, 185, 112, 104, 210, 161, 64],
678
+ discriminator: [
679
+ 155,
680
+ 108,
681
+ 185,
682
+ 112,
683
+ 104,
684
+ 210,
685
+ 161,
686
+ 64
687
+ ],
565
688
  accounts: [
566
689
  {
567
690
  name: "user_token_in_account",
@@ -584,17 +707,18 @@ var idl_default = {
584
707
  }
585
708
  ],
586
709
  accounts: [
587
- {
588
- name: "LbPair",
589
- discriminator: [33, 11, 49, 98, 181, 101, 177, 13]
590
- },
591
- {
592
- name: "Pool",
593
- discriminator: [241, 154, 109, 4, 17, 177, 109, 188]
594
- },
595
710
  {
596
711
  name: "UserLedger",
597
- discriminator: [185, 84, 101, 128, 8, 6, 160, 83]
712
+ discriminator: [
713
+ 185,
714
+ 84,
715
+ 101,
716
+ 128,
717
+ 8,
718
+ 6,
719
+ 160,
720
+ 83
721
+ ]
598
722
  }
599
723
  ],
600
724
  errors: [
@@ -661,7 +785,9 @@ var idl_default = {
661
785
  },
662
786
  {
663
787
  name: "TransferHookMultiReward",
664
- fields: ["u8"]
788
+ fields: [
789
+ "u8"
790
+ ]
665
791
  },
666
792
  {
667
793
  name: "TransferHookReferral"
@@ -670,7 +796,7 @@ var idl_default = {
670
796
  }
671
797
  },
672
798
  {
673
- name: "BaseFeeStruct",
799
+ name: "BaseFeeInfo",
674
800
  serialization: "bytemuck",
675
801
  repr: {
676
802
  kind: "c"
@@ -679,33 +805,34 @@ var idl_default = {
679
805
  kind: "struct",
680
806
  fields: [
681
807
  {
682
- name: "cliff_fee_numerator",
683
- type: "u64"
684
- },
685
- {
686
- name: "base_fee_mode",
687
- type: "u8"
688
- },
689
- {
690
- name: "padding_0",
808
+ name: "data",
691
809
  type: {
692
- array: ["u8", 5]
810
+ array: [
811
+ "u8",
812
+ 32
813
+ ]
693
814
  }
694
- },
695
- {
696
- name: "first_factor",
697
- type: "u16"
698
- },
815
+ }
816
+ ]
817
+ }
818
+ },
819
+ {
820
+ name: "BaseFeeStruct",
821
+ serialization: "bytemuck",
822
+ repr: {
823
+ kind: "c"
824
+ },
825
+ type: {
826
+ kind: "struct",
827
+ fields: [
699
828
  {
700
- name: "second_factor",
829
+ name: "base_fee_info",
701
830
  type: {
702
- array: ["u8", 8]
831
+ defined: {
832
+ name: "BaseFeeInfo"
833
+ }
703
834
  }
704
835
  },
705
- {
706
- name: "third_factor",
707
- type: "u64"
708
- },
709
836
  {
710
837
  name: "padding_1",
711
838
  type: "u64"
@@ -729,7 +856,10 @@ var idl_default = {
729
856
  {
730
857
  name: "padding",
731
858
  type: {
732
- array: ["u8", 7]
859
+ array: [
860
+ "u8",
861
+ 7
862
+ ]
733
863
  }
734
864
  },
735
865
  {
@@ -807,13 +937,19 @@ var idl_default = {
807
937
  {
808
938
  name: "bump_seed",
809
939
  type: {
810
- array: ["u8", 1]
940
+ array: [
941
+ "u8",
942
+ 1
943
+ ]
811
944
  }
812
945
  },
813
946
  {
814
947
  name: "bin_step_seed",
815
948
  type: {
816
- array: ["u8", 2]
949
+ array: [
950
+ "u8",
951
+ 2
952
+ ]
817
953
  }
818
954
  },
819
955
  {
@@ -839,7 +975,10 @@ var idl_default = {
839
975
  {
840
976
  name: "base_factor_seed",
841
977
  type: {
842
- array: ["u8", 2]
978
+ array: [
979
+ "u8",
980
+ 2
981
+ ]
843
982
  }
844
983
  },
845
984
  {
@@ -877,7 +1016,10 @@ var idl_default = {
877
1016
  {
878
1017
  name: "_padding_1",
879
1018
  type: {
880
- array: ["u8", 32]
1019
+ array: [
1020
+ "u8",
1021
+ 32
1022
+ ]
881
1023
  }
882
1024
  },
883
1025
  {
@@ -900,7 +1042,10 @@ var idl_default = {
900
1042
  {
901
1043
  name: "bin_array_bitmap",
902
1044
  type: {
903
- array: ["u64", 16]
1045
+ array: [
1046
+ "u64",
1047
+ 16
1048
+ ]
904
1049
  }
905
1050
  },
906
1051
  {
@@ -910,7 +1055,10 @@ var idl_default = {
910
1055
  {
911
1056
  name: "_padding_2",
912
1057
  type: {
913
- array: ["u8", 32]
1058
+ array: [
1059
+ "u8",
1060
+ 32
1061
+ ]
914
1062
  }
915
1063
  },
916
1064
  {
@@ -932,7 +1080,10 @@ var idl_default = {
932
1080
  {
933
1081
  name: "_padding_3",
934
1082
  type: {
935
- array: ["u8", 8]
1083
+ array: [
1084
+ "u8",
1085
+ 8
1086
+ ]
936
1087
  }
937
1088
  },
938
1089
  {
@@ -951,10 +1102,17 @@ var idl_default = {
951
1102
  name: "token_mint_y_program_flag",
952
1103
  type: "u8"
953
1104
  },
1105
+ {
1106
+ name: "version",
1107
+ type: "u8"
1108
+ },
954
1109
  {
955
1110
  name: "_reserved",
956
1111
  type: {
957
- array: ["u8", 22]
1112
+ array: [
1113
+ "u8",
1114
+ 21
1115
+ ]
958
1116
  }
959
1117
  }
960
1118
  ]
@@ -971,7 +1129,9 @@ var idl_default = {
971
1129
  fields: [
972
1130
  {
973
1131
  name: "pool_fees",
974
- docs: ["Pool fee"],
1132
+ docs: [
1133
+ "Pool fee"
1134
+ ],
975
1135
  type: {
976
1136
  defined: {
977
1137
  name: "PoolFeesStruct"
@@ -980,22 +1140,30 @@ var idl_default = {
980
1140
  },
981
1141
  {
982
1142
  name: "token_a_mint",
983
- docs: ["token a mint"],
1143
+ docs: [
1144
+ "token a mint"
1145
+ ],
984
1146
  type: "pubkey"
985
1147
  },
986
1148
  {
987
1149
  name: "token_b_mint",
988
- docs: ["token b mint"],
1150
+ docs: [
1151
+ "token b mint"
1152
+ ],
989
1153
  type: "pubkey"
990
1154
  },
991
1155
  {
992
1156
  name: "token_a_vault",
993
- docs: ["token a vault"],
1157
+ docs: [
1158
+ "token a vault"
1159
+ ],
994
1160
  type: "pubkey"
995
1161
  },
996
1162
  {
997
1163
  name: "token_b_vault",
998
- docs: ["token b vault"],
1164
+ docs: [
1165
+ "token b vault"
1166
+ ],
999
1167
  type: "pubkey"
1000
1168
  },
1001
1169
  {
@@ -1006,17 +1174,26 @@ var idl_default = {
1006
1174
  type: "pubkey"
1007
1175
  },
1008
1176
  {
1009
- name: "partner",
1010
- docs: ["partner"],
1011
- type: "pubkey"
1177
+ name: "padding_0",
1178
+ docs: [
1179
+ "padding, previously partner pubkey, be careful when using this field"
1180
+ ],
1181
+ type: {
1182
+ array: [
1183
+ "u8",
1184
+ 32
1185
+ ]
1186
+ }
1012
1187
  },
1013
1188
  {
1014
1189
  name: "liquidity",
1015
- docs: ["liquidity share"],
1190
+ docs: [
1191
+ "liquidity share"
1192
+ ],
1016
1193
  type: "u128"
1017
1194
  },
1018
1195
  {
1019
- name: "_padding",
1196
+ name: "padding_1",
1020
1197
  docs: [
1021
1198
  "padding, previous reserve amount, be careful to use that field"
1022
1199
  ],
@@ -1024,100 +1201,128 @@ var idl_default = {
1024
1201
  },
1025
1202
  {
1026
1203
  name: "protocol_a_fee",
1027
- docs: ["protocol a fee"],
1204
+ docs: [
1205
+ "protocol a fee"
1206
+ ],
1028
1207
  type: "u64"
1029
1208
  },
1030
1209
  {
1031
1210
  name: "protocol_b_fee",
1032
- docs: ["protocol b fee"],
1033
- type: "u64"
1034
- },
1035
- {
1036
- name: "partner_a_fee",
1037
- docs: ["partner a fee"],
1211
+ docs: [
1212
+ "protocol b fee"
1213
+ ],
1038
1214
  type: "u64"
1039
1215
  },
1040
1216
  {
1041
- name: "partner_b_fee",
1042
- docs: ["partner b fee"],
1043
- type: "u64"
1217
+ name: "padding_2",
1218
+ type: "u128"
1044
1219
  },
1045
1220
  {
1046
1221
  name: "sqrt_min_price",
1047
- docs: ["min price"],
1222
+ docs: [
1223
+ "min price"
1224
+ ],
1048
1225
  type: "u128"
1049
1226
  },
1050
1227
  {
1051
1228
  name: "sqrt_max_price",
1052
- docs: ["max price"],
1229
+ docs: [
1230
+ "max price"
1231
+ ],
1053
1232
  type: "u128"
1054
1233
  },
1055
1234
  {
1056
1235
  name: "sqrt_price",
1057
- docs: ["current price"],
1236
+ docs: [
1237
+ "current price"
1238
+ ],
1058
1239
  type: "u128"
1059
1240
  },
1060
1241
  {
1061
1242
  name: "activation_point",
1062
- docs: ["Activation point, can be slot or timestamp"],
1243
+ docs: [
1244
+ "Activation point, can be slot or timestamp"
1245
+ ],
1063
1246
  type: "u64"
1064
1247
  },
1065
1248
  {
1066
1249
  name: "activation_type",
1067
- docs: ["Activation type, 0 means by slot, 1 means by timestamp"],
1250
+ docs: [
1251
+ "Activation type, 0 means by slot, 1 means by timestamp"
1252
+ ],
1068
1253
  type: "u8"
1069
1254
  },
1070
1255
  {
1071
1256
  name: "pool_status",
1072
- docs: ["pool status, 0: enable, 1 disable"],
1257
+ docs: [
1258
+ "pool status, 0: enable, 1 disable"
1259
+ ],
1073
1260
  type: "u8"
1074
1261
  },
1075
1262
  {
1076
1263
  name: "token_a_flag",
1077
- docs: ["token a flag"],
1264
+ docs: [
1265
+ "token a flag"
1266
+ ],
1078
1267
  type: "u8"
1079
1268
  },
1080
1269
  {
1081
1270
  name: "token_b_flag",
1082
- docs: ["token b flag"],
1271
+ docs: [
1272
+ "token b flag"
1273
+ ],
1083
1274
  type: "u8"
1084
1275
  },
1085
1276
  {
1086
1277
  name: "collect_fee_mode",
1087
1278
  docs: [
1088
- "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b"
1279
+ "0 is collect fee in both token, 1 only collect fee only in token b"
1089
1280
  ],
1090
1281
  type: "u8"
1091
1282
  },
1092
1283
  {
1093
1284
  name: "pool_type",
1094
- docs: ["pool type"],
1285
+ docs: [
1286
+ "pool type"
1287
+ ],
1095
1288
  type: "u8"
1096
1289
  },
1097
1290
  {
1098
- name: "version",
1291
+ name: "fee_version",
1099
1292
  docs: [
1100
- "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
1293
+ "pool fee version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
1101
1294
  ],
1102
1295
  type: "u8"
1103
1296
  },
1104
1297
  {
1105
- name: "_padding_0",
1106
- docs: ["padding"],
1298
+ name: "padding_3",
1299
+ docs: [
1300
+ "padding"
1301
+ ],
1107
1302
  type: "u8"
1108
1303
  },
1109
1304
  {
1110
1305
  name: "fee_a_per_liquidity",
1111
- docs: ["cumulative"],
1306
+ docs: [
1307
+ "cumulative"
1308
+ ],
1112
1309
  type: {
1113
- array: ["u8", 32]
1310
+ array: [
1311
+ "u8",
1312
+ 32
1313
+ ]
1114
1314
  }
1115
1315
  },
1116
1316
  {
1117
1317
  name: "fee_b_per_liquidity",
1118
- docs: ["cumulative"],
1318
+ docs: [
1319
+ "cumulative"
1320
+ ],
1119
1321
  type: {
1120
- array: ["u8", 32]
1322
+ array: [
1323
+ "u8",
1324
+ 32
1325
+ ]
1121
1326
  }
1122
1327
  },
1123
1328
  {
@@ -1126,7 +1331,9 @@ var idl_default = {
1126
1331
  },
1127
1332
  {
1128
1333
  name: "metrics",
1129
- docs: ["metrics"],
1334
+ docs: [
1335
+ "metrics"
1336
+ ],
1130
1337
  type: {
1131
1338
  defined: {
1132
1339
  name: "PoolMetrics"
@@ -1135,19 +1342,61 @@ var idl_default = {
1135
1342
  },
1136
1343
  {
1137
1344
  name: "creator",
1138
- docs: ["pool creator"],
1345
+ docs: [
1346
+ "pool creator"
1347
+ ],
1139
1348
  type: "pubkey"
1140
1349
  },
1141
1350
  {
1142
- name: "_padding_1",
1143
- docs: ["Padding for further use"],
1351
+ name: "token_a_amount",
1352
+ docs: [
1353
+ "token a amount"
1354
+ ],
1355
+ type: "u64"
1356
+ },
1357
+ {
1358
+ name: "token_b_amount",
1359
+ docs: [
1360
+ "token b amount"
1361
+ ],
1362
+ type: "u64"
1363
+ },
1364
+ {
1365
+ name: "layout_version",
1366
+ docs: [
1367
+ "layout version: version 0: haven't track token_a_amount and token_b_amount, version 1: track token_a_amount and token_b_amount"
1368
+ ],
1369
+ type: "u8"
1370
+ },
1371
+ {
1372
+ name: "padding_4",
1373
+ docs: [
1374
+ "Padding for further use"
1375
+ ],
1376
+ type: {
1377
+ array: [
1378
+ "u8",
1379
+ 7
1380
+ ]
1381
+ }
1382
+ },
1383
+ {
1384
+ name: "padding_5",
1385
+ docs: [
1386
+ "Padding for further use"
1387
+ ],
1144
1388
  type: {
1145
- array: ["u64", 6]
1389
+ array: [
1390
+ "u64",
1391
+ 3
1392
+ ]
1146
1393
  }
1147
1394
  },
1148
1395
  {
1149
1396
  name: "reward_infos",
1150
- docs: ["Farming reward information"],
1397
+ docs: [
1398
+ "Farming reward information"
1399
+ ],
1151
1400
  type: {
1152
1401
  array: [
1153
1402
  {
@@ -1168,8 +1417,7 @@ var idl_default = {
1168
1417
  "Information regarding fee charges",
1169
1418
  "trading_fee = amount * trade_fee_numerator / denominator",
1170
1419
  "protocol_fee = trading_fee * protocol_fee_percentage / 100",
1171
- "referral_fee = protocol_fee * referral_percentage / 100",
1172
- "partner_fee = (protocol_fee - referral_fee) * partner_fee_percentage / denominator"
1420
+ "referral_fee = protocol_fee * referral_percentage / 100"
1173
1421
  ],
1174
1422
  serialization: "bytemuck",
1175
1423
  repr: {
@@ -1202,25 +1450,43 @@ var idl_default = {
1202
1450
  type: "u8"
1203
1451
  },
1204
1452
  {
1205
- name: "partner_fee_percent",
1206
- docs: ["partner fee"],
1453
+ name: "padding_0",
1454
+ docs: [
1455
+ "padding for future use"
1456
+ ],
1207
1457
  type: "u8"
1208
1458
  },
1209
1459
  {
1210
1460
  name: "referral_fee_percent",
1211
- docs: ["referral fee"],
1461
+ docs: [
1462
+ "referral fee"
1463
+ ],
1212
1464
  type: "u8"
1213
1465
  },
1214
1466
  {
1215
- name: "padding_0",
1216
- docs: ["padding"],
1467
+ name: "padding_1",
1468
+ docs: [
1469
+ "padding"
1470
+ ],
1217
1471
  type: {
1218
- array: ["u8", 5]
1472
+ array: [
1473
+ "u8",
1474
+ 3
1475
+ ]
1219
1476
  }
1220
1477
  },
1478
+ {
1479
+ name: "compounding_fee_bps",
1480
+ docs: [
1481
+ "compounding fee bps, only non-zero in CollectFeeMode::Compounding"
1482
+ ],
1483
+ type: "u16"
1484
+ },
1221
1485
  {
1222
1486
  name: "dynamic_fee",
1223
- docs: ["dynamic fee"],
1487
+ docs: [
1488
+ "dynamic fee"
1489
+ ],
1224
1490
  type: {
1225
1491
  defined: {
1226
1492
  name: "DynamicFeeStruct"
@@ -1228,11 +1494,8 @@ var idl_default = {
1228
1494
  }
1229
1495
  },
1230
1496
  {
1231
- name: "padding_1",
1232
- docs: ["padding"],
1233
- type: {
1234
- array: ["u64", 2]
1235
- }
1497
+ name: "init_sqrt_price",
1498
+ type: "u128"
1236
1499
  }
1237
1500
  ]
1238
1501
  }
@@ -1263,12 +1526,13 @@ var idl_default = {
1263
1526
  type: "u64"
1264
1527
  },
1265
1528
  {
1266
- name: "total_partner_a_fee",
1267
- type: "u64"
1268
- },
1269
- {
1270
- name: "total_partner_b_fee",
1271
- type: "u64"
1529
+ name: "padding_0",
1530
+ type: {
1531
+ array: [
1532
+ "u64",
1533
+ 2
1534
+ ]
1535
+ }
1272
1536
  },
1273
1537
  {
1274
1538
  name: "total_position",
@@ -1341,7 +1605,9 @@ var idl_default = {
1341
1605
  },
1342
1606
  {
1343
1607
  name: "StaticParameters",
1344
- docs: ["Parameter that set by the protocol"],
1608
+ docs: [
1609
+ "Parameter that set by the protocol"
1610
+ ],
1345
1611
  serialization: "bytemuck",
1346
1612
  repr: {
1347
1613
  kind: "c"
@@ -1389,10 +1655,21 @@ var idl_default = {
1389
1655
  name: "base_fee_power_factor",
1390
1656
  type: "u8"
1391
1657
  },
1658
+ {
1659
+ name: "function_type",
1660
+ type: "u8"
1661
+ },
1662
+ {
1663
+ name: "collect_fee_mode",
1664
+ type: "u8"
1665
+ },
1392
1666
  {
1393
1667
  name: "_padding",
1394
1668
  type: {
1395
- array: ["u8", 5]
1669
+ array: [
1670
+ "u8",
1671
+ 3
1672
+ ]
1396
1673
  }
1397
1674
  }
1398
1675
  ]
@@ -1441,7 +1718,9 @@ var idl_default = {
1441
1718
  },
1442
1719
  {
1443
1720
  name: "VariableParameters",
1444
- docs: ["Parameters that changes based on dynamic of the market"],
1721
+ docs: [
1722
+ "Parameters that changes based on dynamic of the market"
1723
+ ],
1445
1724
  serialization: "bytemuck",
1446
1725
  repr: {
1447
1726
  kind: "c"
@@ -1464,7 +1743,10 @@ var idl_default = {
1464
1743
  {
1465
1744
  name: "_padding",
1466
1745
  type: {
1467
- array: ["u8", 4]
1746
+ array: [
1747
+ "u8",
1748
+ 4
1749
+ ]
1468
1750
  }
1469
1751
  },
1470
1752
  {
@@ -1474,7 +1756,10 @@ var idl_default = {
1474
1756
  {
1475
1757
  name: "_padding_1",
1476
1758
  type: {
1477
- array: ["u8", 8]
1759
+ array: [
1760
+ "u8",
1761
+ 8
1762
+ ]
1478
1763
  }
1479
1764
  }
1480
1765
  ]
@@ -1522,70 +1807,96 @@ var idl_default = {
1522
1807
  fields: [
1523
1808
  {
1524
1809
  name: "initialized",
1525
- docs: ["Indicates if the reward has been initialized"],
1810
+ docs: [
1811
+ "Indicates if the reward has been initialized"
1812
+ ],
1526
1813
  type: "u8"
1527
1814
  },
1528
1815
  {
1529
1816
  name: "reward_token_flag",
1530
- docs: ["reward token flag"],
1817
+ docs: [
1818
+ "reward token flag"
1819
+ ],
1531
1820
  type: "u8"
1532
1821
  },
1533
1822
  {
1534
1823
  name: "_padding_0",
1535
- docs: ["padding"],
1824
+ docs: [
1825
+ "padding"
1826
+ ],
1536
1827
  type: {
1537
- array: ["u8", 6]
1828
+ array: [
1829
+ "u8",
1830
+ 6
1831
+ ]
1538
1832
  }
1539
1833
  },
1540
1834
  {
1541
- name: "_padding_1",
1835
+ name: "dead_liquidity_reward_checkpoint",
1542
1836
  docs: [
1543
- "Padding to ensure `reward_rate: u128` is 16-byte aligned"
1837
+ "Cumulative dead-liquidity reward (Compounding Pool only)"
1544
1838
  ],
1545
- type: {
1546
- array: ["u8", 8]
1547
- }
1839
+ type: "u64"
1548
1840
  },
1549
1841
  {
1550
1842
  name: "mint",
1551
- docs: ["Reward token mint."],
1843
+ docs: [
1844
+ "Reward token mint."
1845
+ ],
1552
1846
  type: "pubkey"
1553
1847
  },
1554
1848
  {
1555
1849
  name: "vault",
1556
- docs: ["Reward vault token account."],
1850
+ docs: [
1851
+ "Reward vault token account."
1852
+ ],
1557
1853
  type: "pubkey"
1558
1854
  },
1559
1855
  {
1560
1856
  name: "funder",
1561
- docs: ["Authority account that allows to fund rewards"],
1857
+ docs: [
1858
+ "Authority account that allows to fund rewards"
1859
+ ],
1562
1860
  type: "pubkey"
1563
1861
  },
1564
1862
  {
1565
1863
  name: "reward_duration",
1566
- docs: ["reward duration"],
1864
+ docs: [
1865
+ "reward duration"
1866
+ ],
1567
1867
  type: "u64"
1568
1868
  },
1569
1869
  {
1570
1870
  name: "reward_duration_end",
1571
- docs: ["reward duration end"],
1871
+ docs: [
1872
+ "reward duration end"
1873
+ ],
1572
1874
  type: "u64"
1573
1875
  },
1574
1876
  {
1575
1877
  name: "reward_rate",
1576
- docs: ["reward rate"],
1878
+ docs: [
1879
+ "reward rate"
1880
+ ],
1577
1881
  type: "u128"
1578
1882
  },
1579
1883
  {
1580
1884
  name: "reward_per_token_stored",
1581
- docs: ["Reward per token stored"],
1885
+ docs: [
1886
+ "Reward per token stored"
1887
+ ],
1582
1888
  type: {
1583
- array: ["u8", 32]
1889
+ array: [
1890
+ "u8",
1891
+ 32
1892
+ ]
1584
1893
  }
1585
1894
  },
1586
1895
  {
1587
1896
  name: "last_update_time",
1588
- docs: ["The last time reward states were updated."],
1897
+ docs: [
1898
+ "The last time reward states were updated."
1899
+ ],
1589
1900
  type: "u64"
1590
1901
  },
1591
1902
  {
@@ -1648,44 +1959,6 @@ var idl_default = {
1648
1959
  }
1649
1960
  ],
1650
1961
  constants: [
1651
- {
1652
- name: "DAMM_V2",
1653
- type: "pubkey",
1654
- value: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
1655
- },
1656
- {
1657
- name: "DAMM_V2_SWAP_DISC",
1658
- type: {
1659
- array: ["u8", 8]
1660
- },
1661
- value: "[248, 198, 158, 145, 225, 117, 135, 200]"
1662
- },
1663
- {
1664
- name: "DLMM_SWAP2_DISC",
1665
- type: {
1666
- array: ["u8", 8]
1667
- },
1668
- value: "[65, 75, 63, 76, 235, 91, 91, 136]"
1669
- },
1670
- {
1671
- name: "JUP_V6",
1672
- type: "pubkey",
1673
- value: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
1674
- },
1675
- {
1676
- name: "JUP_V6_ROUTE_DISC",
1677
- type: {
1678
- array: ["u8", 8]
1679
- },
1680
- value: "[229, 23, 203, 151, 122, 227, 173, 42]"
1681
- },
1682
- {
1683
- name: "JUP_V6_SHARED_ACCOUNT_ROUTE_DISC",
1684
- type: {
1685
- array: ["u8", 8]
1686
- },
1687
- value: "[193, 32, 155, 51, 65, 214, 156, 129]"
1688
- },
1689
1962
  {
1690
1963
  name: "MAX_BASIS_POINT",
1691
1964
  type: "u16",
@@ -1700,6 +1973,11 @@ var idl_default = {
1700
1973
  };
1701
1974
 
1702
1975
  // src/types.ts
1976
+ var JupiterApiVersion = /* @__PURE__ */ ((JupiterApiVersion3) => {
1977
+ JupiterApiVersion3["V1"] = "v1";
1978
+ JupiterApiVersion3["V2"] = "v2";
1979
+ return JupiterApiVersion3;
1980
+ })(JupiterApiVersion || {});
1703
1981
  var ZapInDammV2PoolSwapRoute = /* @__PURE__ */ ((ZapInDammV2PoolSwapRoute2) => {
1704
1982
  ZapInDammV2PoolSwapRoute2["Jupiter"] = "jupiter";
1705
1983
  ZapInDammV2PoolSwapRoute2["DammV2"] = "dammV2";
@@ -1770,6 +2048,68 @@ var AccountsType = {
1770
2048
  var DLMM_SWAP_DISCRIMINATOR = [65, 75, 63, 76, 235, 91, 91, 136];
1771
2049
  var AMOUNT_IN_DLMM_OFFSET = 8;
1772
2050
  var AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
2051
+ var JUP_V6_ROUTE_DISCRIMINATOR = [
2052
+ 229,
2053
+ 23,
2054
+ 203,
2055
+ 151,
2056
+ 122,
2057
+ 227,
2058
+ 173,
2059
+ 42
2060
+ ];
2061
+ var JUP_V6_SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR = [
2062
+ 193,
2063
+ 32,
2064
+ 155,
2065
+ 51,
2066
+ 65,
2067
+ 214,
2068
+ 156,
2069
+ 129
2070
+ ];
2071
+ var JUP_V6_ROUTE_V2_DISCRIMINATOR = [
2072
+ 187,
2073
+ 100,
2074
+ 250,
2075
+ 204,
2076
+ 49,
2077
+ 196,
2078
+ 175,
2079
+ 20
2080
+ ];
2081
+ var JUP_V6_SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR = [
2082
+ 209,
2083
+ 152,
2084
+ 83,
2085
+ 147,
2086
+ 124,
2087
+ 254,
2088
+ 216,
2089
+ 233
2090
+ ];
2091
+ var JUPITER_INSTRUCTION_LAYOUTS = {
2092
+ // route
2093
+ [Buffer.from(JUP_V6_ROUTE_DISCRIMINATOR).toString("hex")]: {
2094
+ amountInOffset: (dataLength) => dataLength - AMOUNT_IN_JUP_V6_REVERSE_OFFSET,
2095
+ userTransferAuthorityIndex: 1
2096
+ },
2097
+ // shared_accounts_route
2098
+ [Buffer.from(JUP_V6_SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR).toString("hex")]: {
2099
+ amountInOffset: (dataLength) => dataLength - AMOUNT_IN_JUP_V6_REVERSE_OFFSET,
2100
+ userTransferAuthorityIndex: 2
2101
+ },
2102
+ // route_v2
2103
+ [Buffer.from(JUP_V6_ROUTE_V2_DISCRIMINATOR).toString("hex")]: {
2104
+ amountInOffset: () => 8,
2105
+ userTransferAuthorityIndex: 0
2106
+ },
2107
+ // shared_accounts_route_v2
2108
+ [Buffer.from(JUP_V6_SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR).toString("hex")]: {
2109
+ amountInOffset: () => 9,
2110
+ userTransferAuthorityIndex: 1
2111
+ }
2112
+ };
1773
2113
  var AMOUNT_IN_DAMM_V2_OFFSET = 8;
1774
2114
  var DAMM_V2_SWAP_DISCRIMINATOR = [
1775
2115
  248,
@@ -1782,41 +2122,132 @@ var DAMM_V2_SWAP_DISCRIMINATOR = [
1782
2122
  200
1783
2123
  ];
1784
2124
  var DEFAULT_JUPITER_API_URL = "https://api.jup.ag";
2125
+ var DEFAULT_JUPITER_API_VERSION = "v2" /* V2 */;
2126
+ var DEFAULT_JUPITER_QUOTE_OPTIONS = {
2127
+ dynamicSlippage: false,
2128
+ onlyDirectRoutes: true,
2129
+ restrictIntermediateTokens: true,
2130
+ forJitoBundle: true
2131
+ };
1785
2132
 
1786
2133
  // src/helpers/jupiter.ts
1787
- function getJupiterQuote(_0, _1, _2, _3, _4) {
1788
- return __async(this, arguments, function* (inputMint, outputMint, amount, maxAccounts, slippageBps, dynamicSlippage = false, onlyDirectRoutes, restrictIntermediateTokens, config = {}) {
1789
- const params = new URLSearchParams({
1790
- inputMint: inputMint.toString(),
1791
- outputMint: outputMint.toString(),
1792
- amount: amount.toString(),
1793
- slippageBps: slippageBps.toString(),
1794
- maxAccounts: maxAccounts.toString(),
1795
- onlyDirectRoutes: onlyDirectRoutes.toString(),
1796
- restrictIntermediateTokens: restrictIntermediateTokens.toString(),
1797
- dynamicSlippage: dynamicSlippage.toString()
1798
- });
1799
- const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/quote?${params.toString()}`;
2134
+ function resolveJupiterConfig(config = {}) {
2135
+ var _a;
2136
+ return {
2137
+ url: config.jupiterApiUrl || DEFAULT_JUPITER_API_URL,
2138
+ apiKey: config.jupiterApiKey || "",
2139
+ version: (_a = config.jupiterApiVersion) != null ? _a : DEFAULT_JUPITER_API_VERSION
2140
+ };
2141
+ }
2142
+ function getJupiterInstructionLayout(data) {
2143
+ const discriminator = data.subarray(0, 8).toString("hex");
2144
+ const layout = JUPITER_INSTRUCTION_LAYOUTS[discriminator];
2145
+ if (!layout) {
2146
+ throw new Error(
2147
+ `Unsupported Jupiter instruction discriminator ${discriminator}`
2148
+ );
2149
+ }
2150
+ return layout;
2151
+ }
2152
+ function isJupiterBuildResponse(quoteResponse) {
2153
+ return quoteResponse.swapInstruction !== void 0;
2154
+ }
2155
+ function isJupiterSwapInstructionForUser(swapInstruction, user) {
2156
+ const layout = getJupiterInstructionLayout(
2157
+ Buffer.from(swapInstruction.data, "base64")
2158
+ );
2159
+ const authority = swapInstruction.accounts[layout.userTransferAuthorityIndex];
2160
+ return authority !== void 0 && new import_web32.PublicKey(authority.pubkey).equals(user);
2161
+ }
2162
+ function jupiterHeaders(apiKey, json) {
2163
+ return __spreadValues(__spreadValues({
2164
+ Accept: "application/json"
2165
+ }, json ? { "Content-Type": "application/json" } : {}), apiKey ? { "x-api-key": apiKey } : {});
2166
+ }
2167
+ function toSearchParams(query) {
2168
+ var _a;
2169
+ const params = new URLSearchParams(__spreadProps(__spreadValues({
2170
+ inputMint: query.inputMint.toString(),
2171
+ outputMint: query.outputMint.toString(),
2172
+ amount: query.amount,
2173
+ slippageBps: query.slippageBps.toString()
2174
+ }, query.maxAccounts !== void 0 ? { maxAccounts: query.maxAccounts.toString() } : {}), {
2175
+ onlyDirectRoutes: query.onlyDirectRoutes.toString(),
2176
+ restrictIntermediateTokens: query.restrictIntermediateTokens.toString(),
2177
+ dynamicSlippage: query.dynamicSlippage.toString(),
2178
+ forJitoBundle: query.forJitoBundle.toString()
2179
+ }));
2180
+ for (const [name, value] of Object.entries(
2181
+ (_a = query.additionalQueryParams) != null ? _a : {}
2182
+ )) {
2183
+ params.set(name, value);
2184
+ }
2185
+ return params;
2186
+ }
2187
+ function fetchJupiterQuoteV1(query, config) {
2188
+ return __async(this, null, function* () {
2189
+ const { url: baseUrl, apiKey } = resolveJupiterConfig(config);
2190
+ const url = `${baseUrl}/swap/v1/quote?${toSearchParams(query).toString()}`;
1800
2191
  try {
1801
2192
  const response = yield fetch(url, {
1802
2193
  method: "GET",
1803
- headers: __spreadValues({
1804
- Accept: "application/json"
1805
- }, config.jupiterApiKey ? { "x-api-key": config.jupiterApiKey } : {})
2194
+ headers: jupiterHeaders(apiKey, false)
1806
2195
  });
1807
2196
  if (!response.ok) {
1808
2197
  return null;
1809
2198
  }
1810
- const result = yield response.json();
1811
- return result;
2199
+ return yield response.json();
1812
2200
  } catch (error) {
1813
2201
  return null;
1814
2202
  }
1815
2203
  });
1816
2204
  }
1817
- function getJupiterSwapInstruction(_0, _1) {
1818
- return __async(this, arguments, function* (userPublicKey, quoteResponse, config = {}) {
1819
- const url = `${config.jupiterApiUrl || DEFAULT_JUPITER_API_URL}/swap/v1/swap-instructions`;
2205
+ function fetchJupiterBuildV2(query, taker, config) {
2206
+ return __async(this, null, function* () {
2207
+ const { url: baseUrl, apiKey } = resolveJupiterConfig(config);
2208
+ const params = toSearchParams(query);
2209
+ params.set("taker", taker.toString());
2210
+ const url = `${baseUrl}/swap/v2/build?${params.toString()}`;
2211
+ try {
2212
+ const response = yield fetch(url, {
2213
+ method: "GET",
2214
+ headers: jupiterHeaders(apiKey, false)
2215
+ });
2216
+ if (!response.ok) {
2217
+ return null;
2218
+ }
2219
+ return yield response.json();
2220
+ } catch (error) {
2221
+ return null;
2222
+ }
2223
+ });
2224
+ }
2225
+ function getJupiterQuote(_0) {
2226
+ return __async(this, arguments, function* (params, config = {}) {
2227
+ var _a, _b, _c, _d;
2228
+ const query = {
2229
+ inputMint: params.inputMint,
2230
+ outputMint: params.outputMint,
2231
+ amount: params.amount.toString(),
2232
+ slippageBps: params.slippageBps,
2233
+ maxAccounts: params.maxAccounts,
2234
+ dynamicSlippage: (_a = params.dynamicSlippage) != null ? _a : DEFAULT_JUPITER_QUOTE_OPTIONS.dynamicSlippage,
2235
+ onlyDirectRoutes: (_b = params.onlyDirectRoutes) != null ? _b : DEFAULT_JUPITER_QUOTE_OPTIONS.onlyDirectRoutes,
2236
+ restrictIntermediateTokens: (_c = params.restrictIntermediateTokens) != null ? _c : DEFAULT_JUPITER_QUOTE_OPTIONS.restrictIntermediateTokens,
2237
+ forJitoBundle: (_d = params.forJitoBundle) != null ? _d : DEFAULT_JUPITER_QUOTE_OPTIONS.forJitoBundle,
2238
+ additionalQueryParams: params.additionalQueryParams
2239
+ };
2240
+ const { version } = resolveJupiterConfig(config);
2241
+ if (version === "v1" /* V1 */) {
2242
+ return fetchJupiterQuoteV1(query, config);
2243
+ }
2244
+ return fetchJupiterBuildV2(query, params.user, config);
2245
+ });
2246
+ }
2247
+ function fetchJupiterSwapInstructionV1(userPublicKey, quoteResponse, config) {
2248
+ return __async(this, null, function* () {
2249
+ const { url: baseUrl, apiKey } = resolveJupiterConfig(config);
2250
+ const url = `${baseUrl}/swap/v1/swap-instructions`;
1820
2251
  const requestBody = {
1821
2252
  userPublicKey: userPublicKey.toString(),
1822
2253
  quoteResponse
@@ -1825,10 +2256,7 @@ function getJupiterSwapInstruction(_0, _1) {
1825
2256
  try {
1826
2257
  response = yield fetch(url, {
1827
2258
  method: "POST",
1828
- headers: __spreadValues({
1829
- "Content-Type": "application/json",
1830
- Accept: "application/json"
1831
- }, config.jupiterApiKey ? { "x-api-key": config.jupiterApiKey } : {}),
2259
+ headers: jupiterHeaders(apiKey, true),
1832
2260
  body: JSON.stringify(requestBody)
1833
2261
  });
1834
2262
  if (!response.ok) {
@@ -1840,21 +2268,111 @@ function getJupiterSwapInstruction(_0, _1) {
1840
2268
  } catch (error) {
1841
2269
  throw new Error(`Jupiter swap instruction failed to fetch`);
1842
2270
  }
1843
- const result = yield response.json();
1844
- return result;
2271
+ return yield response.json();
2272
+ });
2273
+ }
2274
+ function getJupiterSwapInstruction(_0, _1) {
2275
+ return __async(this, arguments, function* (userPublicKey, quoteResponse, config = {}) {
2276
+ const { version } = resolveJupiterConfig(config);
2277
+ if (version === "v1" /* V1 */) {
2278
+ return fetchJupiterSwapInstructionV1(userPublicKey, quoteResponse, config);
2279
+ }
2280
+ if (!isJupiterBuildResponse(quoteResponse)) {
2281
+ throw new Error(
2282
+ "Jupiter quote has no swap instructions, get the quote with getJupiterQuote under Jupiter API v2"
2283
+ );
2284
+ }
2285
+ if (!isJupiterSwapInstructionForUser(
2286
+ quoteResponse.swapInstruction,
2287
+ userPublicKey
2288
+ )) {
2289
+ throw new Error(
2290
+ `Jupiter quote swap instructions are not built for ${userPublicKey.toBase58()}`
2291
+ );
2292
+ }
2293
+ return quoteResponse;
2294
+ });
2295
+ }
2296
+ function isQuoteMatchesSwap(quoteResponse, user, amount) {
2297
+ if (quoteResponse.inAmount !== amount.toString()) {
2298
+ return false;
2299
+ }
2300
+ if (isJupiterBuildResponse(quoteResponse)) {
2301
+ return isJupiterSwapInstructionForUser(quoteResponse.swapInstruction, user);
2302
+ }
2303
+ return true;
2304
+ }
2305
+ var ACTIVE_LOOKUP_TABLE_DEACTIVATION_SLOT = BigInt("0xffffffffffffffff");
2306
+ function toAddressLookupTableAccounts(addressesByLookupTableAddress) {
2307
+ return Object.entries(addressesByLookupTableAddress != null ? addressesByLookupTableAddress : {}).map(
2308
+ ([key, addresses]) => new import_web32.AddressLookupTableAccount({
2309
+ key: new import_web32.PublicKey(key),
2310
+ state: {
2311
+ addresses: addresses.map((address) => new import_web32.PublicKey(address)),
2312
+ deactivationSlot: ACTIVE_LOOKUP_TABLE_DEACTIVATION_SLOT,
2313
+ lastExtendedSlot: 0,
2314
+ lastExtendedSlotStartIndex: 0
2315
+ }
2316
+ })
2317
+ );
2318
+ }
2319
+ function fetchAddressLookupTableAccounts(connection, addresses) {
2320
+ return __async(this, null, function* () {
2321
+ if (addresses.length === 0) {
2322
+ return [];
2323
+ }
2324
+ const keys = addresses.map((address) => new import_web32.PublicKey(address));
2325
+ const accounts = yield connection.getMultipleAccountsInfo(keys);
2326
+ return keys.map((key, i) => {
2327
+ const account = accounts[i];
2328
+ if (!account || !account.owner.equals(import_web32.AddressLookupTableProgram.programId)) {
2329
+ throw new Error(`Address lookup table not found: ${key.toBase58()}`);
2330
+ }
2331
+ return new import_web32.AddressLookupTableAccount({
2332
+ key,
2333
+ state: import_web32.AddressLookupTableAccount.deserialize(account.data)
2334
+ });
2335
+ });
2336
+ });
2337
+ }
2338
+ function mergeAddressLookupTableAccounts(...lists) {
2339
+ const merged = /* @__PURE__ */ new Map();
2340
+ for (const table of lists.flat()) {
2341
+ const key = table.key.toBase58();
2342
+ if (!merged.has(key)) {
2343
+ merged.set(key, table);
2344
+ }
2345
+ }
2346
+ return [...merged.values()];
2347
+ }
2348
+ function getJupiterAddressLookupTableAccounts(connection, response) {
2349
+ return __async(this, null, function* () {
2350
+ var _a;
2351
+ if (response.addressesByLookupTableAddress) {
2352
+ return toAddressLookupTableAccounts(response.addressesByLookupTableAddress);
2353
+ }
2354
+ return fetchAddressLookupTableAccounts(
2355
+ connection,
2356
+ (_a = response.addressLookupTableAddresses) != null ? _a : []
2357
+ );
1845
2358
  });
1846
2359
  }
1847
- function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1848
- return __async(this, arguments, function* (user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}) {
2360
+ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6, _7) {
2361
+ return __async(this, arguments, function* (connection, user, inputMint, outputMint, amount, maxAccounts, slippageBps, jupiterQuoteResponse, config = {}, jupiterQuoteOptions = {}) {
2362
+ if (jupiterQuoteResponse && !isQuoteMatchesSwap(jupiterQuoteResponse, user, amount)) {
2363
+ throw new Error(
2364
+ `Jupiter quote does not match the swap of ${amount.toString()} by ${user.toBase58()} (quoted inAmount ${jupiterQuoteResponse.inAmount})`
2365
+ );
2366
+ }
1849
2367
  const quoteResponse = jupiterQuoteResponse != null ? jupiterQuoteResponse : yield getJupiterQuote(
1850
- inputMint,
1851
- outputMint,
1852
- amount,
1853
- maxAccounts,
1854
- slippageBps,
1855
- false,
1856
- true,
1857
- true,
2368
+ __spreadValues({
2369
+ inputMint,
2370
+ outputMint,
2371
+ amount,
2372
+ user,
2373
+ maxAccounts,
2374
+ slippageBps
2375
+ }, jupiterQuoteOptions),
1858
2376
  config
1859
2377
  );
1860
2378
  if (!quoteResponse) {
@@ -1878,7 +2396,11 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1878
2396
  programId: new import_web32.PublicKey(swapInstructionResponse.swapInstruction.programId),
1879
2397
  data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1880
2398
  });
1881
- return { transaction: new import_web32.Transaction().add(instruction), quoteResponse };
2399
+ const addressLookupTableAccounts = yield getJupiterAddressLookupTableAccounts(
2400
+ connection,
2401
+ swapInstructionResponse
2402
+ );
2403
+ return { instruction, addressLookupTableAccounts, quoteResponse };
1882
2404
  });
1883
2405
  }
1884
2406
 
@@ -2047,11 +2569,16 @@ function convertLamportsToUiAmount(amount, decimals) {
2047
2569
  function convertUiAmountToLamports(amount, decimals) {
2048
2570
  return amount.mul(import_decimal.default.pow(10, decimals));
2049
2571
  }
2572
+ function filterOutComputeBudgetInstructions(instructions) {
2573
+ return instructions.filter(
2574
+ (ix) => !ix.programId.equals(import_web34.ComputeBudgetProgram.programId)
2575
+ );
2576
+ }
2050
2577
 
2051
2578
  // src/helpers/token.ts
2052
2579
  var import_spl_token3 = require("@solana/spl-token");
2053
2580
  var import_web35 = require("@solana/web3.js");
2054
- var getOrCreateATAInstruction = (connection, tokenMint, owner, payer, allowOwnerOffCurve = true, tokenProgram) => __async(null, null, function* () {
2581
+ var getOrCreateATAInstruction = (_connection, tokenMint, owner, payer, allowOwnerOffCurve = true, tokenProgram) => __async(null, null, function* () {
2055
2582
  const toAccount = (0, import_spl_token3.getAssociatedTokenAddressSync)(
2056
2583
  tokenMint,
2057
2584
  owner,
@@ -2487,8 +3014,8 @@ function estimateSwapOutput(inAmount, effectiveRate) {
2487
3014
  const estimatedOutput = inAmountDecimal.mul(effectiveRate);
2488
3015
  return new import_bn3.default(estimatedOutput.floor().toString());
2489
3016
  }
2490
- function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6) {
2491
- return __async(this, arguments, function* (dlmm, inMint, outMint, inAmount, swapSlippageBps, swapForY, binArrays, config = {}) {
3017
+ function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6, _7) {
3018
+ return __async(this, arguments, function* (dlmm, user, inMint, outMint, inAmount, swapSlippageBps, swapForY, binArrays, config = {}, jupiterQuoteOptions = {}) {
2492
3019
  let dlmmQuoteResult = null;
2493
3020
  try {
2494
3021
  dlmmQuoteResult = dlmm.swapQuote(
@@ -2501,14 +3028,14 @@ function getBestSwapQuoteJupiterDlmm(_0, _1, _2, _3, _4, _5, _6) {
2501
3028
  console.error("Error getting DLMM quote, using jupiter quote only:", error);
2502
3029
  }
2503
3030
  const jupiterQuoteResult = yield getJupiterQuote(
2504
- inMint,
2505
- outMint,
2506
- inAmount,
2507
- 50,
2508
- swapSlippageBps,
2509
- false,
2510
- true,
2511
- true,
3031
+ __spreadValues({
3032
+ inputMint: inMint,
3033
+ outputMint: outMint,
3034
+ amount: inAmount,
3035
+ user,
3036
+ maxAccounts: 50,
3037
+ slippageBps: swapSlippageBps
3038
+ }, jupiterQuoteOptions),
2512
3039
  config
2513
3040
  );
2514
3041
  const jupiterQuote = jupiterQuoteResult ? {
@@ -2624,6 +3151,7 @@ function binarySearchRefineDirectSwapAmount(dlmm, initialActiveBin, initialMinBi
2624
3151
  }
2625
3152
  function estimateDlmmIndirectSwap(_0) {
2626
3153
  return __async(this, arguments, function* ({
3154
+ user,
2627
3155
  amountIn,
2628
3156
  inputTokenMint,
2629
3157
  lbPair,
@@ -2633,6 +3161,7 @@ function estimateDlmmIndirectSwap(_0) {
2633
3161
  maxDeltaId,
2634
3162
  strategy,
2635
3163
  singleSided,
3164
+ jupiterQuoteOptions,
2636
3165
  config = {}
2637
3166
  }) {
2638
3167
  const dlmm = yield import_dlmm3.default.create(connection, lbPair);
@@ -2657,14 +3186,14 @@ function estimateDlmmIndirectSwap(_0) {
2657
3186
  const singleSidedX = singleSided === 0 /* X */;
2658
3187
  const outputTokenMint = singleSidedX ? tokenXMint : tokenYMint;
2659
3188
  const quote = yield getJupiterQuote(
2660
- inputTokenMint,
2661
- outputTokenMint,
2662
- amountIn,
2663
- 50,
2664
- swapSlippageBps,
2665
- false,
2666
- true,
2667
- true,
3189
+ __spreadValues({
3190
+ inputMint: inputTokenMint,
3191
+ outputMint: outputTokenMint,
3192
+ amount: amountIn,
3193
+ user,
3194
+ maxAccounts: 50,
3195
+ slippageBps: swapSlippageBps
3196
+ }, jupiterQuoteOptions),
2668
3197
  config
2669
3198
  );
2670
3199
  if (!quote) {
@@ -2687,25 +3216,25 @@ function estimateDlmmIndirectSwap(_0) {
2687
3216
  const halfAmount = amountIn.div(new import_bn3.default(2));
2688
3217
  const [quoteToXResult, quoteToYResult] = yield Promise.allSettled([
2689
3218
  getJupiterQuote(
2690
- inputTokenMint,
2691
- tokenXMint,
2692
- halfAmount,
2693
- 50,
2694
- swapSlippageBps,
2695
- false,
2696
- true,
2697
- true,
3219
+ __spreadValues({
3220
+ inputMint: inputTokenMint,
3221
+ outputMint: tokenXMint,
3222
+ amount: halfAmount,
3223
+ user,
3224
+ maxAccounts: 50,
3225
+ slippageBps: swapSlippageBps
3226
+ }, jupiterQuoteOptions),
2698
3227
  config
2699
3228
  ),
2700
3229
  getJupiterQuote(
2701
- inputTokenMint,
2702
- tokenYMint,
2703
- halfAmount,
2704
- 50,
2705
- swapSlippageBps,
2706
- false,
2707
- true,
2708
- true,
3230
+ __spreadValues({
3231
+ inputMint: inputTokenMint,
3232
+ outputMint: tokenYMint,
3233
+ amount: halfAmount,
3234
+ user,
3235
+ maxAccounts: 50,
3236
+ slippageBps: swapSlippageBps
3237
+ }, jupiterQuoteOptions),
2709
3238
  config
2710
3239
  )
2711
3240
  ]);
@@ -2801,25 +3330,25 @@ function estimateDlmmIndirectSwap(_0) {
2801
3330
  }
2802
3331
  const [finalQuoteToXResult, finalQuoteToYResult] = yield Promise.allSettled([
2803
3332
  getJupiterQuote(
2804
- inputTokenMint,
2805
- tokenXMint,
2806
- bestAmountToX,
2807
- 50,
2808
- swapSlippageBps,
2809
- false,
2810
- true,
2811
- true,
3333
+ __spreadValues({
3334
+ inputMint: inputTokenMint,
3335
+ outputMint: tokenXMint,
3336
+ amount: bestAmountToX,
3337
+ user,
3338
+ maxAccounts: 50,
3339
+ slippageBps: swapSlippageBps
3340
+ }, jupiterQuoteOptions),
2812
3341
  config
2813
3342
  ),
2814
3343
  getJupiterQuote(
2815
- inputTokenMint,
2816
- tokenYMint,
2817
- bestAmountToY,
2818
- 50,
2819
- swapSlippageBps,
2820
- false,
2821
- true,
2822
- true,
3344
+ __spreadValues({
3345
+ inputMint: inputTokenMint,
3346
+ outputMint: tokenYMint,
3347
+ amount: bestAmountToY,
3348
+ user,
3349
+ maxAccounts: 50,
3350
+ slippageBps: swapSlippageBps
3351
+ }, jupiterQuoteOptions),
2823
3352
  config
2824
3353
  )
2825
3354
  ]);
@@ -2855,6 +3384,7 @@ function estimateDlmmIndirectSwap(_0) {
2855
3384
  }
2856
3385
  function estimateDlmmDirectSwapCore(_0) {
2857
3386
  return __async(this, arguments, function* ({
3387
+ user,
2858
3388
  tokenXAmount,
2859
3389
  tokenYAmount,
2860
3390
  dlmm,
@@ -2863,6 +3393,7 @@ function estimateDlmmDirectSwapCore(_0) {
2863
3393
  maxDeltaId,
2864
3394
  strategy,
2865
3395
  singleSided,
3396
+ jupiterQuoteOptions,
2866
3397
  config = {}
2867
3398
  }) {
2868
3399
  if (singleSided !== void 0) {
@@ -2875,13 +3406,15 @@ function estimateDlmmDirectSwapCore(_0) {
2875
3406
  );
2876
3407
  const quote = yield getBestSwapQuoteJupiterDlmm(
2877
3408
  dlmm,
3409
+ user,
2878
3410
  dlmm.lbPair.tokenYMint,
2879
3411
  dlmm.lbPair.tokenXMint,
2880
3412
  tokenYAmount,
2881
3413
  swapSlippageBps,
2882
3414
  swapForY2,
2883
3415
  binArrayForSwap2,
2884
- config
3416
+ config,
3417
+ jupiterQuoteOptions
2885
3418
  );
2886
3419
  if (!quote) {
2887
3420
  throw new Error(
@@ -2904,13 +3437,15 @@ function estimateDlmmDirectSwapCore(_0) {
2904
3437
  );
2905
3438
  const quote = yield getBestSwapQuoteJupiterDlmm(
2906
3439
  dlmm,
3440
+ user,
2907
3441
  dlmm.lbPair.tokenXMint,
2908
3442
  dlmm.lbPair.tokenYMint,
2909
3443
  tokenXAmount,
2910
3444
  swapSlippageBps,
2911
3445
  swapForY2,
2912
3446
  binArrayForSwap2,
2913
- config
3447
+ config,
3448
+ jupiterQuoteOptions
2914
3449
  );
2915
3450
  if (!quote) {
2916
3451
  throw new Error(
@@ -2999,13 +3534,15 @@ function estimateDlmmDirectSwapCore(_0) {
2999
3534
  );
3000
3535
  const initialQuote = yield getBestSwapQuoteJupiterDlmm(
3001
3536
  dlmm,
3537
+ user,
3002
3538
  inMint,
3003
3539
  outMint,
3004
3540
  initialSwapAmount,
3005
3541
  swapSlippageBps,
3006
3542
  swapForY,
3007
3543
  binArrayForSwap,
3008
- config
3544
+ config,
3545
+ jupiterQuoteOptions
3009
3546
  );
3010
3547
  if (!initialQuote) {
3011
3548
  throw new Error(
@@ -3057,13 +3594,15 @@ function estimateDlmmDirectSwapCore(_0) {
3057
3594
  );
3058
3595
  const finalQuote = yield getBestSwapQuoteJupiterDlmm(
3059
3596
  dlmm,
3597
+ user,
3060
3598
  inMint,
3061
3599
  outMint,
3062
3600
  refinedAmount,
3063
3601
  swapSlippageBps,
3064
3602
  swapForY,
3065
3603
  binArrayForSwap,
3066
- config
3604
+ config,
3605
+ jupiterQuoteOptions
3067
3606
  );
3068
3607
  if (!finalQuote) {
3069
3608
  return {
@@ -3089,6 +3628,7 @@ function estimateDlmmDirectSwapCore(_0) {
3089
3628
  }
3090
3629
  function estimateDlmmDirectSwap(_0) {
3091
3630
  return __async(this, arguments, function* ({
3631
+ user,
3092
3632
  amountIn,
3093
3633
  inputTokenMint,
3094
3634
  lbPair,
@@ -3098,6 +3638,7 @@ function estimateDlmmDirectSwap(_0) {
3098
3638
  maxDeltaId,
3099
3639
  strategy,
3100
3640
  singleSided,
3641
+ jupiterQuoteOptions,
3101
3642
  config = {}
3102
3643
  }) {
3103
3644
  const dlmm = yield import_dlmm3.default.create(connection, lbPair);
@@ -3109,6 +3650,7 @@ function estimateDlmmDirectSwap(_0) {
3109
3650
  const tokenXAmount = isInputTokenX ? amountIn : new import_bn3.default(0);
3110
3651
  const tokenYAmount = isInputTokenX ? new import_bn3.default(0) : amountIn;
3111
3652
  const result = yield estimateDlmmDirectSwapCore({
3653
+ user,
3112
3654
  tokenXAmount,
3113
3655
  tokenYAmount,
3114
3656
  dlmm,
@@ -3117,6 +3659,7 @@ function estimateDlmmDirectSwap(_0) {
3117
3659
  maxDeltaId,
3118
3660
  strategy,
3119
3661
  singleSided,
3662
+ jupiterQuoteOptions,
3120
3663
  config
3121
3664
  });
3122
3665
  return {
@@ -3136,6 +3679,7 @@ function estimateDlmmDirectSwap(_0) {
3136
3679
  }
3137
3680
  function estimateDlmmRebalanceSwap(_0) {
3138
3681
  return __async(this, arguments, function* ({
3682
+ user,
3139
3683
  lbPair,
3140
3684
  position,
3141
3685
  connection,
@@ -3143,11 +3687,13 @@ function estimateDlmmRebalanceSwap(_0) {
3143
3687
  minDeltaId,
3144
3688
  maxDeltaId,
3145
3689
  strategy,
3690
+ jupiterQuoteOptions,
3146
3691
  config = {}
3147
3692
  }) {
3148
3693
  const dlmm = yield import_dlmm3.default.create(connection, lbPair);
3149
3694
  const userPosition = yield dlmm.getPosition(position);
3150
3695
  const result = yield estimateDlmmDirectSwapCore({
3696
+ user,
3151
3697
  tokenXAmount: new import_bn3.default(userPosition.positionData.totalXAmount),
3152
3698
  tokenYAmount: new import_bn3.default(userPosition.positionData.totalYAmount),
3153
3699
  dlmm,
@@ -3157,6 +3703,7 @@ function estimateDlmmRebalanceSwap(_0) {
3157
3703
  strategy,
3158
3704
  singleSided: void 0,
3159
3705
  // rebalance does not use single-sided deposits
3706
+ jupiterQuoteOptions,
3160
3707
  config
3161
3708
  });
3162
3709
  return {
@@ -3224,13 +3771,15 @@ function getExtendMaxAmountTransfer(amount, percentage) {
3224
3771
  var Zap = class {
3225
3772
  /**
3226
3773
  * @param connection - The connection to the Solana cluster
3227
- * @param config - Optional configuration for Jupiter API URL (default: https://api.jup.ag) and API key (default: empty string)
3774
+ * @param config - Optional configuration for Jupiter API URL (default: https://api.jup.ag), API key (default: empty string) and API version (default: JupiterApiVersion.V2)
3228
3775
  */
3229
3776
  constructor(connection, config = {}) {
3777
+ var _a;
3230
3778
  this.connection = connection;
3231
- this.zapProgram = new import_anchor.Program(idl_default, { connection });
3779
+ this.zapProgram = new import_core.Program(idl_default, { connection });
3232
3780
  this.jupiterApiUrl = config.jupiterApiUrl || DEFAULT_JUPITER_API_URL;
3233
3781
  this.jupiterApiKey = config.jupiterApiKey || "";
3782
+ this.jupiterApiVersion = (_a = config.jupiterApiVersion) != null ? _a : DEFAULT_JUPITER_API_VERSION;
3234
3783
  }
3235
3784
  /////// PRIVATE FUNDTIONS //////
3236
3785
  initializeLedgerAccount(owner, payer) {
@@ -3239,7 +3788,7 @@ var Zap = class {
3239
3788
  ledger: deriveLedgerAccount(owner),
3240
3789
  owner,
3241
3790
  payer
3242
- }).transaction();
3791
+ }).instruction();
3243
3792
  });
3244
3793
  }
3245
3794
  closeLedgerAccount(owner, rentReceiver) {
@@ -3248,7 +3797,7 @@ var Zap = class {
3248
3797
  ledger: deriveLedgerAccount(owner),
3249
3798
  owner,
3250
3799
  rentReceiver
3251
- }).transaction();
3800
+ }).instruction();
3252
3801
  });
3253
3802
  }
3254
3803
  setLedgerBalance(owner, amount, isTokenA) {
@@ -3256,7 +3805,7 @@ var Zap = class {
3256
3805
  return yield this.zapProgram.methods.setLedgerBalance(amount, isTokenA).accountsPartial({
3257
3806
  ledger: deriveLedgerAccount(owner),
3258
3807
  owner
3259
- }).transaction();
3808
+ }).instruction();
3260
3809
  });
3261
3810
  }
3262
3811
  updateLedgerBalanceAfterSwap(owner, tokenAccount, preSourceTokenAccount, maxTransferAmount, isTokenA) {
@@ -3269,7 +3818,7 @@ var Zap = class {
3269
3818
  ledger: deriveLedgerAccount(owner),
3270
3819
  tokenAccount,
3271
3820
  owner
3272
- }).transaction();
3821
+ }).instruction();
3273
3822
  });
3274
3823
  }
3275
3824
  zapInDammV2(params) {
@@ -3307,7 +3856,7 @@ var Zap = class {
3307
3856
  tokenBProgram,
3308
3857
  dammProgram: DAMM_V2_PROGRAM_ID,
3309
3858
  dammEventAuthority: deriveDammV2EventAuthority()
3310
- }).transaction();
3859
+ }).instruction();
3311
3860
  });
3312
3861
  }
3313
3862
  resetOrInitializeLedgerAccount(user) {
@@ -3317,9 +3866,9 @@ var Zap = class {
3317
3866
  if (accountInfo) {
3318
3867
  const closeLedger = yield this.closeLedgerAccount(user, user);
3319
3868
  const reInitializeLedger = yield this.initializeLedgerAccount(user, user);
3320
- return new import_web38.Transaction().add(closeLedger).add(reInitializeLedger);
3869
+ return [closeLedger, reInitializeLedger];
3321
3870
  }
3322
- return yield this.initializeLedgerAccount(user, user);
3871
+ return [yield this.initializeLedgerAccount(user, user)];
3323
3872
  });
3324
3873
  }
3325
3874
  zapInDlmmForInitializedPosition(params) {
@@ -3386,7 +3935,7 @@ var Zap = class {
3386
3935
  memoProgram: MEMO_PROGRAM_ID,
3387
3936
  dlmmEventAuthority: deriveDlmmEventAuthority(),
3388
3937
  systemProgram: import_web38.SystemProgram.programId
3389
- }).remainingAccounts(binArrays).transaction();
3938
+ }).remainingAccounts(binArrays).instruction();
3390
3939
  });
3391
3940
  }
3392
3941
  zapInDlmmForUninitializedPosition(params) {
@@ -3450,7 +3999,7 @@ var Zap = class {
3450
3999
  memoProgram: MEMO_PROGRAM_ID,
3451
4000
  dlmmEventAuthority: deriveDlmmEventAuthority(),
3452
4001
  systemProgram: import_web38.SystemProgram.programId
3453
- }).remainingAccounts(binArrays).transaction();
4002
+ }).remainingAccounts(binArrays).instruction();
3454
4003
  });
3455
4004
  }
3456
4005
  //#region Zap In
@@ -3470,6 +4019,7 @@ var Zap = class {
3470
4019
  * @param params.dammV2Quote - The DAMM V2 swap quote for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
3471
4020
  * @param params.jupiterQuote - The Jupiter swap quote for exactly 1 input token in lamports (used for price calculation, not the actual amountIn)
3472
4021
  * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
4022
+ * @param params.jupiterQuoteOptions - Optional Jupiter quote options, see `JupiterQuoteOptions`
3473
4023
  * @returns The zap-in transaction parameters for a DAMM V2 direct pool
3474
4024
  * @throws if input token mint matches either tokenA or tokenB in the pool
3475
4025
  * @throws if failed to get both Jupiter and DAMM v2 swap quotes
@@ -3488,7 +4038,8 @@ var Zap = class {
3488
4038
  slippageBps,
3489
4039
  dammV2Quote,
3490
4040
  jupiterQuote,
3491
- maxTransferAmountExtendPercentage
4041
+ maxTransferAmountExtendPercentage,
4042
+ jupiterQuoteOptions
3492
4043
  } = params;
3493
4044
  const poolState = yield getDammV2Pool(this.connection, pool);
3494
4045
  const {
@@ -3508,7 +4059,7 @@ var Zap = class {
3508
4059
  const tokenAProgram = (0, import_cp_amm_sdk3.getTokenProgram)(tokenAFlag);
3509
4060
  const tokenBProgram = (0, import_cp_amm_sdk3.getTokenProgram)(tokenBFlag);
3510
4061
  const preInstructions = [];
3511
- if (tokenAMint.equals(import_spl_token6.NATIVE_MINT) || tokenBMint.equals(import_spl_token6.NATIVE_MINT)) {
4062
+ if (inputTokenMint.equals(import_spl_token6.NATIVE_MINT)) {
3512
4063
  const { ataPubkey: userWrapSolAcc, ix: initializeUserWrapSOLAta } = yield getOrCreateATAInstruction(
3513
4064
  this.connection,
3514
4065
  import_spl_token6.NATIVE_MINT,
@@ -3560,20 +4111,22 @@ var Zap = class {
3560
4111
  const singleSidedA = isSingleSidedA(poolState);
3561
4112
  const singleSidedB = isSingleSidedB(poolState);
3562
4113
  let amount;
3563
- let swapTransactions = [];
4114
+ let swapInstructions = [];
4115
+ let addressLookupTableAccounts = [];
3564
4116
  let maxTransferAmount;
3565
4117
  let swapInAmount;
3566
4118
  let swapRoute;
3567
4119
  if (singleSidedA && isInputTokenA || singleSidedB && !isInputTokenA) {
3568
4120
  amount = amountIn;
3569
- swapInAmount = new import_anchor.BN(0);
3570
- maxTransferAmount = new import_anchor.BN(0);
4121
+ swapInAmount = new import_core.BN(0);
4122
+ maxTransferAmount = new import_core.BN(0);
3571
4123
  swapRoute = "dammV2" /* DammV2 */;
3572
4124
  } else if (singleSidedA && !isInputTokenA || singleSidedB && isInputTokenA) {
3573
- if (jupiterQuote !== null && (dammV2Quote === null || new import_anchor.BN(jupiterQuote.outAmount).gte(dammV2Quote.swapOutAmount))) {
4125
+ if (jupiterQuote !== null && (dammV2Quote === null || new import_core.BN(jupiterQuote.outAmount).gte(dammV2Quote.swapOutAmount))) {
3574
4126
  swapInAmount = amountIn;
3575
- amount = new import_anchor.BN(0);
4127
+ amount = new import_core.BN(0);
3576
4128
  const result = yield buildJupiterSwapTransaction(
4129
+ this.connection,
3577
4130
  user,
3578
4131
  inputTokenMint,
3579
4132
  outputTokenMint,
@@ -3583,26 +4136,29 @@ var Zap = class {
3583
4136
  void 0,
3584
4137
  {
3585
4138
  jupiterApiUrl: this.jupiterApiUrl,
3586
- jupiterApiKey: this.jupiterApiKey
3587
- }
4139
+ jupiterApiKey: this.jupiterApiKey,
4140
+ jupiterApiVersion: this.jupiterApiVersion
4141
+ },
4142
+ jupiterQuoteOptions
3588
4143
  );
3589
- swapTransactions = [result.transaction];
4144
+ swapInstructions = [result.instruction];
4145
+ addressLookupTableAccounts = result.addressLookupTableAccounts;
3590
4146
  maxTransferAmount = getExtendMaxAmountTransfer(
3591
4147
  result.quoteResponse.outAmount,
3592
4148
  maxTransferAmountExtendPercentage
3593
4149
  );
3594
4150
  swapRoute = "jupiter" /* Jupiter */;
3595
4151
  } else if (dammV2Quote !== null) {
3596
- swapInAmount = new import_anchor.BN(0);
4152
+ swapInAmount = new import_core.BN(0);
3597
4153
  amount = amountIn;
3598
- maxTransferAmount = new import_anchor.BN(0);
4154
+ maxTransferAmount = new import_core.BN(0);
3599
4155
  swapRoute = "dammV2" /* DammV2 */;
3600
4156
  } else {
3601
4157
  throw new Error(
3602
4158
  "No Jupiter or DAMM v2 quote found for single-sided swap, unable to proceed"
3603
4159
  );
3604
4160
  }
3605
- } else if (jupiterQuote !== null && (dammV2Quote === null || new import_anchor.BN(jupiterQuote.outAmount).gte(dammV2Quote.swapOutAmount))) {
4161
+ } else if (jupiterQuote !== null && (dammV2Quote === null || new import_core.BN(jupiterQuote.outAmount).gte(dammV2Quote.swapOutAmount))) {
3606
4162
  const price = convertLamportsToUiAmount(
3607
4163
  new import_decimal4.default(jupiterQuote.outAmount),
3608
4164
  isInputTokenA ? tokenBDecimal : tokenADecimal
@@ -3623,6 +4179,7 @@ var Zap = class {
3623
4179
  );
3624
4180
  amount = amountIn.sub(swapInAmount);
3625
4181
  const result = yield buildJupiterSwapTransaction(
4182
+ this.connection,
3626
4183
  user,
3627
4184
  inputTokenMint,
3628
4185
  outputTokenMint,
@@ -3632,10 +4189,13 @@ var Zap = class {
3632
4189
  void 0,
3633
4190
  {
3634
4191
  jupiterApiUrl: this.jupiterApiUrl,
3635
- jupiterApiKey: this.jupiterApiKey
3636
- }
4192
+ jupiterApiKey: this.jupiterApiKey,
4193
+ jupiterApiVersion: this.jupiterApiVersion
4194
+ },
4195
+ jupiterQuoteOptions
3637
4196
  );
3638
- swapTransactions = [result.transaction];
4197
+ swapInstructions = [result.instruction];
4198
+ addressLookupTableAccounts = result.addressLookupTableAccounts;
3639
4199
  maxTransferAmount = getExtendMaxAmountTransfer(
3640
4200
  result.quoteResponse.outAmount,
3641
4201
  maxTransferAmountExtendPercentage
@@ -3693,7 +4253,8 @@ var Zap = class {
3693
4253
  preSqrtPrice: poolState.sqrtPrice,
3694
4254
  maxSqrtPriceChangeBps,
3695
4255
  preInstructions,
3696
- swapTransactions,
4256
+ swapInstructions,
4257
+ addressLookupTableAccounts,
3697
4258
  cleanUpInstructions,
3698
4259
  swapInEstimate: {
3699
4260
  inAmount: swapInAmount,
@@ -3718,6 +4279,7 @@ var Zap = class {
3718
4279
  * @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)
3719
4280
  * @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)
3720
4281
  * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
4282
+ * @param params.jupiterQuoteOptions - Optional Jupiter quote options, see `JupiterQuoteOptions`
3721
4283
  * @returns The zap-in transaction parameters for a DAMM V2 indirect pool
3722
4284
  * @throws if input token mint matches either tokenA or tokenB in the pool
3723
4285
  * @throws if no Jupiter quote provided for both tokens
@@ -3736,7 +4298,8 @@ var Zap = class {
3736
4298
  maxTransferAmountExtendPercentage,
3737
4299
  slippageBps,
3738
4300
  jupiterQuoteToA,
3739
- jupiterQuoteToB
4301
+ jupiterQuoteToB,
4302
+ jupiterQuoteOptions
3740
4303
  } = params;
3741
4304
  const poolState = yield getDammV2Pool(this.connection, pool);
3742
4305
  const {
@@ -3821,6 +4384,7 @@ var Zap = class {
3821
4384
  );
3822
4385
  }
3823
4386
  const result = yield buildJupiterSwapTransaction(
4387
+ this.connection,
3824
4388
  user,
3825
4389
  inputTokenMint,
3826
4390
  tokenAMint,
@@ -3830,8 +4394,10 @@ var Zap = class {
3830
4394
  void 0,
3831
4395
  {
3832
4396
  jupiterApiUrl: this.jupiterApiUrl,
3833
- jupiterApiKey: this.jupiterApiKey
3834
- }
4397
+ jupiterApiKey: this.jupiterApiKey,
4398
+ jupiterApiVersion: this.jupiterApiVersion
4399
+ },
4400
+ jupiterQuoteOptions
3835
4401
  );
3836
4402
  return {
3837
4403
  user,
@@ -3839,7 +4405,7 @@ var Zap = class {
3839
4405
  position,
3840
4406
  positionNftAccount,
3841
4407
  maxSqrtPriceChangeBps,
3842
- amount: new import_anchor.BN(0),
4408
+ amount: new import_core.BN(0),
3843
4409
  isDirectPool: false,
3844
4410
  tokenAMint,
3845
4411
  tokenBMint,
@@ -3852,14 +4418,15 @@ var Zap = class {
3852
4418
  maxTransferAmountExtendPercentage
3853
4419
  ),
3854
4420
  swapType: 0 /* swapToA */,
3855
- maxTransferAmountB: new import_anchor.BN(0),
4421
+ maxTransferAmountB: new import_core.BN(0),
3856
4422
  preSqrtPrice: poolState.sqrtPrice,
3857
4423
  preInstructions,
3858
- swapTransactions: [result.transaction],
4424
+ swapInstructions: [result.instruction],
4425
+ addressLookupTableAccounts: result.addressLookupTableAccounts,
3859
4426
  cleanUpInstructions,
3860
4427
  swapInEstimate: {
3861
4428
  inAmountA: amountIn,
3862
- inAmountB: new import_anchor.BN(0),
4429
+ inAmountB: new import_core.BN(0),
3863
4430
  routeA: "jupiter" /* Jupiter */,
3864
4431
  routeB: "dammV2" /* DammV2 */
3865
4432
  }
@@ -3872,6 +4439,7 @@ var Zap = class {
3872
4439
  );
3873
4440
  }
3874
4441
  const result = yield buildJupiterSwapTransaction(
4442
+ this.connection,
3875
4443
  user,
3876
4444
  inputTokenMint,
3877
4445
  tokenBMint,
@@ -3881,8 +4449,10 @@ var Zap = class {
3881
4449
  void 0,
3882
4450
  {
3883
4451
  jupiterApiUrl: this.jupiterApiUrl,
3884
- jupiterApiKey: this.jupiterApiKey
3885
- }
4452
+ jupiterApiKey: this.jupiterApiKey,
4453
+ jupiterApiVersion: this.jupiterApiVersion
4454
+ },
4455
+ jupiterQuoteOptions
3886
4456
  );
3887
4457
  return {
3888
4458
  user,
@@ -3890,7 +4460,7 @@ var Zap = class {
3890
4460
  position,
3891
4461
  positionNftAccount,
3892
4462
  maxSqrtPriceChangeBps,
3893
- amount: new import_anchor.BN(0),
4463
+ amount: new import_core.BN(0),
3894
4464
  isDirectPool: false,
3895
4465
  tokenAMint,
3896
4466
  tokenBMint,
@@ -3898,7 +4468,7 @@ var Zap = class {
3898
4468
  tokenBVault,
3899
4469
  tokenAProgram,
3900
4470
  tokenBProgram,
3901
- maxTransferAmountA: new import_anchor.BN(0),
4471
+ maxTransferAmountA: new import_core.BN(0),
3902
4472
  maxTransferAmountB: getExtendMaxAmountTransfer(
3903
4473
  result.quoteResponse.outAmount,
3904
4474
  maxTransferAmountExtendPercentage
@@ -3906,10 +4476,11 @@ var Zap = class {
3906
4476
  swapType: 1 /* swapToB */,
3907
4477
  preSqrtPrice: poolState.sqrtPrice,
3908
4478
  preInstructions,
3909
- swapTransactions: [result.transaction],
4479
+ swapInstructions: [result.instruction],
4480
+ addressLookupTableAccounts: result.addressLookupTableAccounts,
3910
4481
  cleanUpInstructions,
3911
4482
  swapInEstimate: {
3912
- inAmountA: new import_anchor.BN(0),
4483
+ inAmountA: new import_core.BN(0),
3913
4484
  inAmountB: amountIn,
3914
4485
  routeA: "dammV2" /* DammV2 */,
3915
4486
  routeB: "jupiter" /* Jupiter */
@@ -3918,6 +4489,7 @@ var Zap = class {
3918
4489
  }
3919
4490
  if (jupiterQuoteToA && jupiterQuoteToB === null) {
3920
4491
  const result = yield buildJupiterSwapTransaction(
4492
+ this.connection,
3921
4493
  user,
3922
4494
  inputTokenMint,
3923
4495
  tokenAMint,
@@ -3927,8 +4499,10 @@ var Zap = class {
3927
4499
  void 0,
3928
4500
  {
3929
4501
  jupiterApiUrl: this.jupiterApiUrl,
3930
- jupiterApiKey: this.jupiterApiKey
3931
- }
4502
+ jupiterApiKey: this.jupiterApiKey,
4503
+ jupiterApiVersion: this.jupiterApiVersion
4504
+ },
4505
+ jupiterQuoteOptions
3932
4506
  );
3933
4507
  return {
3934
4508
  user,
@@ -3936,7 +4510,7 @@ var Zap = class {
3936
4510
  position,
3937
4511
  positionNftAccount,
3938
4512
  maxSqrtPriceChangeBps,
3939
- amount: new import_anchor.BN(0),
4513
+ amount: new import_core.BN(0),
3940
4514
  isDirectPool: false,
3941
4515
  tokenAMint,
3942
4516
  tokenBMint,
@@ -3949,14 +4523,15 @@ var Zap = class {
3949
4523
  maxTransferAmountExtendPercentage
3950
4524
  ),
3951
4525
  swapType: 0 /* swapToA */,
3952
- maxTransferAmountB: new import_anchor.BN(0),
4526
+ maxTransferAmountB: new import_core.BN(0),
3953
4527
  preSqrtPrice: poolState.sqrtPrice,
3954
4528
  preInstructions,
3955
- swapTransactions: [result.transaction],
4529
+ swapInstructions: [result.instruction],
4530
+ addressLookupTableAccounts: result.addressLookupTableAccounts,
3956
4531
  cleanUpInstructions,
3957
4532
  swapInEstimate: {
3958
4533
  inAmountA: amountIn,
3959
- inAmountB: new import_anchor.BN(0),
4534
+ inAmountB: new import_core.BN(0),
3960
4535
  routeA: "jupiter" /* Jupiter */,
3961
4536
  routeB: "dammV2" /* DammV2 */
3962
4537
  }
@@ -3964,6 +4539,7 @@ var Zap = class {
3964
4539
  }
3965
4540
  if (jupiterQuoteToB && jupiterQuoteToA === null) {
3966
4541
  const result = yield buildJupiterSwapTransaction(
4542
+ this.connection,
3967
4543
  user,
3968
4544
  inputTokenMint,
3969
4545
  tokenBMint,
@@ -3973,8 +4549,10 @@ var Zap = class {
3973
4549
  void 0,
3974
4550
  {
3975
4551
  jupiterApiUrl: this.jupiterApiUrl,
3976
- jupiterApiKey: this.jupiterApiKey
3977
- }
4552
+ jupiterApiKey: this.jupiterApiKey,
4553
+ jupiterApiVersion: this.jupiterApiVersion
4554
+ },
4555
+ jupiterQuoteOptions
3978
4556
  );
3979
4557
  return {
3980
4558
  user,
@@ -3982,7 +4560,7 @@ var Zap = class {
3982
4560
  position,
3983
4561
  positionNftAccount,
3984
4562
  maxSqrtPriceChangeBps,
3985
- amount: new import_anchor.BN(0),
4563
+ amount: new import_core.BN(0),
3986
4564
  isDirectPool: false,
3987
4565
  tokenAMint,
3988
4566
  tokenBMint,
@@ -3990,7 +4568,7 @@ var Zap = class {
3990
4568
  tokenBVault,
3991
4569
  tokenAProgram,
3992
4570
  tokenBProgram,
3993
- maxTransferAmountA: new import_anchor.BN(0),
4571
+ maxTransferAmountA: new import_core.BN(0),
3994
4572
  maxTransferAmountB: getExtendMaxAmountTransfer(
3995
4573
  result.quoteResponse.outAmount,
3996
4574
  maxTransferAmountExtendPercentage
@@ -3998,10 +4576,11 @@ var Zap = class {
3998
4576
  swapType: 1 /* swapToB */,
3999
4577
  preSqrtPrice: poolState.sqrtPrice,
4000
4578
  preInstructions,
4001
- swapTransactions: [result.transaction],
4579
+ swapInstructions: [result.instruction],
4580
+ addressLookupTableAccounts: result.addressLookupTableAccounts,
4002
4581
  cleanUpInstructions,
4003
4582
  swapInEstimate: {
4004
- inAmountA: new import_anchor.BN(0),
4583
+ inAmountA: new import_core.BN(0),
4005
4584
  inAmountB: amountIn,
4006
4585
  routeA: "dammV2" /* DammV2 */,
4007
4586
  routeB: "jupiter" /* Jupiter */
@@ -4038,7 +4617,7 @@ var Zap = class {
4038
4617
  position,
4039
4618
  positionNftAccount,
4040
4619
  maxSqrtPriceChangeBps,
4041
- amount: new import_anchor.BN(0),
4620
+ amount: new import_core.BN(0),
4042
4621
  isDirectPool: false,
4043
4622
  tokenAMint,
4044
4623
  tokenBMint,
@@ -4050,7 +4629,8 @@ var Zap = class {
4050
4629
  preSqrtPrice: poolState.sqrtPrice,
4051
4630
  cleanUpInstructions
4052
4631
  };
4053
- const { transaction: swapToATransaction, quoteResponse: swapToAQuote } = yield buildJupiterSwapTransaction(
4632
+ const swapToA = yield buildJupiterSwapTransaction(
4633
+ this.connection,
4054
4634
  user,
4055
4635
  inputTokenMint,
4056
4636
  tokenAMint,
@@ -4060,10 +4640,13 @@ var Zap = class {
4060
4640
  void 0,
4061
4641
  {
4062
4642
  jupiterApiUrl: this.jupiterApiUrl,
4063
- jupiterApiKey: this.jupiterApiKey
4064
- }
4643
+ jupiterApiKey: this.jupiterApiKey,
4644
+ jupiterApiVersion: this.jupiterApiVersion
4645
+ },
4646
+ jupiterQuoteOptions
4065
4647
  );
4066
- const { transaction: swapToBTransaction, quoteResponse: swapToBQuote } = yield buildJupiterSwapTransaction(
4648
+ const swapToB = yield buildJupiterSwapTransaction(
4649
+ this.connection,
4067
4650
  user,
4068
4651
  inputTokenMint,
4069
4652
  tokenBMint,
@@ -4073,20 +4656,26 @@ var Zap = class {
4073
4656
  void 0,
4074
4657
  {
4075
4658
  jupiterApiUrl: this.jupiterApiUrl,
4076
- jupiterApiKey: this.jupiterApiKey
4077
- }
4659
+ jupiterApiKey: this.jupiterApiKey,
4660
+ jupiterApiVersion: this.jupiterApiVersion
4661
+ },
4662
+ jupiterQuoteOptions
4078
4663
  );
4079
4664
  return __spreadProps(__spreadValues({}, baseParams), {
4080
4665
  maxTransferAmountA: getExtendMaxAmountTransfer(
4081
- swapToAQuote.outAmount,
4666
+ swapToA.quoteResponse.outAmount,
4082
4667
  maxTransferAmountExtendPercentage
4083
4668
  ),
4084
4669
  maxTransferAmountB: getExtendMaxAmountTransfer(
4085
- swapToBQuote.outAmount,
4670
+ swapToB.quoteResponse.outAmount,
4086
4671
  maxTransferAmountExtendPercentage
4087
4672
  ),
4088
4673
  swapType: 2 /* swapToBoth */,
4089
- swapTransactions: [swapToATransaction, swapToBTransaction],
4674
+ swapInstructions: [swapToA.instruction, swapToB.instruction],
4675
+ addressLookupTableAccounts: mergeAddressLookupTableAccounts(
4676
+ swapToA.addressLookupTableAccounts,
4677
+ swapToB.addressLookupTableAccounts
4678
+ ),
4090
4679
  swapInEstimate: {
4091
4680
  inAmountA: swapAmountToA,
4092
4681
  inAmountB: swapAmountToB,
@@ -4101,7 +4690,12 @@ var Zap = class {
4101
4690
  });
4102
4691
  }
4103
4692
  /**
4104
- * Build DAMM v2 zap-in transaction
4693
+ * Build the DAMM v2 zap-in instructions
4694
+ *
4695
+ * Instructions are ordered: setup (token accounts, wrap SOL), swaps, ledger, zap in, clean up.
4696
+ * They must run in that order but can be split across several transactions, because state
4697
+ * between steps lives in accounts. Splitting loses atomicity, so send split transactions as a bundle.
4698
+ * No compute budget instructions are included; the client sets the compute budget for each transaction.
4105
4699
  *
4106
4700
  * @param params.user - The user's public key
4107
4701
  * @param params.pool - The pool's public key
@@ -4118,9 +4712,10 @@ var Zap = class {
4118
4712
  * @param params.preSqrtPrice - The sqrt price before the operation
4119
4713
  * @param params.maxSqrtPriceChangeBps - The maximum sqrt price change in basis points
4120
4714
  * @param params.preInstructions - Instructions to run before the zap in
4121
- * @param params.swapTransactions - Swap transactions to execute
4715
+ * @param params.swapInstructions - Swap instructions to execute
4716
+ * @param params.addressLookupTableAccounts - Lookup tables used by the swap instructions
4122
4717
  * @param params.cleanUpInstructions - Instructions to run after the zap in
4123
- * @returns Response containing transaction components
4718
+ * @returns The ordered instructions and the lookup tables they use
4124
4719
  */
4125
4720
  buildZapInDammV2Transaction(params) {
4126
4721
  return __async(this, null, function* () {
@@ -4140,7 +4735,8 @@ var Zap = class {
4140
4735
  preSqrtPrice,
4141
4736
  maxSqrtPriceChangeBps,
4142
4737
  preInstructions,
4143
- swapTransactions,
4738
+ swapInstructions,
4739
+ addressLookupTableAccounts,
4144
4740
  cleanUpInstructions
4145
4741
  } = params;
4146
4742
  const [
@@ -4164,37 +4760,33 @@ var Zap = class {
4164
4760
  tokenBProgram
4165
4761
  )
4166
4762
  ]);
4167
- const setupTransaction = new import_web38.Transaction();
4168
- initializeTokenAIx && setupTransaction.add(initializeTokenAIx);
4169
- initializeTokenBIx && setupTransaction.add(initializeTokenBIx);
4170
- if (preInstructions.length > 0) {
4171
- setupTransaction.add(...preInstructions);
4172
- }
4173
- const ledgerTransaction = new import_web38.Transaction();
4174
- const resetOrInitializeLedgerTx = yield this.resetOrInitializeLedgerAccount(user);
4175
- ledgerTransaction.add(resetOrInitializeLedgerTx);
4763
+ const setupInstructions = [];
4764
+ initializeTokenAIx && setupInstructions.push(initializeTokenAIx);
4765
+ initializeTokenBIx && setupInstructions.push(initializeTokenBIx);
4766
+ setupInstructions.push(...preInstructions);
4767
+ const ledgerInstructions = yield this.resetOrInitializeLedgerAccount(user);
4176
4768
  if (isDirectPool) {
4177
4769
  const isTokenA = params.isTokenA;
4178
- const setLedgerBalanceTx = yield this.setLedgerBalance(
4770
+ const setLedgerBalanceIx = yield this.setLedgerBalance(
4179
4771
  user,
4180
4772
  amount,
4181
4773
  isTokenA
4182
4774
  );
4183
- ledgerTransaction.add(setLedgerBalanceTx);
4184
- if (swapTransactions.length > 0) {
4775
+ ledgerInstructions.push(setLedgerBalanceIx);
4776
+ if (swapInstructions.length > 0) {
4185
4777
  const tokenAccount = isTokenA ? tokenBAccount : tokenAAccount;
4186
4778
  const preTokenBalance = yield getTokenAccountBalance(
4187
4779
  this.connection,
4188
4780
  tokenAccount
4189
4781
  );
4190
- const updateLedgerBalanceAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
4782
+ const updateLedgerBalanceAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4191
4783
  user,
4192
4784
  tokenAccount,
4193
- new import_anchor.BN(preTokenBalance),
4785
+ new import_core.BN(preTokenBalance),
4194
4786
  params.maxTransferAmount,
4195
4787
  !isTokenA
4196
4788
  );
4197
- ledgerTransaction.add(updateLedgerBalanceAfterSwapTx);
4789
+ ledgerInstructions.push(updateLedgerBalanceAfterSwapIx);
4198
4790
  }
4199
4791
  } else {
4200
4792
  const preTokenABalance = yield getTokenAccountBalance(
@@ -4205,32 +4797,35 @@ var Zap = class {
4205
4797
  this.connection,
4206
4798
  tokenBAccount
4207
4799
  );
4208
- const updateLedgerBalanceTokenAAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
4800
+ const updateLedgerBalanceTokenAAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4209
4801
  user,
4210
4802
  tokenAAccount,
4211
- new import_anchor.BN(preTokenABalance),
4803
+ new import_core.BN(preTokenABalance),
4212
4804
  params.maxTransferAmountA,
4213
4805
  true
4214
4806
  // is token A
4215
4807
  );
4216
- const updateLedgerBalanceTokenBAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
4808
+ const updateLedgerBalanceTokenBAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4217
4809
  user,
4218
4810
  tokenBAccount,
4219
- new import_anchor.BN(preTokenBBalance),
4811
+ new import_core.BN(preTokenBBalance),
4220
4812
  params.maxTransferAmountB,
4221
4813
  false
4222
4814
  // isn't token A
4223
4815
  );
4224
4816
  const swapType = params.swapType;
4225
4817
  if (swapType == 0 /* swapToA */) {
4226
- ledgerTransaction.add(updateLedgerBalanceTokenAAfterSwapTx);
4818
+ ledgerInstructions.push(updateLedgerBalanceTokenAAfterSwapIx);
4227
4819
  } else if (swapType == 1 /* swapToB */) {
4228
- ledgerTransaction.add(updateLedgerBalanceTokenBAfterSwapTx);
4820
+ ledgerInstructions.push(updateLedgerBalanceTokenBAfterSwapIx);
4229
4821
  } else {
4230
- ledgerTransaction.add(updateLedgerBalanceTokenAAfterSwapTx).add(updateLedgerBalanceTokenBAfterSwapTx);
4822
+ ledgerInstructions.push(
4823
+ updateLedgerBalanceTokenAAfterSwapIx,
4824
+ updateLedgerBalanceTokenBAfterSwapIx
4825
+ );
4231
4826
  }
4232
4827
  }
4233
- const zapInTransaction = yield this.zapInDammV2({
4828
+ const zapInInstruction = yield this.zapInDammV2({
4234
4829
  user,
4235
4830
  pool,
4236
4831
  position,
@@ -4246,18 +4841,17 @@ var Zap = class {
4246
4841
  tokenAAccount,
4247
4842
  tokenBAccount
4248
4843
  });
4249
- const cleanUpTransaction = new import_web38.Transaction();
4250
- const closeLedgerTransaction = yield this.closeLedgerAccount(user, user);
4251
- cleanUpTransaction.add(closeLedgerTransaction);
4252
- if (cleanUpInstructions.length > 0) {
4253
- cleanUpTransaction.add(...cleanUpInstructions);
4254
- }
4844
+ const closeLedgerInstruction = yield this.closeLedgerAccount(user, user);
4255
4845
  return {
4256
- setupTransaction: setupTransaction.instructions.length > 0 ? setupTransaction : void 0,
4257
- swapTransactions,
4258
- ledgerTransaction,
4259
- zapInTransaction,
4260
- cleanUpTransaction
4846
+ instructions: [
4847
+ ...setupInstructions,
4848
+ ...swapInstructions,
4849
+ ...ledgerInstructions,
4850
+ zapInInstruction,
4851
+ closeLedgerInstruction,
4852
+ ...cleanUpInstructions
4853
+ ],
4854
+ addressLookupTableAccounts
4261
4855
  };
4262
4856
  });
4263
4857
  }
@@ -4274,8 +4868,8 @@ var Zap = class {
4274
4868
  * @param params.maxDeltaId - The bin delta relative to the active bin for the upper bin position
4275
4869
  * @param params.strategy - The liquidity distribution strategy
4276
4870
  * @param params.favorXInActiveId - Whether to favor token X in the active bin
4277
- * @param params.maxAccounts - The maximum number of accounts for the Jupiter swap query
4278
- * @param params.swapSlippageBps - The swap slippage tolerance in basis points
4871
+ * @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.
4872
+ * @param params.swapSlippageBps - Swap slippage vs the **quoted route**, not vs a fair input/output price. Validate `directSwapEstimate` / `outAmount` before send.
4279
4873
  * @param params.maxTransferAmountExtendPercentage - The percentage to extend the max transfer amount after the swap
4280
4874
  * @param params.maxActiveBinSlippage - The maximum active bin slippage
4281
4875
  * @param params.directSwapEstimate - The result from the direct swap estimate
@@ -4328,12 +4922,14 @@ var Zap = class {
4328
4922
  initializeWrapSolIx && preInstructions.push(initializeWrapSolIx);
4329
4923
  preInstructions.push(...wrapSOL);
4330
4924
  }
4331
- const swapTransactions = [];
4925
+ const swapInstructions = [];
4926
+ let addressLookupTableAccounts = [];
4332
4927
  let maxTransferAmount;
4333
4928
  if (directSwapEstimate.swapType !== 2 /* NoSwap */ && directSwapEstimate.quote) {
4334
4929
  const swapQuote = directSwapEstimate.quote;
4335
4930
  if (swapQuote.route === 0 /* Jupiter */) {
4336
- const { transaction: swapTx } = yield buildJupiterSwapTransaction(
4931
+ const swap = yield buildJupiterSwapTransaction(
4932
+ this.connection,
4337
4933
  user,
4338
4934
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenXMint : tokenYMint,
4339
4935
  directSwapEstimate.swapType === 0 /* XToY */ ? tokenYMint : tokenXMint,
@@ -4343,10 +4939,12 @@ var Zap = class {
4343
4939
  swapQuote.originalQuote,
4344
4940
  {
4345
4941
  jupiterApiUrl: this.jupiterApiUrl,
4346
- jupiterApiKey: this.jupiterApiKey
4942
+ jupiterApiKey: this.jupiterApiKey,
4943
+ jupiterApiVersion: this.jupiterApiVersion
4347
4944
  }
4348
4945
  );
4349
- swapTransactions.push(swapTx);
4946
+ swapInstructions.push(swap.instruction);
4947
+ addressLookupTableAccounts = swap.addressLookupTableAccounts;
4350
4948
  } else {
4351
4949
  const swapForY = directSwapEstimate.swapType === 0 /* XToY */;
4352
4950
  const binArrays2 = yield dlmm.getBinArrayForSwap(swapForY);
@@ -4359,6 +4957,9 @@ var Zap = class {
4359
4957
  user,
4360
4958
  binArraysPubkey: binArrays2.map((item) => item.publicKey)
4361
4959
  });
4960
+ swapTx.instructions = filterOutComputeBudgetInstructions(
4961
+ swapTx.instructions
4962
+ );
4362
4963
  if (tokenXMint.equals(import_spl_token6.NATIVE_MINT) || tokenYMint.equals(import_spl_token6.NATIVE_MINT)) {
4363
4964
  swapTx.instructions = swapTx.instructions.filter((ix) => {
4364
4965
  if (ix.programId.equals(import_spl_token6.TOKEN_PROGRAM_ID)) {
@@ -4367,14 +4968,14 @@ var Zap = class {
4367
4968
  return true;
4368
4969
  });
4369
4970
  }
4370
- swapTransactions.push(swapTx);
4971
+ swapInstructions.push(...swapTx.instructions);
4371
4972
  }
4372
4973
  maxTransferAmount = getExtendMaxAmountTransfer(
4373
4974
  directSwapEstimate.expectedOutput.toString(),
4374
4975
  maxTransferAmountExtendPercentage
4375
4976
  );
4376
4977
  } else {
4377
- maxTransferAmount = new import_anchor.BN(0);
4978
+ maxTransferAmount = new import_core.BN(0);
4378
4979
  }
4379
4980
  const amount = isTokenX ? directSwapEstimate.postSwapX : directSwapEstimate.postSwapY;
4380
4981
  const cleanUpInstructions = [];
@@ -4384,8 +4985,8 @@ var Zap = class {
4384
4985
  }
4385
4986
  const binArrays = (0, import_dlmm4.getBinArraysRequiredByPositionRange)(
4386
4987
  lbPair,
4387
- new import_anchor.BN(activeId + minDeltaId),
4388
- new import_anchor.BN(activeId + maxDeltaId),
4988
+ new import_core.BN(activeId + minDeltaId),
4989
+ new import_core.BN(activeId + maxDeltaId),
4389
4990
  DLMM_PROGRAM_ID
4390
4991
  ).map((item) => ({
4391
4992
  pubkey: item.key,
@@ -4417,7 +5018,8 @@ var Zap = class {
4417
5018
  amount,
4418
5019
  maxTransferAmount,
4419
5020
  preInstructions,
4420
- swapTransactions,
5021
+ swapInstructions,
5022
+ addressLookupTableAccounts,
4421
5023
  cleanUpInstructions,
4422
5024
  binArrays,
4423
5025
  binArrayBitmapExtension: binArrayBitmapExtensionData ? binArrayBitmapExtension : null,
@@ -4498,11 +5100,13 @@ var Zap = class {
4498
5100
  }
4499
5101
  let maxTransferAmountX;
4500
5102
  let maxTransferAmountY;
4501
- const swapTransactions = [];
5103
+ const swapInstructions = [];
5104
+ const swapLookupTables = [];
4502
5105
  const swapAmountToXInLamports = indirectSwapEstimate.swapAmountToX;
4503
5106
  const swapAmountToYInLamports = indirectSwapEstimate.swapAmountToY;
4504
5107
  if (!indirectSwapEstimate.swapAmountToX.isZero() && indirectSwapEstimate.swapToX !== null) {
4505
- const { transaction: swapToXTransaction } = yield buildJupiterSwapTransaction(
5108
+ const swapToX = yield buildJupiterSwapTransaction(
5109
+ this.connection,
4506
5110
  user,
4507
5111
  inputTokenMint,
4508
5112
  tokenXMint,
@@ -4512,13 +5116,16 @@ var Zap = class {
4512
5116
  indirectSwapEstimate.swapToX,
4513
5117
  {
4514
5118
  jupiterApiUrl: this.jupiterApiUrl,
4515
- jupiterApiKey: this.jupiterApiKey
5119
+ jupiterApiKey: this.jupiterApiKey,
5120
+ jupiterApiVersion: this.jupiterApiVersion
4516
5121
  }
4517
5122
  );
4518
- swapTransactions.push(swapToXTransaction);
5123
+ swapInstructions.push(swapToX.instruction);
5124
+ swapLookupTables.push(swapToX.addressLookupTableAccounts);
4519
5125
  }
4520
5126
  if (!indirectSwapEstimate.swapAmountToY.isZero() && indirectSwapEstimate.swapToY !== null) {
4521
- const { transaction: swapToYTransaction } = yield buildJupiterSwapTransaction(
5127
+ const swapToY = yield buildJupiterSwapTransaction(
5128
+ this.connection,
4522
5129
  user,
4523
5130
  inputTokenMint,
4524
5131
  tokenYMint,
@@ -4528,11 +5135,16 @@ var Zap = class {
4528
5135
  indirectSwapEstimate.swapToY,
4529
5136
  {
4530
5137
  jupiterApiUrl: this.jupiterApiUrl,
4531
- jupiterApiKey: this.jupiterApiKey
5138
+ jupiterApiKey: this.jupiterApiKey,
5139
+ jupiterApiVersion: this.jupiterApiVersion
4532
5140
  }
4533
5141
  );
4534
- swapTransactions.push(swapToYTransaction);
5142
+ swapInstructions.push(swapToY.instruction);
5143
+ swapLookupTables.push(swapToY.addressLookupTableAccounts);
4535
5144
  }
5145
+ const addressLookupTableAccounts = mergeAddressLookupTableAccounts(
5146
+ ...swapLookupTables
5147
+ );
4536
5148
  maxTransferAmountX = getExtendMaxAmountTransfer(
4537
5149
  indirectSwapEstimate.postSwapX.toString(),
4538
5150
  maxTransferAmountExtendPercentage
@@ -4543,8 +5155,8 @@ var Zap = class {
4543
5155
  );
4544
5156
  const binArrays = (0, import_dlmm4.getBinArraysRequiredByPositionRange)(
4545
5157
  lbPair,
4546
- new import_anchor.BN(activeId + minDeltaId),
4547
- new import_anchor.BN(activeId + maxDeltaId),
5158
+ new import_core.BN(activeId + minDeltaId),
5159
+ new import_core.BN(activeId + maxDeltaId),
4548
5160
  DLMM_PROGRAM_ID
4549
5161
  ).map((item) => ({
4550
5162
  pubkey: item.key,
@@ -4574,7 +5186,8 @@ var Zap = class {
4574
5186
  maxTransferAmountX,
4575
5187
  maxTransferAmountY,
4576
5188
  preInstructions,
4577
- swapTransactions,
5189
+ swapInstructions,
5190
+ addressLookupTableAccounts,
4578
5191
  cleanUpInstructions,
4579
5192
  binArrays,
4580
5193
  binArrayBitmapExtension: binArrayBitmapExtensionData ? binArrayBitmapExtension : null,
@@ -4584,7 +5197,12 @@ var Zap = class {
4584
5197
  });
4585
5198
  }
4586
5199
  /**
4587
- * Builds a DLMM zap-in transaction
5200
+ * Build the DLMM zap-in instructions
5201
+ *
5202
+ * Instructions are ordered: setup (token accounts, wrap SOL), swaps, ledger, zap in, clean up.
5203
+ * They must run in that order but can be split across several transactions, because state
5204
+ * between steps lives in accounts. Splitting loses atomicity, so send split transactions as a bundle.
5205
+ * No compute budget instructions are included; the client sets the compute budget for each transaction.
4588
5206
  *
4589
5207
  * @param params.user - The user's public key
4590
5208
  * @param params.lbPair - The DLMM pool's public key
@@ -4600,13 +5218,14 @@ var Zap = class {
4600
5218
  * @param params.favorXInActiveId - Whether to favor token X in the active bin
4601
5219
  * @param params.strategy - The liquidity distribution strategy
4602
5220
  * @param params.preInstructions - Instructions to run before the zap in
4603
- * @param params.swapTransactions - Swap transactions to execute
5221
+ * @param params.swapInstructions - Swap instructions to execute
5222
+ * @param params.addressLookupTableAccounts - Lookup tables used by the swap instructions
4604
5223
  * @param params.cleanUpInstructions - Instructions to run after the zap in
4605
5224
  * @param params.binArrays - The bin arrays required for the position
4606
5225
  * @param params.binArrayBitmapExtension - The bin array bitmap extension account if it exists
4607
5226
  * @param params.isDirectRoute - Whether this is a direct route
4608
5227
  * @param params.singleSided - Optional single-sided deposit mode (X or Y only) - default is non-single-sided
4609
- * @returns Response containing transaction components
5228
+ * @returns The ordered instructions and the lookup tables they use
4610
5229
  */
4611
5230
  buildZapInDlmmTransaction(params) {
4612
5231
  return __async(this, null, function* () {
@@ -4625,7 +5244,8 @@ var Zap = class {
4625
5244
  favorXInActiveId,
4626
5245
  strategy,
4627
5246
  preInstructions,
4628
- swapTransactions,
5247
+ swapInstructions,
5248
+ addressLookupTableAccounts,
4629
5249
  cleanUpInstructions,
4630
5250
  binArrays,
4631
5251
  binArrayBitmapExtension,
@@ -4653,62 +5273,58 @@ var Zap = class {
4653
5273
  tokenYProgram
4654
5274
  )
4655
5275
  ]);
4656
- const setupTransaction = new import_web38.Transaction();
4657
- initializeTokenXIx && setupTransaction.add(initializeTokenXIx);
4658
- initializeTokenYIx && setupTransaction.add(initializeTokenYIx);
4659
- if (preInstructions.length > 0) {
4660
- setupTransaction.add(...preInstructions);
4661
- }
4662
- const ledgerTransaction = new import_web38.Transaction();
4663
- const resetOrInitializeLedgerTx = yield this.resetOrInitializeLedgerAccount(user);
4664
- ledgerTransaction.add(resetOrInitializeLedgerTx);
5276
+ const setupInstructions = [];
5277
+ initializeTokenXIx && setupInstructions.push(initializeTokenXIx);
5278
+ initializeTokenYIx && setupInstructions.push(initializeTokenYIx);
5279
+ setupInstructions.push(...preInstructions);
5280
+ const ledgerInstructions = yield this.resetOrInitializeLedgerAccount(user);
4665
5281
  if (isDirectRoute) {
4666
5282
  const { isTokenX, amount, maxTransferAmount } = params;
4667
5283
  if (singleSided !== void 0) {
4668
5284
  const singleSidedX = singleSided === 0 /* X */;
4669
- if (swapTransactions.length > 0) {
5285
+ if (swapInstructions.length > 0) {
4670
5286
  const swappedTokenAccount = singleSidedX ? tokenXAccount : tokenYAccount;
4671
5287
  const preSwappedTokenBalance = yield getTokenAccountBalance(
4672
5288
  this.connection,
4673
5289
  swappedTokenAccount
4674
5290
  );
4675
- const updateLedgerBalanceAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
5291
+ const updateLedgerBalanceAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4676
5292
  user,
4677
5293
  swappedTokenAccount,
4678
- new import_anchor.BN(preSwappedTokenBalance),
5294
+ new import_core.BN(preSwappedTokenBalance),
4679
5295
  maxTransferAmount,
4680
5296
  singleSidedX
4681
5297
  );
4682
- ledgerTransaction.add(updateLedgerBalanceAfterSwapTx);
5298
+ ledgerInstructions.push(updateLedgerBalanceAfterSwapIx);
4683
5299
  } else {
4684
- const setLedgerBalanceTx = yield this.setLedgerBalance(
5300
+ const setLedgerBalanceIx = yield this.setLedgerBalance(
4685
5301
  user,
4686
5302
  amount,
4687
5303
  singleSidedX
4688
5304
  );
4689
- ledgerTransaction.add(setLedgerBalanceTx);
5305
+ ledgerInstructions.push(setLedgerBalanceIx);
4690
5306
  }
4691
5307
  } else {
4692
- const setLedgerBalanceTx = yield this.setLedgerBalance(
5308
+ const setLedgerBalanceIx = yield this.setLedgerBalance(
4693
5309
  user,
4694
5310
  amount,
4695
5311
  isTokenX
4696
5312
  );
4697
- ledgerTransaction.add(setLedgerBalanceTx);
4698
- if (swapTransactions.length > 0) {
5313
+ ledgerInstructions.push(setLedgerBalanceIx);
5314
+ if (swapInstructions.length > 0) {
4699
5315
  const swappedTokenAccount = isTokenX ? tokenYAccount : tokenXAccount;
4700
5316
  const preSwappedTokenBalance = yield getTokenAccountBalance(
4701
5317
  this.connection,
4702
5318
  swappedTokenAccount
4703
5319
  );
4704
- const updateLedgerBalanceAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
5320
+ const updateLedgerBalanceAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4705
5321
  user,
4706
5322
  swappedTokenAccount,
4707
- new import_anchor.BN(preSwappedTokenBalance),
5323
+ new import_core.BN(preSwappedTokenBalance),
4708
5324
  maxTransferAmount,
4709
5325
  !isTokenX
4710
5326
  );
4711
- ledgerTransaction.add(updateLedgerBalanceAfterSwapTx);
5327
+ ledgerInstructions.push(updateLedgerBalanceAfterSwapIx);
4712
5328
  }
4713
5329
  }
4714
5330
  } else {
@@ -4720,14 +5336,14 @@ var Zap = class {
4720
5336
  this.connection,
4721
5337
  swappedTokenAccount
4722
5338
  );
4723
- const updateLedgerBalanceAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
5339
+ const updateLedgerBalanceAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4724
5340
  user,
4725
5341
  swappedTokenAccount,
4726
- new import_anchor.BN(preSwappedTokenBalance),
5342
+ new import_core.BN(preSwappedTokenBalance),
4727
5343
  singleSidedX ? maxTransferAmountX : maxTransferAmountY,
4728
5344
  singleSidedX
4729
5345
  );
4730
- ledgerTransaction.add(updateLedgerBalanceAfterSwapTx);
5346
+ ledgerInstructions.push(updateLedgerBalanceAfterSwapIx);
4731
5347
  } else {
4732
5348
  const preTokenXBalance = yield getTokenAccountBalance(
4733
5349
  this.connection,
@@ -4737,22 +5353,22 @@ var Zap = class {
4737
5353
  this.connection,
4738
5354
  tokenYAccount
4739
5355
  );
4740
- const updateLedgerBalanceTokenXAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
5356
+ const updateLedgerBalanceTokenXAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4741
5357
  user,
4742
5358
  tokenXAccount,
4743
- new import_anchor.BN(preTokenXBalance),
5359
+ new import_core.BN(preTokenXBalance),
4744
5360
  maxTransferAmountX,
4745
5361
  true
4746
5362
  );
4747
- const updateLedgerBalanceTokenYAfterSwapTx = yield this.updateLedgerBalanceAfterSwap(
5363
+ const updateLedgerBalanceTokenYAfterSwapIx = yield this.updateLedgerBalanceAfterSwap(
4748
5364
  user,
4749
5365
  tokenYAccount,
4750
- new import_anchor.BN(preTokenYBalance),
5366
+ new import_core.BN(preTokenYBalance),
4751
5367
  maxTransferAmountY,
4752
5368
  false
4753
5369
  );
4754
- ledgerTransaction.add(updateLedgerBalanceTokenXAfterSwapTx);
4755
- ledgerTransaction.add(updateLedgerBalanceTokenYAfterSwapTx);
5370
+ ledgerInstructions.push(updateLedgerBalanceTokenXAfterSwapIx);
5371
+ ledgerInstructions.push(updateLedgerBalanceTokenYAfterSwapIx);
4756
5372
  }
4757
5373
  }
4758
5374
  const dlmm = yield import_dlmm4.default.create(this.connection, lbPair);
@@ -4766,7 +5382,7 @@ var Zap = class {
4766
5382
  tokenYProgram,
4767
5383
  dlmm.lbPair
4768
5384
  );
4769
- const zapInTransaction = yield this.zapInDlmmForUninitializedPosition({
5385
+ const zapInInstruction = yield this.zapInDlmmForUninitializedPosition({
4770
5386
  user,
4771
5387
  lbPair,
4772
5388
  position,
@@ -4780,18 +5396,17 @@ var Zap = class {
4780
5396
  strategy,
4781
5397
  remainingAccountInfo
4782
5398
  });
4783
- const cleanUpTransaction = new import_web38.Transaction();
4784
- const closeLedgerTransaction = yield this.closeLedgerAccount(user, user);
4785
- cleanUpTransaction.add(closeLedgerTransaction);
4786
- if (cleanUpInstructions.length > 0) {
4787
- cleanUpTransaction.add(...cleanUpInstructions);
4788
- }
5399
+ const closeLedgerInstruction = yield this.closeLedgerAccount(user, user);
4789
5400
  return {
4790
- setupTransaction: setupTransaction.instructions.length > 0 ? setupTransaction : void 0,
4791
- swapTransactions,
4792
- ledgerTransaction,
4793
- zapInTransaction,
4794
- cleanUpTransaction
5401
+ instructions: [
5402
+ ...setupInstructions,
5403
+ ...swapInstructions,
5404
+ ...ledgerInstructions,
5405
+ zapInInstruction,
5406
+ closeLedgerInstruction,
5407
+ ...cleanUpInstructions
5408
+ ],
5409
+ addressLookupTableAccounts
4795
5410
  };
4796
5411
  });
4797
5412
  }
@@ -4799,6 +5414,13 @@ var Zap = class {
4799
5414
  * High level method for DLMM position rebalancing
4800
5415
  * Consist of remove liquidity, zap out through Jupiter or DLMM, and zap back in to rebalance the position
4801
5416
  *
5417
+ * Instructions are ordered: setup (token accounts), init bin arrays, rebalance position, swap, ledger,
5418
+ * zap in, clean up. They must run in that order but can be split across several transactions.
5419
+ * Splitting loses atomicity, so send split transactions as a bundle.
5420
+ * No compute budget instructions are included. The zap-in instruction was measured at about 462k
5421
+ * compute units. Without a compute unit limit, a transaction gets 200k units per instruction (up to
5422
+ * 1.4M), which may not cover it, so set a compute unit limit on the transaction that holds it.
5423
+ *
4802
5424
  * @param params - Rebalancing DLMM position parameters
4803
5425
  * @param params.lbPairAddress - The DLMM pool address
4804
5426
  * @param params.positionAddress - The position address
@@ -4811,7 +5433,7 @@ var Zap = class {
4811
5433
  * @param params.favorXInActiveId - Whether to favor token X in the active bin
4812
5434
  * @param params.directSwapEstimate - The estimate of the direct swap operation
4813
5435
  * @param params.maxAccounts - The maximum number of accounts to use for the swap operation
4814
- * @returns Response containing transactions and estimation details
5436
+ * @returns The ordered instructions, the lookup tables they use, and the estimated balances
4815
5437
  * @throws if fail to get jupiter quote or jupiter swap instruction
4816
5438
  */
4817
5439
  rebalanceDlmmPosition(params) {
@@ -4853,18 +5475,18 @@ var Zap = class {
4853
5475
  tokenYProgram
4854
5476
  )
4855
5477
  ]);
4856
- const setupTransaction = new import_web38.Transaction();
4857
- userTokenXIx && setupTransaction.add(userTokenXIx);
4858
- userTokenYIx && setupTransaction.add(userTokenYIx);
5478
+ const setupInstructions = [];
5479
+ userTokenXIx && setupInstructions.push(userTokenXIx);
5480
+ userTokenYIx && setupInstructions.push(userTokenYIx);
4859
5481
  const strategyParamBuilder = (0, import_dlmm4.getLiquidityStrategyParameterBuilder)(strategy);
4860
5482
  const { x0, y0, deltaX, deltaY } = (0, import_dlmm4.buildLiquidityStrategyParameters)(
4861
- new import_anchor.BN(0),
4862
- new import_anchor.BN(0),
4863
- new import_anchor.BN(minDeltaId),
4864
- new import_anchor.BN(maxDeltaId),
4865
- new import_anchor.BN(dlmm.lbPair.binStep),
5483
+ new import_core.BN(0),
5484
+ new import_core.BN(0),
5485
+ new import_core.BN(minDeltaId),
5486
+ new import_core.BN(maxDeltaId),
5487
+ new import_core.BN(dlmm.lbPair.binStep),
4866
5488
  favorXInActiveId,
4867
- new import_anchor.BN(dlmm.lbPair.activeId),
5489
+ new import_core.BN(dlmm.lbPair.activeId),
4868
5490
  strategyParamBuilder
4869
5491
  );
4870
5492
  const { rebalancePosition, simulationResult } = yield dlmm.simulateRebalancePosition(
@@ -4880,16 +5502,16 @@ var Zap = class {
4880
5502
  y0,
4881
5503
  deltaX,
4882
5504
  deltaY,
4883
- minDeltaId: new import_anchor.BN(minDeltaId),
4884
- maxDeltaId: new import_anchor.BN(maxDeltaId),
5505
+ minDeltaId: new import_core.BN(minDeltaId),
5506
+ maxDeltaId: new import_core.BN(maxDeltaId),
4885
5507
  favorXInActiveBin: favorXInActiveId
4886
5508
  }
4887
5509
  ],
4888
5510
  [
4889
5511
  {
4890
- minBinId: new import_anchor.BN(userPosition.positionData.lowerBinId),
4891
- maxBinId: new import_anchor.BN(userPosition.positionData.upperBinId),
4892
- bps: new import_anchor.BN(import_dlmm4.BASIS_POINT_MAX)
5512
+ minBinId: new import_core.BN(userPosition.positionData.lowerBinId),
5513
+ maxBinId: new import_core.BN(userPosition.positionData.upperBinId),
5514
+ bps: new import_core.BN(import_dlmm4.BASIS_POINT_MAX)
4893
5515
  // remove all liquidity
4894
5516
  }
4895
5517
  ]
@@ -4904,21 +5526,25 @@ var Zap = class {
4904
5526
  rebalancePositionInstruction: _rebalancePositionInstruction
4905
5527
  } = yield dlmm.rebalancePosition(
4906
5528
  { simulationResult, rebalancePosition },
4907
- new import_anchor.BN(maxActiveBinSlippage)
5529
+ new import_core.BN(maxActiveBinSlippage)
5530
+ );
5531
+ let rebalancePositionInstruction = filterOutComputeBudgetInstructions(
5532
+ _rebalancePositionInstruction
4908
5533
  );
4909
- let rebalancePositionInstruction = _rebalancePositionInstruction;
4910
5534
  if (dlmm.lbPair.tokenXMint.equals(import_spl_token6.NATIVE_MINT) || dlmm.lbPair.tokenYMint.equals(import_spl_token6.NATIVE_MINT)) {
4911
5535
  rebalancePositionInstruction = filterOutCloseSplTokenAccountInstructions(
4912
- _rebalancePositionInstruction
5536
+ rebalancePositionInstruction
4913
5537
  );
4914
5538
  }
4915
- const tokenXAmount = new import_anchor.BN(userPosition.positionData.totalXAmount);
4916
- const tokenYAmount = new import_anchor.BN(userPosition.positionData.totalYAmount);
4917
- let swapTransaction;
5539
+ const tokenXAmount = new import_core.BN(userPosition.positionData.totalXAmount);
5540
+ const tokenYAmount = new import_core.BN(userPosition.positionData.totalYAmount);
5541
+ let swapInstructions = [];
5542
+ let addressLookupTableAccounts = [];
4918
5543
  if (directSwapEstimate.swapType !== 2 /* NoSwap */ && directSwapEstimate.quote) {
4919
5544
  const swapQuote = directSwapEstimate.quote;
4920
5545
  if (swapQuote.route === 0 /* Jupiter */) {
4921
- const { transaction: swapTx } = yield buildJupiterSwapTransaction(
5546
+ const swap = yield buildJupiterSwapTransaction(
5547
+ this.connection,
4922
5548
  user,
4923
5549
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenXMint : dlmm.lbPair.tokenYMint,
4924
5550
  directSwapEstimate.swapType === 0 /* XToY */ ? dlmm.lbPair.tokenYMint : dlmm.lbPair.tokenXMint,
@@ -4928,10 +5554,12 @@ var Zap = class {
4928
5554
  swapQuote.originalQuote,
4929
5555
  {
4930
5556
  jupiterApiUrl: this.jupiterApiUrl,
4931
- jupiterApiKey: this.jupiterApiKey
5557
+ jupiterApiKey: this.jupiterApiKey,
5558
+ jupiterApiVersion: this.jupiterApiVersion
4932
5559
  }
4933
5560
  );
4934
- swapTransaction = swapTx;
5561
+ swapInstructions = [swap.instruction];
5562
+ addressLookupTableAccounts = swap.addressLookupTableAccounts;
4935
5563
  } else {
4936
5564
  const swapForY = directSwapEstimate.swapType === 0 /* XToY */;
4937
5565
  const binArrays2 = yield dlmm.getBinArrayForSwap(swapForY);
@@ -4944,12 +5572,15 @@ var Zap = class {
4944
5572
  user,
4945
5573
  binArraysPubkey: binArrays2.map((item) => item.publicKey)
4946
5574
  });
5575
+ swapTx.instructions = filterOutComputeBudgetInstructions(
5576
+ swapTx.instructions
5577
+ );
4947
5578
  if (dlmm.lbPair.tokenXMint.equals(import_spl_token6.NATIVE_MINT) || dlmm.lbPair.tokenYMint.equals(import_spl_token6.NATIVE_MINT)) {
4948
5579
  swapTx.instructions = filterOutCloseSplTokenAccountInstructions(
4949
5580
  swapTx.instructions
4950
5581
  );
4951
5582
  }
4952
- swapTransaction = swapTx;
5583
+ swapInstructions = swapTx.instructions;
4953
5584
  }
4954
5585
  }
4955
5586
  const preTokenXBalance = yield getTokenAccountBalance(
@@ -4964,31 +5595,31 @@ var Zap = class {
4964
5595
  const tokenYAmountAfterSwap = directSwapEstimate.swapType === 0 /* XToY */ ? tokenYAmount.add(directSwapEstimate.expectedOutput) : directSwapEstimate.swapType === 1 /* YToX */ ? tokenYAmount.sub(directSwapEstimate.swapAmount) : tokenYAmount;
4965
5596
  const ledgerAddress = deriveLedgerAccount(user);
4966
5597
  const ledgerAccountInfo = yield this.connection.getAccountInfo(ledgerAddress);
4967
- const ledgerTransaction = new import_web38.Transaction();
5598
+ const ledgerInstructions = [];
4968
5599
  if (!ledgerAccountInfo) {
4969
- const initLedgerTx = yield this.initializeLedgerAccount(user, user);
4970
- ledgerTransaction.add(...initLedgerTx.instructions);
5600
+ const initLedgerIx = yield this.initializeLedgerAccount(user, user);
5601
+ ledgerInstructions.push(initLedgerIx);
4971
5602
  }
4972
- const updateLedgerXTx = yield this.updateLedgerBalanceAfterSwap(
5603
+ const updateLedgerXIx = yield this.updateLedgerBalanceAfterSwap(
4973
5604
  user,
4974
5605
  userTokenX,
4975
- new import_anchor.BN(preTokenXBalance),
5606
+ new import_core.BN(preTokenXBalance),
4976
5607
  tokenXAmountAfterSwap,
4977
5608
  true
4978
5609
  );
4979
- ledgerTransaction.add(...updateLedgerXTx.instructions);
4980
- const updateLedgerYTx = yield this.updateLedgerBalanceAfterSwap(
5610
+ ledgerInstructions.push(updateLedgerXIx);
5611
+ const updateLedgerYIx = yield this.updateLedgerBalanceAfterSwap(
4981
5612
  user,
4982
5613
  userTokenY,
4983
- new import_anchor.BN(preTokenYBalance),
5614
+ new import_core.BN(preTokenYBalance),
4984
5615
  tokenYAmountAfterSwap,
4985
5616
  false
4986
5617
  );
4987
- ledgerTransaction.add(...updateLedgerYTx.instructions);
5618
+ ledgerInstructions.push(updateLedgerYIx);
4988
5619
  const binArrays = (0, import_dlmm4.getBinArraysRequiredByPositionRange)(
4989
5620
  lbPair,
4990
- new import_anchor.BN(dlmm.lbPair.activeId + minDeltaId),
4991
- new import_anchor.BN(dlmm.lbPair.activeId + maxDeltaId),
5621
+ new import_core.BN(dlmm.lbPair.activeId + minDeltaId),
5622
+ new import_core.BN(dlmm.lbPair.activeId + maxDeltaId),
4992
5623
  DLMM_PROGRAM_ID
4993
5624
  ).map((item) => ({
4994
5625
  pubkey: item.key,
@@ -5005,7 +5636,7 @@ var Zap = class {
5005
5636
  tokenYProgram,
5006
5637
  dlmm.lbPair
5007
5638
  );
5008
- const zapInTransaction = yield this.zapInDlmmForInitializedPosition({
5639
+ const zapInInstruction = yield this.zapInDlmmForInitializedPosition({
5009
5640
  user,
5010
5641
  lbPair,
5011
5642
  position,
@@ -5018,28 +5649,26 @@ var Zap = class {
5018
5649
  strategy,
5019
5650
  remainingAccountInfo
5020
5651
  });
5021
- zapInTransaction.instructions.unshift(
5022
- // based on 1 tx that consumed 462_610. Add 20% for safety and round up to nearest 100,000
5023
- // 462_610 * 1.2 = 555_132 => 600_000
5024
- import_web38.ComputeBudgetProgram.setComputeUnitLimit({ units: 6e5 })
5025
- );
5026
- const cleanUpTransaction = new import_web38.Transaction();
5027
- const closeLedgerTx = yield this.closeLedgerAccount(user, user);
5028
- cleanUpTransaction.add(closeLedgerTx);
5652
+ const cleanUpInstructions = [
5653
+ yield this.closeLedgerAccount(user, user)
5654
+ ];
5029
5655
  if (dlmm.lbPair.tokenXMint.equals(import_spl_token6.NATIVE_MINT) || dlmm.lbPair.tokenYMint.equals(import_spl_token6.NATIVE_MINT)) {
5030
5656
  const unwrapIx = unwrapSOLInstruction(user, user);
5031
5657
  if (unwrapIx) {
5032
- cleanUpTransaction.add(unwrapIx);
5658
+ cleanUpInstructions.push(unwrapIx);
5033
5659
  }
5034
5660
  }
5035
5661
  return {
5036
- setupTransaction,
5037
- initBinArrayTransaction: initBinArrayInstructions.length > 0 ? new import_web38.Transaction().add(...initBinArrayInstructions) : void 0,
5038
- rebalancePositionTransaction: rebalancePositionInstruction.length > 0 ? new import_web38.Transaction().add(...rebalancePositionInstruction) : void 0,
5039
- swapTransaction,
5040
- ledgerTransaction,
5041
- zapInTransaction,
5042
- cleanUpTransaction,
5662
+ instructions: [
5663
+ ...setupInstructions,
5664
+ ...filterOutComputeBudgetInstructions(initBinArrayInstructions),
5665
+ ...rebalancePositionInstruction,
5666
+ ...swapInstructions,
5667
+ ...ledgerInstructions,
5668
+ zapInInstruction,
5669
+ ...cleanUpInstructions
5670
+ ],
5671
+ addressLookupTableAccounts,
5043
5672
  estimation: {
5044
5673
  currentBalances: {
5045
5674
  tokenX: tokenXAmount,
@@ -5065,7 +5694,7 @@ var Zap = class {
5065
5694
  * @param params.ammProgram - AMM program ID to interact with
5066
5695
  * @param params.preInstructions - Instructions to run before the zap out
5067
5696
  * @param params.postInstructions - Instructions to run after the zap out
5068
- * @returns builder transaction
5697
+ * @returns The pre-instructions, the zap out instruction and the post-instructions in order, with no lookup tables
5069
5698
  */
5070
5699
  zapOut(params) {
5071
5700
  return __async(this, null, function* () {
@@ -5077,10 +5706,18 @@ var Zap = class {
5077
5706
  preInstructions,
5078
5707
  postInstructions
5079
5708
  } = params;
5080
- return this.zapProgram.methods.zapOut(zapOutParams).accountsPartial({
5709
+ const zapOutInstruction = yield this.zapProgram.methods.zapOut(zapOutParams).accountsPartial({
5081
5710
  userTokenInAccount,
5082
5711
  ammProgram
5083
- }).remainingAccounts(remainingAccounts).preInstructions(preInstructions).postInstructions(postInstructions).transaction();
5712
+ }).remainingAccounts(remainingAccounts).instruction();
5713
+ return {
5714
+ instructions: [
5715
+ ...preInstructions,
5716
+ zapOutInstruction,
5717
+ ...postInstructions
5718
+ ],
5719
+ addressLookupTableAccounts: []
5720
+ };
5084
5721
  });
5085
5722
  }
5086
5723
  /**
@@ -5091,12 +5728,12 @@ var Zap = class {
5091
5728
  * @param params.user - Public key of the user performing the swap
5092
5729
  * @param params.inputMint - Token mint being swapped from
5093
5730
  * @param params.outputMint - Token mint being swapped to
5094
- * @param params.jupiterSwapResponse - Jupiter swap instruction response
5731
+ * @param params.jupiterSwapResponse - Jupiter swap instruction response. Its lookup table fields, when present, are returned as `addressLookupTableAccounts` (v1 tables are fetched with one RPC call)
5095
5732
  * @param params.inputTokenProgram - Token program for the input token (defaults to SPL Token)
5096
5733
  * @param params.outputTokenProgram - Token program for the output token (defaults to SPL Token)
5097
5734
  * @param params.maxSwapAmount - Maximum amount of input token to swap
5098
5735
  * @param params.percentageToZapOut - Percentage of input token to zap out
5099
- * @returns built transaction
5736
+ * @returns The ordered instructions and the lookup tables of the Jupiter swap
5100
5737
  */
5101
5738
  zapOutThroughJupiter(params) {
5102
5739
  return __async(this, null, function* () {
@@ -5114,7 +5751,7 @@ var Zap = class {
5114
5751
  const postInstructions = [];
5115
5752
  const [
5116
5753
  { ataPubkey: inputTokenAccount, ix: inputTokenAccountIx },
5117
- { ataPubkey: outputTokenAccount, ix: outputTokenAccountIx }
5754
+ { ix: outputTokenAccountIx }
5118
5755
  ] = yield Promise.all([
5119
5756
  getOrCreateATAInstruction(
5120
5757
  this.connection,
@@ -5158,27 +5795,36 @@ var Zap = class {
5158
5795
  jupiterSwapResponse.swapInstruction.data,
5159
5796
  "base64"
5160
5797
  );
5161
- const offsetAmountIn = payloadData.length - AMOUNT_IN_JUP_V6_REVERSE_OFFSET;
5798
+ const offsetAmountIn = getJupiterInstructionLayout(
5799
+ payloadData
5800
+ ).amountInOffset(payloadData.length);
5162
5801
  if (inputMint.equals(import_spl_token6.NATIVE_MINT) || outputMint.equals(import_spl_token6.NATIVE_MINT)) {
5163
5802
  const unwrapInstructions = unwrapSOLInstruction(user, user);
5164
5803
  if (unwrapInstructions) {
5165
5804
  postInstructions.push(unwrapInstructions);
5166
5805
  }
5167
5806
  }
5168
- return yield this.zapOut({
5169
- userTokenInAccount: inputTokenAccount,
5170
- zapOutParams: {
5171
- percentage: percentageToZapOut,
5172
- offsetAmountIn,
5173
- preUserTokenBalance: new import_anchor.BN(preUserTokenBalance),
5174
- maxSwapAmount,
5175
- payloadData
5176
- },
5177
- remainingAccounts,
5178
- ammProgram: JUP_V6_PROGRAM_ID,
5179
- preInstructions,
5180
- postInstructions
5181
- });
5807
+ const [{ instructions }, addressLookupTableAccounts] = yield Promise.all([
5808
+ this.zapOut({
5809
+ userTokenInAccount: inputTokenAccount,
5810
+ zapOutParams: {
5811
+ percentage: percentageToZapOut,
5812
+ offsetAmountIn,
5813
+ preUserTokenBalance: new import_core.BN(preUserTokenBalance),
5814
+ maxSwapAmount,
5815
+ payloadData
5816
+ },
5817
+ remainingAccounts,
5818
+ ammProgram: JUP_V6_PROGRAM_ID,
5819
+ preInstructions,
5820
+ postInstructions
5821
+ }),
5822
+ getJupiterAddressLookupTableAccounts(
5823
+ this.connection,
5824
+ jupiterSwapResponse
5825
+ )
5826
+ ]);
5827
+ return { instructions, addressLookupTableAccounts };
5182
5828
  });
5183
5829
  }
5184
5830
  /**
@@ -5194,6 +5840,7 @@ var Zap = class {
5194
5840
  * @param params.minimumSwapAmountOut - Minimum amount of output token to receive
5195
5841
  * @param params.maxSwapAmount - Maximum amount of input token to swap
5196
5842
  * @param params.percentageToZapOut - Percentage of input token to zap out
5843
+ * @returns The ordered instructions, with no lookup tables
5197
5844
  */
5198
5845
  zapOutThroughDammV2(params) {
5199
5846
  return __async(this, null, function* () {
@@ -5266,7 +5913,7 @@ var Zap = class {
5266
5913
  zapOutParams: {
5267
5914
  percentage: percentageToZapOut,
5268
5915
  offsetAmountIn,
5269
- preUserTokenBalance: new import_anchor.BN(preUserTokenBalance),
5916
+ preUserTokenBalance: new import_core.BN(preUserTokenBalance),
5270
5917
  maxSwapAmount,
5271
5918
  payloadData
5272
5919
  },
@@ -5290,6 +5937,7 @@ var Zap = class {
5290
5937
  * @param params.minimumSwapAmountOut - Minimum amount of output token to receive
5291
5938
  * @param params.maxSwapAmount - Maximum amount of input token to swap
5292
5939
  * @param params.percentageToZapOut - Percentage of input token to zap out
5940
+ * @returns The ordered instructions, with no lookup tables
5293
5941
  */
5294
5942
  zapOutThroughDlmm(params) {
5295
5943
  return __async(this, null, function* () {
@@ -5366,7 +6014,7 @@ var Zap = class {
5366
6014
  zapOutParams: {
5367
6015
  percentage: percentageToZapOut,
5368
6016
  offsetAmountIn: AMOUNT_IN_DLMM_OFFSET,
5369
- preUserTokenBalance: new import_anchor.BN(preUserTokenBalance),
6017
+ preUserTokenBalance: new import_core.BN(preUserTokenBalance),
5370
6018
  maxSwapAmount,
5371
6019
  payloadData
5372
6020
  },
@@ -5388,12 +6036,20 @@ var Zap = class {
5388
6036
  DAMM_V2_PROGRAM_ID,
5389
6037
  DAMM_V2_SWAP_DISCRIMINATOR,
5390
6038
  DEFAULT_JUPITER_API_URL,
6039
+ DEFAULT_JUPITER_API_VERSION,
6040
+ DEFAULT_JUPITER_QUOTE_OPTIONS,
5391
6041
  DLMM_PROGRAM_ID,
5392
6042
  DLMM_SWAP_DISCRIMINATOR,
5393
6043
  DlmmDirectSwapQuoteRoute,
5394
6044
  DlmmSingleSided,
5395
6045
  DlmmSwapType,
6046
+ JUPITER_INSTRUCTION_LAYOUTS,
5396
6047
  JUP_V6_PROGRAM_ID,
6048
+ JUP_V6_ROUTE_DISCRIMINATOR,
6049
+ JUP_V6_ROUTE_V2_DISCRIMINATOR,
6050
+ JUP_V6_SHARED_ACCOUNTS_ROUTE_DISCRIMINATOR,
6051
+ JUP_V6_SHARED_ACCOUNTS_ROUTE_V2_DISCRIMINATOR,
6052
+ JupiterApiVersion,
5397
6053
  MEMO_PROGRAM_ID,
5398
6054
  SwapExternalType,
5399
6055
  ZAP_PROGRAM_ID,
@@ -5413,13 +6069,17 @@ var Zap = class {
5413
6069
  estimateDlmmDirectSwap,
5414
6070
  estimateDlmmIndirectSwap,
5415
6071
  estimateDlmmRebalanceSwap,
6072
+ fetchAddressLookupTableAccounts,
5416
6073
  filterOutCloseSplTokenAccountInstructions,
6074
+ filterOutComputeBudgetInstructions,
5417
6075
  getBinArrayBitmapExtension,
5418
6076
  getBitFromBinArrayIndexInBitmapExtension,
5419
6077
  getDammV2Pool,
5420
6078
  getDammV2RemainingAccounts,
5421
6079
  getDlmmRemainingAccounts,
5422
6080
  getExtraAccountMetasForTransferHook,
6081
+ getJupiterAddressLookupTableAccounts,
6082
+ getJupiterInstructionLayout,
5423
6083
  getJupiterQuote,
5424
6084
  getJupiterSwapInstruction,
5425
6085
  getLbPairState,
@@ -5427,8 +6087,13 @@ var Zap = class {
5427
6087
  getOrCreateATAInstruction,
5428
6088
  getTokenAccountBalance,
5429
6089
  getTokenProgramFromMint,
6090
+ isJupiterBuildResponse,
6091
+ isJupiterSwapInstructionForUser,
5430
6092
  isSingleSidedA,
5431
6093
  isSingleSidedB,
6094
+ mergeAddressLookupTableAccounts,
6095
+ resolveJupiterConfig,
6096
+ toAddressLookupTableAccounts,
5432
6097
  toProgramStrategyType,
5433
6098
  unwrapSOLInstruction,
5434
6099
  wrapSOLInstruction