@huma-finance/widgets 0.0.62-beta.611 → 0.0.62-beta.617
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 +29 -3
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/src/components/Lend/solanaSupply/4-Transfer.tsx +51 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
2
|
-
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, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useTrancheVaultAssetsV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, useFactoring,
|
|
2
|
+
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, usePoolUnderlyingTokenBalanceV2, useLenderApprovedV2, useTrancheVaultAssetsV2, useLastDepositTime, usePoolBalance, useReceivableInfoV2, useReceivableContractV2, useERC2612Permit, useMultiSendContract, usePoolUnderlyingToken, useFactoring, useLenderAccounts, useHumaProgram, useTokenAccount, useTrancheMintAccounts, useTrancheTokenAccounts, useBorrowerAccounts, usePoolUnderlyingTokenAccount, Provider as Provider$1 } from '@huma-finance/web-shared';
|
|
3
3
|
import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input, Divider, TextField, FormControl, FormLabel, RadioGroup, FormControlLabel, Radio, Snackbar, Alert, Link, 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';
|
|
@@ -9463,21 +9463,41 @@ function Transfer$2(_ref) {
|
|
|
9463
9463
|
} = poolInfo.underlyingMint;
|
|
9464
9464
|
const supplyBigNumber = SolanaTokenUtils.parseUnits(String(supplyAmount), decimals);
|
|
9465
9465
|
const [transaction, setTransaction] = useState();
|
|
9466
|
+
const {
|
|
9467
|
+
juniorLenderApprovedAccountPDA,
|
|
9468
|
+
seniorLenderApprovedAccountPDA,
|
|
9469
|
+
seniorLenderStateAccount,
|
|
9470
|
+
juniorLenderStateAccount,
|
|
9471
|
+
loading: isLoadingLenderAccounts
|
|
9472
|
+
} = useLenderAccounts(poolInfo.chainId, poolInfo.poolName);
|
|
9466
9473
|
const program = useHumaProgram(poolInfo.chainId);
|
|
9467
9474
|
const handleSuccess = useCallback(() => {
|
|
9468
9475
|
dispatch(setStep(WIDGET_STEP.Done));
|
|
9469
9476
|
}, [dispatch]);
|
|
9470
9477
|
useEffect(() => {
|
|
9471
9478
|
async function getTx() {
|
|
9472
|
-
if (!publicKey || transaction) {
|
|
9479
|
+
if (!publicKey || transaction || isLoadingLenderAccounts) {
|
|
9473
9480
|
return;
|
|
9474
9481
|
}
|
|
9482
|
+
const tx = new Transaction();
|
|
9475
9483
|
const {
|
|
9476
9484
|
underlyingTokenATA,
|
|
9477
9485
|
seniorTrancheATA,
|
|
9478
9486
|
juniorTrancheATA
|
|
9479
9487
|
} = getTokenAccounts(poolInfo, publicKey);
|
|
9480
|
-
|
|
9488
|
+
if (selectedTranche === 'senior' && !seniorLenderStateAccount || selectedTranche === 'junior' && !juniorLenderStateAccount) {
|
|
9489
|
+
const createLenderAccountsTx = await program.methods.createLenderAccounts().accountsPartial({
|
|
9490
|
+
lender: publicKey,
|
|
9491
|
+
humaConfig: poolInfo.humaConfig,
|
|
9492
|
+
poolConfig: poolInfo.poolConfig,
|
|
9493
|
+
approvedLender: selectedTranche === 'senior' ? seniorLenderApprovedAccountPDA : juniorLenderApprovedAccountPDA,
|
|
9494
|
+
trancheMint: selectedTranche === 'senior' ? poolInfo.seniorTrancheMint : poolInfo.juniorTrancheMint,
|
|
9495
|
+
lenderTrancheToken: selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA,
|
|
9496
|
+
tokenProgram: TOKEN_2022_PROGRAM_ID
|
|
9497
|
+
}).transaction();
|
|
9498
|
+
tx.add(createLenderAccountsTx);
|
|
9499
|
+
}
|
|
9500
|
+
const depositTx = await program.methods.deposit(supplyBigNumber).accountsPartial({
|
|
9481
9501
|
depositor: publicKey,
|
|
9482
9502
|
poolConfig: poolInfo.poolConfig,
|
|
9483
9503
|
underlyingMint: poolInfo.underlyingMint.address,
|
|
@@ -9488,10 +9508,16 @@ function Transfer$2(_ref) {
|
|
|
9488
9508
|
humaConfig: poolInfo.humaConfig,
|
|
9489
9509
|
tokenProgram: TOKEN_2022_PROGRAM_ID
|
|
9490
9510
|
}).transaction();
|
|
9511
|
+
tx.add(depositTx);
|
|
9491
9512
|
setTransaction(tx);
|
|
9492
9513
|
}
|
|
9493
9514
|
getTx();
|
|
9494
|
-
}, [poolInfo, program.methods, publicKey, selectedTranche, supplyBigNumber, transaction]);
|
|
9515
|
+
}, [isLoadingLenderAccounts, juniorLenderApprovedAccountPDA, juniorLenderStateAccount, poolInfo, program.methods, publicKey, selectedTranche, seniorLenderApprovedAccountPDA, seniorLenderStateAccount, supplyBigNumber, transaction]);
|
|
9516
|
+
if (isLoadingLenderAccounts) {
|
|
9517
|
+
return jsx(LoadingModal, {
|
|
9518
|
+
title: "Supply"
|
|
9519
|
+
});
|
|
9520
|
+
}
|
|
9495
9521
|
return jsx(SolanaTxSendModal, {
|
|
9496
9522
|
tx: transaction,
|
|
9497
9523
|
chainId: poolInfo.chainId,
|