@huma-finance/widgets 0.0.62-beta.633 → 0.0.62-beta.635

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.
Files changed (43) hide show
  1. package/API.md +195 -0
  2. package/dist/cjs/index.cjs +1871 -299
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/index.d.ts +138 -2
  5. package/dist/index.js +1869 -302
  6. package/dist/index.js.map +1 -1
  7. package/package.json +18 -8
  8. package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +1 -0
  9. package/src/components/CreditLine/solanaBorrow/1-ChooseAmount.tsx +67 -0
  10. package/src/components/CreditLine/solanaBorrow/2-Transfer.tsx +159 -0
  11. package/src/components/CreditLine/solanaBorrow/3-Done.tsx +38 -0
  12. package/src/components/CreditLine/solanaBorrow/index.tsx +93 -0
  13. package/src/components/CreditLine/solanaPayment/1-ChooseAmount.tsx +75 -0
  14. package/src/components/CreditLine/solanaPayment/2-Transfer.tsx +92 -0
  15. package/src/components/CreditLine/solanaPayment/3-Done.tsx +60 -0
  16. package/src/components/CreditLine/solanaPayment/index.tsx +86 -0
  17. package/src/components/InputAmountModal.tsx +13 -2
  18. package/src/components/Lend/{supplyV2/components → components}/PersonaEvaluation.tsx +19 -13
  19. package/src/components/Lend/{supplyV2/components → components}/SecuritizeEvaluation.tsx +7 -8
  20. package/src/components/Lend/solanaAddRedemption/1-ChooseTranche.tsx +114 -0
  21. package/src/components/Lend/solanaAddRedemption/2-ChooseAmount.tsx +183 -0
  22. package/src/components/Lend/solanaAddRedemption/3-Transfer.tsx +102 -0
  23. package/src/components/Lend/solanaAddRedemption/4-Done.tsx +29 -0
  24. package/src/components/Lend/solanaAddRedemption/index.tsx +155 -0
  25. package/src/components/Lend/solanaCancelRedemption/1-ChooseTranche.tsx +114 -0
  26. package/src/components/Lend/solanaCancelRedemption/2-Transfer.tsx +99 -0
  27. package/src/components/Lend/solanaCancelRedemption/3-Done.tsx +55 -0
  28. package/src/components/Lend/solanaCancelRedemption/index.tsx +162 -0
  29. package/src/components/Lend/solanaSupply/1-Evaluation.tsx +43 -0
  30. package/src/components/Lend/solanaSupply/2-ChooseTranche.tsx +116 -0
  31. package/src/components/Lend/solanaSupply/3-ChooseAmount.tsx +131 -0
  32. package/src/components/Lend/solanaSupply/4-Transfer.tsx +137 -0
  33. package/src/components/Lend/solanaSupply/5-Success.tsx +52 -0
  34. package/src/components/Lend/solanaSupply/index.tsx +155 -0
  35. package/src/components/Lend/supplyV2/2-Evaluation.tsx +4 -3
  36. package/src/components/Lend/supplyV2/6-Success.tsx +3 -3
  37. package/src/components/SolanaTxDoneModal.tsx +119 -0
  38. package/src/components/SolanaTxSendModal.tsx +61 -0
  39. package/src/components/SolanaViewOnExplorer.tsx +29 -0
  40. package/src/components/WidgetWrapper.tsx +6 -4
  41. package/src/index.tsx +139 -0
  42. package/src/store/widgets.reducers.ts +5 -0
  43. package/src/store/widgets.store.ts +1 -0
@@ -0,0 +1,116 @@
1
+ import { TrancheType, UnderlyingTokenInfo } from '@huma-finance/shared'
2
+ import {
3
+ css,
4
+ FormControl,
5
+ FormControlLabel,
6
+ FormLabel,
7
+ Radio,
8
+ RadioGroup,
9
+ useTheme,
10
+ } from '@mui/material'
11
+ import React from 'react'
12
+
13
+ import { useAppDispatch } from '../../../hooks/useRedux'
14
+ import { setStep } from '../../../store/widgets.reducers'
15
+ import { WIDGET_STEP } from '../../../store/widgets.store'
16
+ import { BottomButton } from '../../BottomButton'
17
+ import { WrapperModal } from '../../WrapperModal'
18
+
19
+ type Props = {
20
+ poolUnderlyingToken: UnderlyingTokenInfo
21
+ selectedTranche: TrancheType | undefined
22
+ changeTranche: (tranche: TrancheType) => void
23
+ }
24
+
25
+ export function ChooseTranche({
26
+ poolUnderlyingToken,
27
+ selectedTranche,
28
+ changeTranche,
29
+ }: Props): React.ReactElement | null {
30
+ const theme = useTheme()
31
+ const dispatch = useAppDispatch()
32
+
33
+ const styles = {
34
+ subTitle: css`
35
+ color: ${theme.palette.text.primary} !important;
36
+ font-weight: 400;
37
+ font-size: 16px;
38
+ line-height: 150%;
39
+ letter-spacing: 0.15px;
40
+ margin-top: ${theme.spacing(5)};
41
+ margin-left: ${theme.spacing(2)};
42
+ `,
43
+ radioGroup: css`
44
+ margin-left: ${theme.spacing(3)};
45
+ margin-top: ${theme.spacing(3)};
46
+ `,
47
+ formControl: css`
48
+ margin-bottom: ${theme.spacing(1)};
49
+
50
+ .MuiFormControlLabel-label {
51
+ color: ${theme.palette.text.primary};
52
+ font-weight: 400;
53
+ font-size: 16px;
54
+ line-height: 150%;
55
+ letter-spacing: 0.15px;
56
+ }
57
+ `,
58
+ }
59
+
60
+ const handleNext = () => {
61
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
62
+ }
63
+
64
+ const items: {
65
+ label: string
66
+ value: TrancheType
67
+ }[] = [
68
+ {
69
+ label: 'Senior',
70
+ value: 'senior',
71
+ },
72
+ {
73
+ label: 'Junior',
74
+ value: 'junior',
75
+ },
76
+ ]
77
+
78
+ return (
79
+ <WrapperModal title={`Supply ${poolUnderlyingToken.symbol}`}>
80
+ <FormControl>
81
+ <FormLabel css={styles.subTitle}>Select Tranche Type</FormLabel>
82
+ <RadioGroup
83
+ aria-labelledby='buttons-group-label'
84
+ name='radio-buttons-group'
85
+ css={styles.radioGroup}
86
+ onChange={(e) => changeTranche(e.target.value as TrancheType)}
87
+ >
88
+ {items.map((item) => (
89
+ <FormControlLabel
90
+ key={item.label}
91
+ value={item.value}
92
+ control={
93
+ <Radio
94
+ sx={{
95
+ '& .MuiSvgIcon-root': {
96
+ fontSize: 24,
97
+ },
98
+ }}
99
+ />
100
+ }
101
+ label={item.label}
102
+ css={styles.formControl}
103
+ />
104
+ ))}
105
+ </RadioGroup>
106
+ </FormControl>
107
+ <BottomButton
108
+ variant='contained'
109
+ disabled={!selectedTranche}
110
+ onClick={handleNext}
111
+ >
112
+ NEXT
113
+ </BottomButton>
114
+ </WrapperModal>
115
+ )
116
+ }
@@ -0,0 +1,131 @@
1
+ import {
2
+ formatNumber,
3
+ SolanaPoolInfo,
4
+ SolanaTokenUtils,
5
+ TrancheType,
6
+ } from '@huma-finance/shared'
7
+ import { SolanaPoolState } from '@huma-finance/web-shared'
8
+ import React, { useMemo, useState } from 'react'
9
+ import { BN } from '@coral-xyz/anchor'
10
+ import { Account } from '@solana/spl-token'
11
+ import { useAppDispatch } from '../../../hooks/useRedux'
12
+ import { setStep, setSupplyAmount } from '../../../store/widgets.reducers'
13
+ import { WIDGET_STEP } from '../../../store/widgets.store'
14
+ import { InputAmountModal } from '../../InputAmountModal'
15
+
16
+ type Props = {
17
+ poolInfo: SolanaPoolInfo
18
+ poolState: SolanaPoolState
19
+ tokenAccount?: Account
20
+ selectedTranche: TrancheType | undefined
21
+ isUniTranche?: boolean
22
+ }
23
+
24
+ export function ChooseAmount({
25
+ poolInfo,
26
+ poolState,
27
+ tokenAccount,
28
+ selectedTranche,
29
+ isUniTranche,
30
+ }: Props): React.ReactElement | null {
31
+ const dispatch = useAppDispatch()
32
+ const { symbol, decimals } = poolInfo.underlyingMint
33
+ const [currentAmount, setCurrentAmount] = useState<number | string>(0)
34
+ const balance = tokenAccount
35
+ ? new BN(tokenAccount.amount.toString())
36
+ : new BN(0)
37
+
38
+ const { juniorAvailableCapBN, seniorAvailableCapBN } = useMemo(() => {
39
+ const {
40
+ maxSeniorJuniorRatio,
41
+ liquidityCap,
42
+ seniorTrancheAssets,
43
+ juniorTrancheAssets,
44
+ } = poolState
45
+ const juniorTrancheAssetsBN = new BN(juniorTrancheAssets ?? 0)
46
+ const seniorTrancheAssetsBN = new BN(seniorTrancheAssets ?? 0)
47
+ const totalDeployedBN = seniorTrancheAssetsBN.add(juniorTrancheAssetsBN)
48
+ const totalAvailableCapBN = new BN(liquidityCap ?? 0).sub(totalDeployedBN)
49
+ const maxSeniorAssetsBN = juniorTrancheAssetsBN.muln(
50
+ maxSeniorJuniorRatio ?? 0,
51
+ )
52
+ let seniorAvailableCapBN = maxSeniorAssetsBN.sub(seniorTrancheAssetsBN)
53
+ seniorAvailableCapBN = seniorAvailableCapBN.gt(totalAvailableCapBN)
54
+ ? totalAvailableCapBN
55
+ : seniorAvailableCapBN
56
+
57
+ return {
58
+ juniorAvailableCapBN: totalAvailableCapBN.sub(seniorAvailableCapBN),
59
+ seniorAvailableCapBN,
60
+ }
61
+ }, [poolState])
62
+
63
+ const handleChangeAmount = (newAmount: number) => {
64
+ setCurrentAmount(newAmount)
65
+ dispatch(setSupplyAmount(Number(newAmount)))
66
+ }
67
+
68
+ const handleAction = () => {
69
+ dispatch(setStep(WIDGET_STEP.Transfer))
70
+ }
71
+
72
+ const getTrancheCap = () => {
73
+ if (selectedTranche === 'junior') {
74
+ return juniorAvailableCapBN
75
+ }
76
+ return seniorAvailableCapBN
77
+ }
78
+
79
+ const getMinAmount = (): number => {
80
+ const minAmount = poolState.minDepositAmount
81
+ ? SolanaTokenUtils.formatUnits(
82
+ new BN(poolState.minDepositAmount),
83
+ decimals,
84
+ )
85
+ : 0
86
+ return Math.max(0, Math.ceil(Number(minAmount)))
87
+ }
88
+
89
+ const getMaxAmount = (): BN => {
90
+ const trancheCap = getTrancheCap()
91
+ return balance.gt(trancheCap) ? trancheCap : balance
92
+ }
93
+
94
+ const getInfos = () => {
95
+ const trancheCap = getTrancheCap()
96
+ const currentAmountBN = SolanaTokenUtils.parseUnits(
97
+ String(currentAmount),
98
+ decimals,
99
+ )
100
+ const remainingCap = trancheCap.sub(currentAmountBN)
101
+
102
+ if (remainingCap.ltn(0)) {
103
+ return ['0 remaining capacity']
104
+ }
105
+ return [
106
+ `${formatNumber(
107
+ SolanaTokenUtils.formatUnits(remainingCap, decimals),
108
+ )} remaining capacity`,
109
+ ]
110
+ }
111
+
112
+ return (
113
+ <InputAmountModal
114
+ title='Enter Amount'
115
+ subTitle={`Depositing to ${
116
+ isUniTranche ? 'uni tranche' : selectedTranche
117
+ } tranche`}
118
+ tokenSymbol={symbol}
119
+ currentAmount={currentAmount}
120
+ handleChangeAmount={handleChangeAmount}
121
+ minimumAmount={getMinAmount()}
122
+ maxAmount={Number(SolanaTokenUtils.formatUnits(getMaxAmount(), decimals))}
123
+ maxAmountTitle={`${formatNumber(
124
+ SolanaTokenUtils.formatUnits(balance, decimals),
125
+ )} balance`}
126
+ infos={getInfos()}
127
+ handleAction={handleAction}
128
+ actionText='SUPPLY'
129
+ />
130
+ )
131
+ }
@@ -0,0 +1,137 @@
1
+ import {
2
+ getTokenAccounts,
3
+ SolanaPoolInfo,
4
+ SolanaTokenUtils,
5
+ TrancheType,
6
+ } from '@huma-finance/shared'
7
+ import React, { useCallback, useEffect, useState } from 'react'
8
+
9
+ import { TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'
10
+ import { useWallet } from '@solana/wallet-adapter-react'
11
+ import { useHumaProgram, useLenderAccounts } from '@huma-finance/web-shared'
12
+ import { Transaction } from '@solana/web3.js'
13
+ import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
14
+ import { setStep } from '../../../store/widgets.reducers'
15
+ import { WIDGET_STEP } from '../../../store/widgets.store'
16
+ import { selectWidgetState } from '../../../store/widgets.selectors'
17
+ import { SolanaTxSendModal } from '../../SolanaTxSendModal'
18
+ import { LoadingModal } from '../../LoadingModal'
19
+
20
+ type Props = {
21
+ poolInfo: SolanaPoolInfo
22
+ selectedTranche: TrancheType
23
+ }
24
+
25
+ export function Transfer({
26
+ poolInfo,
27
+ selectedTranche,
28
+ }: Props): React.ReactElement | null {
29
+ const dispatch = useAppDispatch()
30
+ const { publicKey } = useWallet()
31
+ const { supplyAmount } = useAppSelector(selectWidgetState)
32
+ const { decimals } = poolInfo.underlyingMint
33
+ const supplyBigNumber = SolanaTokenUtils.parseUnits(
34
+ String(supplyAmount),
35
+ decimals,
36
+ )
37
+ const [transaction, setTransaction] = useState<Transaction>()
38
+ const {
39
+ juniorLenderApprovedAccountPDA,
40
+ seniorLenderApprovedAccountPDA,
41
+ seniorLenderStateAccount,
42
+ juniorLenderStateAccount,
43
+ loading: isLoadingLenderAccounts,
44
+ } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
45
+ const program = useHumaProgram(poolInfo.chainId)
46
+
47
+ const handleSuccess = useCallback(() => {
48
+ dispatch(setStep(WIDGET_STEP.Done))
49
+ }, [dispatch])
50
+
51
+ useEffect(() => {
52
+ async function getTx() {
53
+ if (!publicKey || transaction || isLoadingLenderAccounts) {
54
+ return
55
+ }
56
+
57
+ const tx = new Transaction()
58
+
59
+ const { underlyingTokenATA, seniorTrancheATA, juniorTrancheATA } =
60
+ getTokenAccounts(poolInfo, publicKey)
61
+ if (
62
+ (selectedTranche === 'senior' && !seniorLenderStateAccount) ||
63
+ (selectedTranche === 'junior' && !juniorLenderStateAccount)
64
+ ) {
65
+ const createLenderAccountsTx = await program.methods
66
+ .createLenderAccounts()
67
+ .accountsPartial({
68
+ lender: publicKey,
69
+ humaConfig: poolInfo.humaConfig,
70
+ poolConfig: poolInfo.poolConfig,
71
+ approvedLender:
72
+ selectedTranche === 'senior'
73
+ ? seniorLenderApprovedAccountPDA!
74
+ : juniorLenderApprovedAccountPDA!,
75
+ trancheMint:
76
+ selectedTranche === 'senior'
77
+ ? poolInfo.seniorTrancheMint
78
+ : poolInfo.juniorTrancheMint,
79
+ lenderTrancheToken:
80
+ selectedTranche === 'senior'
81
+ ? seniorTrancheATA
82
+ : juniorTrancheATA,
83
+ tokenProgram: TOKEN_2022_PROGRAM_ID,
84
+ })
85
+ .transaction()
86
+ tx.add(createLenderAccountsTx)
87
+ }
88
+
89
+ const depositTx = await program.methods
90
+ .deposit(supplyBigNumber)
91
+ .accountsPartial({
92
+ depositor: publicKey,
93
+ poolConfig: poolInfo.poolConfig,
94
+ underlyingMint: poolInfo.underlyingMint.address,
95
+ trancheMint:
96
+ selectedTranche === 'senior'
97
+ ? poolInfo.seniorTrancheMint
98
+ : poolInfo.juniorTrancheMint,
99
+ poolUnderlyingToken: poolInfo.poolUnderlyingTokenAccount,
100
+ depositorUnderlyingToken: underlyingTokenATA,
101
+ depositorTrancheToken:
102
+ selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA,
103
+ humaConfig: poolInfo.humaConfig,
104
+ tokenProgram: TOKEN_2022_PROGRAM_ID,
105
+ })
106
+ .transaction()
107
+ tx.add(depositTx)
108
+
109
+ setTransaction(tx)
110
+ }
111
+ getTx()
112
+ }, [
113
+ isLoadingLenderAccounts,
114
+ juniorLenderApprovedAccountPDA,
115
+ juniorLenderStateAccount,
116
+ poolInfo,
117
+ program.methods,
118
+ publicKey,
119
+ selectedTranche,
120
+ seniorLenderApprovedAccountPDA,
121
+ seniorLenderStateAccount,
122
+ supplyBigNumber,
123
+ transaction,
124
+ ])
125
+
126
+ if (isLoadingLenderAccounts) {
127
+ return <LoadingModal title='Supply' />
128
+ }
129
+
130
+ return (
131
+ <SolanaTxSendModal
132
+ tx={transaction}
133
+ chainId={poolInfo.chainId}
134
+ handleSuccess={handleSuccess}
135
+ />
136
+ )
137
+ }
@@ -0,0 +1,52 @@
1
+ import { formatMoney, SolanaPoolInfo, timeUtil } from '@huma-finance/shared'
2
+ import { SolanaPoolState } from '@huma-finance/web-shared'
3
+ import React from 'react'
4
+
5
+ import dayjs from 'dayjs'
6
+ import { selectWidgetState } from '../../../store/widgets.selectors'
7
+ import { useAppSelector } from '../../../hooks/useRedux'
8
+ import { SolanaTxDoneModal } from '../../SolanaTxDoneModal'
9
+
10
+ type Props = {
11
+ poolInfo: SolanaPoolInfo
12
+ poolState: SolanaPoolState
13
+ handleAction: () => void
14
+ }
15
+
16
+ export function Success({
17
+ poolInfo,
18
+ poolState,
19
+ handleAction,
20
+ }: Props): React.ReactElement {
21
+ const { supplyAmount, solanaSignature } = useAppSelector(selectWidgetState)
22
+ const { symbol } = poolInfo.underlyingMint
23
+
24
+ const content = [
25
+ `You successfully supplied ${formatMoney(supplyAmount)} ${symbol}.`,
26
+ ]
27
+
28
+ const getSubContent = () => {
29
+ const lockupEndTime = dayjs()
30
+ .add(poolState.withdrawalLockupPeriodDays ?? 0, 'day')
31
+ .date(1)
32
+ const withdrawTime = lockupEndTime.add(1, 'month')
33
+ return [
34
+ `You can begin submitting redemption requests on ${timeUtil.timestampToLL(
35
+ lockupEndTime.unix(),
36
+ )}, which can be redeemed starting ${timeUtil.timestampToLL(
37
+ withdrawTime.unix(),
38
+ )}.`,
39
+ ]
40
+ }
41
+
42
+ return (
43
+ <SolanaTxDoneModal
44
+ handleAction={handleAction}
45
+ content={content}
46
+ subContent={getSubContent()}
47
+ chainId={poolInfo.chainId}
48
+ solanaSignature={solanaSignature}
49
+ buttonText='DONE'
50
+ />
51
+ )
52
+ }
@@ -0,0 +1,155 @@
1
+ import { SolanaPoolInfo, TrancheType } from '@huma-finance/shared'
2
+ import {
3
+ SolanaPoolState,
4
+ useLenderAccounts,
5
+ useTokenAccount,
6
+ } from '@huma-finance/web-shared'
7
+ import React, { useEffect, useState } from 'react'
8
+ import { useDispatch } from 'react-redux'
9
+
10
+ import { useAppSelector } from '../../../hooks/useRedux'
11
+ import { setStep } from '../../../store/widgets.reducers'
12
+ import { selectWidgetState } from '../../../store/widgets.selectors'
13
+ import { WIDGET_STEP } from '../../../store/widgets.store'
14
+ import { ErrorModal } from '../../ErrorModal'
15
+ import { WidgetWrapper } from '../../WidgetWrapper'
16
+ import { Evaluation } from './1-Evaluation'
17
+ import { ChooseTranche } from './2-ChooseTranche'
18
+ import { ChooseAmount } from './3-ChooseAmount'
19
+ import { Transfer } from './4-Transfer'
20
+ import { Success } from './5-Success'
21
+
22
+ /**
23
+ * Lend pool supply props
24
+ * @typedef {Object} SolanaLendSupplyProps
25
+ * @property {SolanaPoolInfo} poolInfo The metadata of the pool.
26
+ * @property {SolanaPoolState} poolState The current state config of the pool.
27
+ * @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
28
+ * @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
29
+ * @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
30
+ */
31
+ export interface SolanaLendSupplyProps {
32
+ poolInfo: SolanaPoolInfo
33
+ poolState: SolanaPoolState
34
+ pointsTestnetExperience: boolean
35
+ handleClose: () => void
36
+ handleSuccess?: () => void
37
+ }
38
+
39
+ export function SolanaLendSupply({
40
+ poolInfo,
41
+ poolState,
42
+ pointsTestnetExperience,
43
+ handleClose,
44
+ handleSuccess,
45
+ }: SolanaLendSupplyProps): React.ReactElement | null {
46
+ const dispatch = useDispatch()
47
+ const { isUniTranche } = poolState
48
+ const {
49
+ seniorLenderApproved,
50
+ juniorLenderApproved,
51
+ loading: isLoadingLenderAccounts,
52
+ } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
53
+ const [tokenAccount, isLoadingTokenAccount] = useTokenAccount(poolInfo)
54
+ const { step, errorMessage } = useAppSelector(selectWidgetState)
55
+ const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
56
+
57
+ useEffect(() => {
58
+ if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccount) {
59
+ if (!juniorLenderApproved && !seniorLenderApproved) {
60
+ dispatch(setStep(WIDGET_STEP.Evaluation))
61
+ return
62
+ }
63
+
64
+ if (juniorLenderApproved && !seniorLenderApproved) {
65
+ setSelectedTranche('junior')
66
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
67
+ return
68
+ }
69
+
70
+ if (seniorLenderApproved && !juniorLenderApproved) {
71
+ setSelectedTranche('senior')
72
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
73
+ return
74
+ }
75
+
76
+ if (juniorLenderApproved && seniorLenderApproved) {
77
+ dispatch(setStep(WIDGET_STEP.ChooseTranche))
78
+ }
79
+ }
80
+ }, [
81
+ dispatch,
82
+ handleClose,
83
+ poolInfo,
84
+ step,
85
+ isLoadingLenderAccounts,
86
+ juniorLenderApproved,
87
+ seniorLenderApproved,
88
+ isLoadingTokenAccount,
89
+ ])
90
+
91
+ if (isLoadingLenderAccounts || isLoadingTokenAccount) {
92
+ return (
93
+ <WidgetWrapper
94
+ isOpen
95
+ isLoading
96
+ loadingTitle='Supply'
97
+ handleClose={handleClose}
98
+ handleSuccess={handleSuccess}
99
+ />
100
+ )
101
+ }
102
+
103
+ return (
104
+ <WidgetWrapper
105
+ isOpen
106
+ loadingTitle={`Supply ${poolInfo.underlyingMint.symbol}`}
107
+ handleClose={handleClose}
108
+ handleSuccess={handleSuccess}
109
+ >
110
+ {step === WIDGET_STEP.Evaluation && (
111
+ <Evaluation
112
+ poolInfo={poolInfo}
113
+ isUniTranche={!!isUniTranche}
114
+ pointsTestnetExperience={pointsTestnetExperience}
115
+ handleClose={handleClose}
116
+ changeTranche={setSelectedTranche}
117
+ />
118
+ )}
119
+ {step === WIDGET_STEP.ChooseTranche && (
120
+ <ChooseTranche
121
+ poolUnderlyingToken={poolInfo.underlyingMint}
122
+ selectedTranche={selectedTranche}
123
+ changeTranche={setSelectedTranche}
124
+ />
125
+ )}
126
+ {step === WIDGET_STEP.ChooseAmount && (
127
+ <ChooseAmount
128
+ poolInfo={poolInfo}
129
+ poolState={poolState}
130
+ tokenAccount={tokenAccount}
131
+ selectedTranche={selectedTranche}
132
+ isUniTranche={isUniTranche}
133
+ />
134
+ )}
135
+ {step === WIDGET_STEP.Transfer && selectedTranche && (
136
+ <Transfer poolInfo={poolInfo} selectedTranche={selectedTranche} />
137
+ )}
138
+ {step === WIDGET_STEP.Done && (
139
+ <Success
140
+ poolInfo={poolInfo}
141
+ poolState={poolState}
142
+ handleAction={handleClose}
143
+ />
144
+ )}
145
+ {step === WIDGET_STEP.Error && (
146
+ <ErrorModal
147
+ title='Supply'
148
+ errorReason='Sorry there was an error'
149
+ errorMessage={errorMessage}
150
+ handleOk={handleClose}
151
+ />
152
+ )}
153
+ </WidgetWrapper>
154
+ )
155
+ }
@@ -1,9 +1,9 @@
1
- import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
1
+ import { CHAIN_TYPE, PoolInfoV2, TrancheType } from '@huma-finance/shared'
2
2
  import React from 'react'
3
3
 
4
4
  import { Campaign } from '.'
5
- import { PersonaEvaluation } from './components/PersonaEvaluation'
6
- import { SecuritizeEvaluation } from './components/SecuritizeEvaluation'
5
+ import { PersonaEvaluation } from '../components/PersonaEvaluation'
6
+ import { SecuritizeEvaluation } from '../components/SecuritizeEvaluation'
7
7
 
8
8
  type Props = {
9
9
  poolInfo: PoolInfoV2
@@ -35,6 +35,7 @@ export function Evaluation({
35
35
  isUniTranche={isUniTranche}
36
36
  pointsTestnetExperience={pointsTestnetExperience}
37
37
  campaign={campaign}
38
+ chainType={CHAIN_TYPE.EVM}
38
39
  changeTranche={changeTranche}
39
40
  />
40
41
  )
@@ -90,13 +90,13 @@ export function Success({
90
90
  ]
91
91
 
92
92
  const getSubContent = () => {
93
- const redemptionTime = dayjs()
93
+ const lockupEndTime = dayjs()
94
94
  .add(lpConfig.withdrawalLockoutPeriodInDays, 'day')
95
95
  .date(1)
96
- const withdrawTime = redemptionTime.add(1, 'month')
96
+ const withdrawTime = lockupEndTime.add(1, 'month')
97
97
  return [
98
98
  `You can begin submitting redemption requests on ${timeUtil.timestampToLL(
99
- redemptionTime.unix(),
99
+ lockupEndTime.unix(),
100
100
  )}, which can be redeemed starting ${timeUtil.timestampToLL(
101
101
  withdrawTime.unix(),
102
102
  )}.`,