@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,155 @@
1
+ import { SolanaPoolInfo, TrancheType } from '@huma-finance/shared'
2
+ import {
3
+ SolanaPoolState,
4
+ useLenderAccounts,
5
+ useTrancheTokenAccounts,
6
+ } from '@huma-finance/web-shared'
7
+ import React, { useEffect, useState } from 'react'
8
+ import { useDispatch } from 'react-redux'
9
+
10
+ import { BN } from '@coral-xyz/anchor'
11
+ import { useAppSelector } from '../../../hooks/useRedux'
12
+ import { selectWidgetState } from '../../../store/widgets.selectors'
13
+ import { WidgetWrapper } from '../../WidgetWrapper'
14
+ import { WIDGET_STEP } from '../../../store/widgets.store'
15
+ import { ChooseAmount } from './2-ChooseAmount'
16
+ import { setStep } from '../../../store/widgets.reducers'
17
+ import { ErrorModal } from '../../ErrorModal'
18
+ import { ChooseTranche } from './1-ChooseTranche'
19
+ import { Done } from './4-Done'
20
+ import { Transfer } from './3-Transfer'
21
+
22
+ /**
23
+ * Lend pool supply props
24
+ * @typedef {Object} SolanaLendAddRedemptionProps
25
+ * @property {SolanaPoolInfo} poolInfo The metadata of the pool.
26
+ * @property {SolanaPoolState} poolState The current state config of the pool. * @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
27
+ * @property {POOL_NTrancheTypeAME} tranche The tranche type.
28
+ * @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
29
+ */
30
+ export interface SolanaLendAddRedemptionProps {
31
+ poolInfo: SolanaPoolInfo
32
+ poolState: SolanaPoolState
33
+ tranche?: TrancheType
34
+ handleClose: () => void
35
+ handleSuccess?: () => void
36
+ }
37
+
38
+ export function SolanaLendAddRedemption({
39
+ poolInfo,
40
+ poolState,
41
+ tranche,
42
+ handleClose,
43
+ handleSuccess,
44
+ }: SolanaLendAddRedemptionProps): React.ReactElement | null {
45
+ const dispatch = useDispatch()
46
+ const {
47
+ seniorLenderStateAccount,
48
+ juniorLenderStateAccount,
49
+ loading: isLoadingLenderAccounts,
50
+ } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
51
+ const {
52
+ seniorTokenAccount,
53
+ juniorTokenAccount,
54
+ loading: isLoadingTokenAccounts,
55
+ } = useTrancheTokenAccounts(poolInfo)
56
+ const { step, errorMessage } = useAppSelector(selectWidgetState)
57
+ const [selectedTranche, setSelectedTranche] = useState<
58
+ TrancheType | undefined
59
+ >(tranche)
60
+
61
+ useEffect(() => {
62
+ if (!step && !isLoadingLenderAccounts && !isLoadingTokenAccounts) {
63
+ const seniorTrancheShares = new BN(
64
+ seniorTokenAccount?.amount?.toString() ?? 0,
65
+ )
66
+ const juniorTrancheShares = new BN(
67
+ juniorTokenAccount?.amount?.toString() ?? 0,
68
+ )
69
+
70
+ if (selectedTranche) {
71
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
72
+ return
73
+ }
74
+
75
+ if (juniorTrancheShares.gtn(0) && seniorTrancheShares.lten(0)) {
76
+ setSelectedTranche('junior')
77
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
78
+ return
79
+ }
80
+
81
+ if (seniorTrancheShares.gtn(0) && juniorTrancheShares.lten(0)) {
82
+ setSelectedTranche('senior')
83
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
84
+ return
85
+ }
86
+
87
+ if (seniorTrancheShares.gtn(0) && juniorTrancheShares.gtn(0)) {
88
+ dispatch(setStep(WIDGET_STEP.ChooseTranche))
89
+ }
90
+ }
91
+ }, [
92
+ dispatch,
93
+ step,
94
+ isLoadingLenderAccounts,
95
+ isLoadingTokenAccounts,
96
+ seniorTokenAccount?.amount,
97
+ juniorTokenAccount?.amount,
98
+ selectedTranche,
99
+ ])
100
+
101
+ const title = 'Redemption'
102
+ if (isLoadingLenderAccounts || isLoadingTokenAccounts) {
103
+ return (
104
+ <WidgetWrapper
105
+ isOpen
106
+ isLoading
107
+ loadingTitle={title}
108
+ handleClose={handleClose}
109
+ handleSuccess={handleSuccess}
110
+ />
111
+ )
112
+ }
113
+
114
+ return (
115
+ <WidgetWrapper
116
+ isOpen
117
+ loadingTitle={title}
118
+ handleClose={handleClose}
119
+ handleSuccess={handleSuccess}
120
+ >
121
+ {step === WIDGET_STEP.ChooseTranche && (
122
+ <ChooseTranche
123
+ selectedTranche={selectedTranche}
124
+ changeTranche={setSelectedTranche}
125
+ />
126
+ )}
127
+ {step === WIDGET_STEP.ChooseAmount && selectedTranche && (
128
+ <ChooseAmount
129
+ poolInfo={poolInfo}
130
+ poolState={poolState}
131
+ lenderState={
132
+ selectedTranche === 'senior'
133
+ ? seniorLenderStateAccount
134
+ : juniorLenderStateAccount
135
+ }
136
+ selectedTranche={selectedTranche}
137
+ />
138
+ )}
139
+ {step === WIDGET_STEP.Transfer && selectedTranche && (
140
+ <Transfer poolInfo={poolInfo} selectedTranche={selectedTranche} />
141
+ )}
142
+ {step === WIDGET_STEP.Done && (
143
+ <Done poolInfo={poolInfo} handleAction={handleClose} />
144
+ )}
145
+ {step === WIDGET_STEP.Error && (
146
+ <ErrorModal
147
+ title={title}
148
+ errorReason='Sorry there was an error'
149
+ errorMessage={errorMessage}
150
+ handleOk={handleClose}
151
+ />
152
+ )}
153
+ </WidgetWrapper>
154
+ )
155
+ }
@@ -0,0 +1,114 @@
1
+ import { TrancheType } 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
+ selectedTranche: TrancheType | undefined
21
+ changeTranche: (tranche: TrancheType) => void
22
+ }
23
+
24
+ export function ChooseTranche({
25
+ selectedTranche,
26
+ changeTranche,
27
+ }: Props): React.ReactElement | null {
28
+ const theme = useTheme()
29
+ const dispatch = useAppDispatch()
30
+
31
+ const styles = {
32
+ subTitle: css`
33
+ color: ${theme.palette.text.primary} !important;
34
+ font-weight: 400;
35
+ font-size: 16px;
36
+ line-height: 150%;
37
+ letter-spacing: 0.15px;
38
+ margin-top: ${theme.spacing(5)};
39
+ margin-left: ${theme.spacing(2)};
40
+ `,
41
+ radioGroup: css`
42
+ margin-left: ${theme.spacing(3)};
43
+ margin-top: ${theme.spacing(3)};
44
+ `,
45
+ formControl: css`
46
+ margin-bottom: ${theme.spacing(1)};
47
+
48
+ .MuiFormControlLabel-label {
49
+ color: ${theme.palette.text.primary};
50
+ font-weight: 400;
51
+ font-size: 16px;
52
+ line-height: 150%;
53
+ letter-spacing: 0.15px;
54
+ }
55
+ `,
56
+ }
57
+
58
+ const handleNext = () => {
59
+ dispatch(setStep(WIDGET_STEP.ChooseAmount))
60
+ }
61
+
62
+ const items: {
63
+ label: string
64
+ value: TrancheType
65
+ }[] = [
66
+ {
67
+ label: 'Senior',
68
+ value: 'senior',
69
+ },
70
+ {
71
+ label: 'Junior',
72
+ value: 'junior',
73
+ },
74
+ ]
75
+
76
+ return (
77
+ <WrapperModal title='Cancel Redemption'>
78
+ <FormControl>
79
+ <FormLabel css={styles.subTitle}>Select Tranche Type</FormLabel>
80
+ <RadioGroup
81
+ aria-labelledby='buttons-group-label'
82
+ name='radio-buttons-group'
83
+ css={styles.radioGroup}
84
+ onChange={(e) => changeTranche(e.target.value as TrancheType)}
85
+ >
86
+ {items.map((item) => (
87
+ <FormControlLabel
88
+ key={item.label}
89
+ value={item.value}
90
+ control={
91
+ <Radio
92
+ sx={{
93
+ '& .MuiSvgIcon-root': {
94
+ fontSize: 24,
95
+ },
96
+ }}
97
+ />
98
+ }
99
+ label={item.label}
100
+ css={styles.formControl}
101
+ />
102
+ ))}
103
+ </RadioGroup>
104
+ </FormControl>
105
+ <BottomButton
106
+ variant='contained'
107
+ disabled={!selectedTranche}
108
+ onClick={handleNext}
109
+ >
110
+ NEXT
111
+ </BottomButton>
112
+ </WrapperModal>
113
+ )
114
+ }
@@ -0,0 +1,99 @@
1
+ import {
2
+ getTokenAccounts,
3
+ SolanaPoolInfo,
4
+ TrancheType,
5
+ } from '@huma-finance/shared'
6
+ import React, { useCallback, useEffect, useState } from 'react'
7
+
8
+ import { TOKEN_2022_PROGRAM_ID } from '@solana/spl-token'
9
+ import { useWallet } from '@solana/wallet-adapter-react'
10
+ import { LenderStateAccount, useHumaProgram } from '@huma-finance/web-shared'
11
+ import { Transaction } from '@solana/web3.js'
12
+ import { useAppDispatch } from '../../../hooks/useRedux'
13
+ import { setStep } from '../../../store/widgets.reducers'
14
+ import { WIDGET_STEP } from '../../../store/widgets.store'
15
+ import { SolanaTxSendModal } from '../../SolanaTxSendModal'
16
+
17
+ type Props = {
18
+ poolInfo: SolanaPoolInfo
19
+ lenderState: LenderStateAccount | null | undefined
20
+ lenderStatePDA: string | null | undefined
21
+ selectedTranche: TrancheType
22
+ }
23
+
24
+ export function Transfer({
25
+ poolInfo,
26
+ lenderState,
27
+ lenderStatePDA,
28
+ selectedTranche,
29
+ }: Props): React.ReactElement | null {
30
+ const dispatch = useAppDispatch()
31
+ const { publicKey } = useWallet()
32
+ const [transaction, setTransaction] = useState<Transaction>()
33
+ const program = useHumaProgram(poolInfo.chainId)
34
+
35
+ const handleSuccess = useCallback(() => {
36
+ dispatch(setStep(WIDGET_STEP.Done))
37
+ }, [dispatch])
38
+
39
+ useEffect(() => {
40
+ async function getTx() {
41
+ if (!publicKey || !lenderState || !lenderStatePDA || transaction) {
42
+ return
43
+ }
44
+
45
+ const {
46
+ seniorTrancheATA,
47
+ juniorTrancheATA,
48
+ poolSeniorTrancheATA,
49
+ poolJuniorTrancheATA,
50
+ } = getTokenAccounts(poolInfo, publicKey)
51
+ const tx = await program.methods
52
+ .cancelRedemptionRequest(
53
+ lenderState.redemptionRecord.numSharesRequested,
54
+ )
55
+ .accountsPartial({
56
+ lender: publicKey,
57
+ humaConfig: poolInfo.humaConfig,
58
+ poolConfig: poolInfo.poolConfig,
59
+ trancheMint:
60
+ selectedTranche === 'senior'
61
+ ? poolInfo.seniorTrancheMint
62
+ : poolInfo.juniorTrancheMint,
63
+ trancheState:
64
+ selectedTranche === 'senior'
65
+ ? poolInfo.seniorTrancheState
66
+ : poolInfo.juniorTrancheState,
67
+ lenderState: lenderStatePDA,
68
+ poolAuthority: poolInfo.poolAuthority,
69
+ poolTrancheToken:
70
+ selectedTranche === 'senior'
71
+ ? poolSeniorTrancheATA
72
+ : poolJuniorTrancheATA,
73
+ lenderTrancheToken:
74
+ selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA,
75
+ tokenProgram: TOKEN_2022_PROGRAM_ID,
76
+ })
77
+ .transaction()
78
+
79
+ setTransaction(tx)
80
+ }
81
+ getTx()
82
+ }, [
83
+ lenderState,
84
+ lenderStatePDA,
85
+ poolInfo,
86
+ program.methods,
87
+ publicKey,
88
+ selectedTranche,
89
+ transaction,
90
+ ])
91
+
92
+ return (
93
+ <SolanaTxSendModal
94
+ tx={transaction}
95
+ chainId={poolInfo.chainId}
96
+ handleSuccess={handleSuccess}
97
+ />
98
+ )
99
+ }
@@ -0,0 +1,55 @@
1
+ import {
2
+ formatNumber,
3
+ SolanaPoolInfo,
4
+ SolanaTokenUtils,
5
+ TrancheType,
6
+ } from '@huma-finance/shared'
7
+ import React from 'react'
8
+
9
+ import {
10
+ LenderStateAccount,
11
+ useTrancheMintAccounts,
12
+ } from '@huma-finance/web-shared'
13
+ import { SolanaTxDoneModal } from '../../SolanaTxDoneModal'
14
+ import { useAppSelector } from '../../../hooks/useRedux'
15
+ import { selectWidgetState } from '../../../store/widgets.selectors'
16
+
17
+ type Props = {
18
+ poolInfo: SolanaPoolInfo
19
+ lenderState: LenderStateAccount | null | undefined
20
+ selectedTranche: TrancheType
21
+ handleAction: () => void
22
+ }
23
+
24
+ export function Done({
25
+ poolInfo,
26
+ lenderState,
27
+ selectedTranche,
28
+ handleAction,
29
+ }: Props): React.ReactElement | null {
30
+ const { mintAccount, loading: isLoadingTrancheMintAccounts } =
31
+ useTrancheMintAccounts(poolInfo, selectedTranche)
32
+ const { solanaSignature } = useAppSelector(selectWidgetState)
33
+
34
+ const content =
35
+ !lenderState || isLoadingTrancheMintAccounts || !mintAccount
36
+ ? ['']
37
+ : [
38
+ `Your request to cancel the redemption of ${formatNumber(
39
+ SolanaTokenUtils.formatUnits(
40
+ lenderState.redemptionRecord.numSharesRequested,
41
+ mintAccount.decimals,
42
+ ),
43
+ )} shares has been successfully processed.`,
44
+ ]
45
+
46
+ return (
47
+ <SolanaTxDoneModal
48
+ handleAction={handleAction}
49
+ content={content}
50
+ chainId={poolInfo.chainId}
51
+ solanaSignature={solanaSignature}
52
+ buttonText='DONE'
53
+ />
54
+ )
55
+ }
@@ -0,0 +1,162 @@
1
+ import { SolanaPoolInfo, TrancheType } from '@huma-finance/shared'
2
+ import { useLenderAccounts } from '@huma-finance/web-shared'
3
+ import React, { useEffect, useState } from 'react'
4
+ import { useDispatch } from 'react-redux'
5
+
6
+ import { BN } from '@coral-xyz/anchor'
7
+ import { useAppSelector } from '../../../hooks/useRedux'
8
+ import { selectWidgetState } from '../../../store/widgets.selectors'
9
+ import { WidgetWrapper } from '../../WidgetWrapper'
10
+ import { WIDGET_STEP } from '../../../store/widgets.store'
11
+ import { setStep } from '../../../store/widgets.reducers'
12
+ import { ErrorModal } from '../../ErrorModal'
13
+ import { Transfer } from './2-Transfer'
14
+ import { ChooseTranche } from './1-ChooseTranche'
15
+ import { Done } from './3-Done'
16
+
17
+ /**
18
+ * Lend pool supply props
19
+ * @typedef {Object} SolanaLendCancelRedemptionProps
20
+ * @property {SolanaPoolInfo} poolInfo The metadata of the pool.
21
+ * @property {SolanaPoolState} poolState The current state config of the pool. * @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
22
+ * @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
23
+ */
24
+ export interface SolanaLendCancelRedemptionProps {
25
+ poolInfo: SolanaPoolInfo
26
+ tranche?: TrancheType
27
+ handleClose: () => void
28
+ handleSuccess?: () => void
29
+ }
30
+
31
+ export function SolanaLendCancelRedemption({
32
+ poolInfo,
33
+ tranche,
34
+ handleClose,
35
+ handleSuccess,
36
+ }: SolanaLendCancelRedemptionProps): React.ReactElement | null {
37
+ const dispatch = useDispatch()
38
+ const {
39
+ seniorLenderStateAccount,
40
+ juniorLenderStateAccount,
41
+ juniorLenderStateAccountPDA,
42
+ seniorLenderStateAccountPDA,
43
+ loading: isLoadingLenderAccounts,
44
+ } = useLenderAccounts(poolInfo.chainId, poolInfo.poolName)
45
+ const { step, errorMessage } = useAppSelector(selectWidgetState)
46
+ const [selectedTranche, setSelectedTranche] = useState<
47
+ TrancheType | undefined
48
+ >(tranche)
49
+
50
+ useEffect(() => {
51
+ if (!step && !isLoadingLenderAccounts) {
52
+ const seniorTrancheSharesRequested = new BN(
53
+ seniorLenderStateAccount?.redemptionRecord.numSharesRequested ?? 0,
54
+ )
55
+ const juniorTrancheSharesRequested = new BN(
56
+ juniorLenderStateAccount?.redemptionRecord.numSharesRequested ?? 0,
57
+ )
58
+
59
+ if (selectedTranche) {
60
+ dispatch(setStep(WIDGET_STEP.Transfer))
61
+ return
62
+ }
63
+
64
+ if (
65
+ juniorTrancheSharesRequested.gtn(0) &&
66
+ seniorTrancheSharesRequested.lten(0)
67
+ ) {
68
+ setSelectedTranche('junior')
69
+ dispatch(setStep(WIDGET_STEP.Transfer))
70
+ return
71
+ }
72
+
73
+ if (
74
+ seniorTrancheSharesRequested.gtn(0) &&
75
+ juniorTrancheSharesRequested.lten(0)
76
+ ) {
77
+ setSelectedTranche('senior')
78
+ dispatch(setStep(WIDGET_STEP.Transfer))
79
+ return
80
+ }
81
+
82
+ if (
83
+ seniorTrancheSharesRequested.gtn(0) &&
84
+ juniorTrancheSharesRequested.gtn(0)
85
+ ) {
86
+ dispatch(setStep(WIDGET_STEP.ChooseTranche))
87
+ }
88
+ }
89
+ }, [
90
+ dispatch,
91
+ step,
92
+ isLoadingLenderAccounts,
93
+ seniorLenderStateAccount?.redemptionRecord.numSharesRequested,
94
+ juniorLenderStateAccount?.redemptionRecord.numSharesRequested,
95
+ selectedTranche,
96
+ ])
97
+
98
+ const title = 'Cancel Redemption'
99
+ if (isLoadingLenderAccounts) {
100
+ return (
101
+ <WidgetWrapper
102
+ isOpen
103
+ isLoading
104
+ loadingTitle={title}
105
+ handleClose={handleClose}
106
+ handleSuccess={handleSuccess}
107
+ />
108
+ )
109
+ }
110
+
111
+ return (
112
+ <WidgetWrapper
113
+ isOpen
114
+ loadingTitle={title}
115
+ handleClose={handleClose}
116
+ handleSuccess={handleSuccess}
117
+ >
118
+ {step === WIDGET_STEP.ChooseTranche && (
119
+ <ChooseTranche
120
+ selectedTranche={selectedTranche}
121
+ changeTranche={setSelectedTranche}
122
+ />
123
+ )}
124
+ {step === WIDGET_STEP.Transfer && selectedTranche && (
125
+ <Transfer
126
+ poolInfo={poolInfo}
127
+ lenderState={
128
+ selectedTranche === 'senior'
129
+ ? seniorLenderStateAccount
130
+ : juniorLenderStateAccount
131
+ }
132
+ lenderStatePDA={
133
+ selectedTranche === 'senior'
134
+ ? seniorLenderStateAccountPDA
135
+ : juniorLenderStateAccountPDA
136
+ }
137
+ selectedTranche={selectedTranche}
138
+ />
139
+ )}
140
+ {step === WIDGET_STEP.Done && selectedTranche && (
141
+ <Done
142
+ poolInfo={poolInfo}
143
+ lenderState={
144
+ selectedTranche === 'senior'
145
+ ? seniorLenderStateAccount
146
+ : juniorLenderStateAccount
147
+ }
148
+ selectedTranche={selectedTranche}
149
+ handleAction={handleClose}
150
+ />
151
+ )}
152
+ {step === WIDGET_STEP.Error && (
153
+ <ErrorModal
154
+ title={title}
155
+ errorReason='Sorry there was an error'
156
+ errorMessage={errorMessage}
157
+ handleOk={handleClose}
158
+ />
159
+ )}
160
+ </WidgetWrapper>
161
+ )
162
+ }
@@ -0,0 +1,43 @@
1
+ import { CHAIN_TYPE, SolanaPoolInfo, TrancheType } from '@huma-finance/shared'
2
+ import React from 'react'
3
+
4
+ import { PersonaEvaluation } from '../components/PersonaEvaluation'
5
+ import { Campaign } from '../supplyV2'
6
+
7
+ type Props = {
8
+ poolInfo: SolanaPoolInfo
9
+ isUniTranche: boolean
10
+ pointsTestnetExperience: boolean
11
+ campaign?: Campaign
12
+ changeTranche: (tranche: TrancheType) => void
13
+ handleClose: () => void
14
+ }
15
+
16
+ export function Evaluation({
17
+ poolInfo,
18
+ isUniTranche,
19
+ pointsTestnetExperience,
20
+ campaign,
21
+ changeTranche,
22
+ handleClose,
23
+ }: Props): React.ReactElement | null {
24
+ if (poolInfo.KYC?.Persona) {
25
+ return (
26
+ <PersonaEvaluation
27
+ poolInfo={{
28
+ KYC: poolInfo.KYC,
29
+ juniorTrancheVault: poolInfo.juniorTrancheMint,
30
+ seniorTrancheVault: poolInfo.seniorTrancheMint,
31
+ }}
32
+ handleClose={handleClose}
33
+ isUniTranche={isUniTranche}
34
+ pointsTestnetExperience={pointsTestnetExperience}
35
+ campaign={campaign}
36
+ chainType={CHAIN_TYPE.SOLANA}
37
+ changeTranche={changeTranche}
38
+ />
39
+ )
40
+ }
41
+
42
+ return null
43
+ }