@huma-finance/widgets 0.0.59-beta.482 → 0.0.59-beta.487
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 +0 -1
- package/dist/cjs/index.cjs +120 -407
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +123 -409
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/src/components/Activity.tsx +1 -1
- package/src/components/ApproveAllowanceModal.tsx +1 -1
- package/src/components/ApproveAllowanceModalV2.tsx +1 -1
- package/src/components/ChooseAmountModal.tsx +5 -6
- package/src/components/ConfirmTransferModal.tsx +2 -3
- package/src/components/CreditLine/borrow/1-Evaluation.tsx +3 -3
- package/src/components/ErrorModal.tsx +2 -2
- package/src/components/Factoring/FactoredList.tsx +2 -2
- package/src/components/Factoring/UpcomingList.tsx +2 -2
- package/src/components/HumaSnackBar.tsx +2 -2
- package/src/components/HumaTable.tsx +3 -3
- package/src/components/InputAmountModal.tsx +4 -4
- package/src/components/Lend/addRedemptionV2/1-ChooseTranche.tsx +2 -2
- package/src/components/Lend/supply/1-Evaluation/EvaluationEA.tsx +1 -1
- package/src/components/Lend/supply/1-Evaluation/EvaluationKYC.tsx +1 -1
- package/src/components/Lend/supplyV2/1-ChooseTranche.tsx +2 -2
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +329 -20
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +9 -3
- package/src/components/Lend/supplyV2/index.tsx +4 -37
- package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +2 -2
- package/src/components/Notifi/NotifiSubscriptionModal.tsx +1 -1
- package/src/components/ReceivableBackedCreditLine/payment/1-ChoosePaymentType.tsx +2 -2
- package/src/components/SignIn.tsx +1 -1
- package/src/components/SuperfluidFactoring/index.tsx +2 -2
- package/src/components/TxDoneModal.tsx +1 -1
- package/src/components/WrapperModal.tsx +2 -2
- package/src/components/humaModal/HumaModal.tsx +0 -1
- package/src/index.tsx +0 -2
- package/src/store/widgets.reducers.ts +1 -0
- package/src/theme/components.ts +1 -1
- package/dist/assets/output-f6156dde.css +0 -45
- package/dist/cjs/assets/output-f6156dde.css +0 -45
- package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +0 -361
- package/src/components/Lend/supplyV2/components/SecuritizeEvaluation.tsx +0 -345
- package/src/index.css +0 -61
|
@@ -1,37 +1,346 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
CHAINS,
|
|
3
|
+
checkIsDev,
|
|
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'
|
|
3
17
|
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
18
|
+
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
19
|
+
import { setError } from '../../../store/widgets.reducers'
|
|
20
|
+
import { BottomButton } from '../../BottomButton'
|
|
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
|
+
}
|
|
6
38
|
|
|
7
39
|
type Props = {
|
|
8
40
|
poolInfo: PoolInfoV2
|
|
9
|
-
isUniTranche: boolean
|
|
10
|
-
changeTranche: (tranche: TrancheType) => void
|
|
11
41
|
handleClose: () => void
|
|
12
42
|
}
|
|
13
43
|
|
|
14
44
|
export function Evaluation({
|
|
15
45
|
poolInfo,
|
|
16
|
-
isUniTranche,
|
|
17
|
-
changeTranche,
|
|
18
46
|
handleClose,
|
|
19
47
|
}: Props): React.ReactElement | null {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
48
|
+
const theme = useTheme()
|
|
49
|
+
const dispatch = useAppDispatch()
|
|
50
|
+
const isDev = checkIsDev()
|
|
51
|
+
const { account, chainId } = useWeb3React()
|
|
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: #a8a1b2;
|
|
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
|
+
}
|
|
24
311
|
}
|
|
25
|
-
|
|
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) {
|
|
26
324
|
return (
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
325
|
+
<WrapperModal title={kycCopy.title}>
|
|
326
|
+
<Box css={styles.iconWrapper}>
|
|
327
|
+
<img src={ApproveLenderImg} alt='approve-lender' />
|
|
328
|
+
</Box>
|
|
329
|
+
<Box css={styles.description}>{kycCopy.description}</Box>
|
|
330
|
+
{Boolean(kycCopy.buttonText) && (
|
|
331
|
+
<BottomButton variant='contained' onClick={approveLender}>
|
|
332
|
+
{kycCopy.buttonText}
|
|
333
|
+
</BottomButton>
|
|
334
|
+
)}
|
|
335
|
+
{getEmailLinkSentSnackbar()}
|
|
336
|
+
</WrapperModal>
|
|
33
337
|
)
|
|
34
338
|
}
|
|
35
339
|
|
|
36
|
-
return
|
|
340
|
+
return (
|
|
341
|
+
<LoadingModal
|
|
342
|
+
title='Lender Approval'
|
|
343
|
+
description={LoadingCopiesByType[loadingType].description}
|
|
344
|
+
/>
|
|
345
|
+
)
|
|
37
346
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
formatNumber,
|
|
3
2
|
PoolInfoV2,
|
|
4
3
|
TrancheType,
|
|
5
4
|
UnderlyingTokenInfo,
|
|
5
|
+
formatNumber,
|
|
6
|
+
useLPConfigV2,
|
|
6
7
|
usePoolSafeAllowanceV2,
|
|
7
8
|
usePoolUnderlyingTokenBalanceV2,
|
|
8
9
|
} from '@huma-finance/shared'
|
|
@@ -14,19 +15,18 @@ import { useAppDispatch } from '../../../hooks/useRedux'
|
|
|
14
15
|
import { setStep, setSupplyAmount } from '../../../store/widgets.reducers'
|
|
15
16
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
16
17
|
import { InputAmountModal } from '../../InputAmountModal'
|
|
18
|
+
import { LoadingModal } from '../../LoadingModal'
|
|
17
19
|
|
|
18
20
|
type Props = {
|
|
19
21
|
poolInfo: PoolInfoV2
|
|
20
22
|
poolUnderlyingToken: UnderlyingTokenInfo
|
|
21
23
|
selectedTranche: TrancheType | undefined
|
|
22
|
-
isUniTranche: boolean
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export function ChooseAmount({
|
|
26
27
|
poolInfo,
|
|
27
28
|
poolUnderlyingToken,
|
|
28
29
|
selectedTranche,
|
|
29
|
-
isUniTranche,
|
|
30
30
|
}: Props): React.ReactElement | null {
|
|
31
31
|
const dispatch = useAppDispatch()
|
|
32
32
|
const { account, provider } = useWeb3React()
|
|
@@ -46,6 +46,8 @@ export function ChooseAmount({
|
|
|
46
46
|
balance,
|
|
47
47
|
poolUnderlyingToken.decimals,
|
|
48
48
|
)
|
|
49
|
+
const lpConfig = useLPConfigV2(poolInfo.poolName, provider)
|
|
50
|
+
const isUniTranche = lpConfig?.maxSeniorJuniorRatio === 0
|
|
49
51
|
|
|
50
52
|
const handleChangeAmount = (newAmount: number) => {
|
|
51
53
|
setCurrentAmount(newAmount)
|
|
@@ -63,6 +65,10 @@ export function ChooseAmount({
|
|
|
63
65
|
dispatch(setStep(step))
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
if (!lpConfig) {
|
|
69
|
+
return <LoadingModal title='Supply' />
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
return (
|
|
67
73
|
<InputAmountModal
|
|
68
74
|
title='Enter Amount'
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
POOL_NAME,
|
|
3
3
|
TrancheType,
|
|
4
4
|
openInNewTab,
|
|
5
|
-
useLPConfigV2,
|
|
6
5
|
useLenderApprovedV2,
|
|
7
6
|
usePoolInfoV2,
|
|
8
7
|
usePoolUnderlyingTokenInfoV2,
|
|
@@ -29,20 +28,17 @@ import { Notifications } from './7-Notifications'
|
|
|
29
28
|
* Lend pool supply props
|
|
30
29
|
* @typedef {Object} LendSupplyPropsV2
|
|
31
30
|
* @property {POOL_NAME} poolName The name of the pool.
|
|
32
|
-
* @property {boolean} shouldApproveAll To check if should approve both tranches.
|
|
33
31
|
* @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
34
32
|
* @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
35
33
|
*/
|
|
36
34
|
export interface LendSupplyPropsV2 {
|
|
37
35
|
poolName: keyof typeof POOL_NAME
|
|
38
|
-
shouldApproveAll?: boolean
|
|
39
36
|
handleClose: () => void
|
|
40
37
|
handleSuccess?: (blockNumber?: number) => void
|
|
41
38
|
}
|
|
42
39
|
|
|
43
40
|
export function LendSupplyV2({
|
|
44
41
|
poolName: poolNameStr,
|
|
45
|
-
shouldApproveAll,
|
|
46
42
|
handleClose,
|
|
47
43
|
handleSuccess,
|
|
48
44
|
}: LendSupplyPropsV2): React.ReactElement | null {
|
|
@@ -53,8 +49,7 @@ export function LendSupplyV2({
|
|
|
53
49
|
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
54
50
|
const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
|
|
55
51
|
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)
|
|
56
|
-
|
|
57
|
-
const isUniTranche = lpConfig?.maxSeniorJuniorRatio === 0
|
|
52
|
+
|
|
58
53
|
const [lenderApprovedSenior] = useLenderApprovedV2(
|
|
59
54
|
poolName,
|
|
60
55
|
'senior',
|
|
@@ -72,21 +67,7 @@ export function LendSupplyV2({
|
|
|
72
67
|
lenderApprovedSenior !== undefined && lenderApprovedJunior !== undefined
|
|
73
68
|
|
|
74
69
|
useEffect(() => {
|
|
75
|
-
if (!step && poolInfo && lenderApproveStatusFetched
|
|
76
|
-
if (
|
|
77
|
-
shouldApproveAll &&
|
|
78
|
-
!isUniTranche &&
|
|
79
|
-
(!lenderApprovedJunior || !lenderApprovedSenior)
|
|
80
|
-
) {
|
|
81
|
-
if (poolInfo.KYC) {
|
|
82
|
-
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
83
|
-
} else if (poolInfo.supplyLink) {
|
|
84
|
-
openInNewTab(poolInfo.supplyLink)
|
|
85
|
-
handleClose()
|
|
86
|
-
}
|
|
87
|
-
return
|
|
88
|
-
}
|
|
89
|
-
|
|
70
|
+
if (!step && poolInfo && lenderApproveStatusFetched) {
|
|
90
71
|
if (lenderApprovedJunior && !lenderApprovedSenior) {
|
|
91
72
|
setSelectedTranche('junior')
|
|
92
73
|
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
@@ -117,22 +98,14 @@ export function LendSupplyV2({
|
|
|
117
98
|
}, [
|
|
118
99
|
dispatch,
|
|
119
100
|
handleClose,
|
|
120
|
-
isUniTranche,
|
|
121
101
|
lenderApproveStatusFetched,
|
|
122
102
|
lenderApprovedJunior,
|
|
123
103
|
lenderApprovedSenior,
|
|
124
|
-
lpConfig,
|
|
125
104
|
poolInfo,
|
|
126
|
-
shouldApproveAll,
|
|
127
105
|
step,
|
|
128
106
|
])
|
|
129
107
|
|
|
130
|
-
if (
|
|
131
|
-
!poolInfo ||
|
|
132
|
-
!poolUnderlyingToken ||
|
|
133
|
-
!lenderApproveStatusFetched ||
|
|
134
|
-
!lpConfig
|
|
135
|
-
) {
|
|
108
|
+
if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched) {
|
|
136
109
|
return (
|
|
137
110
|
<WidgetWrapper
|
|
138
111
|
isOpen
|
|
@@ -159,19 +132,13 @@ export function LendSupplyV2({
|
|
|
159
132
|
/>
|
|
160
133
|
)}
|
|
161
134
|
{step === WIDGET_STEP.Evaluation && (
|
|
162
|
-
<Evaluation
|
|
163
|
-
poolInfo={poolInfo}
|
|
164
|
-
handleClose={handleClose}
|
|
165
|
-
isUniTranche={isUniTranche}
|
|
166
|
-
changeTranche={setSelectedTranche}
|
|
167
|
-
/>
|
|
135
|
+
<Evaluation poolInfo={poolInfo} handleClose={handleClose} />
|
|
168
136
|
)}
|
|
169
137
|
{step === WIDGET_STEP.ChooseAmount && (
|
|
170
138
|
<ChooseAmount
|
|
171
139
|
poolInfo={poolInfo}
|
|
172
140
|
poolUnderlyingToken={poolUnderlyingToken}
|
|
173
141
|
selectedTranche={selectedTranche}
|
|
174
|
-
isUniTranche={isUniTranche}
|
|
175
142
|
/>
|
|
176
143
|
)}
|
|
177
144
|
{step === WIDGET_STEP.ApproveAllowance && (
|
|
@@ -80,7 +80,7 @@ export function ConfirmTransfer({
|
|
|
80
80
|
itemWrapper: css`
|
|
81
81
|
margin-top: ${theme.spacing(9)};
|
|
82
82
|
color: ${theme.palette.text.primary};
|
|
83
|
-
font-
|
|
83
|
+
font-weight: 400;
|
|
84
84
|
font-size: 16px;
|
|
85
85
|
line-height: 175%;
|
|
86
86
|
letter-spacing: 0.15px;
|
|
@@ -93,7 +93,7 @@ export function ConfirmTransfer({
|
|
|
93
93
|
`,
|
|
94
94
|
itemValue: css`
|
|
95
95
|
font-size: 20px;
|
|
96
|
-
font-
|
|
96
|
+
font-weight: 700;
|
|
97
97
|
`,
|
|
98
98
|
divider: css`
|
|
99
99
|
border-color: #eae6f0;
|
|
@@ -158,7 +158,7 @@ export function NotifiSubscriptionModal({
|
|
|
158
158
|
const styles = {
|
|
159
159
|
disclaimer: css`
|
|
160
160
|
${theme.cssMixins.rowCentered};
|
|
161
|
-
font-
|
|
161
|
+
font-weight: 400;
|
|
162
162
|
font-size: 16px;
|
|
163
163
|
color: #a8a1b2;
|
|
164
164
|
margin-top: ${theme.spacing(6)};
|
|
@@ -31,7 +31,7 @@ export function ChoosePaymentType({
|
|
|
31
31
|
const styles = {
|
|
32
32
|
subTitle: css`
|
|
33
33
|
color: ${theme.palette.text.primary} !important;
|
|
34
|
-
font-
|
|
34
|
+
font-weight: 400;
|
|
35
35
|
font-size: 16px;
|
|
36
36
|
line-height: 150%;
|
|
37
37
|
letter-spacing: 0.15px;
|
|
@@ -46,7 +46,7 @@ export function ChoosePaymentType({
|
|
|
46
46
|
margin-bottom: ${theme.spacing(1)};
|
|
47
47
|
.MuiFormControlLabel-label {
|
|
48
48
|
color: ${theme.palette.text.primary};
|
|
49
|
-
font-
|
|
49
|
+
font-weight: 400;
|
|
50
50
|
font-size: 16px;
|
|
51
51
|
line-height: 150%;
|
|
52
52
|
letter-spacing: 0.15px;
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
POOL_NAME,
|
|
6
6
|
POOL_TYPE,
|
|
7
7
|
PoolMap,
|
|
8
|
-
PoolSubgraphMap,
|
|
9
8
|
useFactoring,
|
|
10
9
|
} from '@huma-finance/shared'
|
|
11
10
|
import React from 'react'
|
|
12
11
|
|
|
12
|
+
import { SubgraphService } from '@huma-finance/sdk'
|
|
13
13
|
import { Activity } from '../Activity'
|
|
14
14
|
import { ApolloWrapper } from '../ApolloWrapper'
|
|
15
15
|
import { StreamFactoringBorrow } from '../StreamFactoring/borrow'
|
|
@@ -57,7 +57,7 @@ export function SuperfluidFactoring(): React.ReactElement {
|
|
|
57
57
|
loading={loading && actionType === 'borrow'}
|
|
58
58
|
/>
|
|
59
59
|
</ApolloWrapper>
|
|
60
|
-
<ApolloWrapper uri={
|
|
60
|
+
<ApolloWrapper uri={SubgraphService.getSubgraphUrlForChainId(chainId!)}>
|
|
61
61
|
{poolInfo && (
|
|
62
62
|
<Activity
|
|
63
63
|
poolInfo={poolInfo}
|
|
@@ -21,14 +21,14 @@ export function WrapperModal({
|
|
|
21
21
|
`,
|
|
22
22
|
header: css`
|
|
23
23
|
${theme.cssMixins.rowHCentered};
|
|
24
|
-
font-
|
|
24
|
+
font-weight: 700;
|
|
25
25
|
font-size: 20px;
|
|
26
26
|
margin-top: ${theme.spacing(-0.5)};
|
|
27
27
|
`,
|
|
28
28
|
content: css`
|
|
29
29
|
${theme.cssMixins.rowHCentered};
|
|
30
30
|
margin-top: ${theme.spacing(4)};
|
|
31
|
-
font-
|
|
31
|
+
font-weight: 400;
|
|
32
32
|
font-size: 16px;
|
|
33
33
|
line-height: 24px;
|
|
34
34
|
color: #49505b;
|
package/src/index.tsx
CHANGED
|
@@ -108,6 +108,7 @@ export const widgetSlice = createSlice({
|
|
|
108
108
|
payload,
|
|
109
109
|
}: PayloadAction<{ errorMessage: string; errorReason?: string }>,
|
|
110
110
|
) => {
|
|
111
|
+
console.trace()
|
|
111
112
|
state.errorMessage = payload.errorMessage
|
|
112
113
|
state.errorReason = payload.errorReason
|
|
113
114
|
state.step = WIDGET_STEP.Error
|
package/src/theme/components.ts
CHANGED