package main import ( "context" "fmt" "time" "github.com/gagliardetto/solana-go" "github.com/shopspring/decimal" parser "github.com/thloyi/pump-parser" example "github.com/thloyi/pump-parser/internal/example" ) var ( pumpProgram = solana.MustPublicKeyFromBase58("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P") pumpAmmProgram = solana.MustPublicKeyFromBase58("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA") ) func main() { //pool, err := ants.NewPool(100, ants.WithPreAlloc(true), ants.WithNonblocking(true)) //if err != nil { // panic(err) //} //xt := tracker.NewTwitterTracker(nil) // Initialize Twitter tracker if needed // laserstream-mainnet-slc.helius-rpc.com:80 ch := make(chan example.SubscriptionMessage, 1) go example.RunLoopWithReConnect(context.Background(), "127.0.0.1:10001", parser.SolProgramPump, ch) // var tokenTxs = make(map[string]*types.Tx) // currentBlock := uint64(0) for msg := range ch { if msg.Tx == nil { block := msg.Block if block.Slot%100 == 0 { fmt.Printf("slot: %d, hash: %s, time: %s, height: %d, estimate delay second: %d\n", block.Slot, block.BlockHash, time.Unix(block.BlockTime, 0).Format("2006-01-02 15:04:05"), block.Height, msg.EstimateDelaySecond) } continue } ptx := msg.Tx // fmt.Println("consume", ptx.ComputeUnitsConsumed, "limit", ptx.CuLimit, "hash", ptx.GetTxHash()) //data, _ := json.Marshal(tx) //fmt.Println(string(data)) //continue //if tx.Token0Address != "HRHLDjqFBhNeyTXUuZQE9gTy5z2112qeQBS9U79NHyyp" { // continue //} //if currentBlock == ptx.Block { // continue //} // 处理交易 if len(ptx.Swaps) > 0 && (ptx.Swaps[0].Program == parser.SolProgramPump || ptx.Swaps[0].Program == parser.SolProgramPumpAMM) { fmt.Printf("success tx : %s, program: %s, event: %s, block: %d, tx: %s, base: %s, quote: %s \n", time.Now().Format("2006-01-02 15:04:05"), ptx.Swaps[0].Program, ptx.Swaps[0].Event, ptx.Block, ptx.GetTxHash(), ptx.Swaps[0].BaseAmount.Div(decimal.NewFromInt(1e6)), ptx.Swaps[0].QuoteAmount.Div(decimal.NewFromInt(1e9))) } // currentBlock = ptx.Block // //if tx.Event == "create" { // if err := pool.Submit(func() { // now := time.Now() // xt.AddToken(tx.Token) // log.Printf("Add token %s, cost: %s %s %v %v", tx.Token.Address, time.Since(now), tx.Token.Twitter, xt.DuplicateCount(tx.Token.Address), xt.HasTwitter(tx.Token.Address)) // }); err != nil { // fmt.Println(err) // } //} } }