@wireio/stake 0.7.3 → 1.0.1

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.
package/lib/stake.m.js CHANGED
@@ -12,68 +12,6 @@ var metadata$3 = {
12
12
  description: "Created with Anchor"
13
13
  };
14
14
  var instructions$3 = [
15
- {
16
- name: "accumulate_unstake_request",
17
- docs: [
18
- "Accumulate unstake requests to be processed in next allocation cycle",
19
- "Multiple requests can be accumulated before calculating allocations",
20
- "Returns the target epoch when this unstake request will be processed",
21
- "We should not be able to call this without development feature enabled",
22
- ""
23
- ],
24
- discriminator: [
25
- 24,
26
- 73,
27
- 69,
28
- 139,
29
- 36,
30
- 209,
31
- 105,
32
- 252
33
- ],
34
- accounts: [
35
- {
36
- name: "admin",
37
- writable: true,
38
- signer: true
39
- },
40
- {
41
- name: "stake_allocation_state",
42
- docs: [
43
- "Stake allocation state - to accumulate pending unstake requests"
44
- ],
45
- writable: true
46
- },
47
- {
48
- name: "stake_metrics",
49
- docs: [
50
- "Stake metrics - to validate total unstake amount is available"
51
- ]
52
- },
53
- {
54
- name: "maintenance_ledger",
55
- docs: [
56
- "Maintenance ledger - to determine target processing epoch"
57
- ]
58
- },
59
- {
60
- name: "global_config",
61
- docs: [
62
- "Global config for min_unstake_request setting"
63
- ]
64
- },
65
- {
66
- name: "clock"
67
- }
68
- ],
69
- args: [
70
- {
71
- name: "amount",
72
- type: "u64"
73
- }
74
- ],
75
- returns: "u64"
76
- },
77
15
  {
78
16
  name: "add_top_performers_batch",
79
17
  docs: [
@@ -127,74 +65,6 @@ var instructions$3 = [
127
65
  args: [
128
66
  ]
129
67
  },
130
- {
131
- name: "add_validator_v2",
132
- docs: [
133
- "Add a new validator bbypassing the looking at leaderboard and getting validators form there"
134
- ],
135
- discriminator: [
136
- 217,
137
- 158,
138
- 30,
139
- 19,
140
- 123,
141
- 99,
142
- 110,
143
- 30
144
- ],
145
- accounts: [
146
- {
147
- name: "authority",
148
- writable: true,
149
- signer: true
150
- },
151
- {
152
- name: "active_list",
153
- docs: [
154
- "Active list - will add the validator here"
155
- ],
156
- writable: true
157
- },
158
- {
159
- name: "validator_info",
160
- docs: [
161
- "Create the validator info account"
162
- ],
163
- writable: true
164
- },
165
- {
166
- name: "validator_transient",
167
- docs: [
168
- "Create the validator transient account"
169
- ],
170
- writable: true
171
- },
172
- {
173
- name: "stake_allocation_state",
174
- docs: [
175
- "Stake allocation state - to update total_active_vpp when adding validator"
176
- ],
177
- writable: true
178
- },
179
- {
180
- name: "system_program"
181
- }
182
- ],
183
- args: [
184
- {
185
- name: "vote_account",
186
- type: "pubkey"
187
- },
188
- {
189
- name: "name",
190
- type: "string"
191
- },
192
- {
193
- name: "performance_score",
194
- type: "u8"
195
- }
196
- ]
197
- },
198
68
  {
199
69
  name: "aggregate_stake_metrics",
200
70
  docs: [
@@ -234,43 +104,6 @@ var instructions$3 = [
234
104
  args: [
235
105
  ]
236
106
  },
237
- {
238
- name: "blacklist_validator",
239
- docs: [
240
- "Blacklist a validator (user-facing, maintenance will handle graveyard movement)",
241
- "UnderPerforming is set automatically when score is updated",
242
- "Another serious emergency stop function"
243
- ],
244
- discriminator: [
245
- 125,
246
- 42,
247
- 36,
248
- 229,
249
- 27,
250
- 38,
251
- 226,
252
- 62
253
- ],
254
- accounts: [
255
- {
256
- name: "validator_info",
257
- writable: true
258
- },
259
- {
260
- name: "stake_allocation_state",
261
- docs: [
262
- "Stake allocation state - to update total_active_vpp when VPP changes"
263
- ],
264
- writable: true
265
- }
266
- ],
267
- args: [
268
- {
269
- name: "vote_account",
270
- type: "pubkey"
271
- }
272
- ]
273
- },
274
107
  {
275
108
  name: "bond_role",
276
109
  discriminator: [
@@ -2860,147 +2693,6 @@ var instructions$3 = [
2860
2693
  }
2861
2694
  ]
2862
2695
  },
2863
- {
2864
- name: "reset_distribution_state",
2865
- discriminator: [
2866
- 159,
2867
- 183,
2868
- 162,
2869
- 74,
2870
- 228,
2871
- 135,
2872
- 157,
2873
- 79
2874
- ],
2875
- accounts: [
2876
- {
2877
- name: "admin",
2878
- signer: true
2879
- },
2880
- {
2881
- name: "distribution_state",
2882
- writable: true
2883
- }
2884
- ],
2885
- args: [
2886
- ]
2887
- },
2888
- {
2889
- name: "reset_global_state",
2890
- discriminator: [
2891
- 252,
2892
- 41,
2893
- 117,
2894
- 110,
2895
- 248,
2896
- 165,
2897
- 48,
2898
- 88
2899
- ],
2900
- accounts: [
2901
- {
2902
- name: "admin",
2903
- signer: true
2904
- },
2905
- {
2906
- name: "global_config"
2907
- },
2908
- {
2909
- name: "global_state",
2910
- writable: true
2911
- },
2912
- {
2913
- name: "pool_authority"
2914
- },
2915
- {
2916
- name: "liqsol_mint"
2917
- },
2918
- {
2919
- name: "liqsol_pool_ata",
2920
- writable: true
2921
- },
2922
- {
2923
- name: "token_program"
2924
- },
2925
- {
2926
- name: "associated_token_program"
2927
- }
2928
- ],
2929
- args: [
2930
- ]
2931
- },
2932
- {
2933
- name: "reset_price_history",
2934
- discriminator: [
2935
- 213,
2936
- 231,
2937
- 155,
2938
- 139,
2939
- 248,
2940
- 60,
2941
- 67,
2942
- 199
2943
- ],
2944
- accounts: [
2945
- {
2946
- name: "admin",
2947
- writable: true,
2948
- signer: true
2949
- },
2950
- {
2951
- name: "global_config"
2952
- },
2953
- {
2954
- name: "tranche_state",
2955
- writable: true
2956
- },
2957
- {
2958
- name: "price_history",
2959
- writable: true
2960
- },
2961
- {
2962
- name: "system_program"
2963
- }
2964
- ],
2965
- args: [
2966
- ]
2967
- },
2968
- {
2969
- name: "reset_tranche_state",
2970
- discriminator: [
2971
- 106,
2972
- 102,
2973
- 143,
2974
- 40,
2975
- 152,
2976
- 173,
2977
- 165,
2978
- 168
2979
- ],
2980
- accounts: [
2981
- {
2982
- name: "admin",
2983
- writable: true,
2984
- signer: true
2985
- },
2986
- {
2987
- name: "global_config"
2988
- },
2989
- {
2990
- name: "tranche_state",
2991
- writable: true
2992
- },
2993
- {
2994
- name: "price_history",
2995
- writable: true
2996
- },
2997
- {
2998
- name: "system_program"
2999
- }
3000
- ],
3001
- args: [
3002
- ]
3003
- },
3004
2696
  {
3005
2697
  name: "set_admin",
3006
2698
  discriminator: [
@@ -3023,8 +2715,7 @@ var instructions$3 = [
3023
2715
  signer: true
3024
2716
  },
3025
2717
  {
3026
- name: "new_authority",
3027
- signer: true
2718
+ name: "new_authority"
3028
2719
  }
3029
2720
  ],
3030
2721
  args: [
@@ -3052,50 +2743,10 @@ var instructions$3 = [
3052
2743
  signer: true
3053
2744
  },
3054
2745
  {
3055
- name: "new_authority",
3056
- signer: true
3057
- }
3058
- ],
3059
- args: [
3060
- ]
3061
- },
3062
- {
3063
- name: "set_last_state_change_epoch",
3064
- docs: [
3065
- "Admin function to directly set last_state_change_epoch (useful for testing cooldowns)"
3066
- ],
3067
- discriminator: [
3068
- 94,
3069
- 57,
3070
- 139,
3071
- 195,
3072
- 123,
3073
- 224,
3074
- 227,
3075
- 106
3076
- ],
3077
- accounts: [
3078
- {
3079
- name: "validator_info",
3080
- writable: true
3081
- },
3082
- {
3083
- name: "stake_allocation_state",
3084
- docs: [
3085
- "Stake allocation state - to update total_active_vpp when VPP changes"
3086
- ],
3087
- writable: true
2746
+ name: "new_authority"
3088
2747
  }
3089
2748
  ],
3090
2749
  args: [
3091
- {
3092
- name: "vote_account",
3093
- type: "pubkey"
3094
- },
3095
- {
3096
- name: "epoch",
3097
- type: "u16"
3098
- }
3099
2750
  ]
3100
2751
  },
3101
2752
  {
@@ -3587,35 +3238,6 @@ var instructions$3 = [
3587
3238
  }
3588
3239
  ]
3589
3240
  },
3590
- {
3591
- name: "test_clear_active_list",
3592
- discriminator: [
3593
- 17,
3594
- 195,
3595
- 59,
3596
- 174,
3597
- 184,
3598
- 137,
3599
- 149,
3600
- 144
3601
- ],
3602
- accounts: [
3603
- {
3604
- name: "active_list",
3605
- writable: true
3606
- },
3607
- {
3608
- name: "processing_state",
3609
- writable: true
3610
- },
3611
- {
3612
- name: "authority",
3613
- signer: true
3614
- }
3615
- ],
3616
- args: [
3617
- ]
3618
- },
3619
3241
  {
3620
3242
  name: "update_config_bool",
3621
3243
  discriminator: [
@@ -4293,8 +3915,118 @@ var events = [
4293
3915
  var errors$3 = [
4294
3916
  {
4295
3917
  code: 6000,
4296
- name: "AccountBorrowFailed",
4297
- msg: "Util Acc borrow Failed"
3918
+ name: "DestinationAccountDoesNotExist",
3919
+ msg: "Destination stake account does not exist"
3920
+ },
3921
+ {
3922
+ code: 6001,
3923
+ name: "SourceAccountDoesNotExist",
3924
+ msg: "Source stake account does not exist"
3925
+ },
3926
+ {
3927
+ code: 6002,
3928
+ name: "InvalidDestinationOwner",
3929
+ msg: "Destination account not owned by stake program"
3930
+ },
3931
+ {
3932
+ code: 6003,
3933
+ name: "InvalidSourceOwner",
3934
+ msg: "Source account not owned by stake program"
3935
+ },
3936
+ {
3937
+ code: 6004,
3938
+ name: "ClockBorrowFailed",
3939
+ msg: "Failed to borrow clock data"
3940
+ },
3941
+ {
3942
+ code: 6005,
3943
+ name: "ClockDeserializeFailed",
3944
+ msg: "Failed to deserialize clock"
3945
+ },
3946
+ {
3947
+ code: 6006,
3948
+ name: "DestinationAnalysisFailed",
3949
+ msg: "Failed to analyze destination stake account"
3950
+ },
3951
+ {
3952
+ code: 6007,
3953
+ name: "SourceAnalysisFailed",
3954
+ msg: "Failed to analyze source stake account"
3955
+ },
3956
+ {
3957
+ code: 6008,
3958
+ name: "DestinationStillActivating",
3959
+ msg: "Destination stake is still activating"
3960
+ },
3961
+ {
3962
+ code: 6009,
3963
+ name: "DestinationDeactivating",
3964
+ msg: "Destination stake is deactivating"
3965
+ },
3966
+ {
3967
+ code: 6010,
3968
+ name: "SourceStillActivating",
3969
+ msg: "Source stake is still activating"
3970
+ },
3971
+ {
3972
+ code: 6011,
3973
+ name: "SourceDeactivating",
3974
+ msg: "Source stake is deactivating"
3975
+ },
3976
+ {
3977
+ code: 6012,
3978
+ name: "DestinationBorrowFailed",
3979
+ msg: "Failed to borrow destination account data"
3980
+ },
3981
+ {
3982
+ code: 6013,
3983
+ name: "DestinationParseFailed",
3984
+ msg: "Failed to parse destination stake state"
3985
+ },
3986
+ {
3987
+ code: 6014,
3988
+ name: "SourceBorrowFailed",
3989
+ msg: "Failed to borrow source account data"
3990
+ },
3991
+ {
3992
+ code: 6015,
3993
+ name: "SourceParseFailed",
3994
+ msg: "Failed to parse source stake state"
3995
+ },
3996
+ {
3997
+ code: 6016,
3998
+ name: "DifferentValidators",
3999
+ msg: "Stakes are delegated to different validators"
4000
+ },
4001
+ {
4002
+ code: 6017,
4003
+ name: "DifferentStakers",
4004
+ msg: "Stakes have different staker authorities"
4005
+ },
4006
+ {
4007
+ code: 6018,
4008
+ name: "DifferentWithdrawers",
4009
+ msg: "Stakes have different withdrawer authorities"
4010
+ },
4011
+ {
4012
+ code: 6019,
4013
+ name: "AuthoritiesNotFound",
4014
+ msg: "Could not extract authorities from accounts"
4015
+ },
4016
+ {
4017
+ code: 6020,
4018
+ name: "MergeInstructionFailed",
4019
+ msg: "Merge instruction failed"
4020
+ },
4021
+ {
4022
+ code: 6021,
4023
+ name: "EpochRewardsActive",
4024
+ msg: "Epoch rewards distribution is active - stake operations blocked"
4025
+ },
4026
+ {
4027
+ code: 6022,
4028
+ name: "DifferentCreditsObserved",
4029
+ msg: "Stakes have different credits_observed - cannot merge until both earn same rewards"
4298
4030
  }
4299
4031
  ];
4300
4032
  var types$5 = [
@@ -6747,153 +6479,6 @@ var instructions$1 = [
6747
6479
  args: [
6748
6480
  ]
6749
6481
  },
6750
- {
6751
- name: "test_clear_leaderboard",
6752
- discriminator: [
6753
- 118,
6754
- 207,
6755
- 26,
6756
- 205,
6757
- 180,
6758
- 7,
6759
- 75,
6760
- 244
6761
- ],
6762
- accounts: [
6763
- {
6764
- name: "leaderboard_state",
6765
- writable: true
6766
- },
6767
- {
6768
- name: "authority",
6769
- signer: true
6770
- }
6771
- ],
6772
- args: [
6773
- ]
6774
- },
6775
- {
6776
- name: "test_force_register_validator",
6777
- discriminator: [
6778
- 136,
6779
- 156,
6780
- 132,
6781
- 32,
6782
- 96,
6783
- 240,
6784
- 7,
6785
- 115
6786
- ],
6787
- accounts: [
6788
- {
6789
- name: "registrant",
6790
- writable: true,
6791
- signer: true
6792
- },
6793
- {
6794
- name: "vote_account"
6795
- },
6796
- {
6797
- name: "validator_record",
6798
- writable: true
6799
- },
6800
- {
6801
- name: "leaderboard_state",
6802
- writable: true
6803
- },
6804
- {
6805
- name: "system_program"
6806
- },
6807
- {
6808
- name: "clock"
6809
- }
6810
- ],
6811
- args: [
6812
- {
6813
- name: "vpp",
6814
- type: "u8"
6815
- }
6816
- ]
6817
- },
6818
- {
6819
- name: "test_force_update_vpp",
6820
- discriminator: [
6821
- 67,
6822
- 51,
6823
- 28,
6824
- 174,
6825
- 200,
6826
- 214,
6827
- 203,
6828
- 162
6829
- ],
6830
- accounts: [
6831
- {
6832
- name: "registrant",
6833
- writable: true,
6834
- signer: true
6835
- },
6836
- {
6837
- name: "vote_account"
6838
- },
6839
- {
6840
- name: "validator_record",
6841
- writable: true
6842
- },
6843
- {
6844
- name: "leaderboard_state",
6845
- writable: true
6846
- }
6847
- ],
6848
- args: [
6849
- {
6850
- name: "vpp",
6851
- type: "u8"
6852
- }
6853
- ]
6854
- },
6855
- {
6856
- name: "test_seed_random_validators",
6857
- discriminator: [
6858
- 48,
6859
- 155,
6860
- 181,
6861
- 112,
6862
- 163,
6863
- 242,
6864
- 43,
6865
- 146
6866
- ],
6867
- accounts: [
6868
- {
6869
- name: "registrant",
6870
- writable: true,
6871
- signer: true
6872
- },
6873
- {
6874
- name: "leaderboard_state",
6875
- writable: true
6876
- }
6877
- ],
6878
- args: [
6879
- {
6880
- name: "count",
6881
- type: "u16"
6882
- },
6883
- {
6884
- name: "seed",
6885
- type: "u64"
6886
- },
6887
- {
6888
- name: "min_vpp",
6889
- type: "u8"
6890
- },
6891
- {
6892
- name: "max_vpp",
6893
- type: "u8"
6894
- }
6895
- ]
6896
- },
6897
6482
  {
6898
6483
  name: "update_commission",
6899
6484
  discriminator: [
@@ -7807,7 +7392,7 @@ const deriveEphemeralStakeAddress = async (user, seed) => {
7807
7392
  return PublicKey.createWithSeed(user, seedStr, StakeProgram.programId);
7808
7393
  };
7809
7394
  const CHAINLINK_FEED = new PublicKey(
7810
- "99B2bTijsU6f1GCT73HmdR7HCFFjGMBcPZY6jZ96ynrR"
7395
+ "CH31Xns5z3M1cTAbKW34jcxPPciazARpijcHj9rxtemt"
7811
7396
  );
7812
7397
  const CHAINLINK_PROGRAM = new PublicKey(
7813
7398
  "HEvSKofvBgfaexv23kMabbYqxasxU3mQ4ibBMEmJWHny"
@@ -8981,191 +8566,222 @@ const _SolanaStakingClient = class _SolanaStakingClient {
8981
8566
  if (amountLamports <= BigInt(0)) {
8982
8567
  throw new Error("Deposit amount must be greater than zero.");
8983
8568
  }
8984
- const tx = await this.depositClient.buildDepositTx(amountLamports);
8985
- const { tx: prepared, blockhash, lastValidBlockHeight } = await this.prepareTx(tx);
8986
- const signed = await this.signTransaction(prepared);
8987
- return await this.sendAndConfirmHttp(signed, {
8988
- blockhash,
8989
- lastValidBlockHeight
8990
- });
8569
+ try {
8570
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8571
+ const ix = await this.depositClient.buildDepositTx(amountLamports);
8572
+ const tx = new Transaction().add(cuIx, ix);
8573
+ const prepared = await this.prepareTx(tx);
8574
+ const signed = await this.signTransaction(prepared.tx);
8575
+ return this.sendAndConfirmHttp(signed, prepared);
8576
+ } catch (err) {
8577
+ throw new Error(`Failed to deposit Solana: ${err}`);
8578
+ }
8991
8579
  }
8992
8580
  async withdraw(amountLamports) {
8993
8581
  this.ensureUser();
8994
8582
  if (amountLamports <= BigInt(0)) {
8995
8583
  throw new Error("Withdraw amount must be greater than zero.");
8996
8584
  }
8997
- const tx = await this.depositClient.buildWithdrawTx(amountLamports);
8998
- const { tx: prepared, blockhash, lastValidBlockHeight } = await this.prepareTx(tx);
8999
- const signed = await this.signTransaction(prepared);
9000
- return await this.sendAndConfirmHttp(signed, {
9001
- blockhash,
9002
- lastValidBlockHeight
9003
- });
8585
+ try {
8586
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8587
+ const ix = await this.depositClient.buildWithdrawTx(amountLamports);
8588
+ const tx = new Transaction().add(cuIx, ix);
8589
+ const prepared = await this.prepareTx(tx);
8590
+ const signed = await this.signTransaction(prepared.tx);
8591
+ return this.sendAndConfirmHttp(signed, prepared);
8592
+ } catch (err) {
8593
+ throw new Error(`Failed to withdraw Solana: ${err}`);
8594
+ }
9004
8595
  }
9005
8596
  async stake(amountLamports) {
9006
8597
  this.ensureUser();
9007
8598
  if (!amountLamports || amountLamports <= BigInt(0)) {
9008
8599
  throw new Error("Stake amount must be greater than zero.");
9009
8600
  }
9010
- const user = this.solPubKey;
9011
- const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
9012
- const ix = await this.outpostClient.buildStakeIx(amountLamports, user);
9013
- const tx = new Transaction().add(cuIx, ix);
9014
- const prepared = await this.prepareTx(tx);
9015
- const signed = await this.signTransaction(prepared.tx);
9016
- return this.sendAndConfirmHttp(signed, prepared);
8601
+ try {
8602
+ const user = this.solPubKey;
8603
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8604
+ const ix = await this.outpostClient.buildStakeIx(amountLamports, user);
8605
+ const tx = new Transaction().add(cuIx, ix);
8606
+ const prepared = await this.prepareTx(tx);
8607
+ const signed = await this.signTransaction(prepared.tx);
8608
+ return this.sendAndConfirmHttp(signed, prepared);
8609
+ } catch (err) {
8610
+ throw new Error(`Failed to stake Solana: ${err}`);
8611
+ }
9017
8612
  }
9018
8613
  async unstake(amountLamports) {
9019
8614
  this.ensureUser();
9020
8615
  if (!amountLamports || amountLamports <= BigInt(0)) {
9021
8616
  throw new Error("Unstake amount must be greater than zero.");
9022
8617
  }
9023
- const user = this.solPubKey;
9024
- const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
9025
- const ix = await this.outpostClient.buildUnstakeIx(amountLamports, user);
9026
- const tx = new Transaction().add(cuIx, ix);
9027
- const prepared = await this.prepareTx(tx);
9028
- const signed = await this.signTransaction(prepared.tx);
9029
- return this.sendAndConfirmHttp(signed, prepared);
8618
+ try {
8619
+ const user = this.solPubKey;
8620
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8621
+ const ix = await this.outpostClient.buildUnstakeIx(amountLamports, user);
8622
+ const tx = new Transaction().add(cuIx, ix);
8623
+ const prepared = await this.prepareTx(tx);
8624
+ const signed = await this.signTransaction(prepared.tx);
8625
+ return this.sendAndConfirmHttp(signed, prepared);
8626
+ } catch (err) {
8627
+ throw new Error(`Failed to unstake Solana: ${err}`);
8628
+ }
9030
8629
  }
9031
8630
  async buy(amountLamports) {
9032
8631
  this.ensureUser();
9033
8632
  if (!amountLamports || amountLamports <= BigInt(0)) {
9034
8633
  throw new Error("liqSOL pretoken purchase requires a positive amount.");
9035
8634
  }
9036
- const user = this.solPubKey;
9037
- const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
9038
- const ix = await this.tokenClient.buildPurchaseIx(amountLamports, user);
9039
- const tx = new Transaction().add(cuIx, ix);
9040
- const { tx: prepared, blockhash, lastValidBlockHeight } = await this.prepareTx(tx);
9041
- const signed = await this.signTransaction(prepared);
9042
- return await this.sendAndConfirmHttp(signed, {
9043
- blockhash,
9044
- lastValidBlockHeight
9045
- });
8635
+ try {
8636
+ const user = this.solPubKey;
8637
+ const cuIx = ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8638
+ const ix = await this.tokenClient.buildPurchaseIx(amountLamports, user);
8639
+ const tx = new Transaction().add(cuIx, ix);
8640
+ const prepared = await this.prepareTx(tx);
8641
+ const signed = await this.signTransaction(prepared.tx);
8642
+ return this.sendAndConfirmHttp(signed, prepared);
8643
+ } catch (err) {
8644
+ throw new Error(`Failed to buy liqSOL pretokens: ${err}`);
8645
+ }
9046
8646
  }
9047
8647
  async getPortfolio() {
9048
8648
  if (!this.pubKey) throw new Error("User pubKey is undefined");
9049
- const user = this.solPubKey;
9050
- const reservePoolPDA = deriveReservePoolPda();
9051
- const vaultPDA = deriveVaultPda();
9052
- const liqsolMint = deriveLiqsolMintPda();
9053
- const userLiqsolAta = getAssociatedTokenAddressSync(
9054
- liqsolMint,
9055
- user,
9056
- false,
9057
- TOKEN_2022_PROGRAM_ID,
9058
- ASSOCIATED_TOKEN_PROGRAM_ID
9059
- );
9060
- const [nativeLamports, actualBalResp, snapshot] = await Promise.all([
9061
- this.connection.getBalance(user, "confirmed"),
9062
- this.connection.getTokenAccountBalance(userLiqsolAta, "confirmed").catch(() => null),
9063
- this.outpostClient.fetchWireState(user).catch(() => null)
9064
- ]);
9065
- const LIQSOL_DECIMALS = 9;
9066
- const actualAmountStr = actualBalResp?.value?.amount ?? "0";
9067
- const globalState = snapshot?.globalState ?? null;
9068
- const outpostAccount = snapshot?.outpostAccount ?? null;
9069
- const trancheState = snapshot?.trancheState ?? null;
9070
- const userPretokenRecord = snapshot?.userPretokenRecord ?? null;
9071
- const stakedLiqsolStr = outpostAccount?.stakedLiqsol?.toString?.() ?? "0";
9072
- const wirePretokensStr = userPretokenRecord?.totalPretokensPurchased?.toString?.() ?? "0";
9073
- const currentIndexStr = globalState?.currentIndex?.toString?.() ?? "0";
9074
- const totalSharesStr = globalState?.totalShares?.toString?.() ?? "0";
9075
- const userSharesStr = outpostAccount?.stakedShares?.toString?.() ?? "0";
9076
- const stakedLiqsol = BigInt(stakedLiqsolStr);
9077
- const currentIndex = BigInt(currentIndexStr);
9078
- const totalShares = BigInt(totalSharesStr);
9079
- const userShares = BigInt(userSharesStr);
9080
- let estimatedClaim = BigInt(0);
9081
- let estimatedYield = BigInt(0);
9082
- if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
9083
- estimatedClaim = userShares * currentIndex / INDEX_SCALE$1;
9084
- if (estimatedClaim > stakedLiqsol) {
9085
- estimatedYield = estimatedClaim - stakedLiqsol;
8649
+ try {
8650
+ const user = this.solPubKey;
8651
+ const reservePoolPDA = deriveReservePoolPda();
8652
+ const vaultPDA = deriveVaultPda();
8653
+ const liqsolMint = deriveLiqsolMintPda();
8654
+ const userLiqsolAta = getAssociatedTokenAddressSync(
8655
+ liqsolMint,
8656
+ user,
8657
+ false,
8658
+ TOKEN_2022_PROGRAM_ID,
8659
+ ASSOCIATED_TOKEN_PROGRAM_ID
8660
+ );
8661
+ const [nativeLamports, actualBalResp, snapshot] = await Promise.all([
8662
+ this.connection.getBalance(user, "confirmed"),
8663
+ this.connection.getTokenAccountBalance(userLiqsolAta, "confirmed").catch(() => null),
8664
+ this.outpostClient.fetchWireState(user).catch(() => null)
8665
+ ]);
8666
+ const LIQSOL_DECIMALS = 9;
8667
+ const actualAmountStr = actualBalResp?.value?.amount ?? "0";
8668
+ const globalState = snapshot?.globalState ?? null;
8669
+ const outpostAccount = snapshot?.outpostAccount ?? null;
8670
+ const trancheState = snapshot?.trancheState ?? null;
8671
+ const userPretokenRecord = snapshot?.userPretokenRecord ?? null;
8672
+ const stakedLiqsolStr = outpostAccount?.stakedLiqsol?.toString?.() ?? "0";
8673
+ const wirePretokensStr = userPretokenRecord?.totalPretokensPurchased?.toString?.() ?? "0";
8674
+ const currentIndexStr = globalState?.currentIndex?.toString?.() ?? "0";
8675
+ const totalSharesStr = globalState?.totalShares?.toString?.() ?? "0";
8676
+ const userSharesStr = outpostAccount?.stakedShares?.toString?.() ?? "0";
8677
+ const stakedLiqsol = BigInt(stakedLiqsolStr);
8678
+ const currentIndex = BigInt(currentIndexStr);
8679
+ const totalShares = BigInt(totalSharesStr);
8680
+ const userShares = BigInt(userSharesStr);
8681
+ let estimatedClaim = BigInt(0);
8682
+ let estimatedYield = BigInt(0);
8683
+ if (userShares > BigInt(0) && currentIndex > BigInt(0)) {
8684
+ estimatedClaim = userShares * currentIndex / INDEX_SCALE$1;
8685
+ if (estimatedClaim > stakedLiqsol) {
8686
+ estimatedYield = estimatedClaim - stakedLiqsol;
8687
+ }
9086
8688
  }
8689
+ return {
8690
+ native: {
8691
+ amount: BigInt(nativeLamports),
8692
+ symbol: "SOL",
8693
+ decimals: 9
8694
+ },
8695
+ liq: {
8696
+ amount: BigInt(actualAmountStr),
8697
+ symbol: "LiqSOL",
8698
+ decimals: LIQSOL_DECIMALS,
8699
+ ata: userLiqsolAta
8700
+ },
8701
+ staked: {
8702
+ amount: stakedLiqsol,
8703
+ symbol: "LiqSOL",
8704
+ decimals: LIQSOL_DECIMALS
8705
+ },
8706
+ wire: {
8707
+ amount: BigInt(wirePretokensStr),
8708
+ symbol: "$WIRE",
8709
+ decimals: 8
8710
+ },
8711
+ yield: {
8712
+ currentIndex,
8713
+ indexScale: INDEX_SCALE$1,
8714
+ totalShares,
8715
+ userShares,
8716
+ estimatedClaim,
8717
+ estimatedYield
8718
+ },
8719
+ extras: {
8720
+ userLiqsolAta: userLiqsolAta.toBase58(),
8721
+ reservePoolPDA: reservePoolPDA.toBase58(),
8722
+ vaultPDA: vaultPDA.toBase58(),
8723
+ globalIndex: globalState?.currentIndex?.toString(),
8724
+ totalShares: globalState?.totalShares?.toString(),
8725
+ currentTrancheNumber: trancheState?.currentTrancheNumber?.toString(),
8726
+ currentTranchePriceUsd: trancheState?.currentTranchePriceUsd?.toString()
8727
+ },
8728
+ chainID: this.network.chainId
8729
+ };
8730
+ } catch (err) {
8731
+ throw new Error(`Failed to get Solana portfolio: ${err}`);
9087
8732
  }
9088
- return {
9089
- native: {
9090
- amount: BigInt(nativeLamports),
9091
- symbol: "SOL",
9092
- decimals: 9
9093
- },
9094
- liq: {
9095
- amount: BigInt(actualAmountStr),
9096
- symbol: "LiqSOL",
9097
- decimals: LIQSOL_DECIMALS,
9098
- ata: userLiqsolAta
9099
- },
9100
- staked: {
9101
- amount: stakedLiqsol,
9102
- symbol: "LiqSOL",
9103
- decimals: LIQSOL_DECIMALS
9104
- },
9105
- wire: {
9106
- amount: BigInt(wirePretokensStr),
9107
- symbol: "$WIRE",
9108
- decimals: 8
9109
- },
9110
- yield: {
9111
- currentIndex,
9112
- indexScale: INDEX_SCALE$1,
9113
- totalShares,
9114
- userShares,
9115
- estimatedClaim,
9116
- estimatedYield
9117
- },
9118
- extras: {
9119
- userLiqsolAta: userLiqsolAta.toBase58(),
9120
- reservePoolPDA: reservePoolPDA.toBase58(),
9121
- vaultPDA: vaultPDA.toBase58(),
9122
- globalIndex: globalState?.currentIndex?.toString(),
9123
- totalShares: globalState?.totalShares?.toString(),
9124
- currentTrancheNumber: trancheState?.currentTrancheNumber?.toString(),
9125
- currentTranchePriceUsd: trancheState?.currentTranchePriceUsd?.toString()
9126
- },
9127
- chainID: this.network.chainId
9128
- };
9129
8733
  }
9130
8734
  async getUserRecord() {
9131
8735
  if (!this.pubKey) throw new Error("User pubKey is undefined");
9132
8736
  return this.distributionClient.getUserRecord(this.solPubKey);
9133
8737
  }
9134
8738
  async getTrancheSnapshot(options) {
9135
- const {
9136
- chainID = SolChainID.WireTestnet,
9137
- windowBefore,
9138
- windowAfter
9139
- } = options ?? {};
9140
- const [globalState, trancheState] = await Promise.all([
9141
- this.tokenClient.fetchGlobalState(),
9142
- this.tokenClient.fetchTrancheState()
9143
- ]);
9144
- const { price: solPriceUsd, timestamp } = await this.tokenClient.getSolPriceUsdSafe();
9145
- return buildSolanaTrancheSnapshot({
9146
- chainID,
9147
- globalState,
9148
- trancheState,
9149
- solPriceUsd,
9150
- nativePriceTimestamp: timestamp,
9151
- ladderWindowBefore: windowBefore,
9152
- ladderWindowAfter: windowAfter
9153
- });
8739
+ try {
8740
+ const {
8741
+ chainID = SolChainID.WireTestnet,
8742
+ windowBefore,
8743
+ windowAfter
8744
+ } = options ?? {};
8745
+ const [globalState, trancheState] = await Promise.all([
8746
+ this.tokenClient.fetchGlobalState(),
8747
+ this.tokenClient.fetchTrancheState()
8748
+ ]);
8749
+ const { price: solPriceUsd, timestamp } = await this.tokenClient.getSolPriceUsdSafe();
8750
+ return buildSolanaTrancheSnapshot({
8751
+ chainID,
8752
+ globalState,
8753
+ trancheState,
8754
+ solPriceUsd,
8755
+ nativePriceTimestamp: timestamp,
8756
+ ladderWindowBefore: windowBefore,
8757
+ ladderWindowAfter: windowAfter
8758
+ });
8759
+ } catch (err) {
8760
+ throw new Error(`Failed to build Solana tranche snapshot: ${err}`);
8761
+ }
9154
8762
  }
9155
8763
  async getSystemAPY() {
9156
- const ratePerEpoch = await this.getEpochRateDecimalFromProgram();
9157
- const epochsPerYear = await this.getEpochsPerYearFromCluster();
9158
- const apyDecimal = Math.pow(1 + ratePerEpoch, epochsPerYear) - 1;
9159
- const apyPercent = apyDecimal * 100;
9160
- return apyPercent;
8764
+ try {
8765
+ const ratePerEpoch = await this.getEpochRateDecimalFromProgram();
8766
+ const epochsPerYear = await this.getEpochsPerYearFromCluster();
8767
+ const apyDecimal = Math.pow(1 + ratePerEpoch, epochsPerYear) - 1;
8768
+ const apyPercent = apyDecimal * 100;
8769
+ return apyPercent;
8770
+ } catch (err) {
8771
+ throw new Error(`Failed to compute Solana system APY: ${err}`);
8772
+ }
9161
8773
  }
9162
8774
  async getEpochRateDecimalFromProgram() {
9163
- const liqSolCoreProgram = this.program.getProgram("liqsolCore");
9164
- const stakeMetricsPda = deriveStakeMetricsPda();
9165
- const stakeMetrics = await liqSolCoreProgram.account.stakeMetrics.fetch(stakeMetricsPda);
9166
- const raw = BigInt(stakeMetrics.solSystemPayRate.toString());
9167
- const rateDecimal = Number(raw) / Number(PAY_RATE_SCALE_FACTOR);
9168
- return rateDecimal;
8775
+ try {
8776
+ const liqSolCoreProgram = this.program.getProgram("liqsolCore");
8777
+ const stakeMetricsPda = deriveStakeMetricsPda();
8778
+ const stakeMetrics = await liqSolCoreProgram.account.stakeMetrics.fetch(stakeMetricsPda);
8779
+ const raw = BigInt(stakeMetrics.solSystemPayRate.toString());
8780
+ const rateDecimal = Number(raw) / Number(PAY_RATE_SCALE_FACTOR);
8781
+ return rateDecimal;
8782
+ } catch (err) {
8783
+ throw new Error(`Failed to read stakeMetrics from program: ${err}`);
8784
+ }
9169
8785
  }
9170
8786
  async getEpochsPerYearFromCluster() {
9171
8787
  const now = Date.now();
@@ -9355,10 +8971,10 @@ _SolanaStakingClient.EPOCHS_PER_YEAR_TTL_MS = 10 * 60 * 1e3;
9355
8971
  _SolanaStakingClient.FEE_CACHE_TTL_MS = 6e4;
9356
8972
  let SolanaStakingClient = _SolanaStakingClient;
9357
8973
 
9358
- var _format$q = "hh-sol-artifact-1";
9359
- var contractName$q = "Accounting";
9360
- var sourceName$q = "contracts/liqEth/accounting.sol";
9361
- var abi$q = [
8974
+ var _format$p = "hh-sol-artifact-1";
8975
+ var contractName$p = "Accounting";
8976
+ var sourceName$p = "contracts/liqEth/accounting.sol";
8977
+ var abi$p = [
9362
8978
  {
9363
8979
  inputs: [
9364
8980
  {
@@ -9920,20 +9536,20 @@ var linkReferences$p = {
9920
9536
  var deployedLinkReferences$p = {
9921
9537
  };
9922
9538
  var AccountingArtifact = {
9923
- _format: _format$q,
9924
- contractName: contractName$q,
9925
- sourceName: sourceName$q,
9926
- abi: abi$q,
9539
+ _format: _format$p,
9540
+ contractName: contractName$p,
9541
+ sourceName: sourceName$p,
9542
+ abi: abi$p,
9927
9543
  bytecode: bytecode$p,
9928
9544
  deployedBytecode: deployedBytecode$p,
9929
9545
  linkReferences: linkReferences$p,
9930
9546
  deployedLinkReferences: deployedLinkReferences$p
9931
9547
  };
9932
9548
 
9933
- var _format$p = "hh-sol-artifact-1";
9934
- var contractName$p = "DepositManager";
9935
- var sourceName$p = "contracts/liqEth/DepositManager.sol";
9936
- var abi$p = [
9549
+ var _format$o = "hh-sol-artifact-1";
9550
+ var contractName$o = "DepositManager";
9551
+ var sourceName$o = "contracts/liqEth/DepositManager.sol";
9552
+ var abi$o = [
9937
9553
  {
9938
9554
  inputs: [
9939
9555
  {
@@ -10968,20 +10584,20 @@ var linkReferences$o = {
10968
10584
  var deployedLinkReferences$o = {
10969
10585
  };
10970
10586
  var DepositManagerArtifact = {
10971
- _format: _format$p,
10972
- contractName: contractName$p,
10973
- sourceName: sourceName$p,
10974
- abi: abi$p,
10587
+ _format: _format$o,
10588
+ contractName: contractName$o,
10589
+ sourceName: sourceName$o,
10590
+ abi: abi$o,
10975
10591
  bytecode: bytecode$o,
10976
10592
  deployedBytecode: deployedBytecode$o,
10977
10593
  linkReferences: linkReferences$o,
10978
10594
  deployedLinkReferences: deployedLinkReferences$o
10979
10595
  };
10980
10596
 
10981
- var _format$o = "hh-sol-artifact-1";
10982
- var contractName$o = "LiqEthToken";
10983
- var sourceName$o = "contracts/liqEth/liqEth.sol";
10984
- var abi$o = [
10597
+ var _format$n = "hh-sol-artifact-1";
10598
+ var contractName$n = "LiqEthToken";
10599
+ var sourceName$n = "contracts/liqEth/liqEth.sol";
10600
+ var abi$n = [
10985
10601
  {
10986
10602
  inputs: [
10987
10603
  {
@@ -12252,20 +11868,20 @@ var linkReferences$n = {
12252
11868
  var deployedLinkReferences$n = {
12253
11869
  };
12254
11870
  var LiqEthArtifact = {
12255
- _format: _format$o,
12256
- contractName: contractName$o,
12257
- sourceName: sourceName$o,
12258
- abi: abi$o,
11871
+ _format: _format$n,
11872
+ contractName: contractName$n,
11873
+ sourceName: sourceName$n,
11874
+ abi: abi$n,
12259
11875
  bytecode: bytecode$n,
12260
11876
  deployedBytecode: deployedBytecode$n,
12261
11877
  linkReferences: linkReferences$n,
12262
11878
  deployedLinkReferences: deployedLinkReferences$n
12263
11879
  };
12264
11880
 
12265
- var _format$n = "hh-sol-artifact-1";
12266
- var contractName$n = "StakingModule";
12267
- var sourceName$n = "contracts/liqEth/stakingModule.sol";
12268
- var abi$n = [
11881
+ var _format$m = "hh-sol-artifact-1";
11882
+ var contractName$m = "StakingModule";
11883
+ var sourceName$m = "contracts/liqEth/stakingModule.sol";
11884
+ var abi$m = [
12269
11885
  {
12270
11886
  inputs: [
12271
11887
  {
@@ -14092,20 +13708,20 @@ var deployedLinkReferences$m = {
14092
13708
  }
14093
13709
  };
14094
13710
  var StakingModuleArtifact = {
14095
- _format: _format$n,
14096
- contractName: contractName$n,
14097
- sourceName: sourceName$n,
14098
- abi: abi$n,
13711
+ _format: _format$m,
13712
+ contractName: contractName$m,
13713
+ sourceName: sourceName$m,
13714
+ abi: abi$m,
14099
13715
  bytecode: bytecode$m,
14100
13716
  deployedBytecode: deployedBytecode$m,
14101
13717
  linkReferences: linkReferences$m,
14102
13718
  deployedLinkReferences: deployedLinkReferences$m
14103
13719
  };
14104
13720
 
14105
- var _format$m = "hh-sol-artifact-1";
14106
- var contractName$m = "WithdrawalQueue";
14107
- var sourceName$m = "contracts/liqEth/withdrawalQueue.sol";
14108
- var abi$m = [
13721
+ var _format$l = "hh-sol-artifact-1";
13722
+ var contractName$l = "WithdrawalQueue";
13723
+ var sourceName$l = "contracts/liqEth/withdrawalQueue.sol";
13724
+ var abi$l = [
14109
13725
  {
14110
13726
  inputs: [
14111
13727
  {
@@ -15103,20 +14719,20 @@ var linkReferences$l = {
15103
14719
  var deployedLinkReferences$l = {
15104
14720
  };
15105
14721
  var WithdrawalQueueArtifact = {
15106
- _format: _format$m,
15107
- contractName: contractName$m,
15108
- sourceName: sourceName$m,
15109
- abi: abi$m,
14722
+ _format: _format$l,
14723
+ contractName: contractName$l,
14724
+ sourceName: sourceName$l,
14725
+ abi: abi$l,
15110
14726
  bytecode: bytecode$l,
15111
14727
  deployedBytecode: deployedBytecode$l,
15112
14728
  linkReferences: linkReferences$l,
15113
14729
  deployedLinkReferences: deployedLinkReferences$l
15114
14730
  };
15115
14731
 
15116
- var _format$l = "hh-sol-artifact-1";
15117
- var contractName$l = "WithdrawalVault";
15118
- var sourceName$l = "contracts/liqEth/withdrawalVault.sol";
15119
- var abi$l = [
14732
+ var _format$k = "hh-sol-artifact-1";
14733
+ var contractName$k = "WithdrawalVault";
14734
+ var sourceName$k = "contracts/liqEth/withdrawalVault.sol";
14735
+ var abi$k = [
15120
14736
  {
15121
14737
  inputs: [
15122
14738
  {
@@ -15578,20 +15194,20 @@ var linkReferences$k = {
15578
15194
  var deployedLinkReferences$k = {
15579
15195
  };
15580
15196
  var WithdrawalVaultArtifact = {
15581
- _format: _format$l,
15582
- contractName: contractName$l,
15583
- sourceName: sourceName$l,
15584
- abi: abi$l,
15197
+ _format: _format$k,
15198
+ contractName: contractName$k,
15199
+ sourceName: sourceName$k,
15200
+ abi: abi$k,
15585
15201
  bytecode: bytecode$k,
15586
15202
  deployedBytecode: deployedBytecode$k,
15587
15203
  linkReferences: linkReferences$k,
15588
15204
  deployedLinkReferences: deployedLinkReferences$k
15589
15205
  };
15590
15206
 
15591
- var _format$k = "hh-sol-artifact-1";
15592
- var contractName$k = "BeaconState";
15593
- var sourceName$k = "contracts/liqEth/BeaconState.sol";
15594
- var abi$k = [
15207
+ var _format$j = "hh-sol-artifact-1";
15208
+ var contractName$j = "BeaconState";
15209
+ var sourceName$j = "contracts/liqEth/BeaconState.sol";
15210
+ var abi$j = [
15595
15211
  {
15596
15212
  inputs: [
15597
15213
  {
@@ -16414,20 +16030,20 @@ var linkReferences$j = {
16414
16030
  var deployedLinkReferences$j = {
16415
16031
  };
16416
16032
  var BeaconStateArtifact = {
16417
- _format: _format$k,
16418
- contractName: contractName$k,
16419
- sourceName: sourceName$k,
16420
- abi: abi$k,
16033
+ _format: _format$j,
16034
+ contractName: contractName$j,
16035
+ sourceName: sourceName$j,
16036
+ abi: abi$j,
16421
16037
  bytecode: bytecode$j,
16422
16038
  deployedBytecode: deployedBytecode$j,
16423
16039
  linkReferences: linkReferences$j,
16424
16040
  deployedLinkReferences: deployedLinkReferences$j
16425
16041
  };
16426
16042
 
16427
- var _format$j = "hh-sol-artifact-1";
16428
- var contractName$j = "YieldOracle";
16429
- var sourceName$j = "contracts/liqEth/Yield.sol";
16430
- var abi$j = [
16043
+ var _format$i = "hh-sol-artifact-1";
16044
+ var contractName$i = "YieldOracle";
16045
+ var sourceName$i = "contracts/liqEth/Yield.sol";
16046
+ var abi$i = [
16431
16047
  {
16432
16048
  inputs: [
16433
16049
  {
@@ -17844,20 +17460,20 @@ var deployedLinkReferences$i = {
17844
17460
  }
17845
17461
  };
17846
17462
  var YieldOracleArtifact = {
17847
- _format: _format$j,
17848
- contractName: contractName$j,
17849
- sourceName: sourceName$j,
17850
- abi: abi$j,
17463
+ _format: _format$i,
17464
+ contractName: contractName$i,
17465
+ sourceName: sourceName$i,
17466
+ abi: abi$i,
17851
17467
  bytecode: bytecode$i,
17852
17468
  deployedBytecode: deployedBytecode$i,
17853
17469
  linkReferences: linkReferences$i,
17854
17470
  deployedLinkReferences: deployedLinkReferences$i
17855
17471
  };
17856
17472
 
17857
- var _format$i = "hh-sol-artifact-1";
17858
- var contractName$i = "Depositor";
17859
- var sourceName$i = "contracts/outpost/Depositor.sol";
17860
- var abi$i = [
17473
+ var _format$h = "hh-sol-artifact-1";
17474
+ var contractName$h = "Depositor";
17475
+ var sourceName$h = "contracts/outpost/Depositor.sol";
17476
+ var abi$h = [
17861
17477
  {
17862
17478
  inputs: [
17863
17479
  {
@@ -19538,20 +19154,20 @@ var deployedLinkReferences$h = {
19538
19154
  }
19539
19155
  };
19540
19156
  var DepositorArtifact = {
19541
- _format: _format$i,
19542
- contractName: contractName$i,
19543
- sourceName: sourceName$i,
19544
- abi: abi$i,
19157
+ _format: _format$h,
19158
+ contractName: contractName$h,
19159
+ sourceName: sourceName$h,
19160
+ abi: abi$h,
19545
19161
  bytecode: bytecode$h,
19546
19162
  deployedBytecode: deployedBytecode$h,
19547
19163
  linkReferences: linkReferences$h,
19548
19164
  deployedLinkReferences: deployedLinkReferences$h
19549
19165
  };
19550
19166
 
19551
- var _format$h = "hh-sol-artifact-1";
19552
- var contractName$h = "ReceiptNFT";
19553
- var sourceName$h = "contracts/outpost/ReceiptNFT.sol";
19554
- var abi$h = [
19167
+ var _format$g = "hh-sol-artifact-1";
19168
+ var contractName$g = "ReceiptNFT";
19169
+ var sourceName$g = "contracts/outpost/ReceiptNFT.sol";
19170
+ var abi$g = [
19555
19171
  {
19556
19172
  inputs: [
19557
19173
  {
@@ -21588,20 +21204,20 @@ var linkReferences$g = {
21588
21204
  var deployedLinkReferences$g = {
21589
21205
  };
21590
21206
  var ReceiptNFTArtifact = {
21591
- _format: _format$h,
21592
- contractName: contractName$h,
21593
- sourceName: sourceName$h,
21594
- abi: abi$h,
21207
+ _format: _format$g,
21208
+ contractName: contractName$g,
21209
+ sourceName: sourceName$g,
21210
+ abi: abi$g,
21595
21211
  bytecode: bytecode$g,
21596
21212
  deployedBytecode: deployedBytecode$g,
21597
21213
  linkReferences: linkReferences$g,
21598
21214
  deployedLinkReferences: deployedLinkReferences$g
21599
21215
  };
21600
21216
 
21601
- var _format$g = "hh-sol-artifact-1";
21602
- var contractName$g = "OutpostManager";
21603
- var sourceName$g = "contracts/outpost/OutpostManager.sol";
21604
- var abi$g = [
21217
+ var _format$f = "hh-sol-artifact-1";
21218
+ var contractName$f = "OutpostManager";
21219
+ var sourceName$f = "contracts/outpost/OutpostManager.sol";
21220
+ var abi$f = [
21605
21221
  {
21606
21222
  inputs: [
21607
21223
  {
@@ -22363,20 +21979,20 @@ var linkReferences$f = {
22363
21979
  var deployedLinkReferences$f = {
22364
21980
  };
22365
21981
  var OutpostManagerArtifact = {
22366
- _format: _format$g,
22367
- contractName: contractName$g,
22368
- sourceName: sourceName$g,
22369
- abi: abi$g,
21982
+ _format: _format$f,
21983
+ contractName: contractName$f,
21984
+ sourceName: sourceName$f,
21985
+ abi: abi$f,
22370
21986
  bytecode: bytecode$f,
22371
21987
  deployedBytecode: deployedBytecode$f,
22372
21988
  linkReferences: linkReferences$f,
22373
21989
  deployedLinkReferences: deployedLinkReferences$f
22374
21990
  };
22375
21991
 
22376
- var _format$f = "hh-sol-artifact-1";
22377
- var contractName$f = "BAR";
22378
- var sourceName$f = "contracts/outpost/BAR.sol";
22379
- var abi$f = [
21992
+ var _format$e = "hh-sol-artifact-1";
21993
+ var contractName$e = "BAR";
21994
+ var sourceName$e = "contracts/outpost/BAR.sol";
21995
+ var abi$e = [
22380
21996
  {
22381
21997
  inputs: [
22382
21998
  {
@@ -24255,20 +23871,20 @@ var deployedLinkReferences$e = {
24255
23871
  }
24256
23872
  };
24257
23873
  var BARArtifact = {
24258
- _format: _format$f,
24259
- contractName: contractName$f,
24260
- sourceName: sourceName$f,
24261
- abi: abi$f,
23874
+ _format: _format$e,
23875
+ contractName: contractName$e,
23876
+ sourceName: sourceName$e,
23877
+ abi: abi$e,
24262
23878
  bytecode: bytecode$e,
24263
23879
  deployedBytecode: deployedBytecode$e,
24264
23880
  linkReferences: linkReferences$e,
24265
23881
  deployedLinkReferences: deployedLinkReferences$e
24266
23882
  };
24267
23883
 
24268
- var _format$e = "hh-sol-artifact-1";
24269
- var contractName$e = "OPP";
24270
- var sourceName$e = "contracts/outpost/OPP.sol";
24271
- var abi$e = [
23884
+ var _format$d = "hh-sol-artifact-1";
23885
+ var contractName$d = "OPP";
23886
+ var sourceName$d = "contracts/outpost/OPP.sol";
23887
+ var abi$d = [
24272
23888
  {
24273
23889
  inputs: [
24274
23890
  {
@@ -25244,20 +24860,20 @@ var deployedLinkReferences$d = {
25244
24860
  }
25245
24861
  };
25246
24862
  var OPPArtifact = {
25247
- _format: _format$e,
25248
- contractName: contractName$e,
25249
- sourceName: sourceName$e,
25250
- abi: abi$e,
24863
+ _format: _format$d,
24864
+ contractName: contractName$d,
24865
+ sourceName: sourceName$d,
24866
+ abi: abi$d,
25251
24867
  bytecode: bytecode$d,
25252
24868
  deployedBytecode: deployedBytecode$d,
25253
24869
  linkReferences: linkReferences$d,
25254
24870
  deployedLinkReferences: deployedLinkReferences$d
25255
24871
  };
25256
24872
 
25257
- var _format$d = "hh-sol-artifact-1";
25258
- var contractName$d = "OPPCommon";
25259
- var sourceName$d = "contracts/outpost/OPPCommon.sol";
25260
- var abi$d = [
24873
+ var _format$c = "hh-sol-artifact-1";
24874
+ var contractName$c = "OPPCommon";
24875
+ var sourceName$c = "contracts/outpost/OPPCommon.sol";
24876
+ var abi$c = [
25261
24877
  {
25262
24878
  inputs: [
25263
24879
  {
@@ -25452,20 +25068,20 @@ var deployedLinkReferences$c = {
25452
25068
  }
25453
25069
  };
25454
25070
  var OPPCommonArtifact = {
25455
- _format: _format$d,
25456
- contractName: contractName$d,
25457
- sourceName: sourceName$d,
25458
- abi: abi$d,
25071
+ _format: _format$c,
25072
+ contractName: contractName$c,
25073
+ sourceName: sourceName$c,
25074
+ abi: abi$c,
25459
25075
  bytecode: bytecode$c,
25460
25076
  deployedBytecode: deployedBytecode$c,
25461
25077
  linkReferences: linkReferences$c,
25462
25078
  deployedLinkReferences: deployedLinkReferences$c
25463
25079
  };
25464
25080
 
25465
- var _format$c = "hh-sol-artifact-1";
25466
- var contractName$c = "OPPInbound";
25467
- var sourceName$c = "contracts/outpost/OPPInbound.sol";
25468
- var abi$c = [
25081
+ var _format$b = "hh-sol-artifact-1";
25082
+ var contractName$b = "OPPInbound";
25083
+ var sourceName$b = "contracts/outpost/OPPInbound.sol";
25084
+ var abi$b = [
25469
25085
  {
25470
25086
  inputs: [
25471
25087
  {
@@ -26498,20 +26114,20 @@ var deployedLinkReferences$b = {
26498
26114
  }
26499
26115
  };
26500
26116
  var OPPInboundArtifact = {
26501
- _format: _format$c,
26502
- contractName: contractName$c,
26503
- sourceName: sourceName$c,
26504
- abi: abi$c,
26117
+ _format: _format$b,
26118
+ contractName: contractName$b,
26119
+ sourceName: sourceName$b,
26120
+ abi: abi$b,
26505
26121
  bytecode: bytecode$b,
26506
26122
  deployedBytecode: deployedBytecode$b,
26507
26123
  linkReferences: linkReferences$b,
26508
26124
  deployedLinkReferences: deployedLinkReferences$b
26509
26125
  };
26510
26126
 
26511
- var _format$b = "hh-sol-artifact-1";
26512
- var contractName$b = "Pretoken";
26513
- var sourceName$b = "contracts/outpost/Pretoken.sol";
26514
- var abi$b = [
26127
+ var _format$a = "hh-sol-artifact-1";
26128
+ var contractName$a = "Pretoken";
26129
+ var sourceName$a = "contracts/outpost/Pretoken.sol";
26130
+ var abi$a = [
26515
26131
  {
26516
26132
  inputs: [
26517
26133
  {
@@ -28192,200 +27808,16 @@ var deployedLinkReferences$a = {
28192
27808
  }
28193
27809
  };
28194
27810
  var PretokenArtifact = {
28195
- _format: _format$b,
28196
- contractName: contractName$b,
28197
- sourceName: sourceName$b,
28198
- abi: abi$b,
27811
+ _format: _format$a,
27812
+ contractName: contractName$a,
27813
+ sourceName: sourceName$a,
27814
+ abi: abi$a,
28199
27815
  bytecode: bytecode$a,
28200
27816
  deployedBytecode: deployedBytecode$a,
28201
27817
  linkReferences: linkReferences$a,
28202
27818
  deployedLinkReferences: deployedLinkReferences$a
28203
27819
  };
28204
27820
 
28205
- var _format$a = "hh-sol-artifact-1";
28206
- var contractName$a = "Aggregator";
28207
- var sourceName$a = "contracts/outpost/Aggregator.sol";
28208
- var abi$a = [
28209
- {
28210
- inputs: [
28211
- {
28212
- internalType: "address",
28213
- name: "_authority",
28214
- type: "address"
28215
- },
28216
- {
28217
- internalType: "int256",
28218
- name: "initialPrice",
28219
- type: "int256"
28220
- },
28221
- {
28222
- internalType: "uint8",
28223
- name: "__decimals",
28224
- type: "uint8"
28225
- }
28226
- ],
28227
- name: "initialize",
28228
- outputs: [
28229
- ],
28230
- stateMutability: "nonpayable",
28231
- type: "function"
28232
- },
28233
- {
28234
- inputs: [
28235
- ],
28236
- name: "decimals",
28237
- outputs: [
28238
- {
28239
- internalType: "uint8",
28240
- name: "",
28241
- type: "uint8"
28242
- }
28243
- ],
28244
- stateMutability: "view",
28245
- type: "function"
28246
- },
28247
- {
28248
- inputs: [
28249
- ],
28250
- name: "description",
28251
- outputs: [
28252
- {
28253
- internalType: "string",
28254
- name: "",
28255
- type: "string"
28256
- }
28257
- ],
28258
- stateMutability: "pure",
28259
- type: "function"
28260
- },
28261
- {
28262
- inputs: [
28263
- ],
28264
- name: "version",
28265
- outputs: [
28266
- {
28267
- internalType: "uint256",
28268
- name: "",
28269
- type: "uint256"
28270
- }
28271
- ],
28272
- stateMutability: "pure",
28273
- type: "function"
28274
- },
28275
- {
28276
- inputs: [
28277
- {
28278
- internalType: "uint80",
28279
- name: "",
28280
- type: "uint80"
28281
- }
28282
- ],
28283
- name: "getRoundData",
28284
- outputs: [
28285
- {
28286
- internalType: "uint80",
28287
- name: "roundId",
28288
- type: "uint80"
28289
- },
28290
- {
28291
- internalType: "int256",
28292
- name: "answer",
28293
- type: "int256"
28294
- },
28295
- {
28296
- internalType: "uint256",
28297
- name: "startedAt",
28298
- type: "uint256"
28299
- },
28300
- {
28301
- internalType: "uint256",
28302
- name: "updatedAt",
28303
- type: "uint256"
28304
- },
28305
- {
28306
- internalType: "uint80",
28307
- name: "answeredInRound",
28308
- type: "uint80"
28309
- }
28310
- ],
28311
- stateMutability: "view",
28312
- type: "function"
28313
- },
28314
- {
28315
- inputs: [
28316
- ],
28317
- name: "latestRoundData",
28318
- outputs: [
28319
- {
28320
- internalType: "uint80",
28321
- name: "roundId",
28322
- type: "uint80"
28323
- },
28324
- {
28325
- internalType: "int256",
28326
- name: "answer",
28327
- type: "int256"
28328
- },
28329
- {
28330
- internalType: "uint256",
28331
- name: "startedAt",
28332
- type: "uint256"
28333
- },
28334
- {
28335
- internalType: "uint256",
28336
- name: "updatedAt",
28337
- type: "uint256"
28338
- },
28339
- {
28340
- internalType: "uint80",
28341
- name: "answeredInRound",
28342
- type: "uint80"
28343
- }
28344
- ],
28345
- stateMutability: "view",
28346
- type: "function"
28347
- },
28348
- {
28349
- inputs: [
28350
- {
28351
- internalType: "int256",
28352
- name: "newPrice",
28353
- type: "int256"
28354
- }
28355
- ],
28356
- name: "updateAnswer",
28357
- outputs: [
28358
- ],
28359
- stateMutability: "nonpayable",
28360
- type: "function"
28361
- },
28362
- {
28363
- inputs: [
28364
- {
28365
- internalType: "int256",
28366
- name: "newPrice",
28367
- type: "int256"
28368
- },
28369
- {
28370
- internalType: "uint256",
28371
- name: "oldTimestamp",
28372
- type: "uint256"
28373
- }
28374
- ],
28375
- name: "updateStale",
28376
- outputs: [
28377
- ],
28378
- stateMutability: "nonpayable",
28379
- type: "function"
28380
- }
28381
- ];
28382
- var AggregatorArtifact = {
28383
- _format: _format$a,
28384
- contractName: contractName$a,
28385
- sourceName: sourceName$a,
28386
- abi: abi$a
28387
- };
28388
-
28389
27821
  var _format$9 = "hh-sol-artifact-1";
28390
27822
  var contractName$9 = "EthUsdPriceConsumer";
28391
27823
  var sourceName$9 = "contracts/outpost/EthUsdPriceConsumer.sol";
@@ -34800,31 +34232,30 @@ const ERC20Abi = ERC20Artifact.abi;
34800
34232
  const ERC721Abi = ERC721Artifact.abi;
34801
34233
  const ERC1155Abi = ERC1155Artifact.abi;
34802
34234
  const ADDRESSES = {
34803
- LiqEthAuthority: "0x3Eb66Bb91F7a022FbABc1619Cb6acce7025Bc41F",
34804
- BeaconState: "0x08F879c6D0964E0A17bF688Af23168f654DF372e",
34805
- WithdrawalQueue: "0x74aDeD940369baDDb0F36426F23B08499e45Fe18",
34806
- LiqEthToken: "0x8C974517D038e2e3b8a1da7b1A026bC8132A4b2e",
34807
- Accounting: "0x766CE996B8132b927988c5b2ECAE8108fB1a9307",
34808
- DepositManager: "0xEd391dB5DB11B5eDBE08e69A51D16e84293C09a3",
34809
- WithdrawalVault: "0xbaBc0D5997283ab9886696A0dEaB8A8093436b48",
34810
- StakingModule: "0x4998fBb6Ca5Ee3Db6c339e2962A34791Af643fEa",
34811
- YieldOracle: "0x61Fe311C57dd9a38Fb7B0c5A8ec521452dB25378",
34812
- OutpostManagerAuthority: "0x3B8705Ba1195AF632b3bd9E46F19348BC828FA3D",
34813
- iodata: "0x4aCABbC74a1cA9B0058d9ADAa0E00Af0f4f73212",
34814
- Base58: "0x1241F36ff30065deD52d51f0d6524EF971259A12",
34815
- sysio_merkle: "0x58ca9b5515266Fd6bF94D5F1268C505b2eC9679c",
34816
- ReceiptNFT: "0x03d6bD46cA9F54B8F8bbA21CfAfe717b36cB8593",
34817
- EthUsdPriceConsumer: "0xdC2DD993A13b3DD6D255B52285625694bd967c9A",
34818
- Pool: "0xd4742757AA61B1Fd3Fcd87980D7D460B12Cd9275",
34819
- OutpostManager: "0x38ec2B56cBCeCaFFe28b535517de1a102C3D74E3",
34820
- sysio_write: "0x0Ec4C1BaB772958aa3Db27459643bfbE7d92E305",
34821
- Pretoken: "0x8c97a51A71640fa411DEfab8feC3401eFfd1a2E4",
34822
- BAR: "0xbAFac13ffd3Aa9aEabaaeb6e4C2cF3dFf3479DC0",
34823
- OPPCommon: "0x12283a6d4E6cE4A0e8AdB319Fc161c7F4f91EA8F",
34824
- OPP: "0x87CE3Fe2CDca39C04aa2c14bbF1E1d9DB6358C4A",
34825
- Depositor: "0x5351B30EA4b75bD9be9Fc0048e88F675f7b3Ac2b",
34826
- OPPInbound: "0x0B1f7FB1c7f01A9cf490a1387E1E100F2bEA6C6d",
34827
- MockAggregator: "0xFCfc3ddd4CBd9Ad3b3af3A374B8bdA1b66eE6FFF"
34235
+ LiqEthAuthority: "0xB8fb7dBA2de501c94EAB723fa48679f698a39Aa4",
34236
+ BeaconState: "0x29719E8e76C52F5fD4888DF401579859c305f2DF",
34237
+ WithdrawalQueue: "0xce388339bFDAed9cAF536ea7b4F42123b4D755d4",
34238
+ LiqEthToken: "0x2C0e75e930Fc72ceD0725854C5E7A55566333F3f",
34239
+ Accounting: "0xE31C44d04c7B055afAC9301F55840f030eaF04BC",
34240
+ DepositManager: "0x21b339ED55A0f037f91B88044C808CcfCCBbF9A8",
34241
+ WithdrawalVault: "0x028743bE7E727aA331A1e952575cb00623B95fE2",
34242
+ StakingModule: "0xDe9754Fb58CcD4D74e94DA5682192E4e6eC334b0",
34243
+ YieldOracle: "0x7B7B8894e75b44B6cA7Dc8bE6dED5059621907b2",
34244
+ OutpostManagerAuthority: "0xeaE32b94c0F858b3600861aAE4Caeee6B6341751",
34245
+ iodata: "0x485Ed153c45189d623Bb37816eD3016A56552273",
34246
+ Base58: "0x8bB3856EC1114B1cE45a78620CF174D90a1Fd4e7",
34247
+ sysio_merkle: "0x5180a926D71c6d94c5c939Fe7Fed14cD7dcAa541",
34248
+ ReceiptNFT: "0x651De616A20b17De1095f9A0694A0e0E68025b78",
34249
+ EthUsdPriceConsumer: "0x2d866f8DB6F6c94997b0027Ba24bc64a03627ddc",
34250
+ Pool: "0xDA268Adcb90c422C2102A5f713182A42A8b9EA0D",
34251
+ OutpostManager: "0x9f279804Cb8539c53709AA37a4C1b30A52A85175",
34252
+ sysio_write: "0x3F8c880efd2c8C3aA1f0CE40b886cc6913eEC1d3",
34253
+ Pretoken: "0xCabF19Fdb7cD063738dd63a418702Ee3642FFc68",
34254
+ BAR: "0x2D8f4D4435509d7b8F93C3Ba93D45447C892f7ED",
34255
+ OPPCommon: "0x1716EEC9f1E0c1aF7BbbA8Fed10652138914f766",
34256
+ OPP: "0x5e1135cF8987268a3e7F68551558Ae92c454429f",
34257
+ Depositor: "0xf4b4ccfD684feB46504D77232FBde23b23d4F774",
34258
+ OPPInbound: "0x088484d45fF93AFabC63810FB0b335792E2B24f3"
34828
34259
  };
34829
34260
  const CONTRACTS = {
34830
34261
  LiqEthAuthority: {
@@ -34883,10 +34314,6 @@ const CONTRACTS = {
34883
34314
  address: ADDRESSES.ReceiptNFT,
34884
34315
  abi: ReceiptNFTArtifact.abi
34885
34316
  },
34886
- MockAggregator: {
34887
- address: ADDRESSES.MockAggregator,
34888
- abi: AggregatorArtifact.abi
34889
- },
34890
34317
  Pool: {
34891
34318
  address: ADDRESSES.Pool,
34892
34319
  abi: PoolArtifact.abi
@@ -35870,10 +35297,6 @@ class EthereumStakingClient {
35870
35297
  async buy(amount) {
35871
35298
  this.ensureUser();
35872
35299
  const buyer = await this.signer.getAddress();
35873
- const network = await this.provider.getNetwork();
35874
- const chainId = network.chainId;
35875
- const allowedTestChains = new Set([560048]);
35876
- if (allowedTestChains.has(chainId)) await this.updateMockAggregatorPrice();
35877
35300
  let result = await this.pretokenClient.purchasePretokensWithLiqETH(amount, buyer);
35878
35301
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
35879
35302
  }
@@ -35987,7 +35410,7 @@ class EthereumStakingClient {
35987
35410
  }
35988
35411
  async getTrancheSnapshot(options) {
35989
35412
  const {
35990
- chainID = EvmChainID.Hoodi,
35413
+ chainID = EvmChainID.Ethereum,
35991
35414
  windowBefore,
35992
35415
  windowAfter
35993
35416
  } = options ?? {};
@@ -36008,10 +35431,8 @@ class EthereumStakingClient {
36008
35431
  ]);
36009
35432
  const totalTrancheSupply = BigInt(totalSupplyBn.toString()) / BigInt(1e10);
36010
35433
  const currentTrancheSupply = BigInt(trancheSupplyBn.toString()) / BigInt(1e10);
36011
- const [roundId, answer, startedAt, updatedAt, answeredInRound] = await this.contract.MockAggregator.latestRoundData();
36012
35434
  let ethPriceUsdBn = await this.contract.EthUsdPriceConsumer.getPrice18Decimals();
36013
35435
  let ethPriceUsd = BigInt(ethPriceUsdBn.toString()) / BigInt(1e10);
36014
- let nativePriceTimestamp = Number(updatedAt);
36015
35436
  const initialTrancheSupply = BigInt(INITIAL_TRANCHE_SUPPLY) * BigInt(1e8);
36016
35437
  return buildEthereumTrancheSnapshot({
36017
35438
  chainID,
@@ -36027,7 +35448,6 @@ class EthereumStakingClient {
36027
35448
  minPriceUsd,
36028
35449
  maxPriceUsd,
36029
35450
  ethPriceUsd,
36030
- nativePriceTimestamp,
36031
35451
  ladderWindowBefore: windowBefore,
36032
35452
  ladderWindowAfter: windowAfter
36033
35453
  });
@@ -36060,34 +35480,6 @@ class EthereumStakingClient {
36060
35480
  }
36061
35481
  return bufferWei;
36062
35482
  }
36063
- async updateMockAggregatorPrice() {
36064
- const aggregator = this.contract.MockAggregator;
36065
- const [roundId, answer, startedAt, updatedAt, answeredInRound] = await aggregator.latestRoundData();
36066
- const now = (await this.provider.getBlock("latest")).timestamp;
36067
- const ageSec = Number(now) - Number(updatedAt);
36068
- const ONE_HOUR = 1 * 3600;
36069
- if (ageSec > ONE_HOUR) {
36070
- const network = await this.provider.getNetwork();
36071
- const chainId = network.chainId;
36072
- const allowedTestChains = new Set([560048]);
36073
- if (!allowedTestChains.has(chainId)) {
36074
- console.warn(`MockAggregator is stale (${ageSec}s) but chainId ${chainId} is not a test/local network \u2014 skipping update.`);
36075
- return;
36076
- }
36077
- const res = await fetch("https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd");
36078
- const data = await res.json();
36079
- const ethUsd = data.ethereum.usd;
36080
- const currentEthPrice = ethers.utils.parseUnits(ethUsd.toString(), 8);
36081
- try {
36082
- const tx = await aggregator.updateAnswer(currentEthPrice);
36083
- const txreceipt = await tx.wait(1);
36084
- } catch (err) {
36085
- console.error("MockAggregator updateAnswer failed", err?.message || err);
36086
- }
36087
- } else {
36088
- console.log(`MockAggregator updated ${ageSec}s ago \u2014 no update needed`);
36089
- }
36090
- }
36091
35483
  }
36092
35484
 
36093
35485
  class Staker {
@@ -36097,12 +35489,10 @@ class Staker {
36097
35489
  if (!Array.isArray(config)) config = [config];
36098
35490
  config.forEach((cfg) => {
36099
35491
  switch (cfg.network.chainId) {
36100
- case SolChainID.Devnet:
36101
- case SolChainID.WireTestnet:
35492
+ case SolChainID.Mainnet:
36102
35493
  this.clients.set(cfg.network.chainId, new SolanaStakingClient(cfg));
36103
35494
  break;
36104
35495
  case EvmChainID.Ethereum:
36105
- case EvmChainID.Hoodi:
36106
35496
  this.clients.set(cfg.network.chainId, new EthereumStakingClient(cfg));
36107
35497
  break;
36108
35498
  default:
@@ -36142,7 +35532,6 @@ const CONTRACT_NAMES = [
36142
35532
  "Base58",
36143
35533
  "sysio_merkle",
36144
35534
  "ReceiptNFT",
36145
- "MockAggregator",
36146
35535
  "Pool",
36147
35536
  "OutpostManager",
36148
35537
  "sysio_write",