@huma-finance/widgets 0.0.51-beta.346 → 0.0.51-beta.349
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/cjs/index.cjs +34 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +35 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Lend/addRedemptionV2/2-ChooseAmount.tsx +54 -2
- package/src/components/Lend/addRedemptionV2/index.tsx +1 -0
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +11 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
2
|
-
import { txAtom, useMQ, supportedChainId, sendTxAtom, isTxFailed, getExplorerUrl, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, getERC20Contract, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, checkIsDev, EAService, EARejectionError, EARejectMessage, EARejectReason, useCLFeeManager, useCLPoolAllowance, usePoolContract, timeUtil, formatNumber, doesChainSupportNotifi, getBlockchainConfigFromChain, CreditState, useCreditContractV2, useCreditStatsV2, CreditStateV2, upScale, toBigNumber, TRANSFER_ABI, FirstLossCoverIndex, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, useTrancheVaultContractV2, getTrancheAssetsAndShares, useCancellableRedemptionInfoV2, useParamsSearch, IdentityService, CHAINS, configUtil, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useLastDepositTime, usePoolBalance, formatAmount, getTrancheVaultContractV2, getTrancheRedemptionStatusV2, getPoolContractV2, useReceivableInfoV2, useReceivableContractV2, CURRENCY_CODE, CreditEventText, useERC2612Permit, SuperfluidPoolProcessor_ABI, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan,
|
|
2
|
+
import { txAtom, useMQ, supportedChainId, sendTxAtom, isTxFailed, getExplorerUrl, openInNewTab, usePoolUnderlyingTokenContract, TxStateType, useMount, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, usePoolInfo, useAccountStats, getERC20Contract, usePoolInfoV2, usePoolUnderlyingTokenInfoV2, usePoolSafeAllowanceV2, useAuthErrorHandling, checkIsDev, EAService, EARejectionError, EARejectMessage, EARejectReason, useCLFeeManager, useCLPoolAllowance, usePoolContract, timeUtil, formatNumber, doesChainSupportNotifi, getBlockchainConfigFromChain, CreditState, useCreditContractV2, useCreditStatsV2, CreditStateV2, upScale, toBigNumber, TRANSFER_ABI, FirstLossCoverIndex, useFirstLossCoverContractV2, useFirstLossCoverRequirementV2, useFirstLossCoverAllowanceV2, useFeeManager, combineStyles, isEmpty, useInvoiceNFTContract, useRFPoolAllowance, useLenderDepositRecordV2, useLPConfigV2, useNextEpochStartTimeV2, timestampToLL, useTrancheVaultContractV2, getTrancheAssetsAndShares, useCancellableRedemptionInfoV2, useParamsSearch, IdentityService, CHAINS, configUtil, usePoolAllowance, useLenderApproved, useLenderPosition, useWithdrawlLockoutInSeconds, usePoolUnderlyingTokenBalance, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useLastDepositTime, usePoolBalance, formatAmount, getTrancheVaultContractV2, getTrancheRedemptionStatusV2, getPoolContractV2, useReceivableInfoV2, useReceivableContractV2, CURRENCY_CODE, CreditEventText, useERC2612Permit, SuperfluidPoolProcessor_ABI, useMultiSendContract, usePoolUnderlyingToken, hasRFActiveLoan, getWalletAddressAbbr, useFactoring, PoolMap, PoolSubgraphMap, CreditEvent, Provider as Provider$1 } from '@huma-finance/shared';
|
|
3
3
|
import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input, Divider, TextField, FormControl, FormLabel, RadioGroup, FormControlLabel, Radio, Snackbar, Alert, Skeleton, TablePagination, LinearProgress, createTheme, ThemeProvider } from '@mui/material';
|
|
4
4
|
import { useAtom, Provider as Provider$2 } from 'jotai';
|
|
5
5
|
import * as React from 'react';
|
|
@@ -4370,6 +4370,7 @@ function ChooseTranche$1(_ref) {
|
|
|
4370
4370
|
|
|
4371
4371
|
function ChooseAmount$6(_ref) {
|
|
4372
4372
|
let {
|
|
4373
|
+
poolInfo,
|
|
4373
4374
|
poolUnderlyingToken,
|
|
4374
4375
|
trancheInfo
|
|
4375
4376
|
} = _ref;
|
|
@@ -4377,10 +4378,29 @@ function ChooseAmount$6(_ref) {
|
|
|
4377
4378
|
const {
|
|
4378
4379
|
symbol
|
|
4379
4380
|
} = poolUnderlyingToken;
|
|
4381
|
+
const {
|
|
4382
|
+
account,
|
|
4383
|
+
provider
|
|
4384
|
+
} = useWeb3React();
|
|
4380
4385
|
const [currentAmount, setCurrentAmount] = useState(0);
|
|
4381
4386
|
const [currentShares, setCurrentShares] = useState(0);
|
|
4382
4387
|
const maxSharesFormatted = ethers.utils.formatUnits(trancheInfo.shares, poolUnderlyingToken.decimals);
|
|
4383
4388
|
const sharePrice = trancheInfo.assets.toNumber() / trancheInfo.shares.toNumber();
|
|
4389
|
+
const [depositRecord] = useLenderDepositRecordV2(poolInfo.poolName, trancheInfo.tranche, account, provider);
|
|
4390
|
+
const lpConfig = useLPConfigV2(poolInfo.poolName, provider);
|
|
4391
|
+
const nextEpochStartTime = useNextEpochStartTimeV2(poolInfo.poolName, provider);
|
|
4392
|
+
useEffect(() => {
|
|
4393
|
+
if (depositRecord && lpConfig && nextEpochStartTime) {
|
|
4394
|
+
const SECONDS_IN_A_DAY = 24 * 60 * 60;
|
|
4395
|
+
if (nextEpochStartTime < depositRecord.lastDepositTime.toNumber() + lpConfig.withdrawalLockoutPeriodInDays * SECONDS_IN_A_DAY) {
|
|
4396
|
+
dispatch(setStep(WIDGET_STEP.Error));
|
|
4397
|
+
dispatch(setError({
|
|
4398
|
+
errorReason: 'Redemption too soon',
|
|
4399
|
+
errorMessage: "Your last deposit was on ".concat(timestampToLL(depositRecord.lastDepositTime.toNumber()), ". Depositors need to wait ").concat(lpConfig.withdrawalLockoutPeriodInDays, " days before redemption")
|
|
4400
|
+
}));
|
|
4401
|
+
}
|
|
4402
|
+
}
|
|
4403
|
+
}, [depositRecord, dispatch, lpConfig, nextEpochStartTime]);
|
|
4384
4404
|
const handleChangeShares = newShares => {
|
|
4385
4405
|
const amount = Number(newShares) * sharePrice;
|
|
4386
4406
|
setCurrentShares(Number(newShares));
|
|
@@ -4391,6 +4411,11 @@ function ChooseAmount$6(_ref) {
|
|
|
4391
4411
|
const handleAction = () => {
|
|
4392
4412
|
dispatch(setStep(WIDGET_STEP.Transfer));
|
|
4393
4413
|
};
|
|
4414
|
+
if (!depositRecord || !lpConfig || !nextEpochStartTime) {
|
|
4415
|
+
return jsx(LoadingModal, {
|
|
4416
|
+
title: "Redemption"
|
|
4417
|
+
});
|
|
4418
|
+
}
|
|
4394
4419
|
return jsx(InputAmountModal, {
|
|
4395
4420
|
title: "Redemption",
|
|
4396
4421
|
subTitle: "Enter number of shares to redeem from ".concat(trancheInfo.tranche, " tranche"),
|
|
@@ -4547,6 +4572,7 @@ function AddRedemptionV2(_ref) {
|
|
|
4547
4572
|
selectedTranche: trancheInfo === null || trancheInfo === void 0 ? void 0 : trancheInfo.tranche,
|
|
4548
4573
|
changeTranche: handleChangeTranche
|
|
4549
4574
|
}), step === WIDGET_STEP.ChooseAmount && trancheInfo && jsx(ChooseAmount$6, {
|
|
4575
|
+
poolInfo: poolInfo,
|
|
4550
4576
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
4551
4577
|
trancheInfo: trancheInfo
|
|
4552
4578
|
}), step === WIDGET_STEP.Transfer && trancheInfo && jsx(Transfer$8, {
|
|
@@ -5597,6 +5623,8 @@ function ChooseAmount$4(_ref) {
|
|
|
5597
5623
|
} = usePoolSafeAllowanceV2(poolInfo.poolName, account, provider);
|
|
5598
5624
|
const [balance] = usePoolUnderlyingTokenBalanceV2(poolInfo.poolName, account, provider);
|
|
5599
5625
|
const maxAmountFormatted = ethers.utils.formatUnits(balance, poolUnderlyingToken.decimals);
|
|
5626
|
+
const lpConfig = useLPConfigV2(poolInfo.poolName, provider);
|
|
5627
|
+
const isUniTranche = (lpConfig === null || lpConfig === void 0 ? void 0 : lpConfig.maxSeniorJuniorRatio) === 0;
|
|
5600
5628
|
const handleChangeAmount = newAmount => {
|
|
5601
5629
|
setCurrentAmount(newAmount);
|
|
5602
5630
|
dispatch(setSupplyAmount(Number(newAmount)));
|
|
@@ -5606,9 +5634,14 @@ function ChooseAmount$4(_ref) {
|
|
|
5606
5634
|
const step = currentAmountBN.gt(allowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
|
|
5607
5635
|
dispatch(setStep(step));
|
|
5608
5636
|
};
|
|
5637
|
+
if (!lpConfig) {
|
|
5638
|
+
return jsx(LoadingModal, {
|
|
5639
|
+
title: "Supply"
|
|
5640
|
+
});
|
|
5641
|
+
}
|
|
5609
5642
|
return jsx(InputAmountModal, {
|
|
5610
5643
|
title: "Enter Amount",
|
|
5611
|
-
subTitle: "Supplying ".concat(symbol, " with ").concat(selectedTranche),
|
|
5644
|
+
subTitle: "Supplying ".concat(symbol, " with ").concat(isUniTranche ? 'uni tranche' : selectedTranche),
|
|
5612
5645
|
tokenSymbol: symbol,
|
|
5613
5646
|
currentAmount: currentAmount,
|
|
5614
5647
|
handleChangeAmount: handleChangeAmount,
|