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