@huma-finance/widgets 0.0.48-beta.285 → 0.0.48-beta.287
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 +188 -183
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +189 -184
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CreditLine/borrowV2/1-ChooseAmount.tsx +8 -6
- package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +18 -8
- package/src/components/CreditLine/paymentV2/index.tsx +2 -2
- package/src/components/CreditLine/supplyFLC/index.tsx +2 -2
- package/src/components/InputAmountModal.tsx +129 -0
- package/src/components/Lend/redeemV2/1-ChooseAction.tsx +1 -0
- package/src/components/Lend/redeemV2/2-ChooseAmount.tsx +14 -75
- package/src/components/Lend/supply/2-ChooseAmount.tsx +1 -0
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +22 -67
- package/src/components/NumericFormatCustom.tsx +3 -1
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.287+ac85e1b",
|
|
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.287+ac85e1b",
|
|
34
|
+
"@huma-finance/shared": "^0.0.48-beta.287+ac85e1b",
|
|
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": "ac85e1b1a3db9eb903f585425b27c57c98a15e19"
|
|
197
197
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CreditStatsV2,
|
|
3
|
+
formatNumber,
|
|
3
4
|
PoolInfoV2,
|
|
4
5
|
UnderlyingTokenInfo,
|
|
5
6
|
usePoolSafeAllowanceV2,
|
|
@@ -11,7 +12,7 @@ import React, { useCallback, useState } from 'react'
|
|
|
11
12
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
12
13
|
import { setBorrowInfo } from '../../../store/widgets.reducers'
|
|
13
14
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
14
|
-
import {
|
|
15
|
+
import { InputAmountModal } from '../../InputAmountModal'
|
|
15
16
|
import { LoadingModal } from '../../LoadingModal'
|
|
16
17
|
|
|
17
18
|
type Props = {
|
|
@@ -65,15 +66,16 @@ export function ChooseAmount({
|
|
|
65
66
|
}
|
|
66
67
|
|
|
67
68
|
return (
|
|
68
|
-
<
|
|
69
|
+
<InputAmountModal
|
|
69
70
|
title='Borrow'
|
|
70
|
-
|
|
71
|
-
sliderMax={creditAvailableFormatted}
|
|
72
|
-
currentAmount={currentAmount}
|
|
71
|
+
subTitle='Choose Amount'
|
|
73
72
|
tokenSymbol={symbol}
|
|
73
|
+
currentAmount={currentAmount}
|
|
74
74
|
handleChangeAmount={handleChangeAmount}
|
|
75
|
+
maxAmount={creditAvailableFormatted}
|
|
76
|
+
info={`${formatNumber(creditAvailableFormatted)} Available`}
|
|
75
77
|
handleAction={handleAction}
|
|
76
|
-
actionText='
|
|
78
|
+
actionText='BORROW'
|
|
77
79
|
/>
|
|
78
80
|
)
|
|
79
81
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
formatNumber,
|
|
2
3
|
PoolInfoV2,
|
|
3
4
|
toBigNumber,
|
|
4
5
|
UnderlyingTokenInfo,
|
|
@@ -12,7 +13,7 @@ import React, { useCallback, useEffect, useState } from 'react'
|
|
|
12
13
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
13
14
|
import { setPaymentAmount, setStep } from '../../../store/widgets.reducers'
|
|
14
15
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
15
|
-
import {
|
|
16
|
+
import { InputAmountModal } from '../../InputAmountModal'
|
|
16
17
|
import { LoadingModal } from '../../LoadingModal'
|
|
17
18
|
|
|
18
19
|
type Props = {
|
|
@@ -44,6 +45,15 @@ export function ChooseAmount({
|
|
|
44
45
|
ethers.utils.formatUnits(payoffAmountBN, decimals),
|
|
45
46
|
)
|
|
46
47
|
|
|
48
|
+
console.log('totalDueAmountBN', totalDueAmountBN.toString())
|
|
49
|
+
console.log('payoffAmountBN', payoffAmountBN.toString())
|
|
50
|
+
console.log('payoffAmount', payoffAmount)
|
|
51
|
+
console.log('currentAmount', currentAmount)
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
setCurrentAmount(totalDueAmount)
|
|
55
|
+
}, [totalDueAmount])
|
|
56
|
+
|
|
47
57
|
useEffect(() => {
|
|
48
58
|
setCurrentAmount(totalDueAmount)
|
|
49
59
|
dispatch(setPaymentAmount({ paymentAmount: totalDueAmount }))
|
|
@@ -70,17 +80,17 @@ export function ChooseAmount({
|
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
return (
|
|
73
|
-
<
|
|
83
|
+
<InputAmountModal
|
|
74
84
|
title='Pay'
|
|
75
|
-
|
|
76
|
-
sliderMax={payoffAmount}
|
|
77
|
-
currentAmount={currentAmount}
|
|
85
|
+
subTitle='Enter Amount'
|
|
78
86
|
tokenSymbol={symbol}
|
|
87
|
+
currentAmount={currentAmount}
|
|
79
88
|
handleChangeAmount={handleChangeAmount}
|
|
89
|
+
maxAmount={payoffAmount}
|
|
90
|
+
maxAmountText='Pay Off'
|
|
91
|
+
info={`${formatNumber(totalDueAmount.toFixed(0))} Due`}
|
|
80
92
|
handleAction={handleAction}
|
|
81
|
-
actionText='
|
|
82
|
-
payoffAmount={payoffAmount}
|
|
83
|
-
hideTerms
|
|
93
|
+
actionText='PAY'
|
|
84
94
|
/>
|
|
85
95
|
)
|
|
86
96
|
}
|
|
@@ -42,7 +42,7 @@ export function CreditLinePaymentV2({
|
|
|
42
42
|
const poolName = POOL_NAME[poolNameStr]
|
|
43
43
|
const poolInfo = usePoolInfoV2(poolName, chainId)
|
|
44
44
|
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
45
|
-
const [{ creditRecord, payoffAmount }] = useCreditStatsV2(
|
|
45
|
+
const [{ creditRecord, totalDueAmount, payoffAmount }] = useCreditStatsV2(
|
|
46
46
|
poolName,
|
|
47
47
|
account,
|
|
48
48
|
provider,
|
|
@@ -78,7 +78,7 @@ export function CreditLinePaymentV2({
|
|
|
78
78
|
poolInfo={poolInfo}
|
|
79
79
|
poolUnderlyingToken={poolUnderlyingToken}
|
|
80
80
|
payoffAmount={payoffAmount!}
|
|
81
|
-
totalDueAmount={
|
|
81
|
+
totalDueAmount={totalDueAmount!}
|
|
82
82
|
/>
|
|
83
83
|
)}
|
|
84
84
|
{step === WIDGET_STEP.ApproveAllowance && (
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
FirstLossCoverIndex,
|
|
3
3
|
POOL_NAME,
|
|
4
4
|
useFirstLossCoverAllowanceV2,
|
|
5
|
-
|
|
5
|
+
useFirstLossCoverRequirementV2,
|
|
6
6
|
usePoolInfoV2,
|
|
7
7
|
usePoolUnderlyingTokenInfoV2,
|
|
8
8
|
} from '@huma-finance/shared'
|
|
@@ -44,7 +44,7 @@ export function SupplyFirstLossCover({
|
|
|
44
44
|
const poolInfo = usePoolInfoV2(poolName, chainId)
|
|
45
45
|
const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider)
|
|
46
46
|
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
47
|
-
const [requirement] =
|
|
47
|
+
const [requirement] = useFirstLossCoverRequirementV2(
|
|
48
48
|
poolName,
|
|
49
49
|
FirstLossCoverIndex.borrower,
|
|
50
50
|
account,
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Box, Button, css, TextField, useTheme } from '@mui/material'
|
|
2
|
+
import React, { useState } from 'react'
|
|
3
|
+
import { NumericFormat } from 'react-number-format'
|
|
4
|
+
|
|
5
|
+
import { BottomButton } from './BottomButton'
|
|
6
|
+
import { WrapperModal } from './WrapperModal'
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
title: string
|
|
10
|
+
subTitle: string
|
|
11
|
+
actionText: string
|
|
12
|
+
tokenSymbol: string
|
|
13
|
+
currentAmount: number | string
|
|
14
|
+
maxAmount: number | string
|
|
15
|
+
maxAmountText?: string
|
|
16
|
+
info?: string
|
|
17
|
+
handleChangeAmount: (amount: number) => void
|
|
18
|
+
handleAction: () => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function InputAmountModal({
|
|
22
|
+
title,
|
|
23
|
+
subTitle,
|
|
24
|
+
actionText,
|
|
25
|
+
tokenSymbol,
|
|
26
|
+
currentAmount,
|
|
27
|
+
maxAmount,
|
|
28
|
+
maxAmountText = 'MAX',
|
|
29
|
+
info,
|
|
30
|
+
handleChangeAmount,
|
|
31
|
+
handleAction,
|
|
32
|
+
}: Props): React.ReactElement | null {
|
|
33
|
+
const theme = useTheme()
|
|
34
|
+
const [inputTouched, setInputTouched] = useState(false)
|
|
35
|
+
const suffix = ` ${tokenSymbol}`
|
|
36
|
+
|
|
37
|
+
const styles = {
|
|
38
|
+
inputAmountWrapper: css`
|
|
39
|
+
margin-bottom: ${theme.spacing(1)};
|
|
40
|
+
margin-top: ${theme.spacing(16)};
|
|
41
|
+
`,
|
|
42
|
+
inputAmount: css`
|
|
43
|
+
${theme.cssMixins.rowSpaceBetweened};
|
|
44
|
+
`,
|
|
45
|
+
inputField: css`
|
|
46
|
+
input {
|
|
47
|
+
width: 100%;
|
|
48
|
+
color: ${theme.palette.text.primary};
|
|
49
|
+
font-family: 'Uni-Neue-Black';
|
|
50
|
+
font-size: 40px;
|
|
51
|
+
line-height: 133.4%;
|
|
52
|
+
}
|
|
53
|
+
`,
|
|
54
|
+
max: css`
|
|
55
|
+
display: flex;
|
|
56
|
+
min-width: fit-content;
|
|
57
|
+
justify-content: center;
|
|
58
|
+
align-items: center;
|
|
59
|
+
border-radius: 32px;
|
|
60
|
+
background: var(--Purple-3, #f7f1ff);
|
|
61
|
+
padding: 4px 10px;
|
|
62
|
+
gap: 8px;
|
|
63
|
+
color: var(--Purple-1, #b246ff);
|
|
64
|
+
font-family: 'Uni-Neue-Bold';
|
|
65
|
+
font-size: 13px;
|
|
66
|
+
line-height: 22px;
|
|
67
|
+
letter-spacing: 0.46px;
|
|
68
|
+
`,
|
|
69
|
+
info: css`
|
|
70
|
+
color: var(--Black-5, #6b6572);
|
|
71
|
+
font-family: 'Uni-Neue-Bold';
|
|
72
|
+
font-size: 20px;
|
|
73
|
+
line-height: 160%;
|
|
74
|
+
letter-spacing: 0.15px;
|
|
75
|
+
`,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const onChange = (
|
|
79
|
+
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
|
|
80
|
+
) => {
|
|
81
|
+
setInputTouched(true)
|
|
82
|
+
handleChangeAmount(
|
|
83
|
+
Number(event.target.value.replace(suffix, '').replaceAll(',', '')),
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const setMaxAmount = () => {
|
|
88
|
+
handleChangeAmount(Number(maxAmount))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<WrapperModal title={title} subTitle={subTitle}>
|
|
93
|
+
<Box css={styles.inputAmountWrapper}>
|
|
94
|
+
<Box css={styles.inputAmount}>
|
|
95
|
+
<NumericFormat
|
|
96
|
+
css={styles.inputField}
|
|
97
|
+
decimalScale={0}
|
|
98
|
+
onChange={onChange}
|
|
99
|
+
value={
|
|
100
|
+
!inputTouched && Number(currentAmount) === 0 ? '' : currentAmount
|
|
101
|
+
}
|
|
102
|
+
suffix={suffix}
|
|
103
|
+
thousandSeparator
|
|
104
|
+
customInput={TextField}
|
|
105
|
+
placeholder={`0${suffix}`}
|
|
106
|
+
variant='standard'
|
|
107
|
+
InputProps={{
|
|
108
|
+
endAdornment: (
|
|
109
|
+
<Button css={styles.max} onClick={setMaxAmount}>
|
|
110
|
+
{maxAmountText}
|
|
111
|
+
</Button>
|
|
112
|
+
),
|
|
113
|
+
}}
|
|
114
|
+
/>
|
|
115
|
+
</Box>
|
|
116
|
+
</Box>
|
|
117
|
+
|
|
118
|
+
{info && <Box css={styles.info}>{info}</Box>}
|
|
119
|
+
|
|
120
|
+
<BottomButton
|
|
121
|
+
variant='contained'
|
|
122
|
+
onClick={handleAction}
|
|
123
|
+
disabled={Number(currentAmount) <= 0}
|
|
124
|
+
>
|
|
125
|
+
{actionText}
|
|
126
|
+
</BottomButton>
|
|
127
|
+
</WrapperModal>
|
|
128
|
+
)
|
|
129
|
+
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
formatMoney,
|
|
3
2
|
getTrancheVaultContractV2,
|
|
4
3
|
PoolInfoV2,
|
|
5
4
|
UnderlyingTokenInfo,
|
|
6
5
|
} from '@huma-finance/shared'
|
|
7
|
-
import { Box, css, Slider, useTheme } from '@mui/material'
|
|
8
6
|
import { useWeb3React } from '@web3-react/core'
|
|
9
7
|
import { BigNumber, ethers } from 'ethers'
|
|
10
8
|
import React, { useEffect, useState } from 'react'
|
|
@@ -17,9 +15,8 @@ import {
|
|
|
17
15
|
setStep,
|
|
18
16
|
} from '../../../store/widgets.reducers'
|
|
19
17
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
20
|
-
import {
|
|
18
|
+
import { InputAmountModal } from '../../InputAmountModal'
|
|
21
19
|
import { LoadingModal } from '../../LoadingModal'
|
|
22
|
-
import { WrapperModal } from '../../WrapperModal'
|
|
23
20
|
|
|
24
21
|
type Props = {
|
|
25
22
|
poolInfo: PoolInfoV2
|
|
@@ -34,7 +31,6 @@ export function ChooseAmount({
|
|
|
34
31
|
redemptionType,
|
|
35
32
|
maxAmount,
|
|
36
33
|
}: Props): React.ReactElement | null {
|
|
37
|
-
const theme = useTheme()
|
|
38
34
|
const dispatch = useAppDispatch()
|
|
39
35
|
const { provider } = useWeb3React()
|
|
40
36
|
const { symbol } = poolUnderlyingToken
|
|
@@ -65,49 +61,7 @@ export function ChooseAmount({
|
|
|
65
61
|
}
|
|
66
62
|
}, [maxAmount, poolInfo.poolName, provider, redemptionActionInfo.tranche])
|
|
67
63
|
|
|
68
|
-
const
|
|
69
|
-
sliderWrapper: css`
|
|
70
|
-
margin-bottom: ${theme.spacing(1)};
|
|
71
|
-
margin-top: ${theme.spacing(14)};
|
|
72
|
-
`,
|
|
73
|
-
currentAmount: css`
|
|
74
|
-
font-size: 32px;
|
|
75
|
-
font-family: 'Uni-Neue-Bold';
|
|
76
|
-
text-align: center;
|
|
77
|
-
background: linear-gradient(233deg, #b246ff 4.17%, #ff6a8a 178.69%);
|
|
78
|
-
background-clip: text;
|
|
79
|
-
-webkit-background-clip: text;
|
|
80
|
-
-webkit-text-fill-color: transparent;
|
|
81
|
-
`,
|
|
82
|
-
slider: css`
|
|
83
|
-
&.MuiSlider-root {
|
|
84
|
-
height: 8px !important;
|
|
85
|
-
color: #e9e9e9;
|
|
86
|
-
}
|
|
87
|
-
& .MuiSlider-track {
|
|
88
|
-
height: 8px !important;
|
|
89
|
-
background: linear-gradient(232.71deg, #a363f4 4.17%, #ff6a8a 178.69%);
|
|
90
|
-
border-radius: 8px;
|
|
91
|
-
}
|
|
92
|
-
& .MuiSlider-thumb::before {
|
|
93
|
-
background: #ffffff;
|
|
94
|
-
border: 1px solid #f9f9f9;
|
|
95
|
-
box-shadow: 1px 1px 12px 2px rgba(163, 100, 244, 0.6);
|
|
96
|
-
border-radius: 50px;
|
|
97
|
-
width: 24px;
|
|
98
|
-
height: 24px;
|
|
99
|
-
}
|
|
100
|
-
`,
|
|
101
|
-
shares: css`
|
|
102
|
-
color: ${theme.palette.text.primary};
|
|
103
|
-
font-family: 'Uni-Neue-Bold';
|
|
104
|
-
font-size: 20px;
|
|
105
|
-
line-height: 160%;
|
|
106
|
-
letter-spacing: 0.15px;
|
|
107
|
-
`,
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const handleChangeAmount = (event: Event, newAmount: number | number[]) => {
|
|
64
|
+
const handleChangeAmount = (newAmount: number) => {
|
|
111
65
|
const shares = Number(newAmount) / sharePrice
|
|
112
66
|
setCurrentShares(shares)
|
|
113
67
|
setCurrentAmount(Number(newAmount))
|
|
@@ -128,35 +82,20 @@ export function ChooseAmount({
|
|
|
128
82
|
}
|
|
129
83
|
|
|
130
84
|
return (
|
|
131
|
-
<
|
|
132
|
-
title={redemptionActionInfo.action}
|
|
85
|
+
<InputAmountModal
|
|
86
|
+
title={`${redemptionActionInfo.action} Redemption Request`}
|
|
133
87
|
subTitle={
|
|
134
88
|
redemptionActionInfo.action === 'Create'
|
|
135
|
-
? `
|
|
136
|
-
: `
|
|
89
|
+
? `Input ${symbol} amount to redeem from ${redemptionActionInfo.tranche} tranche`
|
|
90
|
+
: `Input the amount of the redemption request in ${symbol} that you wish to cancel from the ${redemptionActionInfo.tranche} tranche`
|
|
137
91
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
css={styles.slider}
|
|
147
|
-
aria-label='Amount'
|
|
148
|
-
value={currentAmount}
|
|
149
|
-
onChange={handleChangeAmount}
|
|
150
|
-
/>
|
|
151
|
-
<Box css={styles.shares}>{currentShares.toFixed(1)} Shares</Box>
|
|
152
|
-
</Box>
|
|
153
|
-
<BottomButton
|
|
154
|
-
variant='contained'
|
|
155
|
-
onClick={handleAction}
|
|
156
|
-
disabled={Number(currentAmount) <= 0}
|
|
157
|
-
>
|
|
158
|
-
SUBMIT
|
|
159
|
-
</BottomButton>
|
|
160
|
-
</WrapperModal>
|
|
92
|
+
tokenSymbol={symbol}
|
|
93
|
+
currentAmount={currentAmount}
|
|
94
|
+
handleChangeAmount={handleChangeAmount}
|
|
95
|
+
maxAmount={maxAmountFormatted}
|
|
96
|
+
info={`${currentShares.toFixed(1)} Shares`}
|
|
97
|
+
handleAction={handleAction}
|
|
98
|
+
actionText='SUBMIT'
|
|
99
|
+
/>
|
|
161
100
|
)
|
|
162
101
|
}
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
PoolInfoV2,
|
|
3
3
|
TrancheType,
|
|
4
4
|
UnderlyingTokenInfo,
|
|
5
|
+
formatNumber,
|
|
5
6
|
usePoolSafeAllowanceV2,
|
|
7
|
+
usePoolUnderlyingTokenBalanceV2,
|
|
6
8
|
} from '@huma-finance/shared'
|
|
7
|
-
import { Box, css, TextField, useTheme } from '@mui/material'
|
|
8
9
|
import { useWeb3React } from '@web3-react/core'
|
|
9
10
|
import { BigNumber, ethers } from 'ethers'
|
|
10
11
|
import React, { useState } from 'react'
|
|
@@ -12,9 +13,7 @@ import React, { useState } from 'react'
|
|
|
12
13
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
13
14
|
import { setStep, setSupplyAmount } from '../../../store/widgets.reducers'
|
|
14
15
|
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
15
|
-
import {
|
|
16
|
-
import { NumericFormatCustom } from '../../NumericFormatCustom'
|
|
17
|
-
import { WrapperModal } from '../../WrapperModal'
|
|
16
|
+
import { InputAmountModal } from '../../InputAmountModal'
|
|
18
17
|
|
|
19
18
|
type Props = {
|
|
20
19
|
poolInfo: PoolInfoV2
|
|
@@ -27,7 +26,6 @@ export function ChooseAmount({
|
|
|
27
26
|
poolUnderlyingToken,
|
|
28
27
|
selectedTranche,
|
|
29
28
|
}: Props): React.ReactElement | null {
|
|
30
|
-
const theme = useTheme()
|
|
31
29
|
const dispatch = useAppDispatch()
|
|
32
30
|
const { account, provider } = useWeb3React()
|
|
33
31
|
const { symbol, decimals } = poolUnderlyingToken
|
|
@@ -37,38 +35,17 @@ export function ChooseAmount({
|
|
|
37
35
|
account,
|
|
38
36
|
provider,
|
|
39
37
|
)
|
|
40
|
-
const [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`,
|
|
50
|
-
inputField: css`
|
|
51
|
-
input {
|
|
52
|
-
width: 100%;
|
|
53
|
-
color: ${theme.palette.text.primary};
|
|
54
|
-
font-family: 'Uni-Neue-Black';
|
|
55
|
-
font-size: 40px;
|
|
56
|
-
line-height: 133.4%;
|
|
57
|
-
}
|
|
58
|
-
`,
|
|
59
|
-
inputFieldSymbol: css`
|
|
60
|
-
color: ${theme.palette.text.primary};
|
|
61
|
-
font-family: 'Uni-Neue-Black';
|
|
62
|
-
font-size: 40px;
|
|
63
|
-
line-height: 133.4%;
|
|
64
|
-
`,
|
|
65
|
-
}
|
|
38
|
+
const [balance] = usePoolUnderlyingTokenBalanceV2(
|
|
39
|
+
poolInfo.poolName,
|
|
40
|
+
account,
|
|
41
|
+
provider,
|
|
42
|
+
)
|
|
43
|
+
const maxAmountFormatted = ethers.utils.formatUnits(
|
|
44
|
+
balance,
|
|
45
|
+
poolUnderlyingToken.decimals,
|
|
46
|
+
)
|
|
66
47
|
|
|
67
|
-
const handleChangeAmount = (
|
|
68
|
-
event: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
|
|
69
|
-
) => {
|
|
70
|
-
setInputTouched(true)
|
|
71
|
-
const newAmount = event.target.value
|
|
48
|
+
const handleChangeAmount = (newAmount: number) => {
|
|
72
49
|
setCurrentAmount(newAmount)
|
|
73
50
|
dispatch(setSupplyAmount(Number(newAmount)))
|
|
74
51
|
}
|
|
@@ -85,38 +62,16 @@ export function ChooseAmount({
|
|
|
85
62
|
}
|
|
86
63
|
|
|
87
64
|
return (
|
|
88
|
-
<
|
|
65
|
+
<InputAmountModal
|
|
89
66
|
title='Enter Amount'
|
|
90
67
|
subTitle={`Supplying ${symbol} with ${selectedTranche}`}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
-
inputComponent: NumericFormatCustom as any,
|
|
101
|
-
endAdornment: (
|
|
102
|
-
<Box component='span' css={styles.inputFieldSymbol}>
|
|
103
|
-
{symbol}
|
|
104
|
-
</Box>
|
|
105
|
-
),
|
|
106
|
-
}}
|
|
107
|
-
placeholder='0'
|
|
108
|
-
variant='standard'
|
|
109
|
-
/>
|
|
110
|
-
</Box>
|
|
111
|
-
</Box>
|
|
112
|
-
|
|
113
|
-
<BottomButton
|
|
114
|
-
variant='contained'
|
|
115
|
-
onClick={handleAction}
|
|
116
|
-
disabled={Number(currentAmount) <= 0}
|
|
117
|
-
>
|
|
118
|
-
SUPPLY
|
|
119
|
-
</BottomButton>
|
|
120
|
-
</WrapperModal>
|
|
68
|
+
tokenSymbol={symbol}
|
|
69
|
+
currentAmount={currentAmount}
|
|
70
|
+
handleChangeAmount={handleChangeAmount}
|
|
71
|
+
maxAmount={maxAmountFormatted}
|
|
72
|
+
info={`${formatNumber(maxAmountFormatted)} Available`}
|
|
73
|
+
handleAction={handleAction}
|
|
74
|
+
actionText='SUPPLY'
|
|
75
|
+
/>
|
|
121
76
|
)
|
|
122
77
|
}
|
|
@@ -4,13 +4,14 @@ import { NumericFormat, NumericFormatProps } from 'react-number-format'
|
|
|
4
4
|
interface CustomProps {
|
|
5
5
|
onChange: (event: { target: { name: string; value: string } }) => void
|
|
6
6
|
name: string
|
|
7
|
+
suffix?: string
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export const NumericFormatCustom = React.forwardRef<
|
|
10
11
|
NumericFormatProps,
|
|
11
12
|
CustomProps
|
|
12
13
|
>((props, ref) => {
|
|
13
|
-
const { onChange, ...other } = props
|
|
14
|
+
const { onChange, suffix, ...other } = props
|
|
14
15
|
|
|
15
16
|
return (
|
|
16
17
|
<NumericFormat
|
|
@@ -26,6 +27,7 @@ export const NumericFormatCustom = React.forwardRef<
|
|
|
26
27
|
}}
|
|
27
28
|
thousandSeparator
|
|
28
29
|
valueIsNumericString
|
|
30
|
+
suffix={suffix}
|
|
29
31
|
/>
|
|
30
32
|
)
|
|
31
33
|
})
|