@huma-finance/widgets 0.0.59-beta.494 → 0.0.59-beta.511

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.
Files changed (31) hide show
  1. package/API.md +2 -0
  2. package/dist/cjs/index.cjs +967 -191
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/index.d.ts +8 -0
  5. package/dist/index.js +968 -193
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -4
  8. package/src/components/ChooseAmountModal.tsx +2 -3
  9. package/src/components/ConfirmTransferModal.tsx +1 -1
  10. package/src/components/ErrorModal.tsx +1 -1
  11. package/src/components/InputAmountModal.tsx +2 -2
  12. package/src/components/Lend/supplyV2/2-Evaluation.tsx +31 -329
  13. package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +58 -9
  14. package/src/components/Lend/supplyV2/6-Success.tsx +49 -6
  15. package/src/components/Lend/supplyV2/7-Notifications.tsx +22 -3
  16. package/src/components/Lend/supplyV2/8-PointsEarned.tsx +231 -0
  17. package/src/components/Lend/supplyV2/components/PersonaEvaluation.tsx +442 -0
  18. package/src/components/Lend/supplyV2/components/SecuritizeEvaluation.tsx +345 -0
  19. package/src/components/Lend/supplyV2/index.tsx +67 -5
  20. package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +1 -1
  21. package/src/components/SignIn.tsx +7 -2
  22. package/src/components/TxDoneModal.tsx +21 -2
  23. package/src/components/humaModal/HumaModal.tsx +1 -0
  24. package/src/components/humaModal/HumaModalHeader.tsx +1 -0
  25. package/src/components/icons/congratulations.svg +54 -0
  26. package/src/components/icons/huma-points.svg +15 -0
  27. package/src/components/icons/index.tsx +15 -0
  28. package/src/components/icons/ribbon.svg +9 -0
  29. package/src/store/widgets.reducers.ts +0 -1
  30. package/src/store/widgets.store.ts +1 -0
  31. 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.494+6f95cfb",
3
+ "version": "0.0.59-beta.511+0c622c1",
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.58",
34
- "@huma-finance/shared": "^0.0.58",
33
+ "@huma-finance/sdk": "^0.0.59-beta.511+0c622c1",
34
+ "@huma-finance/shared": "^0.0.59-beta.511+0c622c1",
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": "6f95cfb0c84875a8e823e25133b37bc7cab0abdc"
198
+ "gitHead": "0c622c19fc81a5882f69a49a2272dc9035d995ab"
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: #e9e9e9;
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
- background: #49505b;
162
- border-color: #e9e3f1;
161
+ border-color: ${theme.palette.divider};
163
162
  `,
164
163
  okButton: css`
165
164
  font-weight: 700;
@@ -86,7 +86,7 @@ export function ConfirmTransferModal({
86
86
  animation-iteration-count: infinite;
87
87
  animation-timing-function: linear;
88
88
 
89
- color: #b246ff;
89
+ color: ${theme.palette.primary.main};
90
90
  position: absolute;
91
91
  margin: auto;
92
92
  top: 0;
@@ -62,7 +62,7 @@ export function ErrorModal({
62
62
  errorIcon: css`
63
63
  position: absolute;
64
64
  font-size: 20px;
65
- color: #d32f2f;
65
+ color: ${theme.palette.error.main};
66
66
  margin: ${theme.spacing(0, 2)};
67
67
  `,
68
68
  messageWrapper: css`
@@ -86,8 +86,8 @@ export function InputAmountModal({
86
86
  `,
87
87
  info: css`
88
88
  color: ${theme.palette.text.primary};
89
- font-weight: 700;
90
- font-size: 20px;
89
+ font-weight: 400;
90
+ font-size: 16px;
91
91
  line-height: 160%;
92
92
  letter-spacing: 0.15px;
93
93
  `,
@@ -1,346 +1,48 @@
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'
1
+ import { PoolInfoV2, TrancheType } from '@huma-finance/shared'
2
+ import { BigNumber } from 'ethers'
3
+ import React from 'react'
17
4
 
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
- }
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
- 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: ${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
- <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>
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
- formatNumber,
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 { LoadingModal } from '../../LoadingModal'
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
- const lpConfig = useLPConfigV2(poolInfo.poolName, provider)
50
- const isUniTranche = lpConfig?.maxSeniorJuniorRatio === 0
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
- if (!lpConfig) {
69
- return <LoadingModal title='Supply' />
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={`${formatNumber(maxAmountFormatted)} Available`}
131
+ info={info}
83
132
  handleAction={handleAction}
84
133
  actionText='SUPPLY'
85
134
  />
@@ -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
- const setupNotificationsOrClose = useCallback(() => {
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
- }, [dispatch, handleAction, isFirstTimeNotifiUser, notifiChainSupported])
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={setupNotificationsOrClose}
116
+ handleAction={handleUserAction}
75
117
  content={content}
76
- buttonText={hasNextStep ? "WHAT'S NEXT" : undefined}
118
+ subContent={getSubContent()}
119
+ buttonText={getButtonText()}
77
120
  />
78
121
  )
79
122
  }