@wireio/stake 2.3.0 → 2.4.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 (30) hide show
  1. package/lib/stake.browser.js +1224 -71
  2. package/lib/stake.browser.js.map +1 -1
  3. package/lib/stake.d.ts +1150 -163
  4. package/lib/stake.js +1234 -71
  5. package/lib/stake.js.map +1 -1
  6. package/lib/stake.m.js +1224 -71
  7. package/lib/stake.m.js.map +1 -1
  8. package/package.json +1 -1
  9. package/src/assets/solana/devnet/idl/liqsol_core.json +472 -27
  10. package/src/assets/solana/devnet/idl/liqsol_token.json +34 -0
  11. package/src/assets/solana/devnet/idl/transfer_hook.json +34 -0
  12. package/src/assets/solana/devnet/types/liqsol_core.ts +472 -27
  13. package/src/assets/solana/devnet/types/liqsol_token.ts +34 -0
  14. package/src/assets/solana/devnet/types/transfer_hook.ts +34 -0
  15. package/src/assets/solana/mainnet/idl/liqsol_core.json +472 -27
  16. package/src/assets/solana/mainnet/idl/liqsol_token.json +34 -0
  17. package/src/assets/solana/mainnet/idl/transfer_hook.json +34 -0
  18. package/src/assets/solana/mainnet/types/liqsol_core.ts +472 -27
  19. package/src/assets/solana/mainnet/types/liqsol_token.ts +34 -0
  20. package/src/assets/solana/mainnet/types/transfer_hook.ts +34 -0
  21. package/src/networks/ethereum/ethereum.ts +9 -9
  22. package/src/networks/solana/clients/distribution.client.ts +114 -2
  23. package/src/networks/solana/clients/outpost.client.ts +2 -0
  24. package/src/networks/solana/clients/token.client.ts +2 -0
  25. package/src/networks/solana/constants.ts +3 -0
  26. package/src/networks/solana/program.ts +7 -0
  27. package/src/networks/solana/solana.ts +26 -1
  28. package/src/networks/solana/types.ts +3 -3
  29. package/src/networks/solana/utils.ts +7 -1
  30. package/src/types.ts +10 -1
@@ -67,6 +67,51 @@ var instructions$7 = [
67
67
  args: [
68
68
  ]
69
69
  },
70
+ {
71
+ name: "admin_force_unbond_role",
72
+ discriminator: [
73
+ 80,
74
+ 107,
75
+ 27,
76
+ 49,
77
+ 126,
78
+ 25,
79
+ 31,
80
+ 238
81
+ ],
82
+ accounts: [
83
+ {
84
+ name: "admin",
85
+ signer: true
86
+ },
87
+ {
88
+ name: "global_config"
89
+ },
90
+ {
91
+ name: "global_state"
92
+ },
93
+ {
94
+ name: "user",
95
+ docs: [
96
+ "The user whose role bond is being force-unbonded"
97
+ ]
98
+ },
99
+ {
100
+ name: "outpost_account",
101
+ writable: true
102
+ }
103
+ ],
104
+ args: [
105
+ {
106
+ name: "role",
107
+ type: {
108
+ defined: {
109
+ name: "Role"
110
+ }
111
+ }
112
+ }
113
+ ]
114
+ },
70
115
  {
71
116
  name: "aggregate_stake_metrics",
72
117
  docs: [
@@ -841,6 +886,72 @@ var instructions$7 = [
841
886
  }
842
887
  ]
843
888
  },
889
+ {
890
+ name: "deposit_to_reserve",
891
+ discriminator: [
892
+ 8,
893
+ 79,
894
+ 123,
895
+ 129,
896
+ 146,
897
+ 140,
898
+ 178,
899
+ 128
900
+ ],
901
+ accounts: [
902
+ {
903
+ name: "admin",
904
+ signer: true
905
+ },
906
+ {
907
+ name: "global_config"
908
+ },
909
+ {
910
+ name: "depositor",
911
+ writable: true,
912
+ signer: true
913
+ },
914
+ {
915
+ name: "reserve_pool",
916
+ writable: true
917
+ },
918
+ {
919
+ name: "vault"
920
+ },
921
+ {
922
+ name: "ephemeral_stake",
923
+ writable: true
924
+ },
925
+ {
926
+ name: "controller_state"
927
+ },
928
+ {
929
+ name: "stake_program"
930
+ },
931
+ {
932
+ name: "system_program"
933
+ },
934
+ {
935
+ name: "clock"
936
+ },
937
+ {
938
+ name: "stake_history"
939
+ },
940
+ {
941
+ name: "rent"
942
+ }
943
+ ],
944
+ args: [
945
+ {
946
+ name: "amount",
947
+ type: "u64"
948
+ },
949
+ {
950
+ name: "seed",
951
+ type: "u32"
952
+ }
953
+ ]
954
+ },
844
955
  {
845
956
  name: "desynd",
846
957
  discriminator: [
@@ -917,6 +1028,10 @@ var instructions$7 = [
917
1028
  ],
918
1029
  writable: true
919
1030
  },
1031
+ {
1032
+ name: "pretoken_purchase_history",
1033
+ writable: true
1034
+ },
920
1035
  {
921
1036
  name: "token_program"
922
1037
  },
@@ -959,6 +1074,44 @@ var instructions$7 = [
959
1074
  ],
960
1075
  returns: "u16"
961
1076
  },
1077
+ {
1078
+ name: "has_role",
1079
+ discriminator: [
1080
+ 218,
1081
+ 136,
1082
+ 44,
1083
+ 87,
1084
+ 142,
1085
+ 247,
1086
+ 141,
1087
+ 195
1088
+ ],
1089
+ accounts: [
1090
+ {
1091
+ name: "user",
1092
+ docs: [
1093
+ "User whose role status is being checked."
1094
+ ]
1095
+ },
1096
+ {
1097
+ name: "outpost_account"
1098
+ },
1099
+ {
1100
+ name: "global_state"
1101
+ }
1102
+ ],
1103
+ args: [
1104
+ {
1105
+ name: "role",
1106
+ type: {
1107
+ defined: {
1108
+ name: "Role"
1109
+ }
1110
+ }
1111
+ }
1112
+ ],
1113
+ returns: "bool"
1114
+ },
962
1115
  {
963
1116
  name: "init_bucket",
964
1117
  docs: [
@@ -1310,6 +1463,52 @@ var instructions$7 = [
1310
1463
  args: [
1311
1464
  ]
1312
1465
  },
1466
+ {
1467
+ name: "initialize_pretoken_purchase_history",
1468
+ docs: [
1469
+ "Admin-only: initialize PretokenPurchaseHistory PDA for a pool"
1470
+ ],
1471
+ discriminator: [
1472
+ 140,
1473
+ 166,
1474
+ 196,
1475
+ 128,
1476
+ 189,
1477
+ 240,
1478
+ 159,
1479
+ 1
1480
+ ],
1481
+ accounts: [
1482
+ {
1483
+ name: "admin",
1484
+ writable: true,
1485
+ signer: true
1486
+ },
1487
+ {
1488
+ name: "global_config"
1489
+ },
1490
+ {
1491
+ name: "pretoken_purchase_history",
1492
+ writable: true
1493
+ },
1494
+ {
1495
+ name: "pool_authority"
1496
+ },
1497
+ {
1498
+ name: "global_state",
1499
+ writable: true
1500
+ },
1501
+ {
1502
+ name: "pool_pretoken_record",
1503
+ writable: true
1504
+ },
1505
+ {
1506
+ name: "system_program"
1507
+ }
1508
+ ],
1509
+ args: [
1510
+ ]
1511
+ },
1313
1512
  {
1314
1513
  name: "initialize_processing_state",
1315
1514
  docs: [
@@ -2191,6 +2390,10 @@ var instructions$7 = [
2191
2390
  },
2192
2391
  {
2193
2392
  name: "system_program"
2393
+ },
2394
+ {
2395
+ name: "pretoken_purchase_history",
2396
+ writable: true
2194
2397
  }
2195
2398
  ],
2196
2399
  args: [
@@ -2285,6 +2488,10 @@ var instructions$7 = [
2285
2488
  },
2286
2489
  {
2287
2490
  name: "chainlink_program"
2491
+ },
2492
+ {
2493
+ name: "pretoken_purchase_history",
2494
+ writable: true
2288
2495
  }
2289
2496
  ],
2290
2497
  args: [
@@ -2380,7 +2587,7 @@ var instructions$7 = [
2380
2587
  name: "refresh_stake_metrics_post_sync",
2381
2588
  docs: [
2382
2589
  "V2: Refresh stake metrics after removal selection + PDA setup",
2383
- "Requires ActiveInfosSynced + ValidatorPdaSetup as prerequisites",
2590
+ "Requires ValidatorAdditionSelection + ValidatorPdaSetup as prerequisites",
2384
2591
  "Tracks completion in last_post_sync_stake_metrics_refresh_epoch"
2385
2592
  ],
2386
2593
  discriminator: [
@@ -2424,24 +2631,51 @@ var instructions$7 = [
2424
2631
  ]
2425
2632
  },
2426
2633
  {
2427
- name: "register_user",
2634
+ name: "refund",
2428
2635
  discriminator: [
2429
2636
  2,
2430
- 241,
2431
- 150,
2432
- 223,
2433
- 99,
2434
- 214,
2435
- 116,
2436
- 97
2637
+ 96,
2638
+ 183,
2639
+ 251,
2640
+ 63,
2641
+ 208,
2642
+ 46,
2643
+ 46
2437
2644
  ],
2438
2645
  accounts: [
2646
+ {
2647
+ name: "associated_token_program"
2648
+ },
2439
2649
  {
2440
2650
  name: "user",
2651
+ writable: true,
2652
+ signer: true
2653
+ },
2654
+ {
2655
+ name: "global_state",
2441
2656
  writable: true
2442
2657
  },
2443
2658
  {
2444
- name: "user_ata",
2659
+ name: "outpost_account",
2660
+ writable: true
2661
+ },
2662
+ {
2663
+ name: "distribution_state",
2664
+ writable: true
2665
+ },
2666
+ {
2667
+ name: "pool_authority"
2668
+ },
2669
+ {
2670
+ name: "liqsol_pool_ata",
2671
+ writable: true
2672
+ },
2673
+ {
2674
+ name: "refund_liqsol_ata",
2675
+ writable: true
2676
+ },
2677
+ {
2678
+ name: "liqsol_pool_user_record",
2445
2679
  writable: true
2446
2680
  },
2447
2681
  {
@@ -2449,13 +2683,118 @@ var instructions$7 = [
2449
2683
  writable: true
2450
2684
  },
2451
2685
  {
2452
- name: "payer",
2453
- docs: [
2454
- "Payer for the user record PDA creation (always the user)"
2455
- ],
2686
+ name: "extra_account_meta_list"
2687
+ },
2688
+ {
2689
+ name: "liqsol_core_program"
2690
+ },
2691
+ {
2692
+ name: "transfer_hook_program"
2693
+ },
2694
+ {
2695
+ name: "liqsol_mint"
2696
+ },
2697
+ {
2698
+ name: "token_program"
2699
+ },
2700
+ {
2701
+ name: "bucket_authority"
2702
+ },
2703
+ {
2704
+ name: "bucket_token_account",
2705
+ writable: true
2706
+ },
2707
+ {
2708
+ name: "bucket_user_record",
2709
+ writable: true
2710
+ },
2711
+ {
2712
+ name: "system_program"
2713
+ }
2714
+ ],
2715
+ args: [
2716
+ ]
2717
+ },
2718
+ {
2719
+ name: "register_system_pda",
2720
+ discriminator: [
2721
+ 110,
2722
+ 93,
2723
+ 36,
2724
+ 156,
2725
+ 179,
2726
+ 69,
2727
+ 54,
2728
+ 210
2729
+ ],
2730
+ accounts: [
2731
+ {
2732
+ name: "admin",
2456
2733
  writable: true,
2457
2734
  signer: true
2458
2735
  },
2736
+ {
2737
+ name: "global_config"
2738
+ },
2739
+ {
2740
+ name: "pda_owner",
2741
+ docs: [
2742
+ "The PDA whose user record we're creating — must be system-owned (no program data)."
2743
+ ]
2744
+ },
2745
+ {
2746
+ name: "pda_ata"
2747
+ },
2748
+ {
2749
+ name: "user_record",
2750
+ writable: true
2751
+ },
2752
+ {
2753
+ name: "distribution_state",
2754
+ writable: true
2755
+ },
2756
+ {
2757
+ name: "bucket_authority"
2758
+ },
2759
+ {
2760
+ name: "bucket_token_account",
2761
+ docs: [
2762
+ "The bucket's associated token account holding liqSOL (for index sync)"
2763
+ ],
2764
+ writable: true
2765
+ },
2766
+ {
2767
+ name: "system_program"
2768
+ }
2769
+ ],
2770
+ args: [
2771
+ ]
2772
+ },
2773
+ {
2774
+ name: "register_user",
2775
+ discriminator: [
2776
+ 2,
2777
+ 241,
2778
+ 150,
2779
+ 223,
2780
+ 99,
2781
+ 214,
2782
+ 116,
2783
+ 97
2784
+ ],
2785
+ accounts: [
2786
+ {
2787
+ name: "payer",
2788
+ writable: true,
2789
+ signer: true
2790
+ },
2791
+ {
2792
+ name: "user_ata"
2793
+ },
2794
+ {
2795
+ name: "user_record",
2796
+ writable: true
2797
+ },
2459
2798
  {
2460
2799
  name: "distribution_state",
2461
2800
  writable: true
@@ -2621,7 +2960,8 @@ var instructions$7 = [
2621
2960
  name: "bucket_token_account",
2622
2961
  docs: [
2623
2962
  "The bucket's token account holding liqSOL (for sync_index balance)"
2624
- ]
2963
+ ],
2964
+ writable: true
2625
2965
  },
2626
2966
  {
2627
2967
  name: "reserve_pool",
@@ -2970,7 +3310,8 @@ var instructions$7 = [
2970
3310
  name: "global_config"
2971
3311
  },
2972
3312
  {
2973
- name: "global_state"
3313
+ name: "global_state",
3314
+ writable: true
2974
3315
  },
2975
3316
  {
2976
3317
  name: "user",
@@ -3063,7 +3404,7 @@ var instructions$7 = [
3063
3404
  name: "sync_main_stake_accounts",
3064
3405
  docs: [
3065
3406
  "V2: Sync main stake accounts using PDA architecture (batched)",
3066
- "Processes up to 10 validators per transaction via remaining_accounts",
3407
+ "Processes validators in batches via remaining_accounts (batch size is enforced client-side)",
3067
3408
  "Note: Only syncs primary delegated stakes, not transient stakes"
3068
3409
  ],
3069
3410
  discriminator: [
@@ -3231,6 +3572,10 @@ var instructions$7 = [
3231
3572
  ],
3232
3573
  writable: true
3233
3574
  },
3575
+ {
3576
+ name: "pretoken_purchase_history",
3577
+ writable: true
3578
+ },
3234
3579
  {
3235
3580
  name: "token_program"
3236
3581
  },
@@ -3633,6 +3978,19 @@ var accounts$5 = [
3633
3978
  150
3634
3979
  ]
3635
3980
  },
3981
+ {
3982
+ name: "PretokenPurchaseHistory",
3983
+ discriminator: [
3984
+ 33,
3985
+ 71,
3986
+ 113,
3987
+ 206,
3988
+ 33,
3989
+ 180,
3990
+ 236,
3991
+ 131
3992
+ ]
3993
+ },
3636
3994
  {
3637
3995
  name: "PriceHistory",
3638
3996
  discriminator: [
@@ -4145,12 +4503,24 @@ var types$9 = [
4145
4503
  ],
4146
4504
  type: "u16"
4147
4505
  },
4506
+ {
4507
+ name: "aggregate_mode_tag",
4508
+ docs: [
4509
+ "Tracks which aggregation mode currently owns the shared temp fields.",
4510
+ "0 = idle,",
4511
+ "1 = Normal,",
4512
+ "2 = PostSync,",
4513
+ "3 = PostLateEpoch.",
4514
+ "Prevents cross-mode state contamination when modes share the same vars."
4515
+ ],
4516
+ type: "u8"
4517
+ },
4148
4518
  {
4149
4519
  name: "_reserved",
4150
4520
  type: {
4151
4521
  array: [
4152
4522
  "u8",
4153
- 32
4523
+ 31
4154
4524
  ]
4155
4525
  }
4156
4526
  }
@@ -4383,7 +4753,9 @@ var types$9 = [
4383
4753
  {
4384
4754
  name: "authority",
4385
4755
  docs: [
4386
- "Authority that can update serviceable_epoch"
4756
+ "DEPRECATED: Originally intended as authority for serviceable_epoch updates,",
4757
+ "but serviceable_epoch is updated by merge_deactivated_stakes gated via GlobalConfig.cranky.",
4758
+ "Retained to preserve account layout."
4387
4759
  ],
4388
4760
  type: "pubkey"
4389
4761
  },
@@ -4699,9 +5071,10 @@ var types$9 = [
4699
5071
  type: "u64"
4700
5072
  },
4701
5073
  {
4702
- name: "last_pool_liqsol_balance",
5074
+ name: "expected_pool_balance",
4703
5075
  docs: [
4704
- "Last observed liqSOL pool balance (for yield calculation)"
5076
+ "Expected liqSOL pool balance (tracked by protocol operations, not read from on-chain balance).",
5077
+ "Any discrepancy vs actual on-chain balance is treated as unsolicited donations, not yield."
4705
5078
  ],
4706
5079
  type: "u64"
4707
5080
  },
@@ -4914,6 +5287,9 @@ var types$9 = [
4914
5287
  },
4915
5288
  {
4916
5289
  name: "last_active_infos_synced_epoch",
5290
+ docs: [
5291
+ "DEPRECATED: ActiveInfosSynced removed in WIN-134. Retained to preserve account layout."
5292
+ ],
4917
5293
  type: "u16"
4918
5294
  },
4919
5295
  {
@@ -4928,6 +5304,9 @@ var types$9 = [
4928
5304
  },
4929
5305
  {
4930
5306
  name: "last_distribution_slot",
5307
+ docs: [
5308
+ "DEPRECATED: Distribution slot tracking removed in PR113. Retained to preserve account layout."
5309
+ ],
4931
5310
  type: {
4932
5311
  option: "u64"
4933
5312
  }
@@ -5092,6 +5471,24 @@ var types$9 = [
5092
5471
  {
5093
5472
  name: "bump",
5094
5473
  type: "u8"
5474
+ },
5475
+ {
5476
+ name: "accumulated_pretoken_yield",
5477
+ type: {
5478
+ option: "u64"
5479
+ }
5480
+ },
5481
+ {
5482
+ name: "last_epoch_synd_liqsol",
5483
+ type: {
5484
+ option: "u64"
5485
+ }
5486
+ },
5487
+ {
5488
+ name: "last_synd_epoch",
5489
+ type: {
5490
+ option: "u64"
5491
+ }
5095
5492
  }
5096
5493
  ]
5097
5494
  }
@@ -5186,6 +5583,57 @@ var types$9 = [
5186
5583
  ]
5187
5584
  }
5188
5585
  },
5586
+ {
5587
+ name: "PretokenPurchaseHistory",
5588
+ serialization: "bytemuck",
5589
+ repr: {
5590
+ kind: "c"
5591
+ },
5592
+ type: {
5593
+ kind: "struct",
5594
+ fields: [
5595
+ {
5596
+ name: "starting_epoch",
5597
+ type: "u64"
5598
+ },
5599
+ {
5600
+ name: "latest_epoch",
5601
+ type: "u64"
5602
+ },
5603
+ {
5604
+ name: "purchased_per_epoch",
5605
+ type: {
5606
+ array: [
5607
+ "u64",
5608
+ 100
5609
+ ]
5610
+ }
5611
+ },
5612
+ {
5613
+ name: "synd_per_epoch",
5614
+ type: {
5615
+ array: [
5616
+ "u64",
5617
+ 100
5618
+ ]
5619
+ }
5620
+ },
5621
+ {
5622
+ name: "bump",
5623
+ type: "u8"
5624
+ },
5625
+ {
5626
+ name: "_padding",
5627
+ type: {
5628
+ array: [
5629
+ "u8",
5630
+ 7
5631
+ ]
5632
+ }
5633
+ }
5634
+ ]
5635
+ }
5636
+ },
5189
5637
  {
5190
5638
  name: "PretokenPurchased",
5191
5639
  type: {
@@ -5446,56 +5894,56 @@ var types$9 = [
5446
5894
  {
5447
5895
  name: "addition_in_progress",
5448
5896
  docs: [
5449
- "Whether validator addition selection is currently in progress (batched processing)"
5897
+ "DEPRECATED see BatchOrchestrator. Always false."
5450
5898
  ],
5451
5899
  type: "bool"
5452
5900
  },
5453
5901
  {
5454
5902
  name: "addition_next_rank",
5455
5903
  docs: [
5456
- "Next rank to process in leaderboard sorted_indices"
5904
+ "DEPRECATED see BatchOrchestrator.addition_next_rank. Always 0."
5457
5905
  ],
5458
5906
  type: "u16"
5459
5907
  },
5460
5908
  {
5461
5909
  name: "addition_target_rank",
5462
5910
  docs: [
5463
- "Target rank to process up to (inclusive)"
5911
+ "DEPRECATED see BatchOrchestrator.addition_target_rank. Always 0."
5464
5912
  ],
5465
5913
  type: "u16"
5466
5914
  },
5467
5915
  {
5468
5916
  name: "validators_added_this_selection",
5469
5917
  docs: [
5470
- "Number of validators added in the current selection cycle"
5918
+ "DEPRECATED see BatchOrchestrator. Always 0."
5471
5919
  ],
5472
5920
  type: "u16"
5473
5921
  },
5474
5922
  {
5475
5923
  name: "removal_in_progress",
5476
5924
  docs: [
5477
- "Whether validator removal selection is currently in progress (batched processing)"
5925
+ "DEPRECATED see BatchOrchestrator. Always false."
5478
5926
  ],
5479
5927
  type: "bool"
5480
5928
  },
5481
5929
  {
5482
5930
  name: "removal_next_index",
5483
5931
  docs: [
5484
- "Next index in active list to check for removal"
5932
+ "DEPRECATED see BatchOrchestrator.removal_next_index. Always 0."
5485
5933
  ],
5486
5934
  type: "u16"
5487
5935
  },
5488
5936
  {
5489
5937
  name: "removal_active_list_snapshot",
5490
5938
  docs: [
5491
- "Snapshot of active list count at start of removal (frozen)"
5939
+ "DEPRECATED see BatchOrchestrator. Always 0."
5492
5940
  ],
5493
5941
  type: "u16"
5494
5942
  },
5495
5943
  {
5496
5944
  name: "validators_removed_this_selection",
5497
5945
  docs: [
5498
- "Number of validators removed in the current selection cycle"
5946
+ "DEPRECATED see BatchOrchestrator. Always 0."
5499
5947
  ],
5500
5948
  type: "u16"
5501
5949
  }
@@ -6351,6 +6799,41 @@ var instructions$6 = [
6351
6799
  }
6352
6800
  }
6353
6801
  ]
6802
+ },
6803
+ {
6804
+ name: "update_liqsol_metadata_permissionless",
6805
+ discriminator: [
6806
+ 21,
6807
+ 255,
6808
+ 26,
6809
+ 184,
6810
+ 136,
6811
+ 110,
6812
+ 214,
6813
+ 33
6814
+ ],
6815
+ accounts: [
6816
+ {
6817
+ name: "payer",
6818
+ writable: true,
6819
+ signer: true
6820
+ },
6821
+ {
6822
+ name: "mint_authority"
6823
+ },
6824
+ {
6825
+ name: "mint",
6826
+ writable: true
6827
+ },
6828
+ {
6829
+ name: "token_program"
6830
+ },
6831
+ {
6832
+ name: "system_program"
6833
+ }
6834
+ ],
6835
+ args: [
6836
+ ]
6354
6837
  }
6355
6838
  ];
6356
6839
  var errors$6 = [
@@ -7108,6 +7591,41 @@ var instructions$4 = [
7108
7591
  type: "u64"
7109
7592
  }
7110
7593
  ]
7594
+ },
7595
+ {
7596
+ name: "update_extra_account_meta_list",
7597
+ discriminator: [
7598
+ 44,
7599
+ 125,
7600
+ 141,
7601
+ 226,
7602
+ 97,
7603
+ 179,
7604
+ 166,
7605
+ 96
7606
+ ],
7607
+ accounts: [
7608
+ {
7609
+ name: "payer",
7610
+ writable: true,
7611
+ signer: true
7612
+ },
7613
+ {
7614
+ name: "extra_account_meta_list",
7615
+ writable: true
7616
+ },
7617
+ {
7618
+ name: "mint"
7619
+ },
7620
+ {
7621
+ name: "system_program"
7622
+ },
7623
+ {
7624
+ name: "liqsol_core"
7625
+ }
7626
+ ],
7627
+ args: [
7628
+ ]
7111
7629
  }
7112
7630
  ];
7113
7631
  var accounts$3 = [
@@ -7278,6 +7796,51 @@ var instructions$3 = [
7278
7796
  args: [
7279
7797
  ]
7280
7798
  },
7799
+ {
7800
+ name: "admin_force_unbond_role",
7801
+ discriminator: [
7802
+ 80,
7803
+ 107,
7804
+ 27,
7805
+ 49,
7806
+ 126,
7807
+ 25,
7808
+ 31,
7809
+ 238
7810
+ ],
7811
+ accounts: [
7812
+ {
7813
+ name: "admin",
7814
+ signer: true
7815
+ },
7816
+ {
7817
+ name: "global_config"
7818
+ },
7819
+ {
7820
+ name: "global_state"
7821
+ },
7822
+ {
7823
+ name: "user",
7824
+ docs: [
7825
+ "The user whose role bond is being force-unbonded"
7826
+ ]
7827
+ },
7828
+ {
7829
+ name: "outpost_account",
7830
+ writable: true
7831
+ }
7832
+ ],
7833
+ args: [
7834
+ {
7835
+ name: "role",
7836
+ type: {
7837
+ defined: {
7838
+ name: "Role"
7839
+ }
7840
+ }
7841
+ }
7842
+ ]
7843
+ },
7281
7844
  {
7282
7845
  name: "aggregate_stake_metrics",
7283
7846
  docs: [
@@ -8052,6 +8615,72 @@ var instructions$3 = [
8052
8615
  }
8053
8616
  ]
8054
8617
  },
8618
+ {
8619
+ name: "deposit_to_reserve",
8620
+ discriminator: [
8621
+ 8,
8622
+ 79,
8623
+ 123,
8624
+ 129,
8625
+ 146,
8626
+ 140,
8627
+ 178,
8628
+ 128
8629
+ ],
8630
+ accounts: [
8631
+ {
8632
+ name: "admin",
8633
+ signer: true
8634
+ },
8635
+ {
8636
+ name: "global_config"
8637
+ },
8638
+ {
8639
+ name: "depositor",
8640
+ writable: true,
8641
+ signer: true
8642
+ },
8643
+ {
8644
+ name: "reserve_pool",
8645
+ writable: true
8646
+ },
8647
+ {
8648
+ name: "vault"
8649
+ },
8650
+ {
8651
+ name: "ephemeral_stake",
8652
+ writable: true
8653
+ },
8654
+ {
8655
+ name: "controller_state"
8656
+ },
8657
+ {
8658
+ name: "stake_program"
8659
+ },
8660
+ {
8661
+ name: "system_program"
8662
+ },
8663
+ {
8664
+ name: "clock"
8665
+ },
8666
+ {
8667
+ name: "stake_history"
8668
+ },
8669
+ {
8670
+ name: "rent"
8671
+ }
8672
+ ],
8673
+ args: [
8674
+ {
8675
+ name: "amount",
8676
+ type: "u64"
8677
+ },
8678
+ {
8679
+ name: "seed",
8680
+ type: "u32"
8681
+ }
8682
+ ]
8683
+ },
8055
8684
  {
8056
8685
  name: "desynd",
8057
8686
  discriminator: [
@@ -8128,6 +8757,10 @@ var instructions$3 = [
8128
8757
  ],
8129
8758
  writable: true
8130
8759
  },
8760
+ {
8761
+ name: "pretoken_purchase_history",
8762
+ writable: true
8763
+ },
8131
8764
  {
8132
8765
  name: "token_program"
8133
8766
  },
@@ -8170,6 +8803,44 @@ var instructions$3 = [
8170
8803
  ],
8171
8804
  returns: "u16"
8172
8805
  },
8806
+ {
8807
+ name: "has_role",
8808
+ discriminator: [
8809
+ 218,
8810
+ 136,
8811
+ 44,
8812
+ 87,
8813
+ 142,
8814
+ 247,
8815
+ 141,
8816
+ 195
8817
+ ],
8818
+ accounts: [
8819
+ {
8820
+ name: "user",
8821
+ docs: [
8822
+ "User whose role status is being checked."
8823
+ ]
8824
+ },
8825
+ {
8826
+ name: "outpost_account"
8827
+ },
8828
+ {
8829
+ name: "global_state"
8830
+ }
8831
+ ],
8832
+ args: [
8833
+ {
8834
+ name: "role",
8835
+ type: {
8836
+ defined: {
8837
+ name: "Role"
8838
+ }
8839
+ }
8840
+ }
8841
+ ],
8842
+ returns: "bool"
8843
+ },
8173
8844
  {
8174
8845
  name: "init_bucket",
8175
8846
  docs: [
@@ -8521,6 +9192,52 @@ var instructions$3 = [
8521
9192
  args: [
8522
9193
  ]
8523
9194
  },
9195
+ {
9196
+ name: "initialize_pretoken_purchase_history",
9197
+ docs: [
9198
+ "Admin-only: initialize PretokenPurchaseHistory PDA for a pool"
9199
+ ],
9200
+ discriminator: [
9201
+ 140,
9202
+ 166,
9203
+ 196,
9204
+ 128,
9205
+ 189,
9206
+ 240,
9207
+ 159,
9208
+ 1
9209
+ ],
9210
+ accounts: [
9211
+ {
9212
+ name: "admin",
9213
+ writable: true,
9214
+ signer: true
9215
+ },
9216
+ {
9217
+ name: "global_config"
9218
+ },
9219
+ {
9220
+ name: "pretoken_purchase_history",
9221
+ writable: true
9222
+ },
9223
+ {
9224
+ name: "pool_authority"
9225
+ },
9226
+ {
9227
+ name: "global_state",
9228
+ writable: true
9229
+ },
9230
+ {
9231
+ name: "pool_pretoken_record",
9232
+ writable: true
9233
+ },
9234
+ {
9235
+ name: "system_program"
9236
+ }
9237
+ ],
9238
+ args: [
9239
+ ]
9240
+ },
8524
9241
  {
8525
9242
  name: "initialize_processing_state",
8526
9243
  docs: [
@@ -9402,6 +10119,10 @@ var instructions$3 = [
9402
10119
  },
9403
10120
  {
9404
10121
  name: "system_program"
10122
+ },
10123
+ {
10124
+ name: "pretoken_purchase_history",
10125
+ writable: true
9405
10126
  }
9406
10127
  ],
9407
10128
  args: [
@@ -9496,6 +10217,10 @@ var instructions$3 = [
9496
10217
  },
9497
10218
  {
9498
10219
  name: "chainlink_program"
10220
+ },
10221
+ {
10222
+ name: "pretoken_purchase_history",
10223
+ writable: true
9499
10224
  }
9500
10225
  ],
9501
10226
  args: [
@@ -9591,7 +10316,7 @@ var instructions$3 = [
9591
10316
  name: "refresh_stake_metrics_post_sync",
9592
10317
  docs: [
9593
10318
  "V2: Refresh stake metrics after removal selection + PDA setup",
9594
- "Requires ActiveInfosSynced + ValidatorPdaSetup as prerequisites",
10319
+ "Requires ValidatorAdditionSelection + ValidatorPdaSetup as prerequisites",
9595
10320
  "Tracks completion in last_post_sync_stake_metrics_refresh_epoch"
9596
10321
  ],
9597
10322
  discriminator: [
@@ -9635,24 +10360,51 @@ var instructions$3 = [
9635
10360
  ]
9636
10361
  },
9637
10362
  {
9638
- name: "register_user",
10363
+ name: "refund",
9639
10364
  discriminator: [
9640
10365
  2,
9641
- 241,
9642
- 150,
9643
- 223,
9644
- 99,
9645
- 214,
9646
- 116,
9647
- 97
10366
+ 96,
10367
+ 183,
10368
+ 251,
10369
+ 63,
10370
+ 208,
10371
+ 46,
10372
+ 46
9648
10373
  ],
9649
10374
  accounts: [
10375
+ {
10376
+ name: "associated_token_program"
10377
+ },
9650
10378
  {
9651
10379
  name: "user",
10380
+ writable: true,
10381
+ signer: true
10382
+ },
10383
+ {
10384
+ name: "global_state",
9652
10385
  writable: true
9653
10386
  },
9654
10387
  {
9655
- name: "user_ata",
10388
+ name: "outpost_account",
10389
+ writable: true
10390
+ },
10391
+ {
10392
+ name: "distribution_state",
10393
+ writable: true
10394
+ },
10395
+ {
10396
+ name: "pool_authority"
10397
+ },
10398
+ {
10399
+ name: "liqsol_pool_ata",
10400
+ writable: true
10401
+ },
10402
+ {
10403
+ name: "refund_liqsol_ata",
10404
+ writable: true
10405
+ },
10406
+ {
10407
+ name: "liqsol_pool_user_record",
9656
10408
  writable: true
9657
10409
  },
9658
10410
  {
@@ -9660,13 +10412,118 @@ var instructions$3 = [
9660
10412
  writable: true
9661
10413
  },
9662
10414
  {
9663
- name: "payer",
10415
+ name: "extra_account_meta_list"
10416
+ },
10417
+ {
10418
+ name: "liqsol_core_program"
10419
+ },
10420
+ {
10421
+ name: "transfer_hook_program"
10422
+ },
10423
+ {
10424
+ name: "liqsol_mint"
10425
+ },
10426
+ {
10427
+ name: "token_program"
10428
+ },
10429
+ {
10430
+ name: "bucket_authority"
10431
+ },
10432
+ {
10433
+ name: "bucket_token_account",
10434
+ writable: true
10435
+ },
10436
+ {
10437
+ name: "bucket_user_record",
10438
+ writable: true
10439
+ },
10440
+ {
10441
+ name: "system_program"
10442
+ }
10443
+ ],
10444
+ args: [
10445
+ ]
10446
+ },
10447
+ {
10448
+ name: "register_system_pda",
10449
+ discriminator: [
10450
+ 110,
10451
+ 93,
10452
+ 36,
10453
+ 156,
10454
+ 179,
10455
+ 69,
10456
+ 54,
10457
+ 210
10458
+ ],
10459
+ accounts: [
10460
+ {
10461
+ name: "admin",
10462
+ writable: true,
10463
+ signer: true
10464
+ },
10465
+ {
10466
+ name: "global_config"
10467
+ },
10468
+ {
10469
+ name: "pda_owner",
9664
10470
  docs: [
9665
- "Payer for the user record PDA creation (always the user)"
10471
+ "The PDA whose user record we're creating — must be system-owned (no program data)."
10472
+ ]
10473
+ },
10474
+ {
10475
+ name: "pda_ata"
10476
+ },
10477
+ {
10478
+ name: "user_record",
10479
+ writable: true
10480
+ },
10481
+ {
10482
+ name: "distribution_state",
10483
+ writable: true
10484
+ },
10485
+ {
10486
+ name: "bucket_authority"
10487
+ },
10488
+ {
10489
+ name: "bucket_token_account",
10490
+ docs: [
10491
+ "The bucket's associated token account holding liqSOL (for index sync)"
9666
10492
  ],
10493
+ writable: true
10494
+ },
10495
+ {
10496
+ name: "system_program"
10497
+ }
10498
+ ],
10499
+ args: [
10500
+ ]
10501
+ },
10502
+ {
10503
+ name: "register_user",
10504
+ discriminator: [
10505
+ 2,
10506
+ 241,
10507
+ 150,
10508
+ 223,
10509
+ 99,
10510
+ 214,
10511
+ 116,
10512
+ 97
10513
+ ],
10514
+ accounts: [
10515
+ {
10516
+ name: "payer",
9667
10517
  writable: true,
9668
10518
  signer: true
9669
10519
  },
10520
+ {
10521
+ name: "user_ata"
10522
+ },
10523
+ {
10524
+ name: "user_record",
10525
+ writable: true
10526
+ },
9670
10527
  {
9671
10528
  name: "distribution_state",
9672
10529
  writable: true
@@ -9832,7 +10689,8 @@ var instructions$3 = [
9832
10689
  name: "bucket_token_account",
9833
10690
  docs: [
9834
10691
  "The bucket's token account holding liqSOL (for sync_index balance)"
9835
- ]
10692
+ ],
10693
+ writable: true
9836
10694
  },
9837
10695
  {
9838
10696
  name: "reserve_pool",
@@ -10181,7 +11039,8 @@ var instructions$3 = [
10181
11039
  name: "global_config"
10182
11040
  },
10183
11041
  {
10184
- name: "global_state"
11042
+ name: "global_state",
11043
+ writable: true
10185
11044
  },
10186
11045
  {
10187
11046
  name: "user",
@@ -10274,7 +11133,7 @@ var instructions$3 = [
10274
11133
  name: "sync_main_stake_accounts",
10275
11134
  docs: [
10276
11135
  "V2: Sync main stake accounts using PDA architecture (batched)",
10277
- "Processes up to 10 validators per transaction via remaining_accounts",
11136
+ "Processes validators in batches via remaining_accounts (batch size is enforced client-side)",
10278
11137
  "Note: Only syncs primary delegated stakes, not transient stakes"
10279
11138
  ],
10280
11139
  discriminator: [
@@ -10442,6 +11301,10 @@ var instructions$3 = [
10442
11301
  ],
10443
11302
  writable: true
10444
11303
  },
11304
+ {
11305
+ name: "pretoken_purchase_history",
11306
+ writable: true
11307
+ },
10445
11308
  {
10446
11309
  name: "token_program"
10447
11310
  },
@@ -10844,6 +11707,19 @@ var accounts$2 = [
10844
11707
  150
10845
11708
  ]
10846
11709
  },
11710
+ {
11711
+ name: "PretokenPurchaseHistory",
11712
+ discriminator: [
11713
+ 33,
11714
+ 71,
11715
+ 113,
11716
+ 206,
11717
+ 33,
11718
+ 180,
11719
+ 236,
11720
+ 131
11721
+ ]
11722
+ },
10847
11723
  {
10848
11724
  name: "PriceHistory",
10849
11725
  discriminator: [
@@ -11356,12 +12232,24 @@ var types$5 = [
11356
12232
  ],
11357
12233
  type: "u16"
11358
12234
  },
12235
+ {
12236
+ name: "aggregate_mode_tag",
12237
+ docs: [
12238
+ "Tracks which aggregation mode currently owns the shared temp fields.",
12239
+ "0 = idle,",
12240
+ "1 = Normal,",
12241
+ "2 = PostSync,",
12242
+ "3 = PostLateEpoch.",
12243
+ "Prevents cross-mode state contamination when modes share the same vars."
12244
+ ],
12245
+ type: "u8"
12246
+ },
11359
12247
  {
11360
12248
  name: "_reserved",
11361
12249
  type: {
11362
12250
  array: [
11363
12251
  "u8",
11364
- 32
12252
+ 31
11365
12253
  ]
11366
12254
  }
11367
12255
  }
@@ -11594,7 +12482,9 @@ var types$5 = [
11594
12482
  {
11595
12483
  name: "authority",
11596
12484
  docs: [
11597
- "Authority that can update serviceable_epoch"
12485
+ "DEPRECATED: Originally intended as authority for serviceable_epoch updates,",
12486
+ "but serviceable_epoch is updated by merge_deactivated_stakes gated via GlobalConfig.cranky.",
12487
+ "Retained to preserve account layout."
11598
12488
  ],
11599
12489
  type: "pubkey"
11600
12490
  },
@@ -11910,9 +12800,10 @@ var types$5 = [
11910
12800
  type: "u64"
11911
12801
  },
11912
12802
  {
11913
- name: "last_pool_liqsol_balance",
12803
+ name: "expected_pool_balance",
11914
12804
  docs: [
11915
- "Last observed liqSOL pool balance (for yield calculation)"
12805
+ "Expected liqSOL pool balance (tracked by protocol operations, not read from on-chain balance).",
12806
+ "Any discrepancy vs actual on-chain balance is treated as unsolicited donations, not yield."
11916
12807
  ],
11917
12808
  type: "u64"
11918
12809
  },
@@ -12125,6 +13016,9 @@ var types$5 = [
12125
13016
  },
12126
13017
  {
12127
13018
  name: "last_active_infos_synced_epoch",
13019
+ docs: [
13020
+ "DEPRECATED: ActiveInfosSynced removed in WIN-134. Retained to preserve account layout."
13021
+ ],
12128
13022
  type: "u16"
12129
13023
  },
12130
13024
  {
@@ -12139,6 +13033,9 @@ var types$5 = [
12139
13033
  },
12140
13034
  {
12141
13035
  name: "last_distribution_slot",
13036
+ docs: [
13037
+ "DEPRECATED: Distribution slot tracking removed in PR113. Retained to preserve account layout."
13038
+ ],
12142
13039
  type: {
12143
13040
  option: "u64"
12144
13041
  }
@@ -12303,6 +13200,24 @@ var types$5 = [
12303
13200
  {
12304
13201
  name: "bump",
12305
13202
  type: "u8"
13203
+ },
13204
+ {
13205
+ name: "accumulated_pretoken_yield",
13206
+ type: {
13207
+ option: "u64"
13208
+ }
13209
+ },
13210
+ {
13211
+ name: "last_epoch_synd_liqsol",
13212
+ type: {
13213
+ option: "u64"
13214
+ }
13215
+ },
13216
+ {
13217
+ name: "last_synd_epoch",
13218
+ type: {
13219
+ option: "u64"
13220
+ }
12306
13221
  }
12307
13222
  ]
12308
13223
  }
@@ -12397,6 +13312,57 @@ var types$5 = [
12397
13312
  ]
12398
13313
  }
12399
13314
  },
13315
+ {
13316
+ name: "PretokenPurchaseHistory",
13317
+ serialization: "bytemuck",
13318
+ repr: {
13319
+ kind: "c"
13320
+ },
13321
+ type: {
13322
+ kind: "struct",
13323
+ fields: [
13324
+ {
13325
+ name: "starting_epoch",
13326
+ type: "u64"
13327
+ },
13328
+ {
13329
+ name: "latest_epoch",
13330
+ type: "u64"
13331
+ },
13332
+ {
13333
+ name: "purchased_per_epoch",
13334
+ type: {
13335
+ array: [
13336
+ "u64",
13337
+ 100
13338
+ ]
13339
+ }
13340
+ },
13341
+ {
13342
+ name: "synd_per_epoch",
13343
+ type: {
13344
+ array: [
13345
+ "u64",
13346
+ 100
13347
+ ]
13348
+ }
13349
+ },
13350
+ {
13351
+ name: "bump",
13352
+ type: "u8"
13353
+ },
13354
+ {
13355
+ name: "_padding",
13356
+ type: {
13357
+ array: [
13358
+ "u8",
13359
+ 7
13360
+ ]
13361
+ }
13362
+ }
13363
+ ]
13364
+ }
13365
+ },
12400
13366
  {
12401
13367
  name: "PretokenPurchased",
12402
13368
  type: {
@@ -12657,56 +13623,56 @@ var types$5 = [
12657
13623
  {
12658
13624
  name: "addition_in_progress",
12659
13625
  docs: [
12660
- "Whether validator addition selection is currently in progress (batched processing)"
13626
+ "DEPRECATED see BatchOrchestrator. Always false."
12661
13627
  ],
12662
13628
  type: "bool"
12663
13629
  },
12664
13630
  {
12665
13631
  name: "addition_next_rank",
12666
13632
  docs: [
12667
- "Next rank to process in leaderboard sorted_indices"
13633
+ "DEPRECATED see BatchOrchestrator.addition_next_rank. Always 0."
12668
13634
  ],
12669
13635
  type: "u16"
12670
13636
  },
12671
13637
  {
12672
13638
  name: "addition_target_rank",
12673
13639
  docs: [
12674
- "Target rank to process up to (inclusive)"
13640
+ "DEPRECATED see BatchOrchestrator.addition_target_rank. Always 0."
12675
13641
  ],
12676
13642
  type: "u16"
12677
13643
  },
12678
13644
  {
12679
13645
  name: "validators_added_this_selection",
12680
13646
  docs: [
12681
- "Number of validators added in the current selection cycle"
13647
+ "DEPRECATED see BatchOrchestrator. Always 0."
12682
13648
  ],
12683
13649
  type: "u16"
12684
13650
  },
12685
13651
  {
12686
13652
  name: "removal_in_progress",
12687
13653
  docs: [
12688
- "Whether validator removal selection is currently in progress (batched processing)"
13654
+ "DEPRECATED see BatchOrchestrator. Always false."
12689
13655
  ],
12690
13656
  type: "bool"
12691
13657
  },
12692
13658
  {
12693
13659
  name: "removal_next_index",
12694
13660
  docs: [
12695
- "Next index in active list to check for removal"
13661
+ "DEPRECATED see BatchOrchestrator.removal_next_index. Always 0."
12696
13662
  ],
12697
13663
  type: "u16"
12698
13664
  },
12699
13665
  {
12700
13666
  name: "removal_active_list_snapshot",
12701
13667
  docs: [
12702
- "Snapshot of active list count at start of removal (frozen)"
13668
+ "DEPRECATED see BatchOrchestrator. Always 0."
12703
13669
  ],
12704
13670
  type: "u16"
12705
13671
  },
12706
13672
  {
12707
13673
  name: "validators_removed_this_selection",
12708
13674
  docs: [
12709
- "Number of validators removed in the current selection cycle"
13675
+ "DEPRECATED see BatchOrchestrator. Always 0."
12710
13676
  ],
12711
13677
  type: "u16"
12712
13678
  }
@@ -13562,6 +14528,41 @@ var instructions$2 = [
13562
14528
  }
13563
14529
  }
13564
14530
  ]
14531
+ },
14532
+ {
14533
+ name: "update_liqsol_metadata_permissionless",
14534
+ discriminator: [
14535
+ 21,
14536
+ 255,
14537
+ 26,
14538
+ 184,
14539
+ 136,
14540
+ 110,
14541
+ 214,
14542
+ 33
14543
+ ],
14544
+ accounts: [
14545
+ {
14546
+ name: "payer",
14547
+ writable: true,
14548
+ signer: true
14549
+ },
14550
+ {
14551
+ name: "mint_authority"
14552
+ },
14553
+ {
14554
+ name: "mint",
14555
+ writable: true
14556
+ },
14557
+ {
14558
+ name: "token_program"
14559
+ },
14560
+ {
14561
+ name: "system_program"
14562
+ }
14563
+ ],
14564
+ args: [
14565
+ ]
13565
14566
  }
13566
14567
  ];
13567
14568
  var errors$2 = [
@@ -14319,6 +15320,41 @@ var instructions = [
14319
15320
  type: "u64"
14320
15321
  }
14321
15322
  ]
15323
+ },
15324
+ {
15325
+ name: "update_extra_account_meta_list",
15326
+ discriminator: [
15327
+ 44,
15328
+ 125,
15329
+ 141,
15330
+ 226,
15331
+ 97,
15332
+ 179,
15333
+ 166,
15334
+ 96
15335
+ ],
15336
+ accounts: [
15337
+ {
15338
+ name: "payer",
15339
+ writable: true,
15340
+ signer: true
15341
+ },
15342
+ {
15343
+ name: "extra_account_meta_list",
15344
+ writable: true
15345
+ },
15346
+ {
15347
+ name: "mint"
15348
+ },
15349
+ {
15350
+ name: "system_program"
15351
+ },
15352
+ {
15353
+ name: "liqsol_core"
15354
+ }
15355
+ ],
15356
+ args: [
15357
+ ]
14322
15358
  }
14323
15359
  ];
14324
15360
  var accounts = [
@@ -14484,7 +15520,8 @@ const PDA_SEEDS = {
14484
15520
  WITHDRAW_MINT_AUTHORITY: "mint_authority",
14485
15521
  MINT_METADATA: "mint_metadata",
14486
15522
  LIQ_RECEIPT_DATA: "liq_receipt_data",
14487
- WITHDRAW_MINT: "mint"
15523
+ WITHDRAW_MINT: "mint",
15524
+ PRETOKEN_PURCHASE_HISTORY: "pretoken_purchase_history"
14488
15525
  };
14489
15526
  const deriveEphemeralStakeAddress = async (user, seed) => {
14490
15527
  const seedStr = `ephemeral_${seed}`;
@@ -14669,6 +15706,7 @@ async function buildOutpostAccounts(connection, user, pgs) {
14669
15706
  const liqsolPoolUserRecord = pgs.deriveUserRecordPda(liqsolPoolAta);
14670
15707
  const userUserRecord = pgs.deriveUserRecordPda(userAta);
14671
15708
  const extraAccountMetaList = pgs.deriveExtraAccountMetaListPda(liqsolMint);
15709
+ const pretokenPurchaseHistory = pgs.derivePretokenPurchaseHistoryPda();
14672
15710
  let chainLinkFeed = CHAINLINK_FEED;
14673
15711
  let chainLinkProgram = CHAINLINK_PROGRAM;
14674
15712
  try {
@@ -14698,7 +15736,8 @@ async function buildOutpostAccounts(connection, user, pgs) {
14698
15736
  trancheState,
14699
15737
  chainLinkFeed,
14700
15738
  chainLinkProgram,
14701
- extraAccountMetaList
15739
+ extraAccountMetaList,
15740
+ pretokenPurchaseHistory
14702
15741
  };
14703
15742
  }
14704
15743
  async function getEpochSnapshot(connection) {
@@ -15040,6 +16079,7 @@ let ConvertClient$1 = class ConvertClient {
15040
16079
  }
15041
16080
  };
15042
16081
 
16082
+ const INDEX_SCALE_BN = new BN("1000000000000");
15043
16083
  class DistributionClient {
15044
16084
  constructor(provider, pgs) {
15045
16085
  this.provider = provider;
@@ -15049,6 +16089,14 @@ class DistributionClient {
15049
16089
  get connection() {
15050
16090
  return this.provider.connection;
15051
16091
  }
16092
+ async getTokenBalance(ata) {
16093
+ try {
16094
+ const bal = await this.connection.getTokenAccountBalance(ata);
16095
+ return new BN(bal.value.amount);
16096
+ } catch {
16097
+ return new BN(0);
16098
+ }
16099
+ }
15052
16100
  async getDistributionState() {
15053
16101
  const pda = this.pgs.deriveDistributionStatePda();
15054
16102
  try {
@@ -15116,6 +16164,81 @@ class DistributionClient {
15116
16164
  }
15117
16165
  return { shares: userShares, totalShares, ratio };
15118
16166
  }
16167
+ async getClaimableLiqsol(user) {
16168
+ const liqsolMint = this.pgs.deriveLiqsolMintPda();
16169
+ const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
16170
+ const userAta = getAssociatedTokenAddressSync(
16171
+ liqsolMint,
16172
+ user,
16173
+ true,
16174
+ TOKEN_2022_PROGRAM_ID
16175
+ );
16176
+ const bucketTokenAccount = getAssociatedTokenAddressSync(
16177
+ liqsolMint,
16178
+ bucketAuthority,
16179
+ true,
16180
+ TOKEN_2022_PROGRAM_ID
16181
+ );
16182
+ const [distributionState, userRecord, actualBalance, bucketBalance] = await Promise.all([
16183
+ this.getDistributionState(),
16184
+ this.getUserRecord(user),
16185
+ this.getTokenBalance(userAta),
16186
+ this.getTokenBalance(bucketTokenAccount)
16187
+ ]);
16188
+ if (!distributionState || !userRecord) {
16189
+ return new BN(0);
16190
+ }
16191
+ let syncedIndex = new BN(distributionState.currentIndex.toString());
16192
+ const totalShares = new BN(distributionState.totalShares.toString());
16193
+ const lastBucketBalance = new BN(distributionState.lastBucketBalance.toString());
16194
+ if (totalShares.gt(new BN(0)) && bucketBalance.gt(lastBucketBalance)) {
16195
+ const delta = bucketBalance.sub(lastBucketBalance);
16196
+ const indexDelta = delta.mul(INDEX_SCALE_BN).div(totalShares);
16197
+ if (indexDelta.gt(new BN(0))) {
16198
+ syncedIndex = syncedIndex.add(indexDelta);
16199
+ }
16200
+ }
16201
+ const shares = new BN(userRecord.shares.toString());
16202
+ const entitled = shares.mul(syncedIndex).div(INDEX_SCALE_BN);
16203
+ if (entitled.lte(actualBalance)) {
16204
+ return new BN(0);
16205
+ }
16206
+ return entitled.sub(actualBalance);
16207
+ }
16208
+ async buildClaimRewardsIx(user) {
16209
+ const liqsolMint = this.pgs.deriveLiqsolMintPda();
16210
+ const distributionState = this.pgs.deriveDistributionStatePda();
16211
+ const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
16212
+ const userAta = getAssociatedTokenAddressSync(
16213
+ liqsolMint,
16214
+ user,
16215
+ true,
16216
+ TOKEN_2022_PROGRAM_ID
16217
+ );
16218
+ const bucketTokenAccount = getAssociatedTokenAddressSync(
16219
+ liqsolMint,
16220
+ bucketAuthority,
16221
+ true,
16222
+ TOKEN_2022_PROGRAM_ID
16223
+ );
16224
+ const userRecord = this.pgs.deriveUserRecordPda(userAta);
16225
+ const bucketUserRecord = this.pgs.deriveUserRecordPda(bucketTokenAccount);
16226
+ const extraAccountMetaList = this.pgs.deriveExtraAccountMetaListPda(liqsolMint);
16227
+ return this.program.methods.claimRewards().accounts({
16228
+ user,
16229
+ userAta,
16230
+ userRecord,
16231
+ bucketUserRecord,
16232
+ distributionState,
16233
+ extraAccountMetaList,
16234
+ liqsolCoreProgram: this.pgs.PROGRAM_IDS.LIQSOL_CORE,
16235
+ transferHookProgram: this.pgs.PROGRAM_IDS.TRANSFER_HOOK,
16236
+ liqsolMint,
16237
+ bucketAuthority,
16238
+ bucketTokenAccount,
16239
+ tokenProgram: TOKEN_2022_PROGRAM_ID
16240
+ }).instruction();
16241
+ }
15119
16242
  async getAverageScaledPayRate(windowSize = 5) {
15120
16243
  const history = await this.getPayRateHistory();
15121
16244
  if (!history) {
@@ -15313,7 +16436,8 @@ class OutpostClient {
15313
16436
  outpostAccount: a.outpostAccount,
15314
16437
  tokenProgram: TOKEN_2022_PROGRAM_ID,
15315
16438
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
15316
- systemProgram: SystemProgram.programId
16439
+ systemProgram: SystemProgram.programId,
16440
+ pretokenPurchaseHistory: a.pretokenPurchaseHistory
15317
16441
  }).instruction();
15318
16442
  }
15319
16443
  async buildUnstakeIx(amountLamports, user) {
@@ -15341,7 +16465,8 @@ class OutpostClient {
15341
16465
  outpostAccount: a.outpostAccount,
15342
16466
  tokenProgram: TOKEN_2022_PROGRAM_ID,
15343
16467
  systemProgram: SystemProgram.programId,
15344
- associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID
16468
+ associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
16469
+ pretokenPurchaseHistory: a.pretokenPurchaseHistory
15345
16470
  }).instruction();
15346
16471
  }
15347
16472
  previewPretokens(params) {
@@ -15440,7 +16565,8 @@ class TokenClient {
15440
16565
  chainlinkProgram: a.chainLinkProgram ?? CHAINLINK_PROGRAM,
15441
16566
  tokenProgram: TOKEN_2022_PROGRAM_ID,
15442
16567
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
15443
- systemProgram: SystemProgram.programId
16568
+ systemProgram: SystemProgram.programId,
16569
+ pretokenPurchaseHistory: a.pretokenPurchaseHistory
15444
16570
  }).instruction();
15445
16571
  }
15446
16572
  async getSolPriceUsdSafe() {
@@ -15641,6 +16767,12 @@ class SolanaProgramService {
15641
16767
  this.ids.LIQSOL_CORE
15642
16768
  )[0];
15643
16769
  }
16770
+ derivePretokenPurchaseHistoryPda() {
16771
+ return PublicKey.findProgramAddressSync(
16772
+ [Buffer.from(PDA_SEEDS.PRETOKEN_PURCHASE_HISTORY)],
16773
+ this.ids.LIQSOL_CORE
16774
+ )[0];
16775
+ }
15644
16776
  deriveWithdrawNftMintPda(receiptId) {
15645
16777
  const receiptIdBytes = Buffer.alloc(8);
15646
16778
  const asBigInt = typeof receiptId === "bigint" ? receiptId : BigInt(receiptId.toString());
@@ -15872,6 +17004,17 @@ const _SolanaStakingClient = class _SolanaStakingClient {
15872
17004
  throw err;
15873
17005
  }
15874
17006
  }
17007
+ async claimLiqsolRewards() {
17008
+ this.ensureUser();
17009
+ const owner = this.squadsVaultPDA ?? this.anchor.wallet.publicKey;
17010
+ try {
17011
+ const ix = await this.distributionClient.buildClaimRewardsIx(owner);
17012
+ return !!this.squadsX ? await this.sendSquadsIxs(ix) : await this.buildAndSendIx(ix);
17013
+ } catch (err) {
17014
+ console.log(`Failed to claim liqSOL rewards on Solana: ${err}`);
17015
+ throw err;
17016
+ }
17017
+ }
15875
17018
  async stake(amountLamports) {
15876
17019
  this.ensureUser();
15877
17020
  if (!amountLamports || amountLamports <= BigInt(0))
@@ -15921,10 +17064,11 @@ const _SolanaStakingClient = class _SolanaStakingClient {
15921
17064
  TOKEN_2022_PROGRAM_ID,
15922
17065
  ASSOCIATED_TOKEN_PROGRAM_ID
15923
17066
  );
15924
- const [nativeLamports, actualBalResp, snapshot] = await Promise.all([
17067
+ const [nativeLamports, actualBalResp, snapshot, claimableLamports] = await Promise.all([
15925
17068
  this.connection.getBalance(user, "confirmed"),
15926
17069
  this.connection.getTokenAccountBalance(userLiqsolAta, "confirmed").catch(() => null),
15927
- this.outpostClient.fetchWireState(user).catch(() => null)
17070
+ this.outpostClient.fetchWireState(user).catch(() => null),
17071
+ this.distributionClient.getClaimableLiqsol(user).catch(() => new BN(0))
15928
17072
  ]);
15929
17073
  const LIQSOL_DECIMALS = 9;
15930
17074
  const actualAmountStr = actualBalResp?.value?.amount ?? "0";
@@ -15961,6 +17105,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
15961
17105
  decimals: LIQSOL_DECIMALS,
15962
17106
  ata: userLiqsolAta
15963
17107
  },
17108
+ claimable: {
17109
+ amount: BigInt(claimableLamports.toString()),
17110
+ symbol: "LiqSOL",
17111
+ decimals: LIQSOL_DECIMALS,
17112
+ ata: userLiqsolAta
17113
+ },
15964
17114
  staked: {
15965
17115
  amount: stakedLiqsol,
15966
17116
  symbol: "LiqSOL",
@@ -41534,6 +42684,9 @@ class EthereumStakingClient {
41534
42684
  get network() {
41535
42685
  return this.config.network;
41536
42686
  }
42687
+ get address() {
42688
+ return this.signer?.getAddress();
42689
+ }
41537
42690
  async deposit(amount) {
41538
42691
  this.ensureUser();
41539
42692
  const amountWei = BigNumber.isBigNumber(amount) ? amount : BigNumber.from(amount);
@@ -41542,14 +42695,14 @@ class EthereumStakingClient {
41542
42695
  }
41543
42696
  async withdraw(amount) {
41544
42697
  this.ensureUser();
41545
- const address = await this.signer.getAddress();
42698
+ const address = await this.address;
41546
42699
  const amountWei = BigNumber.from(amount);
41547
42700
  const result = await this.convertClient.performWithdraw(address, amountWei);
41548
42701
  return result.txHash;
41549
42702
  }
41550
42703
  async getPendingWithdraws() {
41551
42704
  this.ensureUser();
41552
- const address = await this.signer.getAddress();
42705
+ const address = await this.address;
41553
42706
  return await this.receiptClient.fetchWithdrawReceipts(address);
41554
42707
  }
41555
42708
  async claimWithdraw(tokenId) {
@@ -41560,7 +42713,7 @@ class EthereumStakingClient {
41560
42713
  }
41561
42714
  async stake(amount) {
41562
42715
  this.ensureUser();
41563
- const walletAddress = await this.signer.getAddress();
42716
+ const walletAddress = await this.address;
41564
42717
  const amountWei = BigNumber.from(amount);
41565
42718
  const result = await this.stakeClient.performStake(amountWei, walletAddress);
41566
42719
  return result.txHash;
@@ -41576,7 +42729,7 @@ class EthereumStakingClient {
41576
42729
  }
41577
42730
  async buy(amount) {
41578
42731
  this.ensureUser();
41579
- const buyer = await this.signer.getAddress();
42732
+ const buyer = await this.address;
41580
42733
  let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
41581
42734
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
41582
42735
  }
@@ -41588,7 +42741,7 @@ class EthereumStakingClient {
41588
42741
  async getPortfolio() {
41589
42742
  try {
41590
42743
  if (!this.signer) return Promise.resolve(null);
41591
- const walletAddress = await this.signer.getAddress();
42744
+ const walletAddress = await this.address;
41592
42745
  const nativeBalance = await this.provider.getBalance(walletAddress);
41593
42746
  const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
41594
42747
  const nativeSymbol = this.network?.nativeCurrency?.symbol ?? "ETH";
@@ -41666,12 +42819,12 @@ class EthereumStakingClient {
41666
42819
  }
41667
42820
  async fetchPrelaunchReceipts(address) {
41668
42821
  this.ensureUser();
41669
- if (address === void 0) address = await this.signer.getAddress();
42822
+ if (address === void 0) address = await this.address;
41670
42823
  return await this.receiptClient.stakeReceipts(address);
41671
42824
  }
41672
42825
  async getOPPMessages(address) {
41673
42826
  this.ensureUser();
41674
- if (!address) address = await this.signer.getAddress();
42827
+ if (!address) address = await this.address;
41675
42828
  return await this.oppClient.getMessages(address);
41676
42829
  }
41677
42830
  ensureUser() {
@@ -41746,7 +42899,7 @@ class EthereumStakingClient {
41746
42899
  }
41747
42900
  async getDepositBuffer(options) {
41748
42901
  this.ensureUser();
41749
- const walletAddress = await this.signer.getAddress();
42902
+ const walletAddress = await this.address;
41750
42903
  const baseGas = await this.provider.estimateGas({
41751
42904
  from: walletAddress,
41752
42905
  to: walletAddress,