@meteora-ag/zap-sdk 1.0.8 → 1.1.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,9 +1,10 @@
1
1
  import * as _solana_web3_js from '@solana/web3.js';
2
- import { PublicKey, AccountMeta, TransactionInstruction, Connection, Transaction } from '@solana/web3.js';
3
- import { IdlTypes, Program } from '@coral-xyz/anchor';
2
+ import { PublicKey, TransactionInstruction, Transaction, AccountMeta, Connection } from '@solana/web3.js';
3
+ import { Program, IdlTypes } from '@coral-xyz/anchor';
4
4
  import BN from 'bn.js';
5
+ import Decimal from 'decimal.js';
6
+ import DLMM, { StrategyType, SwapQuote, RemainingAccountInfo, LbPair, BinArrayBitmapExtension } from '@meteora-ag/dlmm';
5
7
  import { PoolState } from '@meteora-ag/cp-amm-sdk';
6
- import { LbPair, BinArrayBitmapExtension, RemainingAccountInfo } from '@meteora-ag/dlmm';
7
8
 
8
9
  /**
9
10
  * Program IDL in camelCase format in order to be used in JS/TS.
@@ -12,14 +13,432 @@ import { LbPair, BinArrayBitmapExtension, RemainingAccountInfo } from '@meteora-
12
13
  * IDL can be found at `target/idl/zap.json`.
13
14
  */
14
15
  type Zap$1 = {
15
- address: "zapvX9M3uf5pvy4wRPAbQgdQsM1xmuiFnkfHKPvwMiz";
16
+ address: "TzaptpzVczx3Q3rwujjXdhx1HFBXLP7UApACiqWujtA";
16
17
  metadata: {
17
18
  name: "zap";
18
- version: "0.1.0";
19
+ version: "0.2.0";
19
20
  spec: "0.1.0";
20
21
  description: "Created with Anchor";
21
22
  };
22
23
  instructions: [
24
+ {
25
+ name: "closeLedgerAccount";
26
+ discriminator: [189, 122, 172, 13, 122, 54, 54, 51];
27
+ accounts: [
28
+ {
29
+ name: "ledger";
30
+ writable: true;
31
+ },
32
+ {
33
+ name: "owner";
34
+ signer: true;
35
+ relations: ["ledger"];
36
+ },
37
+ {
38
+ name: "rentReceiver";
39
+ writable: true;
40
+ signer: true;
41
+ }
42
+ ];
43
+ args: [];
44
+ },
45
+ {
46
+ name: "initializeLedgerAccount";
47
+ discriminator: [120, 69, 30, 74, 76, 242, 153, 162];
48
+ accounts: [
49
+ {
50
+ name: "ledger";
51
+ writable: true;
52
+ pda: {
53
+ seeds: [
54
+ {
55
+ kind: "const";
56
+ value: [117, 115, 101, 114, 95, 108, 101, 100, 103, 101, 114];
57
+ },
58
+ {
59
+ kind: "account";
60
+ path: "owner";
61
+ }
62
+ ];
63
+ };
64
+ },
65
+ {
66
+ name: "owner";
67
+ signer: true;
68
+ },
69
+ {
70
+ name: "payer";
71
+ writable: true;
72
+ signer: true;
73
+ },
74
+ {
75
+ name: "systemProgram";
76
+ address: "11111111111111111111111111111111";
77
+ }
78
+ ];
79
+ args: [];
80
+ },
81
+ {
82
+ name: "setLedgerBalance";
83
+ discriminator: [131, 49, 240, 17, 228, 248, 156, 54];
84
+ accounts: [
85
+ {
86
+ name: "ledger";
87
+ writable: true;
88
+ },
89
+ {
90
+ name: "owner";
91
+ signer: true;
92
+ relations: ["ledger"];
93
+ }
94
+ ];
95
+ args: [
96
+ {
97
+ name: "amount";
98
+ type: "u64";
99
+ },
100
+ {
101
+ name: "isTokenA";
102
+ type: "bool";
103
+ }
104
+ ];
105
+ },
106
+ {
107
+ name: "updateLedgerBalanceAfterSwap";
108
+ discriminator: [59, 206, 173, 232, 94, 57, 174, 202];
109
+ accounts: [
110
+ {
111
+ name: "ledger";
112
+ writable: true;
113
+ },
114
+ {
115
+ name: "tokenAccount";
116
+ },
117
+ {
118
+ name: "owner";
119
+ signer: true;
120
+ relations: ["ledger"];
121
+ }
122
+ ];
123
+ args: [
124
+ {
125
+ name: "preSourceTokenBalance";
126
+ type: "u64";
127
+ },
128
+ {
129
+ name: "maxTransferAmount";
130
+ type: "u64";
131
+ },
132
+ {
133
+ name: "isTokenA";
134
+ type: "bool";
135
+ }
136
+ ];
137
+ },
138
+ {
139
+ name: "zapInDammV2";
140
+ discriminator: [243, 243, 119, 52, 199, 44, 154, 186];
141
+ accounts: [
142
+ {
143
+ name: "ledger";
144
+ writable: true;
145
+ },
146
+ {
147
+ name: "pool";
148
+ writable: true;
149
+ },
150
+ {
151
+ name: "poolAuthority";
152
+ },
153
+ {
154
+ name: "position";
155
+ writable: true;
156
+ },
157
+ {
158
+ name: "tokenAAccount";
159
+ writable: true;
160
+ },
161
+ {
162
+ name: "tokenBAccount";
163
+ writable: true;
164
+ },
165
+ {
166
+ name: "tokenAVault";
167
+ writable: true;
168
+ },
169
+ {
170
+ name: "tokenBVault";
171
+ writable: true;
172
+ },
173
+ {
174
+ name: "tokenAMint";
175
+ },
176
+ {
177
+ name: "tokenBMint";
178
+ },
179
+ {
180
+ name: "positionNftAccount";
181
+ },
182
+ {
183
+ name: "owner";
184
+ docs: ["owner of position"];
185
+ signer: true;
186
+ relations: ["ledger"];
187
+ },
188
+ {
189
+ name: "tokenAProgram";
190
+ },
191
+ {
192
+ name: "tokenBProgram";
193
+ },
194
+ {
195
+ name: "dammProgram";
196
+ address: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
197
+ },
198
+ {
199
+ name: "dammEventAuthority";
200
+ }
201
+ ];
202
+ args: [
203
+ {
204
+ name: "preSqrtPrice";
205
+ type: "u128";
206
+ },
207
+ {
208
+ name: "maxSqrtPriceChangeBps";
209
+ type: "u32";
210
+ }
211
+ ];
212
+ },
213
+ {
214
+ name: "zapInDlmmForInitializedPosition";
215
+ discriminator: [184, 71, 198, 231, 129, 110, 193, 67];
216
+ accounts: [
217
+ {
218
+ name: "ledger";
219
+ writable: true;
220
+ },
221
+ {
222
+ name: "lbPair";
223
+ docs: ["lb pair"];
224
+ writable: true;
225
+ },
226
+ {
227
+ name: "position";
228
+ writable: true;
229
+ },
230
+ {
231
+ name: "binArrayBitmapExtension";
232
+ writable: true;
233
+ optional: true;
234
+ },
235
+ {
236
+ name: "userTokenX";
237
+ writable: true;
238
+ },
239
+ {
240
+ name: "userTokenY";
241
+ writable: true;
242
+ },
243
+ {
244
+ name: "reserveX";
245
+ writable: true;
246
+ },
247
+ {
248
+ name: "reserveY";
249
+ writable: true;
250
+ },
251
+ {
252
+ name: "tokenXMint";
253
+ },
254
+ {
255
+ name: "tokenYMint";
256
+ },
257
+ {
258
+ name: "dlmmProgram";
259
+ address: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
260
+ },
261
+ {
262
+ name: "owner";
263
+ docs: ["owner of position"];
264
+ signer: true;
265
+ relations: ["ledger"];
266
+ },
267
+ {
268
+ name: "rentPayer";
269
+ writable: true;
270
+ signer: true;
271
+ },
272
+ {
273
+ name: "tokenXProgram";
274
+ },
275
+ {
276
+ name: "tokenYProgram";
277
+ },
278
+ {
279
+ name: "memoProgram";
280
+ },
281
+ {
282
+ name: "systemProgram";
283
+ },
284
+ {
285
+ name: "dlmmEventAuthority";
286
+ }
287
+ ];
288
+ args: [
289
+ {
290
+ name: "activeId";
291
+ type: "i32";
292
+ },
293
+ {
294
+ name: "minDeltaId";
295
+ type: "i32";
296
+ },
297
+ {
298
+ name: "maxDeltaId";
299
+ type: "i32";
300
+ },
301
+ {
302
+ name: "maxActiveBinSlippage";
303
+ type: "u16";
304
+ },
305
+ {
306
+ name: "favorXInActiveId";
307
+ type: "bool";
308
+ },
309
+ {
310
+ name: "strategy";
311
+ type: {
312
+ defined: {
313
+ name: "strategyType";
314
+ };
315
+ };
316
+ },
317
+ {
318
+ name: "remainingAccountsInfo";
319
+ type: {
320
+ defined: {
321
+ name: "remainingAccountsInfo";
322
+ };
323
+ };
324
+ }
325
+ ];
326
+ },
327
+ {
328
+ name: "zapInDlmmForUninitializedPosition";
329
+ discriminator: [59, 220, 182, 27, 254, 253, 2, 232];
330
+ accounts: [
331
+ {
332
+ name: "ledger";
333
+ writable: true;
334
+ },
335
+ {
336
+ name: "lbPair";
337
+ docs: ["lb pair"];
338
+ writable: true;
339
+ },
340
+ {
341
+ name: "position";
342
+ docs: [
343
+ "user position",
344
+ "Check it is different from owner to advoid user to pass owner address wrongly"
345
+ ];
346
+ writable: true;
347
+ signer: true;
348
+ },
349
+ {
350
+ name: "binArrayBitmapExtension";
351
+ writable: true;
352
+ optional: true;
353
+ },
354
+ {
355
+ name: "userTokenX";
356
+ writable: true;
357
+ },
358
+ {
359
+ name: "userTokenY";
360
+ writable: true;
361
+ },
362
+ {
363
+ name: "reserveX";
364
+ writable: true;
365
+ },
366
+ {
367
+ name: "reserveY";
368
+ writable: true;
369
+ },
370
+ {
371
+ name: "tokenXMint";
372
+ },
373
+ {
374
+ name: "tokenYMint";
375
+ },
376
+ {
377
+ name: "dlmmProgram";
378
+ address: "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo";
379
+ },
380
+ {
381
+ name: "owner";
382
+ docs: ["owner of position"];
383
+ signer: true;
384
+ relations: ["ledger"];
385
+ },
386
+ {
387
+ name: "rentPayer";
388
+ writable: true;
389
+ signer: true;
390
+ },
391
+ {
392
+ name: "tokenXProgram";
393
+ },
394
+ {
395
+ name: "tokenYProgram";
396
+ },
397
+ {
398
+ name: "memoProgram";
399
+ },
400
+ {
401
+ name: "systemProgram";
402
+ },
403
+ {
404
+ name: "dlmmEventAuthority";
405
+ }
406
+ ];
407
+ args: [
408
+ {
409
+ name: "binDelta";
410
+ type: "u8";
411
+ },
412
+ {
413
+ name: "activeId";
414
+ type: "i32";
415
+ },
416
+ {
417
+ name: "maxActiveBinSlippage";
418
+ type: "u16";
419
+ },
420
+ {
421
+ name: "favorXInActiveId";
422
+ type: "bool";
423
+ },
424
+ {
425
+ name: "strategy";
426
+ type: {
427
+ defined: {
428
+ name: "strategyType";
429
+ };
430
+ };
431
+ },
432
+ {
433
+ name: "remainingAccountsInfo";
434
+ type: {
435
+ defined: {
436
+ name: "remainingAccountsInfo";
437
+ };
438
+ };
439
+ }
440
+ ];
441
+ },
23
442
  {
24
443
  name: "zapOut";
25
444
  discriminator: [155, 108, 185, 112, 104, 210, 161, 64];
@@ -44,34 +463,890 @@ type Zap$1 = {
44
463
  ];
45
464
  }
46
465
  ];
47
- errors: [
466
+ accounts: [
48
467
  {
49
- code: 6000;
468
+ name: "lbPair";
469
+ discriminator: [33, 11, 49, 98, 181, 101, 177, 13];
470
+ },
471
+ {
472
+ name: "pool";
473
+ discriminator: [241, 154, 109, 4, 17, 177, 109, 188];
474
+ },
475
+ {
476
+ name: "userLedger";
477
+ discriminator: [185, 84, 101, 128, 8, 6, 160, 83];
478
+ }
479
+ ];
480
+ errors: [
481
+ {
482
+ code: 6000;
50
483
  name: "mathOverflow";
51
484
  msg: "Math operation overflow";
52
485
  },
53
486
  {
54
- code: 6001;
55
- name: "invalidOffset";
56
- msg: "Invalid offset";
487
+ code: 6001;
488
+ name: "invalidOffset";
489
+ msg: "Invalid offset";
490
+ },
491
+ {
492
+ code: 6002;
493
+ name: "invalidZapOutParameters";
494
+ msg: "Invalid zapout parameters";
495
+ },
496
+ {
497
+ code: 6003;
498
+ name: "typeCastFailed";
499
+ msg: "Type cast error";
500
+ },
501
+ {
502
+ code: 6004;
503
+ name: "ammIsNotSupported";
504
+ msg: "Amm program is not supported";
505
+ },
506
+ {
507
+ code: 6005;
508
+ name: "invalidPosition";
509
+ msg: "Position is not empty";
510
+ },
511
+ {
512
+ code: 6006;
513
+ name: "exceededSlippage";
514
+ msg: "Exceeded slippage tolerance";
515
+ }
516
+ ];
517
+ types: [
518
+ {
519
+ name: "accountsType";
520
+ type: {
521
+ kind: "enum";
522
+ variants: [
523
+ {
524
+ name: "transferHookX";
525
+ },
526
+ {
527
+ name: "transferHookY";
528
+ },
529
+ {
530
+ name: "transferHookReward";
531
+ },
532
+ {
533
+ name: "transferHookMultiReward";
534
+ fields: ["u8"];
535
+ }
536
+ ];
537
+ };
538
+ },
539
+ {
540
+ name: "baseFeeStruct";
541
+ serialization: "bytemuck";
542
+ repr: {
543
+ kind: "c";
544
+ };
545
+ type: {
546
+ kind: "struct";
547
+ fields: [
548
+ {
549
+ name: "cliffFeeNumerator";
550
+ type: "u64";
551
+ },
552
+ {
553
+ name: "baseFeeMode";
554
+ type: "u8";
555
+ },
556
+ {
557
+ name: "padding0";
558
+ type: {
559
+ array: ["u8", 5];
560
+ };
561
+ },
562
+ {
563
+ name: "firstFactor";
564
+ type: "u16";
565
+ },
566
+ {
567
+ name: "secondFactor";
568
+ type: {
569
+ array: ["u8", 8];
570
+ };
571
+ },
572
+ {
573
+ name: "thirdFactor";
574
+ type: "u64";
575
+ },
576
+ {
577
+ name: "padding1";
578
+ type: "u64";
579
+ }
580
+ ];
581
+ };
582
+ },
583
+ {
584
+ name: "dynamicFeeStruct";
585
+ serialization: "bytemuck";
586
+ repr: {
587
+ kind: "c";
588
+ };
589
+ type: {
590
+ kind: "struct";
591
+ fields: [
592
+ {
593
+ name: "initialized";
594
+ type: "u8";
595
+ },
596
+ {
597
+ name: "padding";
598
+ type: {
599
+ array: ["u8", 7];
600
+ };
601
+ },
602
+ {
603
+ name: "maxVolatilityAccumulator";
604
+ type: "u32";
605
+ },
606
+ {
607
+ name: "variableFeeControl";
608
+ type: "u32";
609
+ },
610
+ {
611
+ name: "binStep";
612
+ type: "u16";
613
+ },
614
+ {
615
+ name: "filterPeriod";
616
+ type: "u16";
617
+ },
618
+ {
619
+ name: "decayPeriod";
620
+ type: "u16";
621
+ },
622
+ {
623
+ name: "reductionFactor";
624
+ type: "u16";
625
+ },
626
+ {
627
+ name: "lastUpdateTimestamp";
628
+ type: "u64";
629
+ },
630
+ {
631
+ name: "binStepU128";
632
+ type: "u128";
633
+ },
634
+ {
635
+ name: "sqrtPriceReference";
636
+ type: "u128";
637
+ },
638
+ {
639
+ name: "volatilityAccumulator";
640
+ type: "u128";
641
+ },
642
+ {
643
+ name: "volatilityReference";
644
+ type: "u128";
645
+ }
646
+ ];
647
+ };
648
+ },
649
+ {
650
+ name: "lbPair";
651
+ serialization: "bytemuck";
652
+ repr: {
653
+ kind: "c";
654
+ };
655
+ type: {
656
+ kind: "struct";
657
+ fields: [
658
+ {
659
+ name: "parameters";
660
+ type: {
661
+ defined: {
662
+ name: "staticParameters";
663
+ };
664
+ };
665
+ },
666
+ {
667
+ name: "vParameters";
668
+ type: {
669
+ defined: {
670
+ name: "variableParameters";
671
+ };
672
+ };
673
+ },
674
+ {
675
+ name: "bumpSeed";
676
+ type: {
677
+ array: ["u8", 1];
678
+ };
679
+ },
680
+ {
681
+ name: "binStepSeed";
682
+ type: {
683
+ array: ["u8", 2];
684
+ };
685
+ },
686
+ {
687
+ name: "pairType";
688
+ type: "u8";
689
+ },
690
+ {
691
+ name: "activeId";
692
+ type: "i32";
693
+ },
694
+ {
695
+ name: "binStep";
696
+ type: "u16";
697
+ },
698
+ {
699
+ name: "status";
700
+ type: "u8";
701
+ },
702
+ {
703
+ name: "requireBaseFactorSeed";
704
+ type: "u8";
705
+ },
706
+ {
707
+ name: "baseFactorSeed";
708
+ type: {
709
+ array: ["u8", 2];
710
+ };
711
+ },
712
+ {
713
+ name: "activationType";
714
+ type: "u8";
715
+ },
716
+ {
717
+ name: "creatorPoolOnOffControl";
718
+ type: "u8";
719
+ },
720
+ {
721
+ name: "tokenXMint";
722
+ type: "pubkey";
723
+ },
724
+ {
725
+ name: "tokenYMint";
726
+ type: "pubkey";
727
+ },
728
+ {
729
+ name: "reserveX";
730
+ type: "pubkey";
731
+ },
732
+ {
733
+ name: "reserveY";
734
+ type: "pubkey";
735
+ },
736
+ {
737
+ name: "protocolFee";
738
+ type: {
739
+ defined: {
740
+ name: "protocolFee";
741
+ };
742
+ };
743
+ },
744
+ {
745
+ name: "padding1";
746
+ type: {
747
+ array: ["u8", 32];
748
+ };
749
+ },
750
+ {
751
+ name: "rewardInfos";
752
+ type: {
753
+ array: [
754
+ {
755
+ defined: {
756
+ name: "dlmm::dlmm::types::RewardInfo";
757
+ };
758
+ },
759
+ 2
760
+ ];
761
+ };
762
+ },
763
+ {
764
+ name: "oracle";
765
+ type: "pubkey";
766
+ },
767
+ {
768
+ name: "binArrayBitmap";
769
+ type: {
770
+ array: ["u64", 16];
771
+ };
772
+ },
773
+ {
774
+ name: "lastUpdatedAt";
775
+ type: "i64";
776
+ },
777
+ {
778
+ name: "padding2";
779
+ type: {
780
+ array: ["u8", 32];
781
+ };
782
+ },
783
+ {
784
+ name: "preActivationSwapAddress";
785
+ type: "pubkey";
786
+ },
787
+ {
788
+ name: "baseKey";
789
+ type: "pubkey";
790
+ },
791
+ {
792
+ name: "activationPoint";
793
+ type: "u64";
794
+ },
795
+ {
796
+ name: "preActivationDuration";
797
+ type: "u64";
798
+ },
799
+ {
800
+ name: "padding3";
801
+ type: {
802
+ array: ["u8", 8];
803
+ };
804
+ },
805
+ {
806
+ name: "padding4";
807
+ type: "u64";
808
+ },
809
+ {
810
+ name: "creator";
811
+ type: "pubkey";
812
+ },
813
+ {
814
+ name: "tokenMintXProgramFlag";
815
+ type: "u8";
816
+ },
817
+ {
818
+ name: "tokenMintYProgramFlag";
819
+ type: "u8";
820
+ },
821
+ {
822
+ name: "reserved";
823
+ type: {
824
+ array: ["u8", 22];
825
+ };
826
+ }
827
+ ];
828
+ };
829
+ },
830
+ {
831
+ name: "pool";
832
+ serialization: "bytemuck";
833
+ repr: {
834
+ kind: "c";
835
+ };
836
+ type: {
837
+ kind: "struct";
838
+ fields: [
839
+ {
840
+ name: "poolFees";
841
+ docs: ["Pool fee"];
842
+ type: {
843
+ defined: {
844
+ name: "poolFeesStruct";
845
+ };
846
+ };
847
+ },
848
+ {
849
+ name: "tokenAMint";
850
+ docs: ["token a mint"];
851
+ type: "pubkey";
852
+ },
853
+ {
854
+ name: "tokenBMint";
855
+ docs: ["token b mint"];
856
+ type: "pubkey";
857
+ },
858
+ {
859
+ name: "tokenAVault";
860
+ docs: ["token a vault"];
861
+ type: "pubkey";
862
+ },
863
+ {
864
+ name: "tokenBVault";
865
+ docs: ["token b vault"];
866
+ type: "pubkey";
867
+ },
868
+ {
869
+ name: "whitelistedVault";
870
+ docs: [
871
+ "Whitelisted vault to be able to buy pool before activation_point"
872
+ ];
873
+ type: "pubkey";
874
+ },
875
+ {
876
+ name: "partner";
877
+ docs: ["partner"];
878
+ type: "pubkey";
879
+ },
880
+ {
881
+ name: "liquidity";
882
+ docs: ["liquidity share"];
883
+ type: "u128";
884
+ },
885
+ {
886
+ name: "padding";
887
+ docs: [
888
+ "padding, previous reserve amount, be careful to use that field"
889
+ ];
890
+ type: "u128";
891
+ },
892
+ {
893
+ name: "protocolAFee";
894
+ docs: ["protocol a fee"];
895
+ type: "u64";
896
+ },
897
+ {
898
+ name: "protocolBFee";
899
+ docs: ["protocol b fee"];
900
+ type: "u64";
901
+ },
902
+ {
903
+ name: "partnerAFee";
904
+ docs: ["partner a fee"];
905
+ type: "u64";
906
+ },
907
+ {
908
+ name: "partnerBFee";
909
+ docs: ["partner b fee"];
910
+ type: "u64";
911
+ },
912
+ {
913
+ name: "sqrtMinPrice";
914
+ docs: ["min price"];
915
+ type: "u128";
916
+ },
917
+ {
918
+ name: "sqrtMaxPrice";
919
+ docs: ["max price"];
920
+ type: "u128";
921
+ },
922
+ {
923
+ name: "sqrtPrice";
924
+ docs: ["current price"];
925
+ type: "u128";
926
+ },
927
+ {
928
+ name: "activationPoint";
929
+ docs: ["Activation point, can be slot or timestamp"];
930
+ type: "u64";
931
+ },
932
+ {
933
+ name: "activationType";
934
+ docs: ["Activation type, 0 means by slot, 1 means by timestamp"];
935
+ type: "u8";
936
+ },
937
+ {
938
+ name: "poolStatus";
939
+ docs: ["pool status, 0: enable, 1 disable"];
940
+ type: "u8";
941
+ },
942
+ {
943
+ name: "tokenAFlag";
944
+ docs: ["token a flag"];
945
+ type: "u8";
946
+ },
947
+ {
948
+ name: "tokenBFlag";
949
+ docs: ["token b flag"];
950
+ type: "u8";
951
+ },
952
+ {
953
+ name: "collectFeeMode";
954
+ docs: [
955
+ "0 is collect fee in both token, 1 only collect fee in token a, 2 only collect fee in token b"
956
+ ];
957
+ type: "u8";
958
+ },
959
+ {
960
+ name: "poolType";
961
+ docs: ["pool type"];
962
+ type: "u8";
963
+ },
964
+ {
965
+ name: "version";
966
+ docs: [
967
+ "pool version, 0: max_fee is still capped at 50%, 1: max_fee is capped at 99%"
968
+ ];
969
+ type: "u8";
970
+ },
971
+ {
972
+ name: "padding0";
973
+ docs: ["padding"];
974
+ type: "u8";
975
+ },
976
+ {
977
+ name: "feeAPerLiquidity";
978
+ docs: ["cumulative"];
979
+ type: {
980
+ array: ["u8", 32];
981
+ };
982
+ },
983
+ {
984
+ name: "feeBPerLiquidity";
985
+ docs: ["cumulative"];
986
+ type: {
987
+ array: ["u8", 32];
988
+ };
989
+ },
990
+ {
991
+ name: "permanentLockLiquidity";
992
+ type: "u128";
993
+ },
994
+ {
995
+ name: "metrics";
996
+ docs: ["metrics"];
997
+ type: {
998
+ defined: {
999
+ name: "poolMetrics";
1000
+ };
1001
+ };
1002
+ },
1003
+ {
1004
+ name: "creator";
1005
+ docs: ["pool creator"];
1006
+ type: "pubkey";
1007
+ },
1008
+ {
1009
+ name: "padding1";
1010
+ docs: ["Padding for further use"];
1011
+ type: {
1012
+ array: ["u64", 6];
1013
+ };
1014
+ },
1015
+ {
1016
+ name: "rewardInfos";
1017
+ docs: ["Farming reward information"];
1018
+ type: {
1019
+ array: [
1020
+ {
1021
+ defined: {
1022
+ name: "cp_amm::state::pool::RewardInfo";
1023
+ };
1024
+ },
1025
+ 2
1026
+ ];
1027
+ };
1028
+ }
1029
+ ];
1030
+ };
1031
+ },
1032
+ {
1033
+ name: "poolFeesStruct";
1034
+ docs: [
1035
+ "Information regarding fee charges",
1036
+ "trading_fee = amount * trade_fee_numerator / denominator",
1037
+ "protocol_fee = trading_fee * protocol_fee_percentage / 100",
1038
+ "referral_fee = protocol_fee * referral_percentage / 100",
1039
+ "partner_fee = (protocol_fee - referral_fee) * partner_fee_percentage / denominator"
1040
+ ];
1041
+ serialization: "bytemuck";
1042
+ repr: {
1043
+ kind: "c";
1044
+ };
1045
+ type: {
1046
+ kind: "struct";
1047
+ fields: [
1048
+ {
1049
+ name: "baseFee";
1050
+ docs: [
1051
+ "Trade fees are extra token amounts that are held inside the token",
1052
+ "accounts during a trade, making the value of liquidity tokens rise.",
1053
+ "Trade fee numerator"
1054
+ ];
1055
+ type: {
1056
+ defined: {
1057
+ name: "baseFeeStruct";
1058
+ };
1059
+ };
1060
+ },
1061
+ {
1062
+ name: "protocolFeePercent";
1063
+ docs: [
1064
+ "Protocol trading fees are extra token amounts that are held inside the token",
1065
+ "accounts during a trade, with the equivalent in pool tokens minted to",
1066
+ "the protocol of the program.",
1067
+ "Protocol trade fee numerator"
1068
+ ];
1069
+ type: "u8";
1070
+ },
1071
+ {
1072
+ name: "partnerFeePercent";
1073
+ docs: ["partner fee"];
1074
+ type: "u8";
1075
+ },
1076
+ {
1077
+ name: "referralFeePercent";
1078
+ docs: ["referral fee"];
1079
+ type: "u8";
1080
+ },
1081
+ {
1082
+ name: "padding0";
1083
+ docs: ["padding"];
1084
+ type: {
1085
+ array: ["u8", 5];
1086
+ };
1087
+ },
1088
+ {
1089
+ name: "dynamicFee";
1090
+ docs: ["dynamic fee"];
1091
+ type: {
1092
+ defined: {
1093
+ name: "dynamicFeeStruct";
1094
+ };
1095
+ };
1096
+ },
1097
+ {
1098
+ name: "padding1";
1099
+ docs: ["padding"];
1100
+ type: {
1101
+ array: ["u64", 2];
1102
+ };
1103
+ }
1104
+ ];
1105
+ };
1106
+ },
1107
+ {
1108
+ name: "poolMetrics";
1109
+ serialization: "bytemuck";
1110
+ repr: {
1111
+ kind: "c";
1112
+ };
1113
+ type: {
1114
+ kind: "struct";
1115
+ fields: [
1116
+ {
1117
+ name: "totalLpAFee";
1118
+ type: "u128";
1119
+ },
1120
+ {
1121
+ name: "totalLpBFee";
1122
+ type: "u128";
1123
+ },
1124
+ {
1125
+ name: "totalProtocolAFee";
1126
+ type: "u64";
1127
+ },
1128
+ {
1129
+ name: "totalProtocolBFee";
1130
+ type: "u64";
1131
+ },
1132
+ {
1133
+ name: "totalPartnerAFee";
1134
+ type: "u64";
1135
+ },
1136
+ {
1137
+ name: "totalPartnerBFee";
1138
+ type: "u64";
1139
+ },
1140
+ {
1141
+ name: "totalPosition";
1142
+ type: "u64";
1143
+ },
1144
+ {
1145
+ name: "padding";
1146
+ type: "u64";
1147
+ }
1148
+ ];
1149
+ };
1150
+ },
1151
+ {
1152
+ name: "protocolFee";
1153
+ serialization: "bytemuck";
1154
+ repr: {
1155
+ kind: "c";
1156
+ };
1157
+ type: {
1158
+ kind: "struct";
1159
+ fields: [
1160
+ {
1161
+ name: "amountX";
1162
+ type: "u64";
1163
+ },
1164
+ {
1165
+ name: "amountY";
1166
+ type: "u64";
1167
+ }
1168
+ ];
1169
+ };
1170
+ },
1171
+ {
1172
+ name: "remainingAccountsInfo";
1173
+ type: {
1174
+ kind: "struct";
1175
+ fields: [
1176
+ {
1177
+ name: "slices";
1178
+ type: {
1179
+ vec: {
1180
+ defined: {
1181
+ name: "remainingAccountsSlice";
1182
+ };
1183
+ };
1184
+ };
1185
+ }
1186
+ ];
1187
+ };
1188
+ },
1189
+ {
1190
+ name: "remainingAccountsSlice";
1191
+ type: {
1192
+ kind: "struct";
1193
+ fields: [
1194
+ {
1195
+ name: "accountsType";
1196
+ type: {
1197
+ defined: {
1198
+ name: "accountsType";
1199
+ };
1200
+ };
1201
+ },
1202
+ {
1203
+ name: "length";
1204
+ type: "u8";
1205
+ }
1206
+ ];
1207
+ };
57
1208
  },
58
1209
  {
59
- code: 6002;
60
- name: "invalidZapOutParameters";
61
- msg: "Math operation overflow";
1210
+ name: "staticParameters";
1211
+ docs: ["Parameter that set by the protocol"];
1212
+ serialization: "bytemuck";
1213
+ repr: {
1214
+ kind: "c";
1215
+ };
1216
+ type: {
1217
+ kind: "struct";
1218
+ fields: [
1219
+ {
1220
+ name: "baseFactor";
1221
+ type: "u16";
1222
+ },
1223
+ {
1224
+ name: "filterPeriod";
1225
+ type: "u16";
1226
+ },
1227
+ {
1228
+ name: "decayPeriod";
1229
+ type: "u16";
1230
+ },
1231
+ {
1232
+ name: "reductionFactor";
1233
+ type: "u16";
1234
+ },
1235
+ {
1236
+ name: "variableFeeControl";
1237
+ type: "u32";
1238
+ },
1239
+ {
1240
+ name: "maxVolatilityAccumulator";
1241
+ type: "u32";
1242
+ },
1243
+ {
1244
+ name: "minBinId";
1245
+ type: "i32";
1246
+ },
1247
+ {
1248
+ name: "maxBinId";
1249
+ type: "i32";
1250
+ },
1251
+ {
1252
+ name: "protocolShare";
1253
+ type: "u16";
1254
+ },
1255
+ {
1256
+ name: "baseFeePowerFactor";
1257
+ type: "u8";
1258
+ },
1259
+ {
1260
+ name: "padding";
1261
+ type: {
1262
+ array: ["u8", 5];
1263
+ };
1264
+ }
1265
+ ];
1266
+ };
62
1267
  },
63
1268
  {
64
- code: 6003;
65
- name: "typeCastFailed";
66
- msg: "Type cast error";
1269
+ name: "strategyType";
1270
+ type: {
1271
+ kind: "enum";
1272
+ variants: [
1273
+ {
1274
+ name: "spot";
1275
+ },
1276
+ {
1277
+ name: "curve";
1278
+ },
1279
+ {
1280
+ name: "bidAsk";
1281
+ }
1282
+ ];
1283
+ };
67
1284
  },
68
1285
  {
69
- code: 6004;
70
- name: "ammIsNotSupported";
71
- msg: "Amm program is not supported";
72
- }
73
- ];
74
- types: [
1286
+ name: "userLedger";
1287
+ serialization: "bytemuck";
1288
+ repr: {
1289
+ kind: "c";
1290
+ };
1291
+ type: {
1292
+ kind: "struct";
1293
+ fields: [
1294
+ {
1295
+ name: "owner";
1296
+ type: "pubkey";
1297
+ },
1298
+ {
1299
+ name: "amountA";
1300
+ type: "u64";
1301
+ },
1302
+ {
1303
+ name: "amountB";
1304
+ type: "u64";
1305
+ }
1306
+ ];
1307
+ };
1308
+ },
1309
+ {
1310
+ name: "variableParameters";
1311
+ docs: ["Parameters that changes based on dynamic of the market"];
1312
+ serialization: "bytemuck";
1313
+ repr: {
1314
+ kind: "c";
1315
+ };
1316
+ type: {
1317
+ kind: "struct";
1318
+ fields: [
1319
+ {
1320
+ name: "volatilityAccumulator";
1321
+ type: "u32";
1322
+ },
1323
+ {
1324
+ name: "volatilityReference";
1325
+ type: "u32";
1326
+ },
1327
+ {
1328
+ name: "indexReference";
1329
+ type: "i32";
1330
+ },
1331
+ {
1332
+ name: "padding";
1333
+ type: {
1334
+ array: ["u8", 4];
1335
+ };
1336
+ },
1337
+ {
1338
+ name: "lastUpdateTimestamp";
1339
+ type: "i64";
1340
+ },
1341
+ {
1342
+ name: "padding1";
1343
+ type: {
1344
+ array: ["u8", 8];
1345
+ };
1346
+ }
1347
+ ];
1348
+ };
1349
+ },
75
1350
  {
76
1351
  name: "zapOutParameters";
77
1352
  type: {
@@ -99,6 +1374,188 @@ type Zap$1 = {
99
1374
  }
100
1375
  ];
101
1376
  };
1377
+ },
1378
+ {
1379
+ name: "cp_amm::state::pool::RewardInfo";
1380
+ docs: ["Stores the state relevant for tracking liquidity mining rewards"];
1381
+ serialization: "bytemuck";
1382
+ repr: {
1383
+ kind: "c";
1384
+ };
1385
+ type: {
1386
+ kind: "struct";
1387
+ fields: [
1388
+ {
1389
+ name: "initialized";
1390
+ docs: ["Indicates if the reward has been initialized"];
1391
+ type: "u8";
1392
+ },
1393
+ {
1394
+ name: "rewardTokenFlag";
1395
+ docs: ["reward token flag"];
1396
+ type: "u8";
1397
+ },
1398
+ {
1399
+ name: "padding0";
1400
+ docs: ["padding"];
1401
+ type: {
1402
+ array: ["u8", 6];
1403
+ };
1404
+ },
1405
+ {
1406
+ name: "padding1";
1407
+ docs: ["Padding to ensure `reward_rate: u128` is 16-byte aligned"];
1408
+ type: {
1409
+ array: ["u8", 8];
1410
+ };
1411
+ },
1412
+ {
1413
+ name: "mint";
1414
+ docs: ["Reward token mint."];
1415
+ type: "pubkey";
1416
+ },
1417
+ {
1418
+ name: "vault";
1419
+ docs: ["Reward vault token account."];
1420
+ type: "pubkey";
1421
+ },
1422
+ {
1423
+ name: "funder";
1424
+ docs: ["Authority account that allows to fund rewards"];
1425
+ type: "pubkey";
1426
+ },
1427
+ {
1428
+ name: "rewardDuration";
1429
+ docs: ["reward duration"];
1430
+ type: "u64";
1431
+ },
1432
+ {
1433
+ name: "rewardDurationEnd";
1434
+ docs: ["reward duration end"];
1435
+ type: "u64";
1436
+ },
1437
+ {
1438
+ name: "rewardRate";
1439
+ docs: ["reward rate"];
1440
+ type: "u128";
1441
+ },
1442
+ {
1443
+ name: "rewardPerTokenStored";
1444
+ docs: ["Reward per token stored"];
1445
+ type: {
1446
+ array: ["u8", 32];
1447
+ };
1448
+ },
1449
+ {
1450
+ name: "lastUpdateTime";
1451
+ docs: ["The last time reward states were updated."];
1452
+ type: "u64";
1453
+ },
1454
+ {
1455
+ name: "cumulativeSecondsWithEmptyLiquidityReward";
1456
+ docs: [
1457
+ "Accumulated seconds when the farm distributed rewards but the bin was empty.",
1458
+ "These rewards will be carried over to the next reward time window."
1459
+ ];
1460
+ type: "u64";
1461
+ }
1462
+ ];
1463
+ };
1464
+ },
1465
+ {
1466
+ name: "dlmm::dlmm::types::RewardInfo";
1467
+ docs: ["Stores the state relevant for tracking liquidity mining rewards"];
1468
+ serialization: "bytemuck";
1469
+ repr: {
1470
+ kind: "c";
1471
+ };
1472
+ type: {
1473
+ kind: "struct";
1474
+ fields: [
1475
+ {
1476
+ name: "mint";
1477
+ type: "pubkey";
1478
+ },
1479
+ {
1480
+ name: "vault";
1481
+ type: "pubkey";
1482
+ },
1483
+ {
1484
+ name: "funder";
1485
+ type: "pubkey";
1486
+ },
1487
+ {
1488
+ name: "rewardDuration";
1489
+ type: "u64";
1490
+ },
1491
+ {
1492
+ name: "rewardDurationEnd";
1493
+ type: "u64";
1494
+ },
1495
+ {
1496
+ name: "rewardRate";
1497
+ type: "u128";
1498
+ },
1499
+ {
1500
+ name: "lastUpdateTime";
1501
+ type: "u64";
1502
+ },
1503
+ {
1504
+ name: "cumulativeSecondsWithEmptyLiquidityReward";
1505
+ type: "u64";
1506
+ }
1507
+ ];
1508
+ };
1509
+ }
1510
+ ];
1511
+ constants: [
1512
+ {
1513
+ name: "dammV2";
1514
+ type: "pubkey";
1515
+ value: "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
1516
+ },
1517
+ {
1518
+ name: "dammV2SwapDisc";
1519
+ type: {
1520
+ array: ["u8", 8];
1521
+ };
1522
+ value: "[248, 198, 158, 145, 225, 117, 135, 200]";
1523
+ },
1524
+ {
1525
+ name: "dlmmSwap2Disc";
1526
+ type: {
1527
+ array: ["u8", 8];
1528
+ };
1529
+ value: "[65, 75, 63, 76, 235, 91, 91, 136]";
1530
+ },
1531
+ {
1532
+ name: "jupV6";
1533
+ type: "pubkey";
1534
+ value: "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
1535
+ },
1536
+ {
1537
+ name: "jupV6RouteDisc";
1538
+ type: {
1539
+ array: ["u8", 8];
1540
+ };
1541
+ value: "[229, 23, 203, 151, 122, 227, 173, 42]";
1542
+ },
1543
+ {
1544
+ name: "jupV6SharedAccountRouteDisc";
1545
+ type: {
1546
+ array: ["u8", 8];
1547
+ };
1548
+ value: "[193, 32, 155, 51, 65, 214, 156, 129]";
1549
+ },
1550
+ {
1551
+ name: "maxBasisPoint";
1552
+ type: "u16";
1553
+ value: "10000";
1554
+ },
1555
+ {
1556
+ name: "userLedgerPrefix";
1557
+ type: "bytes";
1558
+ value: "[117, 115, 101, 114, 95, 108, 101, 100, 103, 101, 114]";
102
1559
  }
103
1560
  ];
104
1561
  };
@@ -208,11 +1665,260 @@ interface JupiterSwapInstructionResponse {
208
1665
  };
209
1666
  };
210
1667
  }
1668
+ type ProgramStrategyType = IdlTypes<Zap$1>["strategyType"];
1669
+ type GetZapInDammV2DirectPoolParams = {
1670
+ user: PublicKey;
1671
+ inputTokenMint: PublicKey;
1672
+ amountIn: Decimal;
1673
+ pool: PublicKey;
1674
+ position: PublicKey;
1675
+ positionNftAccount: PublicKey;
1676
+ maxSqrtPriceChangeBps: number;
1677
+ maxTransferAmountExtendPercentage: number;
1678
+ maxAccounts: number;
1679
+ slippageBps: number;
1680
+ dammV2Quote: {
1681
+ swapInAmount: BN;
1682
+ consumedInAmount: BN;
1683
+ swapOutAmount: BN;
1684
+ minSwapOutAmount: BN;
1685
+ totalFee: BN;
1686
+ priceImpact: Decimal;
1687
+ };
1688
+ jupiterQuote: JupiterQuoteResponse | null;
1689
+ };
1690
+ type GetZapInDammV2InDirectPoolParams = {
1691
+ user: PublicKey;
1692
+ inputTokenMint: PublicKey;
1693
+ amountIn: Decimal;
1694
+ pool: PublicKey;
1695
+ position: PublicKey;
1696
+ positionNftAccount: PublicKey;
1697
+ maxSqrtPriceChangeBps: number;
1698
+ maxTransferAmountExtendPercentage: number;
1699
+ maxAccounts: number;
1700
+ slippageBps: number;
1701
+ jupiterQuoteToA: JupiterQuoteResponse | null;
1702
+ jupiterQuoteToB: JupiterQuoteResponse | null;
1703
+ };
1704
+ type ZapInDammV2DirectPoolParam = {
1705
+ user: PublicKey;
1706
+ pool: PublicKey;
1707
+ position: PublicKey;
1708
+ positionNftAccount: PublicKey;
1709
+ tokenAMint: PublicKey;
1710
+ tokenBMint: PublicKey;
1711
+ tokenAVault: PublicKey;
1712
+ tokenBVault: PublicKey;
1713
+ tokenAProgram: PublicKey;
1714
+ tokenBProgram: PublicKey;
1715
+ isDirectPool: boolean;
1716
+ maxTransferAmount: BN;
1717
+ preSqrtPrice: BN;
1718
+ maxSqrtPriceChangeBps: number;
1719
+ amount: BN;
1720
+ preInstructions: TransactionInstruction[];
1721
+ swapTransactions: Transaction[];
1722
+ cleanUpInstructions: TransactionInstruction[];
1723
+ isTokenA?: boolean;
1724
+ };
1725
+ declare enum SwapExternalType {
1726
+ swapToA = 0,
1727
+ swapToB = 1,
1728
+ swapToBoth = 2
1729
+ }
1730
+ declare enum DlmmSwapExternalType {
1731
+ swapToX = 0,
1732
+ swapToY = 1,
1733
+ swapToBoth = 2,
1734
+ noSwap = 3
1735
+ }
1736
+ type ZapInDammV2InDirectPoolParam = Omit<ZapInDammV2DirectPoolParam, "maxTransferAmount"> & {
1737
+ swapType: SwapExternalType;
1738
+ maxTransferAmountA: BN;
1739
+ maxTransferAmountB: BN;
1740
+ };
1741
+ type ZapInDammV2Response = {
1742
+ setupTransaction?: Transaction;
1743
+ swapTransactions: Transaction[];
1744
+ ledgerTransaction: Transaction;
1745
+ zapInTransaction: Transaction;
1746
+ cleanUpTransaction: Transaction;
1747
+ };
1748
+ interface SwapQuoteResult {
1749
+ inAmount: BN;
1750
+ outAmount: BN;
1751
+ route: "jupiter" | "dlmm";
1752
+ originalQuote: JupiterQuoteResponse | SwapQuote;
1753
+ }
1754
+ type SwapDirection = "xToY" | "yToX" | "noSwap";
1755
+ interface DirectSwapEstimate {
1756
+ swapDirection: SwapDirection;
1757
+ swapAmount: BN;
1758
+ expectedOutput: BN;
1759
+ postSwapX: BN;
1760
+ postSwapY: BN;
1761
+ quote: SwapQuoteResult | null;
1762
+ }
1763
+ interface IndirectSwapEstimate {
1764
+ swapToX: JupiterQuoteResponse | null;
1765
+ swapToY: JupiterQuoteResponse | null;
1766
+ swapAmountToX: BN;
1767
+ swapAmountToY: BN;
1768
+ postSwapX: BN;
1769
+ postSwapY: BN;
1770
+ }
1771
+ interface RebalanceDlmmPositionParams {
1772
+ lbPairAddress: PublicKey;
1773
+ positionAddress: PublicKey;
1774
+ user: PublicKey;
1775
+ binDelta: number;
1776
+ liquiditySlippageBps: number;
1777
+ strategy: StrategyType;
1778
+ favorXInActiveId: boolean;
1779
+ directSwapEstimate: DirectSwapEstimate;
1780
+ }
1781
+ interface RebalanceDlmmPositionResponse {
1782
+ setupTransaction?: Transaction;
1783
+ removeLiquidityTransactions: Transaction[];
1784
+ swapTransaction?: Transaction;
1785
+ ledgerTransaction: Transaction;
1786
+ zapInTransaction: Transaction;
1787
+ cleanUpTransaction: Transaction;
1788
+ estimation: {
1789
+ currentBalances: {
1790
+ tokenX: BN;
1791
+ tokenY: BN;
1792
+ };
1793
+ afterSwap: {
1794
+ tokenX: BN;
1795
+ tokenY: BN;
1796
+ };
1797
+ };
1798
+ }
1799
+ interface EstimateBalancedSwapThroughJupiterAndDlmmParams {
1800
+ lbPairAddress: PublicKey;
1801
+ tokenXAmount: BN;
1802
+ tokenYAmount: BN;
1803
+ slippage: number;
1804
+ }
1805
+ interface GetZapInDlmmIndirectParams {
1806
+ user: PublicKey;
1807
+ lbPair: PublicKey;
1808
+ inputTokenMint: PublicKey;
1809
+ amountIn: BN;
1810
+ maxActiveBinSlippage: number;
1811
+ binDelta: number;
1812
+ strategy: StrategyType;
1813
+ favorXInActiveId: boolean;
1814
+ indirectSwapEstimate: IndirectSwapEstimate;
1815
+ maxAccounts: number;
1816
+ slippageBps: number;
1817
+ maxTransferAmountExtendPercentage: number;
1818
+ }
1819
+ interface GetZapInDlmmDirectParams {
1820
+ user: PublicKey;
1821
+ lbPair: PublicKey;
1822
+ inputTokenMint: PublicKey;
1823
+ amountIn: BN;
1824
+ maxActiveBinSlippage: number;
1825
+ binDelta: number;
1826
+ strategy: StrategyType;
1827
+ favorXInActiveId: boolean;
1828
+ maxAccounts: number;
1829
+ slippageBps: number;
1830
+ maxTransferAmountExtendPercentage: number;
1831
+ directSwapEstimate: DirectSwapEstimate;
1832
+ }
1833
+ type ZapInDlmmIndirectPoolParam = {
1834
+ user: PublicKey;
1835
+ lbPair: PublicKey;
1836
+ tokenXMint: PublicKey;
1837
+ tokenYMint: PublicKey;
1838
+ tokenXProgram: PublicKey;
1839
+ tokenYProgram: PublicKey;
1840
+ activeId: number;
1841
+ binDelta: number;
1842
+ maxActiveBinSlippage: number;
1843
+ favorXInActiveId: boolean;
1844
+ strategy: StrategyType;
1845
+ maxTransferAmountX: BN;
1846
+ maxTransferAmountY: BN;
1847
+ preInstructions: TransactionInstruction[];
1848
+ swapTransactions: Transaction[];
1849
+ cleanUpInstructions: TransactionInstruction[];
1850
+ binArrays: AccountMeta[];
1851
+ remainingAccountInfo: RemainingAccountInfo;
1852
+ binArrayBitmapExtension: PublicKey | null;
1853
+ isDirectRoute: boolean;
1854
+ };
1855
+ type ZapInDlmmDirectPoolParam = {
1856
+ user: PublicKey;
1857
+ lbPair: PublicKey;
1858
+ tokenXMint: PublicKey;
1859
+ tokenYMint: PublicKey;
1860
+ tokenXProgram: PublicKey;
1861
+ tokenYProgram: PublicKey;
1862
+ activeId: number;
1863
+ binDelta: number;
1864
+ maxActiveBinSlippage: number;
1865
+ favorXInActiveId: boolean;
1866
+ strategy: StrategyType;
1867
+ amount: BN;
1868
+ maxTransferAmount: BN;
1869
+ preInstructions: TransactionInstruction[];
1870
+ swapTransactions: Transaction[];
1871
+ cleanUpInstructions: TransactionInstruction[];
1872
+ binArrays: AccountMeta[];
1873
+ remainingAccountInfo: RemainingAccountInfo;
1874
+ binArrayBitmapExtension: PublicKey | null;
1875
+ isDirectRoute: boolean;
1876
+ isTokenX: boolean;
1877
+ };
1878
+ type ZapInDlmmResponse = {
1879
+ setupTransaction?: Transaction;
1880
+ swapTransactions: Transaction[];
1881
+ ledgerTransaction: Transaction;
1882
+ zapInTransaction: Transaction;
1883
+ cleanUpTransaction: Transaction;
1884
+ };
211
1885
 
212
1886
  declare class Zap {
213
1887
  private connection;
214
- private zapProgram;
1888
+ zapProgram: ZapProgram;
215
1889
  constructor(connection: Connection);
1890
+ private initializeLedgerAccount;
1891
+ private closeLedgerAccount;
1892
+ private setLedgerBalance;
1893
+ private updateLedgerBalanceAfterSwap;
1894
+ private zapInDammV2;
1895
+ private resetOrInitializeLedgerAccount;
1896
+ private zapInDlmmForInitializedPosition;
1897
+ private zapInDlmmForUninitializedPosition;
1898
+ getZapInDammV2DirectPoolParams(params: GetZapInDammV2DirectPoolParams): Promise<ZapInDammV2DirectPoolParam>;
1899
+ getZapInDammV2IndirectPoolParams(params: GetZapInDammV2InDirectPoolParams): Promise<ZapInDammV2InDirectPoolParam | null>;
1900
+ buildZapInDammV2Transaction(params: ZapInDammV2DirectPoolParam | ZapInDammV2InDirectPoolParam): Promise<ZapInDammV2Response>;
1901
+ getZapInDlmmDirectParams(params: GetZapInDlmmDirectParams): Promise<ZapInDlmmDirectPoolParam>;
1902
+ getZapInDlmmIndirectParams(params: GetZapInDlmmIndirectParams): Promise<ZapInDlmmIndirectPoolParam>;
1903
+ buildZapInDlmmTransaction(params: (ZapInDlmmIndirectPoolParam | ZapInDlmmDirectPoolParam) & {
1904
+ position: PublicKey;
1905
+ }): Promise<ZapInDlmmResponse>;
1906
+ /**
1907
+ * High level method for DLMM position rebalancing
1908
+ * Consist of remove liquidity, zap out through Jupiter or DLMM, and zap back in to rebalance the position
1909
+ *
1910
+ * @param params - Rebalancing DLMM position parameters
1911
+ * @param params.lbPairAddress - The DLMM pool address
1912
+ * @param params.positionAddress - The position address
1913
+ * @param params.user - Public key of the user performing the rebalance
1914
+ * @param params.binDelta - The delta of bins for the rebalanced position relative to the active bin
1915
+ * @param params.liquiditySlippageBps - The maximum slippage in basis points for the rebalance liquidity operation (percentage * 100)
1916
+ * @param params.strategy - The strategy to use for the rebalance
1917
+ * @param params.favorXInActiveId - Whether to favor token X in the active bin
1918
+ * @param params.directSwapEstimate - The estimate of the direct swap operation
1919
+ * @returns Response containing transactions and estimation details
1920
+ */
1921
+ rebalanceDlmmPosition(params: RebalanceDlmmPositionParams): Promise<RebalanceDlmmPositionResponse>;
216
1922
  /**
217
1923
  * Executes a generic zap out operation with custom parameters.
218
1924
  *
@@ -274,8 +1980,12 @@ declare class Zap {
274
1980
  zapOutThroughDlmm(params: ZapOutThroughDlmmParams): Promise<Transaction>;
275
1981
  }
276
1982
 
277
- declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse>;
1983
+ declare function getJupiterQuote(inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number, dynamicSlippage: boolean | undefined, onlyDirectRoutes: boolean, restrictIntermediateTokens: boolean, apiUrl?: string, apiKey?: string): Promise<JupiterQuoteResponse | null>;
278
1984
  declare function getJupiterSwapInstruction(userPublicKey: PublicKey, quoteResponse: any, apiUrl?: string, apiKey?: string): Promise<JupiterSwapInstructionResponse>;
1985
+ declare function buildJupiterSwapTransaction(user: PublicKey, inputMint: PublicKey, outputMint: PublicKey, amount: BN, maxAccounts: number, slippageBps: number): Promise<{
1986
+ transaction: Transaction;
1987
+ quoteResponse: JupiterQuoteResponse | null;
1988
+ }>;
279
1989
 
280
1990
  declare function getDammV2Pool(connection: Connection, poolAddress: PublicKey): Promise<PoolState>;
281
1991
  declare function getDammV2RemainingAccounts(poolAddress: PublicKey, user: PublicKey, userInputTokenAccount: PublicKey, userTokenOutAccount: PublicKey, tokenAProgram: PublicKey | undefined, tokenBProgram: PublicKey | undefined, poolState: PoolState): Promise<Array<{
@@ -295,8 +2005,13 @@ declare function getDammV2RemainingAccounts(poolAddress: PublicKey, user: Public
295
2005
  declare function createDammV2SwapPayload(amountIn: BN, minimumSwapAmountOut: BN): Buffer;
296
2006
 
297
2007
  declare function deriveDammV2EventAuthority(): PublicKey;
2008
+ declare function deriveDammV2PoolAuthority(): PublicKey;
2009
+ declare function deriveLedgerAccount(owner: PublicKey): PublicKey;
2010
+ declare function deriveDlmmEventAuthority(): PublicKey;
298
2011
 
299
2012
  declare function getTokenProgramFromMint(connection: Connection, mint: PublicKey): Promise<PublicKey>;
2013
+ declare function convertLamportsToUiAmount(amount: Decimal, decimals: number): Decimal;
2014
+ declare function convertUiAmountToLamports(amount: Decimal, decimals: number): Decimal;
300
2015
 
301
2016
  /**
302
2017
  * Get or create a token account
@@ -361,9 +2076,31 @@ declare function convertAccountTypeToNumber(accountType: object): number;
361
2076
  * -> Length (1 byte): number of accounts in this slice.
362
2077
  */
363
2078
  declare function createDlmmSwapPayload(amountIn: BN, minimumSwapAmountOut: BN, remainingAccountsInfo: RemainingAccountInfo): Buffer;
2079
+ declare function toProgramStrategyType(strategy: StrategyType): ProgramStrategyType;
2080
+ declare function binDeltaToMinMaxBinId(binDelta: number, activeBinId: number): {
2081
+ minBinId: number;
2082
+ maxBinId: number;
2083
+ };
364
2084
 
365
2085
  declare function getExtraAccountMetasForTransferHook(connection: Connection, mint: PublicKey): Promise<_solana_web3_js.AccountMeta[]>;
366
2086
 
2087
+ /**
2088
+ * Calculate swap amounts from a single input token (that is not tokenX or tokenY)
2089
+ * to achieve balanced tokenX and tokenY amounts
2090
+ *
2091
+ * Uses Jupiter for swaps since input token is not part of the DLMM pool
2092
+ * First tries a 50:50 split (inputToken -> X and inputToken -> Y)
2093
+ * then refines using binary search if the resulting X and Y values are not balanced enough.
2094
+ */
2095
+ declare function estimateIndirectSwap(inputTokenAmount: BN, inputTokenMint: PublicKey, dlmm: DLMM, swapSlippageBps: number, binDelta: number, strategy: StrategyType): Promise<IndirectSwapEstimate>;
2096
+ /**
2097
+ * Calculate optimal swap amount to achieve equal value (1:1 ratio)
2098
+ *
2099
+ * Balances tokenX and tokenY to achieve equal value by swapping excess of one token to the other
2100
+ * using either the DLMM pool or Jupiter
2101
+ */
2102
+ declare function estimateDirectSwap(tokenXAmount: BN, tokenYAmount: BN, dlmm: DLMM, swapSlippageBps: number, binDelta: number, strategy: StrategyType): Promise<DirectSwapEstimate>;
2103
+
367
2104
  declare const ZAP_PROGRAM_ID: PublicKey;
368
2105
  declare const JUP_V6_PROGRAM_ID: PublicKey;
369
2106
  declare const DAMM_V2_PROGRAM_ID: PublicKey;
@@ -387,4 +2124,4 @@ declare const AMOUNT_IN_JUP_V6_REVERSE_OFFSET = 19;
387
2124
  declare const AMOUNT_IN_DAMM_V2_OFFSET = 8;
388
2125
  declare const DAMM_V2_SWAP_DISCRIMINATOR: number[];
389
2126
 
390
- export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, ZAP_PROGRAM_ID, Zap, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, convertAccountTypeToNumber, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, unwrapSOLInstruction, wrapSOLInstruction };
2127
+ export { AMOUNT_IN_DAMM_V2_OFFSET, AMOUNT_IN_DLMM_OFFSET, AMOUNT_IN_JUP_V6_REVERSE_OFFSET, AccountsType, BIN_ARRAY_INDEX_BOUND, DAMM_V2_PROGRAM_ID, DAMM_V2_SWAP_DISCRIMINATOR, DLMM_PROGRAM_ID, DLMM_SWAP_DISCRIMINATOR, type DirectSwapEstimate, DlmmSwapExternalType, type EstimateBalancedSwapThroughJupiterAndDlmmParams, type GetZapInDammV2DirectPoolParams, type GetZapInDammV2InDirectPoolParams, type GetZapInDlmmDirectParams, type GetZapInDlmmIndirectParams, type IndirectSwapEstimate, JUP_V6_PROGRAM_ID, type JupiterInstruction, type JupiterQuoteResponse, type JupiterRoutePlan, type JupiterSwapInstructionResponse, MEMO_PROGRAM_ID, type ProgramStrategyType, type RebalanceDlmmPositionParams, type RebalanceDlmmPositionResponse, SwapExternalType, type SwapQuoteResult, ZAP_PROGRAM_ID, Zap, type ZapInDammV2DirectPoolParam, type ZapInDammV2InDirectPoolParam, type ZapInDammV2Response, type ZapInDlmmDirectPoolParam, type ZapInDlmmIndirectPoolParam, type ZapInDlmmResponse, type ZapOutParameters, type ZapOutParams, type ZapOutThroughDammV2Params, type ZapOutThroughDlmmParams, type ZapOutThroughJupiterParams, type ZapProgram, binDeltaToMinMaxBinId, buildJupiterSwapTransaction, convertAccountTypeToNumber, convertLamportsToUiAmount, convertUiAmountToLamports, createDammV2SwapPayload, createDlmmSwapPayload, deriveDammV2EventAuthority, deriveDammV2PoolAuthority, deriveDlmmEventAuthority, deriveLedgerAccount, estimateDirectSwap, estimateIndirectSwap, getBinArrayBitmapExtension, getBitFromBinArrayIndexInBitmapExtension, getDammV2Pool, getDammV2RemainingAccounts, getDlmmRemainingAccounts, getExtraAccountMetasForTransferHook, getJupiterQuote, getJupiterSwapInstruction, getLbPairState, getNextBinArrayIndexWithLiquidity, getOrCreateATAInstruction, getTokenAccountBalance, getTokenProgramFromMint, toProgramStrategyType, unwrapSOLInstruction, wrapSOLInstruction };