@huma-finance/widgets 0.0.48-beta.297 → 0.0.48-beta.299

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.297+48b8509",
3
+ "version": "0.0.48-beta.299+e4d1a9c",
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.297+48b8509",
34
- "@huma-finance/shared": "^0.0.48-beta.297+48b8509",
33
+ "@huma-finance/sdk": "^0.0.48-beta.299+e4d1a9c",
34
+ "@huma-finance/shared": "^0.0.47",
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": "48b8509c9aa8f1d267f77ab0982400b136e027d4"
196
+ "gitHead": "e4d1a9c194f7e439f6b11cfa2750abca11af8e33"
197
197
  }
@@ -43,7 +43,7 @@ export function Transfer({ poolInfo }: Props): React.ReactElement {
43
43
  title='Borrow'
44
44
  contract={creditContract}
45
45
  method='drawdown'
46
- params={[account, borrowAmountBN]}
46
+ params={[borrowAmountBN]}
47
47
  handleSuccess={handleSuccess}
48
48
  />
49
49
  )
@@ -14,6 +14,7 @@ type Props = {
14
14
  currentAmount: number | string
15
15
  maxAmount: number | string
16
16
  maxAmountText?: string
17
+ maxAmountTitle?: string
17
18
  info?: string
18
19
  handleChangeAmount: (amount: number) => void
19
20
  handleAction: () => void
@@ -28,6 +29,7 @@ export function InputAmountModal({
28
29
  currentAmount,
29
30
  maxAmount,
30
31
  maxAmountText = 'MAX',
32
+ maxAmountTitle,
31
33
  info,
32
34
  handleChangeAmount,
33
35
  handleAction,
@@ -53,23 +55,39 @@ export function InputAmountModal({
53
55
  line-height: 133.4%;
54
56
  }
55
57
  `,
58
+ maxWrapper: css`
59
+ position: relative;
60
+ display: flex;
61
+ justify-content: flex-end;
62
+ `,
63
+ maxTitle: css`
64
+ position: absolute;
65
+ color: ${theme.palette.text.primary};
66
+ font-family: 'Uni-Neue-Regular';
67
+ font-size: 12px;
68
+ line-height: 166%;
69
+ letter-spacing: 0.4px;
70
+ top: ${theme.spacing(-3)};
71
+ width: 200px;
72
+ text-align: right;
73
+ `,
56
74
  max: css`
57
75
  display: flex;
58
76
  min-width: fit-content;
59
77
  justify-content: center;
60
78
  align-items: center;
61
79
  border-radius: 32px;
62
- background: var(--Purple-3, #f7f1ff);
80
+ background: #f7f1ff;
63
81
  padding: 4px 10px;
64
82
  gap: 8px;
65
- color: var(--Purple-1, #b246ff);
83
+ color: #b246ff;
66
84
  font-family: 'Uni-Neue-Bold';
67
85
  font-size: 13px;
68
86
  line-height: 22px;
69
87
  letter-spacing: 0.46px;
70
88
  `,
71
89
  info: css`
72
- color: var(--Black-5, #6b6572);
90
+ color: ${theme.palette.text.primary};
73
91
  font-family: 'Uni-Neue-Bold';
74
92
  font-size: 20px;
75
93
  line-height: 160%;
@@ -107,7 +125,14 @@ export function InputAmountModal({
107
125
  placeholder={`0${suffix}`}
108
126
  variant='standard'
109
127
  InputProps={{
110
- endAdornment: (
128
+ endAdornment: maxAmountTitle ? (
129
+ <Box css={styles.maxWrapper}>
130
+ <Box css={styles.maxTitle}>{maxAmountTitle}</Box>
131
+ <Button css={styles.max} onClick={setMaxAmount}>
132
+ {maxAmountText}
133
+ </Button>
134
+ </Box>
135
+ ) : (
111
136
  <Button css={styles.max} onClick={setMaxAmount}>
112
137
  {maxAmountText}
113
138
  </Button>
@@ -53,6 +53,7 @@ export function ChooseAmount({
53
53
  handleChangeAmount={handleChangeShares}
54
54
  maxAmount={maxSharesFormatted}
55
55
  info={`${String(formatNumber(currentAmount))} ${symbol}`}
56
+ maxAmountTitle={`${formatNumber(maxSharesFormatted)} Shares`}
56
57
  suffix='Shares'
57
58
  handleAction={handleAction}
58
59
  actionText='REQUEST'
@@ -52,7 +52,7 @@ export function Transfer({
52
52
  <TxSendModalV2
53
53
  contract={trancheVaultContract}
54
54
  method='deposit'
55
- params={[supplyBigNumber, account]}
55
+ params={[supplyBigNumber]}
56
56
  handleSuccess={handleSuccess}
57
57
  />
58
58
  )
@@ -21,6 +21,7 @@ type Props = {
21
21
  tranche: TrancheType
22
22
  poolUnderlyingToken: UnderlyingTokenInfo
23
23
  redemptionStatus: TrancheRedemptionStatus
24
+ poolIsClosed: boolean
24
25
  }
25
26
 
26
27
  export function ConfirmTransfer({
@@ -28,6 +29,7 @@ export function ConfirmTransfer({
28
29
  tranche,
29
30
  poolUnderlyingToken,
30
31
  redemptionStatus,
32
+ poolIsClosed,
31
33
  }: Props): React.ReactElement {
32
34
  const theme = useTheme()
33
35
  const dispatch = useDispatch()
@@ -105,10 +107,12 @@ export function ConfirmTransfer({
105
107
  subTitle='Withdraw all the available amount'
106
108
  >
107
109
  <Box css={styles.itemWrapper}>
108
- <Box css={styles.item}>
109
- <Box>Shares processed</Box>
110
- <Box css={styles.itemValue}>{sharesProcessed}</Box>
111
- </Box>
110
+ {!poolIsClosed && (
111
+ <Box css={styles.item}>
112
+ <Box>Shares processed</Box>
113
+ <Box css={styles.itemValue}>{sharesProcessed}</Box>
114
+ </Box>
115
+ )}
112
116
  <Box css={styles.item}>
113
117
  <Box>Price Per Share</Box>
114
118
  <Box css={styles.itemValue}>
@@ -14,11 +14,13 @@ import { TxSendModalV2 } from '../../TxSendModalV2'
14
14
  type Props = {
15
15
  poolInfo: PoolInfoV2
16
16
  tranche: TrancheType
17
+ poolIsClosed: boolean
17
18
  }
18
19
 
19
20
  export function Transfer({
20
21
  poolInfo,
21
22
  tranche,
23
+ poolIsClosed,
22
24
  }: Props): React.ReactElement | null {
23
25
  const dispatch = useAppDispatch()
24
26
  const { account, provider } = useWeb3React()
@@ -40,7 +42,7 @@ export function Transfer({
40
42
  return (
41
43
  <TxSendModalV2
42
44
  contract={trancheVaultContract}
43
- method='disburse'
45
+ method={poolIsClosed ? 'withdrawAfterPoolClosure' : 'disburse'}
44
46
  params={[]}
45
47
  handleSuccess={handleSuccess}
46
48
  />
@@ -1,4 +1,5 @@
1
1
  import {
2
+ getPoolContractV2,
2
3
  getTrancheRedemptionStatusV2,
3
4
  POOL_NAME,
4
5
  TrancheRedemptionStatus,
@@ -7,7 +8,7 @@ import {
7
8
  usePoolUnderlyingTokenInfoV2,
8
9
  } from '@huma-finance/shared'
9
10
  import { useWeb3React } from '@web3-react/core'
10
- import React, { useCallback, useEffect } from 'react'
11
+ import React, { useCallback, useEffect, useState } from 'react'
11
12
  import { useDispatch } from 'react-redux'
12
13
 
13
14
  import { useAppSelector } from '../../../hooks/useRedux'
@@ -54,6 +55,24 @@ export function LendWithdrawV2({
54
55
  const [redemptionStatus, setRedemptionStatus] = React.useState<
55
56
  TrancheRedemptionStatus | undefined
56
57
  >()
58
+ const [poolIsClosed, setPoolIsClosed] = useState<boolean | undefined>(
59
+ undefined,
60
+ )
61
+
62
+ useEffect(() => {
63
+ const fetchData = async () => {
64
+ if (account && provider) {
65
+ const result = await getTrancheRedemptionStatusV2(
66
+ poolName,
67
+ trancheType,
68
+ account,
69
+ provider,
70
+ )
71
+ setRedemptionStatus(result)
72
+ }
73
+ }
74
+ fetchData()
75
+ }, [account, poolName, provider, trancheType])
57
76
 
58
77
  useEffect(() => {
59
78
  const fetchData = async () => {
@@ -70,6 +89,19 @@ export function LendWithdrawV2({
70
89
  fetchData()
71
90
  }, [account, poolName, provider, trancheType])
72
91
 
92
+ useEffect(() => {
93
+ const fetchData = async () => {
94
+ if (account && provider) {
95
+ const poolContract = await getPoolContractV2(poolName, provider)
96
+ if (poolContract) {
97
+ const poolIsClosed = await poolContract.isPoolClosed()
98
+ setPoolIsClosed(poolIsClosed)
99
+ }
100
+ }
101
+ }
102
+ fetchData()
103
+ }, [account, poolName, provider])
104
+
73
105
  useEffect(() => {
74
106
  if (!step) {
75
107
  dispatch(setStep(WIDGET_STEP.ConfirmTransfer))
@@ -85,7 +117,12 @@ export function LendWithdrawV2({
85
117
  [handleSuccess],
86
118
  )
87
119
 
88
- if (!poolInfo || !poolUnderlyingToken || !redemptionStatus) {
120
+ if (
121
+ !poolInfo ||
122
+ !poolUnderlyingToken ||
123
+ !redemptionStatus ||
124
+ poolIsClosed === undefined
125
+ ) {
89
126
  return (
90
127
  <WidgetWrapper
91
128
  isOpen
@@ -110,10 +147,15 @@ export function LendWithdrawV2({
110
147
  tranche={trancheType}
111
148
  redemptionStatus={redemptionStatus}
112
149
  poolUnderlyingToken={poolUnderlyingToken}
150
+ poolIsClosed={poolIsClosed}
113
151
  />
114
152
  )}
115
153
  {step === WIDGET_STEP.Transfer && (
116
- <Transfer poolInfo={poolInfo} tranche={trancheType} />
154
+ <Transfer
155
+ poolInfo={poolInfo}
156
+ tranche={trancheType}
157
+ poolIsClosed={poolIsClosed}
158
+ />
117
159
  )}
118
160
  {step === WIDGET_STEP.Done && (
119
161
  <Done