@wireio/stake 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/stake.js CHANGED
@@ -8848,13 +8848,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
8848
8848
  throw new Error("Deposit amount must be greater than zero.");
8849
8849
  }
8850
8850
  try {
8851
- const tx = yield this.depositClient.buildDepositTx(amountLamports);
8852
- const { tx: prepared, blockhash, lastValidBlockHeight } = yield this.prepareTx(tx);
8853
- const signed = yield this.signTransaction(prepared);
8854
- return yield this.sendAndConfirmHttp(signed, {
8855
- blockhash,
8856
- lastValidBlockHeight
8857
- });
8851
+ const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8852
+ const ix = yield this.depositClient.buildDepositTx(amountLamports);
8853
+ const tx = new web3_js.Transaction().add(cuIx, ix);
8854
+ const prepared = yield this.prepareTx(tx);
8855
+ const signed = yield this.signTransaction(prepared.tx);
8856
+ return this.sendAndConfirmHttp(signed, prepared);
8858
8857
  } catch (err) {
8859
8858
  throw new Error(`Failed to deposit Solana: ${err}`);
8860
8859
  }
@@ -8867,13 +8866,12 @@ const _SolanaStakingClient = class _SolanaStakingClient {
8867
8866
  throw new Error("Withdraw amount must be greater than zero.");
8868
8867
  }
8869
8868
  try {
8870
- const tx = yield this.depositClient.buildWithdrawTx(amountLamports);
8871
- const { tx: prepared, blockhash, lastValidBlockHeight } = yield this.prepareTx(tx);
8872
- const signed = yield this.signTransaction(prepared);
8873
- return yield this.sendAndConfirmHttp(signed, {
8874
- blockhash,
8875
- lastValidBlockHeight
8876
- });
8869
+ const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8870
+ const ix = yield this.depositClient.buildWithdrawTx(amountLamports);
8871
+ const tx = new web3_js.Transaction().add(cuIx, ix);
8872
+ const prepared = yield this.prepareTx(tx);
8873
+ const signed = yield this.signTransaction(prepared.tx);
8874
+ return this.sendAndConfirmHttp(signed, prepared);
8877
8875
  } catch (err) {
8878
8876
  throw new Error(`Failed to withdraw Solana: ${err}`);
8879
8877
  }
@@ -8928,12 +8926,9 @@ const _SolanaStakingClient = class _SolanaStakingClient {
8928
8926
  const cuIx = web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: 4e5 });
8929
8927
  const ix = yield this.tokenClient.buildPurchaseIx(amountLamports, user);
8930
8928
  const tx = new web3_js.Transaction().add(cuIx, ix);
8931
- const { tx: prepared, blockhash, lastValidBlockHeight } = yield this.prepareTx(tx);
8932
- const signed = yield this.signTransaction(prepared);
8933
- return yield this.sendAndConfirmHttp(signed, {
8934
- blockhash,
8935
- lastValidBlockHeight
8936
- });
8929
+ const prepared = yield this.prepareTx(tx);
8930
+ const signed = yield this.signTransaction(prepared.tx);
8931
+ return this.sendAndConfirmHttp(signed, prepared);
8937
8932
  } catch (err) {
8938
8933
  throw new Error(`Failed to buy liqSOL pretokens: ${err}`);
8939
8934
  }
@@ -35397,18 +35392,22 @@ class OPPClient {
35397
35392
  }
35398
35393
  getMessages(address) {
35399
35394
  return __async$2(this, null, function* () {
35400
- const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
35401
- const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
35402
- const allAssertions = [];
35403
- for (const event of events) {
35404
- const assertions = yield this.extractAssertionsFromEvent(event);
35405
- allAssertions.push(...assertions);
35395
+ try {
35396
+ const oppMessageFilter = this.contract.OPP.filters.OPPMessage();
35397
+ const events = yield this.contract.OPP.queryFilter(oppMessageFilter, 0, "latest");
35398
+ const allAssertions = [];
35399
+ for (const event of events) {
35400
+ const assertions = yield this.extractAssertionsFromEvent(event);
35401
+ allAssertions.push(...assertions);
35402
+ }
35403
+ const normalized = address ? address.toLowerCase() : null;
35404
+ const filtered = allAssertions.filter(
35405
+ (a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
35406
+ );
35407
+ return filtered.reverse();
35408
+ } catch (error) {
35409
+ return [];
35406
35410
  }
35407
- const normalized = address ? address.toLowerCase() : null;
35408
- const filtered = allAssertions.filter(
35409
- (a) => a.from && a.from.toLowerCase() === normalized || a.to && a.to.toLowerCase() === normalized
35410
- );
35411
- return filtered.reverse();
35412
35411
  });
35413
35412
  }
35414
35413
  extractAssertionsFromEvent(event) {
@@ -35671,7 +35670,12 @@ class ReceiptClient {
35671
35670
  }
35672
35671
  stakeReceipts(address) {
35673
35672
  return __async$1(this, null, function* () {
35674
- return this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
35673
+ try {
35674
+ const receipts = yield this.fetchPreLaunchReceipts(address, ReceiptNFTKind.STAKE);
35675
+ return receipts;
35676
+ } catch (err) {
35677
+ return [];
35678
+ }
35675
35679
  });
35676
35680
  }
35677
35681
  pretokenReceipts(address) {
@@ -35847,72 +35851,77 @@ class EthereumStakingClient {
35847
35851
  getPortfolio() {
35848
35852
  return __async(this, null, function* () {
35849
35853
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
35850
- if (!this.signer) return Promise.resolve(null);
35851
- const walletAddress = yield this.signer.getAddress();
35852
- const nativeBalance = yield this.provider.getBalance(walletAddress);
35853
- const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
35854
- const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
35855
- const liqBalance = yield this.contract.LiqEthToken.balanceOf(walletAddress);
35856
- const liqSymbol = "Liq" + ((_i = (_h = (_g = this.network) == null ? void 0 : _g.nativeCurrency) == null ? void 0 : _h.symbol) != null ? _i : "ETH");
35857
- let stakeReceipts = yield this.receiptClient.stakeReceipts(walletAddress);
35858
- let stakeBalanceBN = ethers.BigNumber.from(0);
35859
- for (let r of stakeReceipts) {
35860
- stakeBalanceBN = stakeBalanceBN.add(ethers.BigNumber.from(r.receipt.principal.amount));
35861
- }
35862
- let stakeSharesBN = ethers.BigNumber.from(0);
35863
- for (let r of stakeReceipts) {
35864
- stakeSharesBN = stakeSharesBN.add(ethers.BigNumber.from(r.receipt.shares.amount));
35865
- }
35866
- const wireBalance = yield this.contract.Pretoken.balanceOf(walletAddress);
35867
- let currentIndex = BigInt(0);
35868
- let totalShares = BigInt(0);
35869
- let userShares = BigInt(0);
35870
- const indexScale = BigInt(1e27);
35871
35854
  try {
35872
- const [indexBn, totalSharesBn] = yield Promise.all([
35873
- this.contract.Depositor.index().catch(() => ethers.BigNumber.from(0)),
35874
- this.contract.Depositor.totalShares().catch(() => ethers.BigNumber.from(0))
35875
- ]);
35876
- const userSharesBn = stakeSharesBN;
35877
- currentIndex = BigInt(indexBn.toString());
35878
- totalShares = BigInt(totalSharesBn.toString());
35879
- userShares = BigInt(userSharesBn.toString());
35880
- } catch (e) {
35855
+ if (!this.signer) return Promise.resolve(null);
35856
+ const walletAddress = yield this.signer.getAddress();
35857
+ const nativeBalance = yield this.provider.getBalance(walletAddress);
35858
+ const nativeDecimals = (_c = (_b = (_a = this.network) == null ? void 0 : _a.nativeCurrency) == null ? void 0 : _b.decimals) != null ? _c : 18;
35859
+ const nativeSymbol = (_f = (_e = (_d = this.network) == null ? void 0 : _d.nativeCurrency) == null ? void 0 : _e.symbol) != null ? _f : "ETH";
35860
+ const liqBalance = yield this.contract.LiqEthToken.balanceOf(walletAddress);
35861
+ const liqSymbol = "Liq" + ((_i = (_h = (_g = this.network) == null ? void 0 : _g.nativeCurrency) == null ? void 0 : _h.symbol) != null ? _i : "ETH");
35862
+ let stakeReceipts = yield this.receiptClient.stakeReceipts(walletAddress);
35863
+ let stakeBalanceBN = ethers.BigNumber.from(0);
35864
+ for (let r of stakeReceipts) {
35865
+ stakeBalanceBN = stakeBalanceBN.add(ethers.BigNumber.from(r.receipt.principal.amount));
35866
+ }
35867
+ let stakeSharesBN = ethers.BigNumber.from(0);
35868
+ for (let r of stakeReceipts) {
35869
+ stakeSharesBN = stakeSharesBN.add(ethers.BigNumber.from(r.receipt.shares.amount));
35870
+ }
35871
+ const wireBalance = yield this.contract.Pretoken.balanceOf(walletAddress);
35872
+ let currentIndex = BigInt(0);
35873
+ let totalShares = BigInt(0);
35874
+ let userShares = BigInt(0);
35875
+ const indexScale = BigInt(1e27);
35876
+ try {
35877
+ const [indexBn, totalSharesBn] = yield Promise.all([
35878
+ this.contract.Depositor.index().catch(() => ethers.BigNumber.from(0)),
35879
+ this.contract.Depositor.totalShares().catch(() => ethers.BigNumber.from(0))
35880
+ ]);
35881
+ const userSharesBn = stakeSharesBN;
35882
+ currentIndex = BigInt(indexBn.toString());
35883
+ totalShares = BigInt(totalSharesBn.toString());
35884
+ userShares = BigInt(userSharesBn.toString());
35885
+ } catch (error) {
35886
+ console.log("Error fetching staking index/shares:", error);
35887
+ }
35888
+ let estimatedClaim = BigInt(0);
35889
+ let estimatedYield = BigInt(0);
35890
+ const portfolio = {
35891
+ native: {
35892
+ amount: nativeBalance.toBigInt(),
35893
+ decimals: nativeDecimals,
35894
+ symbol: nativeSymbol
35895
+ },
35896
+ liq: {
35897
+ amount: liqBalance.toBigInt(),
35898
+ decimals: nativeDecimals,
35899
+ symbol: liqSymbol
35900
+ },
35901
+ staked: {
35902
+ amount: stakeBalanceBN.toBigInt(),
35903
+ decimals: nativeDecimals,
35904
+ symbol: liqSymbol
35905
+ },
35906
+ wire: {
35907
+ amount: wireBalance.toBigInt(),
35908
+ decimals: 18,
35909
+ symbol: "$WIRE"
35910
+ },
35911
+ yield: {
35912
+ currentIndex,
35913
+ indexScale,
35914
+ totalShares,
35915
+ userShares,
35916
+ estimatedClaim,
35917
+ estimatedYield
35918
+ },
35919
+ chainID: this.network.chainId
35920
+ };
35921
+ return portfolio;
35922
+ } catch (error) {
35923
+ throw error;
35881
35924
  }
35882
- let estimatedClaim = BigInt(0);
35883
- let estimatedYield = BigInt(0);
35884
- const portfolio = {
35885
- native: {
35886
- amount: nativeBalance.toBigInt(),
35887
- decimals: nativeDecimals,
35888
- symbol: nativeSymbol
35889
- },
35890
- liq: {
35891
- amount: liqBalance.toBigInt(),
35892
- decimals: nativeDecimals,
35893
- symbol: liqSymbol
35894
- },
35895
- staked: {
35896
- amount: stakeBalanceBN.toBigInt(),
35897
- decimals: nativeDecimals,
35898
- symbol: liqSymbol
35899
- },
35900
- wire: {
35901
- amount: wireBalance.toBigInt(),
35902
- decimals: 18,
35903
- symbol: "$WIRE"
35904
- },
35905
- yield: {
35906
- currentIndex,
35907
- indexScale,
35908
- totalShares,
35909
- userShares,
35910
- estimatedClaim,
35911
- estimatedYield
35912
- },
35913
- chainID: this.network.chainId
35914
- };
35915
- return portfolio;
35916
35925
  });
35917
35926
  }
35918
35927
  fetchPrelaunchReceipts(address) {
@@ -36057,6 +36066,7 @@ class Staker {
36057
36066
  this.clients.set(cfg.network.chainId, new SolanaStakingClient(cfg));
36058
36067
  break;
36059
36068
  case core.EvmChainID.Ethereum:
36069
+ case core.EvmChainID.Hoodi:
36060
36070
  this.clients.set(cfg.network.chainId, new EthereumStakingClient(cfg));
36061
36071
  break;
36062
36072
  default: