You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
682 B
23 lines
682 B
4 years ago
|
import {
|
||
|
multiplyCurrencies,
|
||
|
subtractCurrencies,
|
||
4 years ago
|
} from '../../../../../helpers/utils/conversion-util';
|
||
4 years ago
|
import { addHexPrefix } from '../../../../../../app/scripts/lib/util';
|
||
7 years ago
|
|
||
4 years ago
|
export function calcMaxAmount({ balance, gasTotal, sendToken, tokenBalance }) {
|
||
4 years ago
|
const { decimals } = sendToken || {};
|
||
|
const multiplier = Math.pow(10, Number(decimals || 0));
|
||
7 years ago
|
|
||
5 years ago
|
return sendToken
|
||
4 years ago
|
? multiplyCurrencies(tokenBalance, multiplier, {
|
||
6 years ago
|
toNumericBase: 'hex',
|
||
|
multiplicandBase: 16,
|
||
4 years ago
|
multiplierBase: 10,
|
||
4 years ago
|
})
|
||
4 years ago
|
: subtractCurrencies(addHexPrefix(balance), addHexPrefix(gasTotal), {
|
||
|
toNumericBase: 'hex',
|
||
4 years ago
|
aBase: 16,
|
||
|
bBase: 16,
|
||
4 years ago
|
});
|
||
7 years ago
|
}
|