diff --git a/src/contexts/TransferOptions/defaults.ts b/src/contexts/TransferOptions/defaults.ts index f1aa16e2e2..ee62f1828a 100644 --- a/src/contexts/TransferOptions/defaults.ts +++ b/src/contexts/TransferOptions/defaults.ts @@ -14,6 +14,7 @@ export const defaultBondedContext: TransferOptionsContextInterface = { export const transferOptions: TransferOptions = { freeBalance: new BigNumber(0), transferrableBalance: new BigNumber(0), + balanceTxFees: new BigNumber(0), edReserved: new BigNumber(0), nominate: { active: new BigNumber(0), diff --git a/src/contexts/TransferOptions/index.tsx b/src/contexts/TransferOptions/index.tsx index fb7e1c7a79..6bd233b46b 100644 --- a/src/contexts/TransferOptions/index.tsx +++ b/src/contexts/TransferOptions/index.tsx @@ -105,6 +105,11 @@ export const TransferOptionsProvider = ({ // free balance after `total` ledger amount. const freeBalance = BigNumber.max(freeMinusReserve.minus(total), 0); + + // free balance to pay for tsx fees. + const balanceTxFees = BigNumber.max(freeMinusReserve.minus(frozen), 0); + + // free balance that can be transferred. const transferrableBalance = BigNumber.max( freeBalance.minus(feeReserve).minus(frozen), 0 @@ -164,6 +169,7 @@ export const TransferOptionsProvider = ({ return { freeBalance, transferrableBalance, + balanceTxFees, edReserved, nominate: nominateOptions(), pool: poolOptions(), diff --git a/src/contexts/TransferOptions/types.ts b/src/contexts/TransferOptions/types.ts index abba5ece10..6f4e6fb9f4 100644 --- a/src/contexts/TransferOptions/types.ts +++ b/src/contexts/TransferOptions/types.ts @@ -13,6 +13,7 @@ export interface TransferOptionsContextInterface { export interface TransferOptions { freeBalance: BigNumber; transferrableBalance: BigNumber; + balanceTxFees: BigNumber; edReserved: BigNumber; nominate: { active: BigNumber; diff --git a/src/contexts/TxMeta/index.tsx b/src/contexts/TxMeta/index.tsx index 16f74f6e32..5704dfb8a2 100644 --- a/src/contexts/TxMeta/index.tsx +++ b/src/contexts/TxMeta/index.tsx @@ -45,8 +45,8 @@ export const TxMetaProvider = ({ children }: { children: React.ReactNode }) => { const txSignatureRef = React.useRef(txSignature); useEffectIgnoreInitial(() => { - const { transferrableBalance } = getTransferOptions(sender); - setNotEnoughFunds(transferrableBalance.minus(txFees).isLessThan(0)); + const { balanceTxFees } = getTransferOptions(sender); + setNotEnoughFunds(balanceTxFees.minus(txFees).isLessThan(0)); }, [txFees, sender]); const resetTxFees = () => {