@huma-finance/widgets 0.0.12 → 0.0.15

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.
Files changed (47) hide show
  1. package/API.md +6 -5
  2. package/dist/cjs/index.cjs +5058 -5968
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/index.d.ts +9 -6
  5. package/dist/index.js +5059 -5969
  6. package/dist/index.js.map +1 -1
  7. package/package.json +16 -16
  8. package/src/components/ApproveAllowanceModal.tsx +5 -2
  9. package/src/components/ChainNotSupportedModal.tsx +33 -0
  10. package/src/components/ChooseAmountModal.tsx +322 -322
  11. package/src/components/ConfirmTransferModal.tsx +153 -0
  12. package/src/components/CreditLine/borrow/1-Evaluation.tsx +1 -2
  13. package/src/components/CreditLine/borrow/index.tsx +4 -6
  14. package/src/components/Factoring/FactoredList.tsx +1 -1
  15. package/src/components/InvoiceFactoring/borrow/1-Evaluation.tsx +1 -4
  16. package/src/components/InvoiceFactoring/borrow/{3-ChooseAmount.tsx → 2-ChooseAmount.tsx} +5 -3
  17. package/src/components/InvoiceFactoring/borrow/3-ConfirmTransfer.tsx +37 -0
  18. package/src/components/InvoiceFactoring/borrow/index.tsx +5 -7
  19. package/src/components/StreamFactoring/borrow/1-Evaluation.tsx +12 -4
  20. package/src/components/StreamFactoring/borrow/2-ChooseAmount.tsx +4 -1
  21. package/src/components/StreamFactoring/borrow/3-ConfirmTransfer.tsx +18 -80
  22. package/src/components/StreamFactoring/borrow/4-ApproveAllowance.tsx +4 -36
  23. package/src/components/StreamFactoring/borrow/5-Permit.tsx +14 -14
  24. package/src/components/SuperfluidFactoring/SuperfluidFactoredList.tsx +10 -1
  25. package/src/components/SuperfluidFactoring/SuperfluidUpcomingList.tsx +4 -22
  26. package/src/cosmos/CreditLineBorrow.fixture.tsx +1 -0
  27. package/src/cosmos/CreditLinePayment.fixture.tsx +1 -0
  28. package/src/cosmos/SDKTesting.fixture.tsx +615 -615
  29. package/src/cosmos/SuperfluidFactoringBorrow.fixture.tsx +3 -0
  30. package/src/cosmos/utils/env.ts +6 -0
  31. package/src/hooks/useEA.ts +10 -29
  32. package/src/index.tsx +88 -7
  33. package/src/reportWebVitals.ts +9 -9
  34. package/src/store/widgets.store.ts +0 -1
  35. package/src/utilTypes.d.ts +2 -0
  36. package/webpack.cosmos.js +9 -9
  37. package/src/components/AllowListModal.tsx +0 -113
  38. package/src/components/CreditLine/borrow/2-AllowList.tsx +0 -34
  39. package/src/components/InvoiceFactoring/borrow/2-AllowList.tsx +0 -34
  40. package/src/components/InvoiceFactoring/borrow/4-ConfirmTransfer.tsx +0 -104
  41. /package/src/components/CreditLine/borrow/{3-ChooseAmount.tsx → 2-ChooseAmount.tsx} +0 -0
  42. /package/src/components/CreditLine/borrow/{4-Transfer.tsx → 3-Transfer.tsx} +0 -0
  43. /package/src/components/CreditLine/borrow/{5-ApproveAllowance.tsx → 4-ApproveAllowance.tsx} +0 -0
  44. /package/src/components/CreditLine/borrow/{6-Success.tsx → 5-Success.tsx} +0 -0
  45. /package/src/components/InvoiceFactoring/borrow/{5-ApproveNFT.tsx → 4-ApproveNFT.tsx} +0 -0
  46. /package/src/components/InvoiceFactoring/borrow/{6-Transfer.tsx → 5-Transfer.tsx} +0 -0
  47. /package/src/components/InvoiceFactoring/borrow/{7-Success.tsx → 6-Success.tsx} +0 -0
@@ -0,0 +1,153 @@
1
+ import { combineStyles } from '@huma-finance/shared'
2
+ import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'
3
+ import { Box, Button, css, Typography, useTheme } from '@mui/material'
4
+ import React from 'react'
5
+
6
+ import { ReceiptIcon, UsdcIcon } from './icons'
7
+
8
+ type Props = {
9
+ title: string
10
+ description: string
11
+ items: [
12
+ { leftText: string; rightText: string },
13
+ { leftText: string; rightText: string },
14
+ ]
15
+ actionText: string
16
+ handleAction: () => void
17
+ }
18
+
19
+ export function ConfirmTransferModal({
20
+ title,
21
+ description,
22
+ items,
23
+ actionText,
24
+ handleAction,
25
+ }: Props): React.ReactElement | null {
26
+ const theme = useTheme()
27
+
28
+ const styles = {
29
+ wrapper: css`
30
+ height: 518px;
31
+ position: relative;
32
+ ${theme.cssMixins.colStretch};
33
+ `,
34
+ header: css`
35
+ ${theme.cssMixins.rowHCentered};
36
+ margin-top: -5px;
37
+ `,
38
+ description: css`
39
+ font-family: 'Uni-Neue-Regular';
40
+ font-size: 16px;
41
+ color: #49505b;
42
+ margin-top: 30px;
43
+ text-align: center;
44
+ `,
45
+ transferWrapper: css`
46
+ margin-top: 75px;
47
+ `,
48
+ transfer: css`
49
+ font-family: 'Uni-Neue-Regular';
50
+ ${theme.cssMixins.rowSpaceBetweened}
51
+ ${theme.cssMixins.rowVCentered}
52
+ height: 72px;
53
+ background: #f9f8fa;
54
+ border-radius: 4px;
55
+ font-weight: 500;
56
+ font-size: 16px;
57
+ color: #49505b;
58
+ padding: 24px 20px;
59
+ margin-bottom: 9px;
60
+ position: relative;
61
+ box-sizing: border-box;
62
+ `,
63
+ transferItem: css`
64
+ ${theme.cssMixins.rowVCentered}
65
+ `,
66
+ arrow: css`
67
+ @keyframes bounceAlpha {
68
+ 0% {
69
+ opacity: 1;
70
+ transform: translateX(0px) scale(1);
71
+ }
72
+ 25% {
73
+ opacity: 0;
74
+ transform: translateX(10px) scale(0.9);
75
+ }
76
+ 26% {
77
+ opacity: 0;
78
+ transform: translateX(-10px) scale(0.9);
79
+ }
80
+ 55% {
81
+ opacity: 1;
82
+ transform: translateX(0px) scale(1);
83
+ }
84
+ }
85
+ animation-name: bounceAlpha;
86
+ animation-duration: 1.4s;
87
+ animation-iteration-count: infinite;
88
+ animation-timing-function: linear;
89
+
90
+ color: #b246ff;
91
+ position: absolute;
92
+ margin: auto;
93
+ top: 0;
94
+ left: calc(15% + 36px);
95
+ bottom: 0;
96
+ right: 0;
97
+ width: 16px;
98
+ height: 16px;
99
+ `,
100
+ arrowFirst: css`
101
+ left: calc(15% + 20px);
102
+ animation-delay: 0.2s;
103
+ `,
104
+ okButton: css`
105
+ width: 100%;
106
+ position: absolute;
107
+ bottom: 0;
108
+ `,
109
+ usdcIcon: css`
110
+ width: 22px;
111
+ margin-right: 20px;
112
+ & > path:first-of-type {
113
+ fill: #76707e;
114
+ }
115
+ `,
116
+ }
117
+
118
+ return (
119
+ <Box css={styles.wrapper}>
120
+ <Typography variant='h6' css={styles.header}>
121
+ {title}
122
+ </Typography>
123
+ <Box css={styles.description}>{description}</Box>
124
+ <Box css={styles.transferWrapper}>
125
+ <Box css={styles.transfer}>
126
+ <Box css={styles.transferItem}>
127
+ <ReceiptIcon css={{ width: '24px', marginRight: '20px' }} />
128
+ {items[0].leftText}
129
+ </Box>
130
+ <ArrowForwardIosIcon
131
+ css={combineStyles([styles.arrow, styles.arrowFirst])}
132
+ />
133
+ <ArrowForwardIosIcon css={styles.arrow} />
134
+ <Box>{items[0].rightText}</Box>
135
+ </Box>
136
+ <Box css={styles.transfer}>
137
+ <Box css={styles.transferItem}>
138
+ <UsdcIcon css={styles.usdcIcon} />
139
+ {items[1].leftText}
140
+ </Box>
141
+ <ArrowForwardIosIcon
142
+ css={combineStyles([styles.arrow, styles.arrowFirst])}
143
+ />
144
+ <ArrowForwardIosIcon css={styles.arrow} />
145
+ <Box>{items[1].rightText}</Box>
146
+ </Box>
147
+ </Box>
148
+ <Button variant='contained' css={styles.okButton} onClick={handleAction}>
149
+ {actionText}
150
+ </Button>
151
+ </Box>
152
+ )
153
+ }
@@ -1,6 +1,6 @@
1
1
  import { Box, Button, css, Typography, useTheme } from '@mui/material'
2
2
  import { useWeb3React } from '@web3-react/core'
3
- import { ChainEnum, PoolInfoType } from '@huma-finance/shared'
3
+ import { PoolInfoType } from '@huma-finance/shared'
4
4
  import React, { useEffect, useState } from 'react'
5
5
 
6
6
  import useEA from '../../../hooks/useEA'
@@ -34,7 +34,6 @@ export function Evaluation({
34
34
  borrowerWalletAddress: account,
35
35
  },
36
36
  WIDGET_STEP.Evaluation,
37
- chainId === ChainEnum.Goerli,
38
37
  )
39
38
  handleApprove()
40
39
  setStatus('success')
@@ -16,11 +16,10 @@ import { WIDGET_STEP } from '../../../store/widgets.store'
16
16
  import { ErrorModal } from '../../ErrorModal'
17
17
  import { WidgetWrapper } from '../../WidgetWrapper'
18
18
  import { Evaluation } from './1-Evaluation'
19
- import { AllowList } from './2-AllowList'
20
- import { ChooseAmount } from './3-ChooseAmount'
21
- import { ApproveAllowance } from './5-ApproveAllowance'
22
- import { Transfer } from './4-Transfer'
23
- import { Success } from './6-Success'
19
+ import { ChooseAmount } from './2-ChooseAmount'
20
+ import { ApproveAllowance } from './4-ApproveAllowance'
21
+ import { Transfer } from './3-Transfer'
22
+ import { Success } from './5-Success'
24
23
 
25
24
  /**
26
25
  * Credit line pool borrow props
@@ -92,7 +91,6 @@ export function CreditLineBorrow({
92
91
  {step === WIDGET_STEP.Evaluation && (
93
92
  <Evaluation poolInfo={poolInfo} handleApprove={approveCallback} />
94
93
  )}
95
- {step === WIDGET_STEP.AddToAllowList && <AllowList poolInfo={poolInfo} />}
96
94
  {step === WIDGET_STEP.ChooseAmount && (
97
95
  <ChooseAmount poolInfo={poolInfo} accountStats={accountStats} />
98
96
  )}
@@ -58,7 +58,7 @@ export function FactoredList<T>({
58
58
  let factoredItem = {
59
59
  id,
60
60
  due: dueDate,
61
- icon: <ReceiptIcon css={{ width: '18px' }} />,
61
+ icon: <ReceiptIcon css={{ width: '24px' }} />,
62
62
  amount: formatMoney(downScale(receivableAmount.toString(), decimals)),
63
63
  factored: formatMoney(downScale(totalDue.toString(), decimals)),
64
64
  remained: formatMoney(
@@ -1,5 +1,5 @@
1
1
  import { useWeb3React } from '@web3-react/core'
2
- import { ChainEnum, PoolInfoType, toBigNumber } from '@huma-finance/shared'
2
+ import { PoolInfoType, toBigNumber } from '@huma-finance/shared'
3
3
  import React, { useEffect } from 'react'
4
4
 
5
5
  import useEA from '../../../hooks/useEA'
@@ -21,8 +21,6 @@ export function Evaluation({ poolInfo, tokenId }: Props): React.ReactElement {
21
21
  {
22
22
  poolAddress: poolInfo.pool,
23
23
  borrowerWalletAddress: account,
24
- receivableAddress: poolInfo.assetAddress,
25
- receivableParam: toBigNumber(tokenId).toHexString(),
26
24
  context: {
27
25
  receivable: {
28
26
  address: poolInfo.assetAddress!,
@@ -31,7 +29,6 @@ export function Evaluation({ poolInfo, tokenId }: Props): React.ReactElement {
31
29
  },
32
30
  },
33
31
  WIDGET_STEP.ChooseAmount,
34
- chainId === ChainEnum.Goerli,
35
32
  )
36
33
  }
37
34
  }, [
@@ -27,7 +27,9 @@ export function ChooseAmount({
27
27
  const [currentAmount, setCurrentAmount] = useState(0)
28
28
  const { approval } = useAppSelector(selectWidgetState)
29
29
  const { getFeesCharged } = useFeeManager(poolInfo.poolName, poolInfo.poolType)
30
- const [remainder, setRemainder] = useState(approval!.receivable?.amount)
30
+ const [remainder, setRemainder] = useState<string | number | undefined>(
31
+ approval!.receivable?.amountFormatted,
32
+ )
31
33
 
32
34
  const getAvailableCreditLimit = () => {
33
35
  if (approval && creditRecord) {
@@ -35,7 +37,7 @@ export function ChooseAmount({
35
37
  .add(creditRecord.totalDue)
36
38
  .sub(creditRecord.feesAndInterestDue)
37
39
  .toNumber()
38
- return Number(approval.terms.creditLimit) - principal
40
+ return Number(approval.terms.creditLimitFormatted) - principal
39
41
  }
40
42
  return 0
41
43
  }
@@ -45,7 +47,7 @@ export function ChooseAmount({
45
47
  if (approval) {
46
48
  setCurrentAmount(newAmount)
47
49
  setChargedFees(getFeesCharged(newAmount))
48
- setRemainder(Number(approval.receivable!.amount) - newAmount)
50
+ setRemainder(Number(approval.receivable!.amountFormatted) - newAmount)
49
51
  }
50
52
  },
51
53
  [approval, getFeesCharged],
@@ -0,0 +1,37 @@
1
+ import { isEmpty } from '@huma-finance/shared'
2
+ import React from 'react'
3
+
4
+ import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
5
+ import { setStep } from '../../../store/widgets.reducers'
6
+ import { selectWidgetState } from '../../../store/widgets.selectors'
7
+ import { WIDGET_STEP } from '../../../store/widgets.store'
8
+ import { ConfirmTransferModal } from '../../ConfirmTransferModal'
9
+
10
+ export function ConfirmTransfer(): React.ReactElement | null {
11
+ const dispatch = useAppDispatch()
12
+ const { borrowAmountNet, approval } = useAppSelector(selectWidgetState)
13
+
14
+ const handleAction = () => {
15
+ dispatch(setStep(WIDGET_STEP.ApproveNFT))
16
+ }
17
+
18
+ if (isEmpty(borrowAmountNet) || isEmpty(approval)) {
19
+ return null
20
+ }
21
+
22
+ return (
23
+ <ConfirmTransferModal
24
+ title='Confirm transaction details'
25
+ description={`Huma keeps your Invoice NFT as collateral until it's fully paid.`}
26
+ items={[
27
+ { leftText: 'Invoice NFT', rightText: 'Huma' },
28
+ {
29
+ leftText: `${borrowAmountNet!} ${approval?.token.symbol}`,
30
+ rightText: 'You',
31
+ },
32
+ ]}
33
+ actionText='Approve Transfer'
34
+ handleAction={handleAction}
35
+ />
36
+ )
37
+ }
@@ -16,12 +16,11 @@ import { WIDGET_STEP } from '../../../store/widgets.store'
16
16
  import { ErrorModal } from '../../ErrorModal'
17
17
  import { WidgetWrapper } from '../../WidgetWrapper'
18
18
  import { Evaluation } from './1-Evaluation'
19
- import { AllowList } from './2-AllowList'
20
- import { ChooseAmount } from './3-ChooseAmount'
21
- import { ConfirmTransfer } from './4-ConfirmTransfer'
22
- import { ApproveNFT } from './5-ApproveNFT'
23
- import { Transfer } from './6-Transfer'
24
- import { Success } from './7-Success'
19
+ import { ChooseAmount } from './2-ChooseAmount'
20
+ import { ConfirmTransfer } from './3-ConfirmTransfer'
21
+ import { ApproveNFT } from './4-ApproveNFT'
22
+ import { Transfer } from './5-Transfer'
23
+ import { Success } from './6-Success'
25
24
 
26
25
  /**
27
26
  * Invoice factoring pool borrow props
@@ -72,7 +71,6 @@ export function InvoiceFactoringBorrow({
72
71
  {step === WIDGET_STEP.Evaluation && (
73
72
  <Evaluation poolInfo={poolInfo} tokenId={tokenId.toString()} />
74
73
  )}
75
- {step === WIDGET_STEP.AddToAllowList && <AllowList poolInfo={poolInfo} />}
76
74
  {step === WIDGET_STEP.ChooseAmount && (
77
75
  <ChooseAmount poolInfo={poolInfo} accountStats={accountStats} />
78
76
  )}
@@ -26,17 +26,25 @@ export function Evaluation({
26
26
  {
27
27
  poolAddress: poolInfo.pool,
28
28
  borrowerWalletAddress: account,
29
- payerAddress,
30
- superToken,
31
29
  context: {
32
- payerAddress,
30
+ receivable: {
31
+ address: poolInfo.assetAddress!,
32
+ },
33
+ payerWalletAddress: payerAddress,
33
34
  superToken,
34
35
  },
35
36
  },
36
37
  WIDGET_STEP.ChooseAmount,
37
38
  )
38
39
  }
39
- }, [account, checkingEA, payerAddress, poolInfo.pool, superToken])
40
+ }, [
41
+ account,
42
+ checkingEA,
43
+ payerAddress,
44
+ poolInfo.assetAddress,
45
+ poolInfo.pool,
46
+ superToken,
47
+ ])
40
48
 
41
49
  return (
42
50
  <LoadingModal
@@ -49,6 +49,9 @@ export function ChooseAmount({
49
49
  if (borrowFlowrate.gte(currentFlowRateBN)) {
50
50
  borrowFlowrate = currentFlowRateBN.sub(1)
51
51
  }
52
+ if (borrowAmountBN.gte(approval!.terms.creditLimit)) {
53
+ borrowFlowrate = borrowFlowrate.sub(1)
54
+ }
52
55
 
53
56
  // As borrowFlowrate adds 1, need to calculate the new accurate borrow amount
54
57
  const newBorrowAmountBN = borrowFlowrate
@@ -111,7 +114,7 @@ export function ChooseAmount({
111
114
  <ChooseAmountModal
112
115
  title='Choose Amount'
113
116
  description1='Access up to 100% of your stream flowrate'
114
- sliderMax={Number(approval.terms.creditLimit)}
117
+ sliderMax={Number(approval.terms.creditLimitFormatted)}
115
118
  currentAmount={currentAmount}
116
119
  tokenSymbol={approval.token.symbol}
117
120
  topLeft='Fees'
@@ -1,104 +1,42 @@
1
- import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos'
2
- import { Box, Button, css, Typography, useTheme } from '@mui/material'
3
- import { useWeb3React } from '@web3-react/core'
4
1
  import { CHAINS, isEmpty } from '@huma-finance/shared'
5
- import React from 'react'
2
+ import { useWeb3React } from '@web3-react/core'
3
+ import React, { useCallback } from 'react'
6
4
 
7
5
  import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
8
6
  import { setStep } from '../../../store/widgets.reducers'
9
7
  import { selectWidgetState } from '../../../store/widgets.selectors'
10
8
  import { WIDGET_STEP } from '../../../store/widgets.store'
9
+ import { ConfirmTransferModal } from '../../ConfirmTransferModal'
11
10
 
12
11
  export function ConfirmTransfer(): React.ReactElement | null {
13
- const theme = useTheme()
14
12
  const dispatch = useAppDispatch()
15
13
  const { chainId } = useWeb3React()
16
14
  const { borrowAmount, approval } = useAppSelector(selectWidgetState)
17
15
 
18
- const styles = {
19
- wrapper: css`
20
- height: 518px;
21
- position: relative;
22
- ${theme.cssMixins.colStretch};
23
- `,
24
- header: css`
25
- ${theme.cssMixins.rowHCentered};
26
- margin-top: -5px;
27
- `,
28
- description: css`
29
- font-weight: 500;
30
- font-size: 16px;
31
- color: #49505b;
32
- margin-top: 30px;
33
- `,
34
- transferWrapper: css`
35
- margin-top: 75px;
36
- `,
37
- transfer: css`
38
- ${theme.cssMixins.rowSpaceBetweened}
39
- ${theme.cssMixins.rowVCentered}
40
- height: 72px;
41
- background: #f9f8fa;
42
- border-radius: 4px;
43
- font-weight: 500;
44
- font-size: 16px;
45
- color: #49505b;
46
- padding: 24px 32px;
47
- margin-bottom: 9px;
48
- position: relative;
49
- `,
50
- arrow: css`
51
- color: #d2d0d6;
52
- position: absolute;
53
- margin: auto;
54
- top: 0;
55
- left: 0;
56
- bottom: 0;
57
- right: 0;
58
- `,
59
- okButton: css`
60
- width: 100%;
61
- position: absolute;
62
- bottom: 0;
63
- `,
64
- }
65
-
66
- const handleAction = () => {
16
+ const handleAction = useCallback(() => {
67
17
  const step = CHAINS[chainId!].isTestnet
68
18
  ? WIDGET_STEP.ApproveAllowance
69
19
  : WIDGET_STEP.Permit
70
20
  dispatch(setStep(step))
71
- }
21
+ }, [chainId, dispatch])
72
22
 
73
23
  if (isEmpty(borrowAmount) || isEmpty(approval)) {
74
24
  return null
75
25
  }
76
26
 
77
27
  return (
78
- <Box css={styles.wrapper}>
79
- <Typography variant='h6' css={styles.header}>
80
- Confirm transaction details
81
- </Typography>
82
- <Box css={styles.description}>
83
- Huma keeps your Tradable Stream NFT as collateral until it's fully paid.
84
- </Box>
85
- <Box css={styles.transferWrapper}>
86
- <Box css={styles.transfer}>
87
- <Box>Tradable Stream</Box>
88
- <ArrowForwardIosIcon css={styles.arrow} />
89
- <Box>Huma</Box>
90
- </Box>
91
- <Box css={styles.transfer}>
92
- <Box>
93
- {borrowAmount!.toFixed(2)} {approval?.token.symbol}
94
- </Box>
95
- <ArrowForwardIosIcon css={styles.arrow} />
96
- <Box>You</Box>
97
- </Box>
98
- </Box>
99
- <Button variant='contained' css={styles.okButton} onClick={handleAction}>
100
- Approve Transfer
101
- </Button>
102
- </Box>
28
+ <ConfirmTransferModal
29
+ title='Confirm transaction details'
30
+ description={`Huma keeps your Tradable Stream NFT as collateral until it's fully paid.`}
31
+ items={[
32
+ { leftText: 'Tradable Stream', rightText: 'Huma' },
33
+ {
34
+ leftText: `${borrowAmount!.toFixed(2)} ${approval?.token.symbol}`,
35
+ rightText: 'You',
36
+ },
37
+ ]}
38
+ actionText='Approve Transfer'
39
+ handleAction={handleAction}
40
+ />
103
41
  )
104
42
  }
@@ -1,10 +1,4 @@
1
- import { useWeb3React } from '@web3-react/core'
2
- import {
3
- PoolInfoType,
4
- toBigNumber,
5
- upScale,
6
- usePoolAllowance,
7
- } from '@huma-finance/shared'
1
+ import { PoolInfoType } from '@huma-finance/shared'
8
2
  import React, { useCallback } from 'react'
9
3
  import { useDispatch } from 'react-redux'
10
4
 
@@ -13,7 +7,6 @@ import { setStep } from '../../../store/widgets.reducers'
13
7
  import { selectWidgetState } from '../../../store/widgets.selectors'
14
8
  import { WIDGET_STEP } from '../../../store/widgets.store'
15
9
  import { ApproveAllowanceModal } from '../../ApproveAllowanceModal'
16
- import { LoadingModal } from '../../LoadingModal'
17
10
 
18
11
  type Props = {
19
12
  poolInfo: PoolInfoType
@@ -23,43 +16,18 @@ export function ApproveAllowance({
23
16
  poolInfo,
24
17
  }: Props): React.ReactElement | null {
25
18
  const dispatch = useDispatch()
26
- const { account } = useWeb3React()
27
- const { borrowAmount, approval } = useAppSelector(selectWidgetState)
28
- const { allowance, loaded } = usePoolAllowance(
29
- poolInfo.poolName,
30
- poolInfo.poolType,
31
- account,
32
- )
33
-
34
- const getNewAllowance = () => {
35
- if (!borrowAmount || !loaded) {
36
- return null
37
- }
38
- return toBigNumber(
39
- upScale(borrowAmount, poolInfo.poolUnderlyingToken.decimals),
40
- ).add(allowance)
41
- }
19
+ const { borrowAmountBN } = useAppSelector(selectWidgetState)
42
20
 
43
21
  const handleSuccess = useCallback(() => {
44
22
  dispatch(setStep(WIDGET_STEP.Permit))
45
23
  }, [dispatch])
46
24
 
47
- const newAllowance = getNewAllowance()
48
-
49
- if (!newAllowance) {
50
- return (
51
- <LoadingModal
52
- title={`Approve ${approval?.token?.symbol}`}
53
- description='Waiting for approval confirmation...'
54
- />
55
- )
56
- }
57
-
58
25
  return (
59
26
  <ApproveAllowanceModal
60
27
  poolInfo={poolInfo}
61
- allowanceAmount={newAllowance}
28
+ allowanceAmount={borrowAmountBN!}
62
29
  handleSuccess={handleSuccess}
30
+ spender={poolInfo.poolProcessor!}
63
31
  />
64
32
  )
65
33
  }
@@ -1,14 +1,14 @@
1
- import { Contract, ethers } from 'ethers'
2
1
  import {
3
2
  CHAINS,
4
3
  Erc2612,
5
4
  PoolInfoType,
6
- StreamFactoringPool,
5
+ SuperfluidPoolProcessor,
7
6
  useERC2612Permit,
8
7
  useMount,
9
8
  } from '@huma-finance/shared'
10
9
  import ERC2612Abi from '@huma-finance/shared/dist/abis/erc2612.json'
11
- import PoolAbi from '@huma-finance/shared/dist/abis/StreamFactoringPool.json'
10
+ import PoolProcessorAbi from '@huma-finance/shared/dist/abis/SuperfluidPoolProcessor.json'
11
+ import { Contract, ethers } from 'ethers'
12
12
  import React from 'react'
13
13
  import { useDispatch } from 'react-redux'
14
14
 
@@ -46,12 +46,12 @@ export function Permit({
46
46
  const getApproveAllowanceCallData = async () => {
47
47
  const erc2612PermitResult = await getERC2612PermitMessage(
48
48
  tokenAddress,
49
- poolInfo.pool,
49
+ poolInfo.poolProcessor!,
50
50
  borrowAmountBN!,
51
51
  )
52
52
  const tokenContract = new Contract(tokenAddress, ERC2612Abi) as Erc2612
53
53
  return tokenContract.interface.encodeFunctionData('permit', [
54
- poolInfo.pool,
54
+ poolInfo.poolProcessor!,
55
55
  borrowAmountBN!,
56
56
  erc2612PermitResult.nonce,
57
57
  erc2612PermitResult.deadline,
@@ -67,7 +67,7 @@ export function Permit({
67
67
  borrower,
68
68
  superToken,
69
69
  payerAddress,
70
- poolInfo.pool,
70
+ poolInfo.poolProcessor!,
71
71
  stream!.borrowFlowrate!,
72
72
  stream!.durationInSeconds!,
73
73
  )
@@ -96,14 +96,14 @@ export function Permit({
96
96
  NFTPermitResult.s,
97
97
  ],
98
98
  )
99
- const poolContract = new Contract(
100
- poolInfo.pool,
101
- PoolAbi,
102
- ) as StreamFactoringPool
99
+ const poolProcessorContract = new Contract(
100
+ poolInfo.poolProcessor!,
101
+ PoolProcessorAbi,
102
+ ) as SuperfluidPoolProcessor
103
103
 
104
- return poolContract.interface.encodeFunctionData(
105
- 'drawdownWithAuthorization',
106
- [borrowAmountBN!, poolInfo.assetAddress!, drawdownEncodedData],
104
+ return poolProcessorContract.interface.encodeFunctionData(
105
+ 'mintAndDrawdown',
106
+ [borrower, borrowAmountBN!, poolInfo.assetAddress!, drawdownEncodedData],
107
107
  )
108
108
  }
109
109
 
@@ -120,7 +120,7 @@ export function Permit({
120
120
  }
121
121
 
122
122
  const drawdownCalldata = await getDrawdownCallData()
123
- addresses.push(poolInfo.pool)
123
+ addresses.push(poolInfo.poolProcessor!)
124
124
  callData.push(drawdownCalldata)
125
125
 
126
126
  dispatch(setMultisend({ addresses, callData }))
@@ -1,6 +1,6 @@
1
1
  import { EmotionJSX } from '@emotion/react/types/jsx-namespace'
2
2
  import { AccountStats, PoolInfoType } from '@huma-finance/shared'
3
- import React from 'react'
3
+ import React, { useCallback } from 'react'
4
4
 
5
5
  import { ColumnType } from '../../utilTypes'
6
6
  import { FactoredList } from '../Factoring'
@@ -48,6 +48,14 @@ export function SuperfluidFactoredList({
48
48
  accountStats,
49
49
  handlePayManually,
50
50
  }: Props): React.ReactElement {
51
+ const setItem = useCallback(
52
+ () =>
53
+ Promise.resolve({
54
+ name: poolInfo?.extra?.superTokens?.[0].symbol ?? '',
55
+ }),
56
+ [poolInfo?.extra?.superTokens],
57
+ )
58
+
51
59
  return (
52
60
  <FactoredList
53
61
  title='Streams'
@@ -56,6 +64,7 @@ export function SuperfluidFactoredList({
56
64
  handlePayManually={handlePayManually}
57
65
  getColumns={getColumns}
58
66
  accountStats={accountStats}
67
+ setItem={setItem}
59
68
  />
60
69
  )
61
70
  }