@wireio/stake 2.1.1 → 2.2.2

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.js CHANGED
@@ -28,7 +28,7 @@ function _interopNamespaceDefault(e) {
28
28
  var multisig__namespace = /*#__PURE__*/_interopNamespaceDefault(multisig);
29
29
 
30
30
  var __pow = Math.pow;
31
- var __async$g = (__this, __arguments, generator) => {
31
+ var __async$h = (__this, __arguments, generator) => {
32
32
  return new Promise((resolve, reject) => {
33
33
  var fulfilled = (value) => {
34
34
  try {
@@ -61,7 +61,7 @@ class DepositClient {
61
61
  return this.provider.wallet;
62
62
  }
63
63
  buildDepositTx(_0) {
64
- return __async$g(this, arguments, function* (amount, user = this.wallet.publicKey) {
64
+ return __async$h(this, arguments, function* (amount, user = this.wallet.publicKey) {
65
65
  if (!user) {
66
66
  throw new Error(
67
67
  "DepositClient.buildDepositTx: wallet not connected"
@@ -128,7 +128,7 @@ class DepositClient {
128
128
  });
129
129
  }
130
130
  buildWithdrawTx(_0) {
131
- return __async$g(this, arguments, function* (amount, user = this.wallet.publicKey) {
131
+ return __async$h(this, arguments, function* (amount, user = this.wallet.publicKey) {
132
132
  if (!user) {
133
133
  throw new Error(
134
134
  "DepositClient.buildWithdrawTx: wallet not connected"
@@ -186,7 +186,7 @@ class DepositClient {
186
186
  true,
187
187
  splToken.TOKEN_2022_PROGRAM_ID
188
188
  );
189
- const ix = yield this.program.methods.requestWithdraw(new anchor.BN(amount.toString())).accounts({
189
+ return yield this.program.methods.requestWithdraw(new anchor.BN(amount.toString())).accounts({
190
190
  user,
191
191
  owner,
192
192
  global,
@@ -212,71 +212,6 @@ class DepositClient {
212
212
  rent: web3_js.SYSVAR_RENT_PUBKEY,
213
213
  globalConfig
214
214
  }).instruction();
215
- return new web3_js.Transaction().add(ix);
216
- });
217
- }
218
- buildDepositIxForUser(amount, user) {
219
- return __async$g(this, null, function* () {
220
- if (!user) {
221
- throw new Error("buildDepositIxForUser: user is required");
222
- }
223
- if (!amount || amount <= BigInt(0)) {
224
- throw new Error("buildDepositIxForUser: amount must be > 0");
225
- }
226
- const depositAuthority = this.pgs.deriveDepositAuthorityPda();
227
- const liqsolMint = this.pgs.deriveLiqsolMintPda();
228
- const liqsolMintAuthority = this.pgs.deriveLiqsolMintAuthorityPda();
229
- const reservePool = this.pgs.deriveReservePoolPda();
230
- const vault = this.pgs.deriveVaultPda();
231
- const controllerState = this.pgs.deriveStakeControllerStatePda();
232
- const payoutState = this.pgs.derivePayoutStatePda();
233
- const bucketAuthority = this.pgs.deriveBucketAuthorityPda();
234
- const payRateHistory = this.pgs.derivePayRateHistoryPda();
235
- const globalConfig = this.pgs.deriveGlobalConfigPda();
236
- const userAta = splToken.getAssociatedTokenAddressSync(
237
- liqsolMint,
238
- user,
239
- true,
240
- splToken.TOKEN_2022_PROGRAM_ID
241
- );
242
- const distributionState = this.pgs.deriveDistributionStatePda();
243
- const userRecord = this.pgs.deriveUserRecordPda(userAta);
244
- const bucketTokenAccount = splToken.getAssociatedTokenAddressSync(
245
- liqsolMint,
246
- bucketAuthority,
247
- true,
248
- splToken.TOKEN_2022_PROGRAM_ID
249
- );
250
- const seed = Math.floor(Math.random() * __pow(2, 32));
251
- const ephemeralStake = yield this.pgs.deriveEphemeralStakeAddress(user, seed);
252
- const ix = yield this.program.methods.deposit(new anchor.BN(amount.toString()), seed).accounts({
253
- user,
254
- depositAuthority,
255
- systemProgram: web3_js.SystemProgram.programId,
256
- tokenProgram: splToken.TOKEN_2022_PROGRAM_ID,
257
- associatedTokenProgram: splToken.ASSOCIATED_TOKEN_PROGRAM_ID,
258
- liqsolProgram: this.pgs.PROGRAM_IDS.LIQSOL_TOKEN,
259
- stakeProgram: web3_js.StakeProgram.programId,
260
- liqsolMint,
261
- userAta,
262
- liqsolMintAuthority,
263
- reservePool,
264
- vault,
265
- ephemeralStake,
266
- controllerState,
267
- payoutState,
268
- bucketAuthority,
269
- bucketTokenAccount,
270
- userRecord,
271
- distributionState,
272
- payRateHistory,
273
- instructionsSysvar: web3_js.SYSVAR_INSTRUCTIONS_PUBKEY,
274
- clock: web3_js.SYSVAR_CLOCK_PUBKEY,
275
- stakeHistory: web3_js.SYSVAR_STAKE_HISTORY_PUBKEY,
276
- rent: web3_js.SYSVAR_RENT_PUBKEY,
277
- globalConfig
278
- }).instruction();
279
- return { ix, seed, userAta, ephemeralStake };
280
215
  });
281
216
  }
282
217
  }
@@ -14703,7 +14638,7 @@ var devnetTransferHookIDL = {
14703
14638
  types: types$2
14704
14639
  };
14705
14640
 
14706
- var __async$f = (__this, __arguments, generator) => {
14641
+ var __async$g = (__this, __arguments, generator) => {
14707
14642
  return new Promise((resolve, reject) => {
14708
14643
  var fulfilled = (value) => {
14709
14644
  try {
@@ -14727,13 +14662,15 @@ const MAINNET_PROGRAM_IDS = {
14727
14662
  LIQSOL_CORE: new web3_js.PublicKey(liqsolCoreMainnetJson.address),
14728
14663
  LIQSOL_TOKEN: new web3_js.PublicKey(liqsolTokenMainnetJson.address),
14729
14664
  VALIDATOR_LEADERBOARD: new web3_js.PublicKey(validatorLeaderboardMainnetJson.address),
14730
- TRANSFER_HOOK: new web3_js.PublicKey(mainnetTransferHookIDL.address)
14665
+ TRANSFER_HOOK: new web3_js.PublicKey(mainnetTransferHookIDL.address),
14666
+ ALT_LOOKUP_TABLE: new web3_js.PublicKey("AQXTHwkdNBEiXeQuVA5uCoxvzgYUmudRxthQY4vWKCPS")
14731
14667
  };
14732
14668
  const DEVNET_PROGRAM_IDS = {
14733
14669
  LIQSOL_CORE: new web3_js.PublicKey(liqsolCoreDevnetJson.address),
14734
14670
  LIQSOL_TOKEN: new web3_js.PublicKey(liqsolTokenDevnetJson.address),
14735
14671
  VALIDATOR_LEADERBOARD: new web3_js.PublicKey(validatorLeaderboardDevnetJson.address),
14736
- TRANSFER_HOOK: new web3_js.PublicKey(devnetTransferHookIDL.address)
14672
+ TRANSFER_HOOK: new web3_js.PublicKey(devnetTransferHookIDL.address),
14673
+ ALT_LOOKUP_TABLE: new web3_js.PublicKey("3MbupRDxUqPtJzoLLmjEYV3dXJdh1jojQrpDEQUqv7xb")
14737
14674
  };
14738
14675
  const PROGRAM_IDS_BY_CHAIN = {
14739
14676
  [core.SolChainID.Mainnet]: MAINNET_PROGRAM_IDS,
@@ -14779,7 +14716,7 @@ const PDA_SEEDS = {
14779
14716
  LIQ_RECEIPT_DATA: "liq_receipt_data",
14780
14717
  WITHDRAW_MINT: "mint"
14781
14718
  };
14782
- const deriveEphemeralStakeAddress = (user, seed) => __async$f(null, null, function* () {
14719
+ const deriveEphemeralStakeAddress = (user, seed) => __async$g(null, null, function* () {
14783
14720
  const seedStr = `ephemeral_${seed}`;
14784
14721
  return web3_js.PublicKey.createWithSeed(user, seedStr, web3_js.StakeProgram.programId);
14785
14722
  });
@@ -14798,7 +14735,7 @@ const INDEX_SCALE$1 = BigInt(1e12);
14798
14735
  const lamportsToSol = (lamports) => Number(lamports) / LAMPORTS_PER_SOL;
14799
14736
  const solToLamports = (sol) => BigInt(Math.round(sol * LAMPORTS_PER_SOL));
14800
14737
 
14801
- var __async$e = (__this, __arguments, generator) => {
14738
+ var __async$f = (__this, __arguments, generator) => {
14802
14739
  return new Promise((resolve, reject) => {
14803
14740
  var fulfilled = (value) => {
14804
14741
  try {
@@ -14952,7 +14889,7 @@ function buildSolanaTrancheSnapshot(options) {
14952
14889
  };
14953
14890
  }
14954
14891
  function buildOutpostAccounts(connection, user, pgs) {
14955
- return __async$e(this, null, function* () {
14892
+ return __async$f(this, null, function* () {
14956
14893
  const globalState = pgs.deriveOutpostGlobalStatePda();
14957
14894
  const poolAuthority = pgs.deriveOutpostPoolAuthorityPda();
14958
14895
  const liqsolMint = pgs.deriveLiqsolMintPda();
@@ -14976,7 +14913,7 @@ function buildOutpostAccounts(connection, user, pgs) {
14976
14913
  const userAta = yield splToken.getAssociatedTokenAddress(
14977
14914
  liqsolMint,
14978
14915
  user,
14979
- false,
14916
+ true,
14980
14917
  splToken.TOKEN_2022_PROGRAM_ID
14981
14918
  );
14982
14919
  const bucketUserRecord = pgs.deriveUserRecordPda(bucketTokenAccount);
@@ -15017,7 +14954,7 @@ function buildOutpostAccounts(connection, user, pgs) {
15017
14954
  });
15018
14955
  }
15019
14956
  function getEpochSnapshot(connection) {
15020
- return __async$e(this, null, function* () {
14957
+ return __async$f(this, null, function* () {
15021
14958
  var _a;
15022
14959
  const info = yield connection.getEpochInfo();
15023
14960
  let slotTimeMs = Number((_a = process.env.SLOT_TIME_MS_FALLBACK) != null ? _a : 400);
@@ -15048,7 +14985,7 @@ function msToEpochEnd(snapshot) {
15048
14985
  return remainingSlots * snapshot.slotMs;
15049
14986
  }
15050
14987
  function scheduledInstruction(connection, config, instruction) {
15051
- return __async$e(this, null, function* () {
14988
+ return __async$f(this, null, function* () {
15052
14989
  var _a, _b;
15053
14990
  const early = (_a = config.early) != null ? _a : 0.1;
15054
14991
  const late = (_b = config.late) != null ? _b : 0.9;
@@ -15095,14 +15032,14 @@ function generateTestKeypair() {
15095
15032
  return web3_js.Keypair.generate();
15096
15033
  }
15097
15034
  function airdropSol(connection, publicKey, amountSol) {
15098
- return __async$e(this, null, function* () {
15035
+ return __async$f(this, null, function* () {
15099
15036
  const lamports = solToLamports(amountSol);
15100
15037
  const sig = yield connection.requestAirdrop(publicKey, Number(lamports));
15101
15038
  yield connection.confirmTransaction(sig, "confirmed");
15102
15039
  });
15103
15040
  }
15104
15041
  function waitForConfirmation(connection, signature) {
15105
- return __async$e(this, null, function* () {
15042
+ return __async$f(this, null, function* () {
15106
15043
  yield connection.confirmTransaction(signature, "confirmed");
15107
15044
  });
15108
15045
  }
@@ -15110,8 +15047,8 @@ function sleep(ms) {
15110
15047
  return new Promise((resolve) => setTimeout(resolve, ms));
15111
15048
  }
15112
15049
  function waitUntilSafeToExecuteFunction(_0) {
15113
- return __async$e(this, arguments, function* (connection, config = {}) {
15114
- yield scheduledInstruction(connection, config, () => __async$e(null, null, function* () {
15050
+ return __async$f(this, arguments, function* (connection, config = {}) {
15051
+ yield scheduledInstruction(connection, config, () => __async$f(null, null, function* () {
15115
15052
  return;
15116
15053
  }));
15117
15054
  });
@@ -15123,7 +15060,7 @@ function ceilDiv(n, d) {
15123
15060
  return n.add(d.subn(1)).div(d);
15124
15061
  }
15125
15062
 
15126
- var __async$d = (__this, __arguments, generator) => {
15063
+ var __async$e = (__this, __arguments, generator) => {
15127
15064
  return new Promise((resolve, reject) => {
15128
15065
  var fulfilled = (value) => {
15129
15066
  try {
@@ -15153,7 +15090,7 @@ class DistributionClient {
15153
15090
  return this.provider.connection;
15154
15091
  }
15155
15092
  getDistributionState() {
15156
- return __async$d(this, null, function* () {
15093
+ return __async$e(this, null, function* () {
15157
15094
  const pda = this.pgs.deriveDistributionStatePda();
15158
15095
  try {
15159
15096
  return yield this.program.account.distributionState.fetch(pda);
@@ -15163,7 +15100,7 @@ class DistributionClient {
15163
15100
  });
15164
15101
  }
15165
15102
  getPayRateHistory() {
15166
- return __async$d(this, null, function* () {
15103
+ return __async$e(this, null, function* () {
15167
15104
  const pda = this.pgs.derivePayRateHistoryPda();
15168
15105
  try {
15169
15106
  return yield this.program.account.payRateHistory.fetch(
@@ -15175,7 +15112,7 @@ class DistributionClient {
15175
15112
  });
15176
15113
  }
15177
15114
  getGlobalConfig() {
15178
- return __async$d(this, null, function* () {
15115
+ return __async$e(this, null, function* () {
15179
15116
  const pda = this.pgs.deriveGlobalConfigPda();
15180
15117
  try {
15181
15118
  return yield this.program.account.globalConfig.fetch(
@@ -15187,7 +15124,7 @@ class DistributionClient {
15187
15124
  });
15188
15125
  }
15189
15126
  getUserRecord(ownerOrAta) {
15190
- return __async$d(this, null, function* () {
15127
+ return __async$e(this, null, function* () {
15191
15128
  const liqsolMint = this.pgs.deriveLiqsolMintPda();
15192
15129
  try {
15193
15130
  const ata = splToken.getAssociatedTokenAddressSync(
@@ -15212,13 +15149,13 @@ class DistributionClient {
15212
15149
  });
15213
15150
  }
15214
15151
  getUserShares(user) {
15215
- return __async$d(this, null, function* () {
15152
+ return __async$e(this, null, function* () {
15216
15153
  const record = yield this.getUserRecord(user);
15217
15154
  return record ? record.shares : new anchor.BN(0);
15218
15155
  });
15219
15156
  }
15220
15157
  getUserSharePosition(user) {
15221
- return __async$d(this, null, function* () {
15158
+ return __async$e(this, null, function* () {
15222
15159
  const [dist, userShares] = yield Promise.all([
15223
15160
  this.getDistributionState(),
15224
15161
  this.getUserShares(user)
@@ -15232,7 +15169,7 @@ class DistributionClient {
15232
15169
  });
15233
15170
  }
15234
15171
  getAverageScaledPayRate(windowSize = 5) {
15235
- return __async$d(this, null, function* () {
15172
+ return __async$e(this, null, function* () {
15236
15173
  var _a, _b, _c, _d, _e;
15237
15174
  const history = yield this.getPayRateHistory();
15238
15175
  if (!history) {
@@ -15282,7 +15219,7 @@ class DistributionClient {
15282
15219
  }
15283
15220
  }
15284
15221
 
15285
- var __async$c = (__this, __arguments, generator) => {
15222
+ var __async$d = (__this, __arguments, generator) => {
15286
15223
  return new Promise((resolve, reject) => {
15287
15224
  var fulfilled = (value) => {
15288
15225
  try {
@@ -15309,7 +15246,7 @@ class LeaderboardClient {
15309
15246
  this.program = pgs.getProgram("validatorLeaderboard");
15310
15247
  }
15311
15248
  getState() {
15312
- return __async$c(this, null, function* () {
15249
+ return __async$d(this, null, function* () {
15313
15250
  const pda = this.pgs.deriveLeaderboardStatePda();
15314
15251
  try {
15315
15252
  return yield this.program.account.leaderboardState.fetch(pda);
@@ -15319,7 +15256,7 @@ class LeaderboardClient {
15319
15256
  });
15320
15257
  }
15321
15258
  getValidatorRecord(voteAccount) {
15322
- return __async$c(this, null, function* () {
15259
+ return __async$d(this, null, function* () {
15323
15260
  const pda = this.pgs.deriveValidatorRecordPda(voteAccount);
15324
15261
  try {
15325
15262
  return yield this.program.account.validatorRecord.fetchNullable(pda);
@@ -15329,7 +15266,7 @@ class LeaderboardClient {
15329
15266
  });
15330
15267
  }
15331
15268
  getTopValidators(limit = 20) {
15332
- return __async$c(this, null, function* () {
15269
+ return __async$d(this, null, function* () {
15333
15270
  try {
15334
15271
  const leaderboardPda = this.pgs.deriveLeaderboardStatePda();
15335
15272
  const leaderboard = yield this.program.account.leaderboardState.fetch(leaderboardPda);
@@ -15368,7 +15305,7 @@ class LeaderboardClient {
15368
15305
  }
15369
15306
  }
15370
15307
 
15371
- var __async$b = (__this, __arguments, generator) => {
15308
+ var __async$c = (__this, __arguments, generator) => {
15372
15309
  return new Promise((resolve, reject) => {
15373
15310
  var fulfilled = (value) => {
15374
15311
  try {
@@ -15401,7 +15338,7 @@ class OutpostClient {
15401
15338
  return this.provider.wallet;
15402
15339
  }
15403
15340
  buildAccounts(user) {
15404
- return __async$b(this, null, function* () {
15341
+ return __async$c(this, null, function* () {
15405
15342
  const userPk = user != null ? user : this.wallet.publicKey;
15406
15343
  if (!userPk) {
15407
15344
  throw new Error("OutpostClient.buildAccounts: wallet not connected");
@@ -15410,7 +15347,7 @@ class OutpostClient {
15410
15347
  });
15411
15348
  }
15412
15349
  getTokenBalance(ata) {
15413
- return __async$b(this, null, function* () {
15350
+ return __async$c(this, null, function* () {
15414
15351
  try {
15415
15352
  const bal = yield this.connection.getTokenAccountBalance(ata);
15416
15353
  return new anchor.BN(bal.value.amount);
@@ -15420,7 +15357,7 @@ class OutpostClient {
15420
15357
  });
15421
15358
  }
15422
15359
  fetchWireState(user) {
15423
- return __async$b(this, null, function* () {
15360
+ return __async$c(this, null, function* () {
15424
15361
  const userPk = user != null ? user : this.wallet.publicKey;
15425
15362
  if (!userPk) {
15426
15363
  throw new Error("OutpostClient.fetchWireState: wallet not connected");
@@ -15459,15 +15396,14 @@ class OutpostClient {
15459
15396
  }
15460
15397
  });
15461
15398
  }
15462
- buildStakeIx(amountLamports, user) {
15463
- return __async$b(this, null, function* () {
15464
- const userPk = user != null ? user : this.wallet.publicKey;
15465
- if (!userPk) {
15399
+ buildStakeIx(_0) {
15400
+ return __async$c(this, arguments, function* (amountLamports, user = this.wallet.publicKey) {
15401
+ if (!user) {
15466
15402
  throw new Error("OutpostClient.buildStakeIx: wallet not connected");
15467
15403
  }
15468
- const a = yield this.buildAccounts(userPk);
15404
+ const a = yield this.buildAccounts(user);
15469
15405
  return this.program.methods.synd(new anchor.BN(amountLamports.toString())).accounts({
15470
- user: userPk,
15406
+ user,
15471
15407
  liqsolMint: a.liqsolMint,
15472
15408
  globalState: a.globalState,
15473
15409
  distributionState: a.distributionState,
@@ -15490,7 +15426,7 @@ class OutpostClient {
15490
15426
  });
15491
15427
  }
15492
15428
  buildUnstakeIx(amountLamports, user) {
15493
- return __async$b(this, null, function* () {
15429
+ return __async$c(this, null, function* () {
15494
15430
  const userPk = user != null ? user : this.wallet.publicKey;
15495
15431
  if (!userPk) {
15496
15432
  throw new Error("OutpostClient.buildUnstakeIx: wallet not connected");
@@ -15553,7 +15489,7 @@ class OutpostClient {
15553
15489
  }
15554
15490
  }
15555
15491
 
15556
- var __async$a = (__this, __arguments, generator) => {
15492
+ var __async$b = (__this, __arguments, generator) => {
15557
15493
  return new Promise((resolve, reject) => {
15558
15494
  var fulfilled = (value) => {
15559
15495
  try {
@@ -15586,30 +15522,30 @@ class TokenClient {
15586
15522
  return this.provider.connection;
15587
15523
  }
15588
15524
  getAccounts(user) {
15589
- return __async$a(this, null, function* () {
15525
+ return __async$b(this, null, function* () {
15590
15526
  return buildOutpostAccounts(this.provider.connection, user, this.pgs);
15591
15527
  });
15592
15528
  }
15593
15529
  fetchGlobalState() {
15594
- return __async$a(this, null, function* () {
15530
+ return __async$b(this, null, function* () {
15595
15531
  const { globalState } = yield this.getAccounts(this.wallet.publicKey);
15596
15532
  return this.program.account.globalState.fetch(globalState);
15597
15533
  });
15598
15534
  }
15599
15535
  fetchTrancheState() {
15600
- return __async$a(this, null, function* () {
15536
+ return __async$b(this, null, function* () {
15601
15537
  const { trancheState } = yield this.getAccounts(this.wallet.publicKey);
15602
15538
  return this.program.account.trancheState.fetch(trancheState);
15603
15539
  });
15604
15540
  }
15605
15541
  fetchOutpostAccount(user) {
15606
- return __async$a(this, null, function* () {
15542
+ return __async$b(this, null, function* () {
15607
15543
  const { outpostAccount } = yield this.getAccounts(user);
15608
15544
  return this.program.account.outpostAccount.fetchNullable(outpostAccount);
15609
15545
  });
15610
15546
  }
15611
15547
  fetchUserPretokenRecord(user) {
15612
- return __async$a(this, null, function* () {
15548
+ return __async$b(this, null, function* () {
15613
15549
  const { userPretokenRecord } = yield this.getAccounts(user);
15614
15550
  return this.program.account.userPretokenRecord.fetchNullable(
15615
15551
  userPretokenRecord
@@ -15617,8 +15553,9 @@ class TokenClient {
15617
15553
  });
15618
15554
  }
15619
15555
  buildPurchaseIx(_0) {
15620
- return __async$a(this, arguments, function* (amountLamports, user = this.wallet.publicKey) {
15556
+ return __async$b(this, arguments, function* (amountLamports, user = this.wallet.publicKey) {
15621
15557
  var _a, _b;
15558
+ console.log("build purchase for", user.toBase58());
15622
15559
  const a = yield this.getAccounts(user);
15623
15560
  const extraAccountMetaList = this.pgs.deriveExtraAccountMetaListPda(a.liqsolMint);
15624
15561
  const liqsolCoreProgram = this.pgs.PROGRAM_IDS.LIQSOL_CORE;
@@ -15651,7 +15588,7 @@ class TokenClient {
15651
15588
  });
15652
15589
  }
15653
15590
  getSolPriceUsdSafe() {
15654
- return __async$a(this, null, function* () {
15591
+ return __async$b(this, null, function* () {
15655
15592
  try {
15656
15593
  const price = yield this.getSolPriceUsd();
15657
15594
  return { price, timestamp: void 0 };
@@ -15661,7 +15598,7 @@ class TokenClient {
15661
15598
  });
15662
15599
  }
15663
15600
  getSolPriceUsd() {
15664
- return __async$a(this, null, function* () {
15601
+ return __async$b(this, null, function* () {
15665
15602
  const priceHistoryPda = this.pgs.derivePriceHistoryPda();
15666
15603
  const history = yield this.program.account.priceHistory.fetch(
15667
15604
  priceHistoryPda
@@ -15707,7 +15644,7 @@ var __spreadValues = (a, b) => {
15707
15644
  return a;
15708
15645
  };
15709
15646
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
15710
- var __async$9 = (__this, __arguments, generator) => {
15647
+ var __async$a = (__this, __arguments, generator) => {
15711
15648
  return new Promise((resolve, reject) => {
15712
15649
  var fulfilled = (value) => {
15713
15650
  try {
@@ -15985,14 +15922,14 @@ class SolanaProgramService {
15985
15922
  )[0];
15986
15923
  }
15987
15924
  deriveEphemeralStakeAddress(user, seed) {
15988
- return __async$9(this, null, function* () {
15925
+ return __async$a(this, null, function* () {
15989
15926
  const seedStr = `ephemeral_${seed}`;
15990
15927
  return web3_js.PublicKey.createWithSeed(user, seedStr, web3_js.StakeProgram.programId);
15991
15928
  });
15992
15929
  }
15993
15930
  }
15994
15931
 
15995
- var __async$8 = (__this, __arguments, generator) => {
15932
+ var __async$9 = (__this, __arguments, generator) => {
15996
15933
  return new Promise((resolve, reject) => {
15997
15934
  var fulfilled = (value) => {
15998
15935
  try {
@@ -16054,12 +15991,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16054
15991
  const anchorWallet = adapter ? {
16055
15992
  publicKey: solWalletPubkey,
16056
15993
  signTransaction(tx) {
16057
- return __async$8(this, null, function* () {
15994
+ return __async$9(this, null, function* () {
16058
15995
  return adapter.signTransaction(tx);
16059
15996
  });
16060
15997
  },
16061
15998
  signAllTransactions(txs) {
16062
- return __async$8(this, null, function* () {
15999
+ return __async$9(this, null, function* () {
16063
16000
  if (adapter.signAllTransactions) {
16064
16001
  return adapter.signAllTransactions(txs);
16065
16002
  }
@@ -16071,14 +16008,14 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16071
16008
  } : {
16072
16009
  publicKey: solWalletPubkey,
16073
16010
  signTransaction(_tx) {
16074
- return __async$8(this, null, function* () {
16011
+ return __async$9(this, null, function* () {
16075
16012
  throw new Error(
16076
16013
  "Wallet not connected: signTransaction not available"
16077
16014
  );
16078
16015
  });
16079
16016
  },
16080
16017
  signAllTransactions(_txs) {
16081
- return __async$8(this, null, function* () {
16018
+ return __async$9(this, null, function* () {
16082
16019
  throw new Error(
16083
16020
  "Wallet not connected: signAllTransactions not available"
16084
16021
  );
@@ -16113,77 +16050,14 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16113
16050
  const config = (_a = this.config.extras) == null ? void 0 : _a.squadsX;
16114
16051
  return config != null ? config : null;
16115
16052
  }
16116
- createVaultLiqsolAtaOneShot(params) {
16117
- return __async$8(this, null, function* () {
16118
- const { connection, payer, vaultPda } = params;
16119
- const liqsolMint = this.program.deriveLiqsolMintPda();
16120
- const vaultAta = splToken.getAssociatedTokenAddressSync(
16121
- liqsolMint,
16122
- vaultPda,
16123
- true,
16124
- splToken.TOKEN_2022_PROGRAM_ID,
16125
- splToken.ASSOCIATED_TOKEN_PROGRAM_ID
16126
- );
16127
- const info = yield connection.getAccountInfo(vaultAta, "confirmed");
16128
- if (info) return null;
16129
- const ix = splToken.createAssociatedTokenAccountInstruction(
16130
- payer,
16131
- vaultAta,
16132
- vaultPda,
16133
- liqsolMint,
16134
- splToken.TOKEN_2022_PROGRAM_ID,
16135
- splToken.ASSOCIATED_TOKEN_PROGRAM_ID
16136
- );
16137
- const tx = new web3_js.Transaction().add(ix);
16138
- return { tx, vaultAta };
16139
- });
16140
- }
16141
- prepSquadsIxs(ix) {
16142
- return __async$8(this, null, function* () {
16143
- var _a, _b, _c, _d;
16144
- if (!this.squadsX) throw new Error("Attempting to wrap Squads instruction without SquadsX config");
16145
- const multisigPda = this.squadsMultisigPDA;
16146
- const vaultPda = this.squadsVaultPDA;
16147
- const vaultIndex = (_b = (_a = this.squadsX) == null ? void 0 : _a.vaultIndex) != null ? _b : 0;
16148
- const creator = this.solPubKey;
16149
- const ms = yield multisig__namespace.accounts.Multisig.fromAccountAddress(this.connection, multisigPda);
16150
- const current = BigInt((_d = (_c = ms.transactionIndex) == null ? void 0 : _c.toString()) != null ? _d : 0);
16151
- const transactionIndex = current + BigInt(1);
16152
- const { blockhash } = yield this.connection.getLatestBlockhash("confirmed");
16153
- const transactionMessage = new web3_js.TransactionMessage({
16154
- payerKey: vaultPda,
16155
- recentBlockhash: blockhash,
16156
- instructions: [ix]
16157
- });
16158
- const createVaultTxIx = yield multisig__namespace.instructions.vaultTransactionCreate({
16159
- multisigPda,
16160
- transactionIndex,
16161
- creator,
16162
- vaultIndex,
16163
- transactionMessage,
16164
- ephemeralSigners: 0
16165
- });
16166
- const createProposalIx = yield multisig__namespace.instructions.proposalCreate({
16167
- multisigPda,
16168
- transactionIndex,
16169
- creator
16170
- });
16171
- return [createVaultTxIx, createProposalIx];
16172
- });
16173
- }
16174
16053
  deposit(amountLamports) {
16175
- return __async$8(this, null, function* () {
16054
+ return __async$9(this, null, function* () {
16176
16055
  this.ensureUser();
16177
- if (amountLamports <= BigInt(0)) {
16056
+ if (amountLamports <= BigInt(0))
16178
16057
  throw new Error("Deposit amount must be greater than zero.");
16179
- }
16180
16058
  try {
16181
- const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16182
- const ix = yield this.depositClient.buildDepositTx(amountLamports);
16183
- const tx = new web3_js.Transaction().add(ix);
16184
- const prepared = yield this.prepareTx(tx);
16185
- const signed = yield this.signTransaction(prepared.tx);
16186
- return this.sendAndConfirmHttp(signed, prepared);
16059
+ const ix = yield this.depositClient.buildDepositTx(amountLamports, this.squadsVaultPDA);
16060
+ return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
16187
16061
  } catch (err) {
16188
16062
  console.log(`Failed to deposit Solana: ${err}`);
16189
16063
  throw err;
@@ -16191,18 +16065,13 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16191
16065
  });
16192
16066
  }
16193
16067
  withdraw(amountLamports) {
16194
- return __async$8(this, null, function* () {
16068
+ return __async$9(this, null, function* () {
16195
16069
  this.ensureUser();
16196
- if (amountLamports <= BigInt(0)) {
16070
+ if (amountLamports <= BigInt(0))
16197
16071
  throw new Error("Withdraw amount must be greater than zero.");
16198
- }
16199
16072
  try {
16200
- const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16201
- const ix = yield this.depositClient.buildWithdrawTx(amountLamports);
16202
- const tx = new web3_js.Transaction().add(cuIx, ix);
16203
- const prepared = yield this.prepareTx(tx);
16204
- const signed = yield this.signTransaction(prepared.tx);
16205
- return this.sendAndConfirmHttp(signed, prepared);
16073
+ const ix = yield this.depositClient.buildWithdrawTx(amountLamports, this.squadsVaultPDA);
16074
+ return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
16206
16075
  } catch (err) {
16207
16076
  console.log(`Failed to withdraw Solana: ${err}`);
16208
16077
  throw err;
@@ -16210,19 +16079,13 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16210
16079
  });
16211
16080
  }
16212
16081
  stake(amountLamports) {
16213
- return __async$8(this, null, function* () {
16082
+ return __async$9(this, null, function* () {
16214
16083
  this.ensureUser();
16215
- if (!amountLamports || amountLamports <= BigInt(0)) {
16084
+ if (!amountLamports || amountLamports <= BigInt(0))
16216
16085
  throw new Error("Stake amount must be greater than zero.");
16217
- }
16218
16086
  try {
16219
- const user = this.solPubKey;
16220
- const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16221
- const ix = yield this.outpostClient.buildStakeIx(amountLamports, user);
16222
- const tx = new web3_js.Transaction().add(cuIx, ix);
16223
- const prepared = yield this.prepareTx(tx);
16224
- const signed = yield this.signTransaction(prepared.tx);
16225
- return this.sendAndConfirmHttp(signed, prepared);
16087
+ const ix = yield this.outpostClient.buildStakeIx(amountLamports, this.squadsVaultPDA);
16088
+ return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
16226
16089
  } catch (err) {
16227
16090
  console.log(`Failed to stake Solana: ${err}`);
16228
16091
  throw err;
@@ -16230,19 +16093,13 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16230
16093
  });
16231
16094
  }
16232
16095
  unstake(amountLamports) {
16233
- return __async$8(this, null, function* () {
16096
+ return __async$9(this, null, function* () {
16234
16097
  this.ensureUser();
16235
- if (!amountLamports || amountLamports <= BigInt(0)) {
16098
+ if (!amountLamports || amountLamports <= BigInt(0))
16236
16099
  throw new Error("Unstake amount must be greater than zero.");
16237
- }
16238
16100
  try {
16239
- const user = this.solPubKey;
16240
- const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16241
- const ix = yield this.outpostClient.buildUnstakeIx(amountLamports, user);
16242
- const tx = new web3_js.Transaction().add(cuIx, ix);
16243
- const prepared = yield this.prepareTx(tx);
16244
- const signed = yield this.signTransaction(prepared.tx);
16245
- return this.sendAndConfirmHttp(signed, prepared);
16101
+ const ix = yield this.outpostClient.buildUnstakeIx(amountLamports, this.squadsVaultPDA);
16102
+ return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
16246
16103
  } catch (err) {
16247
16104
  console.log(`Failed to unstake Solana: ${err}`);
16248
16105
  throw err;
@@ -16250,19 +16107,13 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16250
16107
  });
16251
16108
  }
16252
16109
  buy(amountLamports) {
16253
- return __async$8(this, null, function* () {
16110
+ return __async$9(this, null, function* () {
16254
16111
  this.ensureUser();
16255
- if (!amountLamports || amountLamports <= BigInt(0)) {
16112
+ if (!amountLamports || amountLamports <= BigInt(0))
16256
16113
  throw new Error("liqSOL pretoken purchase requires a positive amount.");
16257
- }
16258
16114
  try {
16259
- const user = this.solPubKey;
16260
- const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16261
- const ix = yield this.tokenClient.buildPurchaseIx(amountLamports, user);
16262
- const tx = new web3_js.Transaction().add(cuIx, ix);
16263
- const prepared = yield this.prepareTx(tx);
16264
- const signed = yield this.signTransaction(prepared.tx);
16265
- return this.sendAndConfirmHttp(signed, prepared);
16115
+ const ix = yield this.tokenClient.buildPurchaseIx(amountLamports, this.squadsVaultPDA);
16116
+ return !!this.squadsX ? yield this.sendSquadsIxs(ix) : yield this.buildAndSendIx(ix);
16266
16117
  } catch (err) {
16267
16118
  console.log(`Failed to buy liqSOL pretokens: ${err}`);
16268
16119
  throw err;
@@ -16270,9 +16121,8 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16270
16121
  });
16271
16122
  }
16272
16123
  getPortfolio() {
16273
- return __async$8(this, null, function* () {
16124
+ return __async$9(this, null, function* () {
16274
16125
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
16275
- if (!this.pubKey) throw new Error("User pubKey is undefined");
16276
16126
  try {
16277
16127
  const user = !!this.squadsX ? this.squadsVaultPDA : this.solPubKey;
16278
16128
  const reservePoolPDA = this.program.deriveReservePoolPda();
@@ -16361,25 +16211,139 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16361
16211
  });
16362
16212
  }
16363
16213
  getUserRecord() {
16364
- return __async$8(this, null, function* () {
16214
+ return __async$9(this, null, function* () {
16365
16215
  if (!this.pubKey) throw new Error("User pubKey is undefined");
16366
16216
  return this.distributionClient.getUserRecord(this.solPubKey);
16367
16217
  });
16368
16218
  }
16369
16219
  get squadsMultisigPDA() {
16370
- if (!this.squadsX) return null;
16220
+ if (!this.squadsX) return void 0;
16371
16221
  return new web3_js.PublicKey(this.squadsX.multisigPDA);
16372
16222
  }
16373
16223
  get squadsVaultPDA() {
16374
16224
  var _a;
16375
- if (!this.squadsX || !this.squadsMultisigPDA) return null;
16225
+ if (!this.squadsX || !this.squadsMultisigPDA) return void 0;
16376
16226
  const multisigPda = this.squadsMultisigPDA;
16377
16227
  const index = (_a = this.squadsX.vaultIndex) != null ? _a : 0;
16378
16228
  const pda = multisig__namespace.getVaultPda({ multisigPda, index });
16379
16229
  return pda[0];
16380
16230
  }
16231
+ sendSquadsIxs(ix) {
16232
+ return __async$9(this, null, function* () {
16233
+ var _a, _b, _c, _d;
16234
+ if (!this.squadsX) throw new Error("Attempting to wrap Squads instruction without SquadsX config");
16235
+ const multisigPda = this.squadsMultisigPDA;
16236
+ const vaultPda = this.squadsVaultPDA;
16237
+ const vaultIndex = (_b = (_a = this.squadsX) == null ? void 0 : _a.vaultIndex) != null ? _b : 0;
16238
+ const creator = this.solPubKey;
16239
+ const ms = yield multisig__namespace.accounts.Multisig.fromAccountAddress(this.connection, multisigPda);
16240
+ const current = BigInt((_d = (_c = ms.transactionIndex) == null ? void 0 : _c.toString()) != null ? _d : 0);
16241
+ const transactionIndex = current + BigInt(1);
16242
+ const altAddress = this.program.PROGRAM_IDS.ALT_LOOKUP_TABLE;
16243
+ const altAccount = yield this.connection.getAddressLookupTable(altAddress);
16244
+ if (!altAccount.value) throw new Error("ALT not found on-chain or not yet active.");
16245
+ const lookupTable = altAccount.value;
16246
+ const computeLimitIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16247
+ const computePriceIx = web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: 2e3 });
16248
+ const { blockhash } = yield this.connection.getLatestBlockhash("confirmed");
16249
+ const transactionMessage = new web3_js.TransactionMessage({
16250
+ payerKey: vaultPda,
16251
+ recentBlockhash: blockhash,
16252
+ instructions: [computeLimitIx, computePriceIx, ix]
16253
+ });
16254
+ const createVaultTxIx = yield multisig__namespace.instructions.vaultTransactionCreate({
16255
+ multisigPda,
16256
+ transactionIndex,
16257
+ creator,
16258
+ vaultIndex,
16259
+ transactionMessage,
16260
+ ephemeralSigners: 0,
16261
+ addressLookupTableAccounts: [lookupTable]
16262
+ });
16263
+ const vaultTransactionCreate = yield this.buildAndSendIx(createVaultTxIx);
16264
+ console.log("SQUADSX: vaultTransactionCreate", vaultTransactionCreate);
16265
+ const createProposalIx = yield multisig__namespace.instructions.proposalCreate({
16266
+ multisigPda,
16267
+ transactionIndex,
16268
+ creator
16269
+ });
16270
+ const proposalCreate = yield this.buildAndSendIx(createProposalIx);
16271
+ console.log("SQUADSX: proposalCreate", proposalCreate);
16272
+ return proposalCreate;
16273
+ });
16274
+ }
16275
+ buildAndSendIx(ix) {
16276
+ return __async$9(this, null, function* () {
16277
+ const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
16278
+ const ixs = Array.isArray(ix) ? ix : [ix];
16279
+ const tx = new web3_js.Transaction().add(cuIx, ...ixs);
16280
+ const prepared = yield this.prepareTx(tx);
16281
+ const signed = yield this.signTransaction(prepared.tx);
16282
+ return this.sendAndConfirmHttp(signed, prepared);
16283
+ });
16284
+ }
16285
+ sendAndConfirmHttp(signed, _ctx) {
16286
+ return __async$9(this, null, function* () {
16287
+ var _a, _b, _c;
16288
+ this.ensureUser();
16289
+ const rawTx = signed.serialize();
16290
+ try {
16291
+ const signature = yield this.connection.sendRawTransaction(rawTx, {
16292
+ skipPreflight: false,
16293
+ preflightCommitment: commitment,
16294
+ maxRetries: 3
16295
+ });
16296
+ return signature;
16297
+ } catch (e) {
16298
+ const msg = (_a = e == null ? void 0 : e.message) != null ? _a : "";
16299
+ const isSendTxError = e instanceof web3_js.SendTransactionError || (e == null ? void 0 : e.name) === "SendTransactionError";
16300
+ if (isSendTxError && msg.includes("already been processed")) {
16301
+ console.warn(
16302
+ 'sendRawTransaction reports "already been processed"; treating as success without further confirmation.'
16303
+ );
16304
+ const legacy = signed;
16305
+ const first = (_c = (_b = legacy.signatures) == null ? void 0 : _b[0]) == null ? void 0 : _c.signature;
16306
+ if (first) {
16307
+ return bs58.encode(first);
16308
+ }
16309
+ return "already-processed";
16310
+ }
16311
+ throw e;
16312
+ }
16313
+ });
16314
+ }
16315
+ signTransaction(tx) {
16316
+ return __async$9(this, null, function* () {
16317
+ this.ensureUser();
16318
+ return this.anchor.wallet.signTransaction(tx);
16319
+ });
16320
+ }
16321
+ sendTransaction(signed) {
16322
+ return __async$9(this, null, function* () {
16323
+ this.ensureUser();
16324
+ return this.anchor.sendAndConfirm(signed);
16325
+ });
16326
+ }
16327
+ prepareTx(tx) {
16328
+ return __async$9(this, null, function* () {
16329
+ const { blockhash, lastValidBlockHeight } = yield this.connection.getLatestBlockhash("confirmed");
16330
+ tx.recentBlockhash = blockhash;
16331
+ tx.feePayer = this.feePayer;
16332
+ return { tx, blockhash, lastValidBlockHeight };
16333
+ });
16334
+ }
16335
+ ensureUser() {
16336
+ var _a;
16337
+ if (!this.pubKey) throw new Error("User pubKey is undefined");
16338
+ const wallet = (_a = this.anchor) == null ? void 0 : _a.wallet;
16339
+ const pk = wallet == null ? void 0 : wallet.publicKey;
16340
+ if (!pk) throw new Error("Wallet not connected");
16341
+ if (typeof wallet.signTransaction !== "function") {
16342
+ throw new Error("Wallet does not support signTransaction");
16343
+ }
16344
+ }
16381
16345
  getTrancheSnapshot(chainID) {
16382
- return __async$8(this, null, function* () {
16346
+ return __async$9(this, null, function* () {
16383
16347
  try {
16384
16348
  const [globalState, trancheState] = yield Promise.all([
16385
16349
  this.tokenClient.fetchGlobalState(),
@@ -16400,7 +16364,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16400
16364
  });
16401
16365
  }
16402
16366
  getSystemAPY() {
16403
- return __async$8(this, null, function* () {
16367
+ return __async$9(this, null, function* () {
16404
16368
  try {
16405
16369
  const ratePerEpoch = yield this.getEpochRateDecimalFromProgram();
16406
16370
  const epochsPerYear = yield this.getEpochsPerYearFromCluster();
@@ -16414,7 +16378,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16414
16378
  });
16415
16379
  }
16416
16380
  getEpochRateDecimalFromProgram() {
16417
- return __async$8(this, null, function* () {
16381
+ return __async$9(this, null, function* () {
16418
16382
  const liqSolCoreProgram = this.program.getProgram("liqsolCore");
16419
16383
  const payRateHistoryPda = this.program.derivePayRateHistoryPda();
16420
16384
  const payRateHistory = yield liqSolCoreProgram.account.payRateHistory.fetch(payRateHistoryPda);
@@ -16424,14 +16388,28 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16424
16388
  return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
16425
16389
  }
16426
16390
  const currentIndex = Number(payRateHistory.currentIndex);
16427
- const latestIdx = (currentIndex - 1 + maxEntries) % maxEntries;
16428
- const latestEntry = payRateHistory.entries[latestIdx];
16429
- const raw = BigInt(latestEntry.scaledRate.toString());
16430
- return Number(raw) / Number(PAY_RATE_SCALE_FACTOR);
16391
+ const processedCount = Math.min(totalEntriesAdded, maxEntries);
16392
+ let sum = BigInt(0);
16393
+ let validCount = 0;
16394
+ let idx = (currentIndex - 1 + maxEntries) % maxEntries;
16395
+ for (let i = 0; i < processedCount; i++) {
16396
+ const entry = payRateHistory.entries[idx];
16397
+ const scaledRate = BigInt(entry.scaledRate.toString());
16398
+ if (scaledRate > BigInt(0)) {
16399
+ sum += scaledRate;
16400
+ validCount++;
16401
+ }
16402
+ idx = (idx - 1 + maxEntries) % maxEntries;
16403
+ }
16404
+ if (validCount === 0) {
16405
+ return Number(DEFAULT_AVERAGE_PAY_RATE) / Number(PAY_RATE_SCALE_FACTOR);
16406
+ }
16407
+ const average = Number(sum / BigInt(validCount));
16408
+ return average / Number(PAY_RATE_SCALE_FACTOR);
16431
16409
  });
16432
16410
  }
16433
16411
  getEpochsPerYearFromCluster() {
16434
- return __async$8(this, null, function* () {
16412
+ return __async$9(this, null, function* () {
16435
16413
  const now = Date.now();
16436
16414
  if (this.epochsPerYearCache && now - this.epochsPerYearCache.fetchedAt < _SolanaStakingClient.EPOCHS_PER_YEAR_TTL_MS) {
16437
16415
  return this.epochsPerYearCache.value;
@@ -16464,7 +16442,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16464
16442
  });
16465
16443
  }
16466
16444
  getDepositFee(amountLamports, windowSize = 5) {
16467
- return __async$8(this, null, function* () {
16445
+ return __async$9(this, null, function* () {
16468
16446
  var _a, _b, _c;
16469
16447
  if (amountLamports <= BigInt(0)) {
16470
16448
  return BigInt(0);
@@ -16492,7 +16470,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16492
16470
  });
16493
16471
  }
16494
16472
  getDepositBuffer(options) {
16495
- return __async$8(this, null, function* () {
16473
+ return __async$9(this, null, function* () {
16496
16474
  var _a, _b, _c, _d;
16497
16475
  this.ensureUser();
16498
16476
  const balanceLamports = (_a = options == null ? void 0 : options.balanceOverrideLamports) != null ? _a : BigInt(yield this.connection.getBalance(this.feePayer, commitment));
@@ -16548,7 +16526,7 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16548
16526
  });
16549
16527
  }
16550
16528
  getSingleTxFeeLamports() {
16551
- return __async$8(this, null, function* () {
16529
+ return __async$9(this, null, function* () {
16552
16530
  var _a;
16553
16531
  const now = Date.now();
16554
16532
  if (this.cachedTxFee && now - this.cachedTxFee.fetchedAt < _SolanaStakingClient.FEE_CACHE_TTL_MS) {
@@ -16574,66 +16552,6 @@ const _SolanaStakingClient = class _SolanaStakingClient {
16574
16552
  return singleTxFeeLamports;
16575
16553
  });
16576
16554
  }
16577
- sendAndConfirmHttp(signed, _ctx) {
16578
- return __async$8(this, null, function* () {
16579
- var _a, _b, _c;
16580
- this.ensureUser();
16581
- const rawTx = signed.serialize();
16582
- try {
16583
- const signature = yield this.connection.sendRawTransaction(rawTx, {
16584
- skipPreflight: false,
16585
- preflightCommitment: commitment,
16586
- maxRetries: 3
16587
- });
16588
- return signature;
16589
- } catch (e) {
16590
- const msg = (_a = e == null ? void 0 : e.message) != null ? _a : "";
16591
- const isSendTxError = e instanceof web3_js.SendTransactionError || (e == null ? void 0 : e.name) === "SendTransactionError";
16592
- if (isSendTxError && msg.includes("already been processed")) {
16593
- console.warn(
16594
- 'sendRawTransaction reports "already been processed"; treating as success without further confirmation.'
16595
- );
16596
- const legacy = signed;
16597
- const first = (_c = (_b = legacy.signatures) == null ? void 0 : _b[0]) == null ? void 0 : _c.signature;
16598
- if (first) {
16599
- return bs58.encode(first);
16600
- }
16601
- return "already-processed";
16602
- }
16603
- throw e;
16604
- }
16605
- });
16606
- }
16607
- signTransaction(tx) {
16608
- return __async$8(this, null, function* () {
16609
- this.ensureUser();
16610
- return this.anchor.wallet.signTransaction(tx);
16611
- });
16612
- }
16613
- sendTransaction(signed) {
16614
- return __async$8(this, null, function* () {
16615
- this.ensureUser();
16616
- return this.anchor.sendAndConfirm(signed);
16617
- });
16618
- }
16619
- prepareTx(tx) {
16620
- return __async$8(this, null, function* () {
16621
- const { blockhash, lastValidBlockHeight } = yield this.connection.getLatestBlockhash("confirmed");
16622
- tx.recentBlockhash = blockhash;
16623
- tx.feePayer = this.feePayer;
16624
- return { tx, blockhash, lastValidBlockHeight };
16625
- });
16626
- }
16627
- ensureUser() {
16628
- var _a;
16629
- if (!this.pubKey) throw new Error("User pubKey is undefined");
16630
- const wallet = (_a = this.anchor) == null ? void 0 : _a.wallet;
16631
- const pk = wallet == null ? void 0 : wallet.publicKey;
16632
- if (!pk) throw new Error("Wallet not connected");
16633
- if (typeof wallet.signTransaction !== "function") {
16634
- throw new Error("Wallet does not support signTransaction");
16635
- }
16636
- }
16637
16555
  };
16638
16556
  _SolanaStakingClient.EPOCHS_PER_YEAR_TTL_MS = 10 * 60 * 1e3;
16639
16557
  _SolanaStakingClient.FEE_CACHE_TTL_MS = 6e4;
@@ -40650,7 +40568,7 @@ var ERC1155Artifact = {
40650
40568
  deployedLinkReferences: deployedLinkReferences
40651
40569
  };
40652
40570
 
40653
- var __async$7 = (__this, __arguments, generator) => {
40571
+ var __async$8 = (__this, __arguments, generator) => {
40654
40572
  return new Promise((resolve, reject) => {
40655
40573
  var fulfilled = (value) => {
40656
40574
  try {
@@ -40870,7 +40788,7 @@ class EthereumContractService {
40870
40788
  return new ethers.Contract(address, abi, this.signer);
40871
40789
  }
40872
40790
  getNetwork() {
40873
- return __async$7(this, null, function* () {
40791
+ return __async$8(this, null, function* () {
40874
40792
  var _a;
40875
40793
  return (_a = this.provider) == null ? void 0 : _a.getNetwork();
40876
40794
  });
@@ -40926,7 +40844,7 @@ class EthereumContractService {
40926
40844
  }
40927
40845
  }
40928
40846
 
40929
- var __async$6 = (__this, __arguments, generator) => {
40847
+ var __async$7 = (__this, __arguments, generator) => {
40930
40848
  return new Promise((resolve, reject) => {
40931
40849
  var fulfilled = (value) => {
40932
40850
  try {
@@ -40970,7 +40888,7 @@ function formatContractErrors(err) {
40970
40888
  }
40971
40889
  }
40972
40890
  function sendOPPFinalize(opp, gasLimit) {
40973
- return __async$6(this, null, function* () {
40891
+ return __async$7(this, null, function* () {
40974
40892
  var _a;
40975
40893
  const overrides = {};
40976
40894
  try {
@@ -41098,7 +41016,7 @@ function buildEthereumTrancheLadder(options) {
41098
41016
  return ladder;
41099
41017
  }
41100
41018
  function buildEthereumTrancheSnapshot(options) {
41101
- return __async$6(this, null, function* () {
41019
+ return __async$7(this, null, function* () {
41102
41020
  const {
41103
41021
  chainID,
41104
41022
  ethPriceUsd,
@@ -41158,7 +41076,7 @@ function buildEthereumTrancheSnapshot(options) {
41158
41076
  });
41159
41077
  }
41160
41078
 
41161
- var __async$5 = (__this, __arguments, generator) => {
41079
+ var __async$6 = (__this, __arguments, generator) => {
41162
41080
  return new Promise((resolve, reject) => {
41163
41081
  var fulfilled = (value) => {
41164
41082
  try {
@@ -41186,7 +41104,7 @@ class ConvertClient {
41186
41104
  this.contractService = contract;
41187
41105
  }
41188
41106
  simulateDeposit(amount) {
41189
- return __async$5(this, null, function* () {
41107
+ return __async$6(this, null, function* () {
41190
41108
  const amountWei = ethers.BigNumber.isBigNumber(amount) ? amount : ethers.BigNumber.from(amount);
41191
41109
  yield this.contract.DepositManager.callStatic.deposit({
41192
41110
  value: amountWei
@@ -41194,7 +41112,7 @@ class ConvertClient {
41194
41112
  });
41195
41113
  }
41196
41114
  performDeposit(amountWei) {
41197
- return __async$5(this, null, function* () {
41115
+ return __async$6(this, null, function* () {
41198
41116
  var _a, _b;
41199
41117
  const minDeposit = yield this.contract.DepositManager.minDeposit();
41200
41118
  if (amountWei.lt(minDeposit)) {
@@ -41230,7 +41148,7 @@ class ConvertClient {
41230
41148
  });
41231
41149
  }
41232
41150
  performWithdraw(signerAddress, amountWei) {
41233
- return __async$5(this, null, function* () {
41151
+ return __async$6(this, null, function* () {
41234
41152
  var _a, _b;
41235
41153
  let tx, receipt;
41236
41154
  try {
@@ -41258,7 +41176,7 @@ class ConvertClient {
41258
41176
  });
41259
41177
  }
41260
41178
  claimWithdraw(tokenId) {
41261
- return __async$5(this, null, function* () {
41179
+ return __async$6(this, null, function* () {
41262
41180
  var _a, _b;
41263
41181
  let tx, receipt;
41264
41182
  try {
@@ -41286,7 +41204,7 @@ class ConvertClient {
41286
41204
  }
41287
41205
  }
41288
41206
 
41289
- var __async$4 = (__this, __arguments, generator) => {
41207
+ var __async$5 = (__this, __arguments, generator) => {
41290
41208
  return new Promise((resolve, reject) => {
41291
41209
  var fulfilled = (value) => {
41292
41210
  try {
@@ -41314,7 +41232,7 @@ class StakeClient {
41314
41232
  this.contractService = contract;
41315
41233
  }
41316
41234
  simulateStake(amountWei) {
41317
- return __async$4(this, null, function* () {
41235
+ return __async$5(this, null, function* () {
41318
41236
  var _a;
41319
41237
  try {
41320
41238
  yield this.contract.Depositor.callStatic.stakeLiqETH(amountWei);
@@ -41325,7 +41243,7 @@ class StakeClient {
41325
41243
  });
41326
41244
  }
41327
41245
  performStake(amountWei, signerAddress) {
41328
- return __async$4(this, null, function* () {
41246
+ return __async$5(this, null, function* () {
41329
41247
  var _a;
41330
41248
  const depositor = this.contract.Depositor.address;
41331
41249
  const liqRead = this.contract.LiqEthToken;
@@ -41368,7 +41286,7 @@ class StakeClient {
41368
41286
  });
41369
41287
  }
41370
41288
  performWithdrawStake(tokenId, recipient) {
41371
- return __async$4(this, null, function* () {
41289
+ return __async$5(this, null, function* () {
41372
41290
  var _a;
41373
41291
  const tx = yield this.contract.Depositor.withdrawStake(tokenId, recipient);
41374
41292
  const receipt = yield tx.wait(1);
@@ -41391,7 +41309,7 @@ class StakeClient {
41391
41309
  }
41392
41310
  }
41393
41311
 
41394
- var __async$3 = (__this, __arguments, generator) => {
41312
+ var __async$4 = (__this, __arguments, generator) => {
41395
41313
  return new Promise((resolve, reject) => {
41396
41314
  var fulfilled = (value) => {
41397
41315
  try {
@@ -41419,7 +41337,7 @@ class PretokenClient {
41419
41337
  this.contractService = contract;
41420
41338
  }
41421
41339
  purchasePretokensWithLiqETH(amountLiq, buyer) {
41422
- return __async$3(this, null, function* () {
41340
+ return __async$4(this, null, function* () {
41423
41341
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
41424
41342
  const bal = yield this.contract.LiqEthToken.balanceOf(buyer);
41425
41343
  const paused = yield this.contract.Depositor.paused();
@@ -41488,7 +41406,7 @@ class PretokenClient {
41488
41406
  }
41489
41407
  }
41490
41408
 
41491
- var __async$2 = (__this, __arguments, generator) => {
41409
+ var __async$3 = (__this, __arguments, generator) => {
41492
41410
  return new Promise((resolve, reject) => {
41493
41411
  var fulfilled = (value) => {
41494
41412
  try {
@@ -41525,7 +41443,7 @@ class OPPClient {
41525
41443
  return this.contractService.contract;
41526
41444
  }
41527
41445
  getStatus() {
41528
- return __async$2(this, null, function* () {
41446
+ return __async$3(this, null, function* () {
41529
41447
  const depositor = this.contract.Depositor;
41530
41448
  const opp = this.contract.OPP;
41531
41449
  const oppAddress = yield depositor.oppAddress();
@@ -41566,7 +41484,7 @@ class OPPClient {
41566
41484
  });
41567
41485
  }
41568
41486
  getMessages(address) {
41569
- return __async$2(this, null, function* () {
41487
+ return __async$3(this, null, function* () {
41570
41488
  try {
41571
41489
  const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
41572
41490
  const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
@@ -41586,7 +41504,7 @@ class OPPClient {
41586
41504
  });
41587
41505
  }
41588
41506
  extractAssertionsFromEvent(event) {
41589
- return __async$2(this, null, function* () {
41507
+ return __async$3(this, null, function* () {
41590
41508
  var _a, _b;
41591
41509
  const header = event.args.header;
41592
41510
  const payloadAssertions = event.args.payload.assertions;
@@ -41821,7 +41739,7 @@ var ReceiptNFTKind = ((ReceiptNFTKind2) => {
41821
41739
  return ReceiptNFTKind2;
41822
41740
  })(ReceiptNFTKind || {});
41823
41741
 
41824
- var __async$1 = (__this, __arguments, generator) => {
41742
+ var __async$2 = (__this, __arguments, generator) => {
41825
41743
  return new Promise((resolve, reject) => {
41826
41744
  var fulfilled = (value) => {
41827
41745
  try {
@@ -41849,12 +41767,12 @@ class ReceiptClient {
41849
41767
  this.contractService = contract;
41850
41768
  }
41851
41769
  allReceipts(address) {
41852
- return __async$1(this, null, function* () {
41770
+ return __async$2(this, null, function* () {
41853
41771
  return this.fetchPreLaunchReceipts(address);
41854
41772
  });
41855
41773
  }
41856
41774
  stakeReceipts(address) {
41857
- return __async$1(this, null, function* () {
41775
+ return __async$2(this, null, function* () {
41858
41776
  try {
41859
41777
  const receipts = yield this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
41860
41778
  return receipts;
@@ -41864,12 +41782,12 @@ class ReceiptClient {
41864
41782
  });
41865
41783
  }
41866
41784
  pretokenReceipts(address) {
41867
- return __async$1(this, null, function* () {
41785
+ return __async$2(this, null, function* () {
41868
41786
  return this.fetchPreLaunchReceipts(address, ReceiptNFTKind.PRETOKEN_PURCHASE);
41869
41787
  });
41870
41788
  }
41871
41789
  fetchPreLaunchReceipts(address, type) {
41872
- return __async$1(this, null, function* () {
41790
+ return __async$2(this, null, function* () {
41873
41791
  const receiptContract = this.contract.ReceiptNFT;
41874
41792
  const tokenIds = yield this.getOwnedReceiptNFTsFor(address);
41875
41793
  const results = [];
@@ -41906,7 +41824,7 @@ class ReceiptClient {
41906
41824
  });
41907
41825
  }
41908
41826
  getOwnedReceiptNFTsFor(owner, fromBlock = 0, toBlock = "latest") {
41909
- return __async$1(this, null, function* () {
41827
+ return __async$2(this, null, function* () {
41910
41828
  var _a, _b;
41911
41829
  const receiptContract = this.contract.ReceiptNFT;
41912
41830
  const toLogs = yield receiptContract.queryFilter(
@@ -41934,7 +41852,7 @@ class ReceiptClient {
41934
41852
  });
41935
41853
  }
41936
41854
  fetchWithdrawReceipts(address) {
41937
- return __async$1(this, null, function* () {
41855
+ return __async$2(this, null, function* () {
41938
41856
  const tokenIds = yield this.getOwnedWithdrawReceiptsFor(address);
41939
41857
  const results = [];
41940
41858
  for (const idBN of tokenIds) {
@@ -41961,7 +41879,7 @@ class ReceiptClient {
41961
41879
  });
41962
41880
  }
41963
41881
  getOwnedWithdrawReceiptsFor(owner, fromBlock = 0, toBlock = "latest") {
41964
- return __async$1(this, null, function* () {
41882
+ return __async$2(this, null, function* () {
41965
41883
  var _a, _b;
41966
41884
  const contract = this.contract.WithdrawalQueue;
41967
41885
  const toLogs = yield contract.queryFilter(
@@ -41990,6 +41908,64 @@ class ReceiptClient {
41990
41908
  }
41991
41909
  }
41992
41910
 
41911
+ var __async$1 = (__this, __arguments, generator) => {
41912
+ return new Promise((resolve, reject) => {
41913
+ var fulfilled = (value) => {
41914
+ try {
41915
+ step(generator.next(value));
41916
+ } catch (e) {
41917
+ reject(e);
41918
+ }
41919
+ };
41920
+ var rejected = (value) => {
41921
+ try {
41922
+ step(generator.throw(value));
41923
+ } catch (e) {
41924
+ reject(e);
41925
+ }
41926
+ };
41927
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
41928
+ step((generator = generator.apply(__this, __arguments)).next());
41929
+ });
41930
+ };
41931
+ class ValidatorClient {
41932
+ get contract() {
41933
+ return this.contractService.contract;
41934
+ }
41935
+ constructor(contract) {
41936
+ this.contractService = contract;
41937
+ }
41938
+ validatorDepositAndLockBond() {
41939
+ return __async$1(this, null, function* () {
41940
+ var _a, _b;
41941
+ const amountWei = ethers.ethers.utils.parseEther("32");
41942
+ try {
41943
+ yield this.contract.DepositManager.callStatic.validatorDepositAndLockBond({ value: amountWei });
41944
+ } catch (err) {
41945
+ let errorObj = formatContractErrors(err);
41946
+ throw new Error((_a = errorObj.name) != null ? _a : errorObj.raw);
41947
+ }
41948
+ const tx = yield this.contract.DepositManager.validatorDepositAndLockBond({ value: amountWei });
41949
+ const receipt = yield tx.wait(1);
41950
+ let staked;
41951
+ const ev = (_b = receipt.events) == null ? void 0 : _b.find((e) => e.event === "Staked");
41952
+ if (ev && ev.args) {
41953
+ const { sender, amount, shares } = ev.args;
41954
+ staked = {
41955
+ sender,
41956
+ amount: ethers.BigNumber.from(amount),
41957
+ shares: ethers.BigNumber.from(shares)
41958
+ };
41959
+ }
41960
+ return {
41961
+ txHash: tx.hash,
41962
+ receipt,
41963
+ staked
41964
+ };
41965
+ });
41966
+ }
41967
+ }
41968
+
41993
41969
  var __async = (__this, __arguments, generator) => {
41994
41970
  return new Promise((resolve, reject) => {
41995
41971
  var fulfilled = (value) => {
@@ -42032,6 +42008,7 @@ class EthereumStakingClient {
42032
42008
  this.stakeClient = new StakeClient(this.contractService);
42033
42009
  this.oppClient = new OPPClient(this.contractService);
42034
42010
  this.receiptClient = new ReceiptClient(this.contractService);
42011
+ this.validatorClient = new ValidatorClient(this.contractService);
42035
42012
  } catch (error) {
42036
42013
  throw error;
42037
42014
  }
@@ -42104,6 +42081,13 @@ class EthereumStakingClient {
42104
42081
  return result && result.txHash ? result.txHash : "Error - no resulting txHash";
42105
42082
  });
42106
42083
  }
42084
+ validatorDeposit() {
42085
+ return __async(this, null, function* () {
42086
+ this.ensureUser();
42087
+ let result = yield this.validatorClient.validatorDepositAndLockBond();
42088
+ return result && result.txHash ? result.txHash : "Error - no resulting txHash";
42089
+ });
42090
+ }
42107
42091
  getPortfolio() {
42108
42092
  return __async(this, null, function* () {
42109
42093
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;