@huma-finance/widgets 0.0.62-beta.612 → 0.0.62-beta.616
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 +0 -185
- package/dist/cjs/index.cjs +955 -2880
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -116
- package/dist/index.js +658 -2601
- package/dist/index.js.map +1 -1
- package/package.json +9 -12
- package/src/components/InputAmountModal.tsx +2 -12
- package/src/components/Lend/addRedemptionV2/2-ChooseAmount.tsx +6 -1
- package/src/components/Lend/supplyV2/6-Success.tsx +10 -8
- package/src/components/Lend/supplyV2/7-Notifications.tsx +6 -1
- package/src/components/Notifi/NotifiContextWrapper.tsx +57 -0
- package/src/components/Notifi/NotifiSubscriptionModal.tsx +118 -113
- package/src/components/WidgetWrapper.tsx +4 -6
- package/src/hooks/useNotifi.ts +28 -17
- package/src/index.tsx +7 -124
- package/src/store/widgets.reducers.ts +0 -5
- package/src/store/widgets.store.ts +0 -1
- package/src/theme/coreThemeConstants.ts +1 -1
- package/src/components/CreditLine/solanaBorrow/1-ChooseAmount.tsx +0 -86
- package/src/components/CreditLine/solanaBorrow/2-ApproveAllowance.tsx +0 -87
- package/src/components/CreditLine/solanaBorrow/index.tsx +0 -96
- package/src/components/Lend/solanaAddRedemption/1-ChooseTranche.tsx +0 -114
- package/src/components/Lend/solanaAddRedemption/2-ChooseAmount.tsx +0 -183
- package/src/components/Lend/solanaAddRedemption/3-Transfer.tsx +0 -102
- package/src/components/Lend/solanaAddRedemption/4-Done.tsx +0 -29
- package/src/components/Lend/solanaAddRedemption/index.tsx +0 -140
- package/src/components/Lend/solanaCancelRedemption/1-ChooseTranche.tsx +0 -114
- package/src/components/Lend/solanaCancelRedemption/2-Transfer.tsx +0 -99
- package/src/components/Lend/solanaCancelRedemption/3-Done.tsx +0 -55
- package/src/components/Lend/solanaCancelRedemption/index.tsx +0 -152
- package/src/components/Lend/solanaSupply/1-ChooseTranche.tsx +0 -116
- package/src/components/Lend/solanaSupply/2-Evaluation.tsx +0 -0
- package/src/components/Lend/solanaSupply/3-ChooseAmount.tsx +0 -130
- package/src/components/Lend/solanaSupply/4-Transfer.tsx +0 -89
- package/src/components/Lend/solanaSupply/5-Success.tsx +0 -50
- package/src/components/Lend/solanaSupply/index.tsx +0 -143
- package/src/components/SolanaTxDoneModal.tsx +0 -115
- package/src/components/SolanaTxSendModal.tsx +0 -61
- package/src/components/SolanaViewOnExplorer.tsx +0 -29
package/src/index.tsx
CHANGED
|
@@ -73,22 +73,7 @@ import { SuperfluidFactoring } from './components/SuperfluidFactoring'
|
|
|
73
73
|
import { store } from './store'
|
|
74
74
|
import { themeHuma } from './theme'
|
|
75
75
|
import { WCProps } from './utilTypes'
|
|
76
|
-
import {
|
|
77
|
-
SolanaLendSupply,
|
|
78
|
-
SolanaLendSupplyProps,
|
|
79
|
-
} from './components/Lend/solanaSupply'
|
|
80
|
-
import {
|
|
81
|
-
SolanaLendAddRedemption,
|
|
82
|
-
SolanaLendAddRedemptionProps,
|
|
83
|
-
} from './components/Lend/solanaAddRedemption'
|
|
84
|
-
import {
|
|
85
|
-
SolanaLendCancelRedemption,
|
|
86
|
-
SolanaLendCancelRedemptionProps,
|
|
87
|
-
} from './components/Lend/solanaCancelRedemption'
|
|
88
|
-
import {
|
|
89
|
-
SolanaBorrow,
|
|
90
|
-
SolanaBorrowProps,
|
|
91
|
-
} from './components/CreditLine/solanaBorrow'
|
|
76
|
+
import { NotifiContextWrapper } from './components/Notifi/NotifiContextWrapper'
|
|
92
77
|
|
|
93
78
|
/**
|
|
94
79
|
* Mapping of your JSON-RPC connections indexed by chainId
|
|
@@ -132,7 +117,11 @@ function Widget(props: WCProps<WidgetProps>) {
|
|
|
132
117
|
<ReduxProvider store={store}>
|
|
133
118
|
<Web3Provider {...(props as Web3Props)} defaultChainId={chainId}>
|
|
134
119
|
<AtomProvider>
|
|
135
|
-
<ChainSupportProvider>
|
|
120
|
+
<ChainSupportProvider>
|
|
121
|
+
<NotifiContextWrapper chainId={chainId}>
|
|
122
|
+
{children}
|
|
123
|
+
</NotifiContextWrapper>
|
|
124
|
+
</ChainSupportProvider>
|
|
136
125
|
</AtomProvider>
|
|
137
126
|
</Web3Provider>
|
|
138
127
|
</ReduxProvider>
|
|
@@ -545,110 +534,4 @@ export function ReceivableBackedCreditLinePaymentWidgetV2(
|
|
|
545
534
|
)
|
|
546
535
|
}
|
|
547
536
|
|
|
548
|
-
|
|
549
|
-
* Object representing the props passed to Solana widgets
|
|
550
|
-
* @typedef {Object} SolanaWidgetProps
|
|
551
|
-
*/
|
|
552
|
-
type SolanaWidgetProps = {
|
|
553
|
-
handleClose?: () => void
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
function SolanaWidget(props: WCProps<SolanaWidgetProps>) {
|
|
557
|
-
const { children } = props
|
|
558
|
-
|
|
559
|
-
return (
|
|
560
|
-
<ThemeProvider theme={themeHuma}>
|
|
561
|
-
<ReduxProvider store={store}>{children}</ReduxProvider>
|
|
562
|
-
</ThemeProvider>
|
|
563
|
-
)
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Lend pool supply widget props for Solana pools
|
|
568
|
-
* @typedef {Object} SolanaLendSupplyWidgetProps
|
|
569
|
-
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
570
|
-
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
571
|
-
*/
|
|
572
|
-
type SolanaLendSupplyWidgetProps = SolanaLendSupplyProps & SolanaWidgetProps
|
|
573
|
-
|
|
574
|
-
/**
|
|
575
|
-
* Lend pool supply widget for Solana pools
|
|
576
|
-
*
|
|
577
|
-
* @param {SolanaLendSupplyWidgetProps} props - Widget props
|
|
578
|
-
*/
|
|
579
|
-
export function SolanaLendSupplyWidget(props: SolanaLendSupplyWidgetProps) {
|
|
580
|
-
return (
|
|
581
|
-
<SolanaWidget {...props}>
|
|
582
|
-
<SolanaLendSupply {...props} />
|
|
583
|
-
</SolanaWidget>
|
|
584
|
-
)
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
/**
|
|
588
|
-
* Lend pool supply widget props for Solana pools
|
|
589
|
-
* @typedef {Object} SolanaLendAddRedemptionWidgetProps
|
|
590
|
-
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
591
|
-
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
592
|
-
*/
|
|
593
|
-
type SolanaLendAddRedemptionWidgetProps = SolanaLendAddRedemptionProps &
|
|
594
|
-
SolanaWidgetProps
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
* Lend pool supply widget for Solana pools
|
|
598
|
-
*
|
|
599
|
-
* @param {SolanaLendAddRedemptionWidgetProps} props - Widget props
|
|
600
|
-
*/
|
|
601
|
-
export function SolanaLendAddRedemptionWidget(
|
|
602
|
-
props: SolanaLendAddRedemptionWidgetProps,
|
|
603
|
-
) {
|
|
604
|
-
return (
|
|
605
|
-
<SolanaWidget {...props}>
|
|
606
|
-
<SolanaLendAddRedemption {...props} />
|
|
607
|
-
</SolanaWidget>
|
|
608
|
-
)
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Lend pool supply widget props for Solana pools
|
|
613
|
-
* @typedef {Object} SolanaLendCancelRedemptionWidgetProps
|
|
614
|
-
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
615
|
-
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
616
|
-
*/
|
|
617
|
-
type SolanaLendCancelRedemptionWidgetProps = SolanaLendCancelRedemptionProps &
|
|
618
|
-
SolanaWidgetProps
|
|
619
|
-
|
|
620
|
-
/**
|
|
621
|
-
* Lend pool supply widget for Solana pools
|
|
622
|
-
*
|
|
623
|
-
* @param {SolanaLendCancelRedemptionWidgetProps} props - Widget props
|
|
624
|
-
*/
|
|
625
|
-
export function SolanaLendCancelRedemptionWidget(
|
|
626
|
-
props: SolanaLendCancelRedemptionWidgetProps,
|
|
627
|
-
) {
|
|
628
|
-
return (
|
|
629
|
-
<SolanaWidget {...props}>
|
|
630
|
-
<SolanaLendCancelRedemption {...props} />
|
|
631
|
-
</SolanaWidget>
|
|
632
|
-
)
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* Lend pool supply widget props for Solana pools
|
|
637
|
-
* @typedef {Object} SolanaBorrowWidgetProps
|
|
638
|
-
* @property {SolanaLendSupplyProps} SolanaLendSupplyProps - Specific widget props
|
|
639
|
-
* @property {SolanaWidgetProps} SolanaWidgetProps - Widget general props.
|
|
640
|
-
*/
|
|
641
|
-
type SolanaBorrowWidgetProps = SolanaBorrowProps & SolanaWidgetProps
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Lend pool supply widget for Solana pools
|
|
645
|
-
*
|
|
646
|
-
* @param {SolanaBorrowWidgetProps} props - Widget props
|
|
647
|
-
*/
|
|
648
|
-
export function SolanaBorrowWidget(props: SolanaBorrowWidgetProps) {
|
|
649
|
-
return (
|
|
650
|
-
<SolanaWidget {...props}>
|
|
651
|
-
<SolanaBorrow {...props} />
|
|
652
|
-
</SolanaWidget>
|
|
653
|
-
)
|
|
654
|
-
}
|
|
537
|
+
export * from './components/Notifi/NotifiContextWrapper'
|
|
@@ -32,7 +32,6 @@ export const widgetSlice = createSlice({
|
|
|
32
32
|
state.withdrawShares = undefined
|
|
33
33
|
state.redeemAmount = undefined
|
|
34
34
|
state.redeemShares = undefined
|
|
35
|
-
state.solanaSignature = undefined
|
|
36
35
|
},
|
|
37
36
|
setStep: (state, { payload }: PayloadAction<WIDGET_STEP>) => {
|
|
38
37
|
state.step = payload
|
|
@@ -103,9 +102,6 @@ export const widgetSlice = createSlice({
|
|
|
103
102
|
setMultisend: (state, { payload }: PayloadAction<MultisendPayload>) => {
|
|
104
103
|
state.multisend = payload
|
|
105
104
|
},
|
|
106
|
-
setSolanaSignature: (state, { payload }: PayloadAction<string>) => {
|
|
107
|
-
state.solanaSignature = payload
|
|
108
|
-
},
|
|
109
105
|
setError: (
|
|
110
106
|
state,
|
|
111
107
|
{
|
|
@@ -134,7 +130,6 @@ export const {
|
|
|
134
130
|
setWithdrawShares,
|
|
135
131
|
setRedeemAmount,
|
|
136
132
|
setRedeemShares,
|
|
137
|
-
setSolanaSignature,
|
|
138
133
|
} = widgetSlice.actions
|
|
139
134
|
|
|
140
135
|
export default widgetSlice.reducer
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatNumber,
|
|
3
|
-
getSentinelAddress,
|
|
4
|
-
SolanaPoolInfo,
|
|
5
|
-
SolanaTokenUtils,
|
|
6
|
-
} from '@huma-finance/shared'
|
|
7
|
-
import { CreditConfigAccount } from '@huma-finance/web-shared'
|
|
8
|
-
import React, { useCallback, useMemo, useState } from 'react'
|
|
9
|
-
|
|
10
|
-
import { BN } from '@coral-xyz/anchor'
|
|
11
|
-
import { Account } from '@solana/spl-token'
|
|
12
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
13
|
-
import { setBorrowInfo } from '../../../store/widgets.reducers'
|
|
14
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
15
|
-
import { InputAmountModal } from '../../InputAmountModal'
|
|
16
|
-
|
|
17
|
-
type Props = {
|
|
18
|
-
poolInfo: SolanaPoolInfo
|
|
19
|
-
creditConfigAccount: CreditConfigAccount
|
|
20
|
-
tokenAccount: Account
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function ChooseAmount({
|
|
24
|
-
poolInfo,
|
|
25
|
-
creditConfigAccount,
|
|
26
|
-
tokenAccount,
|
|
27
|
-
}: Props): React.ReactElement {
|
|
28
|
-
const dispatch = useAppDispatch()
|
|
29
|
-
const { symbol, decimals } = poolInfo.underlyingMint
|
|
30
|
-
const sentinel = useMemo(
|
|
31
|
-
() => getSentinelAddress(poolInfo.chainId),
|
|
32
|
-
[poolInfo.chainId],
|
|
33
|
-
)
|
|
34
|
-
const [currentAmount, setCurrentAmount] = useState<number>(0)
|
|
35
|
-
const creditAvailable = useMemo(
|
|
36
|
-
() =>
|
|
37
|
-
SolanaTokenUtils.formatUnits(
|
|
38
|
-
creditConfigAccount.creditAvailable,
|
|
39
|
-
decimals,
|
|
40
|
-
),
|
|
41
|
-
[creditConfigAccount.creditAvailable, decimals],
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
const handleChangeAmount = (newAmount: number) => {
|
|
45
|
-
setCurrentAmount(newAmount)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const handleAction = useCallback(() => {
|
|
49
|
-
if (!tokenAccount) {
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const borrowAmountBN = SolanaTokenUtils.parseUnits(
|
|
54
|
-
String(currentAmount),
|
|
55
|
-
decimals,
|
|
56
|
-
)
|
|
57
|
-
const nextStep =
|
|
58
|
-
borrowAmountBN.gt(new BN(tokenAccount.delegatedAmount)) ||
|
|
59
|
-
tokenAccount.delegate?.toString() !== sentinel
|
|
60
|
-
? WIDGET_STEP.ApproveAllowance
|
|
61
|
-
: WIDGET_STEP.Transfer
|
|
62
|
-
|
|
63
|
-
dispatch(
|
|
64
|
-
setBorrowInfo({
|
|
65
|
-
borrowAmount: currentAmount,
|
|
66
|
-
borrowAmountBN,
|
|
67
|
-
chargedFees: 0,
|
|
68
|
-
nextStep,
|
|
69
|
-
}),
|
|
70
|
-
)
|
|
71
|
-
}, [currentAmount, decimals, dispatch, sentinel, tokenAccount])
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<InputAmountModal
|
|
75
|
-
title='Borrow'
|
|
76
|
-
subTitle='Choose Amount'
|
|
77
|
-
tokenSymbol={symbol}
|
|
78
|
-
currentAmount={currentAmount}
|
|
79
|
-
handleChangeAmount={handleChangeAmount}
|
|
80
|
-
maxAmount={creditAvailable}
|
|
81
|
-
infos={[`${String(formatNumber(creditAvailable))} ${symbol} Available`]}
|
|
82
|
-
handleAction={handleAction}
|
|
83
|
-
actionText='BORROW'
|
|
84
|
-
/>
|
|
85
|
-
)
|
|
86
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSentinelAddress,
|
|
3
|
-
SolanaPoolInfo,
|
|
4
|
-
SolanaTokenUtils,
|
|
5
|
-
} from '@huma-finance/shared'
|
|
6
|
-
import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
Account,
|
|
10
|
-
createApproveCheckedInstruction,
|
|
11
|
-
TOKEN_2022_PROGRAM_ID,
|
|
12
|
-
} from '@solana/spl-token'
|
|
13
|
-
import { useConnection, useWallet } from '@solana/wallet-adapter-react'
|
|
14
|
-
import { PublicKey, Transaction } from '@solana/web3.js'
|
|
15
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
16
|
-
import { SolanaTxSendModal } from '../../SolanaTxSendModal'
|
|
17
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
18
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
19
|
-
|
|
20
|
-
type Props = {
|
|
21
|
-
poolInfo: SolanaPoolInfo
|
|
22
|
-
tokenAccount: Account
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function ApproveAllowance({
|
|
26
|
-
poolInfo,
|
|
27
|
-
tokenAccount,
|
|
28
|
-
}: Props): React.ReactElement | null {
|
|
29
|
-
const dispatch = useAppDispatch()
|
|
30
|
-
const { wallet, publicKey, sendTransaction, signTransaction } = useWallet()
|
|
31
|
-
const sentinel = useMemo(
|
|
32
|
-
() => getSentinelAddress(poolInfo.chainId),
|
|
33
|
-
[poolInfo.chainId],
|
|
34
|
-
)
|
|
35
|
-
const { connection } = useConnection()
|
|
36
|
-
const [transaction, setTransaction] = useState<Transaction>()
|
|
37
|
-
|
|
38
|
-
const handleSuccess = useCallback(() => {
|
|
39
|
-
dispatch(setStep(WIDGET_STEP.Transfer))
|
|
40
|
-
}, [dispatch])
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
async function getTx() {
|
|
44
|
-
if (!wallet || !publicKey || !connection || !signTransaction) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const tx = new Transaction().add(
|
|
49
|
-
createApproveCheckedInstruction(
|
|
50
|
-
tokenAccount.address,
|
|
51
|
-
new PublicKey(poolInfo.underlyingMint.address),
|
|
52
|
-
new PublicKey(sentinel), // delegate
|
|
53
|
-
publicKey, // owner of the wallet
|
|
54
|
-
SolanaTokenUtils.parseUnits(
|
|
55
|
-
'100000000000', // 100 billion
|
|
56
|
-
poolInfo.underlyingMint.decimals,
|
|
57
|
-
), // amount
|
|
58
|
-
poolInfo.underlyingMint.decimals,
|
|
59
|
-
undefined, // multiSigners
|
|
60
|
-
TOKEN_2022_PROGRAM_ID,
|
|
61
|
-
),
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
setTransaction(tx)
|
|
65
|
-
}
|
|
66
|
-
getTx()
|
|
67
|
-
}, [
|
|
68
|
-
connection,
|
|
69
|
-
dispatch,
|
|
70
|
-
poolInfo.underlyingMint.address,
|
|
71
|
-
poolInfo.underlyingMint.decimals,
|
|
72
|
-
publicKey,
|
|
73
|
-
sendTransaction,
|
|
74
|
-
sentinel,
|
|
75
|
-
signTransaction,
|
|
76
|
-
tokenAccount.address,
|
|
77
|
-
wallet,
|
|
78
|
-
])
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<SolanaTxSendModal
|
|
82
|
-
tx={transaction}
|
|
83
|
-
chainId={poolInfo.chainId}
|
|
84
|
-
handleSuccess={handleSuccess}
|
|
85
|
-
/>
|
|
86
|
-
)
|
|
87
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { SolanaPoolInfo } from '@huma-finance/shared'
|
|
2
|
-
import {
|
|
3
|
-
useBorrowerAccounts,
|
|
4
|
-
usePoolUnderlyingTokenAccount,
|
|
5
|
-
} from '@huma-finance/web-shared'
|
|
6
|
-
import React, { useEffect } from 'react'
|
|
7
|
-
import { useDispatch } from 'react-redux'
|
|
8
|
-
|
|
9
|
-
import { useAppSelector } from '../../../hooks/useRedux'
|
|
10
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
11
|
-
import { WidgetWrapper } from '../../WidgetWrapper'
|
|
12
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
13
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
14
|
-
import { ErrorModal } from '../../ErrorModal'
|
|
15
|
-
import { ChooseAmount } from './1-ChooseAmount'
|
|
16
|
-
import { ApproveAllowance } from './2-ApproveAllowance'
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Lend pool supply props
|
|
20
|
-
* @typedef {Object} SolanaBorrowProps
|
|
21
|
-
* @property {SolanaPoolInfo} poolInfo The metadata of the pool.
|
|
22
|
-
* @property {SolanaPoolState} poolState The current state config of the pool. * @property {function():void} handleClose Function to notify to close the widget modal when user clicks the 'x' close button.
|
|
23
|
-
* @property {function():void|undefined} handleSuccess Optional function to notify that the lending pool supply action is successful.
|
|
24
|
-
*/
|
|
25
|
-
export interface SolanaBorrowProps {
|
|
26
|
-
poolInfo: SolanaPoolInfo
|
|
27
|
-
handleClose: () => void
|
|
28
|
-
handleSuccess?: () => void
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function SolanaBorrow({
|
|
32
|
-
poolInfo,
|
|
33
|
-
handleClose,
|
|
34
|
-
handleSuccess,
|
|
35
|
-
}: SolanaBorrowProps): React.ReactElement | null {
|
|
36
|
-
const dispatch = useDispatch()
|
|
37
|
-
const { creditConfigAccount, loading: isLoadingBorrowerAccounts } =
|
|
38
|
-
useBorrowerAccounts(poolInfo.chainId, poolInfo.poolName)
|
|
39
|
-
const { account: tokenAccount, loading: isLoadingTokenAccounts } =
|
|
40
|
-
usePoolUnderlyingTokenAccount(poolInfo)
|
|
41
|
-
const { step, errorMessage } = useAppSelector(selectWidgetState)
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
if (!step) {
|
|
44
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
45
|
-
}
|
|
46
|
-
}, [dispatch, step])
|
|
47
|
-
|
|
48
|
-
const title = 'Redemption'
|
|
49
|
-
if (isLoadingBorrowerAccounts || isLoadingTokenAccounts) {
|
|
50
|
-
return (
|
|
51
|
-
<WidgetWrapper
|
|
52
|
-
isOpen
|
|
53
|
-
isLoading
|
|
54
|
-
loadingTitle={title}
|
|
55
|
-
handleClose={handleClose}
|
|
56
|
-
handleSuccess={handleSuccess}
|
|
57
|
-
/>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<WidgetWrapper
|
|
63
|
-
isOpen
|
|
64
|
-
loadingTitle={title}
|
|
65
|
-
handleClose={handleClose}
|
|
66
|
-
handleSuccess={handleSuccess}
|
|
67
|
-
>
|
|
68
|
-
{step === WIDGET_STEP.ChooseAmount &&
|
|
69
|
-
creditConfigAccount &&
|
|
70
|
-
tokenAccount && (
|
|
71
|
-
<ChooseAmount
|
|
72
|
-
poolInfo={poolInfo}
|
|
73
|
-
creditConfigAccount={creditConfigAccount}
|
|
74
|
-
tokenAccount={tokenAccount}
|
|
75
|
-
/>
|
|
76
|
-
)}
|
|
77
|
-
{step === WIDGET_STEP.ApproveAllowance && tokenAccount && (
|
|
78
|
-
<ApproveAllowance poolInfo={poolInfo} tokenAccount={tokenAccount} />
|
|
79
|
-
)}
|
|
80
|
-
{/* {step === WIDGET_STEP.Transfer && selectedTranche && (
|
|
81
|
-
<Transfer poolInfo={poolInfo} selectedTranche={selectedTranche} />
|
|
82
|
-
)}
|
|
83
|
-
{step === WIDGET_STEP.Done && (
|
|
84
|
-
<Done poolInfo={poolInfo} handleAction={handleClose} />
|
|
85
|
-
)} */}
|
|
86
|
-
{step === WIDGET_STEP.Error && (
|
|
87
|
-
<ErrorModal
|
|
88
|
-
title={title}
|
|
89
|
-
errorReason='Sorry there was an error'
|
|
90
|
-
errorMessage={errorMessage}
|
|
91
|
-
handleOk={handleClose}
|
|
92
|
-
/>
|
|
93
|
-
)}
|
|
94
|
-
</WidgetWrapper>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { TrancheType } from '@huma-finance/shared'
|
|
2
|
-
import {
|
|
3
|
-
css,
|
|
4
|
-
FormControl,
|
|
5
|
-
FormControlLabel,
|
|
6
|
-
FormLabel,
|
|
7
|
-
Radio,
|
|
8
|
-
RadioGroup,
|
|
9
|
-
useTheme,
|
|
10
|
-
} from '@mui/material'
|
|
11
|
-
import React from 'react'
|
|
12
|
-
|
|
13
|
-
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
14
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
15
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
16
|
-
import { BottomButton } from '../../BottomButton'
|
|
17
|
-
import { WrapperModal } from '../../WrapperModal'
|
|
18
|
-
|
|
19
|
-
type Props = {
|
|
20
|
-
selectedTranche: TrancheType | undefined
|
|
21
|
-
changeTranche: (tranche: TrancheType) => void
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function ChooseTranche({
|
|
25
|
-
selectedTranche,
|
|
26
|
-
changeTranche,
|
|
27
|
-
}: Props): React.ReactElement | null {
|
|
28
|
-
const theme = useTheme()
|
|
29
|
-
const dispatch = useAppDispatch()
|
|
30
|
-
|
|
31
|
-
const styles = {
|
|
32
|
-
subTitle: css`
|
|
33
|
-
color: ${theme.palette.text.primary} !important;
|
|
34
|
-
font-weight: 400;
|
|
35
|
-
font-size: 16px;
|
|
36
|
-
line-height: 150%;
|
|
37
|
-
letter-spacing: 0.15px;
|
|
38
|
-
margin-top: ${theme.spacing(5)};
|
|
39
|
-
margin-left: ${theme.spacing(2)};
|
|
40
|
-
`,
|
|
41
|
-
radioGroup: css`
|
|
42
|
-
margin-left: ${theme.spacing(3)};
|
|
43
|
-
margin-top: ${theme.spacing(3)};
|
|
44
|
-
`,
|
|
45
|
-
formControl: css`
|
|
46
|
-
margin-bottom: ${theme.spacing(1)};
|
|
47
|
-
|
|
48
|
-
.MuiFormControlLabel-label {
|
|
49
|
-
color: ${theme.palette.text.primary};
|
|
50
|
-
font-weight: 400;
|
|
51
|
-
font-size: 16px;
|
|
52
|
-
line-height: 150%;
|
|
53
|
-
letter-spacing: 0.15px;
|
|
54
|
-
}
|
|
55
|
-
`,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const handleNext = () => {
|
|
59
|
-
dispatch(setStep(WIDGET_STEP.ChooseAmount))
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const items: {
|
|
63
|
-
label: string
|
|
64
|
-
value: TrancheType
|
|
65
|
-
}[] = [
|
|
66
|
-
{
|
|
67
|
-
label: 'Senior',
|
|
68
|
-
value: 'senior',
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
label: 'Junior',
|
|
72
|
-
value: 'junior',
|
|
73
|
-
},
|
|
74
|
-
]
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<WrapperModal title='Redemption'>
|
|
78
|
-
<FormControl>
|
|
79
|
-
<FormLabel css={styles.subTitle}>Select Tranche Type</FormLabel>
|
|
80
|
-
<RadioGroup
|
|
81
|
-
aria-labelledby='buttons-group-label'
|
|
82
|
-
name='radio-buttons-group'
|
|
83
|
-
css={styles.radioGroup}
|
|
84
|
-
onChange={(e) => changeTranche(e.target.value as TrancheType)}
|
|
85
|
-
>
|
|
86
|
-
{items.map((item) => (
|
|
87
|
-
<FormControlLabel
|
|
88
|
-
key={item.label}
|
|
89
|
-
value={item.value}
|
|
90
|
-
control={
|
|
91
|
-
<Radio
|
|
92
|
-
sx={{
|
|
93
|
-
'& .MuiSvgIcon-root': {
|
|
94
|
-
fontSize: 24,
|
|
95
|
-
},
|
|
96
|
-
}}
|
|
97
|
-
/>
|
|
98
|
-
}
|
|
99
|
-
label={item.label}
|
|
100
|
-
css={styles.formControl}
|
|
101
|
-
/>
|
|
102
|
-
))}
|
|
103
|
-
</RadioGroup>
|
|
104
|
-
</FormControl>
|
|
105
|
-
<BottomButton
|
|
106
|
-
variant='contained'
|
|
107
|
-
disabled={!selectedTranche}
|
|
108
|
-
onClick={handleNext}
|
|
109
|
-
>
|
|
110
|
-
NEXT
|
|
111
|
-
</BottomButton>
|
|
112
|
-
</WrapperModal>
|
|
113
|
-
)
|
|
114
|
-
}
|