diff --git a/packages/wallet-ts/src/broadcaster/Web3Broadcaster.ts b/packages/wallet-ts/src/broadcaster/Web3Broadcaster.ts index a997f665a..5d8260611 100644 --- a/packages/wallet-ts/src/broadcaster/Web3Broadcaster.ts +++ b/packages/wallet-ts/src/broadcaster/Web3Broadcaster.ts @@ -13,8 +13,8 @@ import { SendTransactionOptions } from '../wallets/types' import { DEFAULT_GAS_PRICE, GAS_LIMIT_MULTIPLIER, - GAS_PRICE_MULTIPLIER, INJ_DENOM, + TIP_IN_GWEI, TX_DEFAULTS_GAS, } from '../utils/constants' @@ -110,13 +110,14 @@ export class Web3Broadcaster { from: address, to: tokenAddress, gas: new BigNumberInWei(gas.times(GAS_LIMIT_MULTIPLIER).toFixed(0)) + .decimalPlaces(0) .toNumber() .toString(16), maxFeePerGas: new BigNumberInWei(gasPrice) - .times(GAS_PRICE_MULTIPLIER) + .decimalPlaces(0) .toNumber() .toString(16), - maxPriorityFeePerGas: '0x77359400' /* 2 gwei in hex */, + maxPriorityFeePerGas: TIP_IN_GWEI.toString(16), data, } } @@ -167,13 +168,14 @@ export class Web3Broadcaster { from: address, to: peggyContractAddress, gas: new BigNumberInWei(gas.times(GAS_LIMIT_MULTIPLIER).toFixed(0)) + .decimalPlaces(0) .toNumber() .toString(16), maxFeePerGas: new BigNumberInWei(gasPrice) - .times(GAS_PRICE_MULTIPLIER) + .decimalPlaces(0) .toNumber() .toString(16), - maxPriorityFeePerGas: '0x77359400' /* 2 gwei in hex */, + maxPriorityFeePerGas: TIP_IN_GWEI.toString(16), data, } } @@ -229,13 +231,14 @@ export class Web3Broadcaster { from: address, to: peggyContractAddress, gas: new BigNumberInWei(gas.times(GAS_LIMIT_MULTIPLIER).toFixed(0)) + .decimalPlaces(0) .toNumber() .toString(16), maxFeePerGas: new BigNumberInWei(gasPrice) - .times(GAS_PRICE_MULTIPLIER) + .decimalPlaces(0) .toNumber() .toString(16), - maxPriorityFeePerGas: '0x77359400' /* 2 gwei in hex */, + maxPriorityFeePerGas: TIP_IN_GWEI.toString(16), data: abiEncodedData, } } diff --git a/packages/wallet-ts/src/strategies/wallet/strategies/Ledger/Base.ts b/packages/wallet-ts/src/strategies/wallet/strategies/Ledger/Base.ts index 8366b36ad..0e4a2905d 100644 --- a/packages/wallet-ts/src/strategies/wallet/strategies/Ledger/Base.ts +++ b/packages/wallet-ts/src/strategies/wallet/strategies/Ledger/Base.ts @@ -16,6 +16,7 @@ import { } from '@injectivelabs/exceptions' import { DirectSignResponse } from '@cosmjs/proto-signing' import { TxRaw } from '@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb' +import { TIP_IN_GWEI } from 'packages/wallet-ts/src/utils' import { ConcreteWalletStrategy, EthereumWalletStrategyArgs, @@ -230,7 +231,7 @@ export default class LedgerBase gasLimit: addHexPrefix(txData.gas), maxFeePerGas: addHexPrefix(txData.gasPrice || txData.maxFeePerGas), maxPriorityFeePerGas: addHexPrefix( - txData.maxPriorityFeePerGas || '0x77359400' /* 2 Gwei in HEX */, + txData.maxPriorityFeePerGas || TIP_IN_GWEI.toString(16), ), } diff --git a/packages/wallet-ts/src/strategies/wallet/strategies/Trezor/index.ts b/packages/wallet-ts/src/strategies/wallet/strategies/Trezor/index.ts index 6c8645f44..253dc4d78 100644 --- a/packages/wallet-ts/src/strategies/wallet/strategies/Trezor/index.ts +++ b/packages/wallet-ts/src/strategies/wallet/strategies/Trezor/index.ts @@ -17,6 +17,7 @@ import { } from '@injectivelabs/exceptions' import { DirectSignResponse } from '@cosmjs/proto-signing' import { TxRaw } from '@injectivelabs/chain-api/cosmos/tx/v1beta1/tx_pb' +import { TIP_IN_GWEI } from 'packages/wallet-ts/src/utils' import { ConcreteWalletStrategy, EthereumWalletStrategyArgs, @@ -254,7 +255,7 @@ export default class Trezor gasLimit: addHexPrefix(txData.gas), maxFeePerGas: addHexPrefix(txData.gasPrice || txData.maxFeePerGas), maxPriorityFeePerGas: addHexPrefix( - txData.maxPriorityFeePerGas || '0x77359400' /* 2 Gwei in HEX */, + txData.maxPriorityFeePerGas || TIP_IN_GWEI.toString(16), ), } const tx = FeeMarketEIP1559Transaction.fromTxData(eip1559TxData, { diff --git a/packages/wallet-ts/src/utils/constants.ts b/packages/wallet-ts/src/utils/constants.ts index 31272090e..f42d6cb15 100644 --- a/packages/wallet-ts/src/utils/constants.ts +++ b/packages/wallet-ts/src/utils/constants.ts @@ -1,6 +1,9 @@ import { BigNumberInBase } from '@injectivelabs/utils' export const GWEI_IN_WEI: BigNumberInBase = new BigNumberInBase(1000000000) +export const TIP_IN_GWEI: BigNumberInBase = new BigNumberInBase(2).times( + GWEI_IN_WEI, +) export const GAS_LIMIT_MULTIPLIER = 1.2 export const GAS_PRICE_MULTIPLIER = 1.1 export const TX_DEFAULTS_GAS = 80_000_000