@huma-finance/widgets 0.0.59-beta.494 → 0.0.59-beta.495
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/API.md +2 -0
- package/dist/cjs/index.cjs +967 -191
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +968 -193
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/src/components/ChooseAmountModal.tsx +2 -3
- package/src/components/ConfirmTransferModal.tsx +2 -2
- package/src/components/ErrorModal.tsx +1 -1
- package/src/components/InputAmountModal.tsx +2 -2
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +31 -329
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +58 -9
- package/src/components/Lend/supplyV2/6-Success.tsx +49 -6
- package/src/components/Lend/supplyV2/7-Notifications.tsx +22 -3
- package/src/components/Lend/supplyV2/8-PointsEarned.tsx +231 -0
- package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +442 -0
- package/src/components/Lend/supplyV2/components/SecuritizeEvaluation.tsx +345 -0
- package/src/components/Lend/supplyV2/index.tsx +67 -5
- package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +1 -1
- package/src/components/SignIn.tsx +7 -2
- package/src/components/TxDoneModal.tsx +21 -2
- package/src/components/humaModal/HumaModal.tsx +1 -0
- package/src/components/humaModal/HumaModalHeader.tsx +1 -0
- package/src/components/icons/congratulations.svg +54 -0
- package/src/components/icons/huma-points.svg +15 -0
- package/src/components/icons/index.tsx +15 -0
- package/src/components/icons/ribbon.svg +9 -0
- package/src/store/widgets.reducers.ts +0 -1
- package/src/store/widgets.store.ts +1 -0
- package/src/theme/palette.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.59-beta.
|
|
3
|
+
"version": "0.0.59-beta.495+251ec58",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@ethersproject/experimental": "^5.7.0",
|
|
31
31
|
"@ethersproject/providers": "^5.6.0",
|
|
32
32
|
"@ethersproject/units": "^5.6.0",
|
|
33
|
-
"@huma-finance/sdk": "^0.0.
|
|
34
|
-
"@huma-finance/shared": "^0.0.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.59-beta.495+251ec58",
|
|
34
|
+
"@huma-finance/shared": "^0.0.59-beta.495+251ec58",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
37
37
|
"@mui/styles": "^5.0.2",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"history": "^5.3.0",
|
|
64
64
|
"jotai": "^1.13.1",
|
|
65
65
|
"moment": "^2.29.4",
|
|
66
|
+
"persona": "^5.1.0",
|
|
66
67
|
"qrcode": "^1.5.1",
|
|
67
68
|
"query-string": "^7.1.1",
|
|
68
69
|
"react": "^18.2.0",
|
|
@@ -137,6 +138,7 @@
|
|
|
137
138
|
"@typechain/ethers-v5": "^10.1.0",
|
|
138
139
|
"@types/jest": "^27.5.2",
|
|
139
140
|
"@types/node": "^17.0.45",
|
|
141
|
+
"@types/persona": "^0.0.32",
|
|
140
142
|
"@types/qrcode": "^1.5.0",
|
|
141
143
|
"@types/react": "^18.0.21",
|
|
142
144
|
"@types/react-dom": "^18.0.6",
|
|
@@ -193,5 +195,5 @@
|
|
|
193
195
|
"optionalDependencies": {
|
|
194
196
|
"encoding": "^0.1.13"
|
|
195
197
|
},
|
|
196
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "251ec58e00a51c114330cb054098fdb9268220e3"
|
|
197
199
|
}
|
|
@@ -134,7 +134,7 @@ export function ChooseAmountModal({
|
|
|
134
134
|
margin-bottom: ${theme.spacing(7)};
|
|
135
135
|
&.MuiSlider-root {
|
|
136
136
|
height: 8px !important;
|
|
137
|
-
color:
|
|
137
|
+
color: ${theme.palette.text.primary};
|
|
138
138
|
}
|
|
139
139
|
& .MuiSlider-track {
|
|
140
140
|
height: 8px !important;
|
|
@@ -158,8 +158,7 @@ export function ChooseAmountModal({
|
|
|
158
158
|
`,
|
|
159
159
|
divider: css`
|
|
160
160
|
margin: ${theme.spacing(2, 0)};
|
|
161
|
-
|
|
162
|
-
border-color: #e9e3f1;
|
|
161
|
+
border-color: ${theme.palette.divider};
|
|
163
162
|
`,
|
|
164
163
|
okButton: css`
|
|
165
164
|
font-weight: 700;
|
|
@@ -53,7 +53,7 @@ export function ConfirmTransferModal({
|
|
|
53
53
|
background: #f9f8fa;
|
|
54
54
|
border-radius: 4px;
|
|
55
55
|
font-size: 16px;
|
|
56
|
-
color: ${theme.palette.text.
|
|
56
|
+
color: ${theme.palette.text.secondary};
|
|
57
57
|
padding: ${theme.spacing(3, 2)};
|
|
58
58
|
margin-bottom: ${theme.spacing(1)};
|
|
59
59
|
position: relative;
|
|
@@ -86,7 +86,7 @@ export function ConfirmTransferModal({
|
|
|
86
86
|
animation-iteration-count: infinite;
|
|
87
87
|
animation-timing-function: linear;
|
|
88
88
|
|
|
89
|
-
color:
|
|
89
|
+
color: ${theme.palette.primary.main};
|
|
90
90
|
position: absolute;
|
|
91
91
|
margin: auto;
|
|
92
92
|
top: 0;
|
|
@@ -1,346 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
configUtil,
|
|
5
|
-
DocSignatureStatus,
|
|
6
|
-
IdentityService,
|
|
7
|
-
KYCCopy,
|
|
8
|
-
PoolInfoV2,
|
|
9
|
-
timeUtil,
|
|
10
|
-
useAuthErrorHandling,
|
|
11
|
-
useParamsSearch,
|
|
12
|
-
VerificationStatusResult,
|
|
13
|
-
} from '@huma-finance/shared'
|
|
14
|
-
import { Box, css, useTheme } from '@mui/material'
|
|
15
|
-
import { useWeb3React } from '@web3-react/core'
|
|
16
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
1
|
+
import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
|
|
2
|
+
import { BigNumber } from 'ethers'
|
|
3
|
+
import React from 'react'
|
|
17
4
|
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { HumaSnackBar } from '../../HumaSnackBar'
|
|
22
|
-
import { ApproveLenderImg } from '../../images'
|
|
23
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
24
|
-
import { WrapperModal } from '../../WrapperModal'
|
|
25
|
-
|
|
26
|
-
const LoadingCopiesByType: {
|
|
27
|
-
[key: string]: {
|
|
28
|
-
description: string
|
|
29
|
-
}
|
|
30
|
-
} = {
|
|
31
|
-
verificationStatus: {
|
|
32
|
-
description: `Checking your verification status...`,
|
|
33
|
-
},
|
|
34
|
-
sendDocSignatureLink: {
|
|
35
|
-
description: `Sending signature link...`,
|
|
36
|
-
},
|
|
37
|
-
}
|
|
5
|
+
import { Campaign } from '.'
|
|
6
|
+
import { PersonaEvaluation } from './components/PersonaEvaluation'
|
|
7
|
+
import { SecuritizeEvaluation } from './components/SecuritizeEvaluation'
|
|
38
8
|
|
|
39
9
|
type Props = {
|
|
40
10
|
poolInfo: PoolInfoV2
|
|
11
|
+
isUniTranche: boolean
|
|
12
|
+
minDepositAmount: BigNumber
|
|
13
|
+
pointsTestnetExperience: boolean
|
|
14
|
+
campaign?: Campaign
|
|
15
|
+
changeTranche: (tranche: TrancheType) => void
|
|
41
16
|
handleClose: () => void
|
|
42
17
|
}
|
|
43
18
|
|
|
44
19
|
export function Evaluation({
|
|
45
20
|
poolInfo,
|
|
21
|
+
isUniTranche,
|
|
22
|
+
minDepositAmount,
|
|
23
|
+
campaign,
|
|
24
|
+
pointsTestnetExperience,
|
|
25
|
+
changeTranche,
|
|
46
26
|
handleClose,
|
|
47
27
|
}: Props): React.ReactElement | null {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const { kycProvider, code, kycPool } = useParamsSearch()
|
|
53
|
-
const {
|
|
54
|
-
isWalletOwnershipVerified,
|
|
55
|
-
setError: setAuthError,
|
|
56
|
-
error: authError,
|
|
57
|
-
} = useAuthErrorHandling(isDev)
|
|
58
|
-
const [loadingType, setLoadingType] = useState<
|
|
59
|
-
'verificationStatus' | 'sendDocSignatureLink'
|
|
60
|
-
>()
|
|
61
|
-
const KYCCopies = poolInfo.KYC!
|
|
62
|
-
const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
|
|
63
|
-
const [KYCVerifyStatus, setKYCVerifyStatus] =
|
|
64
|
-
useState<VerificationStatusResult>()
|
|
65
|
-
const [docSignatureStatus, setDocSignatureStatus] =
|
|
66
|
-
useState<DocSignatureStatus['status']>()
|
|
67
|
-
const docSignatureCompleted = docSignatureStatus === 'completed'
|
|
68
|
-
const [openSnackBar, setOpenSnackBar] = useState<boolean>(false)
|
|
69
|
-
|
|
70
|
-
const styles = {
|
|
71
|
-
iconWrapper: css`
|
|
72
|
-
${theme.cssMixins.rowCentered};
|
|
73
|
-
margin-top: ${theme.spacing(8)};
|
|
74
|
-
& > img {
|
|
75
|
-
width: 144px;
|
|
76
|
-
}
|
|
77
|
-
`,
|
|
78
|
-
description: css`
|
|
79
|
-
${theme.cssMixins.rowCentered};
|
|
80
|
-
margin-top: ${theme.spacing(10)};
|
|
81
|
-
padding: ${theme.spacing(0, 2)};
|
|
82
|
-
font-weight: 400;
|
|
83
|
-
font-size: 16px;
|
|
84
|
-
color: ${theme.palette.text.secondary};
|
|
85
|
-
`,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const { envelopeKey, envelopeLastQueryTimeKey, envelopeDocuSignStatusKey } =
|
|
89
|
-
useMemo(() => {
|
|
90
|
-
const envelopeKey = `${poolInfo.pool.toLowerCase()}-${account?.toLowerCase()}`
|
|
91
|
-
const envelopeLastQueryTimeKey = `${envelopeKey}-last-query-time`
|
|
92
|
-
const envelopeDocuSignStatusKey = `${envelopeKey}-docuSign-status`
|
|
93
|
-
return {
|
|
94
|
-
envelopeKey,
|
|
95
|
-
envelopeLastQueryTimeKey,
|
|
96
|
-
envelopeDocuSignStatusKey,
|
|
97
|
-
}
|
|
98
|
-
}, [account, poolInfo.pool])
|
|
99
|
-
|
|
100
|
-
// DocuSign GET requests to any specific URL can be called not more often than once every 15 minutes.
|
|
101
|
-
// https://developers.docusign.com/platform/api-guidelines/#:~:text=Polling,not%20once%20every%2010%20minutes
|
|
102
|
-
const checkGetDocSignatureStatusIsAvailable = useCallback(() => {
|
|
103
|
-
const lastQueryTime = localStorage.getItem(envelopeLastQueryTimeKey)
|
|
104
|
-
if (!lastQueryTime) {
|
|
105
|
-
return true
|
|
106
|
-
}
|
|
107
|
-
const lastQueryTimeNumber = Number(lastQueryTime)
|
|
108
|
-
const now = timeUtil.getUnixTimestamp()
|
|
109
|
-
const diff = now - lastQueryTimeNumber
|
|
110
|
-
const fifteenMinutes = 15 * 60
|
|
111
|
-
return diff > fifteenMinutes
|
|
112
|
-
}, [envelopeLastQueryTimeKey])
|
|
113
|
-
|
|
114
|
-
useEffect(() => {
|
|
115
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
116
|
-
const docuSignStatus = localStorage.getItem(envelopeDocuSignStatusKey)
|
|
117
|
-
setDocSignatureStatus(docuSignStatus as DocSignatureStatus['status'])
|
|
118
|
-
if (docuSignStatus === 'completed') {
|
|
119
|
-
setKYCCopy(KYCCopies.docUnderReview)
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const fetchData = async () => {
|
|
124
|
-
try {
|
|
125
|
-
if (kycProvider && kycPool && account && chainId) {
|
|
126
|
-
setLoadingType('verificationStatus')
|
|
127
|
-
await IdentityService.onboard(
|
|
128
|
-
account,
|
|
129
|
-
code as string,
|
|
130
|
-
kycPool as string,
|
|
131
|
-
chainId,
|
|
132
|
-
isDev,
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
} catch (e) {
|
|
136
|
-
try {
|
|
137
|
-
setAuthError(e)
|
|
138
|
-
setKYCCopy(KYCCopies.signInRequired)
|
|
139
|
-
} catch (e) {
|
|
140
|
-
// The repeated call will throw an error of 401, so we can ignore it.
|
|
141
|
-
console.log(e)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
try {
|
|
146
|
-
if (account && chainId) {
|
|
147
|
-
setLoadingType('verificationStatus')
|
|
148
|
-
const verificationStatus =
|
|
149
|
-
await IdentityService.getVerificationStatus(
|
|
150
|
-
account,
|
|
151
|
-
poolInfo.pool,
|
|
152
|
-
chainId,
|
|
153
|
-
isDev,
|
|
154
|
-
)
|
|
155
|
-
setKYCVerifyStatus(verificationStatus)
|
|
156
|
-
if (verificationStatus.isVerified) {
|
|
157
|
-
const envelopeId = localStorage.getItem(envelopeKey)
|
|
158
|
-
if (!envelopeId) {
|
|
159
|
-
setKYCCopy(KYCCopies.emailSignatureLink)
|
|
160
|
-
} else if (!checkGetDocSignatureStatusIsAvailable()) {
|
|
161
|
-
setKYCCopy(KYCCopies.resendSignatureLink)
|
|
162
|
-
} else {
|
|
163
|
-
const { status } = await IdentityService.getDocSignatureStatus(
|
|
164
|
-
envelopeId,
|
|
165
|
-
chainId,
|
|
166
|
-
isDev,
|
|
167
|
-
)
|
|
168
|
-
localStorage.setItem(
|
|
169
|
-
envelopeLastQueryTimeKey,
|
|
170
|
-
String(timeUtil.getUnixTimestamp()),
|
|
171
|
-
)
|
|
172
|
-
localStorage.setItem(envelopeDocuSignStatusKey, status)
|
|
173
|
-
setDocSignatureStatus(status)
|
|
174
|
-
if (status === 'completed') {
|
|
175
|
-
setKYCCopy(KYCCopies.docUnderReview)
|
|
176
|
-
// For voided and declined status, we need to send a new link
|
|
177
|
-
} else if (['voided', 'declined'].includes(status)) {
|
|
178
|
-
localStorage.removeItem(envelopeKey)
|
|
179
|
-
localStorage.removeItem(envelopeLastQueryTimeKey)
|
|
180
|
-
setKYCCopy(KYCCopies.emailSignatureLink)
|
|
181
|
-
} else {
|
|
182
|
-
setKYCCopy(KYCCopies.resendSignatureLink)
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
setKYCCopy(KYCCopies.verifyIdentity)
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
} catch (e: unknown) {
|
|
190
|
-
try {
|
|
191
|
-
setAuthError(e)
|
|
192
|
-
setKYCCopy(KYCCopies.signInRequired)
|
|
193
|
-
} catch (e) {
|
|
194
|
-
console.error(e)
|
|
195
|
-
dispatch(
|
|
196
|
-
setError({
|
|
197
|
-
errorMessage: 'Something went wrong, please try again later.',
|
|
198
|
-
}),
|
|
199
|
-
)
|
|
200
|
-
}
|
|
201
|
-
} finally {
|
|
202
|
-
setLoadingType(undefined)
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
fetchData()
|
|
206
|
-
}, [
|
|
207
|
-
KYCCopies.docUnderReview,
|
|
208
|
-
KYCCopies.emailSignatureLink,
|
|
209
|
-
KYCCopies.resendSignatureLink,
|
|
210
|
-
KYCCopies.signInRequired,
|
|
211
|
-
KYCCopies.verifyIdentity,
|
|
212
|
-
account,
|
|
213
|
-
chainId,
|
|
214
|
-
checkGetDocSignatureStatusIsAvailable,
|
|
215
|
-
code,
|
|
216
|
-
dispatch,
|
|
217
|
-
envelopeDocuSignStatusKey,
|
|
218
|
-
envelopeKey,
|
|
219
|
-
envelopeLastQueryTimeKey,
|
|
220
|
-
isDev,
|
|
221
|
-
kycPool,
|
|
222
|
-
kycProvider,
|
|
223
|
-
poolInfo.pool,
|
|
224
|
-
setAuthError,
|
|
225
|
-
isWalletOwnershipVerified,
|
|
226
|
-
])
|
|
227
|
-
|
|
228
|
-
useEffect(() => {
|
|
229
|
-
if (
|
|
230
|
-
authError &&
|
|
231
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
-
[4001, 'ACTION_REJECTED'].includes((authError as any).code)
|
|
233
|
-
) {
|
|
234
|
-
dispatch(
|
|
235
|
-
setError({
|
|
236
|
-
errorMessage: 'User has rejected the transaction.',
|
|
237
|
-
}),
|
|
238
|
-
)
|
|
239
|
-
}
|
|
240
|
-
}, [authError, dispatch])
|
|
241
|
-
|
|
242
|
-
const approveLender = async () => {
|
|
243
|
-
if (docSignatureCompleted) {
|
|
244
|
-
handleClose()
|
|
245
|
-
return
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const { isNotOnboarded, isVerified } = KYCVerifyStatus || {}
|
|
249
|
-
|
|
250
|
-
if (!isVerified) {
|
|
251
|
-
const issuerId = CHAINS[chainId!].isTestnet
|
|
252
|
-
? '53a66b32-583e-40e7-ba90-baf516d2cadd'
|
|
253
|
-
: '5557baf5-d3c2-4c80-b522-c05a11c6e586'
|
|
254
|
-
const baseUrl = configUtil.getKYCProviderBaseUrl(
|
|
255
|
-
poolInfo.KYC!.provider,
|
|
256
|
-
chainId!,
|
|
257
|
-
)
|
|
258
|
-
const originUrl = window.location.href.split('?')[0]
|
|
259
|
-
const redirectUrl = `${originUrl}?poolName=${
|
|
260
|
-
poolInfo.poolName
|
|
261
|
-
}&kycProvider=${poolInfo.KYC!.provider}&kycPool=${poolInfo.pool}`
|
|
262
|
-
const providerAuthorizeUrl = `${baseUrl}/#/authorize?issuerId=${issuerId}&scope=details&details=verification&redirectUrl=${redirectUrl}`
|
|
263
|
-
window.location.href = isNotOnboarded ? providerAuthorizeUrl : baseUrl
|
|
264
|
-
} else {
|
|
265
|
-
const envelopeId = localStorage.getItem(envelopeKey)
|
|
266
|
-
try {
|
|
267
|
-
setLoadingType('sendDocSignatureLink')
|
|
268
|
-
if (!envelopeId) {
|
|
269
|
-
const { envelopeId } = await IdentityService.requestDocSignature(
|
|
270
|
-
account!,
|
|
271
|
-
chainId!,
|
|
272
|
-
isDev,
|
|
273
|
-
)
|
|
274
|
-
localStorage.setItem(envelopeKey, envelopeId)
|
|
275
|
-
localStorage.setItem(
|
|
276
|
-
envelopeLastQueryTimeKey,
|
|
277
|
-
String(timeUtil.getUnixTimestamp()),
|
|
278
|
-
)
|
|
279
|
-
setOpenSnackBar(true)
|
|
280
|
-
setKYCCopy(KYCCopies.resendSignatureLink)
|
|
281
|
-
} else {
|
|
282
|
-
await IdentityService.resendDocSignatureLink(
|
|
283
|
-
envelopeId,
|
|
284
|
-
chainId!,
|
|
285
|
-
isDev,
|
|
286
|
-
)
|
|
287
|
-
setOpenSnackBar(true)
|
|
288
|
-
}
|
|
289
|
-
} catch (e: unknown) {
|
|
290
|
-
try {
|
|
291
|
-
const { envelopeId } = await IdentityService.requestDocSignature(
|
|
292
|
-
account!,
|
|
293
|
-
chainId!,
|
|
294
|
-
isDev,
|
|
295
|
-
)
|
|
296
|
-
localStorage.setItem(envelopeKey, envelopeId)
|
|
297
|
-
localStorage.setItem(
|
|
298
|
-
envelopeLastQueryTimeKey,
|
|
299
|
-
String(timeUtil.getUnixTimestamp()),
|
|
300
|
-
)
|
|
301
|
-
setOpenSnackBar(true)
|
|
302
|
-
setKYCCopy(KYCCopies.resendSignatureLink)
|
|
303
|
-
} catch (e) {
|
|
304
|
-
setAuthError(e)
|
|
305
|
-
setKYCCopy(KYCCopies.signInRequired)
|
|
306
|
-
}
|
|
307
|
-
} finally {
|
|
308
|
-
setLoadingType(undefined)
|
|
309
|
-
}
|
|
310
|
-
}
|
|
28
|
+
if (poolInfo.KYC?.Securitize) {
|
|
29
|
+
return (
|
|
30
|
+
<SecuritizeEvaluation poolInfo={poolInfo} handleClose={handleClose} />
|
|
31
|
+
)
|
|
311
32
|
}
|
|
312
|
-
|
|
313
|
-
const getEmailLinkSentSnackbar = () => (
|
|
314
|
-
<HumaSnackBar
|
|
315
|
-
open={openSnackBar}
|
|
316
|
-
title='Signature Link Sent'
|
|
317
|
-
message='The secure signature session link has been sent to you via email.'
|
|
318
|
-
severity='success'
|
|
319
|
-
onClose={() => setOpenSnackBar(false)}
|
|
320
|
-
/>
|
|
321
|
-
)
|
|
322
|
-
|
|
323
|
-
if (!loadingType) {
|
|
33
|
+
if (poolInfo.KYC?.Persona) {
|
|
324
34
|
return (
|
|
325
|
-
<
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
{
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
)}
|
|
335
|
-
{getEmailLinkSentSnackbar()}
|
|
336
|
-
</WrapperModal>
|
|
35
|
+
<PersonaEvaluation
|
|
36
|
+
poolInfo={poolInfo}
|
|
37
|
+
handleClose={handleClose}
|
|
38
|
+
isUniTranche={isUniTranche}
|
|
39
|
+
pointsTestnetExperience={pointsTestnetExperience}
|
|
40
|
+
campaign={campaign}
|
|
41
|
+
minDepositAmount={minDepositAmount}
|
|
42
|
+
changeTranche={changeTranche}
|
|
43
|
+
/>
|
|
337
44
|
)
|
|
338
45
|
}
|
|
339
46
|
|
|
340
|
-
return
|
|
341
|
-
<LoadingModal
|
|
342
|
-
title='Lender Approval'
|
|
343
|
-
description={LoadingCopiesByType[loadingType].description}
|
|
344
|
-
/>
|
|
345
|
-
)
|
|
47
|
+
return null
|
|
346
48
|
}
|
|
@@ -1,37 +1,49 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CampaignService,
|
|
3
|
+
checkIsDev,
|
|
4
|
+
formatNumber,
|
|
2
5
|
PoolInfoV2,
|
|
3
6
|
TrancheType,
|
|
4
7
|
UnderlyingTokenInfo,
|
|
5
|
-
|
|
6
|
-
useLPConfigV2,
|
|
8
|
+
useDebouncedValue,
|
|
7
9
|
usePoolSafeAllowanceV2,
|
|
8
10
|
usePoolUnderlyingTokenBalanceV2,
|
|
9
11
|
} from '@huma-finance/shared'
|
|
10
12
|
import { useWeb3React } from '@web3-react/core'
|
|
11
13
|
import { BigNumber, ethers } from 'ethers'
|
|
12
|
-
import React, { useState } from 'react'
|
|
14
|
+
import React, { useEffect, useState } from 'react'
|
|
13
15
|
|
|
14
16
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
15
17
|
import { setStep, setSupplyAmount } from '../../../store/widgets.reducers'
|
|
16
18
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
17
19
|
import { InputAmountModal } from '../../InputAmountModal'
|
|
18
|
-
import {
|
|
20
|
+
import { Campaign } from '.'
|
|
19
21
|
|
|
20
22
|
type Props = {
|
|
21
23
|
poolInfo: PoolInfoV2
|
|
22
24
|
poolUnderlyingToken: UnderlyingTokenInfo
|
|
23
25
|
selectedTranche: TrancheType | undefined
|
|
26
|
+
isUniTranche: boolean
|
|
27
|
+
pointsTestnetExperience: boolean
|
|
28
|
+
campaign?: Campaign
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
export function ChooseAmount({
|
|
27
32
|
poolInfo,
|
|
28
33
|
poolUnderlyingToken,
|
|
29
34
|
selectedTranche,
|
|
35
|
+
isUniTranche,
|
|
36
|
+
pointsTestnetExperience,
|
|
37
|
+
campaign,
|
|
30
38
|
}: Props): React.ReactElement | null {
|
|
39
|
+
const isDev = checkIsDev()
|
|
31
40
|
const dispatch = useAppDispatch()
|
|
32
41
|
const { account, provider } = useWeb3React()
|
|
33
42
|
const { symbol, decimals } = poolUnderlyingToken
|
|
34
43
|
const [currentAmount, setCurrentAmount] = useState<number | string>(0)
|
|
44
|
+
const debouncedValue = useDebouncedValue(currentAmount)
|
|
45
|
+
const [campaignPoints, setCampaignPoints] = useState<number>(0)
|
|
46
|
+
const [lockupPeriodMonths, setLockupPeriodMonths] = useState<number>(0)
|
|
35
47
|
const { allowance = BigNumber.from(0) } = usePoolSafeAllowanceV2(
|
|
36
48
|
poolInfo.poolName,
|
|
37
49
|
account,
|
|
@@ -46,8 +58,42 @@ export function ChooseAmount({
|
|
|
46
58
|
balance,
|
|
47
59
|
poolUnderlyingToken.decimals,
|
|
48
60
|
)
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const getBasePoints = async () => {
|
|
64
|
+
if (campaign && selectedTranche && Number(debouncedValue) > 0) {
|
|
65
|
+
const estimatedPoints = await CampaignService.getEstimatedPoints(
|
|
66
|
+
campaign.campaignGroupId,
|
|
67
|
+
ethers.utils
|
|
68
|
+
.parseUnits(
|
|
69
|
+
String(debouncedValue),
|
|
70
|
+
poolInfo.poolUnderlyingToken.decimals,
|
|
71
|
+
)
|
|
72
|
+
.toString(),
|
|
73
|
+
isDev,
|
|
74
|
+
pointsTestnetExperience,
|
|
75
|
+
)
|
|
76
|
+
const campaignPoints = estimatedPoints.find(
|
|
77
|
+
(item) => item.campaignId === campaign.id,
|
|
78
|
+
)
|
|
79
|
+
if (campaignPoints) {
|
|
80
|
+
setCampaignPoints(campaignPoints[`${selectedTranche}TranchePoints`])
|
|
81
|
+
setLockupPeriodMonths(campaignPoints.lockupPeriodMonths)
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
setCampaignPoints(0)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
getBasePoints()
|
|
88
|
+
}, [
|
|
89
|
+
campaign,
|
|
90
|
+
debouncedValue,
|
|
91
|
+
decimals,
|
|
92
|
+
isDev,
|
|
93
|
+
pointsTestnetExperience,
|
|
94
|
+
poolInfo.poolUnderlyingToken.decimals,
|
|
95
|
+
selectedTranche,
|
|
96
|
+
])
|
|
51
97
|
|
|
52
98
|
const handleChangeAmount = (newAmount: number) => {
|
|
53
99
|
setCurrentAmount(newAmount)
|
|
@@ -65,8 +111,11 @@ export function ChooseAmount({
|
|
|
65
111
|
dispatch(setStep(step))
|
|
66
112
|
}
|
|
67
113
|
|
|
68
|
-
|
|
69
|
-
|
|
114
|
+
let info = `${formatNumber(maxAmountFormatted)} Available`
|
|
115
|
+
if (campaign && campaignPoints > 0) {
|
|
116
|
+
info = `You will earn ${formatNumber(
|
|
117
|
+
campaignPoints,
|
|
118
|
+
)} points for the entire ${lockupPeriodMonths} months right away.`
|
|
70
119
|
}
|
|
71
120
|
|
|
72
121
|
return (
|
|
@@ -79,7 +128,7 @@ export function ChooseAmount({
|
|
|
79
128
|
currentAmount={currentAmount}
|
|
80
129
|
handleChangeAmount={handleChangeAmount}
|
|
81
130
|
maxAmount={maxAmountFormatted}
|
|
82
|
-
info={
|
|
131
|
+
info={info}
|
|
83
132
|
handleAction={handleAction}
|
|
84
133
|
actionText='SUPPLY'
|
|
85
134
|
/>
|