Skip to content

Commit 99aa094

Browse files
committed
refactor: clearer math in bump calculation
1 parent ecaf600 commit 99aa094

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

core/utils/eth_client_utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ func BytesToQuorumThresholdPercentages(quorumThresholdPercentagesBytes []byte) e
5252
// Very basic algorithm to calculate the gasPrice bump based on the currentGasPrice and retry iteration.
5353
// It adds a i/10 percentage to the current prices, where i represents the iteration.
5454
func CalculateGasPriceBumpBasedOnRetry(currentGasPrice *big.Int, iteration int) *big.Int {
55-
factor := (new(big.Int).Add(big.NewInt(100), new(big.Int).Mul(big.NewInt(int64(iteration)), big.NewInt(10))))
56-
gasPrice := new(big.Int).Mul(currentGasPrice, factor)
57-
gasPrice = gasPrice.Div(gasPrice, big.NewInt(100))
55+
percentageBump := new(big.Int).Div(big.NewInt(int64(iteration)), big.NewInt(10))
56+
bumpAmount := new(big.Int).Mul(currentGasPrice, percentageBump)
57+
bumpedGasPrice := new(big.Int).Add(currentGasPrice, bumpAmount)
5858

59-
return gasPrice
59+
return bumpedGasPrice
6060
}
6161

6262
// Sends a transaction and waits for the receipt for three blocks, if not received

0 commit comments

Comments
 (0)