diff --git a/packages/huma-widget/src/components/CreditLine/payment/1-ChooseAmount.tsx b/packages/huma-widget/src/components/CreditLine/payment/1-ChooseAmount.tsx index d29aac3..b87aee6 100644 --- a/packages/huma-widget/src/components/CreditLine/payment/1-ChooseAmount.tsx +++ b/packages/huma-widget/src/components/CreditLine/payment/1-ChooseAmount.tsx @@ -6,6 +6,7 @@ import { useCLPoolAllowance, } from '@huma-finance/shared' import React, { useCallback, useEffect, useState } from 'react' +import { BigNumber } from 'ethers' import { useAppDispatch } from '../../../hooks/useRedux' import { setPaymentAmount, setStep } from '../../../store/widgets.reducers' @@ -43,8 +44,8 @@ export function ChooseAmount({ ) const handleAction = useCallback(() => { - const payAmount = upScale(currentAmount, decimals) - const step = toBigNumber(payAmount).gt(allowance) + const payAmount = upScale(toBigNumber(currentAmount), decimals) + const step = payAmount.gt(allowance) ? WIDGET_STEP.ApproveAllowance : WIDGET_STEP.Transfer dispatch(setStep(step)) diff --git a/packages/huma-widget/src/components/CreditLine/payment/3-Transfer.tsx b/packages/huma-widget/src/components/CreditLine/payment/3-Transfer.tsx index a07d892..8df17ad 100644 --- a/packages/huma-widget/src/components/CreditLine/payment/3-Transfer.tsx +++ b/packages/huma-widget/src/components/CreditLine/payment/3-Transfer.tsx @@ -1,6 +1,7 @@ import { useWeb3React } from '@web3-react/core' import { PoolInfoType, toBigNumber, upScale } from '@huma-finance/shared' import React, { useCallback } from 'react' +import { BigNumber } from 'ethers' import { useAppDispatch, useAppSelector } from '../../../hooks/useRedux' import { selectWidgetState } from '../../../store/widgets.selectors' @@ -17,7 +18,10 @@ export function Transfer({ poolInfo }: Props): React.ReactElement { const { account } = useWeb3React() const { paymentAmount } = useAppSelector(selectWidgetState) const { decimals } = poolInfo.poolUnderlyingToken - const paymentBigNumber = toBigNumber(upScale(paymentAmount!, decimals)) + const paymentBigNumber = upScale( + toBigNumber(paymentAmount!), + decimals, + ) const handleSuccess = useCallback(() => { dispatch(setStep(WIDGET_STEP.Done))