2025-12-26 10:57:37 +08:00
|
|
|
package main
|
|
|
|
|
|
2025-12-26 11:34:45 +08:00
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
2026-01-05 12:45:32 +08:00
|
|
|
"log/slog"
|
2025-12-26 11:34:45 +08:00
|
|
|
"os"
|
|
|
|
|
"os/signal"
|
|
|
|
|
"syscall"
|
|
|
|
|
|
2026-01-05 12:45:32 +08:00
|
|
|
"github.com/gagliardetto/solana-go/rpc"
|
|
|
|
|
|
2025-12-26 11:34:45 +08:00
|
|
|
"github.com/samlior/libsam/pkg/shreder"
|
|
|
|
|
)
|
2025-12-26 10:57:37 +08:00
|
|
|
|
|
|
|
|
func main() {
|
2025-12-26 11:34:45 +08:00
|
|
|
url := os.Getenv("URL")
|
|
|
|
|
if url == "" {
|
|
|
|
|
panic("URL is not set")
|
|
|
|
|
}
|
2026-01-05 12:45:32 +08:00
|
|
|
rpcUrl := os.Getenv("RPC_URL")
|
|
|
|
|
if rpcUrl == "" {
|
|
|
|
|
panic("RPC_URL is not set")
|
|
|
|
|
}
|
|
|
|
|
rpcClient := rpc.New(rpcUrl)
|
|
|
|
|
shreder.SetLogLevel(slog.LevelDebug)
|
2025-12-26 11:34:45 +08:00
|
|
|
shrederClient, cleanup, err := shreder.NewShrederClient(
|
|
|
|
|
url,
|
2026-01-05 12:45:32 +08:00
|
|
|
rpcClient,
|
2025-12-30 11:03:11 +08:00
|
|
|
map[string]*shreder.SubscribeRequestFilterTransactions{
|
2025-12-26 11:34:45 +08:00
|
|
|
"pumpfunamm": {
|
2026-01-05 12:45:32 +08:00
|
|
|
//AccountRequired: []string{
|
|
|
|
|
// "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
|
|
|
|
|
//},
|
|
|
|
|
AccountInclude: []string{
|
2025-12-26 11:34:45 +08:00
|
|
|
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA",
|
2026-01-05 12:45:32 +08:00
|
|
|
"GS4CU59F31iL7aR2Q8zVS8DRrcRnXX1yjQ66TqNVQnaR", //Event Authority
|
|
|
|
|
"5PHirr8joyTMp9JMm6nW7hNDVyEYdkzDqazxPD7RaTjx", // Fee Config
|
2026-01-06 16:42:07 +08:00
|
|
|
"pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ", // pump fee program
|
2025-12-26 11:34:45 +08:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
"photon": {
|
|
|
|
|
AccountRequired: []string{
|
|
|
|
|
"BSfD6SHZigAfDWSjzD5Q41jw8LmKwtmjskPH9XW1mrRW",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-01-06 16:42:07 +08:00
|
|
|
"jupiterV6": {
|
|
|
|
|
AccountRequired: []string{
|
|
|
|
|
"JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-01-07 15:39:32 +08:00
|
|
|
"okxdexroutev2": {
|
|
|
|
|
AccountRequired: []string{
|
|
|
|
|
"proVF4pMXVaYqmy4NjniPh4pqKNfMmsihgd4wdkCX3u",
|
|
|
|
|
},
|
|
|
|
|
},
|
2026-01-07 18:02:45 +08:00
|
|
|
"dflow": {
|
|
|
|
|
AccountRequired: []string{
|
|
|
|
|
"DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH",
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-12-26 11:34:45 +08:00
|
|
|
// TODO: axiom, gmgn, etc.
|
2026-01-08 11:57:57 +08:00
|
|
|
}, shreder.BlocksStats(false), shreder.LogParsedStats(true), shreder.ShowTableLoaded(false))
|
2025-12-26 11:34:45 +08:00
|
|
|
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
|
2025-12-30 11:03:11 +08:00
|
|
|
txCh := make(chan shreder.TxSignalBatch, 1000)
|
2025-12-26 11:34:45 +08:00
|
|
|
go func() {
|
|
|
|
|
err := shrederClient.ReadSync(ctx, txCh)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if !errors.Is(err, context.Canceled) {
|
|
|
|
|
panic(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
select {
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
return
|
|
|
|
|
case txBatch := <-txCh:
|
2026-01-05 12:45:32 +08:00
|
|
|
//jsonData, _ := json.MarshalIndent(txBatch, "", " ")
|
2026-01-06 16:42:07 +08:00
|
|
|
for _, tx := range txBatch {
|
2026-01-08 11:57:57 +08:00
|
|
|
if tx.Label == "okxdexroutev2" || tx.Label == "jupiterv6" || tx.Label == "dflow" {
|
2026-01-07 21:15:54 +08:00
|
|
|
fmt.Println("===============", tx.TxHash, tx.Label, tx.Event, tx.Token0Address, "token:", tx.Token0Amount, "parse time:", tx.ParseEnd.Sub(tx.ParseStart))
|
2026-01-06 16:42:07 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//fmt.Println(txBatch[0].TxHash)
|
2025-12-26 11:34:45 +08:00
|
|
|
}
|
|
|
|
|
}
|
2025-12-26 10:57:37 +08:00
|
|
|
}
|