@wireio/stake 0.4.1 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { Program, BN, AnchorProvider } from '@coral-xyz/anchor';
4
4
  import { getAssociatedTokenAddressSync, TOKEN_2022_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddress } from '@solana/spl-token';
5
5
  import { ethers, Contract, BigNumber } from 'ethers';
6
6
 
7
- var address$3 = "2qSsCXBYUSwF7zrzTT9jFpRpCmWoDpEyHr9exfCMq56P";
7
+ var address$3 = "5nBtmutQLrRKBUxNfHJPDjiW5u8id6QM9Hhjg1D1g1XH";
8
8
  var metadata$3 = {
9
9
  name: "liqsol_core",
10
10
  version: "0.1.0",
@@ -18,7 +18,8 @@ var instructions$3 = [
18
18
  "Accumulate unstake requests to be processed in next allocation cycle",
19
19
  "Multiple requests can be accumulated before calculating allocations",
20
20
  "Returns the target epoch when this unstake request will be processed",
21
- "We should not be able to"
21
+ "We should not be able to call this without development feature enabled",
22
+ ""
22
23
  ],
23
24
  discriminator: [
24
25
  24,
@@ -55,6 +56,12 @@ var instructions$3 = [
55
56
  "Maintenance ledger - to determine target processing epoch"
56
57
  ]
57
58
  },
59
+ {
60
+ name: "global_config",
61
+ docs: [
62
+ "Global config for min_unstake_request setting"
63
+ ]
64
+ },
58
65
  {
59
66
  name: "clock"
60
67
  }
@@ -106,6 +113,12 @@ var instructions$3 = [
106
113
  name: "processing_state",
107
114
  writable: true
108
115
  },
116
+ {
117
+ name: "global_config",
118
+ docs: [
119
+ "Global config for threshold parameters"
120
+ ]
121
+ },
109
122
  {
110
123
  name: "authority",
111
124
  signer: true
@@ -182,44 +195,6 @@ var instructions$3 = [
182
195
  }
183
196
  ]
184
197
  },
185
- {
186
- name: "advance_serviceability",
187
- docs: [
188
- "Advance the max servicable receipt ID"
189
- ],
190
- discriminator: [
191
- 139,
192
- 89,
193
- 79,
194
- 2,
195
- 90,
196
- 211,
197
- 173,
198
- 240
199
- ],
200
- accounts: [
201
- {
202
- name: "authority",
203
- docs: [
204
- "Authority that can update serviceable epoch"
205
- ],
206
- signer: true
207
- },
208
- {
209
- name: "global",
210
- writable: true
211
- },
212
- {
213
- name: "runtime_program"
214
- }
215
- ],
216
- args: [
217
- {
218
- name: "resolved_epoch",
219
- type: "u64"
220
- }
221
- ]
222
- },
223
198
  {
224
199
  name: "aggregate_stake_metrics",
225
200
  docs: [
@@ -381,6 +356,12 @@ var instructions$3 = [
381
356
  "Maintenance ledger - to track last unstake allocation epoch"
382
357
  ],
383
358
  writable: true
359
+ },
360
+ {
361
+ name: "global_config",
362
+ docs: [
363
+ "Global config for late epoch slot gate"
364
+ ]
384
365
  }
385
366
  ],
386
367
  args: [
@@ -445,6 +426,12 @@ var instructions$3 = [
445
426
  docs: [
446
427
  "Global withdraw operator state - to read total_encumbered_funds"
447
428
  ]
429
+ },
430
+ {
431
+ name: "global_config",
432
+ docs: [
433
+ "Global config for rebalancing thresholds"
434
+ ]
448
435
  }
449
436
  ],
450
437
  args: [
@@ -569,6 +556,12 @@ var instructions$3 = [
569
556
  {
570
557
  name: "stake_history"
571
558
  },
559
+ {
560
+ name: "global_config",
561
+ docs: [
562
+ "Global config for claim_withdrawals_enabled check"
563
+ ]
564
+ },
572
565
  {
573
566
  name: "token_program"
574
567
  },
@@ -621,6 +614,12 @@ var instructions$3 = [
621
614
  "Stake controller state - used to verify authority"
622
615
  ]
623
616
  },
617
+ {
618
+ name: "global_config",
619
+ docs: [
620
+ "Global config for cooldown_epochs"
621
+ ]
622
+ },
624
623
  {
625
624
  name: "clock"
626
625
  },
@@ -960,6 +959,12 @@ var instructions$3 = [
960
959
  name: "controller_state",
961
960
  writable: true
962
961
  },
962
+ {
963
+ name: "global_config",
964
+ docs: [
965
+ "Global config for deposit settings"
966
+ ]
967
+ },
963
968
  {
964
969
  name: "payout_state",
965
970
  writable: true
@@ -1096,47 +1101,6 @@ var instructions$3 = [
1096
1101
  }
1097
1102
  ]
1098
1103
  },
1099
- {
1100
- name: "force_validator_unstake",
1101
- docs: [
1102
- "A function you can call to directly influence the amount to unstake from a particular validator",
1103
- "Tbh this is a bypass of the system and should not be called unless you know what you are doing"
1104
- ],
1105
- discriminator: [
1106
- 7,
1107
- 208,
1108
- 146,
1109
- 241,
1110
- 10,
1111
- 219,
1112
- 109,
1113
- 30
1114
- ],
1115
- accounts: [
1116
- {
1117
- name: "admin",
1118
- writable: true,
1119
- signer: true
1120
- },
1121
- {
1122
- name: "validator_info",
1123
- docs: [
1124
- "Validator info account to update"
1125
- ],
1126
- writable: true
1127
- }
1128
- ],
1129
- args: [
1130
- {
1131
- name: "vote_account",
1132
- type: "pubkey"
1133
- },
1134
- {
1135
- name: "amount",
1136
- type: "u64"
1137
- }
1138
- ]
1139
- },
1140
1104
  {
1141
1105
  name: "get_min_max_resolved_epoch_deactivations",
1142
1106
  docs: [
@@ -1382,6 +1346,38 @@ var instructions$3 = [
1382
1346
  args: [
1383
1347
  ]
1384
1348
  },
1349
+ {
1350
+ name: "initialize_global_config",
1351
+ discriminator: [
1352
+ 113,
1353
+ 216,
1354
+ 122,
1355
+ 131,
1356
+ 225,
1357
+ 209,
1358
+ 22,
1359
+ 55
1360
+ ],
1361
+ accounts: [
1362
+ {
1363
+ name: "global_config",
1364
+ writable: true
1365
+ },
1366
+ {
1367
+ name: "controller_state"
1368
+ },
1369
+ {
1370
+ name: "payer",
1371
+ writable: true,
1372
+ signer: true
1373
+ },
1374
+ {
1375
+ name: "system_program"
1376
+ }
1377
+ ],
1378
+ args: [
1379
+ ]
1380
+ },
1385
1381
  {
1386
1382
  name: "initialize_graveyard_list",
1387
1383
  docs: [
@@ -1912,6 +1908,10 @@ var instructions$3 = [
1912
1908
  ],
1913
1909
  writable: true
1914
1910
  },
1911
+ {
1912
+ name: "withdraw_global",
1913
+ writable: true
1914
+ },
1915
1915
  {
1916
1916
  name: "stake_program"
1917
1917
  },
@@ -1976,6 +1976,12 @@ var instructions$3 = [
1976
1976
  name: "processing_state",
1977
1977
  writable: true
1978
1978
  },
1979
+ {
1980
+ name: "global_config",
1981
+ docs: [
1982
+ "Global config for late epoch slot gate"
1983
+ ]
1984
+ },
1979
1985
  {
1980
1986
  name: "clock"
1981
1987
  },
@@ -2050,6 +2056,12 @@ var instructions$3 = [
2050
2056
  },
2051
2057
  {
2052
2058
  name: "instructions"
2059
+ },
2060
+ {
2061
+ name: "global_config",
2062
+ docs: [
2063
+ "Global config for process_pay_cycle_enabled check"
2064
+ ]
2053
2065
  }
2054
2066
  ],
2055
2067
  args: [
@@ -2122,6 +2134,12 @@ var instructions$3 = [
2122
2134
  },
2123
2135
  {
2124
2136
  name: "rent"
2137
+ },
2138
+ {
2139
+ name: "global_config",
2140
+ docs: [
2141
+ "Global config for process_stake_orders_enabled check"
2142
+ ]
2125
2143
  }
2126
2144
  ],
2127
2145
  args: [
@@ -2231,6 +2249,12 @@ var instructions$3 = [
2231
2249
  },
2232
2250
  {
2233
2251
  name: "stake_program"
2252
+ },
2253
+ {
2254
+ name: "global_config",
2255
+ docs: [
2256
+ "Global config for process_unstake_orders_enabled check"
2257
+ ]
2234
2258
  }
2235
2259
  ],
2236
2260
  args: [
@@ -2508,6 +2532,12 @@ var instructions$3 = [
2508
2532
  },
2509
2533
  {
2510
2534
  name: "active_list"
2535
+ },
2536
+ {
2537
+ name: "global_config",
2538
+ docs: [
2539
+ "Global config for late epoch slot gate"
2540
+ ]
2511
2541
  }
2512
2542
  ],
2513
2543
  args: [
@@ -2549,6 +2579,12 @@ var instructions$3 = [
2549
2579
  },
2550
2580
  {
2551
2581
  name: "active_list"
2582
+ },
2583
+ {
2584
+ name: "global_config",
2585
+ docs: [
2586
+ "Global config for late epoch slot gate"
2587
+ ]
2552
2588
  }
2553
2589
  ],
2554
2590
  args: [
@@ -2643,6 +2679,12 @@ var instructions$3 = [
2643
2679
  {
2644
2680
  name: "allocation_state"
2645
2681
  },
2682
+ {
2683
+ name: "global_config",
2684
+ docs: [
2685
+ "Global config for late epoch slot gate"
2686
+ ]
2687
+ },
2646
2688
  {
2647
2689
  name: "authority",
2648
2690
  signer: true
@@ -2774,6 +2816,12 @@ var instructions$3 = [
2774
2816
  "Maintenance ledger - for accumulate_unstake_request"
2775
2817
  ]
2776
2818
  },
2819
+ {
2820
+ name: "global_config",
2821
+ docs: [
2822
+ "Global config for min_unstake_request setting"
2823
+ ]
2824
+ },
2777
2825
  {
2778
2826
  name: "clock"
2779
2827
  },
@@ -3155,6 +3203,12 @@ var instructions$3 = [
3155
3203
  name: "allocation_state",
3156
3204
  writable: true
3157
3205
  },
3206
+ {
3207
+ name: "global_config",
3208
+ docs: [
3209
+ "Global config for late epoch slot gate"
3210
+ ]
3211
+ },
3158
3212
  {
3159
3213
  name: "system_program",
3160
3214
  docs: [
@@ -3223,6 +3277,12 @@ var instructions$3 = [
3223
3277
  name: "maintenance_ledger",
3224
3278
  writable: true
3225
3279
  },
3280
+ {
3281
+ name: "global_config",
3282
+ docs: [
3283
+ "Global config for late epoch slot gate"
3284
+ ]
3285
+ },
3226
3286
  {
3227
3287
  name: "authority",
3228
3288
  signer: true
@@ -3232,37 +3292,32 @@ var instructions$3 = [
3232
3292
  ]
3233
3293
  },
3234
3294
  {
3235
- name: "sync_distribution_index",
3295
+ name: "sync_leaderboard_scores_batch",
3236
3296
  discriminator: [
3237
- 82,
3238
- 159,
3239
- 232,
3240
- 125,
3241
- 12,
3242
- 29,
3243
- 9,
3244
- 226
3297
+ 52,
3298
+ 11,
3299
+ 210,
3300
+ 173,
3301
+ 90,
3302
+ 5,
3303
+ 48,
3304
+ 50
3245
3305
  ],
3246
3306
  accounts: [
3247
3307
  {
3248
- name: "authority",
3249
- docs: [
3250
- "Admin or crank that triggers the index sync"
3251
- ],
3252
- signer: true
3308
+ name: "leaderboard_state"
3253
3309
  },
3254
3310
  {
3255
- name: "distribution_state",
3311
+ name: "processing_state",
3256
3312
  writable: true
3257
3313
  },
3258
3314
  {
3259
- name: "bucket_authority",
3260
- docs: [
3261
- "The bucket's associated token account holding liqSOL"
3262
- ]
3315
+ name: "maintenance_ledger",
3316
+ writable: true
3263
3317
  },
3264
3318
  {
3265
- name: "bucket_token_account"
3319
+ name: "authority",
3320
+ signer: true
3266
3321
  }
3267
3322
  ],
3268
3323
  args: [
@@ -3350,6 +3405,12 @@ var instructions$3 = [
3350
3405
  name: "maintenance_ledger",
3351
3406
  writable: true
3352
3407
  },
3408
+ {
3409
+ name: "global_config",
3410
+ docs: [
3411
+ "Global config for min_vpp_entry and min_vpp_exit"
3412
+ ]
3413
+ },
3353
3414
  {
3354
3415
  name: "authority",
3355
3416
  signer: true
@@ -3481,63 +3542,235 @@ var instructions$3 = [
3481
3542
  ]
3482
3543
  },
3483
3544
  {
3484
- name: "update_growth_parameters",
3545
+ name: "update_config_bool",
3485
3546
  discriminator: [
3486
- 172,
3487
- 187,
3488
- 237,
3489
- 233,
3490
- 250,
3491
- 160,
3492
- 115,
3493
- 239
3547
+ 79,
3548
+ 36,
3549
+ 65,
3550
+ 239,
3551
+ 188,
3552
+ 35,
3553
+ 13,
3554
+ 160
3494
3555
  ],
3495
3556
  accounts: [
3496
3557
  {
3497
- name: "admin",
3498
- writable: true,
3499
- signer: true
3500
- },
3501
- {
3502
- name: "tranche_state",
3558
+ name: "global_config",
3503
3559
  writable: true
3504
3560
  },
3505
3561
  {
3506
- name: "price_history",
3507
- writable: true
3562
+ name: "controller_state"
3508
3563
  },
3509
3564
  {
3510
- name: "system_program"
3565
+ name: "authority",
3566
+ docs: [
3567
+ "Authority must match StakeControllerState.authority"
3568
+ ],
3569
+ signer: true
3511
3570
  }
3512
3571
  ],
3513
3572
  args: [
3514
3573
  {
3515
- name: "supply_growth_bps",
3516
- type: "u16"
3574
+ name: "key",
3575
+ type: {
3576
+ defined: {
3577
+ name: "ConfigKeyBool"
3578
+ }
3579
+ }
3517
3580
  },
3518
3581
  {
3519
- name: "price_growth_bps",
3520
- type: "u16"
3582
+ name: "value",
3583
+ type: "bool"
3521
3584
  }
3522
3585
  ]
3523
3586
  },
3524
3587
  {
3525
- name: "update_price_bounds",
3588
+ name: "update_config_u16",
3526
3589
  discriminator: [
3527
- 241,
3528
- 116,
3529
- 141,
3530
- 65,
3531
- 61,
3532
- 95,
3533
- 232,
3534
- 28
3590
+ 149,
3591
+ 9,
3592
+ 244,
3593
+ 25,
3594
+ 46,
3595
+ 136,
3596
+ 59,
3597
+ 173
3535
3598
  ],
3536
3599
  accounts: [
3537
3600
  {
3538
- name: "admin",
3539
- writable: true,
3540
- signer: true
3601
+ name: "global_config",
3602
+ writable: true
3603
+ },
3604
+ {
3605
+ name: "controller_state"
3606
+ },
3607
+ {
3608
+ name: "authority",
3609
+ docs: [
3610
+ "Authority must match StakeControllerState.authority"
3611
+ ],
3612
+ signer: true
3613
+ }
3614
+ ],
3615
+ args: [
3616
+ {
3617
+ name: "key",
3618
+ type: {
3619
+ defined: {
3620
+ name: "ConfigKeyU16"
3621
+ }
3622
+ }
3623
+ },
3624
+ {
3625
+ name: "value",
3626
+ type: "u16"
3627
+ }
3628
+ ]
3629
+ },
3630
+ {
3631
+ name: "update_config_u64",
3632
+ discriminator: [
3633
+ 120,
3634
+ 43,
3635
+ 124,
3636
+ 106,
3637
+ 97,
3638
+ 80,
3639
+ 208,
3640
+ 123
3641
+ ],
3642
+ accounts: [
3643
+ {
3644
+ name: "global_config",
3645
+ writable: true
3646
+ },
3647
+ {
3648
+ name: "controller_state"
3649
+ },
3650
+ {
3651
+ name: "authority",
3652
+ docs: [
3653
+ "Authority must match StakeControllerState.authority"
3654
+ ],
3655
+ signer: true
3656
+ }
3657
+ ],
3658
+ args: [
3659
+ {
3660
+ name: "key",
3661
+ type: {
3662
+ defined: {
3663
+ name: "ConfigKeyU64"
3664
+ }
3665
+ }
3666
+ },
3667
+ {
3668
+ name: "value",
3669
+ type: "u64"
3670
+ }
3671
+ ]
3672
+ },
3673
+ {
3674
+ name: "update_config_u8",
3675
+ discriminator: [
3676
+ 17,
3677
+ 160,
3678
+ 31,
3679
+ 134,
3680
+ 222,
3681
+ 250,
3682
+ 229,
3683
+ 253
3684
+ ],
3685
+ accounts: [
3686
+ {
3687
+ name: "global_config",
3688
+ writable: true
3689
+ },
3690
+ {
3691
+ name: "controller_state"
3692
+ },
3693
+ {
3694
+ name: "authority",
3695
+ docs: [
3696
+ "Authority must match StakeControllerState.authority"
3697
+ ],
3698
+ signer: true
3699
+ }
3700
+ ],
3701
+ args: [
3702
+ {
3703
+ name: "key",
3704
+ type: {
3705
+ defined: {
3706
+ name: "ConfigKeyU8"
3707
+ }
3708
+ }
3709
+ },
3710
+ {
3711
+ name: "value",
3712
+ type: "u8"
3713
+ }
3714
+ ]
3715
+ },
3716
+ {
3717
+ name: "update_growth_parameters",
3718
+ discriminator: [
3719
+ 172,
3720
+ 187,
3721
+ 237,
3722
+ 233,
3723
+ 250,
3724
+ 160,
3725
+ 115,
3726
+ 239
3727
+ ],
3728
+ accounts: [
3729
+ {
3730
+ name: "admin",
3731
+ writable: true,
3732
+ signer: true
3733
+ },
3734
+ {
3735
+ name: "tranche_state",
3736
+ writable: true
3737
+ },
3738
+ {
3739
+ name: "price_history",
3740
+ writable: true
3741
+ },
3742
+ {
3743
+ name: "system_program"
3744
+ }
3745
+ ],
3746
+ args: [
3747
+ {
3748
+ name: "supply_growth_bps",
3749
+ type: "u16"
3750
+ },
3751
+ {
3752
+ name: "price_growth_bps",
3753
+ type: "u16"
3754
+ }
3755
+ ]
3756
+ },
3757
+ {
3758
+ name: "update_price_bounds",
3759
+ discriminator: [
3760
+ 241,
3761
+ 116,
3762
+ 141,
3763
+ 65,
3764
+ 61,
3765
+ 95,
3766
+ 232,
3767
+ 28
3768
+ ],
3769
+ accounts: [
3770
+ {
3771
+ name: "admin",
3772
+ writable: true,
3773
+ signer: true
3541
3774
  },
3542
3775
  {
3543
3776
  name: "tranche_state",
@@ -3554,11 +3787,11 @@ var instructions$3 = [
3554
3787
  args: [
3555
3788
  {
3556
3789
  name: "min_price_usd",
3557
- type: "i128"
3790
+ type: "u64"
3558
3791
  },
3559
3792
  {
3560
3793
  name: "max_price_usd",
3561
- type: "i128"
3794
+ type: "u64"
3562
3795
  },
3563
3796
  {
3564
3797
  name: "max_staleness_seconds",
@@ -3607,6 +3840,19 @@ var accounts$2 = [
3607
3840
  127
3608
3841
  ]
3609
3842
  },
3843
+ {
3844
+ name: "GlobalConfig",
3845
+ discriminator: [
3846
+ 149,
3847
+ 8,
3848
+ 156,
3849
+ 202,
3850
+ 160,
3851
+ 252,
3852
+ 176,
3853
+ 217
3854
+ ]
3855
+ },
3610
3856
  {
3611
3857
  name: "GlobalState",
3612
3858
  discriminator: [
@@ -4168,187 +4414,525 @@ var types$5 = [
4168
4414
  ],
4169
4415
  type: "u16"
4170
4416
  },
4417
+ {
4418
+ name: "leaderboard_scores_next_index",
4419
+ docs: [
4420
+ "Next leaderboard registry index to process for score sync"
4421
+ ],
4422
+ type: "u16"
4423
+ },
4171
4424
  {
4172
4425
  name: "removal_next_index",
4173
4426
  docs: [
4174
- "Next index in active list to check for removal"
4427
+ "Next index in active list to check for removal"
4428
+ ],
4429
+ type: "u16"
4430
+ },
4431
+ {
4432
+ name: "addition_next_rank",
4433
+ docs: [
4434
+ "Next rank in leaderboard to check for addition"
4435
+ ],
4436
+ type: "u16"
4437
+ },
4438
+ {
4439
+ name: "addition_target_rank",
4440
+ docs: [
4441
+ "Target (inclusive) leaderboard rank to process up to"
4442
+ ],
4443
+ type: "u16"
4444
+ },
4445
+ {
4446
+ name: "graveyard_next_index",
4447
+ docs: [
4448
+ "Next index in graveyard list to process"
4449
+ ],
4450
+ type: "u16"
4451
+ },
4452
+ {
4453
+ name: "graveyard_cleanup_next_index",
4454
+ docs: [
4455
+ "Next index in graveyard list to check for cleanup"
4456
+ ],
4457
+ type: "u16"
4458
+ },
4459
+ {
4460
+ name: "_reserved",
4461
+ type: {
4462
+ array: [
4463
+ "u8",
4464
+ 32
4465
+ ]
4466
+ }
4467
+ }
4468
+ ]
4469
+ }
4470
+ },
4471
+ {
4472
+ name: "ConfigKeyBool",
4473
+ docs: [
4474
+ "Keys for bool config values (feature flags) - stored as bits in a u16",
4475
+ "Bit positions: 0=Deposits, 1=Withdrawals, 2=ClaimWithdrawals, 3=ProcessStake,",
4476
+ "4=ProcessUnstake, 5=ProcessPayCycle, 6=Rebalancing, 7-15=Reserved"
4477
+ ],
4478
+ type: {
4479
+ kind: "enum",
4480
+ variants: [
4481
+ {
4482
+ name: "DepositsEnabled"
4483
+ },
4484
+ {
4485
+ name: "WithdrawalsEnabled"
4486
+ },
4487
+ {
4488
+ name: "ClaimWithdrawalsEnabled"
4489
+ },
4490
+ {
4491
+ name: "ProcessStakeOrdersEnabled"
4492
+ },
4493
+ {
4494
+ name: "ProcessUnstakeOrdersEnabled"
4495
+ },
4496
+ {
4497
+ name: "ProcessPayCycleEnabled"
4498
+ },
4499
+ {
4500
+ name: "RebalancingEnabled"
4501
+ }
4502
+ ]
4503
+ }
4504
+ },
4505
+ {
4506
+ name: "ConfigKeyU16",
4507
+ docs: [
4508
+ "Keys for u16 config values (small counts, thresholds, ranks)"
4509
+ ],
4510
+ type: {
4511
+ kind: "enum",
4512
+ variants: [
4513
+ {
4514
+ name: "CooldownEpochs"
4515
+ },
4516
+ {
4517
+ name: "DepositFeeEpochsMultiplier"
4518
+ },
4519
+ {
4520
+ name: "MinVppEntry"
4521
+ },
4522
+ {
4523
+ name: "MinVppExit"
4524
+ },
4525
+ {
4526
+ name: "TinyNetworkThreshold"
4527
+ },
4528
+ {
4529
+ name: "SmallNetworkThreshold"
4530
+ },
4531
+ {
4532
+ name: "MediumNetworkThreshold"
4533
+ },
4534
+ {
4535
+ name: "LargeNetworkEntryRank"
4536
+ },
4537
+ {
4538
+ name: "LargeNetworkExitRank"
4539
+ }
4540
+ ]
4541
+ }
4542
+ },
4543
+ {
4544
+ name: "ConfigKeyU64",
4545
+ docs: [
4546
+ "Keys for u64 config values (large amounts, rates)"
4547
+ ],
4548
+ type: {
4549
+ kind: "enum",
4550
+ variants: [
4551
+ {
4552
+ name: "MinUserDeposit"
4553
+ },
4554
+ {
4555
+ name: "MinUnstakeRequest"
4556
+ },
4557
+ {
4558
+ name: "MinRebalanceStakeDelta"
4559
+ },
4560
+ {
4561
+ name: "MinRebalanceUnstakeDelta"
4562
+ },
4563
+ {
4564
+ name: "TransientThreshold"
4565
+ },
4566
+ {
4567
+ name: "MinLateEpochSlotGate"
4568
+ }
4569
+ ]
4570
+ }
4571
+ },
4572
+ {
4573
+ name: "ConfigKeyU8",
4574
+ docs: [
4575
+ "Keys for u8 config values (percentages 0-100)"
4576
+ ],
4577
+ type: {
4578
+ kind: "enum",
4579
+ variants: [
4580
+ {
4581
+ name: "SmallNetworkEntryPercent"
4582
+ },
4583
+ {
4584
+ name: "SmallNetworkExitPercent"
4585
+ },
4586
+ {
4587
+ name: "MediumNetworkEntryPercent"
4588
+ },
4589
+ {
4590
+ name: "MediumNetworkExitPercent"
4591
+ }
4592
+ ]
4593
+ }
4594
+ },
4595
+ {
4596
+ name: "DistributionState",
4597
+ type: {
4598
+ kind: "struct",
4599
+ fields: [
4600
+ {
4601
+ name: "liqsol_mint",
4602
+ type: "pubkey"
4603
+ },
4604
+ {
4605
+ name: "current_index",
4606
+ type: "u64"
4607
+ },
4608
+ {
4609
+ name: "total_shares",
4610
+ docs: [
4611
+ "Sum of all user shares across the system"
4612
+ ],
4613
+ type: "u64"
4614
+ },
4615
+ {
4616
+ name: "last_bucket_balance",
4617
+ docs: [
4618
+ "Last observed bucket balance used for incremental index updates"
4619
+ ],
4620
+ type: "u64"
4621
+ },
4622
+ {
4623
+ name: "bump",
4624
+ type: "u8"
4625
+ },
4626
+ {
4627
+ name: "bucket_bump",
4628
+ docs: [
4629
+ "Cached bucket authority bump to avoid repeated find_program_address calls"
4630
+ ],
4631
+ type: "u8"
4632
+ },
4633
+ {
4634
+ name: "pool_bump",
4635
+ docs: [
4636
+ "Cached pool authority bump to avoid repeated find_program_address calls"
4637
+ ],
4638
+ type: "u8"
4639
+ },
4640
+ {
4641
+ name: "bucket_authority",
4642
+ docs: [
4643
+ "Cached bucket authority pubkey for transfer-hook optimization"
4644
+ ],
4645
+ type: "pubkey"
4646
+ },
4647
+ {
4648
+ name: "pool_authority",
4649
+ docs: [
4650
+ "Cached pool authority pubkey for transfer-hook optimization"
4651
+ ],
4652
+ type: "pubkey"
4653
+ }
4654
+ ]
4655
+ }
4656
+ },
4657
+ {
4658
+ name: "EpochResolved",
4659
+ type: {
4660
+ kind: "struct",
4661
+ fields: [
4662
+ {
4663
+ name: "validator",
4664
+ type: "pubkey"
4665
+ },
4666
+ {
4667
+ name: "epoch",
4668
+ type: "u64"
4669
+ },
4670
+ {
4671
+ name: "total_stake_amount",
4672
+ type: "u64"
4673
+ },
4674
+ {
4675
+ name: "max_index",
4676
+ type: "u32"
4677
+ }
4678
+ ]
4679
+ }
4680
+ },
4681
+ {
4682
+ name: "Global",
4683
+ docs: [
4684
+ "Global operator state. Epoch-based model: receipts are serviceable",
4685
+ "when `epoch <= serviceable_epoch` as reported by an external runtime."
4686
+ ],
4687
+ type: {
4688
+ kind: "struct",
4689
+ fields: [
4690
+ {
4691
+ name: "bump",
4692
+ type: "u8"
4693
+ },
4694
+ {
4695
+ name: "authority",
4696
+ docs: [
4697
+ "Authority that can update serviceable_epoch"
4698
+ ],
4699
+ type: "pubkey"
4700
+ },
4701
+ {
4702
+ name: "liqsol_mint",
4703
+ docs: [
4704
+ "Token-2022 liqSOL mint burned on withdraw."
4705
+ ],
4706
+ type: "pubkey"
4707
+ },
4708
+ {
4709
+ name: "serviceable_epoch",
4710
+ docs: [
4711
+ "Highest epoch that is currently claimable."
4712
+ ],
4713
+ type: "u64"
4714
+ },
4715
+ {
4716
+ name: "total_encumbered_funds",
4717
+ docs: [
4718
+ "Total SOL encumbered for pending withdrawal requests.",
4719
+ "This amount is reserved from the reserve pool and will be paid out when receipts are claimed."
4720
+ ],
4721
+ type: "u64"
4722
+ },
4723
+ {
4724
+ name: "next_receipt_id",
4725
+ docs: [
4726
+ "Monotonic counter for generating unique receipt IDs"
4727
+ ],
4728
+ type: "u64"
4729
+ }
4730
+ ]
4731
+ }
4732
+ },
4733
+ {
4734
+ name: "GlobalConfig",
4735
+ docs: [
4736
+ "Zero-copy global config PDA",
4737
+ "Authority is taken from StakeControllerState, not stored here"
4738
+ ],
4739
+ serialization: "bytemuckunsafe",
4740
+ repr: {
4741
+ kind: "c"
4742
+ },
4743
+ type: {
4744
+ kind: "struct",
4745
+ fields: [
4746
+ {
4747
+ name: "bump",
4748
+ type: "u8"
4749
+ },
4750
+ {
4751
+ name: "_padding",
4752
+ type: {
4753
+ array: [
4754
+ "u8",
4755
+ 7
4756
+ ]
4757
+ }
4758
+ },
4759
+ {
4760
+ name: "min_user_deposit",
4761
+ docs: [
4762
+ "Minimum SOL amount a user can deposit"
4763
+ ],
4764
+ type: "u64"
4765
+ },
4766
+ {
4767
+ name: "min_unstake_request",
4768
+ docs: [
4769
+ "Minimum SOL amount for an unstake/withdrawal request"
4175
4770
  ],
4176
- type: "u16"
4771
+ type: "u64"
4177
4772
  },
4178
4773
  {
4179
- name: "addition_next_rank",
4774
+ name: "min_rebalance_stake_delta",
4180
4775
  docs: [
4181
- "Next rank in leaderboard to check for addition"
4776
+ "Minimum stake delta to trigger a stake rebalance order"
4182
4777
  ],
4183
- type: "u16"
4778
+ type: "u64"
4184
4779
  },
4185
4780
  {
4186
- name: "addition_target_rank",
4781
+ name: "min_rebalance_unstake_delta",
4187
4782
  docs: [
4188
- "Target (inclusive) leaderboard rank to process up to"
4783
+ "Minimum unstake delta to trigger an unstake rebalance order"
4189
4784
  ],
4190
- type: "u16"
4785
+ type: "u64"
4191
4786
  },
4192
4787
  {
4193
- name: "graveyard_next_index",
4788
+ name: "transient_threshold",
4194
4789
  docs: [
4195
- "Next index in graveyard list to process"
4790
+ "Minimum transient stake to include in effective stake calculations"
4196
4791
  ],
4197
- type: "u16"
4792
+ type: "u64"
4198
4793
  },
4199
4794
  {
4200
- name: "graveyard_cleanup_next_index",
4795
+ name: "min_late_epoch_slot_gate",
4201
4796
  docs: [
4202
- "Next index in graveyard list to check for cleanup"
4797
+ "Minimum slots that must have elapsed in the epoch before late epoch operations can execute"
4203
4798
  ],
4204
- type: "u16"
4799
+ type: "u64"
4205
4800
  },
4206
4801
  {
4207
- name: "_reserved",
4802
+ name: "_reserved_u64",
4208
4803
  type: {
4209
4804
  array: [
4210
- "u8",
4211
- 32
4805
+ "u64",
4806
+ 2
4212
4807
  ]
4213
4808
  }
4214
- }
4215
- ]
4216
- }
4217
- },
4218
- {
4219
- name: "DistributionState",
4220
- type: {
4221
- kind: "struct",
4222
- fields: [
4223
- {
4224
- name: "liqsol_mint",
4225
- type: "pubkey"
4226
4809
  },
4227
4810
  {
4228
- name: "current_index",
4229
- type: "u64"
4811
+ name: "cooldown_epochs",
4812
+ docs: [
4813
+ "Epochs a validator must wait in the graveyard before it is booted. This begins after the last recorded state change"
4814
+ ],
4815
+ type: "u16"
4230
4816
  },
4231
4817
  {
4232
- name: "total_shares",
4818
+ name: "deposit_fee_multiplier",
4233
4819
  docs: [
4234
- "Sum of all user shares across the system"
4820
+ "Multiplier for deposit fee calculation, this would be average \"pay rate x number of epochs we expect the stake to warm up\""
4235
4821
  ],
4236
- type: "u64"
4822
+ type: "u16"
4237
4823
  },
4238
4824
  {
4239
- name: "last_bucket_balance",
4825
+ name: "min_vpp_entry",
4240
4826
  docs: [
4241
- "Last observed bucket balance used for incremental index updates"
4827
+ "Minimum VPP score required to enter the active validator set, this is a fall back for when the val set is really small"
4242
4828
  ],
4243
- type: "u64"
4829
+ type: "u16"
4244
4830
  },
4245
4831
  {
4246
- name: "bump",
4247
- type: "u8"
4832
+ name: "min_vpp_exit",
4833
+ docs: [
4834
+ "VPP score threshold below which a validator is removed from active set, again a fall back"
4835
+ ],
4836
+ type: "u16"
4248
4837
  },
4249
4838
  {
4250
- name: "bucket_bump",
4839
+ name: "tiny_network_threshold",
4251
4840
  docs: [
4252
- "Cached bucket authority bump to avoid repeated find_program_address calls"
4841
+ "Max validators for \"tiny\" network band (uses fixed VPP thresholds) as above"
4253
4842
  ],
4254
- type: "u8"
4843
+ type: "u16"
4255
4844
  },
4256
4845
  {
4257
- name: "pool_bump",
4846
+ name: "small_network_threshold",
4258
4847
  docs: [
4259
- "Cached pool authority bump to avoid repeated find_program_address calls"
4848
+ "Max validators for \"small\" network band (uses percentile-based selection)"
4260
4849
  ],
4261
- type: "u8"
4850
+ type: "u16"
4262
4851
  },
4263
4852
  {
4264
- name: "bucket_authority",
4853
+ name: "medium_network_threshold",
4265
4854
  docs: [
4266
- "Cached bucket authority pubkey for transfer-hook optimization"
4855
+ "Max validators for \"medium\" network band (uses percentile-based selection)"
4267
4856
  ],
4268
- type: "pubkey"
4857
+ type: "u16"
4269
4858
  },
4270
4859
  {
4271
- name: "pool_authority",
4860
+ name: "large_network_entry_rank",
4272
4861
  docs: [
4273
- "Cached pool authority pubkey for transfer-hook optimization"
4862
+ "Fixed rank threshold to enter active set in large networks (0-indexed)"
4274
4863
  ],
4275
- type: "pubkey"
4276
- }
4277
- ]
4278
- }
4279
- },
4280
- {
4281
- name: "EpochResolved",
4282
- type: {
4283
- kind: "struct",
4284
- fields: [
4285
- {
4286
- name: "validator",
4287
- type: "pubkey"
4864
+ type: "u16"
4288
4865
  },
4289
4866
  {
4290
- name: "epoch",
4291
- type: "u64"
4867
+ name: "large_network_exit_rank",
4868
+ docs: [
4869
+ "Fixed rank threshold to exit active set in large networks (0-indexed)"
4870
+ ],
4871
+ type: "u16"
4292
4872
  },
4293
4873
  {
4294
- name: "total_stake_amount",
4295
- type: "u64"
4874
+ name: "_reserved_u16",
4875
+ type: {
4876
+ array: [
4877
+ "u16",
4878
+ 3
4879
+ ]
4880
+ }
4296
4881
  },
4297
4882
  {
4298
- name: "max_index",
4299
- type: "u32"
4300
- }
4301
- ]
4302
- }
4303
- },
4304
- {
4305
- name: "Global",
4306
- docs: [
4307
- "Global operator state. Epoch-based model: receipts are serviceable",
4308
- "when `epoch <= serviceable_epoch` as reported by an external runtime."
4309
- ],
4310
- type: {
4311
- kind: "struct",
4312
- fields: [
4313
- {
4314
- name: "bump",
4883
+ name: "small_network_entry_percent",
4884
+ docs: [
4885
+ "Percentile rank required to enter active set in small networks"
4886
+ ],
4315
4887
  type: "u8"
4316
4888
  },
4317
4889
  {
4318
- name: "authority",
4890
+ name: "small_network_exit_percent",
4319
4891
  docs: [
4320
- "Authority that can update serviceable_epoch"
4892
+ "Percentile rank below which validators exit in small networks"
4321
4893
  ],
4322
- type: "pubkey"
4894
+ type: "u8"
4323
4895
  },
4324
4896
  {
4325
- name: "liqsol_mint",
4897
+ name: "medium_network_entry_percent",
4326
4898
  docs: [
4327
- "Token-2022 liqSOL mint burned on withdraw."
4899
+ "Percentile rank required to enter active set in medium networks"
4328
4900
  ],
4329
- type: "pubkey"
4901
+ type: "u8"
4330
4902
  },
4331
4903
  {
4332
- name: "serviceable_epoch",
4904
+ name: "medium_network_exit_percent",
4333
4905
  docs: [
4334
- "Highest epoch that is currently claimable."
4906
+ "Percentile rank below which validators exit in medium networks"
4335
4907
  ],
4336
- type: "u64"
4908
+ type: "u8"
4337
4909
  },
4338
4910
  {
4339
- name: "total_encumbered_funds",
4340
- docs: [
4341
- "Total SOL encumbered for pending withdrawal requests.",
4342
- "This amount is reserved from the reserve pool and will be paid out when receipts are claimed."
4343
- ],
4344
- type: "u64"
4911
+ name: "_reserved_u8",
4912
+ type: {
4913
+ array: [
4914
+ "u8",
4915
+ 2
4916
+ ]
4917
+ }
4345
4918
  },
4346
4919
  {
4347
- name: "next_receipt_id",
4920
+ name: "feature_flags",
4348
4921
  docs: [
4349
- "Monotonic counter for generating unique receipt IDs"
4922
+ "Bit 0: DepositsEnabled, Bit 1: WithdrawalsEnabled, Bit 2: ClaimWithdrawalsEnabled,",
4923
+ "Bit 3: ProcessStakeOrdersEnabled, Bit 4: ProcessUnstakeOrdersEnabled,",
4924
+ "Bit 5: ProcessPayCycleEnabled, Bit 6: RebalancingEnabled, Bits 7-15: Reserved"
4350
4925
  ],
4351
- type: "u64"
4926
+ type: "u16"
4927
+ },
4928
+ {
4929
+ name: "_reserved_flags",
4930
+ type: {
4931
+ array: [
4932
+ "u16",
4933
+ 1
4934
+ ]
4935
+ }
4352
4936
  }
4353
4937
  ]
4354
4938
  }
@@ -4619,6 +5203,10 @@ var types$5 = [
4619
5203
  name: "last_validator_score_sync_epoch",
4620
5204
  type: "u16"
4621
5205
  },
5206
+ {
5207
+ name: "last_leaderboard_scores_sync_epoch",
5208
+ type: "u16"
5209
+ },
4622
5210
  {
4623
5211
  name: "last_active_infos_synced_epoch",
4624
5212
  type: "u16"
@@ -4908,7 +5496,7 @@ var types$5 = [
4908
5496
  },
4909
5497
  {
4910
5498
  name: "pretokens_purchased",
4911
- type: "i128"
5499
+ type: "u64"
4912
5500
  }
4913
5501
  ]
4914
5502
  }
@@ -4936,7 +5524,7 @@ var types$5 = [
4936
5524
  ],
4937
5525
  type: {
4938
5526
  array: [
4939
- "i128",
5527
+ "u64",
4940
5528
  10
4941
5529
  ]
4942
5530
  }
@@ -5112,6 +5700,30 @@ var types$5 = [
5112
5700
  ],
5113
5701
  type: "u64"
5114
5702
  },
5703
+ {
5704
+ name: "is_small_distribution_mode",
5705
+ docs: [
5706
+ "Whether we're in small distribution mode (not enough for VPP-based distribution)",
5707
+ "In this mode, we distribute evenly to first N validators instead of using VPP ratios"
5708
+ ],
5709
+ type: "bool"
5710
+ },
5711
+ {
5712
+ name: "validators_to_fund_this_rebalance",
5713
+ docs: [
5714
+ "Number of validators to fund in small distribution mode",
5715
+ "Calculated as floor(total_to_distribute / MIN_STAKE_DELEGATION)"
5716
+ ],
5717
+ type: "u16"
5718
+ },
5719
+ {
5720
+ name: "amount_per_validator_this_rebalance",
5721
+ docs: [
5722
+ "Amount each validator gets in small distribution mode",
5723
+ "Calculated as total_to_distribute / validators_to_fund"
5724
+ ],
5725
+ type: "u64"
5726
+ },
5115
5727
  {
5116
5728
  name: "selection_entry_threshold_vpp",
5117
5729
  docs: [
@@ -5288,8 +5900,7 @@ var types$5 = [
5288
5900
  {
5289
5901
  name: "TrancheState",
5290
5902
  docs: [
5291
- "All i128 values use 8-decimal precision (SCALE = 1e8 = 100,000,000)",
5292
- "This matches Chainlink SOL/USD's native format, avoiding conversion overhead",
5903
+ "All u64 values use 8-decimal precision (SCALE = 1e8 = 100,000,000)",
5293
5904
  "Example: $193.32 is stored as 19332000000"
5294
5905
  ],
5295
5906
  type: {
@@ -5308,19 +5919,19 @@ var types$5 = [
5308
5919
  },
5309
5920
  {
5310
5921
  name: "current_tranche_supply",
5311
- type: "i128"
5922
+ type: "u64"
5312
5923
  },
5313
5924
  {
5314
5925
  name: "current_tranche_price_usd",
5315
- type: "i128"
5926
+ type: "u64"
5316
5927
  },
5317
5928
  {
5318
5929
  name: "total_pretokens_sold",
5319
- type: "i128"
5930
+ type: "u64"
5320
5931
  },
5321
5932
  {
5322
5933
  name: "initial_tranche_supply",
5323
- type: "i128"
5934
+ type: "u64"
5324
5935
  },
5325
5936
  {
5326
5937
  name: "supply_growth_bps",
@@ -5341,14 +5952,14 @@ var types$5 = [
5341
5952
  docs: [
5342
5953
  "Minimum valid SOL/USD price for validation (8-dec)"
5343
5954
  ],
5344
- type: "i128"
5955
+ type: "u64"
5345
5956
  },
5346
5957
  {
5347
5958
  name: "max_price_usd",
5348
5959
  docs: [
5349
5960
  "Maximum valid SOL/USD price for validation (8-dec)"
5350
5961
  ],
5351
- type: "i128"
5962
+ type: "u64"
5352
5963
  },
5353
5964
  {
5354
5965
  name: "max_staleness_seconds",
@@ -5393,7 +6004,7 @@ var types$5 = [
5393
6004
  },
5394
6005
  {
5395
6006
  name: "total_pretokens_purchased",
5396
- type: "i128"
6007
+ type: "u64"
5397
6008
  },
5398
6009
  {
5399
6010
  name: "last_tranche_number",
@@ -5401,7 +6012,7 @@ var types$5 = [
5401
6012
  },
5402
6013
  {
5403
6014
  name: "last_tranche_price_usd",
5404
- type: "i128"
6015
+ type: "u64"
5405
6016
  },
5406
6017
  {
5407
6018
  name: "bump",
@@ -5929,7 +6540,7 @@ var liqsolCoreIDL = {
5929
6540
  types: types$5
5930
6541
  };
5931
6542
 
5932
- var address$2 = "6hiJ8PrSyYLr7H9MA9VYh9fvGoHxZ2TXdDAMzjeUVSXZ";
6543
+ var address$2 = "5MRFSLCkXPEzfR6gkcZCVttq9g83mMUHyTZ85Z3TSpvU";
5933
6544
  var metadata$2 = {
5934
6545
  name: "liqsol_token",
5935
6546
  version: "0.1.0",
@@ -6118,7 +6729,7 @@ var liqsolTokenJson = {
6118
6729
  types: types$4
6119
6730
  };
6120
6731
 
6121
- var address$1 = "H6CWj2PgxCE9Z5dPi9nMrR2VxT1C4DQcqR1QjmLeon47";
6732
+ var address$1 = "5v7mWL1735qp2Th9B5WNf7spGynR5ZaxwyCYoQw13DP2";
6122
6733
  var metadata$1 = {
6123
6734
  name: "validator_leaderboard",
6124
6735
  version: "0.1.0",
@@ -6240,6 +6851,9 @@ var instructions$1 = [
6240
6851
  },
6241
6852
  {
6242
6853
  name: "system_program"
6854
+ },
6855
+ {
6856
+ name: "clock"
6243
6857
  }
6244
6858
  ],
6245
6859
  args: [
@@ -6847,7 +7461,7 @@ var validatorLeaderboardJson = {
6847
7461
  types: types$3
6848
7462
  };
6849
7463
 
6850
- var address = "EtqCLddkPNGjkgiH9rVUmK3M5X2FKFprQvgscBJ8g6hX";
7464
+ var address = "HbBpH9opFW9gcYVanHLweKuHhWQ8P3Kcc1mbpAx1vojz";
6851
7465
  var metadata = {
6852
7466
  name: "transfer_hook",
6853
7467
  version: "0.1.0",
@@ -6972,6 +7586,11 @@ var errors = [
6972
7586
  {
6973
7587
  code: 6002,
6974
7588
  name: "TlvAccountResolutionError"
7589
+ },
7590
+ {
7591
+ code: 6003,
7592
+ name: "CannotTransferToBucket",
7593
+ msg: "Cannot transfer liqSOL directly to bucket - only protocol minting is allowed"
6975
7594
  }
6976
7595
  ];
6977
7596
  var types$2 = [
@@ -7060,6 +7679,7 @@ const {
7060
7679
  TRANSFER_HOOK
7061
7680
  } = PROGRAM_IDS;
7062
7681
  const PDA_SEEDS = {
7682
+ GLOBAL_CONFIG: "global_config",
7063
7683
  DEPOSIT_AUTHORITY: "deposit_authority",
7064
7684
  VAULT: "vault",
7065
7685
  RESERVE_POOL: "reserve_pool",
@@ -7093,6 +7713,10 @@ const PDA_SEEDS = {
7093
7713
  LIQ_RECEIPT_DATA: "liq_receipt_data",
7094
7714
  WITHDRAW_MINT: "mint"
7095
7715
  };
7716
+ const deriveGlobalConfigPda = () => PublicKey.findProgramAddressSync(
7717
+ [Buffer.from(PDA_SEEDS.GLOBAL_CONFIG)],
7718
+ LIQSOL_CORE
7719
+ )[0];
7096
7720
  const deriveLiqsolMintPda = () => PublicKey.findProgramAddressSync(
7097
7721
  [Buffer.from(PDA_SEEDS.LIQSOL_MINT)],
7098
7722
  LIQSOL_TOKEN
@@ -7302,6 +7926,7 @@ class DepositClient {
7302
7926
  const payoutState = derivePayoutStatePda();
7303
7927
  const bucketAuthority = deriveBucketAuthorityPda();
7304
7928
  const payRateHistory = derivePayRateHistoryPda();
7929
+ const globalConfig = deriveGlobalConfigPda();
7305
7930
  const userAta = getAssociatedTokenAddressSync(
7306
7931
  liqsolMint,
7307
7932
  user,
@@ -7342,7 +7967,8 @@ class DepositClient {
7342
7967
  instructionsSysvar: SYSVAR_INSTRUCTIONS_PUBKEY,
7343
7968
  clock: SYSVAR_CLOCK_PUBKEY,
7344
7969
  stakeHistory: SYSVAR_STAKE_HISTORY_PUBKEY,
7345
- rent: SYSVAR_RENT_PUBKEY
7970
+ rent: SYSVAR_RENT_PUBKEY,
7971
+ globalConfig
7346
7972
  }).instruction();
7347
7973
  return new Transaction().add(ix);
7348
7974
  }
@@ -7371,6 +7997,7 @@ class DepositClient {
7371
7997
  const stakeAllocationState = deriveStakeAllocationStatePda();
7372
7998
  const stakeMetrics = deriveStakeMetricsPda();
7373
7999
  const maintenanceLedger = deriveMaintenanceLedgerPda();
8000
+ const globalConfig = deriveGlobalConfigPda();
7374
8001
  const globalState = await this.program.account.global.fetch(global);
7375
8002
  const receiptId = globalState.nextReceiptId.toBigInt();
7376
8003
  const mintAuthority = deriveWithdrawMintAuthorityPda();
@@ -7414,7 +8041,8 @@ class DepositClient {
7414
8041
  tokenInterface: TOKEN_2022_PROGRAM_ID,
7415
8042
  associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
7416
8043
  systemProgram: SystemProgram.programId,
7417
- rent: SYSVAR_RENT_PUBKEY
8044
+ rent: SYSVAR_RENT_PUBKEY,
8045
+ globalConfig
7418
8046
  }).instruction();
7419
8047
  return new Transaction().add(ix);
7420
8048
  }
@@ -8291,7 +8919,7 @@ class SolanaStakingClient {
8291
8919
  return this.config.network;
8292
8920
  }
8293
8921
  async deposit(amountLamports) {
8294
- this.ensureWriteAccess();
8922
+ this.ensureUser();
8295
8923
  if (amountLamports <= BigInt(0)) {
8296
8924
  throw new Error("Deposit amount must be greater than zero.");
8297
8925
  }
@@ -8304,7 +8932,7 @@ class SolanaStakingClient {
8304
8932
  });
8305
8933
  }
8306
8934
  async withdraw(amountLamports) {
8307
- this.ensureWriteAccess();
8935
+ this.ensureUser();
8308
8936
  if (amountLamports <= BigInt(0)) {
8309
8937
  throw new Error("Withdraw amount must be greater than zero.");
8310
8938
  }
@@ -8317,31 +8945,33 @@ class SolanaStakingClient {
8317
8945
  });
8318
8946
  }
8319
8947
  async stake(amountLamports) {
8320
- this.ensureWriteAccess();
8948
+ this.ensureUser();
8321
8949
  if (!amountLamports || amountLamports <= BigInt(0)) {
8322
8950
  throw new Error("Stake amount must be greater than zero.");
8323
8951
  }
8324
8952
  const user = this.solPubKey;
8953
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8325
8954
  const ix = await this.outpostClient.buildStakeIx(amountLamports, user);
8326
- const tx = new Transaction().add(ix);
8955
+ const tx = new Transaction().add(cuIx, ix);
8327
8956
  const prepared = await this.prepareTx(tx);
8328
8957
  const signed = await this.signTransaction(prepared.tx);
8329
8958
  return this.sendAndConfirmHttp(signed, prepared);
8330
8959
  }
8331
8960
  async unstake(amountLamports) {
8332
- this.ensureWriteAccess();
8961
+ this.ensureUser();
8333
8962
  if (!amountLamports || amountLamports <= BigInt(0)) {
8334
8963
  throw new Error("Unstake amount must be greater than zero.");
8335
8964
  }
8336
8965
  const user = this.solPubKey;
8966
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8337
8967
  const ix = await this.outpostClient.buildUnstakeIx(amountLamports, user);
8338
- const tx = new Transaction().add(ix);
8968
+ const tx = new Transaction().add(cuIx, ix);
8339
8969
  const prepared = await this.prepareTx(tx);
8340
8970
  const signed = await this.signTransaction(prepared.tx);
8341
8971
  return this.sendAndConfirmHttp(signed, prepared);
8342
8972
  }
8343
8973
  async buy(amountLamports) {
8344
- this.ensureWriteAccess();
8974
+ this.ensureUser();
8345
8975
  if (!amountLamports || amountLamports <= BigInt(0)) {
8346
8976
  throw new Error("liqSOL pretoken purchase requires a positive amount.");
8347
8977
  }
@@ -8389,12 +9019,12 @@ class SolanaStakingClient {
8389
9019
  const currentIndex = BigInt(currentIndexStr);
8390
9020
  const totalShares = BigInt(totalSharesStr);
8391
9021
  const userShares = BigInt(userSharesStr);
8392
- let estimatedClaimLiqsol = BigInt(0);
8393
- let estimatedYieldLiqsol = BigInt(0);
9022
+ let estimatedClaim = BigInt(0);
9023
+ let estimatedYield = BigInt(0);
8394
9024
  if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
8395
- estimatedClaimLiqsol = userShares * currentIndex / INDEX_SCALE$1;
8396
- if (estimatedClaimLiqsol > stakedLiqsol) {
8397
- estimatedYieldLiqsol = estimatedClaimLiqsol - stakedLiqsol;
9025
+ estimatedClaim = userShares * currentIndex / INDEX_SCALE$1;
9026
+ if (estimatedClaim > stakedLiqsol) {
9027
+ estimatedYield = estimatedClaim - stakedLiqsol;
8398
9028
  }
8399
9029
  }
8400
9030
  return {
@@ -8424,8 +9054,8 @@ class SolanaStakingClient {
8424
9054
  indexScale: INDEX_SCALE$1,
8425
9055
  totalShares,
8426
9056
  userShares,
8427
- estimatedClaimLiqsol,
8428
- estimatedYieldLiqsol
9057
+ estimatedClaim,
9058
+ estimatedYield
8429
9059
  },
8430
9060
  extras: {
8431
9061
  userLiqsolAta: userLiqsolAta.toBase58(),
@@ -8439,6 +9069,16 @@ class SolanaStakingClient {
8439
9069
  chainID: this.network.chainId
8440
9070
  };
8441
9071
  }
9072
+ async getUserRecord() {
9073
+ if (!this.pubKey) throw new Error("User pubKey is undefined");
9074
+ return this.distributionClient.getUserRecord(this.solPubKey);
9075
+ }
9076
+ getSystemAPY() {
9077
+ return Promise.resolve(0);
9078
+ }
9079
+ getDepositFee(amount) {
9080
+ return Promise.resolve(amount * BigInt(1) / BigInt(100));
9081
+ }
8442
9082
  async getTrancheSnapshot(options) {
8443
9083
  const {
8444
9084
  chainID = SolChainID.WireTestnet,
@@ -8460,12 +9100,8 @@ class SolanaStakingClient {
8460
9100
  ladderWindowAfter: windowAfter
8461
9101
  });
8462
9102
  }
8463
- async getUserRecord() {
8464
- if (!this.pubKey) throw new Error("User pubKey is undefined");
8465
- return this.distributionClient.getUserRecord(this.solPubKey);
8466
- }
8467
9103
  async sendAndConfirmHttp(signed, ctx) {
8468
- this.ensureWriteAccess();
9104
+ this.ensureUser();
8469
9105
  const signature = await this.connection.sendRawTransaction(
8470
9106
  signed.serialize(),
8471
9107
  {
@@ -8490,11 +9126,11 @@ class SolanaStakingClient {
8490
9126
  return signature;
8491
9127
  }
8492
9128
  async signTransaction(tx) {
8493
- this.ensureWriteAccess();
9129
+ this.ensureUser();
8494
9130
  return this.anchor.wallet.signTransaction(tx);
8495
9131
  }
8496
9132
  async sendTransaction(signed) {
8497
- this.ensureWriteAccess();
9133
+ this.ensureUser();
8498
9134
  return this.anchor.sendAndConfirm(signed);
8499
9135
  }
8500
9136
  async prepareTx(tx) {
@@ -8503,7 +9139,7 @@ class SolanaStakingClient {
8503
9139
  tx.feePayer = this.solPubKey;
8504
9140
  return { tx, blockhash, lastValidBlockHeight };
8505
9141
  }
8506
- ensureWriteAccess() {
9142
+ ensureUser() {
8507
9143
  if (!this.pubKey || !this.anchor.wallet.publicKey) {
8508
9144
  throw new Error("User Authorization required: pubKey is undefined");
8509
9145
  }
@@ -29135,8 +29771,12 @@ class EthereumStakingClient {
29135
29771
  constructor(config) {
29136
29772
  this.config = config;
29137
29773
  try {
29138
- this.provider = config.provider;
29139
- this.signer = this.provider.getSigner();
29774
+ if (config.provider) {
29775
+ this.provider = config.provider;
29776
+ this.signer = this.provider.getSigner();
29777
+ } else {
29778
+ this.provider = new ethers.providers.JsonRpcProvider(config.network.rpcUrls[0]);
29779
+ }
29140
29780
  this.pubKey = config.pubKey;
29141
29781
  this.contractService = new EthereumContractService({
29142
29782
  provider: this.provider,
@@ -29158,17 +29798,20 @@ class EthereumStakingClient {
29158
29798
  return this.config.network;
29159
29799
  }
29160
29800
  async deposit(amount) {
29801
+ this.ensureUser();
29161
29802
  const amountWei = BigNumber.isBigNumber(amount) ? amount : BigNumber.from(amount);
29162
29803
  const result = await this.convertClient.performDeposit(amountWei);
29163
29804
  return result.txHash;
29164
29805
  }
29165
29806
  async withdraw(amount) {
29807
+ this.ensureUser();
29166
29808
  const address = await this.signer.getAddress();
29167
29809
  const amountWei = BigNumber.from(amount);
29168
29810
  const result = await this.convertClient.performWithdraw(address, amountWei);
29169
29811
  return result.txHash;
29170
29812
  }
29171
29813
  async stake(amount) {
29814
+ this.ensureUser();
29172
29815
  const walletAddress = await this.signer.getAddress();
29173
29816
  const amountWei = BigNumber.from(amount);
29174
29817
  const result = await this.stakeClient.performStake(amountWei, walletAddress);
@@ -29178,38 +29821,20 @@ class EthereumStakingClient {
29178
29821
  throw new Error("Method not yet implemented.");
29179
29822
  }
29180
29823
  async unstakePrelaunch(tokenId, recipient) {
29824
+ this.ensureUser();
29181
29825
  const tokenIdBigNum = BigNumber.from(tokenId);
29182
29826
  const result = await this.stakeClient.performWithdrawStake(tokenIdBigNum, recipient);
29183
29827
  return result.txHash;
29184
29828
  }
29185
29829
  async buy(amount) {
29830
+ this.ensureUser();
29186
29831
  const buyer = await this.signer.getAddress();
29187
29832
  await this.updateMockAggregatorPrice();
29188
29833
  let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
29189
29834
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
29190
29835
  }
29191
- async getOPPMessages(address) {
29192
- if (!address) address = await this.signer.getAddress();
29193
- return await this.oppClient.getMessages(address);
29194
- }
29195
- async getOPPStatus() {
29196
- return await this.oppClient.getStatus();
29197
- }
29198
- async fetchPrelaunchReceipts(address) {
29199
- if (address === void 0) address = await this.signer.getAddress();
29200
- return await this.receiptClient.stakeReceipts(address);
29201
- }
29202
- async getEthStats() {
29203
- let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
29204
- let minDeposit = await this.contract.DepositManager.minDeposit();
29205
- let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
29206
- return {
29207
- withdrawDelay,
29208
- minDeposit,
29209
- rewardCooldown
29210
- };
29211
- }
29212
29836
  async getPortfolio() {
29837
+ this.ensureUser();
29213
29838
  const walletAddress = await this.signer.getAddress();
29214
29839
  const nativeBalance = await this.provider.getBalance(walletAddress);
29215
29840
  const nativeDecimals = this.network?.nativeCurrency?.decimals ?? 18;
@@ -29221,7 +29846,28 @@ class EthereumStakingClient {
29221
29846
  for (let r of stakeReceipts) {
29222
29847
  stakeBalanceBN = stakeBalanceBN.add(BigNumber.from(r.receipt.principal.amount));
29223
29848
  }
29849
+ let stakeSharesBN = BigNumber.from(0);
29850
+ for (let r of stakeReceipts) {
29851
+ stakeSharesBN = stakeSharesBN.add(BigNumber.from(r.receipt.shares.amount));
29852
+ }
29224
29853
  const wireBalance = await this.contract.Pretoken.balanceOf(walletAddress);
29854
+ let currentIndex = BigInt(0);
29855
+ let totalShares = BigInt(0);
29856
+ let userShares = BigInt(0);
29857
+ const indexScale = BigInt(1e27);
29858
+ try {
29859
+ const [indexBn, totalSharesBn] = await Promise.all([
29860
+ this.contract.Depositor.index().catch(() => BigNumber.from(0)),
29861
+ this.contract.Depositor.totalShares().catch(() => BigNumber.from(0))
29862
+ ]);
29863
+ const userSharesBn = stakeSharesBN;
29864
+ currentIndex = BigInt(indexBn.toString());
29865
+ totalShares = BigInt(totalSharesBn.toString());
29866
+ userShares = BigInt(userSharesBn.toString());
29867
+ } catch {
29868
+ }
29869
+ let estimatedClaim = BigInt(0);
29870
+ let estimatedYield = BigInt(0);
29225
29871
  const portfolio = {
29226
29872
  native: {
29227
29873
  amount: nativeBalance.toBigInt(),
@@ -29243,10 +29889,56 @@ class EthereumStakingClient {
29243
29889
  decimals: 18,
29244
29890
  symbol: "$WIRE"
29245
29891
  },
29892
+ yield: {
29893
+ currentIndex,
29894
+ indexScale,
29895
+ totalShares,
29896
+ userShares,
29897
+ estimatedClaim,
29898
+ estimatedYield
29899
+ },
29246
29900
  chainID: this.network.chainId
29247
29901
  };
29248
29902
  return portfolio;
29249
29903
  }
29904
+ async fetchPrelaunchReceipts(address) {
29905
+ this.ensureUser();
29906
+ if (address === void 0) address = await this.signer.getAddress();
29907
+ return await this.receiptClient.stakeReceipts(address);
29908
+ }
29909
+ async getOPPMessages(address) {
29910
+ this.ensureUser();
29911
+ if (!address) address = await this.signer.getAddress();
29912
+ return await this.oppClient.getMessages(address);
29913
+ }
29914
+ ensureUser() {
29915
+ if (!this.signer) {
29916
+ throw new Error(
29917
+ "EthereumStakingClient: write operation requires a wallet-connected Web3 provider"
29918
+ );
29919
+ }
29920
+ }
29921
+ async getSystemAPY() {
29922
+ const annualBpsBn = await this.contract.DepositManager.dailyRateBPS();
29923
+ return annualBpsBn.toNumber() / 1e4;
29924
+ }
29925
+ async getDepositFee(amountWei) {
29926
+ const feeBn = await this.contract.DepositManager.procFee(amountWei);
29927
+ return BigInt(feeBn.toString());
29928
+ }
29929
+ async getOPPStatus() {
29930
+ return await this.oppClient.getStatus();
29931
+ }
29932
+ async getEthStats() {
29933
+ let withdrawDelay = await this.contract.DepositManager.withdrawDelay();
29934
+ let minDeposit = await this.contract.DepositManager.minDeposit();
29935
+ let rewardCooldown = await this.contract.DepositManager.rewardCooldown();
29936
+ return {
29937
+ withdrawDelay,
29938
+ minDeposit,
29939
+ rewardCooldown
29940
+ };
29941
+ }
29250
29942
  async getTrancheSnapshot(options) {
29251
29943
  const {
29252
29944
  chainID = EvmChainID.Hoodi,
@@ -29386,5 +30078,5 @@ var types = /*#__PURE__*/Object.freeze({
29386
30078
  __proto__: null
29387
30079
  });
29388
30080
 
29389
- export { ADDRESSES, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DepositClient, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, INDEX_SCALE$1 as INDEX_SCALE, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, PurchaseAsset, ReceiptNFTKind, types as SOL, SolanaStakingClient, Staker, TRANSFER_HOOK, TokenClient, VALIDATOR_LEADERBOARD, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, calculateExpectedFee, deriveBarConfigPda, deriveBondLevelPda, deriveBondedActorPda, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveExtraAccountMetaListPda, deriveLeaderboardStatePda, deriveLiqReceiptDataPda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, deriveMaintenanceLedgerPda, deriveOutpostAccountPda, deriveOutpostGlobalStatePda, deriveOutpostPoolAuthorityPda, derivePayRateHistoryPda, derivePayoutStatePda, derivePriceHistoryPda, deriveReservePoolPda, deriveStakeAllocationStatePda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveStakeMetricsPda, deriveTrancheStatePda, deriveUserPretokenRecordPda, deriveUserRecordPda, deriveValidatorRecordPda, deriveVaultPda, deriveWithdrawGlobalPda, deriveWithdrawMintAuthorityPda, deriveWithdrawMintMetadataPda, deriveWithdrawNftMintPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
30081
+ export { ADDRESSES, CHAINLINK_FEED, CHAINLINK_PROGRAM, CONTRACTS, DEFAULT_AVERAGE_PAY_RATE, DEFAULT_PAY_RATE_LOOKBACK, DepositClient, DistributionClient, EPHEMERAL_RENT_EXEMPTION, ERC1155Abi, ERC20Abi, ERC721Abi, types$1 as ETH, EthereumContractService, EthereumStakingClient, INDEX_SCALE$1 as INDEX_SCALE, LAMPORTS_PER_SOL, LIQSOL_CORE, LIQSOL_TOKEN, LeaderboardClient, OutpostClient, PAY_RATE_SCALE_FACTOR, PDA_SEEDS, PROGRAM_IDS, PurchaseAsset, ReceiptNFTKind, types as SOL, SolanaStakingClient, Staker, TRANSFER_HOOK, TokenClient, VALIDATOR_LEADERBOARD, airdropSol, buildOutpostAccounts, buildSolanaTrancheLadder, buildSolanaTrancheSnapshot, calculateExpectedFee, deriveBarConfigPda, deriveBondLevelPda, deriveBondedActorPda, deriveBucketAuthorityPda, deriveDepositAuthorityPda, deriveDistributionStatePda, deriveEphemeralStakeAddress, deriveExtraAccountMetaListPda, deriveGlobalConfigPda, deriveLeaderboardStatePda, deriveLiqReceiptDataPda, deriveLiqsolMintAuthorityPda, deriveLiqsolMintPda, deriveMaintenanceLedgerPda, deriveOutpostAccountPda, deriveOutpostGlobalStatePda, deriveOutpostPoolAuthorityPda, derivePayRateHistoryPda, derivePayoutStatePda, derivePriceHistoryPda, deriveReservePoolPda, deriveStakeAllocationStatePda, deriveStakeControllerStatePda, deriveStakeControllerVaultPda, deriveStakeMetricsPda, deriveTrancheStatePda, deriveUserPretokenRecordPda, deriveUserRecordPda, deriveValidatorRecordPda, deriveVaultPda, deriveWithdrawGlobalPda, deriveWithdrawMintAuthorityPda, deriveWithdrawMintMetadataPda, deriveWithdrawNftMintPda, generateRandomDepositAmount, generateTestKeypair, getAveragePayRate, getBucketLiqSolBalance, getEpochSnapshot, getErrorMessage, getLiqsolCoreProgram, getPayoutStateRaw, getReservePoolBalance, getStakeControllerStateRaw, getUserLiqSolBalance, getUserRecordRaw, lamportsToSol, msToEpochEnd, previewDepositEffects, scheduledInstruction, sleep, solToLamports, toBigint, tokensToShares, waitForConfirmation, waitUntilSafeToExecuteFunction };
29390
30082
  //# sourceMappingURL=stake.browser.js.map