package main import ( "context" "errors" "fmt" "log/slog" "os" "os/signal" "syscall" "time" "github.com/gagliardetto/solana-go/rpc" "github.com/shopspring/decimal" "github.com/samlior/libsam/pkg/shreder" ) func main() { url := os.Getenv("URL") if url == "" { panic("URL is not set") } rpcUrl := os.Getenv("RPC_URL") if rpcUrl == "" { panic("RPC_URL is not set") } rpcClient := rpc.New(rpcUrl) shreder.SetLogLevel(slog.LevelDebug) shrederClient, cleanup, err := shreder.NewShrederClient( url, rpcClient, map[string]*shreder.SubscribeRequestFilterTransactions{ "pumpfunamm": { //AccountRequired: []string{ // "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", //}, AccountInclude: []string{ "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", "GS4CU59F31iL7aR2Q8zVS8DRrcRnXX1yjQ66TqNVQnaR", //Event Authority "5PHirr8joyTMp9JMm6nW7hNDVyEYdkzDqazxPD7RaTjx", // Fee Config "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ", // pump fee program }, }, "photon": { AccountRequired: []string{ "BSfD6SHZigAfDWSjzD5Q41jw8LmKwtmjskPH9XW1mrRW", }, }, "jupiterV6": { AccountRequired: []string{ "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4", }, }, "okxdexroutev2": { AccountRequired: []string{ "proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u", }, }, "dflow": { AccountRequired: []string{ "DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH", }, }, // TODO: axiom, gmgn, etc. }, shreder.BlocksStats(false), shreder.LogParsedStats(true), shreder.ShowTableLoaded(false)) if err != nil { panic(err) } defer cleanup() exitSignal := make(chan os.Signal, 1) ctx, cancel := context.WithCancel(context.Background()) signal.Notify(exitSignal, syscall.SIGINT, syscall.SIGTERM) go func() { <-exitSignal cancel() }() // async read from shreder txCh := make(chan shreder.TxSignal, 1000) go func() { err := shrederClient.ReadEntriesSync(ctx, txCh) if err != nil { if !errors.Is(err, context.Canceled) { panic(err) } } }() for { select { case <-ctx.Done(): return case tx := <-txCh: //jsonData, _ := json.MarshalIndent(txBatch, "", " ") if tx.Token0Amount.GreaterThan(decimal.NewFromInt(100)) && (tx.Label == "okxdexroutev2" || tx.Label == "jupiterv6" || tx.Label == "dflow") { fmt.Println(time.Now(), "===============", tx.TxHash, "parse time:", tx.Stats.Done.Sub(tx.Stats.Filter), "decode time:", tx.Stats.Decoded.Sub(tx.Stats.FEC), "filter time:", tx.Stats.Filter.Sub(tx.Stats.Decoded), "dataLen", tx.Stats.DataLen, "txCount", tx.Stats.TxCount, "txOffset", tx.Stats.TxOffset, tx.Label, tx.Event, "token:", tx.Token0Amount) } //if tx.Token0Amount.GreaterThan(decimal.NewFromInt(100)) && (tx.Label == "okxdexroutev2" || tx.Label == "jupiterv6" || tx.Label == "dflow") { // fmt.Println(time.Now(), "===============", tx.TxHash, // tx.Label, tx.Event, "token:", tx.Token0Amount) //} //fmt.Println(txBatch[0].TxHash) } } }