This repository was archived by the owner on Oct 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default to sender balance override in gas estimation if no paymaster (#…
…350)
- Loading branch information
Showing
13 changed files
with
259 additions
and
76 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,39 @@ | ||
package fees | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/ethereum/go-ethereum/ethclient" | ||
) | ||
|
||
// GasPrices contains recommended gas fees for a UserOperation to be included in a timely manner. | ||
type GasPrices struct { | ||
MaxFeePerGas *big.Int | ||
MaxPriorityFeePerGas *big.Int | ||
} | ||
|
||
// NewGasPrices returns an instance of GasPrices with the latest suggested fees derived from an Eth Client. | ||
func NewGasPrices(eth *ethclient.Client) (*GasPrices, error) { | ||
gp := GasPrices{} | ||
if head, err := eth.HeaderByNumber(context.Background(), nil); err != nil { | ||
return nil, err | ||
} else if head.BaseFee != nil { | ||
tip, err := eth.SuggestGasTipCap(context.Background()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
gp.MaxFeePerGas = big.NewInt(0).Add(tip, big.NewInt(0).Mul(head.BaseFee, common.Big2)) | ||
gp.MaxPriorityFeePerGas = tip | ||
} else { | ||
sgp, err := eth.SuggestGasPrice(context.Background()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
gp.MaxFeePerGas = sgp | ||
gp.MaxPriorityFeePerGas = sgp | ||
} | ||
|
||
return &gp, nil | ||
} |
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
Oops, something went wrong.