@huma-finance/widgets 0.0.61-beta.561 → 0.0.61-beta.565
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/API.md +1 -0
- package/dist/cjs/index.cjs +13 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/Lend/addRedemptionV2/2-ChooseAmount.tsx +7 -8
- package/src/components/Lend/addRedemptionV2/index.tsx +19 -1
package/dist/index.d.ts
CHANGED
|
@@ -141,11 +141,13 @@ type InvoiceFactoringPaymentProps = {
|
|
|
141
141
|
* Lend pool add redemption props
|
|
142
142
|
* @typedef {Object} AddRedemptionPropsV2
|
|
143
143
|
* @property {POOL_NAME} poolName The name of the pool.
|
|
144
|
+
* @property {POOL_NTrancheTypeAME} tranche The tranche type.
|
|
144
145
|
* @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
145
146
|
* @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the lending pool withdraw action is successful.
|
|
146
147
|
*/
|
|
147
148
|
type AddRedemptionPropsV2 = {
|
|
148
149
|
poolName: keyof typeof POOL_NAME;
|
|
150
|
+
tranche?: TrancheType;
|
|
149
151
|
handleClose: () => void;
|
|
150
152
|
handleSuccess?: (blockNumber?: number) => void;
|
|
151
153
|
};
|
package/dist/index.js
CHANGED
|
@@ -21,6 +21,7 @@ import ArrowDropUpIcon from '@mui/icons-material/ArrowDropUp';
|
|
|
21
21
|
import { newFrontendClient } from '@notifi-network/notifi-frontend-client';
|
|
22
22
|
import { NumericFormat } from 'react-number-format';
|
|
23
23
|
import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
|
|
24
|
+
import dayjs from 'dayjs';
|
|
24
25
|
import Persona from 'persona';
|
|
25
26
|
import moment from 'moment';
|
|
26
27
|
import { drawdownWithReceivable, HumaContext, HumaReceivableFactory, makePaymentWithReceivable, makePrincipalPaymentAndDrawdownWithReceivable, SubgraphService } from '@huma-finance/sdk';
|
|
@@ -4514,11 +4515,13 @@ function ChooseAmount$6(_ref) {
|
|
|
4514
4515
|
useEffect(() => {
|
|
4515
4516
|
if (depositRecord && lpConfig && nextEpochStartTime) {
|
|
4516
4517
|
const SECONDS_IN_A_DAY = 24 * 60 * 60;
|
|
4517
|
-
|
|
4518
|
+
const lockupEndTime = depositRecord.lastDepositTime.toNumber() + lpConfig.withdrawalLockoutPeriodInDays * SECONDS_IN_A_DAY;
|
|
4519
|
+
if (nextEpochStartTime < lockupEndTime) {
|
|
4520
|
+
const lockupEndTimeDayjs = dayjs.unix(lockupEndTime).date(1);
|
|
4518
4521
|
dispatch(setStep(WIDGET_STEP.Error));
|
|
4519
4522
|
dispatch(setError({
|
|
4520
4523
|
errorReason: 'Redemption too soon',
|
|
4521
|
-
errorMessage: "Your last deposit was on ".concat(timestampToLL(depositRecord.lastDepositTime.toNumber()), ".
|
|
4524
|
+
errorMessage: "Your last deposit was on ".concat(timestampToLL(depositRecord.lastDepositTime.toNumber()), ". You can redeem on ").concat(timestampToLL(lockupEndTimeDayjs.unix()), ".")
|
|
4522
4525
|
}));
|
|
4523
4526
|
}
|
|
4524
4527
|
}
|
|
@@ -4603,6 +4606,7 @@ function Done$2(_ref) {
|
|
|
4603
4606
|
function AddRedemptionV2(_ref) {
|
|
4604
4607
|
let {
|
|
4605
4608
|
poolName: poolNameStr,
|
|
4609
|
+
tranche,
|
|
4606
4610
|
handleClose,
|
|
4607
4611
|
handleSuccess
|
|
4608
4612
|
} = _ref;
|
|
@@ -4647,6 +4651,11 @@ function AddRedemptionV2(_ref) {
|
|
|
4647
4651
|
}, [account, poolName, provider]);
|
|
4648
4652
|
useEffect(() => {
|
|
4649
4653
|
if (!step && trancheInfoFetched) {
|
|
4654
|
+
if (tranche) {
|
|
4655
|
+
setTrancheInfo(tranche === 'junior' ? juniorTrancheInfo : seniorTrancheInfo);
|
|
4656
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
4657
|
+
return;
|
|
4658
|
+
}
|
|
4650
4659
|
if (juniorTrancheInfo.assets.gt(0) && seniorTrancheInfo.assets.lte(0)) {
|
|
4651
4660
|
setTrancheInfo(juniorTrancheInfo);
|
|
4652
4661
|
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
@@ -4661,7 +4670,7 @@ function AddRedemptionV2(_ref) {
|
|
|
4661
4670
|
dispatch(setStep(WIDGET_STEP.ChooseTranche));
|
|
4662
4671
|
}
|
|
4663
4672
|
}
|
|
4664
|
-
}, [dispatch, juniorTrancheInfo, seniorTrancheInfo, step, trancheInfoFetched]);
|
|
4673
|
+
}, [dispatch, juniorTrancheInfo, seniorTrancheInfo, step, tranche, trancheInfoFetched]);
|
|
4665
4674
|
const handleRedeemSuccess = useCallback(blockNumber => {
|
|
4666
4675
|
if (handleSuccess) {
|
|
4667
4676
|
handleSuccess(blockNumber);
|