@huma-finance/widgets 0.0.59-beta.481 → 0.0.59-beta.483
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 +1 -1
- package/dist/cjs/index.cjs +597 -172
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.js +598 -173
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/InputAmountModal.tsx +2 -2
- package/src/components/Lend/supplyV2/2-Evaluation.tsx +8 -0
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +47 -2
- 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 +145 -0
- package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +78 -12
- package/src/components/Lend/supplyV2/index.tsx +31 -7
- package/src/components/TxDoneModal.tsx +21 -2
- 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.store.ts +1 -0
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.483+eb578bd",
|
|
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.59-beta.
|
|
34
|
-
"@huma-finance/shared": "^0.0.59-beta.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.59-beta.483+eb578bd",
|
|
34
|
+
"@huma-finance/shared": "^0.0.59-beta.483+eb578bd",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
37
37
|
"@mui/styles": "^5.0.2",
|
|
@@ -195,5 +195,5 @@
|
|
|
195
195
|
"optionalDependencies": {
|
|
196
196
|
"encoding": "^0.1.13"
|
|
197
197
|
},
|
|
198
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "eb578bdfeae74ea663467cbb26204075b27c76f0"
|
|
199
199
|
}
|
|
@@ -88,8 +88,8 @@ export function InputAmountModal({
|
|
|
88
88
|
`,
|
|
89
89
|
info: css`
|
|
90
90
|
color: ${theme.palette.text.primary};
|
|
91
|
-
font-family: 'Uni-Neue-
|
|
92
|
-
font-size:
|
|
91
|
+
font-family: 'Uni-Neue-Regular';
|
|
92
|
+
font-size: 16px;
|
|
93
93
|
line-height: 160%;
|
|
94
94
|
letter-spacing: 0.15px;
|
|
95
95
|
`,
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
|
|
2
|
+
import { BigNumber } from 'ethers'
|
|
2
3
|
import React from 'react'
|
|
3
4
|
|
|
5
|
+
import { Campaign } from '.'
|
|
4
6
|
import { PersonaEvaluation } from './components/PersonaEvaluation'
|
|
5
7
|
import { SecuritizeEvaluation } from './components/SecuritizeEvaluation'
|
|
6
8
|
|
|
7
9
|
type Props = {
|
|
8
10
|
poolInfo: PoolInfoV2
|
|
9
11
|
isUniTranche: boolean
|
|
12
|
+
minDepositAmount: BigNumber
|
|
13
|
+
campaign?: Campaign
|
|
10
14
|
changeTranche: (tranche: TrancheType) => void
|
|
11
15
|
handleClose: () => void
|
|
12
16
|
}
|
|
@@ -14,6 +18,8 @@ type Props = {
|
|
|
14
18
|
export function Evaluation({
|
|
15
19
|
poolInfo,
|
|
16
20
|
isUniTranche,
|
|
21
|
+
minDepositAmount,
|
|
22
|
+
campaign,
|
|
17
23
|
changeTranche,
|
|
18
24
|
handleClose,
|
|
19
25
|
}: Props): React.ReactElement | null {
|
|
@@ -28,6 +34,8 @@ export function Evaluation({
|
|
|
28
34
|
poolInfo={poolInfo}
|
|
29
35
|
handleClose={handleClose}
|
|
30
36
|
isUniTranche={isUniTranche}
|
|
37
|
+
campaign={campaign}
|
|
38
|
+
minDepositAmount={minDepositAmount}
|
|
31
39
|
changeTranche={changeTranche}
|
|
32
40
|
/>
|
|
33
41
|
)
|
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CampaignService,
|
|
2
3
|
formatNumber,
|
|
3
4
|
PoolInfoV2,
|
|
4
5
|
TrancheType,
|
|
5
6
|
UnderlyingTokenInfo,
|
|
7
|
+
useDebouncedValue,
|
|
6
8
|
usePoolSafeAllowanceV2,
|
|
7
9
|
usePoolUnderlyingTokenBalanceV2,
|
|
8
10
|
} from '@huma-finance/shared'
|
|
9
11
|
import { useWeb3React } from '@web3-react/core'
|
|
10
12
|
import { BigNumber, ethers } from 'ethers'
|
|
11
|
-
import React, { useState } from 'react'
|
|
13
|
+
import React, { useEffect, useState } from 'react'
|
|
12
14
|
|
|
13
15
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
14
16
|
import { setStep, setSupplyAmount } from '../../../store/widgets.reducers'
|
|
15
17
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
16
18
|
import { InputAmountModal } from '../../InputAmountModal'
|
|
19
|
+
import { Campaign } from '.'
|
|
17
20
|
|
|
18
21
|
type Props = {
|
|
19
22
|
poolInfo: PoolInfoV2
|
|
20
23
|
poolUnderlyingToken: UnderlyingTokenInfo
|
|
21
24
|
selectedTranche: TrancheType | undefined
|
|
22
25
|
isUniTranche: boolean
|
|
26
|
+
campaign?: Campaign
|
|
23
27
|
}
|
|
24
28
|
|
|
25
29
|
export function ChooseAmount({
|
|
@@ -27,11 +31,15 @@ export function ChooseAmount({
|
|
|
27
31
|
poolUnderlyingToken,
|
|
28
32
|
selectedTranche,
|
|
29
33
|
isUniTranche,
|
|
34
|
+
campaign,
|
|
30
35
|
}: Props): React.ReactElement | null {
|
|
31
36
|
const dispatch = useAppDispatch()
|
|
32
37
|
const { account, provider } = useWeb3React()
|
|
33
38
|
const { symbol, decimals } = poolUnderlyingToken
|
|
34
39
|
const [currentAmount, setCurrentAmount] = useState<number | string>(0)
|
|
40
|
+
const debouncedValue = useDebouncedValue(currentAmount)
|
|
41
|
+
const [campaignPoints, setCampaignPoints] = useState<number>(0)
|
|
42
|
+
const [lockupPeriodMonths, setLockupPeriodMonths] = useState<number>(0)
|
|
35
43
|
const { allowance = BigNumber.from(0) } = usePoolSafeAllowanceV2(
|
|
36
44
|
poolInfo.poolName,
|
|
37
45
|
account,
|
|
@@ -47,6 +55,36 @@ export function ChooseAmount({
|
|
|
47
55
|
poolUnderlyingToken.decimals,
|
|
48
56
|
)
|
|
49
57
|
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const getBasePoints = async () => {
|
|
60
|
+
if (campaign && selectedTranche && Number(debouncedValue) > 0) {
|
|
61
|
+
const estimatedPoints = await CampaignService.getEstimatedPoints(
|
|
62
|
+
campaign.campaignGroupId,
|
|
63
|
+
ethers.utils
|
|
64
|
+
.parseUnits(
|
|
65
|
+
String(debouncedValue),
|
|
66
|
+
poolInfo.poolUnderlyingToken.decimals,
|
|
67
|
+
)
|
|
68
|
+
.toString(),
|
|
69
|
+
)
|
|
70
|
+
const campaignPoints = estimatedPoints.find(
|
|
71
|
+
(item) => item.campaignId === campaign.id,
|
|
72
|
+
)
|
|
73
|
+
if (campaignPoints) {
|
|
74
|
+
setCampaignPoints(campaignPoints[`${selectedTranche}TranchePoints`])
|
|
75
|
+
setLockupPeriodMonths(campaignPoints.lockupPeriodMonths)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
getBasePoints()
|
|
80
|
+
}, [
|
|
81
|
+
campaign,
|
|
82
|
+
debouncedValue,
|
|
83
|
+
decimals,
|
|
84
|
+
poolInfo.poolUnderlyingToken.decimals,
|
|
85
|
+
selectedTranche,
|
|
86
|
+
])
|
|
87
|
+
|
|
50
88
|
const handleChangeAmount = (newAmount: number) => {
|
|
51
89
|
setCurrentAmount(newAmount)
|
|
52
90
|
dispatch(setSupplyAmount(Number(newAmount)))
|
|
@@ -63,6 +101,13 @@ export function ChooseAmount({
|
|
|
63
101
|
dispatch(setStep(step))
|
|
64
102
|
}
|
|
65
103
|
|
|
104
|
+
let info = `${formatNumber(maxAmountFormatted)} Available`
|
|
105
|
+
if (campaign && campaignPoints > 0) {
|
|
106
|
+
info = `You will earn ${formatNumber(
|
|
107
|
+
campaignPoints,
|
|
108
|
+
)} points for the entire ${lockupPeriodMonths} months right away.`
|
|
109
|
+
}
|
|
110
|
+
|
|
66
111
|
return (
|
|
67
112
|
<InputAmountModal
|
|
68
113
|
title='Enter Amount'
|
|
@@ -73,7 +118,7 @@ export function ChooseAmount({
|
|
|
73
118
|
currentAmount={currentAmount}
|
|
74
119
|
handleChangeAmount={handleChangeAmount}
|
|
75
120
|
maxAmount={maxAmountFormatted}
|
|
76
|
-
info={
|
|
121
|
+
info={info}
|
|
77
122
|
handleAction={handleAction}
|
|
78
123
|
actionText='SUPPLY'
|
|
79
124
|
/>
|
|
@@ -4,11 +4,13 @@ import {
|
|
|
4
4
|
formatMoney,
|
|
5
5
|
PoolInfoV2,
|
|
6
6
|
sendTxAtom,
|
|
7
|
+
timeUtil,
|
|
7
8
|
TRANSFER_ABI,
|
|
8
9
|
UnderlyingTokenInfo,
|
|
9
10
|
} from '@huma-finance/shared'
|
|
10
11
|
import { useWeb3React } from '@web3-react/core'
|
|
11
12
|
import { useAtom } from 'jotai'
|
|
13
|
+
import moment from 'moment'
|
|
12
14
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
13
15
|
import { useDispatch } from 'react-redux'
|
|
14
16
|
|
|
@@ -16,24 +18,31 @@ import {
|
|
|
16
18
|
useDoesChainSupportNotifi,
|
|
17
19
|
useIsFirstTimeNotifiUser,
|
|
18
20
|
} from '../../../hooks/useNotifi'
|
|
19
|
-
import { TxDoneModal } from '../../TxDoneModal'
|
|
20
21
|
import { setStep } from '../../../store/widgets.reducers'
|
|
21
22
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
23
|
+
import { TxDoneModal } from '../../TxDoneModal'
|
|
24
|
+
import { Campaign } from '.'
|
|
22
25
|
|
|
23
26
|
type Props = {
|
|
24
27
|
poolInfo: PoolInfoV2
|
|
25
28
|
poolUnderlyingToken: UnderlyingTokenInfo
|
|
29
|
+
lpConfig: { withdrawalLockoutPeriodInDays: number }
|
|
30
|
+
campaign?: Campaign
|
|
31
|
+
updateTransactionHash: (hash: string) => void
|
|
26
32
|
handleAction: () => void
|
|
27
33
|
}
|
|
28
34
|
|
|
29
35
|
export function Success({
|
|
30
36
|
poolInfo,
|
|
31
37
|
poolUnderlyingToken,
|
|
38
|
+
lpConfig,
|
|
39
|
+
campaign,
|
|
40
|
+
updateTransactionHash,
|
|
32
41
|
handleAction,
|
|
33
42
|
}: Props): React.ReactElement {
|
|
34
43
|
const dispatch = useDispatch()
|
|
35
44
|
const { account, chainId } = useWeb3React()
|
|
36
|
-
const [{ txReceipt }] = useAtom(sendTxAtom)
|
|
45
|
+
const [{ txReceipt, txHash }] = useAtom(sendTxAtom)
|
|
37
46
|
const { symbol, decimals, address } = poolUnderlyingToken
|
|
38
47
|
const [supplyAmount, setSupplyAmount] = useState<string | undefined>()
|
|
39
48
|
const { isFirstTimeNotifiUser } = useIsFirstTimeNotifiUser(account, chainId)
|
|
@@ -57,23 +66,57 @@ export function Success({
|
|
|
57
66
|
}
|
|
58
67
|
}, [account, address, decimals, poolInfo.poolSafe, txReceipt])
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (txHash) {
|
|
71
|
+
updateTransactionHash(txHash)
|
|
72
|
+
}
|
|
73
|
+
}, [txHash, updateTransactionHash])
|
|
74
|
+
|
|
75
|
+
const handleUserAction = useCallback(() => {
|
|
61
76
|
if (isFirstTimeNotifiUser && notifiChainSupported) {
|
|
62
77
|
dispatch(setStep(WIDGET_STEP.Notifications))
|
|
78
|
+
} else if (campaign) {
|
|
79
|
+
dispatch(setStep(WIDGET_STEP.PointsEarned))
|
|
63
80
|
} else {
|
|
64
81
|
handleAction()
|
|
65
82
|
}
|
|
66
|
-
}, [
|
|
83
|
+
}, [
|
|
84
|
+
campaign,
|
|
85
|
+
dispatch,
|
|
86
|
+
handleAction,
|
|
87
|
+
isFirstTimeNotifiUser,
|
|
88
|
+
notifiChainSupported,
|
|
89
|
+
])
|
|
67
90
|
|
|
68
91
|
const content = [
|
|
69
92
|
`You successfully supplied ${formatMoney(supplyAmount)} ${symbol}.`,
|
|
70
93
|
]
|
|
71
94
|
|
|
95
|
+
const getSubContent = () => {
|
|
96
|
+
const currentTime = moment().add(
|
|
97
|
+
lpConfig.withdrawalLockoutPeriodInDays,
|
|
98
|
+
'days',
|
|
99
|
+
)
|
|
100
|
+
return [
|
|
101
|
+
`First redemption date: ${timeUtil.timestampToLL(
|
|
102
|
+
currentTime.unix(),
|
|
103
|
+
)}. You can redeem end of each month after.`,
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const getButtonText = () => {
|
|
108
|
+
if (hasNextStep) {
|
|
109
|
+
return "WHAT'S NEXT"
|
|
110
|
+
}
|
|
111
|
+
return campaign ? 'VIEW POINTS' : undefined
|
|
112
|
+
}
|
|
113
|
+
|
|
72
114
|
return (
|
|
73
115
|
<TxDoneModal
|
|
74
|
-
handleAction={
|
|
116
|
+
handleAction={handleUserAction}
|
|
75
117
|
content={content}
|
|
76
|
-
|
|
118
|
+
subContent={getSubContent()}
|
|
119
|
+
buttonText={getButtonText()}
|
|
77
120
|
/>
|
|
78
121
|
)
|
|
79
122
|
}
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useCallback } from 'react'
|
|
2
|
+
import { useDispatch } from 'react-redux'
|
|
3
|
+
|
|
4
|
+
import { Campaign } from '.'
|
|
2
5
|
import { NotifiSubscriptionModal } from '../../Notifi/NotifiSubscriptionModal'
|
|
6
|
+
import { setStep } from '../../../store/widgets.reducers'
|
|
7
|
+
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
3
8
|
|
|
4
9
|
type Props = {
|
|
10
|
+
campaign?: Campaign
|
|
5
11
|
handleAction: () => void
|
|
6
12
|
}
|
|
7
13
|
|
|
8
|
-
export function Notifications({
|
|
9
|
-
|
|
14
|
+
export function Notifications({
|
|
15
|
+
campaign,
|
|
16
|
+
handleAction,
|
|
17
|
+
}: Props): React.ReactElement {
|
|
18
|
+
const dispatch = useDispatch()
|
|
19
|
+
|
|
20
|
+
const handleUserAction = useCallback(() => {
|
|
21
|
+
if (campaign) {
|
|
22
|
+
dispatch(setStep(WIDGET_STEP.PointsEarned))
|
|
23
|
+
} else {
|
|
24
|
+
handleAction()
|
|
25
|
+
}
|
|
26
|
+
}, [campaign, dispatch, handleAction])
|
|
27
|
+
|
|
28
|
+
return <NotifiSubscriptionModal handleSuccess={handleUserAction} />
|
|
10
29
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { CampaignService, formatNumber } from '@huma-finance/shared'
|
|
2
|
+
import { Box, css, useTheme } from '@mui/material'
|
|
3
|
+
import { useWeb3React } from '@web3-react/core'
|
|
4
|
+
import React, { useEffect, useState } from 'react'
|
|
5
|
+
import { useDispatch } from 'react-redux'
|
|
6
|
+
|
|
7
|
+
import { setError } from '../../../store/widgets.reducers'
|
|
8
|
+
import { BottomButton } from '../../BottomButton'
|
|
9
|
+
import { CongratulationsIcon, HumaPointsIcon, RibbonIcon } from '../../icons'
|
|
10
|
+
import { LoadingModal } from '../../LoadingModal'
|
|
11
|
+
|
|
12
|
+
type Props = {
|
|
13
|
+
transactionHash: string
|
|
14
|
+
lpConfig: { withdrawalLockoutPeriodInDays: number }
|
|
15
|
+
handleAction: () => void
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function PointsEarned({
|
|
19
|
+
transactionHash,
|
|
20
|
+
lpConfig,
|
|
21
|
+
handleAction,
|
|
22
|
+
}: Props): React.ReactElement {
|
|
23
|
+
const theme = useTheme()
|
|
24
|
+
const dispatch = useDispatch()
|
|
25
|
+
const { account, chainId } = useWeb3React()
|
|
26
|
+
const [pointsAccumulated, setPointsAccumulated] = useState<
|
|
27
|
+
number | undefined
|
|
28
|
+
>()
|
|
29
|
+
const lockupMonths = lpConfig.withdrawalLockoutPeriodInDays / 30
|
|
30
|
+
const monthText =
|
|
31
|
+
lockupMonths > 1 ? `${lockupMonths} months` : `${lockupMonths} month`
|
|
32
|
+
const [loading, setLoading] = useState(false)
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const updateWalletPoints = async () => {
|
|
36
|
+
const setErrorMessage = () => {
|
|
37
|
+
dispatch(
|
|
38
|
+
setError({
|
|
39
|
+
errorMessage:
|
|
40
|
+
'Failed to update wallet points. Be assured that your points will be added later.',
|
|
41
|
+
}),
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
setLoading(true)
|
|
47
|
+
const result = await CampaignService.updateWalletPoints(
|
|
48
|
+
chainId!,
|
|
49
|
+
account!,
|
|
50
|
+
transactionHash,
|
|
51
|
+
)
|
|
52
|
+
if (!result.pointsAccumulated) {
|
|
53
|
+
setErrorMessage()
|
|
54
|
+
}
|
|
55
|
+
setPointsAccumulated(result.pointsAccumulated)
|
|
56
|
+
} catch (error) {
|
|
57
|
+
setErrorMessage()
|
|
58
|
+
} finally {
|
|
59
|
+
setLoading(false)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
updateWalletPoints()
|
|
63
|
+
}, [account, chainId, dispatch, transactionHash])
|
|
64
|
+
|
|
65
|
+
const styles = {
|
|
66
|
+
wrapper: css`
|
|
67
|
+
height: 518px;
|
|
68
|
+
position: relative;
|
|
69
|
+
`,
|
|
70
|
+
congrats: css`
|
|
71
|
+
margin: ${theme.spacing(-4, -4.5, 0, -4.5)};
|
|
72
|
+
`,
|
|
73
|
+
ribbon: css`
|
|
74
|
+
position: relative;
|
|
75
|
+
${theme.cssMixins.rowHCentered};
|
|
76
|
+
font-family: 'Uni-Neue-Bold';
|
|
77
|
+
margin-top: ${theme.spacing(-8)};
|
|
78
|
+
color: #fbfbfc;
|
|
79
|
+
font-size: 20px;
|
|
80
|
+
line-height: 160%;
|
|
81
|
+
letter-spacing: 0.15px;
|
|
82
|
+
`,
|
|
83
|
+
ribbonContent: css`
|
|
84
|
+
${theme.cssMixins.rowVCentered};
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: ${theme.spacing(1)};
|
|
87
|
+
|
|
88
|
+
svg {
|
|
89
|
+
margin-right: ${theme.spacing(1)};
|
|
90
|
+
}
|
|
91
|
+
`,
|
|
92
|
+
entirePoints: css`
|
|
93
|
+
color: ${theme.palette.text.tertiary};
|
|
94
|
+
text-align: center;
|
|
95
|
+
font-family: 'Uni-Neue-Bold';
|
|
96
|
+
font-size: 20px;
|
|
97
|
+
line-height: 160%;
|
|
98
|
+
letter-spacing: 0.15px;
|
|
99
|
+
margin-top: ${theme.spacing(7)};
|
|
100
|
+
`,
|
|
101
|
+
entirePointsDetails: css`
|
|
102
|
+
color: ${theme.palette.text.tertiary};
|
|
103
|
+
text-align: center;
|
|
104
|
+
font-family: 'Uni-Neue-Regular';
|
|
105
|
+
font-size: 16px;
|
|
106
|
+
line-height: 150%;
|
|
107
|
+
letter-spacing: 0.15px;
|
|
108
|
+
margin-top: ${theme.spacing(4)};
|
|
109
|
+
`,
|
|
110
|
+
everyday: css`
|
|
111
|
+
font-family: 'Uni-Neue-Bold';
|
|
112
|
+
`,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (loading) {
|
|
116
|
+
return <LoadingModal title='SUPPLY' />
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Box css={styles.wrapper}>
|
|
121
|
+
<Box css={styles.congrats}>
|
|
122
|
+
<CongratulationsIcon />
|
|
123
|
+
</Box>
|
|
124
|
+
<Box css={styles.ribbon}>
|
|
125
|
+
<RibbonIcon />
|
|
126
|
+
<Box css={styles.ribbonContent}>
|
|
127
|
+
<HumaPointsIcon />
|
|
128
|
+
<Box>{formatNumber(pointsAccumulated)} Points</Box>
|
|
129
|
+
</Box>
|
|
130
|
+
</Box>
|
|
131
|
+
<Box css={styles.entirePoints}>
|
|
132
|
+
<Box>Congratulations,</Box>
|
|
133
|
+
<Box>you've earned {pointsAccumulated} points</Box>
|
|
134
|
+
</Box>
|
|
135
|
+
<Box css={styles.entirePointsDetails}>
|
|
136
|
+
You'll earn points <span css={styles.everyday}>everyday</span> for{' '}
|
|
137
|
+
{monthText} straight. Plus, If you keep your investment till after{' '}
|
|
138
|
+
{monthText}, you’ll gain extra points daily.
|
|
139
|
+
</Box>
|
|
140
|
+
<BottomButton variant='contained' onClick={handleAction}>
|
|
141
|
+
GREAT
|
|
142
|
+
</BottomButton>
|
|
143
|
+
</Box>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CAMPAIGN_REFERENCE_CODE,
|
|
3
|
+
CampaignService,
|
|
2
4
|
checkIsDev,
|
|
5
|
+
formatNumber,
|
|
3
6
|
IdentityServiceV2,
|
|
4
7
|
IdentityVerificationStatusV2,
|
|
5
8
|
KYCCopy,
|
|
@@ -10,16 +13,20 @@ import {
|
|
|
10
13
|
} from '@huma-finance/shared'
|
|
11
14
|
import { Box, css, useTheme } from '@mui/material'
|
|
12
15
|
import { useWeb3React } from '@web3-react/core'
|
|
16
|
+
import { BigNumber } from 'ethers'
|
|
17
|
+
import Persona, { Client } from 'persona'
|
|
13
18
|
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
|
14
19
|
|
|
15
|
-
import
|
|
20
|
+
import { Campaign } from '..'
|
|
16
21
|
import { useAppDispatch } from '../../../../hooks/useRedux'
|
|
17
22
|
import { setError, setStep } from '../../../../store/widgets.reducers'
|
|
23
|
+
import { WIDGET_STEP } from '../../../../store/widgets.store'
|
|
18
24
|
import { BottomButton } from '../../../BottomButton'
|
|
19
25
|
import { ApproveLenderImg } from '../../../images'
|
|
20
26
|
import { LoadingModal } from '../../../LoadingModal'
|
|
21
27
|
import { WrapperModal } from '../../../WrapperModal'
|
|
22
|
-
|
|
28
|
+
|
|
29
|
+
type LoadingType = 'verificationStatus' | 'startKYC' | 'approveLender'
|
|
23
30
|
|
|
24
31
|
const LoadingCopiesByType: {
|
|
25
32
|
[key: string]: {
|
|
@@ -40,6 +47,8 @@ const LoadingCopiesByType: {
|
|
|
40
47
|
type Props = {
|
|
41
48
|
poolInfo: PoolInfoV2
|
|
42
49
|
isUniTranche: boolean
|
|
50
|
+
minDepositAmount: BigNumber
|
|
51
|
+
campaign?: Campaign
|
|
43
52
|
changeTranche: (tranche: TrancheType) => void
|
|
44
53
|
handleClose: () => void
|
|
45
54
|
}
|
|
@@ -47,6 +56,8 @@ type Props = {
|
|
|
47
56
|
export function PersonaEvaluation({
|
|
48
57
|
poolInfo,
|
|
49
58
|
isUniTranche,
|
|
59
|
+
minDepositAmount: minDepositAmountBN,
|
|
60
|
+
campaign,
|
|
50
61
|
changeTranche,
|
|
51
62
|
handleClose,
|
|
52
63
|
}: Props): React.ReactElement | null {
|
|
@@ -61,20 +72,58 @@ export function PersonaEvaluation({
|
|
|
61
72
|
isWalletOwnershipVerificationRequired,
|
|
62
73
|
} = useAuthErrorHandling(isDev)
|
|
63
74
|
const KYCCopies = poolInfo.KYC!.Persona!
|
|
64
|
-
const [loadingType, setLoadingType] = useState<
|
|
65
|
-
'verificationStatus' | 'startKYC' | 'approveLender' | undefined
|
|
66
|
-
>()
|
|
75
|
+
const [loadingType, setLoadingType] = useState<LoadingType>()
|
|
67
76
|
const [kycCopy, setKYCCopy] = useState<KYCCopy>(KYCCopies.verifyIdentity)
|
|
68
|
-
const
|
|
69
|
-
const [
|
|
70
|
-
const [
|
|
71
|
-
|
|
72
|
-
|
|
77
|
+
const isVerifyIdentity = kycCopy === KYCCopies.verifyIdentity
|
|
78
|
+
const [inquiryId, setInquiryId] = useState<string>()
|
|
79
|
+
const [sessionToken, setSessionToken] = useState<string>()
|
|
80
|
+
const [verificationStatus, setVerificationStatus] =
|
|
81
|
+
useState<VerificationStatusResultV2>()
|
|
73
82
|
const [showPersonaClient, setShowPersonaClient] = useState<boolean>(false)
|
|
83
|
+
const [campaignBasePoints, setCampaignBasePoints] = useState<number>(0)
|
|
74
84
|
const isKYCCompletedRef = useRef<boolean>(false)
|
|
75
85
|
const isActionOngoingRef = useRef<boolean>(false)
|
|
76
86
|
const isKYCResumedRef = useRef<boolean>(false)
|
|
77
87
|
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const createNewWallet = async () => {
|
|
90
|
+
if (isWalletOwnershipVerified && campaign && account) {
|
|
91
|
+
await CampaignService.createNewWallet(
|
|
92
|
+
account,
|
|
93
|
+
localStorage.getItem(CAMPAIGN_REFERENCE_CODE) ?? undefined,
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
createNewWallet()
|
|
98
|
+
}, [account, campaign, isWalletOwnershipVerified])
|
|
99
|
+
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
const getBasePoints = async () => {
|
|
102
|
+
if (campaign) {
|
|
103
|
+
const estimatedPoints = await CampaignService.getEstimatedPoints(
|
|
104
|
+
campaign.campaignGroupId,
|
|
105
|
+
minDepositAmountBN.toString(),
|
|
106
|
+
)
|
|
107
|
+
const campaignPoints = estimatedPoints.find(
|
|
108
|
+
(item) => item.campaignId === campaign.id,
|
|
109
|
+
)
|
|
110
|
+
if (campaignPoints) {
|
|
111
|
+
const { juniorTranchePoints, seniorTranchePoints } = campaignPoints
|
|
112
|
+
if (isUniTranche) {
|
|
113
|
+
setCampaignBasePoints(juniorTranchePoints ?? 0)
|
|
114
|
+
} else {
|
|
115
|
+
setCampaignBasePoints(
|
|
116
|
+
juniorTranchePoints < seniorTranchePoints
|
|
117
|
+
? juniorTranchePoints
|
|
118
|
+
: seniorTranchePoints,
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
getBasePoints()
|
|
125
|
+
}, [campaign, isUniTranche, minDepositAmountBN])
|
|
126
|
+
|
|
78
127
|
const approveLender = useCallback(async () => {
|
|
79
128
|
try {
|
|
80
129
|
isActionOngoingRef.current = true
|
|
@@ -269,6 +318,7 @@ export function PersonaEvaluation({
|
|
|
269
318
|
|
|
270
319
|
const startKYC = async () => {
|
|
271
320
|
isActionOngoingRef.current = true
|
|
321
|
+
isKYCResumedRef.current = false
|
|
272
322
|
setLoadingType('startKYC')
|
|
273
323
|
const client: Client = new Persona.Client({
|
|
274
324
|
inquiryId,
|
|
@@ -326,13 +376,17 @@ export function PersonaEvaluation({
|
|
|
326
376
|
}
|
|
327
377
|
`,
|
|
328
378
|
description: css`
|
|
329
|
-
|
|
379
|
+
text-align: justify;
|
|
330
380
|
margin-top: ${theme.spacing(10)};
|
|
331
381
|
padding: ${theme.spacing(0, 2)};
|
|
332
382
|
font-family: 'Uni-Neue-Regular';
|
|
333
383
|
font-size: 16px;
|
|
334
384
|
color: #a8a1b2;
|
|
335
385
|
`,
|
|
386
|
+
points: css`
|
|
387
|
+
color: #b246ff;
|
|
388
|
+
font-family: 'Uni-Neue-Bold';
|
|
389
|
+
`,
|
|
336
390
|
}
|
|
337
391
|
|
|
338
392
|
if (!loadingType) {
|
|
@@ -341,7 +395,19 @@ export function PersonaEvaluation({
|
|
|
341
395
|
<Box css={styles.iconWrapper}>
|
|
342
396
|
<img src={ApproveLenderImg} alt='approve-lender' />
|
|
343
397
|
</Box>
|
|
344
|
-
|
|
398
|
+
{campaign && isVerifyIdentity ? (
|
|
399
|
+
<Box css={styles.description}>
|
|
400
|
+
<span>You’ll be rewarded with a minimum of</span>
|
|
401
|
+
<span css={styles.points}>
|
|
402
|
+
{' '}
|
|
403
|
+
{formatNumber(campaignBasePoints)} Huma points{' '}
|
|
404
|
+
</span>
|
|
405
|
+
<span>after completing KYC and your first investment.</span>
|
|
406
|
+
</Box>
|
|
407
|
+
) : (
|
|
408
|
+
<Box css={styles.description}>{kycCopy.description}</Box>
|
|
409
|
+
)}
|
|
410
|
+
|
|
345
411
|
{Boolean(kycCopy.buttonText) && (
|
|
346
412
|
<BottomButton variant='contained' onClick={handleAction}>
|
|
347
413
|
{kycCopy.buttonText}
|