@jup-ag/lend 0.2.0-beta.2 → 0.2.0-beta.3

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.
@@ -0,0 +1,2184 @@
1
+ import { Program } from '@coral-xyz/anchor';
2
+ import { PublicKey } from '@solana/web3.js';
3
+ import { getAssociatedTokenAddress, getAccount, createAssociatedTokenAccountInstruction } from '@solana/spl-token';
4
+ import { BN } from 'bn.js';
5
+
6
+ const address = "jup3YeL8QhtSx1e253b2FDvsMNC87fDrgQZivbrndc9";
7
+ const metadata = {
8
+ name: "lending",
9
+ version: "0.1.2",
10
+ spec: "0.1.0",
11
+ description: "Created with Anchor"
12
+ };
13
+ const instructions = [
14
+ {
15
+ name: "deposit",
16
+ discriminator: [
17
+ 242,
18
+ 35,
19
+ 198,
20
+ 137,
21
+ 82,
22
+ 225,
23
+ 242,
24
+ 182
25
+ ],
26
+ accounts: [
27
+ {
28
+ name: "signer",
29
+ writable: true,
30
+ signer: true
31
+ },
32
+ {
33
+ name: "depositor_token_account",
34
+ writable: true
35
+ },
36
+ {
37
+ name: "recipient_token_account",
38
+ writable: true
39
+ },
40
+ {
41
+ name: "mint",
42
+ relations: [
43
+ "lending",
44
+ "rewards_rate_model"
45
+ ]
46
+ },
47
+ {
48
+ name: "lending_admin"
49
+ },
50
+ {
51
+ name: "lending",
52
+ writable: true
53
+ },
54
+ {
55
+ name: "f_token_mint",
56
+ writable: true,
57
+ relations: [
58
+ "lending"
59
+ ]
60
+ },
61
+ {
62
+ name: "supply_token_reserves_liquidity",
63
+ writable: true
64
+ },
65
+ {
66
+ name: "lending_supply_position_on_liquidity",
67
+ writable: true
68
+ },
69
+ {
70
+ name: "rate_model"
71
+ },
72
+ {
73
+ name: "vault",
74
+ writable: true
75
+ },
76
+ {
77
+ name: "liquidity",
78
+ writable: true
79
+ },
80
+ {
81
+ name: "liquidity_program",
82
+ relations: [
83
+ "lending_admin"
84
+ ]
85
+ },
86
+ {
87
+ name: "rewards_rate_model"
88
+ },
89
+ {
90
+ name: "token_program"
91
+ },
92
+ {
93
+ name: "associated_token_program",
94
+ optional: true,
95
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
96
+ },
97
+ {
98
+ name: "system_program",
99
+ address: "11111111111111111111111111111111"
100
+ }
101
+ ],
102
+ args: [
103
+ {
104
+ name: "assets",
105
+ type: "u64"
106
+ }
107
+ ],
108
+ returns: "u64"
109
+ },
110
+ {
111
+ name: "deposit_with_min_amount_out",
112
+ discriminator: [
113
+ 116,
114
+ 144,
115
+ 16,
116
+ 97,
117
+ 118,
118
+ 109,
119
+ 40,
120
+ 119
121
+ ],
122
+ accounts: [
123
+ {
124
+ name: "signer",
125
+ writable: true,
126
+ signer: true
127
+ },
128
+ {
129
+ name: "depositor_token_account",
130
+ writable: true
131
+ },
132
+ {
133
+ name: "recipient_token_account",
134
+ writable: true
135
+ },
136
+ {
137
+ name: "mint",
138
+ relations: [
139
+ "lending",
140
+ "rewards_rate_model"
141
+ ]
142
+ },
143
+ {
144
+ name: "lending_admin"
145
+ },
146
+ {
147
+ name: "lending",
148
+ writable: true
149
+ },
150
+ {
151
+ name: "f_token_mint",
152
+ writable: true,
153
+ relations: [
154
+ "lending"
155
+ ]
156
+ },
157
+ {
158
+ name: "supply_token_reserves_liquidity",
159
+ writable: true
160
+ },
161
+ {
162
+ name: "lending_supply_position_on_liquidity",
163
+ writable: true
164
+ },
165
+ {
166
+ name: "rate_model"
167
+ },
168
+ {
169
+ name: "vault",
170
+ writable: true
171
+ },
172
+ {
173
+ name: "liquidity",
174
+ writable: true
175
+ },
176
+ {
177
+ name: "liquidity_program",
178
+ relations: [
179
+ "lending_admin"
180
+ ]
181
+ },
182
+ {
183
+ name: "rewards_rate_model"
184
+ },
185
+ {
186
+ name: "token_program"
187
+ },
188
+ {
189
+ name: "associated_token_program",
190
+ optional: true,
191
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
192
+ },
193
+ {
194
+ name: "system_program",
195
+ address: "11111111111111111111111111111111"
196
+ }
197
+ ],
198
+ args: [
199
+ {
200
+ name: "assets",
201
+ type: "u64"
202
+ },
203
+ {
204
+ name: "min_amount_out",
205
+ type: "u64"
206
+ }
207
+ ]
208
+ },
209
+ {
210
+ name: "init_lending",
211
+ discriminator: [
212
+ 156,
213
+ 224,
214
+ 67,
215
+ 46,
216
+ 89,
217
+ 189,
218
+ 157,
219
+ 209
220
+ ],
221
+ accounts: [
222
+ {
223
+ name: "signer",
224
+ writable: true,
225
+ signer: true
226
+ },
227
+ {
228
+ name: "lending_admin",
229
+ writable: true
230
+ },
231
+ {
232
+ name: "mint",
233
+ relations: [
234
+ "token_reserves_liquidity"
235
+ ]
236
+ },
237
+ {
238
+ name: "f_token_mint",
239
+ writable: true,
240
+ pda: {
241
+ seeds: [
242
+ {
243
+ kind: "const",
244
+ value: [
245
+ 102,
246
+ 95,
247
+ 116,
248
+ 111,
249
+ 107,
250
+ 101,
251
+ 110,
252
+ 95,
253
+ 109,
254
+ 105,
255
+ 110,
256
+ 116
257
+ ]
258
+ },
259
+ {
260
+ kind: "account",
261
+ path: "mint"
262
+ }
263
+ ]
264
+ }
265
+ },
266
+ {
267
+ name: "metadata_account",
268
+ writable: true,
269
+ pda: {
270
+ seeds: [
271
+ {
272
+ kind: "const",
273
+ value: [
274
+ 109,
275
+ 101,
276
+ 116,
277
+ 97,
278
+ 100,
279
+ 97,
280
+ 116,
281
+ 97
282
+ ]
283
+ },
284
+ {
285
+ kind: "const",
286
+ value: [
287
+ 11,
288
+ 112,
289
+ 101,
290
+ 177,
291
+ 227,
292
+ 209,
293
+ 124,
294
+ 69,
295
+ 56,
296
+ 157,
297
+ 82,
298
+ 127,
299
+ 107,
300
+ 4,
301
+ 195,
302
+ 205,
303
+ 88,
304
+ 184,
305
+ 108,
306
+ 115,
307
+ 26,
308
+ 160,
309
+ 253,
310
+ 181,
311
+ 73,
312
+ 182,
313
+ 209,
314
+ 188,
315
+ 3,
316
+ 248,
317
+ 41,
318
+ 70
319
+ ]
320
+ },
321
+ {
322
+ kind: "account",
323
+ path: "f_token_mint"
324
+ }
325
+ ],
326
+ program: {
327
+ kind: "const",
328
+ value: [
329
+ 11,
330
+ 112,
331
+ 101,
332
+ 177,
333
+ 227,
334
+ 209,
335
+ 124,
336
+ 69,
337
+ 56,
338
+ 157,
339
+ 82,
340
+ 127,
341
+ 107,
342
+ 4,
343
+ 195,
344
+ 205,
345
+ 88,
346
+ 184,
347
+ 108,
348
+ 115,
349
+ 26,
350
+ 160,
351
+ 253,
352
+ 181,
353
+ 73,
354
+ 182,
355
+ 209,
356
+ 188,
357
+ 3,
358
+ 248,
359
+ 41,
360
+ 70
361
+ ]
362
+ }
363
+ }
364
+ },
365
+ {
366
+ name: "lending",
367
+ writable: true,
368
+ pda: {
369
+ seeds: [
370
+ {
371
+ kind: "const",
372
+ value: [
373
+ 108,
374
+ 101,
375
+ 110,
376
+ 100,
377
+ 105,
378
+ 110,
379
+ 103
380
+ ]
381
+ },
382
+ {
383
+ kind: "account",
384
+ path: "mint"
385
+ },
386
+ {
387
+ kind: "account",
388
+ path: "f_token_mint"
389
+ }
390
+ ]
391
+ }
392
+ },
393
+ {
394
+ name: "token_reserves_liquidity"
395
+ },
396
+ {
397
+ name: "token_program"
398
+ },
399
+ {
400
+ name: "system_program",
401
+ address: "11111111111111111111111111111111"
402
+ },
403
+ {
404
+ name: "sysvar_instruction",
405
+ address: "Sysvar1nstructions1111111111111111111111111"
406
+ },
407
+ {
408
+ name: "metadata_program",
409
+ address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
410
+ },
411
+ {
412
+ name: "rent",
413
+ address: "SysvarRent111111111111111111111111111111111"
414
+ }
415
+ ],
416
+ args: [
417
+ {
418
+ name: "symbol",
419
+ type: "string"
420
+ },
421
+ {
422
+ name: "liquidity_program",
423
+ type: "pubkey"
424
+ }
425
+ ]
426
+ },
427
+ {
428
+ name: "init_lending_admin",
429
+ discriminator: [
430
+ 203,
431
+ 185,
432
+ 241,
433
+ 165,
434
+ 56,
435
+ 254,
436
+ 33,
437
+ 9
438
+ ],
439
+ accounts: [
440
+ {
441
+ name: "authority",
442
+ writable: true,
443
+ signer: true
444
+ },
445
+ {
446
+ name: "lending_admin",
447
+ writable: true,
448
+ pda: {
449
+ seeds: [
450
+ {
451
+ kind: "const",
452
+ value: [
453
+ 108,
454
+ 101,
455
+ 110,
456
+ 100,
457
+ 105,
458
+ 110,
459
+ 103,
460
+ 95,
461
+ 97,
462
+ 100,
463
+ 109,
464
+ 105,
465
+ 110
466
+ ]
467
+ }
468
+ ]
469
+ }
470
+ },
471
+ {
472
+ name: "system_program",
473
+ address: "11111111111111111111111111111111"
474
+ }
475
+ ],
476
+ args: [
477
+ {
478
+ name: "liquidity_program",
479
+ type: "pubkey"
480
+ },
481
+ {
482
+ name: "rebalancer",
483
+ type: "pubkey"
484
+ },
485
+ {
486
+ name: "authority",
487
+ type: "pubkey"
488
+ }
489
+ ]
490
+ },
491
+ {
492
+ name: "mint",
493
+ discriminator: [
494
+ 51,
495
+ 57,
496
+ 225,
497
+ 47,
498
+ 182,
499
+ 146,
500
+ 137,
501
+ 166
502
+ ],
503
+ accounts: [
504
+ {
505
+ name: "signer",
506
+ writable: true,
507
+ signer: true
508
+ },
509
+ {
510
+ name: "depositor_token_account",
511
+ writable: true
512
+ },
513
+ {
514
+ name: "recipient_token_account",
515
+ writable: true
516
+ },
517
+ {
518
+ name: "mint",
519
+ relations: [
520
+ "lending",
521
+ "rewards_rate_model"
522
+ ]
523
+ },
524
+ {
525
+ name: "lending_admin"
526
+ },
527
+ {
528
+ name: "lending",
529
+ writable: true
530
+ },
531
+ {
532
+ name: "f_token_mint",
533
+ writable: true,
534
+ relations: [
535
+ "lending"
536
+ ]
537
+ },
538
+ {
539
+ name: "supply_token_reserves_liquidity",
540
+ writable: true
541
+ },
542
+ {
543
+ name: "lending_supply_position_on_liquidity",
544
+ writable: true
545
+ },
546
+ {
547
+ name: "rate_model"
548
+ },
549
+ {
550
+ name: "vault",
551
+ writable: true
552
+ },
553
+ {
554
+ name: "liquidity",
555
+ writable: true
556
+ },
557
+ {
558
+ name: "liquidity_program",
559
+ relations: [
560
+ "lending_admin"
561
+ ]
562
+ },
563
+ {
564
+ name: "rewards_rate_model"
565
+ },
566
+ {
567
+ name: "token_program"
568
+ },
569
+ {
570
+ name: "associated_token_program",
571
+ optional: true,
572
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
573
+ },
574
+ {
575
+ name: "system_program",
576
+ address: "11111111111111111111111111111111"
577
+ }
578
+ ],
579
+ args: [
580
+ {
581
+ name: "shares",
582
+ type: "u64"
583
+ }
584
+ ],
585
+ returns: "u64"
586
+ },
587
+ {
588
+ name: "mint_with_max_assets",
589
+ discriminator: [
590
+ 6,
591
+ 94,
592
+ 69,
593
+ 122,
594
+ 30,
595
+ 179,
596
+ 146,
597
+ 171
598
+ ],
599
+ accounts: [
600
+ {
601
+ name: "signer",
602
+ writable: true,
603
+ signer: true
604
+ },
605
+ {
606
+ name: "depositor_token_account",
607
+ writable: true
608
+ },
609
+ {
610
+ name: "recipient_token_account",
611
+ writable: true
612
+ },
613
+ {
614
+ name: "mint",
615
+ relations: [
616
+ "lending",
617
+ "rewards_rate_model"
618
+ ]
619
+ },
620
+ {
621
+ name: "lending_admin"
622
+ },
623
+ {
624
+ name: "lending",
625
+ writable: true
626
+ },
627
+ {
628
+ name: "f_token_mint",
629
+ writable: true,
630
+ relations: [
631
+ "lending"
632
+ ]
633
+ },
634
+ {
635
+ name: "supply_token_reserves_liquidity",
636
+ writable: true
637
+ },
638
+ {
639
+ name: "lending_supply_position_on_liquidity",
640
+ writable: true
641
+ },
642
+ {
643
+ name: "rate_model"
644
+ },
645
+ {
646
+ name: "vault",
647
+ writable: true
648
+ },
649
+ {
650
+ name: "liquidity",
651
+ writable: true
652
+ },
653
+ {
654
+ name: "liquidity_program",
655
+ relations: [
656
+ "lending_admin"
657
+ ]
658
+ },
659
+ {
660
+ name: "rewards_rate_model"
661
+ },
662
+ {
663
+ name: "token_program"
664
+ },
665
+ {
666
+ name: "associated_token_program",
667
+ optional: true,
668
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
669
+ },
670
+ {
671
+ name: "system_program",
672
+ address: "11111111111111111111111111111111"
673
+ }
674
+ ],
675
+ args: [
676
+ {
677
+ name: "shares",
678
+ type: "u64"
679
+ },
680
+ {
681
+ name: "max_assets",
682
+ type: "u64"
683
+ }
684
+ ],
685
+ returns: "u64"
686
+ },
687
+ {
688
+ name: "rebalance",
689
+ discriminator: [
690
+ 108,
691
+ 158,
692
+ 77,
693
+ 9,
694
+ 210,
695
+ 52,
696
+ 88,
697
+ 62
698
+ ],
699
+ accounts: [
700
+ {
701
+ name: "signer",
702
+ writable: true,
703
+ signer: true
704
+ },
705
+ {
706
+ name: "depositor_token_account",
707
+ writable: true,
708
+ pda: {
709
+ seeds: [
710
+ {
711
+ kind: "account",
712
+ path: "signer"
713
+ },
714
+ {
715
+ kind: "account",
716
+ path: "token_program"
717
+ },
718
+ {
719
+ kind: "account",
720
+ path: "mint"
721
+ }
722
+ ],
723
+ program: {
724
+ kind: "const",
725
+ value: [
726
+ 140,
727
+ 151,
728
+ 37,
729
+ 143,
730
+ 78,
731
+ 36,
732
+ 137,
733
+ 241,
734
+ 187,
735
+ 61,
736
+ 16,
737
+ 41,
738
+ 20,
739
+ 142,
740
+ 13,
741
+ 131,
742
+ 11,
743
+ 90,
744
+ 19,
745
+ 153,
746
+ 218,
747
+ 255,
748
+ 16,
749
+ 132,
750
+ 4,
751
+ 142,
752
+ 123,
753
+ 216,
754
+ 219,
755
+ 233,
756
+ 248,
757
+ 89
758
+ ]
759
+ }
760
+ }
761
+ },
762
+ {
763
+ name: "lending_admin"
764
+ },
765
+ {
766
+ name: "lending",
767
+ writable: true
768
+ },
769
+ {
770
+ name: "mint",
771
+ relations: [
772
+ "lending",
773
+ "rewards_rate_model"
774
+ ]
775
+ },
776
+ {
777
+ name: "f_token_mint",
778
+ writable: true,
779
+ relations: [
780
+ "lending"
781
+ ]
782
+ },
783
+ {
784
+ name: "supply_token_reserves_liquidity",
785
+ writable: true
786
+ },
787
+ {
788
+ name: "lending_supply_position_on_liquidity",
789
+ writable: true
790
+ },
791
+ {
792
+ name: "rate_model",
793
+ writable: true
794
+ },
795
+ {
796
+ name: "vault",
797
+ writable: true
798
+ },
799
+ {
800
+ name: "liquidity",
801
+ writable: true
802
+ },
803
+ {
804
+ name: "liquidity_program",
805
+ relations: [
806
+ "lending_admin"
807
+ ]
808
+ },
809
+ {
810
+ name: "rewards_rate_model"
811
+ },
812
+ {
813
+ name: "token_program"
814
+ },
815
+ {
816
+ name: "associated_token_program",
817
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
818
+ },
819
+ {
820
+ name: "system_program",
821
+ address: "11111111111111111111111111111111"
822
+ }
823
+ ],
824
+ args: [
825
+ ]
826
+ },
827
+ {
828
+ name: "redeem",
829
+ discriminator: [
830
+ 184,
831
+ 12,
832
+ 86,
833
+ 149,
834
+ 70,
835
+ 196,
836
+ 97,
837
+ 225
838
+ ],
839
+ accounts: [
840
+ {
841
+ name: "signer",
842
+ writable: true,
843
+ signer: true
844
+ },
845
+ {
846
+ name: "owner_token_account",
847
+ writable: true
848
+ },
849
+ {
850
+ name: "recipient_token_account",
851
+ writable: true
852
+ },
853
+ {
854
+ name: "lending_admin"
855
+ },
856
+ {
857
+ name: "lending",
858
+ writable: true
859
+ },
860
+ {
861
+ name: "mint",
862
+ relations: [
863
+ "lending",
864
+ "rewards_rate_model"
865
+ ]
866
+ },
867
+ {
868
+ name: "f_token_mint",
869
+ writable: true,
870
+ relations: [
871
+ "lending"
872
+ ]
873
+ },
874
+ {
875
+ name: "supply_token_reserves_liquidity",
876
+ writable: true
877
+ },
878
+ {
879
+ name: "lending_supply_position_on_liquidity",
880
+ writable: true
881
+ },
882
+ {
883
+ name: "rate_model"
884
+ },
885
+ {
886
+ name: "vault",
887
+ writable: true
888
+ },
889
+ {
890
+ name: "claim_account",
891
+ writable: true,
892
+ optional: true
893
+ },
894
+ {
895
+ name: "liquidity",
896
+ writable: true
897
+ },
898
+ {
899
+ name: "liquidity_program",
900
+ relations: [
901
+ "lending_admin"
902
+ ]
903
+ },
904
+ {
905
+ name: "rewards_rate_model"
906
+ },
907
+ {
908
+ name: "token_program"
909
+ },
910
+ {
911
+ name: "associated_token_program",
912
+ optional: true,
913
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
914
+ },
915
+ {
916
+ name: "system_program",
917
+ address: "11111111111111111111111111111111"
918
+ }
919
+ ],
920
+ args: [
921
+ {
922
+ name: "shares",
923
+ type: "u64"
924
+ }
925
+ ],
926
+ returns: "u64"
927
+ },
928
+ {
929
+ name: "redeem_with_min_amount_out",
930
+ discriminator: [
931
+ 235,
932
+ 189,
933
+ 237,
934
+ 56,
935
+ 166,
936
+ 180,
937
+ 184,
938
+ 149
939
+ ],
940
+ accounts: [
941
+ {
942
+ name: "signer",
943
+ writable: true,
944
+ signer: true
945
+ },
946
+ {
947
+ name: "owner_token_account",
948
+ writable: true
949
+ },
950
+ {
951
+ name: "recipient_token_account",
952
+ writable: true
953
+ },
954
+ {
955
+ name: "lending_admin"
956
+ },
957
+ {
958
+ name: "lending",
959
+ writable: true
960
+ },
961
+ {
962
+ name: "mint",
963
+ relations: [
964
+ "lending",
965
+ "rewards_rate_model"
966
+ ]
967
+ },
968
+ {
969
+ name: "f_token_mint",
970
+ writable: true,
971
+ relations: [
972
+ "lending"
973
+ ]
974
+ },
975
+ {
976
+ name: "supply_token_reserves_liquidity",
977
+ writable: true
978
+ },
979
+ {
980
+ name: "lending_supply_position_on_liquidity",
981
+ writable: true
982
+ },
983
+ {
984
+ name: "rate_model"
985
+ },
986
+ {
987
+ name: "vault",
988
+ writable: true
989
+ },
990
+ {
991
+ name: "claim_account",
992
+ writable: true,
993
+ optional: true
994
+ },
995
+ {
996
+ name: "liquidity",
997
+ writable: true
998
+ },
999
+ {
1000
+ name: "liquidity_program",
1001
+ relations: [
1002
+ "lending_admin"
1003
+ ]
1004
+ },
1005
+ {
1006
+ name: "rewards_rate_model"
1007
+ },
1008
+ {
1009
+ name: "token_program"
1010
+ },
1011
+ {
1012
+ name: "associated_token_program",
1013
+ optional: true,
1014
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
1015
+ },
1016
+ {
1017
+ name: "system_program",
1018
+ address: "11111111111111111111111111111111"
1019
+ }
1020
+ ],
1021
+ args: [
1022
+ {
1023
+ name: "shares",
1024
+ type: "u64"
1025
+ },
1026
+ {
1027
+ name: "min_amount_out",
1028
+ type: "u64"
1029
+ }
1030
+ ]
1031
+ },
1032
+ {
1033
+ name: "set_rewards_rate_model",
1034
+ discriminator: [
1035
+ 174,
1036
+ 231,
1037
+ 116,
1038
+ 203,
1039
+ 8,
1040
+ 58,
1041
+ 143,
1042
+ 203
1043
+ ],
1044
+ accounts: [
1045
+ {
1046
+ name: "signer",
1047
+ signer: true
1048
+ },
1049
+ {
1050
+ name: "lending_admin"
1051
+ },
1052
+ {
1053
+ name: "lending",
1054
+ writable: true
1055
+ },
1056
+ {
1057
+ name: "f_token_mint",
1058
+ relations: [
1059
+ "lending"
1060
+ ]
1061
+ },
1062
+ {
1063
+ name: "new_rewards_rate_model"
1064
+ },
1065
+ {
1066
+ name: "supply_token_reserves_liquidity"
1067
+ }
1068
+ ],
1069
+ args: [
1070
+ {
1071
+ name: "mint",
1072
+ type: "pubkey"
1073
+ }
1074
+ ]
1075
+ },
1076
+ {
1077
+ name: "update_authority",
1078
+ discriminator: [
1079
+ 32,
1080
+ 46,
1081
+ 64,
1082
+ 28,
1083
+ 149,
1084
+ 75,
1085
+ 243,
1086
+ 88
1087
+ ],
1088
+ accounts: [
1089
+ {
1090
+ name: "signer",
1091
+ signer: true
1092
+ },
1093
+ {
1094
+ name: "lending_admin",
1095
+ writable: true
1096
+ }
1097
+ ],
1098
+ args: [
1099
+ {
1100
+ name: "new_authority",
1101
+ type: "pubkey"
1102
+ }
1103
+ ]
1104
+ },
1105
+ {
1106
+ name: "update_auths",
1107
+ discriminator: [
1108
+ 93,
1109
+ 96,
1110
+ 178,
1111
+ 156,
1112
+ 57,
1113
+ 117,
1114
+ 253,
1115
+ 209
1116
+ ],
1117
+ accounts: [
1118
+ {
1119
+ name: "signer",
1120
+ signer: true
1121
+ },
1122
+ {
1123
+ name: "lending_admin",
1124
+ writable: true
1125
+ }
1126
+ ],
1127
+ args: [
1128
+ {
1129
+ name: "auth_status",
1130
+ type: {
1131
+ vec: {
1132
+ defined: {
1133
+ name: "AddressBool"
1134
+ }
1135
+ }
1136
+ }
1137
+ }
1138
+ ]
1139
+ },
1140
+ {
1141
+ name: "update_rate",
1142
+ discriminator: [
1143
+ 24,
1144
+ 225,
1145
+ 53,
1146
+ 189,
1147
+ 72,
1148
+ 212,
1149
+ 225,
1150
+ 178
1151
+ ],
1152
+ accounts: [
1153
+ {
1154
+ name: "lending",
1155
+ writable: true
1156
+ },
1157
+ {
1158
+ name: "mint",
1159
+ relations: [
1160
+ "lending",
1161
+ "supply_token_reserves_liquidity"
1162
+ ]
1163
+ },
1164
+ {
1165
+ name: "f_token_mint",
1166
+ relations: [
1167
+ "lending"
1168
+ ]
1169
+ },
1170
+ {
1171
+ name: "supply_token_reserves_liquidity"
1172
+ },
1173
+ {
1174
+ name: "rewards_rate_model"
1175
+ }
1176
+ ],
1177
+ args: [
1178
+ ]
1179
+ },
1180
+ {
1181
+ name: "update_rebalancer",
1182
+ discriminator: [
1183
+ 206,
1184
+ 187,
1185
+ 54,
1186
+ 228,
1187
+ 145,
1188
+ 8,
1189
+ 203,
1190
+ 111
1191
+ ],
1192
+ accounts: [
1193
+ {
1194
+ name: "signer",
1195
+ signer: true
1196
+ },
1197
+ {
1198
+ name: "lending_admin",
1199
+ writable: true
1200
+ }
1201
+ ],
1202
+ args: [
1203
+ {
1204
+ name: "new_rebalancer",
1205
+ type: "pubkey"
1206
+ }
1207
+ ]
1208
+ },
1209
+ {
1210
+ name: "withdraw",
1211
+ discriminator: [
1212
+ 183,
1213
+ 18,
1214
+ 70,
1215
+ 156,
1216
+ 148,
1217
+ 109,
1218
+ 161,
1219
+ 34
1220
+ ],
1221
+ accounts: [
1222
+ {
1223
+ name: "signer",
1224
+ writable: true,
1225
+ signer: true
1226
+ },
1227
+ {
1228
+ name: "owner_token_account",
1229
+ writable: true
1230
+ },
1231
+ {
1232
+ name: "recipient_token_account",
1233
+ writable: true
1234
+ },
1235
+ {
1236
+ name: "lending_admin"
1237
+ },
1238
+ {
1239
+ name: "lending",
1240
+ writable: true
1241
+ },
1242
+ {
1243
+ name: "mint",
1244
+ relations: [
1245
+ "lending",
1246
+ "rewards_rate_model"
1247
+ ]
1248
+ },
1249
+ {
1250
+ name: "f_token_mint",
1251
+ writable: true,
1252
+ relations: [
1253
+ "lending"
1254
+ ]
1255
+ },
1256
+ {
1257
+ name: "supply_token_reserves_liquidity",
1258
+ writable: true
1259
+ },
1260
+ {
1261
+ name: "lending_supply_position_on_liquidity",
1262
+ writable: true
1263
+ },
1264
+ {
1265
+ name: "rate_model"
1266
+ },
1267
+ {
1268
+ name: "vault",
1269
+ writable: true
1270
+ },
1271
+ {
1272
+ name: "claim_account",
1273
+ writable: true,
1274
+ optional: true
1275
+ },
1276
+ {
1277
+ name: "liquidity",
1278
+ writable: true
1279
+ },
1280
+ {
1281
+ name: "liquidity_program",
1282
+ relations: [
1283
+ "lending_admin"
1284
+ ]
1285
+ },
1286
+ {
1287
+ name: "rewards_rate_model"
1288
+ },
1289
+ {
1290
+ name: "token_program"
1291
+ },
1292
+ {
1293
+ name: "associated_token_program",
1294
+ optional: true,
1295
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
1296
+ },
1297
+ {
1298
+ name: "system_program",
1299
+ address: "11111111111111111111111111111111"
1300
+ }
1301
+ ],
1302
+ args: [
1303
+ {
1304
+ name: "amount",
1305
+ type: "u64"
1306
+ }
1307
+ ],
1308
+ returns: "u64"
1309
+ },
1310
+ {
1311
+ name: "withdraw_with_max_shares_burn",
1312
+ discriminator: [
1313
+ 47,
1314
+ 197,
1315
+ 183,
1316
+ 171,
1317
+ 239,
1318
+ 18,
1319
+ 245,
1320
+ 171
1321
+ ],
1322
+ accounts: [
1323
+ {
1324
+ name: "signer",
1325
+ writable: true,
1326
+ signer: true
1327
+ },
1328
+ {
1329
+ name: "owner_token_account",
1330
+ writable: true
1331
+ },
1332
+ {
1333
+ name: "recipient_token_account",
1334
+ writable: true
1335
+ },
1336
+ {
1337
+ name: "lending_admin"
1338
+ },
1339
+ {
1340
+ name: "lending",
1341
+ writable: true
1342
+ },
1343
+ {
1344
+ name: "mint",
1345
+ relations: [
1346
+ "lending",
1347
+ "rewards_rate_model"
1348
+ ]
1349
+ },
1350
+ {
1351
+ name: "f_token_mint",
1352
+ writable: true,
1353
+ relations: [
1354
+ "lending"
1355
+ ]
1356
+ },
1357
+ {
1358
+ name: "supply_token_reserves_liquidity",
1359
+ writable: true
1360
+ },
1361
+ {
1362
+ name: "lending_supply_position_on_liquidity",
1363
+ writable: true
1364
+ },
1365
+ {
1366
+ name: "rate_model"
1367
+ },
1368
+ {
1369
+ name: "vault",
1370
+ writable: true
1371
+ },
1372
+ {
1373
+ name: "claim_account",
1374
+ writable: true,
1375
+ optional: true
1376
+ },
1377
+ {
1378
+ name: "liquidity",
1379
+ writable: true
1380
+ },
1381
+ {
1382
+ name: "liquidity_program",
1383
+ relations: [
1384
+ "lending_admin"
1385
+ ]
1386
+ },
1387
+ {
1388
+ name: "rewards_rate_model"
1389
+ },
1390
+ {
1391
+ name: "token_program"
1392
+ },
1393
+ {
1394
+ name: "associated_token_program",
1395
+ optional: true,
1396
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
1397
+ },
1398
+ {
1399
+ name: "system_program",
1400
+ address: "11111111111111111111111111111111"
1401
+ }
1402
+ ],
1403
+ args: [
1404
+ {
1405
+ name: "amount",
1406
+ type: "u64"
1407
+ },
1408
+ {
1409
+ name: "max_shares_burn",
1410
+ type: "u64"
1411
+ }
1412
+ ],
1413
+ returns: "u64"
1414
+ }
1415
+ ];
1416
+ const accounts = [
1417
+ {
1418
+ name: "Lending",
1419
+ discriminator: [
1420
+ 135,
1421
+ 199,
1422
+ 82,
1423
+ 16,
1424
+ 249,
1425
+ 131,
1426
+ 182,
1427
+ 241
1428
+ ]
1429
+ },
1430
+ {
1431
+ name: "LendingAdmin",
1432
+ discriminator: [
1433
+ 42,
1434
+ 8,
1435
+ 33,
1436
+ 220,
1437
+ 163,
1438
+ 40,
1439
+ 210,
1440
+ 5
1441
+ ]
1442
+ },
1443
+ {
1444
+ name: "LendingRewardsRateModel",
1445
+ discriminator: [
1446
+ 166,
1447
+ 72,
1448
+ 71,
1449
+ 131,
1450
+ 172,
1451
+ 74,
1452
+ 166,
1453
+ 181
1454
+ ]
1455
+ },
1456
+ {
1457
+ name: "TokenReserve",
1458
+ discriminator: [
1459
+ 21,
1460
+ 18,
1461
+ 59,
1462
+ 135,
1463
+ 120,
1464
+ 20,
1465
+ 31,
1466
+ 12
1467
+ ]
1468
+ },
1469
+ {
1470
+ name: "UserSupplyPosition",
1471
+ discriminator: [
1472
+ 202,
1473
+ 219,
1474
+ 136,
1475
+ 118,
1476
+ 61,
1477
+ 177,
1478
+ 21,
1479
+ 146
1480
+ ]
1481
+ }
1482
+ ];
1483
+ const events = [
1484
+ {
1485
+ name: "LogDeposit",
1486
+ discriminator: [
1487
+ 176,
1488
+ 243,
1489
+ 1,
1490
+ 56,
1491
+ 142,
1492
+ 206,
1493
+ 1,
1494
+ 106
1495
+ ]
1496
+ },
1497
+ {
1498
+ name: "LogRebalance",
1499
+ discriminator: [
1500
+ 90,
1501
+ 67,
1502
+ 219,
1503
+ 41,
1504
+ 181,
1505
+ 118,
1506
+ 132,
1507
+ 9
1508
+ ]
1509
+ },
1510
+ {
1511
+ name: "LogUpdateAuthority",
1512
+ discriminator: [
1513
+ 150,
1514
+ 152,
1515
+ 157,
1516
+ 143,
1517
+ 6,
1518
+ 135,
1519
+ 193,
1520
+ 101
1521
+ ]
1522
+ },
1523
+ {
1524
+ name: "LogUpdateAuths",
1525
+ discriminator: [
1526
+ 88,
1527
+ 80,
1528
+ 109,
1529
+ 48,
1530
+ 111,
1531
+ 203,
1532
+ 76,
1533
+ 251
1534
+ ]
1535
+ },
1536
+ {
1537
+ name: "LogUpdateRates",
1538
+ discriminator: [
1539
+ 222,
1540
+ 11,
1541
+ 113,
1542
+ 60,
1543
+ 147,
1544
+ 15,
1545
+ 68,
1546
+ 217
1547
+ ]
1548
+ },
1549
+ {
1550
+ name: "LogUpdateRebalancer",
1551
+ discriminator: [
1552
+ 66,
1553
+ 79,
1554
+ 144,
1555
+ 204,
1556
+ 26,
1557
+ 217,
1558
+ 153,
1559
+ 225
1560
+ ]
1561
+ },
1562
+ {
1563
+ name: "LogUpdateRewards",
1564
+ discriminator: [
1565
+ 37,
1566
+ 13,
1567
+ 111,
1568
+ 186,
1569
+ 47,
1570
+ 245,
1571
+ 162,
1572
+ 121
1573
+ ]
1574
+ },
1575
+ {
1576
+ name: "LogWithdraw",
1577
+ discriminator: [
1578
+ 49,
1579
+ 9,
1580
+ 176,
1581
+ 179,
1582
+ 222,
1583
+ 190,
1584
+ 6,
1585
+ 117
1586
+ ]
1587
+ }
1588
+ ];
1589
+ const errors = [
1590
+ {
1591
+ code: 6000,
1592
+ name: "FTokenDepositInsignificant",
1593
+ msg: "F_TOKEN_DEPOSIT_INSIGNIFICANT"
1594
+ },
1595
+ {
1596
+ code: 6001,
1597
+ name: "FTokenMinAmountOut",
1598
+ msg: "F_TOKEN_MIN_AMOUNT_OUT"
1599
+ },
1600
+ {
1601
+ code: 6002,
1602
+ name: "FTokenMaxAmount",
1603
+ msg: "F_TOKEN_MAX_AMOUNT"
1604
+ },
1605
+ {
1606
+ code: 6003,
1607
+ name: "FTokenInvalidParams",
1608
+ msg: "F_TOKEN_INVALID_PARAMS"
1609
+ },
1610
+ {
1611
+ code: 6004,
1612
+ name: "FTokenRewardsRateModelAlreadySet",
1613
+ msg: "F_TOKEN_REWARDS_RATE_MODEL_ALREADY_SET"
1614
+ },
1615
+ {
1616
+ code: 6005,
1617
+ name: "FTokenMaxAuthCountReached",
1618
+ msg: "F_TOKEN_MAX_AUTH_COUNT"
1619
+ },
1620
+ {
1621
+ code: 6006,
1622
+ name: "FTokenLiquidityExchangePriceUnexpected",
1623
+ msg: "F_TOKEN_LIQUIDITY_EXCHANGE_PRICE_UNEXPECTED"
1624
+ },
1625
+ {
1626
+ code: 6007,
1627
+ name: "FTokenCpiToLiquidityFailed",
1628
+ msg: "F_TOKEN_CPI_TO_LIQUIDITY_FAILED"
1629
+ },
1630
+ {
1631
+ code: 6008,
1632
+ name: "FTokenOnlyAuth",
1633
+ msg: "F_TOKEN_ONLY_AUTH"
1634
+ },
1635
+ {
1636
+ code: 6009,
1637
+ name: "FTokenOnlyAuthority",
1638
+ msg: "F_TOKEN_ONLY_AUTHORITY"
1639
+ },
1640
+ {
1641
+ code: 6010,
1642
+ name: "FTokenOnlyRebalancer",
1643
+ msg: "F_TOKEN_ONLY_REBALANCER"
1644
+ },
1645
+ {
1646
+ code: 6011,
1647
+ name: "FTokenUserSupplyPositionRequired",
1648
+ msg: "F_TOKEN_USER_SUPPLY_POSITION_REQUIRED"
1649
+ },
1650
+ {
1651
+ code: 6012,
1652
+ name: "FTokenLiquidityProgramMismatch",
1653
+ msg: "F_TOKEN_LIQUIDITY_PROGRAM_MISMATCH"
1654
+ }
1655
+ ];
1656
+ const types = [
1657
+ {
1658
+ name: "AddressBool",
1659
+ type: {
1660
+ kind: "struct",
1661
+ fields: [
1662
+ {
1663
+ name: "addr",
1664
+ type: "pubkey"
1665
+ },
1666
+ {
1667
+ name: "value",
1668
+ type: "bool"
1669
+ }
1670
+ ]
1671
+ }
1672
+ },
1673
+ {
1674
+ name: "Lending",
1675
+ type: {
1676
+ kind: "struct",
1677
+ fields: [
1678
+ {
1679
+ name: "mint",
1680
+ type: "pubkey"
1681
+ },
1682
+ {
1683
+ name: "f_token_mint",
1684
+ type: "pubkey"
1685
+ },
1686
+ {
1687
+ name: "lending_id",
1688
+ type: "u16"
1689
+ },
1690
+ {
1691
+ name: "decimals",
1692
+ docs: [
1693
+ "@dev number of decimals for the fToken, same as ASSET"
1694
+ ],
1695
+ type: "u8"
1696
+ },
1697
+ {
1698
+ name: "rewards_rate_model",
1699
+ docs: [
1700
+ "@dev To read PDA of rewards rate model to get_rate instruction"
1701
+ ],
1702
+ type: "pubkey"
1703
+ },
1704
+ {
1705
+ name: "liquidity_exchange_price",
1706
+ docs: [
1707
+ "@dev exchange price for the underlying asset in the liquidity protocol (without rewards)"
1708
+ ],
1709
+ type: "u64"
1710
+ },
1711
+ {
1712
+ name: "token_exchange_price",
1713
+ docs: [
1714
+ "@dev exchange price between fToken and the underlying asset (with rewards)"
1715
+ ],
1716
+ type: "u64"
1717
+ },
1718
+ {
1719
+ name: "last_update_timestamp",
1720
+ docs: [
1721
+ "@dev timestamp when exchange prices were updated the last time"
1722
+ ],
1723
+ type: "u64"
1724
+ },
1725
+ {
1726
+ name: "token_reserves_liquidity",
1727
+ type: "pubkey"
1728
+ },
1729
+ {
1730
+ name: "supply_position_on_liquidity",
1731
+ type: "pubkey"
1732
+ },
1733
+ {
1734
+ name: "bump",
1735
+ type: "u8"
1736
+ }
1737
+ ]
1738
+ }
1739
+ },
1740
+ {
1741
+ name: "LendingAdmin",
1742
+ type: {
1743
+ kind: "struct",
1744
+ fields: [
1745
+ {
1746
+ name: "authority",
1747
+ type: "pubkey"
1748
+ },
1749
+ {
1750
+ name: "liquidity_program",
1751
+ type: "pubkey"
1752
+ },
1753
+ {
1754
+ name: "rebalancer",
1755
+ type: "pubkey"
1756
+ },
1757
+ {
1758
+ name: "next_lending_id",
1759
+ type: "u16"
1760
+ },
1761
+ {
1762
+ name: "auths",
1763
+ type: {
1764
+ vec: "pubkey"
1765
+ }
1766
+ },
1767
+ {
1768
+ name: "bump",
1769
+ type: "u8"
1770
+ }
1771
+ ]
1772
+ }
1773
+ },
1774
+ {
1775
+ name: "LendingRewardsRateModel",
1776
+ type: {
1777
+ kind: "struct",
1778
+ fields: [
1779
+ {
1780
+ name: "mint",
1781
+ docs: [
1782
+ "@dev mint address"
1783
+ ],
1784
+ type: "pubkey"
1785
+ },
1786
+ {
1787
+ name: "start_tvl",
1788
+ docs: [
1789
+ "@dev tvl below which rewards rate is 0. If current TVL is below this value, triggering `update_rate()` on the fToken",
1790
+ "might bring the total TVL above this cut-off."
1791
+ ],
1792
+ type: "u64"
1793
+ },
1794
+ {
1795
+ name: "duration",
1796
+ docs: [
1797
+ "@dev for how long current rewards should run"
1798
+ ],
1799
+ type: "u64"
1800
+ },
1801
+ {
1802
+ name: "start_time",
1803
+ docs: [
1804
+ "@dev when current rewards got started"
1805
+ ],
1806
+ type: "u64"
1807
+ },
1808
+ {
1809
+ name: "yearly_reward",
1810
+ docs: [
1811
+ "@dev current annualized reward based on input params (duration, rewardAmount)"
1812
+ ],
1813
+ type: "u64"
1814
+ },
1815
+ {
1816
+ name: "next_duration",
1817
+ docs: [
1818
+ "@dev Duration for the next rewards phase"
1819
+ ],
1820
+ type: "u64"
1821
+ },
1822
+ {
1823
+ name: "next_reward_amount",
1824
+ docs: [
1825
+ "@dev Amount of rewards for the next phase"
1826
+ ],
1827
+ type: "u64"
1828
+ },
1829
+ {
1830
+ name: "bump",
1831
+ type: "u8"
1832
+ }
1833
+ ]
1834
+ }
1835
+ },
1836
+ {
1837
+ name: "LogDeposit",
1838
+ type: {
1839
+ kind: "struct",
1840
+ fields: [
1841
+ {
1842
+ name: "sender",
1843
+ type: "pubkey"
1844
+ },
1845
+ {
1846
+ name: "receiver",
1847
+ type: "pubkey"
1848
+ },
1849
+ {
1850
+ name: "assets",
1851
+ type: "u64"
1852
+ },
1853
+ {
1854
+ name: "shares_minted",
1855
+ type: "u64"
1856
+ }
1857
+ ]
1858
+ }
1859
+ },
1860
+ {
1861
+ name: "LogRebalance",
1862
+ type: {
1863
+ kind: "struct",
1864
+ fields: [
1865
+ {
1866
+ name: "assets",
1867
+ type: "u64"
1868
+ }
1869
+ ]
1870
+ }
1871
+ },
1872
+ {
1873
+ name: "LogUpdateAuthority",
1874
+ type: {
1875
+ kind: "struct",
1876
+ fields: [
1877
+ {
1878
+ name: "new_authority",
1879
+ type: "pubkey"
1880
+ }
1881
+ ]
1882
+ }
1883
+ },
1884
+ {
1885
+ name: "LogUpdateAuths",
1886
+ type: {
1887
+ kind: "struct",
1888
+ fields: [
1889
+ {
1890
+ name: "auth_status",
1891
+ type: {
1892
+ vec: {
1893
+ defined: {
1894
+ name: "AddressBool"
1895
+ }
1896
+ }
1897
+ }
1898
+ }
1899
+ ]
1900
+ }
1901
+ },
1902
+ {
1903
+ name: "LogUpdateRates",
1904
+ type: {
1905
+ kind: "struct",
1906
+ fields: [
1907
+ {
1908
+ name: "token_exchange_price",
1909
+ type: "u64"
1910
+ },
1911
+ {
1912
+ name: "liquidity_exchange_price",
1913
+ type: "u64"
1914
+ }
1915
+ ]
1916
+ }
1917
+ },
1918
+ {
1919
+ name: "LogUpdateRebalancer",
1920
+ type: {
1921
+ kind: "struct",
1922
+ fields: [
1923
+ {
1924
+ name: "new_rebalancer",
1925
+ type: "pubkey"
1926
+ }
1927
+ ]
1928
+ }
1929
+ },
1930
+ {
1931
+ name: "LogUpdateRewards",
1932
+ type: {
1933
+ kind: "struct",
1934
+ fields: [
1935
+ {
1936
+ name: "rewards_rate_model",
1937
+ type: "pubkey"
1938
+ }
1939
+ ]
1940
+ }
1941
+ },
1942
+ {
1943
+ name: "LogWithdraw",
1944
+ type: {
1945
+ kind: "struct",
1946
+ fields: [
1947
+ {
1948
+ name: "sender",
1949
+ type: "pubkey"
1950
+ },
1951
+ {
1952
+ name: "receiver",
1953
+ type: "pubkey"
1954
+ },
1955
+ {
1956
+ name: "owner",
1957
+ type: "pubkey"
1958
+ },
1959
+ {
1960
+ name: "assets",
1961
+ type: "u64"
1962
+ },
1963
+ {
1964
+ name: "shares_burned",
1965
+ type: "u64"
1966
+ }
1967
+ ]
1968
+ }
1969
+ },
1970
+ {
1971
+ name: "TokenReserve",
1972
+ docs: [
1973
+ "Token configuration and exchange prices"
1974
+ ],
1975
+ serialization: "bytemuck",
1976
+ repr: {
1977
+ kind: "c",
1978
+ packed: true
1979
+ },
1980
+ type: {
1981
+ kind: "struct",
1982
+ fields: [
1983
+ {
1984
+ name: "mint",
1985
+ type: "pubkey"
1986
+ },
1987
+ {
1988
+ name: "vault",
1989
+ type: "pubkey"
1990
+ },
1991
+ {
1992
+ name: "borrow_rate",
1993
+ type: "u16"
1994
+ },
1995
+ {
1996
+ name: "fee_on_interest",
1997
+ type: "u16"
1998
+ },
1999
+ {
2000
+ name: "last_utilization",
2001
+ type: "u16"
2002
+ },
2003
+ {
2004
+ name: "last_update_timestamp",
2005
+ type: "u64"
2006
+ },
2007
+ {
2008
+ name: "supply_exchange_price",
2009
+ type: "u64"
2010
+ },
2011
+ {
2012
+ name: "borrow_exchange_price",
2013
+ type: "u64"
2014
+ },
2015
+ {
2016
+ name: "max_utilization",
2017
+ type: "u16"
2018
+ },
2019
+ {
2020
+ name: "total_supply_with_interest",
2021
+ type: "u64"
2022
+ },
2023
+ {
2024
+ name: "total_supply_interest_free",
2025
+ type: "u64"
2026
+ },
2027
+ {
2028
+ name: "total_borrow_with_interest",
2029
+ type: "u64"
2030
+ },
2031
+ {
2032
+ name: "total_borrow_interest_free",
2033
+ type: "u64"
2034
+ },
2035
+ {
2036
+ name: "total_claim_amount",
2037
+ type: "u64"
2038
+ },
2039
+ {
2040
+ name: "interacting_protocol",
2041
+ type: "pubkey"
2042
+ },
2043
+ {
2044
+ name: "interacting_timestamp",
2045
+ type: "u64"
2046
+ },
2047
+ {
2048
+ name: "interacting_balance",
2049
+ type: "u64"
2050
+ }
2051
+ ]
2052
+ }
2053
+ },
2054
+ {
2055
+ name: "UserSupplyPosition",
2056
+ docs: [
2057
+ "User supply position"
2058
+ ],
2059
+ serialization: "bytemuck",
2060
+ repr: {
2061
+ kind: "c",
2062
+ packed: true
2063
+ },
2064
+ type: {
2065
+ kind: "struct",
2066
+ fields: [
2067
+ {
2068
+ name: "protocol",
2069
+ type: "pubkey"
2070
+ },
2071
+ {
2072
+ name: "mint",
2073
+ type: "pubkey"
2074
+ },
2075
+ {
2076
+ name: "with_interest",
2077
+ type: "u8"
2078
+ },
2079
+ {
2080
+ name: "amount",
2081
+ type: "u64"
2082
+ },
2083
+ {
2084
+ name: "withdrawal_limit",
2085
+ type: "u64"
2086
+ },
2087
+ {
2088
+ name: "decay_amount",
2089
+ type: "u64"
2090
+ },
2091
+ {
2092
+ name: "last_update",
2093
+ type: "u64"
2094
+ },
2095
+ {
2096
+ name: "expand_pct",
2097
+ type: "u16"
2098
+ },
2099
+ {
2100
+ name: "expand_duration",
2101
+ type: "u32"
2102
+ },
2103
+ {
2104
+ name: "decay_duration",
2105
+ type: "u32"
2106
+ },
2107
+ {
2108
+ name: "base_withdrawal_limit",
2109
+ type: "u64"
2110
+ },
2111
+ {
2112
+ name: "status",
2113
+ type: "u8"
2114
+ }
2115
+ ]
2116
+ }
2117
+ }
2118
+ ];
2119
+ const lending = {
2120
+ address: address,
2121
+ metadata: metadata,
2122
+ instructions: instructions,
2123
+ accounts: accounts,
2124
+ events: events,
2125
+ errors: errors,
2126
+ types: types
2127
+ };
2128
+
2129
+ const U64_MAX = new BN("18446744073709551615");
2130
+ const MAX_DEPOSIT = U64_MAX;
2131
+ const MAX_WITHDRAW = U64_MAX;
2132
+ const getLendingProgram = ({
2133
+ connection,
2134
+ signer,
2135
+ market
2136
+ }) => {
2137
+ let idl = { ...lending };
2138
+ if (market === "ethena")
2139
+ idl.address = "jup97Zx1NixM8UJMQFw8TtKzqTiRT3ETAJR7cVx3PfQ";
2140
+ return new Program(idl, {
2141
+ connection,
2142
+ publicKey: signer
2143
+ });
2144
+ };
2145
+ const getAccountOwner = async (account, connection) => {
2146
+ const info = await connection.getAccountInfo(account);
2147
+ if (!info)
2148
+ throw new Error(`Account info not found for ${account.toString()}`);
2149
+ return info.owner;
2150
+ };
2151
+ const getOrCreateATAInstruction = async (owner, mint, connection) => {
2152
+ const tokenProgram = await getAccountOwner(mint, connection);
2153
+ const associatedTokenAccount = await getAssociatedTokenAddress(
2154
+ mint,
2155
+ owner,
2156
+ true,
2157
+ // allowOwnerOffCurve - supports PDA owners
2158
+ tokenProgram
2159
+ );
2160
+ const account = await getAccount(
2161
+ connection,
2162
+ associatedTokenAccount,
2163
+ "confirmed",
2164
+ tokenProgram
2165
+ ).catch(() => null);
2166
+ const ixs = [];
2167
+ if (!account) {
2168
+ ixs.push(
2169
+ createAssociatedTokenAccountInstruction(
2170
+ owner,
2171
+ associatedTokenAccount,
2172
+ owner,
2173
+ mint,
2174
+ tokenProgram
2175
+ )
2176
+ );
2177
+ }
2178
+ return ixs;
2179
+ };
2180
+ const getLiquidityProgramId = (market) => {
2181
+ return market === "ethena" ? new PublicKey("jup6QF1sNDGpkkcu6F4qaFHcRBmnSS1VgyB4uFbBvNS") : new PublicKey("jupeiUmn818Jg1ekPURTpr4mFo29p46vygyykFJ3wZC");
2182
+ };
2183
+
2184
+ export { MAX_DEPOSIT as M, U64_MAX as U, getLiquidityProgramId as a, getLendingProgram as b, getOrCreateATAInstruction as c, MAX_WITHDRAW as d, getAccountOwner as g };