@huma-finance/widgets 0.0.62-beta.714 → 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.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input,
3
3
  import { useAtom, Provider as Provider$1 } from 'jotai';
4
4
  import React, { useCallback, useState, useEffect, useMemo, useRef } from 'react';
5
5
  import { useSelector, useDispatch, Provider } from 'react-redux';
6
- import { supportedChainId, isTxFailed, getExplorerUrl, openInNewTab, TxStateType, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, getERC20Contract, checkIsDev, EAService, EARejectionError, EARejectMessage, EARejectReason, timeUtil, formatNumber, doesChainSupportNotifi, CreditState, isEmpty, CreditStateV2, upScale, toBigNumber, TRANSFER_ABI, FirstLossCoverIndex, combineStyles, timestampToLL, getTrancheAssetsAndShares, IdentityService, CHAINS, configUtil, IdentityServiceV2, IdentityVerificationStatusV2, CampaignService, CAMPAIGN_REFERENCE_CODE, KYC_PROVIDER, CHAIN_TYPE, formatAmount, getTrancheVaultContractV2, getTrancheRedemptionStatusV2, getPoolContractV2, CURRENCY_CODE, SuperfluidPoolProcessor_ABI, PoolMap, SOLANA_CHAIN_INFO, SolanaTokenUtils, getSolanaExplorerUrl, getTokenAccounts, getSentinelAddress, getCreditAccounts, ChainEnum, getBlockchainConfigFromChain } from '@huma-finance/shared';
6
+ import { supportedChainId, isTxFailed, getExplorerUrl, openInNewTab, TxStateType, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, getERC20Contract, checkIsDev, EAService, EARejectionError, EARejectMessage, EARejectReason, timeUtil, formatNumber, doesChainSupportNotifi, CreditState, isEmpty, CreditStateV2, upScale, toBigNumber, TRANSFER_ABI, FirstLossCoverIndex, combineStyles, timestampToLL, getTrancheAssetsAndShares, IdentityService, CHAINS, configUtil, IdentityServiceV2, IdentityVerificationStatusV2, CampaignService, CAMPAIGN_REFERENCE_CODE, KYC_PROVIDER, CHAIN_TYPE, formatAmount, getTrancheVaultContractV2, getTrancheRedemptionStatusV2, getPoolContractV2, CURRENCY_CODE, SuperfluidPoolProcessor_ABI, PoolMap, SOLANA_CHAIN_INFO, SolanaTokenUtils, getSolanaExplorerUrl, getSentinelAddress, getTokenAccounts, convertToShares, getCreditAccounts, ChainEnum, getBlockchainConfigFromChain } from '@huma-finance/shared';
7
7
  import { useWeb3React } from '@web3-react/core';
8
8
  import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
9
9
  import { txAtom, useMQ, sendTxAtom, usePoolUnderlyingTokenContract, useMount, usePoolInfo, useAccountStats, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, useCLFeeManager, useCLPoolAllowance, usePoolContract, useCreditContractV2, useCreditStatsV2, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, useTrancheVaultContractV2, useCancellableRedemptionInfoV2, useParamsSearch, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, useChainInfo, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useTrancheVaultAssetsV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, useFactoring, useLenderAccounts, useHumaProgram, useTokenAccount, useTrancheMintAccounts, useTrancheTokenAccounts, useBorrowerAccounts } from '@huma-finance/web-shared';
@@ -27,7 +27,7 @@ import { drawdownWithReceivable, HumaContext, HumaReceivableFactory, makePayment
27
27
  import moment from 'moment';
28
28
  import { getAddress } from '@ethersproject/address';
29
29
  import { BN } from '@coral-xyz/anchor';
30
- import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, getAccount, TokenAccountNotFoundError, TokenInvalidAccountOwnerError, createAssociatedTokenAccountInstruction, ASSOCIATED_TOKEN_PROGRAM_ID, createApproveCheckedInstruction } from '@solana/spl-token';
30
+ import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, createApproveCheckedInstruction, getAccount, TokenAccountNotFoundError, TokenInvalidAccountOwnerError, createAssociatedTokenAccountInstruction, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token';
31
31
  import { useWallet, useConnection } from '@solana/wallet-adapter-react';
32
32
  import { Transaction, PublicKey } from '@solana/web3.js';
33
33
  import { arrayify } from '@ethersproject/bytes';
@@ -8772,6 +8772,7 @@ function Transfer$4(_ref) {
8772
8772
  const {
8773
8773
  publicKey
8774
8774
  } = useWallet();
8775
+ const sentinel = getSentinelAddress(poolInfo.chainId);
8775
8776
  const {
8776
8777
  supplyAmount
8777
8778
  } = useAppSelector(selectWidgetState);
@@ -8785,6 +8786,8 @@ function Transfer$4(_ref) {
8785
8786
  seniorLenderApprovedAccountPDA,
8786
8787
  seniorLenderStateAccount,
8787
8788
  juniorLenderStateAccount,
8789
+ seniorTrancheMintSupply,
8790
+ juniorTrancheMintSupply,
8788
8791
  loading: isLoadingLenderAccounts
8789
8792
  } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName);
8790
8793
  const program = useHumaProgram(poolInfo.chainId);
@@ -8801,6 +8804,7 @@ function Transfer$4(_ref) {
8801
8804
  }, [dispatch, isDev, pointsTestnetExperience, poolInfo.chainId, poolState.campaign, publicKey]);
8802
8805
  useEffect(() => {
8803
8806
  async function getTx() {
8807
+ var _poolState$seniorTran, _poolState$juniorTran;
8804
8808
  if (!publicKey || transaction || isLoadingLenderAccounts) {
8805
8809
  return;
8806
8810
  }
@@ -8836,10 +8840,22 @@ function Transfer$4(_ref) {
8836
8840
  underlyingTokenProgram: TOKEN_PROGRAM_ID
8837
8841
  }).transaction();
8838
8842
  tx.add(depositTx);
8843
+
8844
+ // Approve automatic redemptions
8845
+ const sharesAmount = convertToShares(selectedTranche === 'senior' ? new BN((_poolState$seniorTran = poolState.seniorTrancheAssets) !== null && _poolState$seniorTran !== void 0 ? _poolState$seniorTran : 0) : new BN((_poolState$juniorTran = poolState.juniorTrancheAssets) !== null && _poolState$juniorTran !== void 0 ? _poolState$juniorTran : 0), selectedTranche === 'senior' ? seniorTrancheMintSupply !== null && seniorTrancheMintSupply !== void 0 ? seniorTrancheMintSupply : new BN(0) : juniorTrancheMintSupply !== null && juniorTrancheMintSupply !== void 0 ? juniorTrancheMintSupply : new BN(0), supplyBigNumber);
8846
+ tx.add(createApproveCheckedInstruction(selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA, new PublicKey(selectedTranche === 'senior' ? poolInfo.seniorTrancheMint : poolInfo.juniorTrancheMint), new PublicKey(sentinel),
8847
+ // delegate
8848
+ publicKey,
8849
+ // owner of the wallet
8850
+ BigInt(sharesAmount.muln(1.1).toString()),
8851
+ // amount
8852
+ poolInfo.trancheDecimals, undefined,
8853
+ // multiSigners
8854
+ TOKEN_2022_PROGRAM_ID));
8839
8855
  setTransaction(tx);
8840
8856
  }
8841
8857
  getTx();
8842
- }, [isLoadingLenderAccounts, juniorLenderApprovedAccountPDA, juniorLenderStateAccount, poolInfo, program.methods, publicKey, selectedTranche, seniorLenderApprovedAccountPDA, seniorLenderStateAccount, supplyBigNumber, transaction]);
8858
+ }, [isLoadingLenderAccounts, juniorLenderApprovedAccountPDA, juniorLenderStateAccount, juniorTrancheMintSupply, poolInfo, poolState.juniorTrancheAssets, poolState.seniorTrancheAssets, program.methods, publicKey, selectedTranche, seniorLenderApprovedAccountPDA, seniorLenderStateAccount, seniorTrancheMintSupply, sentinel, supplyBigNumber, transaction]);
8843
8859
  if (isLoadingLenderAccounts) {
8844
8860
  return jsx(LoadingModal, {
8845
8861
  title: "Supply"
@@ -8937,7 +8953,7 @@ function Success(_ref) {
8937
8953
  var _poolState$withdrawal;
8938
8954
  const lockupEndTime = dayjs().add((_poolState$withdrawal = poolState.withdrawalLockupPeriodDays) !== null && _poolState$withdrawal !== void 0 ? _poolState$withdrawal : 0, 'day').date(1);
8939
8955
  const withdrawTime = lockupEndTime.add(1, 'month');
8940
- return ["You can begin submitting redemption requests on ".concat(timeUtil.timestampToLL(lockupEndTime.unix()), ", which can be redeemed starting ").concat(timeUtil.timestampToLL(withdrawTime.unix()), ".")];
8956
+ return ["You can begin submitting redemption requests on ".concat(timeUtil.timestampToLL(lockupEndTime.unix()), ". Your deposit will be automatically redeemed and your yield rewards will stop on ").concat(timeUtil.timestampToLL(withdrawTime.unix()), ".")];
8941
8957
  };
8942
8958
  const handleUserAction = useCallback(() => {
8943
8959
  if (campaign) {