@huma-finance/widgets 0.0.62-beta.714 → 0.0.62-beta.716

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.
@@ -8789,6 +8789,7 @@ function Transfer$4(_ref) {
8789
8789
  const {
8790
8790
  publicKey
8791
8791
  } = walletAdapterReact.useWallet();
8792
+ const sentinel = shared.getSentinelAddress(poolInfo.chainId);
8792
8793
  const {
8793
8794
  supplyAmount
8794
8795
  } = useAppSelector(selectWidgetState);
@@ -8802,6 +8803,8 @@ function Transfer$4(_ref) {
8802
8803
  seniorLenderApprovedAccountPDA,
8803
8804
  seniorLenderStateAccount,
8804
8805
  juniorLenderStateAccount,
8806
+ seniorTrancheMintSupply,
8807
+ juniorTrancheMintSupply,
8805
8808
  loading: isLoadingLenderAccounts
8806
8809
  } = webShared.useLenderAccounts(poolInfo.chainId, poolInfo.poolName);
8807
8810
  const program = webShared.useHumaProgram(poolInfo.chainId);
@@ -8818,6 +8821,7 @@ function Transfer$4(_ref) {
8818
8821
  }, [dispatch, isDev, pointsTestnetExperience, poolInfo.chainId, poolState.campaign, publicKey]);
8819
8822
  React.useEffect(() => {
8820
8823
  async function getTx() {
8824
+ var _poolState$seniorTran, _poolState$juniorTran;
8821
8825
  if (!publicKey || transaction || isLoadingLenderAccounts) {
8822
8826
  return;
8823
8827
  }
@@ -8853,10 +8857,22 @@ function Transfer$4(_ref) {
8853
8857
  underlyingTokenProgram: splToken.TOKEN_PROGRAM_ID
8854
8858
  }).transaction();
8855
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));
8856
8872
  setTransaction(tx);
8857
8873
  }
8858
8874
  getTx();
8859
- }, [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]);
8860
8876
  if (isLoadingLenderAccounts) {
8861
8877
  return jsxRuntime.jsx(LoadingModal, {
8862
8878
  title: "Supply"
@@ -8954,7 +8970,7 @@ function Success(_ref) {
8954
8970
  var _poolState$withdrawal;
8955
8971
  const lockupEndTime = dayjs__default["default"]().add((_poolState$withdrawal = poolState.withdrawalLockupPeriodDays) !== null && _poolState$withdrawal !== void 0 ? _poolState$withdrawal : 0, 'day').date(1);
8956
8972
  const withdrawTime = lockupEndTime.add(1, 'month');
8957
- 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 ["Redemption request will be automatically submitted on ".concat(shared.timeUtil.timestampToLL(lockupEndTime.unix()), ". Your deposit can be redeemed and yield rewards will stop on ").concat(shared.timeUtil.timestampToLL(withdrawTime.unix()), ".")];
8958
8974
  };
8959
8975
  const handleUserAction = React.useCallback(() => {
8960
8976
  if (campaign) {