From 31a52acfa24921f7385f837d7621bec6904dd412 Mon Sep 17 00:00:00 2001 From: Victor Creed Date: Thu, 15 Oct 2020 08:06:07 +0300 Subject: [PATCH] fixes unlending --- src/app/containers/WithdrawLentAmount/index.tsx | 13 ++++++------- src/app/hooks/useSendContractTx.ts | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/containers/WithdrawLentAmount/index.tsx b/src/app/containers/WithdrawLentAmount/index.tsx index 43eedf588..b0e38a5cc 100644 --- a/src/app/containers/WithdrawLentAmount/index.tsx +++ b/src/app/containers/WithdrawLentAmount/index.tsx @@ -9,7 +9,7 @@ import { Asset } from 'types/asset'; import { useAccount } from '../../hooks/useAccount'; import { useUnLendTokensRBTC } from '../../hooks/useUnLendTokensRBTC'; import { WithdrawLentDialog } from '../../components/WithdrawLentDialog'; -import { weiTo18, weiToBigInt } from '../../../utils/blockchain/math-helpers'; +import { weiTo18 } from '../../../utils/blockchain/math-helpers'; import { bignumber, min } from 'mathjs'; import { useUnLendTokens } from '../../hooks/useUnLendTokens'; import { useLending_totalAssetSupply } from '../../hooks/lending/useLending_totalAssetSupply'; @@ -39,11 +39,10 @@ export function WithdrawLentAmount(props: Props) { const [balance, setBalance] = useState(calculateBalance()); const [amount, setAmount] = useState(weiTo18(balance)); - const fixedAmount = weiToBigInt(amount); const { unLend: unlendToken, ...txTokenState } = useUnLendTokens(props.asset); const { unLend: unlendBtc, ...txBtcState } = useUnLendTokensRBTC(props.asset); - const [, /*txAmount*/ setTxAmount] = useState('0'); + const [txAmount, setTxAmount] = useState('0'); useEffect(() => { setBalance(calculateBalance()); @@ -64,16 +63,16 @@ export function WithdrawLentAmount(props: Props) { const handleUnLendClick = useCallback(() => { if (props.asset === Asset.BTC) { - unlendBtc(fixedAmount); + unlendBtc(txAmount); } else { - unlendToken(fixedAmount); + unlendToken(txAmount); } - }, [props.asset, unlendBtc, fixedAmount, unlendToken]); + }, [props.asset, unlendBtc, txAmount, unlendToken]); return ( setAmount(value)} onConfirm={() => handleUnLendClick()} diff --git a/src/app/hooks/useSendContractTx.ts b/src/app/hooks/useSendContractTx.ts index 66017f40b..ad2578ba6 100644 --- a/src/app/hooks/useSendContractTx.ts +++ b/src/app/hooks/useSendContractTx.ts @@ -59,6 +59,7 @@ export function useSendContractTx( setStatus(TransactionStatus.PENDING); }) .catch(e => { + console.error(e); setStatus(TransactionStatus.ERROR); setLoading(false); });