Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
Split Existential Deposit and margin
Browse files Browse the repository at this point in the history
Restore EXISTENTIAL_DEPOSIT, use new constant EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN to handle recommended margin
  • Loading branch information
alexalouit committed May 12, 2022
1 parent e8aea66 commit 437622f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/families/polkadot/js-getTransactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
calculateAmount,
getMinimumAmountToBond,
getMinimumBalance,
EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN,
} from "./logic";
import { isValidAddress } from "./address";
import { getCurrentPolkadotPreloadData } from "./preload";
Expand Down Expand Up @@ -77,7 +78,11 @@ const getSendTransactionStatus = async (
const minimumBalanceExistential = getMinimumBalance(a);
const leftover = a.spendableBalance.minus(totalSpent);

if (a.spendableBalance.lte(EXISTENTIAL_DEPOSIT)) {
if (
a.spendableBalance.lte(
EXISTENTIAL_DEPOSIT.plus(EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN)
)
) {
errors.amount = new NotEnoughBalance();
} else if (
minimumBalanceExistential.gt(0) &&
Expand Down
3 changes: 2 additions & 1 deletion src/families/polkadot/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { Account, OperationType } from "../../types";
import type { Transaction } from "./types";
import { getCurrentPolkadotPreloadData } from "./preload";

export const EXISTENTIAL_DEPOSIT = new BigNumber(11000000000);
export const EXISTENTIAL_DEPOSIT = new BigNumber(10000000000);
export const EXISTENTIAL_DEPOSIT_RECOMMENDED_MARGIN = new BigNumber(1000000000); // Polkadot recommended Existential Deposit error margin
export const MAX_NOMINATIONS = 16;
export const MAX_UNLOCKINGS = 32;
export const PRELOAD_MAX_AGE = 60 * 1000;
Expand Down

0 comments on commit 437622f

Please sign in to comment.