@huma-finance/widgets 0.0.48-beta.291 → 0.0.48-beta.296
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 +294 -171
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +295 -172
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +0 -5
- package/src/components/Lend/supplyV2/1-ChooseTranche.tsx +21 -23
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +30 -20
- package/src/components/Lend/supplyV2/4-ApproveAllowance.tsx +15 -2
- package/src/components/Lend/supplyV2/5-Transfer.tsx +58 -14
- package/src/components/Lend/supplyV2/6-Success.tsx +2 -5
- package/src/components/Lend/supplyV2/index.tsx +59 -31
- package/src/components/Lend/withdrawV2/1-ChooseTranche.tsx +26 -108
- package/src/components/Lend/withdrawV2/2-ChooseAmount.tsx +88 -0
- package/src/components/Lend/withdrawV2/3-Transfer.tsx +110 -0
- package/src/components/Lend/withdrawV2/index.tsx +123 -34
- package/src/components/Lend/withdrawV2/2-Transfer.tsx +0 -48
- /package/src/components/Lend/withdrawV2/{3-Done.tsx → 4-Done.tsx} +0 -0
package/dist/cjs/index.cjs
CHANGED
|
@@ -2477,7 +2477,7 @@ function ChooseAmountModal(_ref) {
|
|
|
2477
2477
|
});
|
|
2478
2478
|
}
|
|
2479
2479
|
|
|
2480
|
-
function ChooseAmount$
|
|
2480
|
+
function ChooseAmount$d(_ref) {
|
|
2481
2481
|
let {
|
|
2482
2482
|
poolInfo,
|
|
2483
2483
|
accountStats
|
|
@@ -2954,7 +2954,7 @@ function CreditLineBorrow(_ref) {
|
|
|
2954
2954
|
children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$4, {
|
|
2955
2955
|
poolInfo: poolInfo,
|
|
2956
2956
|
handleApprove: approveCallback
|
|
2957
|
-
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
2957
|
+
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$d, {
|
|
2958
2958
|
poolInfo: poolInfo,
|
|
2959
2959
|
accountStats: accountStats
|
|
2960
2960
|
}), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$a, {
|
|
@@ -3045,7 +3045,7 @@ function InputAmountModal(_ref) {
|
|
|
3045
3045
|
});
|
|
3046
3046
|
}
|
|
3047
3047
|
|
|
3048
|
-
function ChooseAmount$
|
|
3048
|
+
function ChooseAmount$c(_ref) {
|
|
3049
3049
|
let {
|
|
3050
3050
|
poolInfo,
|
|
3051
3051
|
poolUnderlyingToken,
|
|
@@ -3287,7 +3287,7 @@ function CreditLineBorrowV2(_ref) {
|
|
|
3287
3287
|
handleSuccess: handleSuccessCallback,
|
|
3288
3288
|
children: [!step && jsxRuntime.jsx(LoadingModal, {
|
|
3289
3289
|
title: "Borrow"
|
|
3290
|
-
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
3290
|
+
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$c, {
|
|
3291
3291
|
poolInfo: poolInfo,
|
|
3292
3292
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
3293
3293
|
accountStats: accountStats
|
|
@@ -3311,7 +3311,7 @@ function CreditLineBorrowV2(_ref) {
|
|
|
3311
3311
|
});
|
|
3312
3312
|
}
|
|
3313
3313
|
|
|
3314
|
-
function ChooseAmount$
|
|
3314
|
+
function ChooseAmount$b(_ref) {
|
|
3315
3315
|
let {
|
|
3316
3316
|
payoffAmount,
|
|
3317
3317
|
totalDueAmount,
|
|
@@ -3468,7 +3468,7 @@ function CreditLinePayment(_ref) {
|
|
|
3468
3468
|
loadingTitle: "Make Payment",
|
|
3469
3469
|
handleClose: handleClose,
|
|
3470
3470
|
handleSuccess: handleSuccess,
|
|
3471
|
-
children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
3471
|
+
children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$b, {
|
|
3472
3472
|
poolInfo: poolInfo,
|
|
3473
3473
|
payoffAmount: payoffAmount,
|
|
3474
3474
|
totalDueAmount: totalDueAmount
|
|
@@ -3487,7 +3487,7 @@ function CreditLinePayment(_ref) {
|
|
|
3487
3487
|
});
|
|
3488
3488
|
}
|
|
3489
3489
|
|
|
3490
|
-
function ChooseAmount$
|
|
3490
|
+
function ChooseAmount$a(_ref) {
|
|
3491
3491
|
let {
|
|
3492
3492
|
payoffAmount: payoffAmountBN,
|
|
3493
3493
|
totalDueAmount: totalDueAmountBN,
|
|
@@ -3509,10 +3509,6 @@ function ChooseAmount$9(_ref) {
|
|
|
3509
3509
|
} = shared.usePoolSafeAllowanceV2(poolInfo.poolName, account, provider);
|
|
3510
3510
|
const totalDueAmount = Number(ethers.ethers.utils.formatUnits(totalDueAmountBN, decimals));
|
|
3511
3511
|
const payoffAmount = Number(ethers.ethers.utils.formatUnits(payoffAmountBN, decimals));
|
|
3512
|
-
console.log('totalDueAmountBN', totalDueAmountBN.toString());
|
|
3513
|
-
console.log('payoffAmountBN', payoffAmountBN.toString());
|
|
3514
|
-
console.log('payoffAmount', payoffAmount);
|
|
3515
|
-
console.log('currentAmount', currentAmount);
|
|
3516
3512
|
React.useEffect(() => {
|
|
3517
3513
|
setCurrentAmount(totalDueAmount);
|
|
3518
3514
|
}, [totalDueAmount]);
|
|
@@ -3676,7 +3672,7 @@ function CreditLinePaymentV2(_ref) {
|
|
|
3676
3672
|
loadingTitle: "Pay",
|
|
3677
3673
|
handleClose: handleClose,
|
|
3678
3674
|
handleSuccess: handleSuccess,
|
|
3679
|
-
children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
3675
|
+
children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$a, {
|
|
3680
3676
|
poolInfo: poolInfo,
|
|
3681
3677
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
3682
3678
|
payoffAmount: payoffAmount,
|
|
@@ -3869,7 +3865,7 @@ function Evaluation$3(_ref) {
|
|
|
3869
3865
|
});
|
|
3870
3866
|
}
|
|
3871
3867
|
|
|
3872
|
-
function ChooseAmount$
|
|
3868
|
+
function ChooseAmount$9(_ref) {
|
|
3873
3869
|
var _receivable;
|
|
3874
3870
|
let {
|
|
3875
3871
|
poolInfo,
|
|
@@ -4150,7 +4146,7 @@ function InvoiceFactoringBorrow(_ref) {
|
|
|
4150
4146
|
children: [step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$3, {
|
|
4151
4147
|
poolInfo: poolInfo,
|
|
4152
4148
|
tokenId: tokenId.toString()
|
|
4153
|
-
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
4149
|
+
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$9, {
|
|
4154
4150
|
poolInfo: poolInfo,
|
|
4155
4151
|
accountStats: accountStats
|
|
4156
4152
|
}), step === WIDGET_STEP.ConfirmTransfer && jsxRuntime.jsx(ConfirmTransfer$1, {}), step === WIDGET_STEP.ApproveNFT && jsxRuntime.jsx(ApproveNFT, {
|
|
@@ -4169,7 +4165,7 @@ function InvoiceFactoringBorrow(_ref) {
|
|
|
4169
4165
|
});
|
|
4170
4166
|
}
|
|
4171
4167
|
|
|
4172
|
-
function ChooseAmount$
|
|
4168
|
+
function ChooseAmount$8(_ref) {
|
|
4173
4169
|
let {
|
|
4174
4170
|
creditRecord,
|
|
4175
4171
|
poolInfo
|
|
@@ -4314,7 +4310,7 @@ function InvoiceFactoringPayment(_ref) {
|
|
|
4314
4310
|
loadingTitle: "Make Payment",
|
|
4315
4311
|
handleClose: handleClose,
|
|
4316
4312
|
handleSuccess: handleSuccess,
|
|
4317
|
-
children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
4313
|
+
children: [step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$8, {
|
|
4318
4314
|
creditRecord: creditRecord,
|
|
4319
4315
|
poolInfo: poolInfo
|
|
4320
4316
|
}), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$5, {
|
|
@@ -4460,7 +4456,7 @@ function ChooseAction(_ref) {
|
|
|
4460
4456
|
});
|
|
4461
4457
|
}
|
|
4462
4458
|
|
|
4463
|
-
function ChooseAmount$
|
|
4459
|
+
function ChooseAmount$7(_ref) {
|
|
4464
4460
|
let {
|
|
4465
4461
|
poolInfo,
|
|
4466
4462
|
poolUnderlyingToken,
|
|
@@ -4675,7 +4671,7 @@ function LendRedeemV2(_ref) {
|
|
|
4675
4671
|
changeRedemptionType: setRedemptionType,
|
|
4676
4672
|
seniorPosition: seniorPosition,
|
|
4677
4673
|
juniorPosition: juniorPosition
|
|
4678
|
-
}), step === WIDGET_STEP.ChooseAmount && redemptionType && jsxRuntime.jsx(ChooseAmount$
|
|
4674
|
+
}), step === WIDGET_STEP.ChooseAmount && redemptionType && jsxRuntime.jsx(ChooseAmount$7, {
|
|
4679
4675
|
poolInfo: poolInfo,
|
|
4680
4676
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
4681
4677
|
redemptionType: redemptionType,
|
|
@@ -5085,7 +5081,7 @@ function Evaluation$2(_ref) {
|
|
|
5085
5081
|
});
|
|
5086
5082
|
}
|
|
5087
5083
|
|
|
5088
|
-
function ChooseAmount$
|
|
5084
|
+
function ChooseAmount$6(_ref) {
|
|
5089
5085
|
let {
|
|
5090
5086
|
allowance,
|
|
5091
5087
|
withdrawlLockoutSeconds,
|
|
@@ -5292,7 +5288,7 @@ function LendSupply(_ref) {
|
|
|
5292
5288
|
poolInfo: poolInfo,
|
|
5293
5289
|
handleClose: handleClose,
|
|
5294
5290
|
handleApproveSuccess: handleApproveSuccess
|
|
5295
|
-
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
5291
|
+
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$6, {
|
|
5296
5292
|
poolInfo: poolInfo,
|
|
5297
5293
|
allowance: allowance,
|
|
5298
5294
|
underlyingTokenBalance: balanceWithoutDecimals,
|
|
@@ -5317,11 +5313,12 @@ function LendSupply(_ref) {
|
|
|
5317
5313
|
}
|
|
5318
5314
|
|
|
5319
5315
|
var _templateObject$9, _templateObject2$7, _templateObject3$6;
|
|
5320
|
-
function
|
|
5316
|
+
function ChooseSupplyType(_ref) {
|
|
5321
5317
|
let {
|
|
5322
5318
|
poolUnderlyingToken,
|
|
5323
|
-
|
|
5324
|
-
|
|
5319
|
+
selectedSupplyType,
|
|
5320
|
+
supplyTypes,
|
|
5321
|
+
changeSupplyType
|
|
5325
5322
|
} = _ref;
|
|
5326
5323
|
const theme = material.useTheme();
|
|
5327
5324
|
const dispatch = useAppDispatch();
|
|
@@ -5330,16 +5327,15 @@ function ChooseTranche$1(_ref) {
|
|
|
5330
5327
|
radioGroup: material.css(_templateObject2$7 || (_templateObject2$7 = _taggedTemplateLiteral(["\n margin-left: ", ";\n margin-top: ", ";\n "])), theme.spacing(3), theme.spacing(3)),
|
|
5331
5328
|
formControl: material.css(_templateObject3$6 || (_templateObject3$6 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n\n .MuiFormControlLabel-label {\n color: ", ";\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n line-height: 150%;\n letter-spacing: 0.15px;\n }\n "])), theme.spacing(1), theme.palette.text.primary)
|
|
5332
5329
|
};
|
|
5330
|
+
const handleChangeSupplyType = supplyTypeValue => {
|
|
5331
|
+
const supplyType = supplyTypes.find(item => item.value === supplyTypeValue);
|
|
5332
|
+
if (supplyType) {
|
|
5333
|
+
changeSupplyType(supplyType);
|
|
5334
|
+
}
|
|
5335
|
+
};
|
|
5333
5336
|
const handleNext = () => {
|
|
5334
5337
|
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
5335
5338
|
};
|
|
5336
|
-
const items = [{
|
|
5337
|
-
label: 'Senior',
|
|
5338
|
-
value: 'senior'
|
|
5339
|
-
}, {
|
|
5340
|
-
label: 'Junior',
|
|
5341
|
-
value: 'junior'
|
|
5342
|
-
}];
|
|
5343
5339
|
return jsxRuntime.jsxs(WrapperModal, {
|
|
5344
5340
|
title: "Supply ".concat(poolUnderlyingToken.symbol),
|
|
5345
5341
|
children: [jsxRuntime.jsxs(material.FormControl, {
|
|
@@ -5350,8 +5346,8 @@ function ChooseTranche$1(_ref) {
|
|
|
5350
5346
|
"aria-labelledby": "buttons-group-label",
|
|
5351
5347
|
name: "radio-buttons-group",
|
|
5352
5348
|
css: styles.radioGroup,
|
|
5353
|
-
onChange: e =>
|
|
5354
|
-
children:
|
|
5349
|
+
onChange: e => handleChangeSupplyType(e.target.value),
|
|
5350
|
+
children: supplyTypes.map(item => jsxRuntime.jsx(material.FormControlLabel, {
|
|
5355
5351
|
value: item.value,
|
|
5356
5352
|
control: jsxRuntime.jsx(material.Radio, {
|
|
5357
5353
|
sx: {
|
|
@@ -5366,7 +5362,7 @@ function ChooseTranche$1(_ref) {
|
|
|
5366
5362
|
})]
|
|
5367
5363
|
}), jsxRuntime.jsx(BottomButton, {
|
|
5368
5364
|
variant: "contained",
|
|
5369
|
-
disabled: !
|
|
5365
|
+
disabled: !selectedSupplyType,
|
|
5370
5366
|
onClick: handleNext,
|
|
5371
5367
|
children: "NEXT"
|
|
5372
5368
|
})]
|
|
@@ -5605,11 +5601,11 @@ function Evaluation$1(_ref) {
|
|
|
5605
5601
|
});
|
|
5606
5602
|
}
|
|
5607
5603
|
|
|
5608
|
-
function ChooseAmount$
|
|
5604
|
+
function ChooseAmount$5(_ref) {
|
|
5609
5605
|
let {
|
|
5610
5606
|
poolInfo,
|
|
5611
5607
|
poolUnderlyingToken,
|
|
5612
|
-
|
|
5608
|
+
selectedSupplyType
|
|
5613
5609
|
} = _ref;
|
|
5614
5610
|
const dispatch = useAppDispatch();
|
|
5615
5611
|
const {
|
|
@@ -5622,22 +5618,28 @@ function ChooseAmount$4(_ref) {
|
|
|
5622
5618
|
} = poolUnderlyingToken;
|
|
5623
5619
|
const [currentAmount, setCurrentAmount] = React.useState(0);
|
|
5624
5620
|
const {
|
|
5625
|
-
allowance = ethers.BigNumber.from(0)
|
|
5621
|
+
allowance: poolSafeAllowance = ethers.BigNumber.from(0)
|
|
5626
5622
|
} = shared.usePoolSafeAllowanceV2(poolInfo.poolName, account, provider);
|
|
5627
|
-
const [
|
|
5628
|
-
const
|
|
5623
|
+
const [firstLossCoverAllowance = ethers.BigNumber.from(0)] = shared.useFirstLossCoverAllowanceV2(poolInfo.poolName, Number(selectedSupplyType.value), account, provider);
|
|
5624
|
+
const [underlyingTokenBalance = ethers.BigNumber.from(0)] = shared.usePoolUnderlyingTokenBalanceV2(poolInfo.poolName, account, provider);
|
|
5625
|
+
const maxAmountFormatted = ethers.ethers.utils.formatUnits(underlyingTokenBalance, poolUnderlyingToken.decimals);
|
|
5629
5626
|
const handleChangeAmount = newAmount => {
|
|
5630
5627
|
setCurrentAmount(newAmount);
|
|
5631
5628
|
dispatch(setSupplyAmount(Number(newAmount)));
|
|
5632
5629
|
};
|
|
5633
5630
|
const handleAction = () => {
|
|
5634
5631
|
const currentAmountBN = ethers.ethers.utils.parseUnits(String(currentAmount), decimals);
|
|
5635
|
-
|
|
5636
|
-
|
|
5632
|
+
if (selectedSupplyType.type === 'tranche') {
|
|
5633
|
+
const step = currentAmountBN.gt(poolSafeAllowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
|
|
5634
|
+
dispatch(setStep(step));
|
|
5635
|
+
} else {
|
|
5636
|
+
const step = currentAmountBN.gt(firstLossCoverAllowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer;
|
|
5637
|
+
dispatch(setStep(step));
|
|
5638
|
+
}
|
|
5637
5639
|
};
|
|
5638
5640
|
return jsxRuntime.jsx(InputAmountModal, {
|
|
5639
5641
|
title: "Enter Amount",
|
|
5640
|
-
subTitle: "Supplying ".concat(symbol, " with ").concat(
|
|
5642
|
+
subTitle: "Supplying ".concat(symbol, " with ").concat(selectedSupplyType === null || selectedSupplyType === void 0 ? void 0 : selectedSupplyType.label),
|
|
5641
5643
|
tokenSymbol: symbol,
|
|
5642
5644
|
currentAmount: currentAmount,
|
|
5643
5645
|
handleChangeAmount: handleChangeAmount,
|
|
@@ -5651,10 +5653,14 @@ function ChooseAmount$4(_ref) {
|
|
|
5651
5653
|
function ApproveAllowance$3(_ref) {
|
|
5652
5654
|
let {
|
|
5653
5655
|
poolInfo,
|
|
5654
|
-
poolUnderlyingToken
|
|
5656
|
+
poolUnderlyingToken,
|
|
5657
|
+
selectedSupplyType
|
|
5655
5658
|
} = _ref;
|
|
5656
5659
|
const dispatch = useAppDispatch();
|
|
5657
|
-
|
|
5660
|
+
let spender = poolInfo.poolSafe;
|
|
5661
|
+
if (selectedSupplyType.type === 'firstLossCover') {
|
|
5662
|
+
spender = poolInfo.firstLossCovers[Number(selectedSupplyType.value)];
|
|
5663
|
+
}
|
|
5658
5664
|
const handleSuccess = React.useCallback(() => {
|
|
5659
5665
|
dispatch(setStep(WIDGET_STEP.Transfer));
|
|
5660
5666
|
}, [dispatch]);
|
|
@@ -5670,7 +5676,7 @@ function Transfer$5(_ref) {
|
|
|
5670
5676
|
let {
|
|
5671
5677
|
poolInfo,
|
|
5672
5678
|
poolUnderlyingToken,
|
|
5673
|
-
|
|
5679
|
+
selectedSupplyType
|
|
5674
5680
|
} = _ref;
|
|
5675
5681
|
const dispatch = useAppDispatch();
|
|
5676
5682
|
const {
|
|
@@ -5684,17 +5690,40 @@ function Transfer$5(_ref) {
|
|
|
5684
5690
|
decimals
|
|
5685
5691
|
} = poolUnderlyingToken;
|
|
5686
5692
|
const supplyBigNumber = ethers.ethers.utils.parseUnits(String(supplyAmount), decimals);
|
|
5687
|
-
const
|
|
5693
|
+
const [contract, setContract] = React.useState(undefined);
|
|
5694
|
+
React.useEffect(() => {
|
|
5695
|
+
const fetchData = async () => {
|
|
5696
|
+
if (account) {
|
|
5697
|
+
if (selectedSupplyType.type === 'tranche') {
|
|
5698
|
+
const trancheVaultContract = await shared.getTrancheVaultContractV2(poolInfo.poolName, selectedSupplyType.value, provider, account);
|
|
5699
|
+
if (trancheVaultContract) {
|
|
5700
|
+
setContract(trancheVaultContract);
|
|
5701
|
+
}
|
|
5702
|
+
}
|
|
5703
|
+
if (selectedSupplyType.type === 'firstLossCover') {
|
|
5704
|
+
const firstLossCoverContract = await shared.getFirstLossCoverContractV2(poolInfo.poolName, Number(selectedSupplyType.value), provider, account);
|
|
5705
|
+
if (firstLossCoverContract) {
|
|
5706
|
+
setContract(firstLossCoverContract);
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5709
|
+
}
|
|
5710
|
+
};
|
|
5711
|
+
fetchData();
|
|
5712
|
+
}, [account, poolInfo.poolName, provider, selectedSupplyType.type, selectedSupplyType.value]);
|
|
5713
|
+
const method = selectedSupplyType.type === 'tranche' ? 'deposit' : 'depositCover';
|
|
5714
|
+
const params = selectedSupplyType.type === 'tranche' ? [supplyBigNumber, account] : [supplyBigNumber];
|
|
5688
5715
|
const handleSuccess = React.useCallback(() => {
|
|
5689
5716
|
dispatch(setStep(WIDGET_STEP.Done));
|
|
5690
5717
|
}, [dispatch]);
|
|
5691
|
-
if (!
|
|
5692
|
-
return
|
|
5718
|
+
if (!contract) {
|
|
5719
|
+
return jsxRuntime.jsx(LoadingModal, {
|
|
5720
|
+
title: "Transaction Pending"
|
|
5721
|
+
});
|
|
5693
5722
|
}
|
|
5694
5723
|
return jsxRuntime.jsx(TxSendModalV2, {
|
|
5695
|
-
contract:
|
|
5696
|
-
method:
|
|
5697
|
-
params:
|
|
5724
|
+
contract: contract,
|
|
5725
|
+
method: method,
|
|
5726
|
+
params: params,
|
|
5698
5727
|
handleSuccess: handleSuccess
|
|
5699
5728
|
});
|
|
5700
5729
|
}
|
|
@@ -5733,10 +5762,9 @@ function Success$4(_ref) {
|
|
|
5733
5762
|
events.forEach(event => {
|
|
5734
5763
|
const {
|
|
5735
5764
|
from,
|
|
5736
|
-
to,
|
|
5737
5765
|
value
|
|
5738
5766
|
} = event.args;
|
|
5739
|
-
if (from.toLowerCase() === (account === null || account === void 0 ? void 0 : account.toLowerCase())
|
|
5767
|
+
if (from.toLowerCase() === (account === null || account === void 0 ? void 0 : account.toLowerCase())) {
|
|
5740
5768
|
setSupplyAmount(shared.downScale(value.toString(), decimals));
|
|
5741
5769
|
}
|
|
5742
5770
|
});
|
|
@@ -5785,36 +5813,50 @@ function LendSupplyV2(_ref) {
|
|
|
5785
5813
|
step,
|
|
5786
5814
|
errorMessage
|
|
5787
5815
|
} = useAppSelector(selectWidgetState);
|
|
5788
|
-
const [
|
|
5816
|
+
const [supplyTypes, setSupplyTypes] = React.useState([]);
|
|
5817
|
+
const [selectedSupplyType, setSelectedSupplyType] = React.useState();
|
|
5789
5818
|
const poolUnderlyingToken = shared.usePoolUnderlyingTokenInfoV2(poolName, provider);
|
|
5790
5819
|
const [lenderApprovedSenior] = shared.useLenderApprovedV2(poolName, 'senior', account, provider);
|
|
5791
5820
|
const [lenderApprovedJunior] = shared.useLenderApprovedV2(poolName, 'junior', account, provider);
|
|
5792
|
-
const
|
|
5821
|
+
const [flcStats] = shared.useFirstLossCoverStatsV2(poolName, account, provider);
|
|
5822
|
+
const lenderApproveStatusFetched = lenderApprovedSenior !== undefined && lenderApprovedJunior !== undefined && flcStats !== undefined;
|
|
5793
5823
|
React.useEffect(() => {
|
|
5794
5824
|
if (!step && poolInfo && lenderApproveStatusFetched) {
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5825
|
+
const items = [];
|
|
5826
|
+
if (lenderApprovedSenior) {
|
|
5827
|
+
items.push({
|
|
5828
|
+
label: 'Senior Tranche',
|
|
5829
|
+
value: 'senior',
|
|
5830
|
+
type: 'tranche'
|
|
5831
|
+
});
|
|
5799
5832
|
}
|
|
5800
|
-
if (
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5833
|
+
if (lenderApprovedJunior) {
|
|
5834
|
+
items.push({
|
|
5835
|
+
label: 'Junior Tranche',
|
|
5836
|
+
value: 'junior',
|
|
5837
|
+
type: 'tranche'
|
|
5838
|
+
});
|
|
5804
5839
|
}
|
|
5805
|
-
|
|
5840
|
+
flcStats.filter(flc => flc.isApproved).forEach(flc => {
|
|
5841
|
+
items.push({
|
|
5842
|
+
label: "".concat(shared.capitalizeFirstLetter(shared.FirstLossCoverIndex[flc.firstLossCoverIndex]), " First Loss Cover"),
|
|
5843
|
+
value: String(flc.firstLossCoverIndex),
|
|
5844
|
+
type: 'firstLossCover'
|
|
5845
|
+
});
|
|
5846
|
+
});
|
|
5847
|
+
if (items.length === 1) {
|
|
5848
|
+
setSelectedSupplyType(items[0]);
|
|
5849
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
5850
|
+
} else if (items.length > 1) {
|
|
5851
|
+
setSupplyTypes(items);
|
|
5806
5852
|
dispatch(setStep(WIDGET_STEP.ChooseTranche));
|
|
5807
|
-
|
|
5808
|
-
}
|
|
5809
|
-
if (poolInfo.KYC) {
|
|
5853
|
+
} else if (poolInfo.KYC) {
|
|
5810
5854
|
dispatch(setStep(WIDGET_STEP.Evaluation));
|
|
5811
|
-
|
|
5812
|
-
}
|
|
5813
|
-
if (poolInfo.supplyLink) {
|
|
5855
|
+
} else if (poolInfo.supplyLink) {
|
|
5814
5856
|
shared.openInNewTab(poolInfo.supplyLink);
|
|
5815
5857
|
}
|
|
5816
5858
|
}
|
|
5817
|
-
}, [dispatch, lenderApproveStatusFetched, lenderApprovedJunior, lenderApprovedSenior, poolInfo, step]);
|
|
5859
|
+
}, [dispatch, flcStats, lenderApproveStatusFetched, lenderApprovedJunior, lenderApprovedSenior, poolInfo, step]);
|
|
5818
5860
|
if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched) {
|
|
5819
5861
|
return jsxRuntime.jsx(WidgetWrapper, {
|
|
5820
5862
|
isOpen: true,
|
|
@@ -5829,24 +5871,26 @@ function LendSupplyV2(_ref) {
|
|
|
5829
5871
|
loadingTitle: "Supply ".concat(poolUnderlyingToken.symbol),
|
|
5830
5872
|
handleClose: handleClose,
|
|
5831
5873
|
handleSuccess: handleSuccess,
|
|
5832
|
-
children: [step === WIDGET_STEP.ChooseTranche && jsxRuntime.jsx(
|
|
5874
|
+
children: [step === WIDGET_STEP.ChooseTranche && jsxRuntime.jsx(ChooseSupplyType, {
|
|
5833
5875
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
5834
|
-
|
|
5835
|
-
|
|
5876
|
+
selectedSupplyType: selectedSupplyType,
|
|
5877
|
+
supplyTypes: supplyTypes,
|
|
5878
|
+
changeSupplyType: setSelectedSupplyType
|
|
5836
5879
|
}), step === WIDGET_STEP.Evaluation && jsxRuntime.jsx(Evaluation$1, {
|
|
5837
5880
|
poolInfo: poolInfo,
|
|
5838
5881
|
handleClose: handleClose
|
|
5839
|
-
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
5882
|
+
}), step === WIDGET_STEP.ChooseAmount && selectedSupplyType && jsxRuntime.jsx(ChooseAmount$5, {
|
|
5840
5883
|
poolInfo: poolInfo,
|
|
5841
5884
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
5842
|
-
|
|
5843
|
-
}), step === WIDGET_STEP.ApproveAllowance && jsxRuntime.jsx(ApproveAllowance$3, {
|
|
5885
|
+
selectedSupplyType: selectedSupplyType
|
|
5886
|
+
}), step === WIDGET_STEP.ApproveAllowance && selectedSupplyType && jsxRuntime.jsx(ApproveAllowance$3, {
|
|
5844
5887
|
poolInfo: poolInfo,
|
|
5845
|
-
poolUnderlyingToken: poolUnderlyingToken
|
|
5846
|
-
|
|
5888
|
+
poolUnderlyingToken: poolUnderlyingToken,
|
|
5889
|
+
selectedSupplyType: selectedSupplyType
|
|
5890
|
+
}), step === WIDGET_STEP.Transfer && selectedSupplyType && jsxRuntime.jsx(Transfer$5, {
|
|
5847
5891
|
poolInfo: poolInfo,
|
|
5848
5892
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
5849
|
-
|
|
5893
|
+
selectedSupplyType: selectedSupplyType
|
|
5850
5894
|
}), step === WIDGET_STEP.Done && jsxRuntime.jsx(Success$4, {
|
|
5851
5895
|
poolInfo: poolInfo,
|
|
5852
5896
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
@@ -5904,7 +5948,7 @@ function CheckWithdrawable(_ref) {
|
|
|
5904
5948
|
});
|
|
5905
5949
|
}
|
|
5906
5950
|
|
|
5907
|
-
function ChooseAmount$
|
|
5951
|
+
function ChooseAmount$4(_ref) {
|
|
5908
5952
|
let {
|
|
5909
5953
|
lenderPosition,
|
|
5910
5954
|
poolInfo
|
|
@@ -6048,7 +6092,7 @@ function LendWithdraw(_ref) {
|
|
|
6048
6092
|
children: [(!step || step === WIDGET_STEP.CheckWithdrawable) && jsxRuntime.jsx(CheckWithdrawable, {
|
|
6049
6093
|
poolInfo: poolInfo,
|
|
6050
6094
|
handleClose: handleClose
|
|
6051
|
-
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$
|
|
6095
|
+
}), step === WIDGET_STEP.ChooseAmount && jsxRuntime.jsx(ChooseAmount$4, {
|
|
6052
6096
|
poolInfo: poolInfo,
|
|
6053
6097
|
lenderPosition: lenderPosition
|
|
6054
6098
|
}), step === WIDGET_STEP.Transfer && jsxRuntime.jsx(Transfer$4, {
|
|
@@ -6067,73 +6111,35 @@ function LendWithdraw(_ref) {
|
|
|
6067
6111
|
|
|
6068
6112
|
var _templateObject$7, _templateObject2$5, _templateObject3$5;
|
|
6069
6113
|
function ChooseTranche(_ref) {
|
|
6070
|
-
var _seniorWithdrawableAm, _juniorWithdrawableAm;
|
|
6071
6114
|
let {
|
|
6072
|
-
poolInfo,
|
|
6073
6115
|
poolUnderlyingToken,
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
changeTranche
|
|
6116
|
+
selectedWithdrawType,
|
|
6117
|
+
withdrawTypes,
|
|
6118
|
+
changeWithdrawType
|
|
6078
6119
|
} = _ref;
|
|
6079
6120
|
const theme = material.useTheme();
|
|
6080
6121
|
const dispatch = useAppDispatch();
|
|
6081
6122
|
const {
|
|
6082
|
-
|
|
6083
|
-
} = core.useWeb3React();
|
|
6084
|
-
const {
|
|
6085
|
-
symbol,
|
|
6086
|
-
decimals
|
|
6123
|
+
symbol
|
|
6087
6124
|
} = poolUnderlyingToken;
|
|
6088
|
-
const [seniorWithdrawableShares, setSeniorWithdrawableShares] = React.useState(ethers.BigNumber.from(0));
|
|
6089
|
-
const [juniorWithdrawableShares, setJuniorWithdrawableShares] = React.useState(ethers.BigNumber.from(0));
|
|
6090
|
-
const isLoading = seniorWithdrawableAmount === undefined || juniorWithdrawableAmount === undefined;
|
|
6091
|
-
React.useEffect(() => {
|
|
6092
|
-
const fetchData = async () => {
|
|
6093
|
-
if (seniorWithdrawableAmount !== null && seniorWithdrawableAmount !== void 0 && seniorWithdrawableAmount.gt(0)) {
|
|
6094
|
-
const seniorVaultContract = await shared.getTrancheVaultContractV2(poolInfo.poolName, 'senior', provider);
|
|
6095
|
-
if (seniorVaultContract) {
|
|
6096
|
-
const shares = await seniorVaultContract.convertToShares(seniorWithdrawableAmount);
|
|
6097
|
-
setSeniorWithdrawableShares(shares);
|
|
6098
|
-
}
|
|
6099
|
-
}
|
|
6100
|
-
};
|
|
6101
|
-
fetchData();
|
|
6102
|
-
}, [poolInfo.poolName, provider, seniorWithdrawableAmount]);
|
|
6103
|
-
React.useEffect(() => {
|
|
6104
|
-
const fetchData = async () => {
|
|
6105
|
-
if (juniorWithdrawableAmount !== null && juniorWithdrawableAmount !== void 0 && juniorWithdrawableAmount.gt(0)) {
|
|
6106
|
-
const juniorVaultContract = await shared.getTrancheVaultContractV2(poolInfo.poolName, 'senior', provider);
|
|
6107
|
-
if (juniorVaultContract) {
|
|
6108
|
-
const shares = await juniorVaultContract.convertToShares(juniorWithdrawableAmount);
|
|
6109
|
-
setJuniorWithdrawableShares(shares);
|
|
6110
|
-
}
|
|
6111
|
-
}
|
|
6112
|
-
};
|
|
6113
|
-
fetchData();
|
|
6114
|
-
}, [poolInfo.poolName, provider, juniorWithdrawableAmount]);
|
|
6115
6125
|
const styles = {
|
|
6116
6126
|
subTitle: material.css(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteral(["\n color: ", " !important;\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n line-height: 150%;\n letter-spacing: 0.15px;\n margin-top: ", ";\n margin-left: ", ";\n "])), theme.palette.text.primary, theme.spacing(5), theme.spacing(2)),
|
|
6117
6127
|
radioGroup: material.css(_templateObject2$5 || (_templateObject2$5 = _taggedTemplateLiteral(["\n margin-left: ", ";\n margin-top: ", ";\n "])), theme.spacing(3), theme.spacing(3)),
|
|
6118
6128
|
formControl: material.css(_templateObject3$5 || (_templateObject3$5 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n\n .MuiFormControlLabel-label {\n color: ", ";\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n line-height: 150%;\n letter-spacing: 0.15px;\n }\n "])), theme.spacing(1), theme.palette.text.primary)
|
|
6119
6129
|
};
|
|
6130
|
+
const handleChangeWithdrawType = withdrawTypeValue => {
|
|
6131
|
+
const withdrawType = withdrawTypes.find(item => item.value === withdrawTypeValue);
|
|
6132
|
+
if (withdrawType) {
|
|
6133
|
+
changeWithdrawType(withdrawType);
|
|
6134
|
+
}
|
|
6135
|
+
};
|
|
6120
6136
|
const handleNext = () => {
|
|
6121
|
-
|
|
6137
|
+
if ((selectedWithdrawType === null || selectedWithdrawType === void 0 ? void 0 : selectedWithdrawType.type) === 'firstLossCover') {
|
|
6138
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount));
|
|
6139
|
+
} else {
|
|
6140
|
+
dispatch(setStep(WIDGET_STEP.Transfer));
|
|
6141
|
+
}
|
|
6122
6142
|
};
|
|
6123
|
-
const items = [{
|
|
6124
|
-
label: "Withdraw ".concat(shared.formatBNFixed(seniorWithdrawableAmount, decimals), " ").concat(symbol, " from Senior vault (").concat(shared.formatBNFixed(seniorWithdrawableShares, decimals), " shares)"),
|
|
6125
|
-
value: 'senior',
|
|
6126
|
-
disabled: (_seniorWithdrawableAm = seniorWithdrawableAmount === null || seniorWithdrawableAmount === void 0 ? void 0 : seniorWithdrawableAmount.lte(0)) !== null && _seniorWithdrawableAm !== void 0 ? _seniorWithdrawableAm : true
|
|
6127
|
-
}, {
|
|
6128
|
-
label: "Withdraw ".concat(shared.formatBNFixed(juniorWithdrawableAmount, decimals), " ").concat(symbol, " from Junior vault (").concat(shared.formatBNFixed(juniorWithdrawableShares, decimals), " shares)"),
|
|
6129
|
-
value: 'junior',
|
|
6130
|
-
disabled: (_juniorWithdrawableAm = juniorWithdrawableAmount === null || juniorWithdrawableAmount === void 0 ? void 0 : juniorWithdrawableAmount.lte(0)) !== null && _juniorWithdrawableAm !== void 0 ? _juniorWithdrawableAm : true
|
|
6131
|
-
}];
|
|
6132
|
-
if (isLoading) {
|
|
6133
|
-
return jsxRuntime.jsx(LoadingModal, {
|
|
6134
|
-
title: "Withdraw ".concat(symbol)
|
|
6135
|
-
});
|
|
6136
|
-
}
|
|
6137
6143
|
return jsxRuntime.jsxs(WrapperModal, {
|
|
6138
6144
|
title: "Withdraw ".concat(symbol),
|
|
6139
6145
|
children: [jsxRuntime.jsxs(material.FormControl, {
|
|
@@ -6144,10 +6150,9 @@ function ChooseTranche(_ref) {
|
|
|
6144
6150
|
"aria-labelledby": "buttons-group-label",
|
|
6145
6151
|
name: "radio-buttons-group",
|
|
6146
6152
|
css: styles.radioGroup,
|
|
6147
|
-
onChange: e =>
|
|
6148
|
-
children:
|
|
6153
|
+
onChange: e => handleChangeWithdrawType(e.target.value),
|
|
6154
|
+
children: withdrawTypes.map(item => jsxRuntime.jsx(material.FormControlLabel, {
|
|
6149
6155
|
value: item.value,
|
|
6150
|
-
disabled: item.disabled,
|
|
6151
6156
|
control: jsxRuntime.jsx(material.Radio, {
|
|
6152
6157
|
sx: {
|
|
6153
6158
|
'& .MuiSvgIcon-root': {
|
|
@@ -6161,34 +6166,116 @@ function ChooseTranche(_ref) {
|
|
|
6161
6166
|
})]
|
|
6162
6167
|
}), jsxRuntime.jsx(BottomButton, {
|
|
6163
6168
|
variant: "contained",
|
|
6164
|
-
disabled: !
|
|
6169
|
+
disabled: !selectedWithdrawType,
|
|
6165
6170
|
onClick: handleNext,
|
|
6166
6171
|
children: "NEXT"
|
|
6167
6172
|
})]
|
|
6168
6173
|
});
|
|
6169
6174
|
}
|
|
6170
6175
|
|
|
6176
|
+
function ChooseAmount$3(_ref) {
|
|
6177
|
+
let {
|
|
6178
|
+
poolInfo,
|
|
6179
|
+
poolUnderlyingToken,
|
|
6180
|
+
selectedWithdrawType
|
|
6181
|
+
} = _ref;
|
|
6182
|
+
const dispatch = useAppDispatch();
|
|
6183
|
+
const {
|
|
6184
|
+
provider
|
|
6185
|
+
} = core.useWeb3React();
|
|
6186
|
+
const {
|
|
6187
|
+
symbol
|
|
6188
|
+
} = poolUnderlyingToken;
|
|
6189
|
+
const [sharePrice, setSharePrice] = React.useState(0);
|
|
6190
|
+
const [currentAmount, setCurrentAmount] = React.useState(0);
|
|
6191
|
+
const [currentShares, setCurrentShares] = React.useState(0);
|
|
6192
|
+
const maxAmountFormatted = ethers.ethers.utils.formatUnits(selectedWithdrawType.withdrawableAmount, poolUnderlyingToken.decimals);
|
|
6193
|
+
React.useEffect(() => {
|
|
6194
|
+
if (selectedWithdrawType.withdrawableAmount.gt(0)) {
|
|
6195
|
+
const fetchData = async () => {
|
|
6196
|
+
const firstLossCoverContract = await shared.getFirstLossCoverContractV2(poolInfo.poolName, Number(selectedWithdrawType.value), provider);
|
|
6197
|
+
if (firstLossCoverContract) {
|
|
6198
|
+
const shares = await firstLossCoverContract.convertToShares(selectedWithdrawType.withdrawableAmount);
|
|
6199
|
+
const price = selectedWithdrawType.withdrawableAmount.div(shares);
|
|
6200
|
+
setSharePrice(price.toNumber());
|
|
6201
|
+
}
|
|
6202
|
+
};
|
|
6203
|
+
fetchData();
|
|
6204
|
+
}
|
|
6205
|
+
}, [poolInfo.poolName, provider, selectedWithdrawType.value, selectedWithdrawType.withdrawableAmount]);
|
|
6206
|
+
const handleChangeAmount = newAmount => {
|
|
6207
|
+
const shares = Number(newAmount) / sharePrice;
|
|
6208
|
+
setCurrentShares(shares);
|
|
6209
|
+
setCurrentAmount(newAmount);
|
|
6210
|
+
dispatch(setWithdrawAmount(Number(newAmount)));
|
|
6211
|
+
};
|
|
6212
|
+
const handleAction = () => {
|
|
6213
|
+
dispatch(setStep(WIDGET_STEP.Transfer));
|
|
6214
|
+
};
|
|
6215
|
+
return jsxRuntime.jsx(InputAmountModal, {
|
|
6216
|
+
title: "Withdraw ".concat(symbol),
|
|
6217
|
+
subTitle: selectedWithdrawType.label,
|
|
6218
|
+
tokenSymbol: symbol,
|
|
6219
|
+
currentAmount: currentAmount,
|
|
6220
|
+
handleChangeAmount: handleChangeAmount,
|
|
6221
|
+
maxAmount: maxAmountFormatted,
|
|
6222
|
+
info: "".concat(currentShares.toFixed(1), " Shares"),
|
|
6223
|
+
handleAction: handleAction,
|
|
6224
|
+
actionText: "WITHDRAW"
|
|
6225
|
+
});
|
|
6226
|
+
}
|
|
6227
|
+
|
|
6171
6228
|
function Transfer$3(_ref) {
|
|
6172
6229
|
let {
|
|
6173
6230
|
poolInfo,
|
|
6174
|
-
|
|
6231
|
+
poolUnderlyingToken,
|
|
6232
|
+
selectedWithdrawType
|
|
6175
6233
|
} = _ref;
|
|
6176
6234
|
const dispatch = useAppDispatch();
|
|
6177
6235
|
const {
|
|
6178
6236
|
account,
|
|
6179
6237
|
provider
|
|
6180
6238
|
} = core.useWeb3React();
|
|
6181
|
-
const
|
|
6239
|
+
const {
|
|
6240
|
+
withdrawAmount
|
|
6241
|
+
} = useAppSelector(selectWidgetState);
|
|
6242
|
+
const [firstLossCoverShares, setFirstLossCoverShares] = React__default["default"].useState(undefined);
|
|
6243
|
+
const [contract, setContract] = React.useState(undefined);
|
|
6244
|
+
React.useEffect(() => {
|
|
6245
|
+
const fetchData = async () => {
|
|
6246
|
+
if (account) {
|
|
6247
|
+
if (selectedWithdrawType.type === 'tranche') {
|
|
6248
|
+
const trancheVaultContract = await shared.getTrancheVaultContractV2(poolInfo.poolName, selectedWithdrawType.value, provider, account);
|
|
6249
|
+
if (trancheVaultContract) {
|
|
6250
|
+
setContract(trancheVaultContract);
|
|
6251
|
+
}
|
|
6252
|
+
}
|
|
6253
|
+
if (selectedWithdrawType.type === 'firstLossCover') {
|
|
6254
|
+
const firstLossCoverContract = await shared.getFirstLossCoverContractV2(poolInfo.poolName, Number(selectedWithdrawType.value), provider, account);
|
|
6255
|
+
if (firstLossCoverContract) {
|
|
6256
|
+
const shares = await firstLossCoverContract.convertToShares(ethers.ethers.utils.parseUnits(String(withdrawAmount), poolUnderlyingToken.decimals));
|
|
6257
|
+
setFirstLossCoverShares(shares);
|
|
6258
|
+
setContract(firstLossCoverContract);
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
};
|
|
6263
|
+
fetchData();
|
|
6264
|
+
}, [account, poolInfo.poolName, poolUnderlyingToken.decimals, provider, selectedWithdrawType.type, selectedWithdrawType.value, withdrawAmount]);
|
|
6265
|
+
const method = selectedWithdrawType.type === 'tranche' ? 'disburse' : 'redeemCover';
|
|
6266
|
+
const params = selectedWithdrawType.type === 'tranche' ? [] : [firstLossCoverShares, account];
|
|
6182
6267
|
const handleSuccess = React.useCallback(() => {
|
|
6183
6268
|
dispatch(setStep(WIDGET_STEP.Done));
|
|
6184
6269
|
}, [dispatch]);
|
|
6185
|
-
if (!
|
|
6186
|
-
return
|
|
6270
|
+
if (!account || !contract) {
|
|
6271
|
+
return jsxRuntime.jsx(LoadingModal, {
|
|
6272
|
+
title: "Transaction Pending"
|
|
6273
|
+
});
|
|
6187
6274
|
}
|
|
6188
6275
|
return jsxRuntime.jsx(TxSendModalV2, {
|
|
6189
|
-
contract:
|
|
6190
|
-
method:
|
|
6191
|
-
params:
|
|
6276
|
+
contract: contract,
|
|
6277
|
+
method: method,
|
|
6278
|
+
params: params,
|
|
6192
6279
|
handleSuccess: handleSuccess
|
|
6193
6280
|
});
|
|
6194
6281
|
}
|
|
@@ -6228,33 +6315,66 @@ function LendWithdrawV2(_ref) {
|
|
|
6228
6315
|
step,
|
|
6229
6316
|
errorMessage
|
|
6230
6317
|
} = useAppSelector(selectWidgetState);
|
|
6231
|
-
const [
|
|
6232
|
-
const [
|
|
6318
|
+
const [withdrawTypes, setWithdrawTypes] = React.useState([]);
|
|
6319
|
+
const [selectedWithdrawType, setSelectedWithdrawType] = React.useState();
|
|
6320
|
+
const [seniorWithdrawableAmount, refreshSeniorWithdrawableAmount] = shared.useTrancheWithdrawableAssetsV2(poolName, 'senior', account, provider);
|
|
6321
|
+
const [juniorWithdrawableAmount, refreshJuniorWithdrawableAmount] = shared.useTrancheWithdrawableAssetsV2(poolName, 'junior', account, provider);
|
|
6322
|
+
const isReadyForFlcWithdrawal = shared.usePoolIsReadyForFlcWithdrawalV2(poolName, provider);
|
|
6323
|
+
const [flcStats, refreshFlcStats] = shared.useFirstLossCoverStatsV2(poolName, account, provider);
|
|
6233
6324
|
const poolUnderlyingToken = shared.usePoolUnderlyingTokenInfoV2(poolName, provider);
|
|
6234
|
-
const
|
|
6235
|
-
|
|
6325
|
+
const {
|
|
6326
|
+
symbol,
|
|
6327
|
+
decimals
|
|
6328
|
+
} = poolUnderlyingToken || {};
|
|
6329
|
+
const isLoading = !poolInfo || !poolUnderlyingToken || isReadyForFlcWithdrawal === undefined || !seniorWithdrawableAmount || !juniorWithdrawableAmount || !flcStats;
|
|
6236
6330
|
React.useEffect(() => {
|
|
6237
|
-
if (!step) {
|
|
6238
|
-
|
|
6331
|
+
if (!step && !isLoading) {
|
|
6332
|
+
const items = [];
|
|
6333
|
+
if (seniorWithdrawableAmount.gt(0)) {
|
|
6334
|
+
items.push({
|
|
6335
|
+
label: "Withdraw ".concat(shared.formatBNFixed(seniorWithdrawableAmount, decimals), " ").concat(symbol, " from Senior Tranche"),
|
|
6336
|
+
value: 'senior',
|
|
6337
|
+
type: 'tranche',
|
|
6338
|
+
withdrawableAmount: seniorWithdrawableAmount
|
|
6339
|
+
});
|
|
6340
|
+
}
|
|
6341
|
+
if (juniorWithdrawableAmount.gt(0)) {
|
|
6342
|
+
items.push({
|
|
6343
|
+
label: "Withdraw ".concat(shared.formatBNFixed(juniorWithdrawableAmount, decimals), " ").concat(symbol, " from Junior Tranche"),
|
|
6344
|
+
value: 'junior',
|
|
6345
|
+
type: 'tranche',
|
|
6346
|
+
withdrawableAmount: juniorWithdrawableAmount
|
|
6347
|
+
});
|
|
6348
|
+
}
|
|
6349
|
+
if (isReadyForFlcWithdrawal) {
|
|
6350
|
+
flcStats.filter(flc => flc.totalAssets.gt(0)).forEach(flc => {
|
|
6351
|
+
items.push({
|
|
6352
|
+
label: "Withdraw ".concat(symbol, " from ").concat(shared.capitalizeFirstLetter(shared.FirstLossCoverIndex[flc.firstLossCoverIndex]), " First Loss Cover"),
|
|
6353
|
+
value: String(flc.firstLossCoverIndex),
|
|
6354
|
+
type: 'firstLossCover',
|
|
6355
|
+
withdrawableAmount: flc.totalAssets
|
|
6356
|
+
});
|
|
6357
|
+
});
|
|
6358
|
+
}
|
|
6359
|
+
setWithdrawTypes(items);
|
|
6360
|
+
if (items.length === 1) {
|
|
6361
|
+
setSelectedWithdrawType(items[0]);
|
|
6362
|
+
const step = items[0].type === 'firstLossCover' ? WIDGET_STEP.ChooseAmount : WIDGET_STEP.Transfer;
|
|
6363
|
+
dispatch(setStep(step));
|
|
6364
|
+
} else if (items.length > 1) {
|
|
6365
|
+
dispatch(setStep(WIDGET_STEP.ChooseTranche));
|
|
6366
|
+
}
|
|
6239
6367
|
}
|
|
6240
|
-
}, [dispatch, step]);
|
|
6368
|
+
}, [decimals, dispatch, flcStats, isLoading, isReadyForFlcWithdrawal, juniorWithdrawableAmount, seniorWithdrawableAmount, step, symbol]);
|
|
6241
6369
|
const handleWithdrawSuccess = React.useCallback(blockNumber => {
|
|
6242
6370
|
refreshSeniorWithdrawableAmount();
|
|
6243
6371
|
refreshJuniorWithdrawableAmount();
|
|
6372
|
+
refreshFlcStats();
|
|
6244
6373
|
if (handleSuccess) {
|
|
6245
6374
|
handleSuccess(blockNumber);
|
|
6246
6375
|
}
|
|
6247
|
-
}, [handleSuccess, refreshJuniorWithdrawableAmount, refreshSeniorWithdrawableAmount]);
|
|
6248
|
-
|
|
6249
|
-
setSelectedTranche(tranche);
|
|
6250
|
-
if (tranche === 'senior') {
|
|
6251
|
-
setWithdrawAmount(seniorWithdrawableAmount);
|
|
6252
|
-
}
|
|
6253
|
-
if (tranche === 'junior') {
|
|
6254
|
-
setWithdrawAmount(juniorWithdrawableAmount);
|
|
6255
|
-
}
|
|
6256
|
-
}, [juniorWithdrawableAmount, seniorWithdrawableAmount]);
|
|
6257
|
-
if (!poolInfo || !poolUnderlyingToken) {
|
|
6376
|
+
}, [handleSuccess, refreshFlcStats, refreshJuniorWithdrawableAmount, refreshSeniorWithdrawableAmount]);
|
|
6377
|
+
if (isLoading) {
|
|
6258
6378
|
return null;
|
|
6259
6379
|
}
|
|
6260
6380
|
return jsxRuntime.jsxs(WidgetWrapper, {
|
|
@@ -6263,18 +6383,21 @@ function LendWithdrawV2(_ref) {
|
|
|
6263
6383
|
handleClose: handleClose,
|
|
6264
6384
|
handleSuccess: handleWithdrawSuccess,
|
|
6265
6385
|
children: [step === WIDGET_STEP.ChooseTranche && jsxRuntime.jsx(ChooseTranche, {
|
|
6386
|
+
poolUnderlyingToken: poolUnderlyingToken,
|
|
6387
|
+
selectedWithdrawType: selectedWithdrawType,
|
|
6388
|
+
withdrawTypes: withdrawTypes,
|
|
6389
|
+
changeWithdrawType: setSelectedWithdrawType
|
|
6390
|
+
}), step === WIDGET_STEP.ChooseAmount && selectedWithdrawType && jsxRuntime.jsx(ChooseAmount$3, {
|
|
6266
6391
|
poolInfo: poolInfo,
|
|
6267
6392
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
seniorWithdrawableAmount: seniorWithdrawableAmount,
|
|
6271
|
-
juniorWithdrawableAmount: juniorWithdrawableAmount
|
|
6272
|
-
}), step === WIDGET_STEP.Transfer && selectedTranche && jsxRuntime.jsx(Transfer$3, {
|
|
6393
|
+
selectedWithdrawType: selectedWithdrawType
|
|
6394
|
+
}), step === WIDGET_STEP.Transfer && selectedWithdrawType && jsxRuntime.jsx(Transfer$3, {
|
|
6273
6395
|
poolInfo: poolInfo,
|
|
6274
|
-
selectedTranche: selectedTranche
|
|
6275
|
-
}), step === WIDGET_STEP.Done && withdrawAmount && jsxRuntime.jsx(Done, {
|
|
6276
6396
|
poolUnderlyingToken: poolUnderlyingToken,
|
|
6277
|
-
|
|
6397
|
+
selectedWithdrawType: selectedWithdrawType
|
|
6398
|
+
}), step === WIDGET_STEP.Done && selectedWithdrawType && jsxRuntime.jsx(Done, {
|
|
6399
|
+
poolUnderlyingToken: poolUnderlyingToken,
|
|
6400
|
+
withdrawAmount: selectedWithdrawType.withdrawableAmount,
|
|
6278
6401
|
handleAction: handleClose
|
|
6279
6402
|
}), step === WIDGET_STEP.Error && jsxRuntime.jsx(ErrorModal, {
|
|
6280
6403
|
title: "Withdraw",
|