-
Notifications
You must be signed in to change notification settings - Fork 5
/
callBundle.go
50 lines (40 loc) Β· 1.39 KB
/
callBundle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package flotscmd
import (
"fmt"
"github.com/benleb/gloomberg/internal/flots"
"github.com/charmbracelet/log"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// sendBundleCmd represents the callSendBundle command.
var callBundleCmd = &cobra.Command{
Use: "callBundle",
Short: "simulates a bundle of given raw transactions",
Run: func(cmd *cobra.Command, args []string) {
// flashbots client
flots := flots.New()
//
// parse raw txs
if flagRawTransactions == nil {
log.Fatal("β no raw transactions provided!")
}
fmt.Println("transactions:")
rawTxs := make([][]byte, 0)
for idx, rawtx := range flagRawTransactions {
rawTxs = append(rawTxs, hexutil.MustDecode(rawtx))
fmt.Printf(" tx %d: %+v", idx, rawtx)
}
//
// simulate with call bundle
callBundle := flots.CallBundle(rawTxs)
fmt.Printf("π’ call bundle: %+v\n\n\n", callBundle)
},
}
func init() {
FlotsCmd.AddCommand(callBundleCmd)
callBundleCmd.Flags().StringSliceVarP(&flagRawTransactions, "rawtxs", "t", make([]string, 0), "signed transactions (get them from https://flashbots-bundler.surge.sh/rpc for example)")
_ = callBundleCmd.MarkFlagRequired("rawtxs")
callBundleCmd.Flags().Int64Var(&flagPlusBlocks, "plusBlocks", 5, "blocks to add to the current block number")
_ = viper.BindPFlag("flots.plusBlocks", callBundleCmd.Flags().Lookup("plusBlocks"))
}