@hodlmarkets/sdk 0.1.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.
Files changed (68) hide show
  1. package/README.md +121 -0
  2. package/dist/accounts.cjs +1893 -0
  3. package/dist/accounts.cjs.map +1 -0
  4. package/dist/accounts.d.cts +9 -0
  5. package/dist/accounts.d.ts +9 -0
  6. package/dist/accounts.js +1885 -0
  7. package/dist/accounts.js.map +1 -0
  8. package/dist/client.cjs +2161 -0
  9. package/dist/client.cjs.map +1 -0
  10. package/dist/client.d.cts +44 -0
  11. package/dist/client.d.ts +44 -0
  12. package/dist/client.js +2155 -0
  13. package/dist/client.js.map +1 -0
  14. package/dist/constants.cjs +68 -0
  15. package/dist/constants.cjs.map +1 -0
  16. package/dist/constants.d.cts +62 -0
  17. package/dist/constants.d.ts +62 -0
  18. package/dist/constants.js +50 -0
  19. package/dist/constants.js.map +1 -0
  20. package/dist/errors.cjs +43 -0
  21. package/dist/errors.cjs.map +1 -0
  22. package/dist/errors.d.cts +8 -0
  23. package/dist/errors.d.ts +8 -0
  24. package/dist/errors.js +39 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/events.cjs +1923 -0
  27. package/dist/events.cjs.map +1 -0
  28. package/dist/events.d.cts +20 -0
  29. package/dist/events.d.ts +20 -0
  30. package/dist/events.js +1913 -0
  31. package/dist/events.js.map +1 -0
  32. package/dist/index.cjs +2357 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.cts +12 -0
  35. package/dist/index.d.ts +12 -0
  36. package/dist/index.js +2302 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/instructions.cjs +2022 -0
  39. package/dist/instructions.cjs.map +1 -0
  40. package/dist/instructions.d.cts +38 -0
  41. package/dist/instructions.d.ts +38 -0
  42. package/dist/instructions.js +2012 -0
  43. package/dist/instructions.js.map +1 -0
  44. package/dist/math.cjs +98 -0
  45. package/dist/math.cjs.map +1 -0
  46. package/dist/math.d.cts +58 -0
  47. package/dist/math.d.ts +58 -0
  48. package/dist/math.js +85 -0
  49. package/dist/math.js.map +1 -0
  50. package/dist/pda.cjs +52 -0
  51. package/dist/pda.cjs.map +1 -0
  52. package/dist/pda.d.cts +10 -0
  53. package/dist/pda.d.ts +10 -0
  54. package/dist/pda.js +41 -0
  55. package/dist/pda.js.map +1 -0
  56. package/dist/transaction.cjs +37 -0
  57. package/dist/transaction.cjs.map +1 -0
  58. package/dist/transaction.d.cts +11 -0
  59. package/dist/transaction.d.ts +11 -0
  60. package/dist/transaction.js +34 -0
  61. package/dist/transaction.js.map +1 -0
  62. package/dist/types.cjs +4 -0
  63. package/dist/types.cjs.map +1 -0
  64. package/dist/types.d.cts +153 -0
  65. package/dist/types.d.ts +153 -0
  66. package/dist/types.js +3 -0
  67. package/dist/types.js.map +1 -0
  68. package/package.json +96 -0
@@ -0,0 +1,2012 @@
1
+ import { PublicKey, SystemProgram, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RENT_PUBKEY } from '@solana/web3.js';
2
+ import { getAssociatedTokenAddressSync, ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token';
3
+ import BN from 'bn.js';
4
+ import { AnchorProvider, Program } from '@coral-xyz/anchor';
5
+
6
+ // src/instructions.ts
7
+ new PublicKey("hodLrUfwyK3Z7Td5hdZhyojyznG1rqbHVex11y5s4yG");
8
+ new PublicKey("EFAquDGAHjkoPB6TGKVibD3BYhbFXNDjuXKpiBHdYzji");
9
+ new BN("30000000000");
10
+ new BN("1000000000000000");
11
+ new BN("100000000");
12
+ var SEEDS = {
13
+ POOL: Buffer.from("pool"),
14
+ VAULT_AUTHORITY: Buffer.from("vault_authority"),
15
+ SOL_VAULT: Buffer.from("sol_vault"),
16
+ POSITION: Buffer.from("position"),
17
+ PROTOCOL_FEES: Buffer.from("protocol_fees"),
18
+ EVENT_AUTHORITY: Buffer.from("__event_authority")
19
+ };
20
+
21
+ // src/pda.ts
22
+ function getPoolStatePDA(mint, programId) {
23
+ return PublicKey.findProgramAddressSync([SEEDS.POOL, mint.toBuffer()], programId);
24
+ }
25
+ function getVaultAuthorityPDA(poolState, programId) {
26
+ return PublicKey.findProgramAddressSync([SEEDS.VAULT_AUTHORITY, poolState.toBuffer()], programId);
27
+ }
28
+ function getSolVaultPDA(poolState, programId) {
29
+ return PublicKey.findProgramAddressSync([SEEDS.SOL_VAULT, poolState.toBuffer()], programId);
30
+ }
31
+ function getPositionPDA(poolState, owner, programId) {
32
+ return PublicKey.findProgramAddressSync([SEEDS.POSITION, poolState.toBuffer(), owner.toBuffer()], programId);
33
+ }
34
+ function getProtocolFeesPDA(programId) {
35
+ return PublicKey.findProgramAddressSync([SEEDS.PROTOCOL_FEES], programId);
36
+ }
37
+ function getEventAuthorityPDA(programId) {
38
+ return PublicKey.findProgramAddressSync([SEEDS.EVENT_AUTHORITY], programId);
39
+ }
40
+
41
+ // src/idl/hodl.json
42
+ var hodl_default = {
43
+ address: "hodLrUfwyK3Z7Td5hdZhyojyznG1rqbHVex11y5s4yG",
44
+ metadata: {
45
+ name: "hodl",
46
+ version: "0.1.0",
47
+ spec: "0.1.0"
48
+ },
49
+ instructions: [
50
+ {
51
+ name: "buy",
52
+ docs: [
53
+ "Buy tokens from the vAMM",
54
+ "",
55
+ "Tokens are split into tradable (immediate) and vaulted (accrue linearly).",
56
+ "Allocation is based on token-amount range bands: 40/60 at 0-50M, +5% per 50M band, 100/0 at 600M+.",
57
+ "After vest_duration passes, all buys are 100% tradable."
58
+ ],
59
+ discriminator: [
60
+ 102,
61
+ 6,
62
+ 61,
63
+ 18,
64
+ 1,
65
+ 218,
66
+ 235,
67
+ 234
68
+ ],
69
+ accounts: [
70
+ {
71
+ name: "buyer",
72
+ writable: true,
73
+ signer: true
74
+ },
75
+ {
76
+ name: "pool_state",
77
+ writable: true,
78
+ pda: {
79
+ seeds: [
80
+ {
81
+ kind: "const",
82
+ value: [
83
+ 112,
84
+ 111,
85
+ 111,
86
+ 108
87
+ ]
88
+ },
89
+ {
90
+ kind: "account",
91
+ path: "mint"
92
+ }
93
+ ]
94
+ }
95
+ },
96
+ {
97
+ name: "token_vault",
98
+ writable: true
99
+ },
100
+ {
101
+ name: "vault_authority",
102
+ pda: {
103
+ seeds: [
104
+ {
105
+ kind: "const",
106
+ value: [
107
+ 118,
108
+ 97,
109
+ 117,
110
+ 108,
111
+ 116,
112
+ 95,
113
+ 97,
114
+ 117,
115
+ 116,
116
+ 104,
117
+ 111,
118
+ 114,
119
+ 105,
120
+ 116,
121
+ 121
122
+ ]
123
+ },
124
+ {
125
+ kind: "account",
126
+ path: "pool_state"
127
+ }
128
+ ]
129
+ }
130
+ },
131
+ {
132
+ name: "buyer_token_account",
133
+ writable: true,
134
+ pda: {
135
+ seeds: [
136
+ {
137
+ kind: "account",
138
+ path: "buyer"
139
+ },
140
+ {
141
+ kind: "const",
142
+ value: [
143
+ 6,
144
+ 221,
145
+ 246,
146
+ 225,
147
+ 215,
148
+ 101,
149
+ 161,
150
+ 147,
151
+ 217,
152
+ 203,
153
+ 225,
154
+ 70,
155
+ 206,
156
+ 235,
157
+ 121,
158
+ 172,
159
+ 28,
160
+ 180,
161
+ 133,
162
+ 237,
163
+ 95,
164
+ 91,
165
+ 55,
166
+ 145,
167
+ 58,
168
+ 140,
169
+ 245,
170
+ 133,
171
+ 126,
172
+ 255,
173
+ 0,
174
+ 169
175
+ ]
176
+ },
177
+ {
178
+ kind: "account",
179
+ path: "mint"
180
+ }
181
+ ],
182
+ program: {
183
+ kind: "const",
184
+ value: [
185
+ 140,
186
+ 151,
187
+ 37,
188
+ 143,
189
+ 78,
190
+ 36,
191
+ 137,
192
+ 241,
193
+ 187,
194
+ 61,
195
+ 16,
196
+ 41,
197
+ 20,
198
+ 142,
199
+ 13,
200
+ 131,
201
+ 11,
202
+ 90,
203
+ 19,
204
+ 153,
205
+ 218,
206
+ 255,
207
+ 16,
208
+ 132,
209
+ 4,
210
+ 142,
211
+ 123,
212
+ 216,
213
+ 219,
214
+ 233,
215
+ 248,
216
+ 89
217
+ ]
218
+ }
219
+ }
220
+ },
221
+ {
222
+ name: "pool_sol_account",
223
+ writable: true,
224
+ pda: {
225
+ seeds: [
226
+ {
227
+ kind: "const",
228
+ value: [
229
+ 115,
230
+ 111,
231
+ 108,
232
+ 95,
233
+ 118,
234
+ 97,
235
+ 117,
236
+ 108,
237
+ 116
238
+ ]
239
+ },
240
+ {
241
+ kind: "account",
242
+ path: "pool_state"
243
+ }
244
+ ]
245
+ }
246
+ },
247
+ {
248
+ name: "mint"
249
+ },
250
+ {
251
+ name: "token_program",
252
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
253
+ },
254
+ {
255
+ name: "associated_token_program",
256
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
257
+ },
258
+ {
259
+ name: "system_program",
260
+ address: "11111111111111111111111111111111"
261
+ },
262
+ {
263
+ name: "position",
264
+ writable: true,
265
+ pda: {
266
+ seeds: [
267
+ {
268
+ kind: "const",
269
+ value: [
270
+ 112,
271
+ 111,
272
+ 115,
273
+ 105,
274
+ 116,
275
+ 105,
276
+ 111,
277
+ 110
278
+ ]
279
+ },
280
+ {
281
+ kind: "account",
282
+ path: "pool_state"
283
+ },
284
+ {
285
+ kind: "account",
286
+ path: "buyer"
287
+ }
288
+ ]
289
+ }
290
+ },
291
+ {
292
+ name: "event_authority",
293
+ pda: {
294
+ seeds: [
295
+ {
296
+ kind: "const",
297
+ value: [
298
+ 95,
299
+ 95,
300
+ 101,
301
+ 118,
302
+ 101,
303
+ 110,
304
+ 116,
305
+ 95,
306
+ 97,
307
+ 117,
308
+ 116,
309
+ 104,
310
+ 111,
311
+ 114,
312
+ 105,
313
+ 116,
314
+ 121
315
+ ]
316
+ }
317
+ ]
318
+ }
319
+ },
320
+ {
321
+ name: "program"
322
+ }
323
+ ],
324
+ args: [
325
+ {
326
+ name: "sol_amount",
327
+ type: "u64"
328
+ },
329
+ {
330
+ name: "min_tokens_out",
331
+ type: "u64"
332
+ }
333
+ ]
334
+ },
335
+ {
336
+ name: "claim_accrued",
337
+ docs: [
338
+ "Claim accrued tokens",
339
+ "Transfers tokens that have accrued from vaulted to tradable from vault to wallet"
340
+ ],
341
+ discriminator: [
342
+ 209,
343
+ 92,
344
+ 30,
345
+ 216,
346
+ 89,
347
+ 249,
348
+ 122,
349
+ 243
350
+ ],
351
+ accounts: [
352
+ {
353
+ name: "owner",
354
+ signer: true
355
+ },
356
+ {
357
+ name: "pool_state",
358
+ writable: true,
359
+ pda: {
360
+ seeds: [
361
+ {
362
+ kind: "const",
363
+ value: [
364
+ 112,
365
+ 111,
366
+ 111,
367
+ 108
368
+ ]
369
+ },
370
+ {
371
+ kind: "account",
372
+ path: "pool_state.mint",
373
+ account: "PoolState"
374
+ }
375
+ ]
376
+ }
377
+ },
378
+ {
379
+ name: "position",
380
+ writable: true,
381
+ pda: {
382
+ seeds: [
383
+ {
384
+ kind: "const",
385
+ value: [
386
+ 112,
387
+ 111,
388
+ 115,
389
+ 105,
390
+ 116,
391
+ 105,
392
+ 111,
393
+ 110
394
+ ]
395
+ },
396
+ {
397
+ kind: "account",
398
+ path: "pool_state"
399
+ },
400
+ {
401
+ kind: "account",
402
+ path: "owner"
403
+ }
404
+ ]
405
+ }
406
+ },
407
+ {
408
+ name: "token_vault",
409
+ writable: true
410
+ },
411
+ {
412
+ name: "vault_authority",
413
+ pda: {
414
+ seeds: [
415
+ {
416
+ kind: "const",
417
+ value: [
418
+ 118,
419
+ 97,
420
+ 117,
421
+ 108,
422
+ 116,
423
+ 95,
424
+ 97,
425
+ 117,
426
+ 116,
427
+ 104,
428
+ 111,
429
+ 114,
430
+ 105,
431
+ 116,
432
+ 121
433
+ ]
434
+ },
435
+ {
436
+ kind: "account",
437
+ path: "pool_state"
438
+ }
439
+ ]
440
+ }
441
+ },
442
+ {
443
+ name: "user_token_account",
444
+ writable: true
445
+ },
446
+ {
447
+ name: "token_program",
448
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
449
+ },
450
+ {
451
+ name: "event_authority",
452
+ pda: {
453
+ seeds: [
454
+ {
455
+ kind: "const",
456
+ value: [
457
+ 95,
458
+ 95,
459
+ 101,
460
+ 118,
461
+ 101,
462
+ 110,
463
+ 116,
464
+ 95,
465
+ 97,
466
+ 117,
467
+ 116,
468
+ 104,
469
+ 111,
470
+ 114,
471
+ 105,
472
+ 116,
473
+ 121
474
+ ]
475
+ }
476
+ ]
477
+ }
478
+ },
479
+ {
480
+ name: "program"
481
+ }
482
+ ],
483
+ args: []
484
+ },
485
+ {
486
+ name: "close_position",
487
+ docs: [
488
+ "Close an empty position account and reclaim rent"
489
+ ],
490
+ discriminator: [
491
+ 123,
492
+ 134,
493
+ 81,
494
+ 0,
495
+ 49,
496
+ 68,
497
+ 98,
498
+ 98
499
+ ],
500
+ accounts: [
501
+ {
502
+ name: "owner",
503
+ writable: true,
504
+ signer: true
505
+ },
506
+ {
507
+ name: "pool_state",
508
+ writable: true
509
+ },
510
+ {
511
+ name: "position",
512
+ writable: true,
513
+ pda: {
514
+ seeds: [
515
+ {
516
+ kind: "const",
517
+ value: [
518
+ 112,
519
+ 111,
520
+ 115,
521
+ 105,
522
+ 116,
523
+ 105,
524
+ 111,
525
+ 110
526
+ ]
527
+ },
528
+ {
529
+ kind: "account",
530
+ path: "pool_state"
531
+ },
532
+ {
533
+ kind: "account",
534
+ path: "owner"
535
+ }
536
+ ]
537
+ }
538
+ },
539
+ {
540
+ name: "user_token_account",
541
+ writable: true
542
+ },
543
+ {
544
+ name: "mint"
545
+ },
546
+ {
547
+ name: "token_program",
548
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
549
+ },
550
+ {
551
+ name: "system_program",
552
+ address: "11111111111111111111111111111111"
553
+ },
554
+ {
555
+ name: "event_authority",
556
+ pda: {
557
+ seeds: [
558
+ {
559
+ kind: "const",
560
+ value: [
561
+ 95,
562
+ 95,
563
+ 101,
564
+ 118,
565
+ 101,
566
+ 110,
567
+ 116,
568
+ 95,
569
+ 97,
570
+ 117,
571
+ 116,
572
+ 104,
573
+ 111,
574
+ 114,
575
+ 105,
576
+ 116,
577
+ 121
578
+ ]
579
+ }
580
+ ]
581
+ }
582
+ },
583
+ {
584
+ name: "program"
585
+ }
586
+ ],
587
+ args: []
588
+ },
589
+ {
590
+ name: "create_token",
591
+ docs: [
592
+ "Create a new token and initialize vAMM pool"
593
+ ],
594
+ discriminator: [
595
+ 84,
596
+ 52,
597
+ 204,
598
+ 228,
599
+ 24,
600
+ 140,
601
+ 234,
602
+ 75
603
+ ],
604
+ accounts: [
605
+ {
606
+ name: "creator",
607
+ writable: true,
608
+ signer: true
609
+ },
610
+ {
611
+ name: "protocol_authority"
612
+ },
613
+ {
614
+ name: "mint",
615
+ writable: true,
616
+ signer: true
617
+ },
618
+ {
619
+ name: "pool_state",
620
+ writable: true,
621
+ pda: {
622
+ seeds: [
623
+ {
624
+ kind: "const",
625
+ value: [
626
+ 112,
627
+ 111,
628
+ 111,
629
+ 108
630
+ ]
631
+ },
632
+ {
633
+ kind: "account",
634
+ path: "mint"
635
+ }
636
+ ]
637
+ }
638
+ },
639
+ {
640
+ name: "token_vault",
641
+ writable: true
642
+ },
643
+ {
644
+ name: "vault_authority",
645
+ pda: {
646
+ seeds: [
647
+ {
648
+ kind: "const",
649
+ value: [
650
+ 118,
651
+ 97,
652
+ 117,
653
+ 108,
654
+ 116,
655
+ 95,
656
+ 97,
657
+ 117,
658
+ 116,
659
+ 104,
660
+ 111,
661
+ 114,
662
+ 105,
663
+ 116,
664
+ 121
665
+ ]
666
+ },
667
+ {
668
+ kind: "account",
669
+ path: "pool_state"
670
+ }
671
+ ]
672
+ }
673
+ },
674
+ {
675
+ name: "metadata",
676
+ writable: true
677
+ },
678
+ {
679
+ name: "pool_sol_account",
680
+ writable: true
681
+ },
682
+ {
683
+ name: "protocol_fee_wallet",
684
+ writable: true,
685
+ pda: {
686
+ seeds: [
687
+ {
688
+ kind: "const",
689
+ value: [
690
+ 112,
691
+ 114,
692
+ 111,
693
+ 116,
694
+ 111,
695
+ 99,
696
+ 111,
697
+ 108,
698
+ 95,
699
+ 102,
700
+ 101,
701
+ 101,
702
+ 115
703
+ ]
704
+ }
705
+ ]
706
+ }
707
+ },
708
+ {
709
+ name: "token_program",
710
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
711
+ },
712
+ {
713
+ name: "associated_token_program",
714
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
715
+ },
716
+ {
717
+ name: "system_program",
718
+ address: "11111111111111111111111111111111"
719
+ },
720
+ {
721
+ name: "rent",
722
+ address: "SysvarRent111111111111111111111111111111111"
723
+ },
724
+ {
725
+ name: "metadata_program"
726
+ },
727
+ {
728
+ name: "sysvar_instructions"
729
+ },
730
+ {
731
+ name: "event_authority",
732
+ pda: {
733
+ seeds: [
734
+ {
735
+ kind: "const",
736
+ value: [
737
+ 95,
738
+ 95,
739
+ 101,
740
+ 118,
741
+ 101,
742
+ 110,
743
+ 116,
744
+ 95,
745
+ 97,
746
+ 117,
747
+ 116,
748
+ 104,
749
+ 111,
750
+ 114,
751
+ 105,
752
+ 116,
753
+ 121
754
+ ]
755
+ }
756
+ ]
757
+ }
758
+ },
759
+ {
760
+ name: "program"
761
+ }
762
+ ],
763
+ args: [
764
+ {
765
+ name: "name",
766
+ type: "string"
767
+ },
768
+ {
769
+ name: "symbol",
770
+ type: "string"
771
+ },
772
+ {
773
+ name: "uri",
774
+ type: "string"
775
+ },
776
+ {
777
+ name: "pool_description",
778
+ type: "string"
779
+ },
780
+ {
781
+ name: "vest_duration",
782
+ type: "i64"
783
+ }
784
+ ]
785
+ },
786
+ {
787
+ name: "emergency_withdraw_sol",
788
+ docs: [
789
+ "Emergency withdraw SOL from a pool's sol_vault"
790
+ ],
791
+ discriminator: [
792
+ 219,
793
+ 156,
794
+ 123,
795
+ 176,
796
+ 91,
797
+ 105,
798
+ 30,
799
+ 160
800
+ ],
801
+ accounts: [
802
+ {
803
+ name: "authority",
804
+ writable: true,
805
+ signer: true
806
+ },
807
+ {
808
+ name: "pool_state"
809
+ },
810
+ {
811
+ name: "sol_vault",
812
+ writable: true,
813
+ pda: {
814
+ seeds: [
815
+ {
816
+ kind: "const",
817
+ value: [
818
+ 115,
819
+ 111,
820
+ 108,
821
+ 95,
822
+ 118,
823
+ 97,
824
+ 117,
825
+ 108,
826
+ 116
827
+ ]
828
+ },
829
+ {
830
+ kind: "account",
831
+ path: "pool_state"
832
+ }
833
+ ]
834
+ }
835
+ },
836
+ {
837
+ name: "system_program",
838
+ address: "11111111111111111111111111111111"
839
+ }
840
+ ],
841
+ args: [
842
+ {
843
+ name: "amount",
844
+ type: "u64"
845
+ }
846
+ ]
847
+ },
848
+ {
849
+ name: "sell",
850
+ docs: [
851
+ "Sell tokens back to the vAMM",
852
+ "If sell_percentage is provided, it overrides token_amount"
853
+ ],
854
+ discriminator: [
855
+ 51,
856
+ 230,
857
+ 133,
858
+ 164,
859
+ 1,
860
+ 127,
861
+ 131,
862
+ 173
863
+ ],
864
+ accounts: [
865
+ {
866
+ name: "seller",
867
+ writable: true,
868
+ signer: true
869
+ },
870
+ {
871
+ name: "pool_state",
872
+ writable: true,
873
+ pda: {
874
+ seeds: [
875
+ {
876
+ kind: "const",
877
+ value: [
878
+ 112,
879
+ 111,
880
+ 111,
881
+ 108
882
+ ]
883
+ },
884
+ {
885
+ kind: "account",
886
+ path: "mint"
887
+ }
888
+ ]
889
+ }
890
+ },
891
+ {
892
+ name: "position",
893
+ writable: true,
894
+ pda: {
895
+ seeds: [
896
+ {
897
+ kind: "const",
898
+ value: [
899
+ 112,
900
+ 111,
901
+ 115,
902
+ 105,
903
+ 116,
904
+ 105,
905
+ 111,
906
+ 110
907
+ ]
908
+ },
909
+ {
910
+ kind: "account",
911
+ path: "pool_state"
912
+ },
913
+ {
914
+ kind: "account",
915
+ path: "seller"
916
+ }
917
+ ]
918
+ }
919
+ },
920
+ {
921
+ name: "token_vault",
922
+ writable: true
923
+ },
924
+ {
925
+ name: "vault_authority",
926
+ pda: {
927
+ seeds: [
928
+ {
929
+ kind: "const",
930
+ value: [
931
+ 118,
932
+ 97,
933
+ 117,
934
+ 108,
935
+ 116,
936
+ 95,
937
+ 97,
938
+ 117,
939
+ 116,
940
+ 104,
941
+ 111,
942
+ 114,
943
+ 105,
944
+ 116,
945
+ 121
946
+ ]
947
+ },
948
+ {
949
+ kind: "account",
950
+ path: "pool_state"
951
+ }
952
+ ]
953
+ }
954
+ },
955
+ {
956
+ name: "seller_token_account",
957
+ writable: true
958
+ },
959
+ {
960
+ name: "pool_sol_account",
961
+ writable: true,
962
+ pda: {
963
+ seeds: [
964
+ {
965
+ kind: "const",
966
+ value: [
967
+ 115,
968
+ 111,
969
+ 108,
970
+ 95,
971
+ 118,
972
+ 97,
973
+ 117,
974
+ 108,
975
+ 116
976
+ ]
977
+ },
978
+ {
979
+ kind: "account",
980
+ path: "pool_state"
981
+ }
982
+ ]
983
+ }
984
+ },
985
+ {
986
+ name: "mint"
987
+ },
988
+ {
989
+ name: "token_program",
990
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
991
+ },
992
+ {
993
+ name: "system_program",
994
+ address: "11111111111111111111111111111111"
995
+ },
996
+ {
997
+ name: "event_authority",
998
+ pda: {
999
+ seeds: [
1000
+ {
1001
+ kind: "const",
1002
+ value: [
1003
+ 95,
1004
+ 95,
1005
+ 101,
1006
+ 118,
1007
+ 101,
1008
+ 110,
1009
+ 116,
1010
+ 95,
1011
+ 97,
1012
+ 117,
1013
+ 116,
1014
+ 104,
1015
+ 111,
1016
+ 114,
1017
+ 105,
1018
+ 116,
1019
+ 121
1020
+ ]
1021
+ }
1022
+ ]
1023
+ }
1024
+ },
1025
+ {
1026
+ name: "program"
1027
+ }
1028
+ ],
1029
+ args: [
1030
+ {
1031
+ name: "token_amount",
1032
+ type: "u64"
1033
+ },
1034
+ {
1035
+ name: "min_sol_out",
1036
+ type: "u64"
1037
+ },
1038
+ {
1039
+ name: "sell_percentage",
1040
+ type: {
1041
+ option: "u8"
1042
+ }
1043
+ }
1044
+ ]
1045
+ },
1046
+ {
1047
+ name: "withdraw_protocol_fees",
1048
+ docs: [
1049
+ "Withdraw accumulated protocol fees"
1050
+ ],
1051
+ discriminator: [
1052
+ 11,
1053
+ 68,
1054
+ 165,
1055
+ 98,
1056
+ 18,
1057
+ 208,
1058
+ 134,
1059
+ 73
1060
+ ],
1061
+ accounts: [
1062
+ {
1063
+ name: "authority",
1064
+ writable: true,
1065
+ signer: true
1066
+ },
1067
+ {
1068
+ name: "protocol_fee_wallet",
1069
+ writable: true,
1070
+ pda: {
1071
+ seeds: [
1072
+ {
1073
+ kind: "const",
1074
+ value: [
1075
+ 112,
1076
+ 114,
1077
+ 111,
1078
+ 116,
1079
+ 111,
1080
+ 99,
1081
+ 111,
1082
+ 108,
1083
+ 95,
1084
+ 102,
1085
+ 101,
1086
+ 101,
1087
+ 115
1088
+ ]
1089
+ }
1090
+ ]
1091
+ }
1092
+ },
1093
+ {
1094
+ name: "system_program",
1095
+ address: "11111111111111111111111111111111"
1096
+ }
1097
+ ],
1098
+ args: [
1099
+ {
1100
+ name: "amount",
1101
+ type: "u64"
1102
+ }
1103
+ ]
1104
+ }
1105
+ ],
1106
+ accounts: [
1107
+ {
1108
+ name: "PoolState",
1109
+ discriminator: [
1110
+ 247,
1111
+ 237,
1112
+ 227,
1113
+ 245,
1114
+ 215,
1115
+ 195,
1116
+ 222,
1117
+ 70
1118
+ ]
1119
+ },
1120
+ {
1121
+ name: "Position",
1122
+ discriminator: [
1123
+ 170,
1124
+ 188,
1125
+ 143,
1126
+ 228,
1127
+ 122,
1128
+ 64,
1129
+ 247,
1130
+ 208
1131
+ ]
1132
+ }
1133
+ ],
1134
+ events: [
1135
+ {
1136
+ name: "AccrualClaimed",
1137
+ discriminator: [
1138
+ 86,
1139
+ 99,
1140
+ 51,
1141
+ 211,
1142
+ 226,
1143
+ 48,
1144
+ 235,
1145
+ 238
1146
+ ]
1147
+ },
1148
+ {
1149
+ name: "PositionClosed",
1150
+ discriminator: [
1151
+ 157,
1152
+ 163,
1153
+ 227,
1154
+ 228,
1155
+ 13,
1156
+ 97,
1157
+ 138,
1158
+ 121
1159
+ ]
1160
+ },
1161
+ {
1162
+ name: "TokenCreated",
1163
+ discriminator: [
1164
+ 236,
1165
+ 19,
1166
+ 41,
1167
+ 255,
1168
+ 130,
1169
+ 78,
1170
+ 147,
1171
+ 172
1172
+ ]
1173
+ },
1174
+ {
1175
+ name: "TokenPurchased",
1176
+ discriminator: [
1177
+ 3,
1178
+ 73,
1179
+ 186,
1180
+ 50,
1181
+ 15,
1182
+ 181,
1183
+ 213,
1184
+ 37
1185
+ ]
1186
+ },
1187
+ {
1188
+ name: "TokenSold",
1189
+ discriminator: [
1190
+ 88,
1191
+ 61,
1192
+ 1,
1193
+ 247,
1194
+ 185,
1195
+ 6,
1196
+ 252,
1197
+ 86
1198
+ ]
1199
+ }
1200
+ ],
1201
+ errors: [
1202
+ {
1203
+ code: 7005,
1204
+ name: "InsufficientTokens",
1205
+ msg: "Insufficient token reserves in vault"
1206
+ },
1207
+ {
1208
+ code: 7100,
1209
+ name: "ArithmeticOverflow",
1210
+ msg: "Arithmetic overflow"
1211
+ },
1212
+ {
1213
+ code: 7102,
1214
+ name: "DivisionError",
1215
+ msg: "Division by zero or invalid division"
1216
+ },
1217
+ {
1218
+ code: 7104,
1219
+ name: "TokenOverflow",
1220
+ msg: "Token calculation overflow"
1221
+ },
1222
+ {
1223
+ code: 7105,
1224
+ name: "TokenUnderflow",
1225
+ msg: "Token calculation underflow"
1226
+ },
1227
+ {
1228
+ code: 7200,
1229
+ name: "SlippageExceeded",
1230
+ msg: "Slippage exceeded: output below minimum threshold"
1231
+ },
1232
+ {
1233
+ code: 7312,
1234
+ name: "AccrualCalculationOverflow",
1235
+ msg: "Accrual calculation overflow"
1236
+ },
1237
+ {
1238
+ code: 7315,
1239
+ name: "PositionNotEmpty",
1240
+ msg: "Position is not empty, must sell all tokens first"
1241
+ },
1242
+ {
1243
+ code: 7319,
1244
+ name: "InvalidProtocolAuthority",
1245
+ msg: "Invalid protocol authority - must match PROTOCOL_AUTHORITY constant"
1246
+ },
1247
+ {
1248
+ code: 7321,
1249
+ name: "MustHaveUnlockedPortion",
1250
+ msg: "Position must have tokens to perform this operation"
1251
+ },
1252
+ {
1253
+ code: 7500,
1254
+ name: "PositionNotOwnedBySigner",
1255
+ msg: "Position not owned by signer"
1256
+ },
1257
+ {
1258
+ code: 7505,
1259
+ name: "InvalidSolVaultPDA",
1260
+ msg: "SOL vault PDA derivation mismatch"
1261
+ },
1262
+ {
1263
+ code: 7601,
1264
+ name: "InvalidVestingType",
1265
+ msg: "Invalid vesting type"
1266
+ },
1267
+ {
1268
+ code: 7604,
1269
+ name: "InvalidPercentage",
1270
+ msg: "Invalid percentage value (must be 0-100)"
1271
+ },
1272
+ {
1273
+ code: 7901,
1274
+ name: "NotAuthorized",
1275
+ msg: "Not authorized"
1276
+ },
1277
+ {
1278
+ code: 8014,
1279
+ name: "InsufficientLiquidity",
1280
+ msg: "Insufficient liquidity"
1281
+ },
1282
+ {
1283
+ code: 8018,
1284
+ name: "VammNotActive",
1285
+ msg: "vAMM is not active"
1286
+ },
1287
+ {
1288
+ code: 8020,
1289
+ name: "InvalidAmount",
1290
+ msg: "Invalid amount"
1291
+ }
1292
+ ],
1293
+ types: [
1294
+ {
1295
+ name: "AccrualClaimed",
1296
+ docs: [
1297
+ "Event emitted when accrued tokens are claimed"
1298
+ ],
1299
+ type: {
1300
+ kind: "struct",
1301
+ fields: [
1302
+ {
1303
+ name: "owner",
1304
+ type: "pubkey"
1305
+ },
1306
+ {
1307
+ name: "pool",
1308
+ type: "pubkey"
1309
+ },
1310
+ {
1311
+ name: "position",
1312
+ type: "pubkey"
1313
+ },
1314
+ {
1315
+ name: "tokens_claimed",
1316
+ type: "u64"
1317
+ },
1318
+ {
1319
+ name: "new_tradable_tokens",
1320
+ type: "u64"
1321
+ },
1322
+ {
1323
+ name: "remaining_vaulted_tokens",
1324
+ type: "u64"
1325
+ },
1326
+ {
1327
+ name: "tokens_transferred",
1328
+ type: "u64"
1329
+ },
1330
+ {
1331
+ name: "initial_vaulted",
1332
+ type: "u64"
1333
+ },
1334
+ {
1335
+ name: "timestamp",
1336
+ type: "i64"
1337
+ }
1338
+ ]
1339
+ }
1340
+ },
1341
+ {
1342
+ name: "PoolMetadata",
1343
+ type: {
1344
+ kind: "struct",
1345
+ fields: [
1346
+ {
1347
+ name: "name",
1348
+ docs: [
1349
+ "Optional pool name"
1350
+ ],
1351
+ type: "string"
1352
+ },
1353
+ {
1354
+ name: "description",
1355
+ docs: [
1356
+ "Optional pool description"
1357
+ ],
1358
+ type: "string"
1359
+ },
1360
+ {
1361
+ name: "version",
1362
+ docs: [
1363
+ "Pool version"
1364
+ ],
1365
+ type: "u8"
1366
+ }
1367
+ ]
1368
+ }
1369
+ },
1370
+ {
1371
+ name: "PoolState",
1372
+ docs: [
1373
+ "Pool state account - main state for a vAMM pool"
1374
+ ],
1375
+ type: {
1376
+ kind: "struct",
1377
+ fields: [
1378
+ {
1379
+ name: "authority",
1380
+ docs: [
1381
+ "Pool authority (creator)"
1382
+ ],
1383
+ type: "pubkey"
1384
+ },
1385
+ {
1386
+ name: "mint",
1387
+ docs: [
1388
+ "Token mint for this pool"
1389
+ ],
1390
+ type: "pubkey"
1391
+ },
1392
+ {
1393
+ name: "token_vault",
1394
+ docs: [
1395
+ "Token vault (holds unsold tokens)"
1396
+ ],
1397
+ type: "pubkey"
1398
+ },
1399
+ {
1400
+ name: "vault_authority",
1401
+ docs: [
1402
+ "Vault authority (PDA)"
1403
+ ],
1404
+ type: "pubkey"
1405
+ },
1406
+ {
1407
+ name: "sol_vault",
1408
+ docs: [
1409
+ "Pool SOL vault (holds raised SOL)"
1410
+ ],
1411
+ type: "pubkey"
1412
+ },
1413
+ {
1414
+ name: "total_positions",
1415
+ docs: [
1416
+ "Total number of positions in this pool"
1417
+ ],
1418
+ type: "u64"
1419
+ },
1420
+ {
1421
+ name: "creation_timestamp",
1422
+ docs: [
1423
+ "Pool creation timestamp (Unix timestamp)"
1424
+ ],
1425
+ type: "i64"
1426
+ },
1427
+ {
1428
+ name: "last_update_timestamp",
1429
+ docs: [
1430
+ "Last update timestamp (Unix timestamp)"
1431
+ ],
1432
+ type: "i64"
1433
+ },
1434
+ {
1435
+ name: "metadata",
1436
+ docs: [
1437
+ "Pool metadata"
1438
+ ],
1439
+ type: {
1440
+ defined: {
1441
+ name: "PoolMetadata"
1442
+ }
1443
+ }
1444
+ },
1445
+ {
1446
+ name: "vest_duration",
1447
+ docs: [
1448
+ "=== ACCRUAL SYSTEM FIELDS ===",
1449
+ "Dev-set unlock duration in seconds (applies to all traders)"
1450
+ ],
1451
+ type: "i64"
1452
+ },
1453
+ {
1454
+ name: "next_position_number",
1455
+ docs: [
1456
+ "Next position number to assign (sequential counter for display/identity)"
1457
+ ],
1458
+ type: "u64"
1459
+ },
1460
+ {
1461
+ name: "vamm_active",
1462
+ docs: [
1463
+ "=== VAMM STATE ===",
1464
+ "vAMM is active for trading"
1465
+ ],
1466
+ type: "bool"
1467
+ },
1468
+ {
1469
+ name: "vamm_real_sol",
1470
+ docs: [
1471
+ "Real SOL in the vAMM"
1472
+ ],
1473
+ type: "u64"
1474
+ },
1475
+ {
1476
+ name: "vamm_tokens",
1477
+ docs: [
1478
+ "Real tokens in the vAMM"
1479
+ ],
1480
+ type: "u64"
1481
+ },
1482
+ {
1483
+ name: "vamm_k",
1484
+ docs: [
1485
+ "The invariant k (set at creation, never changes)",
1486
+ "k = (vamm_real_sol + VIRTUAL_SOL) * vamm_tokens"
1487
+ ],
1488
+ type: "u128"
1489
+ },
1490
+ {
1491
+ name: "tokens_sold",
1492
+ docs: [
1493
+ "Cumulative tokens bought from vAMM (increases on buy, decreases on sell)"
1494
+ ],
1495
+ type: "u64"
1496
+ },
1497
+ {
1498
+ name: "tokens_reserved_for_claims",
1499
+ docs: [
1500
+ "Vault tokens reserved for position claims (not available for vAMM liquidity)",
1501
+ "Incremented on buy (vaulted portion), decremented on claim_accrued"
1502
+ ],
1503
+ type: "u64"
1504
+ },
1505
+ {
1506
+ name: "bump_vault_auth",
1507
+ docs: [
1508
+ "Bump seeds for PDAs"
1509
+ ],
1510
+ type: "u8"
1511
+ },
1512
+ {
1513
+ name: "bump_pool",
1514
+ type: "u8"
1515
+ }
1516
+ ]
1517
+ }
1518
+ },
1519
+ {
1520
+ name: "Position",
1521
+ docs: [
1522
+ "Position in a vAMM pool",
1523
+ "Tokens split into tradable (immediate) and vaulted (accrue linearly over vest_duration)"
1524
+ ],
1525
+ type: {
1526
+ kind: "struct",
1527
+ fields: [
1528
+ {
1529
+ name: "owner",
1530
+ docs: [
1531
+ "Owner's public key"
1532
+ ],
1533
+ type: {
1534
+ array: [
1535
+ "u8",
1536
+ 32
1537
+ ]
1538
+ }
1539
+ },
1540
+ {
1541
+ name: "pool",
1542
+ docs: [
1543
+ "Pool this position belongs to"
1544
+ ],
1545
+ type: {
1546
+ array: [
1547
+ "u8",
1548
+ 32
1549
+ ]
1550
+ }
1551
+ },
1552
+ {
1553
+ name: "tradable_tokens",
1554
+ docs: [
1555
+ "Tradable tokens (can be sold immediately)"
1556
+ ],
1557
+ type: "u64"
1558
+ },
1559
+ {
1560
+ name: "vaulted_tokens",
1561
+ docs: [
1562
+ "Vaulted tokens (accruing linearly to tradable)"
1563
+ ],
1564
+ type: "u64"
1565
+ },
1566
+ {
1567
+ name: "sol_spent",
1568
+ docs: [
1569
+ "SOL spent on this position"
1570
+ ],
1571
+ type: "u64"
1572
+ },
1573
+ {
1574
+ name: "tokens_transferred",
1575
+ docs: [
1576
+ "Cumulative tokens transferred to wallet (for claim_accrued tracking)"
1577
+ ],
1578
+ type: "u64"
1579
+ },
1580
+ {
1581
+ name: "entry_timestamp",
1582
+ docs: [
1583
+ "Entry timestamp (for accrual calculation)"
1584
+ ],
1585
+ type: "i64"
1586
+ },
1587
+ {
1588
+ name: "initial_vaulted",
1589
+ docs: [
1590
+ "Cumulative initial vaulted tokens from all buys (for accrual calculation)",
1591
+ "This tracks the total vaulted amount at buy time, used to calculate accrual progress"
1592
+ ],
1593
+ type: "u64"
1594
+ },
1595
+ {
1596
+ name: "position_number",
1597
+ docs: [
1598
+ "Position number in the pool (sequential counter for display/identity)"
1599
+ ],
1600
+ type: "u64"
1601
+ },
1602
+ {
1603
+ name: "last_update_timestamp",
1604
+ docs: [
1605
+ "Last update timestamp"
1606
+ ],
1607
+ type: "i64"
1608
+ }
1609
+ ]
1610
+ }
1611
+ },
1612
+ {
1613
+ name: "PositionClosed",
1614
+ docs: [
1615
+ "Event emitted when a position account is closed"
1616
+ ],
1617
+ type: {
1618
+ kind: "struct",
1619
+ fields: [
1620
+ {
1621
+ name: "owner",
1622
+ type: "pubkey"
1623
+ },
1624
+ {
1625
+ name: "pool",
1626
+ type: "pubkey"
1627
+ },
1628
+ {
1629
+ name: "position",
1630
+ type: "pubkey"
1631
+ },
1632
+ {
1633
+ name: "rent_reclaimed",
1634
+ type: "u64"
1635
+ },
1636
+ {
1637
+ name: "timestamp",
1638
+ type: "i64"
1639
+ }
1640
+ ]
1641
+ }
1642
+ },
1643
+ {
1644
+ name: "TokenCreated",
1645
+ docs: [
1646
+ "Event emitted when a new token and vAMM pool is created"
1647
+ ],
1648
+ type: {
1649
+ kind: "struct",
1650
+ fields: [
1651
+ {
1652
+ name: "mint",
1653
+ type: "pubkey"
1654
+ },
1655
+ {
1656
+ name: "pool",
1657
+ type: "pubkey"
1658
+ },
1659
+ {
1660
+ name: "creator",
1661
+ type: "pubkey"
1662
+ },
1663
+ {
1664
+ name: "name",
1665
+ type: "string"
1666
+ },
1667
+ {
1668
+ name: "symbol",
1669
+ type: "string"
1670
+ },
1671
+ {
1672
+ name: "total_supply",
1673
+ type: "u64"
1674
+ },
1675
+ {
1676
+ name: "initial_k",
1677
+ type: "u128"
1678
+ },
1679
+ {
1680
+ name: "vamm_tokens",
1681
+ type: "u64"
1682
+ },
1683
+ {
1684
+ name: "vest_duration",
1685
+ type: "i64"
1686
+ },
1687
+ {
1688
+ name: "creation_timestamp",
1689
+ type: "i64"
1690
+ }
1691
+ ]
1692
+ }
1693
+ },
1694
+ {
1695
+ name: "TokenPurchased",
1696
+ docs: [
1697
+ "Event emitted when tokens are bought"
1698
+ ],
1699
+ type: {
1700
+ kind: "struct",
1701
+ fields: [
1702
+ {
1703
+ name: "buyer",
1704
+ type: "pubkey"
1705
+ },
1706
+ {
1707
+ name: "pool",
1708
+ type: "pubkey"
1709
+ },
1710
+ {
1711
+ name: "mint",
1712
+ type: "pubkey"
1713
+ },
1714
+ {
1715
+ name: "sol_amount",
1716
+ type: "u64"
1717
+ },
1718
+ {
1719
+ name: "tokens_received",
1720
+ type: "u64"
1721
+ },
1722
+ {
1723
+ name: "vamm_real_sol",
1724
+ type: "u64"
1725
+ },
1726
+ {
1727
+ name: "vamm_tokens",
1728
+ type: "u64"
1729
+ },
1730
+ {
1731
+ name: "tokens_sold",
1732
+ type: "u64"
1733
+ },
1734
+ {
1735
+ name: "position",
1736
+ type: "pubkey"
1737
+ },
1738
+ {
1739
+ name: "position_number",
1740
+ type: "u64"
1741
+ },
1742
+ {
1743
+ name: "vest_duration",
1744
+ type: "i64"
1745
+ },
1746
+ {
1747
+ name: "unlock_time_seconds",
1748
+ type: "i64"
1749
+ },
1750
+ {
1751
+ name: "tradable_tokens",
1752
+ docs: [
1753
+ "Position state after buy"
1754
+ ],
1755
+ type: "u64"
1756
+ },
1757
+ {
1758
+ name: "vaulted_tokens",
1759
+ type: "u64"
1760
+ },
1761
+ {
1762
+ name: "sol_spent",
1763
+ type: "u64"
1764
+ },
1765
+ {
1766
+ name: "tokens_transferred",
1767
+ type: "u64"
1768
+ },
1769
+ {
1770
+ name: "initial_vaulted",
1771
+ type: "u64"
1772
+ },
1773
+ {
1774
+ name: "timestamp",
1775
+ type: "i64"
1776
+ }
1777
+ ]
1778
+ }
1779
+ },
1780
+ {
1781
+ name: "TokenSold",
1782
+ docs: [
1783
+ "Event emitted when tokens are sold"
1784
+ ],
1785
+ type: {
1786
+ kind: "struct",
1787
+ fields: [
1788
+ {
1789
+ name: "seller",
1790
+ type: "pubkey"
1791
+ },
1792
+ {
1793
+ name: "pool",
1794
+ type: "pubkey"
1795
+ },
1796
+ {
1797
+ name: "mint",
1798
+ type: "pubkey"
1799
+ },
1800
+ {
1801
+ name: "token_amount",
1802
+ type: "u64"
1803
+ },
1804
+ {
1805
+ name: "sol_received",
1806
+ type: "u64"
1807
+ },
1808
+ {
1809
+ name: "vamm_real_sol",
1810
+ type: "u64"
1811
+ },
1812
+ {
1813
+ name: "vamm_tokens",
1814
+ type: "u64"
1815
+ },
1816
+ {
1817
+ name: "tokens_sold",
1818
+ type: "u64"
1819
+ },
1820
+ {
1821
+ name: "position",
1822
+ type: "pubkey"
1823
+ },
1824
+ {
1825
+ name: "position_number",
1826
+ type: "u64"
1827
+ },
1828
+ {
1829
+ name: "vest_duration",
1830
+ type: "i64"
1831
+ },
1832
+ {
1833
+ name: "unlock_time_seconds",
1834
+ type: "i64"
1835
+ },
1836
+ {
1837
+ name: "tradable_tokens",
1838
+ docs: [
1839
+ "Position state after sell"
1840
+ ],
1841
+ type: "u64"
1842
+ },
1843
+ {
1844
+ name: "vaulted_tokens",
1845
+ type: "u64"
1846
+ },
1847
+ {
1848
+ name: "sol_spent",
1849
+ type: "u64"
1850
+ },
1851
+ {
1852
+ name: "tokens_transferred",
1853
+ type: "u64"
1854
+ },
1855
+ {
1856
+ name: "initial_vaulted",
1857
+ type: "u64"
1858
+ },
1859
+ {
1860
+ name: "timestamp",
1861
+ type: "i64"
1862
+ }
1863
+ ]
1864
+ }
1865
+ }
1866
+ ]
1867
+ };
1868
+
1869
+ // src/program.ts
1870
+ var DUMMY_WALLET = {
1871
+ publicKey: PublicKey.default,
1872
+ signTransaction: async (tx) => tx,
1873
+ signAllTransactions: async (txs) => txs
1874
+ };
1875
+ function getProgram(connection) {
1876
+ const provider = new AnchorProvider(connection, DUMMY_WALLET, { commitment: "confirmed" });
1877
+ return new Program(hodl_default, provider);
1878
+ }
1879
+
1880
+ // src/instructions.ts
1881
+ var METADATA_PROGRAM_ID = new PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
1882
+ function getMetadataPDA(mint) {
1883
+ const [pda] = PublicKey.findProgramAddressSync(
1884
+ [Buffer.from("metadata"), METADATA_PROGRAM_ID.toBuffer(), mint.toBuffer()],
1885
+ METADATA_PROGRAM_ID
1886
+ );
1887
+ return pda;
1888
+ }
1889
+ async function buildBuyInstruction(params) {
1890
+ const { buyer, mint, solAmount, minTokensOut, connection, config } = params;
1891
+ const program = getProgram(connection);
1892
+ const [poolState] = getPoolStatePDA(mint, config.programId);
1893
+ const [vaultAuthority] = getVaultAuthorityPDA(poolState, config.programId);
1894
+ const tokenVault = getAssociatedTokenAddressSync(mint, vaultAuthority, true);
1895
+ const buyerTokenAccount = getAssociatedTokenAddressSync(mint, buyer);
1896
+ const [poolSolAccount] = getSolVaultPDA(poolState, config.programId);
1897
+ const [position] = getPositionPDA(poolState, buyer, config.programId);
1898
+ const [eventAuthority] = getEventAuthorityPDA(config.programId);
1899
+ return program.methods.buy(solAmount, minTokensOut).accountsPartial({
1900
+ buyer,
1901
+ poolState,
1902
+ tokenVault,
1903
+ vaultAuthority,
1904
+ buyerTokenAccount,
1905
+ poolSolAccount,
1906
+ mint,
1907
+ tokenProgram: TOKEN_PROGRAM_ID,
1908
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
1909
+ systemProgram: SystemProgram.programId,
1910
+ position,
1911
+ eventAuthority,
1912
+ program: config.programId
1913
+ }).instruction();
1914
+ }
1915
+ async function buildSellInstruction(params) {
1916
+ const { seller, mint, tokenAmount, minSolOut, sellPercentage, connection, config } = params;
1917
+ const program = getProgram(connection);
1918
+ const [poolState] = getPoolStatePDA(mint, config.programId);
1919
+ const [vaultAuthority] = getVaultAuthorityPDA(poolState, config.programId);
1920
+ const tokenVault = getAssociatedTokenAddressSync(mint, vaultAuthority, true);
1921
+ const sellerTokenAccount = getAssociatedTokenAddressSync(mint, seller);
1922
+ const [poolSolAccount] = getSolVaultPDA(poolState, config.programId);
1923
+ const [position] = getPositionPDA(poolState, seller, config.programId);
1924
+ const [eventAuthority] = getEventAuthorityPDA(config.programId);
1925
+ return program.methods.sell(tokenAmount, minSolOut, sellPercentage ?? null).accountsPartial({
1926
+ seller,
1927
+ poolState,
1928
+ position,
1929
+ tokenVault,
1930
+ vaultAuthority,
1931
+ sellerTokenAccount,
1932
+ poolSolAccount,
1933
+ mint,
1934
+ tokenProgram: TOKEN_PROGRAM_ID,
1935
+ systemProgram: SystemProgram.programId,
1936
+ eventAuthority,
1937
+ program: config.programId
1938
+ }).instruction();
1939
+ }
1940
+ async function buildCreateTokenInstruction(params) {
1941
+ const { creator, mint, name, symbol, uri, poolDescription, vestDuration, connection, config } = params;
1942
+ const program = getProgram(connection);
1943
+ const [poolState] = getPoolStatePDA(mint, config.programId);
1944
+ const [vaultAuthority] = getVaultAuthorityPDA(poolState, config.programId);
1945
+ const tokenVault = getAssociatedTokenAddressSync(mint, vaultAuthority, true);
1946
+ const metadata = getMetadataPDA(mint);
1947
+ const [poolSolAccount] = getSolVaultPDA(poolState, config.programId);
1948
+ const [protocolFeeWallet] = getProtocolFeesPDA(config.programId);
1949
+ const [eventAuthority] = getEventAuthorityPDA(config.programId);
1950
+ return program.methods.createToken(name, symbol, uri, poolDescription, vestDuration).accountsPartial({
1951
+ creator,
1952
+ protocolAuthority: config.protocolAuthority,
1953
+ mint,
1954
+ poolState,
1955
+ tokenVault,
1956
+ vaultAuthority,
1957
+ metadata,
1958
+ poolSolAccount,
1959
+ protocolFeeWallet,
1960
+ tokenProgram: TOKEN_PROGRAM_ID,
1961
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
1962
+ systemProgram: SystemProgram.programId,
1963
+ rent: SYSVAR_RENT_PUBKEY,
1964
+ metadataProgram: METADATA_PROGRAM_ID,
1965
+ sysvarInstructions: SYSVAR_INSTRUCTIONS_PUBKEY,
1966
+ eventAuthority,
1967
+ program: config.programId
1968
+ }).instruction();
1969
+ }
1970
+ async function buildClaimAccruedInstruction(params) {
1971
+ const { owner, poolState, connection, config } = params;
1972
+ const program = getProgram(connection);
1973
+ const poolData = await program.account.poolState.fetch(poolState);
1974
+ const mint = poolData.mint;
1975
+ const [vaultAuthority] = getVaultAuthorityPDA(poolState, config.programId);
1976
+ const tokenVault = getAssociatedTokenAddressSync(mint, vaultAuthority, true);
1977
+ const userTokenAccount = getAssociatedTokenAddressSync(mint, owner);
1978
+ const [position] = getPositionPDA(poolState, owner, config.programId);
1979
+ const [eventAuthority] = getEventAuthorityPDA(config.programId);
1980
+ return program.methods.claimAccrued().accountsPartial({
1981
+ owner,
1982
+ poolState,
1983
+ position,
1984
+ tokenVault,
1985
+ vaultAuthority,
1986
+ userTokenAccount,
1987
+ tokenProgram: TOKEN_PROGRAM_ID,
1988
+ eventAuthority,
1989
+ program: config.programId
1990
+ }).instruction();
1991
+ }
1992
+ async function buildClosePositionInstruction(params) {
1993
+ const { owner, poolState, mint, userTokenAccount, connection, config } = params;
1994
+ const program = getProgram(connection);
1995
+ const [position] = getPositionPDA(poolState, owner, config.programId);
1996
+ const [eventAuthority] = getEventAuthorityPDA(config.programId);
1997
+ return program.methods.closePosition().accountsPartial({
1998
+ owner,
1999
+ poolState,
2000
+ position,
2001
+ userTokenAccount,
2002
+ mint,
2003
+ tokenProgram: TOKEN_PROGRAM_ID,
2004
+ systemProgram: SystemProgram.programId,
2005
+ eventAuthority,
2006
+ program: config.programId
2007
+ }).instruction();
2008
+ }
2009
+
2010
+ export { buildBuyInstruction, buildClaimAccruedInstruction, buildClosePositionInstruction, buildCreateTokenInstruction, buildSellInstruction };
2011
+ //# sourceMappingURL=instructions.js.map
2012
+ //# sourceMappingURL=instructions.js.map