@huma-finance/widgets 0.0.48-beta.284 → 0.0.48-beta.285
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.48-beta.
|
|
3
|
+
"version": "0.0.48-beta.285+8f3c2ea",
|
|
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.48-beta.
|
|
34
|
-
"@huma-finance/shared": "^0.0.48-beta.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.48-beta.285+8f3c2ea",
|
|
34
|
+
"@huma-finance/shared": "^0.0.48-beta.285+8f3c2ea",
|
|
35
35
|
"@mui/icons-material": "^5.3.0",
|
|
36
36
|
"@mui/material": "^5.0.6",
|
|
37
37
|
"@mui/styles": "^5.0.2",
|
|
@@ -193,5 +193,5 @@
|
|
|
193
193
|
"optionalDependencies": {
|
|
194
194
|
"encoding": "^0.1.13"
|
|
195
195
|
},
|
|
196
|
-
"gitHead": "
|
|
196
|
+
"gitHead": "8f3c2ea41fcde0549235950da76316b2262c0a83"
|
|
197
197
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
openInNewTab,
|
|
3
|
-
PoolInfoV2,
|
|
4
|
-
TrancheType,
|
|
5
|
-
UnderlyingTokenInfo,
|
|
6
|
-
useLenderApprovedV2,
|
|
7
|
-
} from '@huma-finance/shared'
|
|
1
|
+
import { TrancheType, UnderlyingTokenInfo } from '@huma-finance/shared'
|
|
8
2
|
import {
|
|
9
3
|
css,
|
|
10
4
|
FormControl,
|
|
@@ -14,7 +8,6 @@ import {
|
|
|
14
8
|
RadioGroup,
|
|
15
9
|
useTheme,
|
|
16
10
|
} from '@mui/material'
|
|
17
|
-
import { useWeb3React } from '@web3-react/core'
|
|
18
11
|
import React from 'react'
|
|
19
12
|
|
|
20
13
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
@@ -22,39 +15,20 @@ import { setStep } from '../../../store/widgets.reducers'
|
|
|
22
15
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
23
16
|
import { BottomButton } from '../../BottomButton'
|
|
24
17
|
import { WrapperModal } from '../../WrapperModal'
|
|
25
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
26
18
|
|
|
27
19
|
type Props = {
|
|
28
|
-
poolInfo: PoolInfoV2
|
|
29
20
|
poolUnderlyingToken: UnderlyingTokenInfo
|
|
30
21
|
selectedTranche: TrancheType | undefined
|
|
31
22
|
changeTranche: (tranche: TrancheType) => void
|
|
32
23
|
}
|
|
33
24
|
|
|
34
25
|
export function ChooseTranche({
|
|
35
|
-
poolInfo,
|
|
36
26
|
poolUnderlyingToken,
|
|
37
27
|
selectedTranche,
|
|
38
28
|
changeTranche,
|
|
39
29
|
}: Props): React.ReactElement | null {
|
|
40
30
|
const theme = useTheme()
|
|
41
|
-
const { poolName } = poolInfo
|
|
42
31
|
const dispatch = useAppDispatch()
|
|
43
|
-
const { account, provider } = useWeb3React()
|
|
44
|
-
const [lenderApprovedSenior] = useLenderApprovedV2(
|
|
45
|
-
poolName,
|
|
46
|
-
'senior',
|
|
47
|
-
account,
|
|
48
|
-
provider,
|
|
49
|
-
)
|
|
50
|
-
const [lenderApprovedJunior] = useLenderApprovedV2(
|
|
51
|
-
poolName,
|
|
52
|
-
'junior',
|
|
53
|
-
account,
|
|
54
|
-
provider,
|
|
55
|
-
)
|
|
56
|
-
const isLoading =
|
|
57
|
-
lenderApprovedSenior === undefined || lenderApprovedJunior === undefined
|
|
58
32
|
|
|
59
33
|
const styles = {
|
|
60
34
|
subTitle: css`
|
|
@@ -84,16 +58,7 @@ export function ChooseTranche({
|
|
|
84
58
|
}
|
|
85
59
|
|
|
86
60
|
const handleNext = () => {
|
|
87
|
-
|
|
88
|
-
(selectedTranche === 'senior' && lenderApprovedSenior) ||
|
|
89
|
-
(selectedTranche === 'junior' && lenderApprovedJunior)
|
|
90
|
-
) {
|
|
91
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
92
|
-
} else if (poolInfo.KYC) {
|
|
93
|
-
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
94
|
-
} else if (poolInfo.supplyLink) {
|
|
95
|
-
openInNewTab(poolInfo.supplyLink)
|
|
96
|
-
}
|
|
61
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
97
62
|
}
|
|
98
63
|
|
|
99
64
|
const items: {
|
|
@@ -110,10 +75,6 @@ export function ChooseTranche({
|
|
|
110
75
|
},
|
|
111
76
|
]
|
|
112
77
|
|
|
113
|
-
if (isLoading) {
|
|
114
|
-
return <LoadingModal title={`Supply ${poolUnderlyingToken.symbol}`} />
|
|
115
|
-
}
|
|
116
|
-
|
|
117
78
|
return (
|
|
118
79
|
<WrapperModal title={`Supply ${poolUnderlyingToken.symbol}`}>
|
|
119
80
|
<FormControl>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
POOL_NAME,
|
|
3
3
|
TrancheType,
|
|
4
|
+
openInNewTab,
|
|
5
|
+
useLenderApprovedV2,
|
|
4
6
|
usePoolInfoV2,
|
|
5
7
|
usePoolUnderlyingTokenInfoV2,
|
|
6
8
|
} from '@huma-finance/shared'
|
|
@@ -42,19 +44,66 @@ export function LendSupplyV2({
|
|
|
42
44
|
}: LendSupplyPropsV2): React.ReactElement | null {
|
|
43
45
|
const dispatch = useDispatch()
|
|
44
46
|
const poolName = POOL_NAME[poolNameStr]
|
|
45
|
-
const { chainId, provider } = useWeb3React()
|
|
47
|
+
const { chainId, provider, account } = useWeb3React()
|
|
46
48
|
const poolInfo = usePoolInfoV2(poolName, chainId)
|
|
47
49
|
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
48
50
|
const [selectedTranche, setSelectedTranche] = useState<TrancheType>()
|
|
49
51
|
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)
|
|
50
52
|
|
|
53
|
+
const [lenderApprovedSenior] = useLenderApprovedV2(
|
|
54
|
+
poolName,
|
|
55
|
+
'senior',
|
|
56
|
+
account,
|
|
57
|
+
provider,
|
|
58
|
+
)
|
|
59
|
+
const [lenderApprovedJunior] = useLenderApprovedV2(
|
|
60
|
+
poolName,
|
|
61
|
+
'junior',
|
|
62
|
+
account,
|
|
63
|
+
provider,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const lenderApproveStatusFetched =
|
|
67
|
+
lenderApprovedSenior !== undefined && lenderApprovedJunior !== undefined
|
|
68
|
+
|
|
51
69
|
useEffect(() => {
|
|
52
|
-
if (!step) {
|
|
53
|
-
|
|
70
|
+
if (!step && poolInfo && lenderApproveStatusFetched) {
|
|
71
|
+
if (lenderApprovedJunior && !lenderApprovedSenior) {
|
|
72
|
+
setSelectedTranche('junior')
|
|
73
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (lenderApprovedSenior && !lenderApprovedJunior) {
|
|
78
|
+
setSelectedTranche('senior')
|
|
79
|
+
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (lenderApprovedJunior && lenderApprovedSenior) {
|
|
84
|
+
dispatch(setStep(WIDGET_STEP.ChooseTranche))
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (poolInfo.KYC) {
|
|
89
|
+
dispatch(setStep(WIDGET_STEP.Evaluation))
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (poolInfo.supplyLink) {
|
|
94
|
+
openInNewTab(poolInfo.supplyLink)
|
|
95
|
+
}
|
|
54
96
|
}
|
|
55
|
-
}, [
|
|
97
|
+
}, [
|
|
98
|
+
dispatch,
|
|
99
|
+
lenderApproveStatusFetched,
|
|
100
|
+
lenderApprovedJunior,
|
|
101
|
+
lenderApprovedSenior,
|
|
102
|
+
poolInfo,
|
|
103
|
+
step,
|
|
104
|
+
])
|
|
56
105
|
|
|
57
|
-
if (!poolInfo || !poolUnderlyingToken) {
|
|
106
|
+
if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched) {
|
|
58
107
|
return (
|
|
59
108
|
<WidgetWrapper
|
|
60
109
|
isOpen
|
|
@@ -75,7 +124,6 @@ export function LendSupplyV2({
|
|
|
75
124
|
>
|
|
76
125
|
{step === WIDGET_STEP.ChooseTranche && (
|
|
77
126
|
<ChooseTranche
|
|
78
|
-
poolInfo={poolInfo}
|
|
79
127
|
poolUnderlyingToken={poolUnderlyingToken}
|
|
80
128
|
selectedTranche={selectedTranche}
|
|
81
129
|
changeTranche={setSelectedTranche}
|