-
Notifications
You must be signed in to change notification settings - Fork 380
Closed
Description
Remove deprecated SuggestGasPrice from codebase or replace it with logic used like in suggestedFeeAndTip method
func (t *transactionService) suggestedFeeAndTip(ctx context.Context, gasPrice *big.Int, boostPercent int) (*big.Int, *big.Int, error) {
gasTipCap, err := t.backend.SuggestGasTipCap(ctx)
if err != nil {
return nil, nil, err
}
multiplier := big.NewInt(int64(boostPercent) + 100)
gasTipCap = new(big.Int).Div(new(big.Int).Mul(gasTipCap, multiplier), big.NewInt(100))
minimumTip := big.NewInt(MinimumGasTipCap)
if gasTipCap.Cmp(minimumTip) < 0 {
gasTipCap = new(big.Int).Set(minimumTip)
}
var gasFeeCap *big.Int
if gasPrice == nil {
latestBlockHeader, err := t.backend.HeaderByNumber(ctx, nil)
if err != nil {
return nil, nil, fmt.Errorf("failed to get latest block: %w", err)
}
if latestBlockHeader.BaseFee == nil {
return nil, nil, ErrEIP1559NotSupported
}
// gasFeeCap = (2 * baseFee) + gasTipCap
gasFeeCap = new(big.Int).Add(
new(big.Int).Mul(latestBlockHeader.BaseFee, big.NewInt(2)),
gasTipCap,
)
} else {
gasFeeCap = new(big.Int).Set(gasPrice)
}
if gasTipCap.Cmp(gasFeeCap) > 0 {
t.logger.Warning("gas tip cap is higher than gas fee cap, using gas fee cap as gas tip cap", "gas_tip_cap", gasTipCap, "gas_fee_cap", gasFeeCap)
gasTipCap = new(big.Int).Set(gasFeeCap)
}
t.logger.Debug("prepare transaction", "gas_max_fee", gasFeeCap, "gas_max_tip", gasTipCap)
return gasFeeCap, gasTipCap, nil
}0xCardiE
Metadata
Metadata
Assignees
Labels
No labels