@huma-finance/widgets 0.0.61-beta.543 → 0.0.61-beta.544
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 +30 -55
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +31 -56
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +0 -4
- package/src/components/Lend/supplyV2/8-PointsEarned.tsx +22 -16
- package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +14 -48
- package/src/components/Lend/supplyV2/index.tsx +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.61-beta.
|
|
3
|
+
"version": "0.0.61-beta.544+e3f8572",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -30,9 +30,9 @@
|
|
|
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.61-beta.
|
|
34
|
-
"@huma-finance/shared": "^0.0.61-beta.
|
|
35
|
-
"@huma-finance/web-shared": "^0.0.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.61-beta.544+e3f8572",
|
|
34
|
+
"@huma-finance/shared": "^0.0.61-beta.544+e3f8572",
|
|
35
|
+
"@huma-finance/web-shared": "^0.0.61-beta.544+e3f8572",
|
|
36
36
|
"@mui/icons-material": "^5.3.0",
|
|
37
37
|
"@mui/material": "^5.0.6",
|
|
38
38
|
"@mui/styles": "^5.0.2",
|
|
@@ -195,5 +195,5 @@
|
|
|
195
195
|
"optionalDependencies": {
|
|
196
196
|
"encoding": "^0.1.13"
|
|
197
197
|
},
|
|
198
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "e3f85721970a1379a26063a817646ddc678cac21"
|
|
199
199
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
|
|
2
|
-
import { BigNumber } from 'ethers'
|
|
3
2
|
import React from 'react'
|
|
4
3
|
|
|
5
4
|
import { Campaign } from '.'
|
|
@@ -9,7 +8,6 @@ import { SecuritizeEvaluation } from './components/SecuritizeEvaluation'
|
|
|
9
8
|
type Props = {
|
|
10
9
|
poolInfo: PoolInfoV2
|
|
11
10
|
isUniTranche: boolean
|
|
12
|
-
minDepositAmount: BigNumber
|
|
13
11
|
pointsTestnetExperience: boolean
|
|
14
12
|
campaign?: Campaign
|
|
15
13
|
changeTranche: (tranche: TrancheType) => void
|
|
@@ -19,7 +17,6 @@ type Props = {
|
|
|
19
17
|
export function Evaluation({
|
|
20
18
|
poolInfo,
|
|
21
19
|
isUniTranche,
|
|
22
|
-
minDepositAmount,
|
|
23
20
|
campaign,
|
|
24
21
|
pointsTestnetExperience,
|
|
25
22
|
changeTranche,
|
|
@@ -38,7 +35,6 @@ export function Evaluation({
|
|
|
38
35
|
isUniTranche={isUniTranche}
|
|
39
36
|
pointsTestnetExperience={pointsTestnetExperience}
|
|
40
37
|
campaign={campaign}
|
|
41
|
-
minDepositAmount={minDepositAmount}
|
|
42
38
|
changeTranche={changeTranche}
|
|
43
39
|
/>
|
|
44
40
|
)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CampaignService,
|
|
3
|
+
checkIsDev,
|
|
4
|
+
formatNumber,
|
|
5
|
+
isEmpty,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
2
7
|
import { useAuthErrorHandling } from '@huma-finance/web-shared'
|
|
3
8
|
import { Box, css, useTheme } from '@mui/material'
|
|
4
9
|
import { useWeb3React } from '@web3-react/core'
|
|
@@ -40,6 +45,8 @@ export function PointsEarned({
|
|
|
40
45
|
const [pointsAccumulated, setPointsAccumulated] = useState<
|
|
41
46
|
number | undefined
|
|
42
47
|
>()
|
|
48
|
+
const hasPointsAccumulated =
|
|
49
|
+
!isEmpty(pointsAccumulated) && pointsAccumulated! > 0
|
|
43
50
|
const lockupMonths = Math.round(lpConfig.withdrawalLockoutPeriodInDays / 30)
|
|
44
51
|
const monthText =
|
|
45
52
|
lockupMonths > 1 ? `${lockupMonths} months` : `${lockupMonths} month`
|
|
@@ -109,21 +116,10 @@ export function PointsEarned({
|
|
|
109
116
|
isDev,
|
|
110
117
|
pointsTestnetExperience,
|
|
111
118
|
)
|
|
112
|
-
if (!result.pointsAccumulated) {
|
|
113
|
-
dispatch(
|
|
114
|
-
setError({
|
|
115
|
-
errorMessage: ERROR_MESSAGE,
|
|
116
|
-
}),
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
119
|
setPointsAccumulated(result.pointsAccumulated)
|
|
120
120
|
setState(STATE.Congrats)
|
|
121
121
|
} catch (error) {
|
|
122
|
-
|
|
123
|
-
setError({
|
|
124
|
-
errorMessage: ERROR_MESSAGE,
|
|
125
|
-
}),
|
|
126
|
-
)
|
|
122
|
+
console.error('Failed to update wallet points', error)
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
125
|
}
|
|
@@ -204,12 +200,22 @@ export function PointsEarned({
|
|
|
204
200
|
<RibbonIcon />
|
|
205
201
|
<Box css={styles.ribbonContent}>
|
|
206
202
|
<HumaPointsIcon />
|
|
207
|
-
<Box>
|
|
203
|
+
<Box>
|
|
204
|
+
{hasPointsAccumulated
|
|
205
|
+
? `${formatNumber(pointsAccumulated)} Points`
|
|
206
|
+
: 'Points earned'}
|
|
207
|
+
</Box>
|
|
208
208
|
</Box>
|
|
209
209
|
</Box>
|
|
210
210
|
<Box css={styles.entirePoints}>
|
|
211
|
-
|
|
212
|
-
|
|
211
|
+
{hasPointsAccumulated ? (
|
|
212
|
+
<>
|
|
213
|
+
<Box>Congratulations,</Box>
|
|
214
|
+
<Box>you've earned {pointsAccumulated} points</Box>
|
|
215
|
+
</>
|
|
216
|
+
) : (
|
|
217
|
+
<Box>Congratulations on joining the Huma Protocol!</Box>
|
|
218
|
+
)}
|
|
213
219
|
</Box>
|
|
214
220
|
<Box css={styles.entirePointsDetails}>
|
|
215
221
|
You'll earn points <span css={styles.everyday}>everyday</span> for{' '}
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
CAMPAIGN_REFERENCE_CODE,
|
|
3
3
|
CampaignService,
|
|
4
4
|
checkIsDev,
|
|
5
|
-
formatNumber,
|
|
6
5
|
IdentityServiceV2,
|
|
7
6
|
IdentityVerificationStatusV2,
|
|
8
7
|
KYCCopy,
|
|
@@ -13,7 +12,6 @@ import {
|
|
|
13
12
|
import { useAuthErrorHandling } from '@huma-finance/web-shared'
|
|
14
13
|
import { Box, css, useTheme } from '@mui/material'
|
|
15
14
|
import { useWeb3React } from '@web3-react/core'
|
|
16
|
-
import { BigNumber } from 'ethers'
|
|
17
15
|
import Persona, { Client } from 'persona'
|
|
18
16
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
19
17
|
|
|
@@ -47,17 +45,15 @@ const LoadingCopiesByType: {
|
|
|
47
45
|
type Props = {
|
|
48
46
|
poolInfo: PoolInfoV2
|
|
49
47
|
isUniTranche: boolean
|
|
50
|
-
minDepositAmount: BigNumber
|
|
51
48
|
pointsTestnetExperience: boolean
|
|
52
49
|
campaign?: Campaign
|
|
53
50
|
changeTranche: (tranche: TrancheType) => void
|
|
54
|
-
handleClose: () => void
|
|
51
|
+
handleClose: (identityStatus?: IdentityVerificationStatusV2) => void
|
|
55
52
|
}
|
|
56
53
|
|
|
57
54
|
export function PersonaEvaluation({
|
|
58
55
|
poolInfo,
|
|
59
56
|
isUniTranche,
|
|
60
|
-
minDepositAmount: minDepositAmountBN,
|
|
61
57
|
campaign,
|
|
62
58
|
pointsTestnetExperience,
|
|
63
59
|
changeTranche,
|
|
@@ -81,7 +77,6 @@ export function PersonaEvaluation({
|
|
|
81
77
|
const [verificationStatus, setVerificationStatus] =
|
|
82
78
|
useState<VerificationStatusResultV2>()
|
|
83
79
|
const [showPersonaClient, setShowPersonaClient] = useState<boolean>(false)
|
|
84
|
-
const [campaignBasePoints, setCampaignBasePoints] = useState<number>(0)
|
|
85
80
|
const isKYCCompletedRef = useRef<boolean>(false)
|
|
86
81
|
const isActionOngoingRef = useRef<boolean>(false)
|
|
87
82
|
const isKYCResumedRef = useRef<boolean>(false)
|
|
@@ -106,41 +101,6 @@ export function PersonaEvaluation({
|
|
|
106
101
|
pointsTestnetExperience,
|
|
107
102
|
])
|
|
108
103
|
|
|
109
|
-
useEffect(() => {
|
|
110
|
-
const getBasePoints = async () => {
|
|
111
|
-
if (campaign) {
|
|
112
|
-
const estimatedPoints = await CampaignService.getEstimatedPoints(
|
|
113
|
-
campaign.campaignGroupId,
|
|
114
|
-
minDepositAmountBN.toString(),
|
|
115
|
-
isDev,
|
|
116
|
-
pointsTestnetExperience,
|
|
117
|
-
)
|
|
118
|
-
const campaignPoints = estimatedPoints.find(
|
|
119
|
-
(item) => item.campaignId === campaign.id,
|
|
120
|
-
)
|
|
121
|
-
if (campaignPoints) {
|
|
122
|
-
const { juniorTranchePoints, seniorTranchePoints } = campaignPoints
|
|
123
|
-
if (isUniTranche) {
|
|
124
|
-
setCampaignBasePoints(juniorTranchePoints ?? 0)
|
|
125
|
-
} else {
|
|
126
|
-
setCampaignBasePoints(
|
|
127
|
-
juniorTranchePoints < seniorTranchePoints
|
|
128
|
-
? juniorTranchePoints
|
|
129
|
-
: seniorTranchePoints,
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
getBasePoints()
|
|
136
|
-
}, [
|
|
137
|
-
campaign,
|
|
138
|
-
isDev,
|
|
139
|
-
isUniTranche,
|
|
140
|
-
minDepositAmountBN,
|
|
141
|
-
pointsTestnetExperience,
|
|
142
|
-
])
|
|
143
|
-
|
|
144
104
|
const approveLender = useCallback(async () => {
|
|
145
105
|
try {
|
|
146
106
|
isActionOngoingRef.current = true
|
|
@@ -250,7 +210,8 @@ export function PersonaEvaluation({
|
|
|
250
210
|
}
|
|
251
211
|
|
|
252
212
|
case IdentityVerificationStatusV2.APPROVED: {
|
|
253
|
-
|
|
213
|
+
setKYCCopy(KYCCopies.verificationApproved)
|
|
214
|
+
setLoadingType(undefined)
|
|
254
215
|
break
|
|
255
216
|
}
|
|
256
217
|
|
|
@@ -266,6 +227,11 @@ export function PersonaEvaluation({
|
|
|
266
227
|
break
|
|
267
228
|
}
|
|
268
229
|
|
|
230
|
+
case IdentityVerificationStatusV2.CONSENTED_TO_SUBSCRIPTION: {
|
|
231
|
+
await approveLender()
|
|
232
|
+
break
|
|
233
|
+
}
|
|
234
|
+
|
|
269
235
|
default:
|
|
270
236
|
break
|
|
271
237
|
}
|
|
@@ -340,6 +306,7 @@ export function PersonaEvaluation({
|
|
|
340
306
|
const client: Client = new Persona.Client({
|
|
341
307
|
inquiryId,
|
|
342
308
|
sessionToken,
|
|
309
|
+
frameWidth: '480px',
|
|
343
310
|
onReady: () => {
|
|
344
311
|
client.open()
|
|
345
312
|
setShowPersonaClient(true)
|
|
@@ -375,7 +342,8 @@ export function PersonaEvaluation({
|
|
|
375
342
|
|
|
376
343
|
case IdentityVerificationStatusV2.DECLINED:
|
|
377
344
|
case IdentityVerificationStatusV2.NEEDS_REVIEW:
|
|
378
|
-
|
|
345
|
+
case IdentityVerificationStatusV2.APPROVED:
|
|
346
|
+
handleClose(verificationStatus.status)
|
|
379
347
|
break
|
|
380
348
|
|
|
381
349
|
default:
|
|
@@ -413,12 +381,10 @@ export function PersonaEvaluation({
|
|
|
413
381
|
</Box>
|
|
414
382
|
{campaign && kycCopy === KYCCopies.verifyIdentity ? (
|
|
415
383
|
<Box css={styles.description}>
|
|
416
|
-
<span>
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
{formatNumber(campaignBasePoints)} Huma points{' '}
|
|
384
|
+
<span>
|
|
385
|
+
You'll be rewarded with Huma points after completing KYC/KYB and
|
|
386
|
+
your first investment.
|
|
420
387
|
</span>
|
|
421
|
-
<span>after completing KYC and your first investment.</span>
|
|
422
388
|
</Box>
|
|
423
389
|
) : (
|
|
424
390
|
<Box css={styles.description}>{kycCopy.description}</Box>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
IdentityVerificationStatusV2,
|
|
3
|
+
openInNewTab,
|
|
4
|
+
POOL_NAME,
|
|
5
|
+
TrancheType,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
2
7
|
import {
|
|
3
8
|
useLenderApprovedV2,
|
|
4
9
|
useLPConfigV2,
|
|
5
10
|
usePoolInfoV2,
|
|
6
|
-
usePoolSettingsV2,
|
|
7
11
|
usePoolUnderlyingTokenInfoV2,
|
|
8
12
|
} from '@huma-finance/web-shared'
|
|
9
13
|
import { useWeb3React } from '@web3-react/core'
|
|
@@ -36,14 +40,14 @@ export interface Campaign {
|
|
|
36
40
|
* @property {POOL_NAME} poolName The name of the pool.
|
|
37
41
|
* @property {boolean} pointsTestnetExperience If the user is in the testnet experience.
|
|
38
42
|
* @property {Campaign} campaign The campaign info.
|
|
39
|
-
* @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
43
|
+
* @property {function((IdentityVerificationStatusV2|undefined)):void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
40
44
|
* @property {function((number|undefined)):void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
41
45
|
*/
|
|
42
46
|
export interface LendSupplyPropsV2 {
|
|
43
47
|
poolName: keyof typeof POOL_NAME
|
|
44
48
|
pointsTestnetExperience: boolean
|
|
45
49
|
campaign?: Campaign
|
|
46
|
-
handleClose: () => void
|
|
50
|
+
handleClose: (identityStatus?: IdentityVerificationStatusV2) => void
|
|
47
51
|
handleSuccess?: (blockNumber?: number) => void
|
|
48
52
|
}
|
|
49
53
|
|
|
@@ -62,7 +66,6 @@ export function LendSupplyV2({
|
|
|
62
66
|
const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
|
|
63
67
|
const [transactionHash, setTransactionHash] = useState<string | undefined>()
|
|
64
68
|
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)
|
|
65
|
-
const poolSettings = usePoolSettingsV2(poolName, provider)
|
|
66
69
|
const lpConfig = useLPConfigV2(poolName, provider)
|
|
67
70
|
const isUniTranche = lpConfig?.maxSeniorJuniorRatio === 0
|
|
68
71
|
const [lenderApprovedSenior] = useLenderApprovedV2(
|
|
@@ -141,8 +144,7 @@ export function LendSupplyV2({
|
|
|
141
144
|
!poolInfo ||
|
|
142
145
|
!poolUnderlyingToken ||
|
|
143
146
|
!lenderApproveStatusFetched ||
|
|
144
|
-
!lpConfig
|
|
145
|
-
!poolSettings
|
|
147
|
+
!lpConfig
|
|
146
148
|
) {
|
|
147
149
|
return (
|
|
148
150
|
<WidgetWrapper
|
|
@@ -177,7 +179,6 @@ export function LendSupplyV2({
|
|
|
177
179
|
changeTranche={setSelectedTranche}
|
|
178
180
|
pointsTestnetExperience={pointsTestnetExperience}
|
|
179
181
|
campaign={campaign}
|
|
180
|
-
minDepositAmount={poolSettings.minDepositAmount}
|
|
181
182
|
/>
|
|
182
183
|
)}
|
|
183
184
|
{step === WIDGET_STEP.ChooseAmount && (
|