@huma-finance/widgets 0.0.48-beta.296 → 0.0.48-beta.298
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 +69 -22
- package/dist/cjs/index.cjs +2105 -2188
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.d.ts +45 -14
- package/dist/index.js +2105 -2189
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CreditLine/borrowV2/3-Transfer.tsx +1 -1
- package/src/components/CreditLine/paymentV2/1-ChooseAmount.tsx +5 -0
- package/src/components/InputAmountModal.tsx +32 -5
- package/src/components/Lend/{withdrawV2 → addRedemptionV2}/1-ChooseTranche.tsx +25 -30
- package/src/components/Lend/addRedemptionV2/2-ChooseAmount.tsx +62 -0
- package/src/components/Lend/{redeemV2 → addRedemptionV2}/3-Transfer.tsx +7 -12
- package/src/components/Lend/addRedemptionV2/4-Done.tsx +20 -0
- package/src/components/Lend/addRedemptionV2/index.tsx +172 -0
- package/src/components/Lend/cancelRedemptionV2 /1-Transfer.tsx +51 -0
- package/src/components/Lend/cancelRedemptionV2 /2-Done.tsx +29 -0
- package/src/components/Lend/cancelRedemptionV2 /index.tsx +120 -0
- package/src/components/Lend/supplyV2/1-ChooseTranche.tsx +23 -21
- package/src/components/Lend/supplyV2/3-ChooseAmount.tsx +20 -30
- package/src/components/Lend/supplyV2/4-ApproveAllowance.tsx +2 -15
- package/src/components/Lend/supplyV2/5-Transfer.tsx +14 -58
- package/src/components/Lend/supplyV2/6-Success.tsx +5 -2
- package/src/components/Lend/supplyV2/index.tsx +31 -59
- package/src/components/Lend/withdrawV2/1-ConfirmTransfer.tsx +135 -0
- package/src/components/Lend/withdrawV2/2-Transfer.tsx +50 -0
- package/src/components/Lend/withdrawV2/index.tsx +89 -130
- package/src/index.tsx +44 -15
- package/src/components/Lend/redeemV2/1-ChooseAction.tsx +0 -237
- package/src/components/Lend/redeemV2/2-ChooseAmount.tsx +0 -101
- package/src/components/Lend/redeemV2/4-Done.tsx +0 -33
- package/src/components/Lend/redeemV2/index.tsx +0 -207
- package/src/components/Lend/withdrawV2/2-ChooseAmount.tsx +0 -88
- package/src/components/Lend/withdrawV2/3-Transfer.tsx +0 -110
- /package/src/components/Lend/withdrawV2/{4-Done.tsx → 3-Done.tsx} +0 -0
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FirstLossCoverIndex,
|
|
3
|
-
getFirstLossCoverContractV2,
|
|
4
|
-
getTrancheVaultContractV2,
|
|
5
|
-
PoolInfoV2,
|
|
6
|
-
TrancheType,
|
|
7
|
-
UnderlyingTokenInfo,
|
|
8
|
-
} from '@huma-finance/shared'
|
|
9
|
-
import { useWeb3React } from '@web3-react/core'
|
|
10
|
-
import { BigNumber, ethers } from 'ethers'
|
|
11
|
-
import React, { useCallback, useEffect, useState } from 'react'
|
|
12
|
-
|
|
13
|
-
import { WithdrawType } from '.'
|
|
14
|
-
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
15
|
-
import { setStep } from '../../../store/widgets.reducers'
|
|
16
|
-
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
17
|
-
import { WIDGET_STEP } from '../../../store/widgets.store'
|
|
18
|
-
import { LoadingModal } from '../../LoadingModal'
|
|
19
|
-
import { TxSendModalV2 } from '../../TxSendModalV2'
|
|
20
|
-
|
|
21
|
-
type Props = {
|
|
22
|
-
poolInfo: PoolInfoV2
|
|
23
|
-
poolUnderlyingToken: UnderlyingTokenInfo
|
|
24
|
-
selectedWithdrawType: WithdrawType
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function Transfer({
|
|
28
|
-
poolInfo,
|
|
29
|
-
poolUnderlyingToken,
|
|
30
|
-
selectedWithdrawType,
|
|
31
|
-
}: Props): React.ReactElement | null {
|
|
32
|
-
const dispatch = useAppDispatch()
|
|
33
|
-
const { account, provider } = useWeb3React()
|
|
34
|
-
const { withdrawAmount } = useAppSelector(selectWidgetState)
|
|
35
|
-
const [firstLossCoverShares, setFirstLossCoverShares] = React.useState<
|
|
36
|
-
BigNumber | undefined
|
|
37
|
-
>(undefined)
|
|
38
|
-
const [contract, setContract] = useState<ethers.Contract | undefined>(
|
|
39
|
-
undefined,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const fetchData = async () => {
|
|
44
|
-
if (account) {
|
|
45
|
-
if (selectedWithdrawType.type === 'tranche') {
|
|
46
|
-
const trancheVaultContract = await getTrancheVaultContractV2(
|
|
47
|
-
poolInfo.poolName,
|
|
48
|
-
selectedWithdrawType.value as TrancheType,
|
|
49
|
-
provider,
|
|
50
|
-
account,
|
|
51
|
-
)
|
|
52
|
-
if (trancheVaultContract) {
|
|
53
|
-
setContract(trancheVaultContract)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (selectedWithdrawType.type === 'firstLossCover') {
|
|
57
|
-
const firstLossCoverContract = await getFirstLossCoverContractV2(
|
|
58
|
-
poolInfo.poolName,
|
|
59
|
-
Number(selectedWithdrawType.value) as FirstLossCoverIndex,
|
|
60
|
-
provider,
|
|
61
|
-
account,
|
|
62
|
-
)
|
|
63
|
-
if (firstLossCoverContract) {
|
|
64
|
-
const shares = await firstLossCoverContract.convertToShares(
|
|
65
|
-
ethers.utils.parseUnits(
|
|
66
|
-
String(withdrawAmount),
|
|
67
|
-
poolUnderlyingToken.decimals,
|
|
68
|
-
),
|
|
69
|
-
)
|
|
70
|
-
setFirstLossCoverShares(shares)
|
|
71
|
-
setContract(firstLossCoverContract)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
fetchData()
|
|
77
|
-
}, [
|
|
78
|
-
account,
|
|
79
|
-
poolInfo.poolName,
|
|
80
|
-
poolUnderlyingToken.decimals,
|
|
81
|
-
provider,
|
|
82
|
-
selectedWithdrawType.type,
|
|
83
|
-
selectedWithdrawType.value,
|
|
84
|
-
withdrawAmount,
|
|
85
|
-
])
|
|
86
|
-
|
|
87
|
-
const method =
|
|
88
|
-
selectedWithdrawType.type === 'tranche' ? 'disburse' : 'redeemCover'
|
|
89
|
-
const params =
|
|
90
|
-
selectedWithdrawType.type === 'tranche'
|
|
91
|
-
? []
|
|
92
|
-
: [firstLossCoverShares, account]
|
|
93
|
-
|
|
94
|
-
const handleSuccess = useCallback(() => {
|
|
95
|
-
dispatch(setStep(WIDGET_STEP.Done))
|
|
96
|
-
}, [dispatch])
|
|
97
|
-
|
|
98
|
-
if (!account || !contract) {
|
|
99
|
-
return <LoadingModal title='Transaction Pending' />
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<TxSendModalV2
|
|
104
|
-
contract={contract}
|
|
105
|
-
method={method}
|
|
106
|
-
params={params}
|
|
107
|
-
handleSuccess={handleSuccess}
|
|
108
|
-
/>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
File without changes
|