-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update gas price checks in transaction pool to use base fees
- Loading branch information
1 parent
bbfd2b9
commit 5680656
Showing
8 changed files
with
64 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package gaspricelimits | ||
|
||
import "math/big" | ||
|
||
// GetSuggestedGasPriceForNewTransactions a gas price that should be suggested | ||
// to users for new transactions based on the current base fee. This function | ||
// returns a value that is 10% higher than the base fee to provide a buffer | ||
// for the price to increase before the transaction is included in a block. | ||
func GetSuggestedGasPriceForNewTransactions(baseFee *big.Int) *big.Int { | ||
return addPercentage(baseFee, 10) | ||
} | ||
|
||
// GetMinimumFeeCapForTransactionPool returns the gas price the transaction pool | ||
// should check for when accepting new transactions. This function returns a | ||
// value that is 5% higher than the base fee to provide a buffer for the price | ||
// to increase before the transaction is included in a block. | ||
func GetMinimumFeeCapForTransactionPool(baseFee *big.Int) *big.Int { | ||
return addPercentage(baseFee, 5) | ||
} | ||
|
||
// GetMinimumFeeCapForEventEmitter returns the gas price the event emitter should | ||
// check for when including transactions in a block. This function returns a | ||
// value that is 2% higher than the base fee to provide a buffer for the price | ||
// to increase before the transaction is included in a block. | ||
func GetMinimumFeeCapForEventEmitter(baseFee *big.Int) *big.Int { | ||
return addPercentage(baseFee, 2) | ||
} | ||
|
||
func addPercentage(a *big.Int, percentage int) *big.Int { | ||
if a == nil { | ||
return big.NewInt(0) | ||
} | ||
res := new(big.Int).Set(a) | ||
res.Mul(res, big.NewInt(int64(percentage+100))) | ||
res.Div(res, big.NewInt(100)) | ||
return res | ||
} |