From 0e44c9e35d7963a573cd42d65cc7eb7f26d2a53b Mon Sep 17 00:00:00 2001 From: calvin-nl Date: Fri, 2 Feb 2024 09:39:37 -0500 Subject: [PATCH] Add 20% gas price buffer to legacy transactions --- lib/ethers/transaction.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/ethers/transaction.ex b/lib/ethers/transaction.ex index 36cbc32..473a729 100644 --- a/lib/ethers/transaction.ex +++ b/lib/ethers/transaction.ex @@ -249,6 +249,16 @@ defmodule Ethers.Transaction do end end + defp do_post_process(:gas_price, {:ok, v_hex}) do + with {:ok, v} <- Utils.hex_to_integer(v_hex) do + # Setting a higher value for gas_price gas since the actual base fee is + # determined by the last block. This way we minimize the chance to get stuck in + # queue when base fee increases + mex_fee_per_gas = div(v * 120, 100) + {:ok, {:gas_price, Utils.integer_to_hex(mex_fee_per_gas)}} + end + end + defp do_post_process(key, {:ok, v_hex}) do {:ok, {key, v_hex}} end