@huma-finance/widgets 0.0.62-beta.726 → 0.0.62-beta.729
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 +156 -99
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +157 -100
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/Lend/components/ApproveLenderBase.tsx +103 -0
- package/src/components/Lend/components/PersonaEvaluation.tsx +2 -58
- package/src/components/Lend/solanaSupply/1-Evaluation.tsx +1 -18
- package/src/components/Lend/solanaSupply/2-ApproveLender.tsx +37 -0
- package/src/components/Lend/solanaSupply/index.tsx +18 -6
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +1 -12
- package/src/components/Lend/supplyV2/3-ApproveLender.tsx +26 -0
- package/src/components/Lend/supplyV2/index.tsx +20 -22
- package/src/store/widgets.store.ts +1 -0
- /package/src/components/Lend/solanaSupply/{2-ChooseTranche.tsx → 3-ChooseTranche.tsx} +0 -0
- /package/src/components/Lend/solanaSupply/{3-ChooseAmount.tsx → 4-ChooseAmount.tsx} +0 -0
- /package/src/components/Lend/solanaSupply/{4-ApproveAllowance.tsx → 5-ApproveAllowance.tsx} +0 -0
- /package/src/components/Lend/solanaSupply/{4-Transfer.tsx → 6-Transfer.tsx} +0 -0
- /package/src/components/Lend/solanaSupply/{5-Success.tsx → 7-Success.tsx} +0 -0
- /package/src/components/Lend/solanaSupply/{6-PointsEarned.tsx → 8-PointsEarned.tsx} +0 -0
- /package/src/components/Lend/supplyV2/{3-ChooseAmount.tsx → 4-ChooseAmount.tsx} +0 -0
- /package/src/components/Lend/supplyV2/{4-ApproveAllowance.tsx → 5-ApproveAllowance.tsx} +0 -0
- /package/src/components/Lend/supplyV2/{5-Transfer.tsx → 6-Transfer.tsx} +0 -0
- /package/src/components/Lend/supplyV2/{6-Success.tsx → 7-Success.tsx} +0 -0
- /package/src/components/Lend/supplyV2/{7-Notifications.tsx → 8-Notifications.tsx} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.62-beta.
|
|
3
|
+
"version": "0.0.62-beta.729+5102a4a",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"@ethersproject/experimental": "^5.7.0",
|
|
30
30
|
"@ethersproject/providers": "^5.6.0",
|
|
31
31
|
"@ethersproject/units": "^5.6.0",
|
|
32
|
-
"@huma-finance/sdk": "^0.0.62-beta.
|
|
33
|
-
"@huma-finance/shared": "^0.0.
|
|
34
|
-
"@huma-finance/web-shared": "^0.0.
|
|
32
|
+
"@huma-finance/sdk": "^0.0.62-beta.729+5102a4a",
|
|
33
|
+
"@huma-finance/shared": "^0.0.62-beta.729+5102a4a",
|
|
34
|
+
"@huma-finance/web-shared": "^0.0.62-beta.729+5102a4a",
|
|
35
35
|
"@mui/x-date-pickers": "^5.0.7",
|
|
36
36
|
"@notifi-network/notifi-frontend-client": "^1.1.2",
|
|
37
37
|
"@notifi-network/notifi-react": "^1.1.2",
|
|
@@ -201,5 +201,5 @@
|
|
|
201
201
|
"optionalDependencies": {
|
|
202
202
|
"encoding": "^0.1.13"
|
|
203
203
|
},
|
|
204
|
-
"gitHead": "
|
|
204
|
+
"gitHead": "5102a4acd220077fb8627be88ea87ca530467f43"
|
|
205
205
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* eslint-disable no-await-in-loop */
|
|
2
|
+
import {
|
|
3
|
+
CHAIN_TYPE,
|
|
4
|
+
checkIsDev,
|
|
5
|
+
IdentityServiceV2,
|
|
6
|
+
timeUtil,
|
|
7
|
+
TrancheType,
|
|
8
|
+
} from '@huma-finance/shared'
|
|
9
|
+
import { useChainInfo } from '@huma-finance/web-shared'
|
|
10
|
+
import React, { useCallback, useEffect } from 'react'
|
|
11
|
+
|
|
12
|
+
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
13
|
+
import { setError, setStep } from '../../../store/widgets.reducers'
|
|
14
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
15
|
+
import { LoadingModal } from '../../LoadingModal'
|
|
16
|
+
|
|
17
|
+
type Props = {
|
|
18
|
+
juniorTrancheVault: string
|
|
19
|
+
seniorTrancheVault: string
|
|
20
|
+
chainType: CHAIN_TYPE
|
|
21
|
+
isUniTranche: boolean
|
|
22
|
+
chainSpecificData?: Record<string, unknown>
|
|
23
|
+
changeTranche: (tranche: TrancheType) => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function ApproveLenderBase({
|
|
27
|
+
juniorTrancheVault,
|
|
28
|
+
seniorTrancheVault,
|
|
29
|
+
isUniTranche,
|
|
30
|
+
chainType,
|
|
31
|
+
chainSpecificData,
|
|
32
|
+
changeTranche,
|
|
33
|
+
}: Props): React.ReactElement | null {
|
|
34
|
+
const isDev = checkIsDev()
|
|
35
|
+
const dispatch = useAppDispatch()
|
|
36
|
+
const { account, chainId } = useChainInfo(isDev, chainType)
|
|
37
|
+
|
|
38
|
+
const approveLender = useCallback(
|
|
39
|
+
async (trancheVault: string) => {
|
|
40
|
+
let tryAttempts = 2
|
|
41
|
+
|
|
42
|
+
while (tryAttempts > 0) {
|
|
43
|
+
try {
|
|
44
|
+
tryAttempts -= 1
|
|
45
|
+
await IdentityServiceV2.approveLender(
|
|
46
|
+
account!,
|
|
47
|
+
chainId!,
|
|
48
|
+
trancheVault,
|
|
49
|
+
isDev,
|
|
50
|
+
chainSpecificData,
|
|
51
|
+
)
|
|
52
|
+
tryAttempts = 0
|
|
53
|
+
} catch (e: unknown) {
|
|
54
|
+
if (tryAttempts === 0) {
|
|
55
|
+
dispatch(
|
|
56
|
+
setError({
|
|
57
|
+
errorMessage: 'Something went wrong, please try again later.',
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
} else {
|
|
61
|
+
await timeUtil.sleep(3000)
|
|
62
|
+
console.error(e)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[account, chainId, chainSpecificData, dispatch, isDev],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const approveLenderAsync = async () => {
|
|
72
|
+
if (account && chainId) {
|
|
73
|
+
if (isUniTranche) {
|
|
74
|
+
await approveLender(juniorTrancheVault)
|
|
75
|
+
changeTranche('junior')
|
|
76
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
77
|
+
} else {
|
|
78
|
+
await approveLender(juniorTrancheVault)
|
|
79
|
+
await approveLender(seniorTrancheVault)
|
|
80
|
+
dispatch(setStep(WIDGET_STEP.ChooseTranche))
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
approveLenderAsync()
|
|
86
|
+
}, [
|
|
87
|
+
account,
|
|
88
|
+
approveLender,
|
|
89
|
+
chainId,
|
|
90
|
+
changeTranche,
|
|
91
|
+
dispatch,
|
|
92
|
+
isUniTranche,
|
|
93
|
+
juniorTrancheVault,
|
|
94
|
+
seniorTrancheVault,
|
|
95
|
+
])
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<LoadingModal
|
|
99
|
+
title='Lender Approval'
|
|
100
|
+
description='Checking your verification status...'
|
|
101
|
+
/>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
IdentityVerificationStatusV2,
|
|
9
9
|
KYCCopy,
|
|
10
10
|
KYCType,
|
|
11
|
-
TrancheType,
|
|
12
11
|
VerificationStatusResultV2,
|
|
13
12
|
} from '@huma-finance/shared'
|
|
14
13
|
import { useAuthErrorHandling, useChainInfo } from '@huma-finance/web-shared'
|
|
@@ -34,22 +33,16 @@ type Props = {
|
|
|
34
33
|
seniorTrancheVault: string
|
|
35
34
|
}
|
|
36
35
|
chainType: CHAIN_TYPE
|
|
37
|
-
isUniTranche: boolean
|
|
38
36
|
pointsTestnetExperience: boolean
|
|
39
37
|
campaign?: Campaign
|
|
40
|
-
chainSpecificData?: Record<string, unknown>
|
|
41
|
-
changeTranche: (tranche: TrancheType) => void
|
|
42
38
|
handleClose: (options?: CloseModalOptions) => void
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
export function PersonaEvaluation({
|
|
46
42
|
poolInfo,
|
|
47
|
-
isUniTranche,
|
|
48
43
|
campaign,
|
|
49
44
|
pointsTestnetExperience,
|
|
50
45
|
chainType,
|
|
51
|
-
chainSpecificData,
|
|
52
|
-
changeTranche,
|
|
53
46
|
handleClose,
|
|
54
47
|
}: Props): React.ReactElement | null {
|
|
55
48
|
const theme = useTheme()
|
|
@@ -95,55 +88,6 @@ export function PersonaEvaluation({
|
|
|
95
88
|
pointsTestnetExperience,
|
|
96
89
|
])
|
|
97
90
|
|
|
98
|
-
const approveLender = useCallback(async () => {
|
|
99
|
-
isActionOngoingRef.current = true
|
|
100
|
-
setLoadingType('approveLender')
|
|
101
|
-
try {
|
|
102
|
-
await IdentityServiceV2.approveLender(
|
|
103
|
-
account!,
|
|
104
|
-
chainId!,
|
|
105
|
-
poolInfo.juniorTrancheVault,
|
|
106
|
-
isDev,
|
|
107
|
-
chainSpecificData,
|
|
108
|
-
)
|
|
109
|
-
} catch (e: unknown) {
|
|
110
|
-
console.error(e)
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (!isUniTranche) {
|
|
114
|
-
try {
|
|
115
|
-
await IdentityServiceV2.approveLender(
|
|
116
|
-
account!,
|
|
117
|
-
chainId!,
|
|
118
|
-
poolInfo.seniorTrancheVault,
|
|
119
|
-
isDev,
|
|
120
|
-
chainSpecificData,
|
|
121
|
-
)
|
|
122
|
-
} catch (e: unknown) {
|
|
123
|
-
console.error(e)
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (isUniTranche) {
|
|
127
|
-
changeTranche('junior')
|
|
128
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
129
|
-
} else {
|
|
130
|
-
dispatch(setStep(WIDGET_STEP.ChooseTranche))
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
isActionOngoingRef.current = false
|
|
134
|
-
setLoadingType(undefined)
|
|
135
|
-
}, [
|
|
136
|
-
account,
|
|
137
|
-
chainId,
|
|
138
|
-
chainSpecificData,
|
|
139
|
-
changeTranche,
|
|
140
|
-
dispatch,
|
|
141
|
-
isDev,
|
|
142
|
-
isUniTranche,
|
|
143
|
-
poolInfo.juniorTrancheVault,
|
|
144
|
-
poolInfo.seniorTrancheVault,
|
|
145
|
-
])
|
|
146
|
-
|
|
147
91
|
const checkVerificationStatus = useCallback(async () => {
|
|
148
92
|
if (isActionOngoingRef.current || isKYCResumedRef.current) {
|
|
149
93
|
return
|
|
@@ -247,7 +191,7 @@ export function PersonaEvaluation({
|
|
|
247
191
|
}
|
|
248
192
|
|
|
249
193
|
case IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION: {
|
|
250
|
-
|
|
194
|
+
dispatch(setStep(WIDGET_STEP.ApproveLender))
|
|
251
195
|
break
|
|
252
196
|
}
|
|
253
197
|
|
|
@@ -260,7 +204,7 @@ export function PersonaEvaluation({
|
|
|
260
204
|
} finally {
|
|
261
205
|
isActionOngoingRef.current = false
|
|
262
206
|
}
|
|
263
|
-
}, [KYCCopies, account,
|
|
207
|
+
}, [KYCCopies, account, chainId, dispatch, isDev, setAuthError])
|
|
264
208
|
|
|
265
209
|
useEffect(() => {
|
|
266
210
|
checkVerificationStatus()
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CHAIN_TYPE,
|
|
3
|
-
SOLANA_CHAIN_INFO,
|
|
4
|
-
SolanaPoolInfo,
|
|
5
|
-
TrancheType,
|
|
6
|
-
} from '@huma-finance/shared'
|
|
1
|
+
import { CHAIN_TYPE, SolanaPoolInfo } from '@huma-finance/shared'
|
|
7
2
|
import React from 'react'
|
|
8
3
|
|
|
9
4
|
import { PersonaEvaluation } from '../components/PersonaEvaluation'
|
|
@@ -11,24 +6,18 @@ import { Campaign } from '../supplyV2'
|
|
|
11
6
|
|
|
12
7
|
type Props = {
|
|
13
8
|
poolInfo: SolanaPoolInfo
|
|
14
|
-
isUniTranche: boolean
|
|
15
9
|
pointsTestnetExperience: boolean
|
|
16
10
|
campaign?: Campaign
|
|
17
|
-
changeTranche: (tranche: TrancheType) => void
|
|
18
11
|
handleClose: () => void
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
export function Evaluation({
|
|
22
15
|
poolInfo,
|
|
23
|
-
isUniTranche,
|
|
24
16
|
pointsTestnetExperience,
|
|
25
17
|
campaign,
|
|
26
|
-
changeTranche,
|
|
27
18
|
handleClose,
|
|
28
19
|
}: Props): React.ReactElement | null {
|
|
29
20
|
if (poolInfo.KYC?.Persona) {
|
|
30
|
-
const solanChainInfo = SOLANA_CHAIN_INFO[poolInfo.chainId]
|
|
31
|
-
|
|
32
21
|
return (
|
|
33
22
|
<PersonaEvaluation
|
|
34
23
|
poolInfo={{
|
|
@@ -37,15 +26,9 @@ export function Evaluation({
|
|
|
37
26
|
seniorTrancheVault: poolInfo.seniorTrancheMint,
|
|
38
27
|
}}
|
|
39
28
|
handleClose={handleClose}
|
|
40
|
-
isUniTranche={isUniTranche}
|
|
41
29
|
pointsTestnetExperience={pointsTestnetExperience}
|
|
42
30
|
campaign={campaign}
|
|
43
|
-
chainSpecificData={{
|
|
44
|
-
huma_program_id: solanChainInfo.poolProgram,
|
|
45
|
-
pool_id: poolInfo.poolId,
|
|
46
|
-
}}
|
|
47
31
|
chainType={CHAIN_TYPE.SOLANA}
|
|
48
|
-
changeTranche={changeTranche}
|
|
49
32
|
/>
|
|
50
33
|
)
|
|
51
34
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CHAIN_TYPE,
|
|
3
|
+
SOLANA_CHAIN_INFO,
|
|
4
|
+
SolanaPoolInfo,
|
|
5
|
+
TrancheType,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
7
|
+
import React from 'react'
|
|
8
|
+
|
|
9
|
+
import { ApproveLenderBase } from '../components/ApproveLenderBase'
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
poolInfo: SolanaPoolInfo
|
|
13
|
+
isUniTranche: boolean
|
|
14
|
+
changeTranche: (tranche: TrancheType) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function ApproveLender({
|
|
18
|
+
poolInfo,
|
|
19
|
+
isUniTranche,
|
|
20
|
+
changeTranche,
|
|
21
|
+
}: Props): React.ReactElement | null {
|
|
22
|
+
const solanaChainInfo = SOLANA_CHAIN_INFO[poolInfo.chainId]
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<ApproveLenderBase
|
|
26
|
+
juniorTrancheVault={poolInfo.juniorTrancheMint}
|
|
27
|
+
seniorTrancheVault={poolInfo.seniorTrancheMint}
|
|
28
|
+
isUniTranche={isUniTranche}
|
|
29
|
+
chainType={CHAIN_TYPE.SOLANA}
|
|
30
|
+
chainSpecificData={{
|
|
31
|
+
huma_program_id: solanaChainInfo.poolProgram,
|
|
32
|
+
pool_id: poolInfo.poolId,
|
|
33
|
+
}}
|
|
34
|
+
changeTranche={changeTranche}
|
|
35
|
+
/>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -19,11 +19,12 @@ import { ErrorModal } from '../../ErrorModal'
|
|
|
19
19
|
import { PointsEarned } from '../../PointsEarned'
|
|
20
20
|
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
21
21
|
import { Evaluation } from './1-Evaluation'
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
22
|
+
import { ApproveLender } from './2-ApproveLender'
|
|
23
|
+
import { ChooseTranche } from './3-ChooseTranche'
|
|
24
|
+
import { ChooseAmount } from './4-ChooseAmount'
|
|
25
|
+
import { ApproveAllowance } from './5-ApproveAllowance'
|
|
26
|
+
import { Transfer } from './6-Transfer'
|
|
27
|
+
import { Success } from './7-Success'
|
|
27
28
|
|
|
28
29
|
export interface Campaign {
|
|
29
30
|
id: string
|
|
@@ -72,6 +73,11 @@ export function SolanaLendSupply({
|
|
|
72
73
|
return
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
if (!isUniTranche && (!juniorLenderApproved || !seniorLenderApproved)) {
|
|
77
|
+
dispatch(setStep(WIDGET_STEP.ApproveLender))
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
75
81
|
if (juniorLenderApproved && !seniorLenderApproved) {
|
|
76
82
|
setSelectedTranche('junior')
|
|
77
83
|
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
@@ -97,6 +103,7 @@ export function SolanaLendSupply({
|
|
|
97
103
|
juniorLenderApproved,
|
|
98
104
|
seniorLenderApproved,
|
|
99
105
|
isLoadingTokenAccount,
|
|
106
|
+
isUniTranche,
|
|
100
107
|
])
|
|
101
108
|
|
|
102
109
|
if (isLoadingLenderAccounts || isLoadingTokenAccount) {
|
|
@@ -121,10 +128,15 @@ export function SolanaLendSupply({
|
|
|
121
128
|
{step === WIDGET_STEP.Evaluation && (
|
|
122
129
|
<Evaluation
|
|
123
130
|
poolInfo={poolInfo}
|
|
124
|
-
isUniTranche={!!isUniTranche}
|
|
125
131
|
pointsTestnetExperience={pointsTestnetExperience}
|
|
126
132
|
campaign={poolState.campaign}
|
|
127
133
|
handleClose={handleClose}
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
136
|
+
{step === WIDGET_STEP.ApproveLender && (
|
|
137
|
+
<ApproveLender
|
|
138
|
+
poolInfo={poolInfo}
|
|
139
|
+
isUniTranche={!!isUniTranche}
|
|
128
140
|
changeTranche={setSelectedTranche}
|
|
129
141
|
/>
|
|
130
142
|
)}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CHAIN_TYPE,
|
|
3
|
-
CloseModalOptions,
|
|
4
|
-
PoolInfoV2,
|
|
5
|
-
TrancheType,
|
|
6
|
-
} from '@huma-finance/shared'
|
|
1
|
+
import { CHAIN_TYPE, CloseModalOptions, PoolInfoV2 } from '@huma-finance/shared'
|
|
7
2
|
import React from 'react'
|
|
8
3
|
|
|
9
4
|
import { Campaign } from '.'
|
|
@@ -12,19 +7,15 @@ import { SecuritizeEvaluation } from '../components/SecuritizeEvaluation'
|
|
|
12
7
|
|
|
13
8
|
type Props = {
|
|
14
9
|
poolInfo: PoolInfoV2
|
|
15
|
-
isUniTranche: boolean
|
|
16
10
|
pointsTestnetExperience: boolean
|
|
17
11
|
campaign?: Campaign
|
|
18
|
-
changeTranche: (tranche: TrancheType) => void
|
|
19
12
|
handleClose: (options?: CloseModalOptions) => void
|
|
20
13
|
}
|
|
21
14
|
|
|
22
15
|
export function Evaluation({
|
|
23
16
|
poolInfo,
|
|
24
|
-
isUniTranche,
|
|
25
17
|
campaign,
|
|
26
18
|
pointsTestnetExperience,
|
|
27
|
-
changeTranche,
|
|
28
19
|
handleClose,
|
|
29
20
|
}: Props): React.ReactElement | null {
|
|
30
21
|
if (poolInfo.KYC?.Securitize) {
|
|
@@ -37,11 +28,9 @@ export function Evaluation({
|
|
|
37
28
|
<PersonaEvaluation
|
|
38
29
|
poolInfo={poolInfo}
|
|
39
30
|
handleClose={handleClose}
|
|
40
|
-
isUniTranche={isUniTranche}
|
|
41
31
|
pointsTestnetExperience={pointsTestnetExperience}
|
|
42
32
|
campaign={campaign}
|
|
43
33
|
chainType={CHAIN_TYPE.EVM}
|
|
44
|
-
changeTranche={changeTranche}
|
|
45
34
|
/>
|
|
46
35
|
)
|
|
47
36
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CHAIN_TYPE, PoolInfoV2, TrancheType } from '@huma-finance/shared'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { ApproveLenderBase } from '../components/ApproveLenderBase'
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
poolInfo: PoolInfoV2
|
|
8
|
+
isUniTranche: boolean
|
|
9
|
+
changeTranche: (tranche: TrancheType) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ApproveLender({
|
|
13
|
+
poolInfo,
|
|
14
|
+
isUniTranche,
|
|
15
|
+
changeTranche,
|
|
16
|
+
}: Props): React.ReactElement {
|
|
17
|
+
return (
|
|
18
|
+
<ApproveLenderBase
|
|
19
|
+
juniorTrancheVault={poolInfo.juniorTrancheVault}
|
|
20
|
+
seniorTrancheVault={poolInfo.seniorTrancheVault}
|
|
21
|
+
isUniTranche={isUniTranche}
|
|
22
|
+
chainType={CHAIN_TYPE.EVM}
|
|
23
|
+
changeTranche={changeTranche}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -23,11 +23,12 @@ import { PointsEarned } from '../../PointsEarned'
|
|
|
23
23
|
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
24
24
|
import { ChooseTranche } from './1-ChooseTranche'
|
|
25
25
|
import { Evaluation } from './2-Evaluation'
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
26
|
+
import { ApproveLender } from './3-ApproveLender'
|
|
27
|
+
import { ChooseAmount } from './4-ChooseAmount'
|
|
28
|
+
import { ApproveAllowance } from './5-ApproveAllowance'
|
|
29
|
+
import { Transfer } from './6-Transfer'
|
|
30
|
+
import { Success } from './7-Success'
|
|
31
|
+
import { Notifications } from './8-Notifications'
|
|
31
32
|
|
|
32
33
|
export interface Campaign {
|
|
33
34
|
id: string
|
|
@@ -87,11 +88,11 @@ export function LendSupplyV2({
|
|
|
87
88
|
|
|
88
89
|
useEffect(() => {
|
|
89
90
|
if (!step && poolInfo && lenderApproveStatusFetched && lpConfig) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
!isUniTranche &&
|
|
93
|
-
|
|
94
|
-
) {
|
|
91
|
+
const uniTrancheNotEvaluated = isUniTranche && !lenderApprovedJunior
|
|
92
|
+
const tranchesNotEvaluated =
|
|
93
|
+
!isUniTranche && !lenderApprovedJunior && !lenderApprovedSenior
|
|
94
|
+
|
|
95
|
+
if (uniTrancheNotEvaluated || tranchesNotEvaluated) {
|
|
95
96
|
if (poolInfo.KYC) {
|
|
96
97
|
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
97
98
|
} else if (poolInfo.supplyLink) {
|
|
@@ -101,15 +102,8 @@ export function LendSupplyV2({
|
|
|
101
102
|
return
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
if (
|
|
105
|
-
|
|
106
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (lenderApprovedSenior && !lenderApprovedJunior) {
|
|
111
|
-
setSelectedTranche('senior')
|
|
112
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
105
|
+
if (!isUniTranche && (!lenderApprovedJunior || !lenderApprovedSenior)) {
|
|
106
|
+
dispatch(setStep(WIDGET_STEP.ApproveLender))
|
|
113
107
|
return
|
|
114
108
|
}
|
|
115
109
|
|
|
@@ -137,7 +131,6 @@ export function LendSupplyV2({
|
|
|
137
131
|
lenderApprovedSenior,
|
|
138
132
|
lpConfig,
|
|
139
133
|
poolInfo,
|
|
140
|
-
campaign,
|
|
141
134
|
step,
|
|
142
135
|
])
|
|
143
136
|
|
|
@@ -178,12 +171,17 @@ export function LendSupplyV2({
|
|
|
178
171
|
<Evaluation
|
|
179
172
|
poolInfo={poolInfo}
|
|
180
173
|
handleClose={handleClose}
|
|
181
|
-
isUniTranche={isUniTranche}
|
|
182
|
-
changeTranche={setSelectedTranche}
|
|
183
174
|
pointsTestnetExperience={pointsTestnetExperience}
|
|
184
175
|
campaign={campaign}
|
|
185
176
|
/>
|
|
186
177
|
)}
|
|
178
|
+
{step === WIDGET_STEP.ApproveLender && (
|
|
179
|
+
<ApproveLender
|
|
180
|
+
poolInfo={poolInfo}
|
|
181
|
+
isUniTranche={isUniTranche}
|
|
182
|
+
changeTranche={setSelectedTranche}
|
|
183
|
+
/>
|
|
184
|
+
)}
|
|
187
185
|
{step === WIDGET_STEP.ChooseAmount && (
|
|
188
186
|
<ChooseAmount
|
|
189
187
|
poolInfo={poolInfo}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|