@huma-finance/widgets 0.0.48-v2.278 → 0.0.48-v2.296
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 +227 -221
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +228 -222
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CreditLine/borrow/5-Success.tsx +7 -2
- package/src/components/CreditLine/borrowV2/1-ChooseAmount.tsx +8 -6
- package/src/components/CreditLine/borrowV2/4-Success.tsx +2 -1
- package/src/components/CreditLine/payment/4-Success.tsx +2 -2
- package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +18 -8
- package/src/components/CreditLine/paymentV2/4-Success.tsx +2 -2
- 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/InvoiceFactoring/borrow/6-Success.tsx +5 -1
- 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/1-ChooseTranche.tsx +2 -41
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +22 -67
- package/src/components/Lend/supplyV2/index.tsx +54 -6
- package/src/components/NumericFormatCustom.tsx +3 -1
- package/src/components/ReceivableBackedCreditLine/borrow/5-Success.tsx +2 -1
- package/src/components/ReceivableBackedCreditLine/payment/7-Success.tsx +4 -4
- package/src/components/StreamFactoring/borrow/7-Success.tsx +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.48-v2.
|
|
3
|
+
"version": "0.0.48-v2.296+a164927",
|
|
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-v2.
|
|
34
|
-
"@huma-finance/shared": "^0.0.48-v2.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.48-v2.296+a164927",
|
|
34
|
+
"@huma-finance/shared": "^0.0.48-v2.296+a164927",
|
|
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": "a1649276102423ab6203cd72cf131f448a385cac"
|
|
197
197
|
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CreditRecordType,
|
|
3
|
+
PoolInfoType,
|
|
4
|
+
formatNumber,
|
|
5
|
+
timeUtil,
|
|
6
|
+
} from '@huma-finance/shared'
|
|
2
7
|
import React from 'react'
|
|
3
8
|
|
|
4
9
|
import { useAppSelector } from '../../../hooks/useRedux'
|
|
@@ -24,7 +29,7 @@ export function Success({
|
|
|
24
29
|
const dueDate = timeUtil.timestampToLL(creditRecord?.dueDate.toNumber())
|
|
25
30
|
|
|
26
31
|
const content = [
|
|
27
|
-
`${borrowAmountNet} ${symbol} is now in your wallet.`,
|
|
32
|
+
`${formatNumber(borrowAmountNet)} ${symbol} is now in your wallet.`,
|
|
28
33
|
`Note: your payment will be automatically deducted on ${dueDate}.`,
|
|
29
34
|
]
|
|
30
35
|
|
|
@@ -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,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CreditStatsV2,
|
|
3
|
+
formatNumber,
|
|
3
4
|
timeUtil,
|
|
4
5
|
UnderlyingTokenInfo,
|
|
5
6
|
} from '@huma-finance/shared'
|
|
@@ -27,7 +28,7 @@ export function Success({
|
|
|
27
28
|
const dueDate = timeUtil.timestampToLL(creditRecord?.nextDueDate.toNumber())
|
|
28
29
|
|
|
29
30
|
const content = [
|
|
30
|
-
`${borrowAmountNet} ${symbol} is now in your wallet.`,
|
|
31
|
+
`${formatNumber(borrowAmountNet)} ${symbol} is now in your wallet.`,
|
|
31
32
|
`Note: your payment will be automatically deducted on ${dueDate}.`,
|
|
32
33
|
]
|
|
33
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decodeLogs,
|
|
3
3
|
downScale,
|
|
4
|
-
|
|
4
|
+
formatNumber,
|
|
5
5
|
PoolInfoType,
|
|
6
6
|
sendTxAtom,
|
|
7
7
|
TRANSFER_ABI,
|
|
@@ -32,7 +32,7 @@ export function Success({ poolInfo, handleAction }: Props): React.ReactElement {
|
|
|
32
32
|
}, [decimals, txReceipt])
|
|
33
33
|
|
|
34
34
|
const content = [
|
|
35
|
-
`You successfully paid ${
|
|
35
|
+
`You successfully paid ${formatNumber(payedAmount)} ${symbol}.`,
|
|
36
36
|
]
|
|
37
37
|
|
|
38
38
|
return <TxDoneModal handleAction={handleAction} content={content} />
|
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decodeLogs,
|
|
3
3
|
downScale,
|
|
4
|
-
|
|
4
|
+
formatNumber,
|
|
5
5
|
sendTxAtom,
|
|
6
6
|
TRANSFER_ABI,
|
|
7
7
|
UnderlyingTokenInfo,
|
|
@@ -35,7 +35,7 @@ export function Success({
|
|
|
35
35
|
}, [decimals, txReceipt])
|
|
36
36
|
|
|
37
37
|
const content = [
|
|
38
|
-
`You successfully paid ${
|
|
38
|
+
`You successfully paid ${formatNumber(paidAmount)} ${symbol}.`,
|
|
39
39
|
]
|
|
40
40
|
|
|
41
41
|
return <TxDoneModal handleAction={handleAction} content={content} />
|
|
@@ -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,4 +1,6 @@
|
|
|
1
|
+
import { formatNumber } from '@huma-finance/shared'
|
|
1
2
|
import React from 'react'
|
|
3
|
+
|
|
2
4
|
import { useAppSelector } from '../../../hooks/useRedux'
|
|
3
5
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
4
6
|
import { TxDoneModal } from '../../TxDoneModal'
|
|
@@ -12,7 +14,9 @@ export function Success({ handleAction }: Props): React.ReactElement {
|
|
|
12
14
|
useAppSelector(selectWidgetState)
|
|
13
15
|
|
|
14
16
|
const content = [
|
|
15
|
-
`${borrowAmountNet} ${
|
|
17
|
+
`${formatNumber(borrowAmountNet)} ${
|
|
18
|
+
approval?.token.symbol
|
|
19
|
+
} is now in your wallet.`,
|
|
16
20
|
`The remaining ${remainder} ${approval?.token.symbol} will be sent to your wallet when the invoice is paid.`,
|
|
17
21
|
]
|
|
18
22
|
|
|
@@ -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
|
}
|
|
@@ -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>
|