Skip to content

Commit

Permalink
add gas fee/tip multiplier to manifold minter
Browse files Browse the repository at this point in the history
  • Loading branch information
benleb committed Jul 30, 2023
1 parent a9355a5 commit 241ce8b
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions cmd/mintcmd/manifold.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ var (

flagInstanceID int64

flagGasFeeCapMultiplier float64
flagGasTipCapMultiplier float64

flagPrivateKeys []string
flagRPCs []string

Expand Down Expand Up @@ -84,6 +87,12 @@ func init() {
_ = viper.BindPFlag("mint.rpcs", manifoldCmd.Flags().Lookup("rpcs"))
// _ = manifoldCmd.MarkFlagRequired("rpcs")

// gas settings
manifoldCmd.Flags().Float64Var(&flagGasFeeCapMultiplier, "fee-cap", 1.0, "gas fee cap multiplier")
_ = viper.BindPFlag("mint.fee_multiplier", manifoldCmd.Flags().Lookup("fee-cap"))
manifoldCmd.Flags().Float64Var(&flagGasTipCapMultiplier, "tip-cap", 1.0, "gas tip cap multiplier")
_ = viper.BindPFlag("mint.tip_multiplier", manifoldCmd.Flags().Lookup("tip-cap"))

// number of wallets to use
manifoldCmd.Flags().Uint16("num-wallets", 3, "number of wallets to use for minting")
_ = viper.BindPFlag("mint.manifold.num-wallets", manifoldCmd.Flags().Lookup("num-wallets"))
Expand Down Expand Up @@ -330,7 +339,7 @@ func mintManifold(_ *cobra.Command, _ []string) {
log.Print("")
log.Printf(" 💤 💤 💤 waiting for mint start in %s 💤 💤 💤", style.BoldAlmostWhite(fmt.Sprint(time.Until(startDate).Truncate(time.Second).String())))
log.Print("")
log.Printf(style.GrayStyle.Render(" (use --no-wait to skip waiting)"))
log.Printf(style.GrayStyle.Render(" (use --no-wait to skip waiting)"))
log.Print("")
log.Print("")

Expand Down Expand Up @@ -443,6 +452,18 @@ func mintERC1155(rpcEndpoints mapset.Set[string], mintWallet *MintWallet, txsPer

log.Printf("%s | ⛽️ gasTip: %+v", mintWallet.tag, style.BoldAlmostWhite(fmt.Sprint(gasTip)))

//
// apply gas multiplier
feeCapMultiplier := new(big.Float).SetFloat64(viper.GetFloat64("mint.fee_multiplier"))
tipCapMultiplier := new(big.Float).SetFloat64(viper.GetFloat64("mint.tip_multiplier"))

suggestedFee := new(big.Float).SetInt(gasPrice)
suggestedTip := new(big.Float).SetInt(gasTip)

gasFeeCap, _ := new(big.Float).Mul(suggestedFee, feeCapMultiplier).Int(nil)
gasTipCap, _ := new(big.Float).Mul(suggestedTip, tipCapMultiplier).Int(nil)

// 💸 💸 💸
mintCost := utils.EtherToWei(big.NewFloat(mintInfo.MintPrice))
totalCost := new(big.Int).Add(manifoldFee, mintCost)

Expand All @@ -462,12 +483,8 @@ func mintERC1155(rpcEndpoints mapset.Set[string], mintWallet *MintWallet, txsPer
txOpts.From = crypto.PubkeyToAddress(mintWallet.privateKey.PublicKey)
txOpts.Nonce = big.NewInt(int64(nonce))
txOpts.Value = totalCost
// use 1.5x the amount of the current suggested gas price
// txOpts.GasPrice = new(big.Int).Div(new(big.Int).Mul(gasPrice, big.NewInt(3)), big.NewInt(2))
// use 2x the amount of the current suggested gas tip
// txOpts.GasTipCap = new(big.Int).Mul(gasTip, big.NewInt(2))
// txOpts.GasTipCap = new(big.Int).Mul(gasTip, big.NewInt(1))
txOpts.GasFeeCap = new(big.Int).Mul(gasPrice, big.NewInt(1))
txOpts.GasFeeCap = gasFeeCap
txOpts.GasTipCap = gasTipCap

log.Printf("%s | txOpts: %#v", mintWallet.tag, txOpts)

Expand Down

0 comments on commit 241ce8b

Please sign in to comment.