fix slippage
This commit is contained in:
@@ -45,9 +45,11 @@ type Client struct {
|
||||
firstMessage bool
|
||||
|
||||
handler Handler
|
||||
|
||||
xToken string
|
||||
}
|
||||
|
||||
func NewClientWithPumpSwap(endpoint string, ch chan SubscriptionMessage) *Client {
|
||||
func NewClientWithPumpSwap(endpoint string, xtoken string, ch chan SubscriptionMessage) *Client {
|
||||
var subscription pb.SubscribeRequest
|
||||
|
||||
//var failed = true
|
||||
@@ -58,10 +60,10 @@ func NewClientWithPumpSwap(endpoint string, ch chan SubscriptionMessage) *Client
|
||||
Vote: &vote,
|
||||
}
|
||||
|
||||
subscription.Transactions["transactions_sub"].AccountInclude = []string{
|
||||
"pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", //Pump AMM
|
||||
"6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", //Pump
|
||||
}
|
||||
//subscription.Transactions["transactions_sub"].AccountInclude = []string{
|
||||
// "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA", //Pump AMM
|
||||
// "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", //Pump
|
||||
//}
|
||||
subscription.BlocksMeta = make(map[string]*pb.SubscribeRequestFilterBlocksMeta)
|
||||
subscription.BlocksMeta["block_meta"] = &pb.SubscribeRequestFilterBlocksMeta{}
|
||||
|
||||
@@ -72,6 +74,7 @@ func NewClientWithPumpSwap(endpoint string, ch chan SubscriptionMessage) *Client
|
||||
lastReceiveTime: time.Now(),
|
||||
subStatus: false,
|
||||
subscription: &subscription,
|
||||
xToken: xtoken,
|
||||
}
|
||||
c.handler = NewPumpHandler(func(tx *types.Tx) {
|
||||
c.sendTx(tx)
|
||||
@@ -112,12 +115,12 @@ func NewClientWithLaunchLab(endpoint string, ch chan SubscriptionMessage) *Clien
|
||||
return c
|
||||
}
|
||||
|
||||
func RunLoopWithReConnect(ctx context.Context, endpoint, program string, ch chan SubscriptionMessage) {
|
||||
func RunLoopWithReConnect(ctx context.Context, endpoint, token, program string, ch chan SubscriptionMessage) {
|
||||
var client *Client
|
||||
if program == types.SolProgramRaydiumLaunchLab {
|
||||
client = NewClientWithLaunchLab(endpoint, ch)
|
||||
} else {
|
||||
client = NewClientWithPumpSwap(endpoint, ch)
|
||||
client = NewClientWithPumpSwap(endpoint, token, ch)
|
||||
}
|
||||
for {
|
||||
select {
|
||||
@@ -206,12 +209,13 @@ func (c *Client) grpcSubscribe(ctx context.Context, conn *grpc.ClientConn) error
|
||||
log.Printf("Subscription request: %s", string(subscriptionJson))
|
||||
|
||||
// Set up the subscription request
|
||||
//if *token != "" {
|
||||
// md := metadata.New(map[string]string{"x-token": *token})
|
||||
// ctx = metadata.NewOutgoingContext(ctx, md)
|
||||
//}
|
||||
md := metadata.New(map[string]string{"x-token": "5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d"})
|
||||
ctx = metadata.NewOutgoingContext(ctx, md)
|
||||
if c.xToken != "" {
|
||||
fmt.Println("xtoken", c.xToken)
|
||||
md := metadata.New(map[string]string{"x-token": c.xToken})
|
||||
ctx = metadata.NewOutgoingContext(ctx, md)
|
||||
}
|
||||
//md := metadata.New(map[string]string{"x-token": "5adcf1f9-5719-43d1-bf3f-c2d4e1e5f94d"})
|
||||
//ctx = metadata.NewOutgoingContext(ctx, md)
|
||||
|
||||
stream, err := client.Subscribe(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user