@huma-finance/widgets 0.0.62-beta.713 → 0.0.62-beta.715

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.
@@ -8726,7 +8726,6 @@ function SolanaViewOnExplorer(_ref) {
8726
8726
  });
8727
8727
  }
8728
8728
 
8729
- /* eslint-disable no-await-in-loop */
8730
8729
  function SolanaTxSendModal(_ref) {
8731
8730
  let {
8732
8731
  chainId,
@@ -8747,28 +8746,18 @@ function SolanaTxSendModal(_ref) {
8747
8746
  return;
8748
8747
  }
8749
8748
  try {
8749
+ const latestBlockHash = await connection.getLatestBlockhash();
8750
8750
  const signature = await sendTransaction(tx, connection);
8751
8751
  setSignature(signature);
8752
8752
  dispatch(setSolanaSignature(signature));
8753
- let transactionConfirmed = false;
8754
- for (let i = 0; i < 30; i += 1) {
8755
- var _result$value;
8756
- shared.timeUtil.sleep(1000);
8757
- const result = await connection.getSignatureStatus(signature);
8758
- if (result !== null && result !== void 0 && (_result$value = result.value) !== null && _result$value !== void 0 && _result$value.confirmations) {
8759
- transactionConfirmed = true;
8760
- break;
8761
- }
8762
- }
8763
- if (transactionConfirmed) {
8764
- handleSuccess({
8765
- signature
8766
- });
8767
- } else {
8768
- dispatch(setError({
8769
- errorMessage: 'Transaction failed to confirm in time'
8770
- }));
8771
- }
8753
+ await connection.confirmTransaction({
8754
+ blockhash: latestBlockHash.blockhash,
8755
+ lastValidBlockHeight: latestBlockHash.lastValidBlockHeight,
8756
+ signature
8757
+ });
8758
+ handleSuccess({
8759
+ signature
8760
+ });
8772
8761
  } catch (error) {
8773
8762
  const err = error;
8774
8763
  dispatch(setError({
@@ -8800,6 +8789,7 @@ function Transfer$4(_ref) {
8800
8789
  const {
8801
8790
  publicKey
8802
8791
  } = walletAdapterReact.useWallet();
8792
+ const sentinel = shared.getSentinelAddress(poolInfo.chainId);
8803
8793
  const {
8804
8794
  supplyAmount
8805
8795
  } = useAppSelector(selectWidgetState);
@@ -8813,6 +8803,8 @@ function Transfer$4(_ref) {
8813
8803
  seniorLenderApprovedAccountPDA,
8814
8804
  seniorLenderStateAccount,
8815
8805
  juniorLenderStateAccount,
8806
+ seniorTrancheMintSupply,
8807
+ juniorTrancheMintSupply,
8816
8808
  loading: isLoadingLenderAccounts
8817
8809
  } = webShared.useLenderAccounts(poolInfo.chainId, poolInfo.poolName);
8818
8810
  const program = webShared.useHumaProgram(poolInfo.chainId);
@@ -8829,6 +8821,7 @@ function Transfer$4(_ref) {
8829
8821
  }, [dispatch, isDev, pointsTestnetExperience, poolInfo.chainId, poolState.campaign, publicKey]);
8830
8822
  React.useEffect(() => {
8831
8823
  async function getTx() {
8824
+ var _poolState$seniorTran, _poolState$juniorTran;
8832
8825
  if (!publicKey || transaction || isLoadingLenderAccounts) {
8833
8826
  return;
8834
8827
  }
@@ -8864,10 +8857,22 @@ function Transfer$4(_ref) {
8864
8857
  underlyingTokenProgram: splToken.TOKEN_PROGRAM_ID
8865
8858
  }).transaction();
8866
8859
  tx.add(depositTx);
8860
+
8861
+ // Approve automatic redemptions
8862
+ const sharesAmount = shared.convertToShares(selectedTranche === 'senior' ? new anchor.BN((_poolState$seniorTran = poolState.seniorTrancheAssets) !== null && _poolState$seniorTran !== void 0 ? _poolState$seniorTran : 0) : new anchor.BN((_poolState$juniorTran = poolState.juniorTrancheAssets) !== null && _poolState$juniorTran !== void 0 ? _poolState$juniorTran : 0), selectedTranche === 'senior' ? seniorTrancheMintSupply !== null && seniorTrancheMintSupply !== void 0 ? seniorTrancheMintSupply : new anchor.BN(0) : juniorTrancheMintSupply !== null && juniorTrancheMintSupply !== void 0 ? juniorTrancheMintSupply : new anchor.BN(0), supplyBigNumber);
8863
+ tx.add(splToken.createApproveCheckedInstruction(selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA, new web3_js.PublicKey(selectedTranche === 'senior' ? poolInfo.seniorTrancheMint : poolInfo.juniorTrancheMint), new web3_js.PublicKey(sentinel),
8864
+ // delegate
8865
+ publicKey,
8866
+ // owner of the wallet
8867
+ BigInt(sharesAmount.muln(1.1).toString()),
8868
+ // amount
8869
+ poolInfo.trancheDecimals, undefined,
8870
+ // multiSigners
8871
+ splToken.TOKEN_2022_PROGRAM_ID));
8867
8872
  setTransaction(tx);
8868
8873
  }
8869
8874
  getTx();
8870
- }, [isLoadingLenderAccounts, juniorLenderApprovedAccountPDA, juniorLenderStateAccount, poolInfo, program.methods, publicKey, selectedTranche, seniorLenderApprovedAccountPDA, seniorLenderStateAccount, supplyBigNumber, transaction]);
8875
+ }, [isLoadingLenderAccounts, juniorLenderApprovedAccountPDA, juniorLenderStateAccount, juniorTrancheMintSupply, poolInfo, poolState.juniorTrancheAssets, poolState.seniorTrancheAssets, program.methods, publicKey, selectedTranche, seniorLenderApprovedAccountPDA, seniorLenderStateAccount, seniorTrancheMintSupply, sentinel, supplyBigNumber, transaction]);
8871
8876
  if (isLoadingLenderAccounts) {
8872
8877
  return jsxRuntime.jsx(LoadingModal, {
8873
8878
  title: "Supply"
@@ -8965,7 +8970,7 @@ function Success(_ref) {
8965
8970
  var _poolState$withdrawal;
8966
8971
  const lockupEndTime = dayjs__default["default"]().add((_poolState$withdrawal = poolState.withdrawalLockupPeriodDays) !== null && _poolState$withdrawal !== void 0 ? _poolState$withdrawal : 0, 'day').date(1);
8967
8972
  const withdrawTime = lockupEndTime.add(1, 'month');
8968
- return ["You can begin submitting redemption requests on ".concat(shared.timeUtil.timestampToLL(lockupEndTime.unix()), ", which can be redeemed starting ").concat(shared.timeUtil.timestampToLL(withdrawTime.unix()), ".")];
8973
+ return ["You can begin submitting redemption requests on ".concat(shared.timeUtil.timestampToLL(lockupEndTime.unix()), ". Your deposit will be automatically redeemed and your yield rewards will stop on ").concat(shared.timeUtil.timestampToLL(withdrawTime.unix()), ".")];
8969
8974
  };
8970
8975
  const handleUserAction = React.useCallback(() => {
8971
8976
  if (campaign) {