Skip to content

Commit

Permalink
fixes unlending
Browse files Browse the repository at this point in the history
  • Loading branch information
creed-victor committed Oct 15, 2020
1 parent d11ef48 commit 31a52ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/app/containers/WithdrawLentAmount/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
Expand All @@ -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 (
<WithdrawLentDialog
asset={props.asset}
amount={fixedAmount}
amount={amount}
balance={balance}
onChangeAmount={value => setAmount(value)}
onConfirm={() => handleUnLendClick()}
Expand Down
1 change: 1 addition & 0 deletions src/app/hooks/useSendContractTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function useSendContractTx(
setStatus(TransactionStatus.PENDING);
})
.catch(e => {
console.error(e);
setStatus(TransactionStatus.ERROR);
setLoading(false);
});
Expand Down

0 comments on commit 31a52ac

Please sign in to comment.