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