package main import ( "context" "errors" "fmt" "log/slog" "os" "os/signal" "syscall" "github.com/gagliardetto/solana-go/rpc" "github.com/samlior/libsam/v2/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) //handlers := shreder.GetRegisteredHandlers() 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", }, }, // TODO: axiom, gmgn, etc. }, //shreder.WithCustomParsers(map[solana.PublicKey]shreder.Handler{ // solana.MustPublicKeyFromBase58("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"): handlers[solana.MustPublicKeyFromBase58("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4")], // solana.MustPublicKeyFromBase58("proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u"): handlers[solana.MustPublicKeyFromBase58("proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u")], //}), 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: if tx.Label == "dbot" || tx.Label == "okxdexroutev2" { fmt.Println("===============", tx.TxHash, tx.Label, tx.Program, tx.Event, tx.Token0Address, tx.Token1Address, "token0amount:", tx.Token0Amount, "token1amount:", tx.Token1Amount, "parse time:", tx.ParseEnd.Sub(tx.ParseStart), "cu price:", tx.CUPrice, "swqos agent:", tx.SWQoSAgent, "swqos tips:", tx.SWQoSTips) } } } }