@huma-finance/widgets 0.0.51-beta.351 → 0.0.51-beta.361
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 +8 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/CreditLine/payment/1-ChooseAmount.tsx +3 -2
- package/src/components/CreditLine/payment/3-Transfer.tsx +5 -1
- package/src/components/Lend/withdraw/index.tsx +7 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huma-finance/widgets",
|
|
3
|
-
"version": "0.0.51-beta.
|
|
3
|
+
"version": "0.0.51-beta.361+68c9d02",
|
|
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.51-beta.
|
|
34
|
-
"@huma-finance/shared": "^0.0.51-beta.
|
|
33
|
+
"@huma-finance/sdk": "^0.0.51-beta.361+68c9d02",
|
|
34
|
+
"@huma-finance/shared": "^0.0.51-beta.361+68c9d02",
|
|
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": "68c9d025b5b4752b329e9ff82ba5cf2ec3dc8ed6"
|
|
197
197
|
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useCLPoolAllowance,
|
|
7
7
|
} from '@huma-finance/shared'
|
|
8
8
|
import React, { useCallback, useEffect, useState } from 'react'
|
|
9
|
+
import { BigNumber } from 'ethers'
|
|
9
10
|
|
|
10
11
|
import { useAppDispatch } from '../../../hooks/useRedux'
|
|
11
12
|
import { setPaymentAmount, setStep } from '../../../store/widgets.reducers'
|
|
@@ -48,8 +49,8 @@ export function ChooseAmount({
|
|
|
48
49
|
)
|
|
49
50
|
|
|
50
51
|
const handleAction = useCallback(() => {
|
|
51
|
-
const payAmount = upScale(currentAmount, decimals)
|
|
52
|
-
const step =
|
|
52
|
+
const payAmount = upScale<BigNumber>(toBigNumber(currentAmount), decimals)
|
|
53
|
+
const step = payAmount.gt(allowance)
|
|
53
54
|
? WIDGET_STEP.ApproveAllowance
|
|
54
55
|
: WIDGET_STEP.Transfer
|
|
55
56
|
dispatch(setStep(step))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useWeb3React } from '@web3-react/core'
|
|
2
2
|
import { PoolInfoType, toBigNumber, upScale } from '@huma-finance/shared'
|
|
3
3
|
import React, { useCallback } from 'react'
|
|
4
|
+
import { BigNumber } from 'ethers'
|
|
4
5
|
|
|
5
6
|
import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux'
|
|
6
7
|
import { selectWidgetState } from '../../../store/widgets.selectors'
|
|
@@ -17,7 +18,10 @@ export function Transfer({ poolInfo }: Props): React.ReactElement {
|
|
|
17
18
|
const { account } = useWeb3React()
|
|
18
19
|
const { paymentAmount } = useAppSelector(selectWidgetState)
|
|
19
20
|
const { decimals } = poolInfo.poolUnderlyingToken
|
|
20
|
-
const paymentBigNumber =
|
|
21
|
+
const paymentBigNumber = upScale<BigNumber>(
|
|
22
|
+
toBigNumber(paymentAmount!),
|
|
23
|
+
decimals,
|
|
24
|
+
)
|
|
21
25
|
|
|
22
26
|
const handleSuccess = useCallback(() => {
|
|
23
27
|
dispatch(setStep(WIDGET_STEP.Done))
|
|
@@ -62,8 +62,10 @@ export function LendWithdraw({
|
|
|
62
62
|
)
|
|
63
63
|
|
|
64
64
|
useEffect(() => {
|
|
65
|
-
if (!step && lenderPosition && poolBalance) {
|
|
65
|
+
if (!step && lenderPosition?.gt(0) && poolBalance?.gt(0)) {
|
|
66
66
|
dispatch(setStep(WIDGET_STEP.CheckWithdrawable))
|
|
67
|
+
} else if (!step && (lenderPosition?.eq(0) || poolBalance?.eq(0))) {
|
|
68
|
+
dispatch(setStep(WIDGET_STEP.Error))
|
|
67
69
|
}
|
|
68
70
|
}, [dispatch, lenderPosition, poolBalance, step])
|
|
69
71
|
|
|
@@ -88,14 +90,14 @@ export function LendWithdraw({
|
|
|
88
90
|
handleClose={handleClose}
|
|
89
91
|
handleSuccess={handleWithdrawSuccess}
|
|
90
92
|
>
|
|
91
|
-
{
|
|
93
|
+
{step === WIDGET_STEP.CheckWithdrawable && (
|
|
92
94
|
<CheckWithdrawable poolInfo={poolInfo} handleClose={handleClose} />
|
|
93
95
|
)}
|
|
94
|
-
{step === WIDGET_STEP.ChooseAmount && (
|
|
96
|
+
{step === WIDGET_STEP.ChooseAmount && lenderPosition && poolBalance && (
|
|
95
97
|
<ChooseAmount
|
|
96
98
|
poolInfo={poolInfo}
|
|
97
|
-
lenderPosition={lenderPosition
|
|
98
|
-
poolBalance={poolBalance
|
|
99
|
+
lenderPosition={lenderPosition}
|
|
100
|
+
poolBalance={poolBalance}
|
|
99
101
|
/>
|
|
100
102
|
)}
|
|
101
103
|
{step === WIDGET_STEP.Transfer && <Transfer poolInfo={poolInfo} />}
|