Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing fastBestEffort flag #192

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/grpcclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ func callPlaceOrderBundle(g *provider.GRPCClient, ownerAddr, payerAddr, _ string
log.Infof("created unsigned place order transaction: %v", response.Transaction)

resp, err := g.SignAndSubmit(ctx, &pb.TransactionMessage{
Content: response.Transaction.Content}, true, true, false, false)
Content: response.Transaction.Content}, true, true, false)
if err != nil {
log.Errorf("failed to sign and submit order (%v)", err)
return true
Expand Down Expand Up @@ -902,7 +902,7 @@ func callPlaceOrderWithStakedRPCs(g *provider.GRPCClient, ownerAddr, payerAddr,
log.Infof("created unsigned place order transaction: %v", response.Transaction)

resp, err := g.SignAndSubmit(ctx, &pb.TransactionMessage{
Content: response.Transaction.Content}, true, false, true, false)
Content: response.Transaction.Content}, true, false, true)
if err != nil {
log.Errorf("failed to sign and submit order (%v)", err)
return true
Expand Down
4 changes: 2 additions & 2 deletions examples/httpclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ func callPlaceOrderBundle(ownerAddr string, bundleTip uint64) bool {

tx, err := h.SignAndSubmit(ctx, &pb.TransactionMessage{Content: resp.Transactions[0].Content, IsCleanup: false},
true,
true, false, false)
true, false)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -778,7 +778,7 @@ func callPlaceOrderWithStakedRPCs(ownerAddr string, bundleTip uint64) bool {

tx, err := h.SignAndSubmit(ctx, &pb.TransactionMessage{Content: resp.Transactions[0].Content, IsCleanup: false},
true,
false, true, false)
false, true)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions examples/wsclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ func callPlaceOrderBundle(w *provider.WSClient, ownerAddr string, tipAmount uint

signature, err := w.SignAndSubmit(ctx, &pb.TransactionMessage{Content: resp.Transactions[0].Content},
true,
true, false, false)
true, false)
if err != nil {
log.Errorf("failed to sign and submit tx: %s", err)
return true
Expand Down Expand Up @@ -871,7 +871,7 @@ func callPlaceOrderWithStakedRPCs(w *provider.WSClient, ownerAddr string, tipAmo

signature, err := w.SignAndSubmit(ctx, &pb.TransactionMessage{Content: resp.Transactions[0].Content},
true,
false, true, false)
false, true)
if err != nil {
log.Errorf("failed to sign and submit tx: %s", err)
return true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.22.1

require (
github.com/bloXroute-Labs/solana-trader-proto v1.9.2-0.20240701182849-47644387b812
github.com/bloXroute-Labs/solana-trader-proto v1.9.2-0.20240729211326-e729568a1c8d
github.com/gagliardetto/binary v0.7.7
github.com/gagliardetto/solana-go v1.8.4
github.com/gorilla/websocket v1.4.2
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHf
github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc=
github.com/bloXroute-Labs/solana-trader-proto v1.9.2-0.20240701182849-47644387b812 h1:iD3E4lH2a74U0Y3X87fDu9FvQKMajLep1a0y1Qu1oa8=
github.com/bloXroute-Labs/solana-trader-proto v1.9.2-0.20240701182849-47644387b812/go.mod h1:OPAXgJCllC8aCvjRO1uOvpd1eHP0x5Rfr61oQAZEX8Y=
github.com/bloXroute-Labs/solana-trader-proto v1.9.2-0.20240729211326-e729568a1c8d h1:YqYunxpt2cQY/W5i8mmDTYdTISJetSrpLG76Pss0z1w=
github.com/bloXroute-Labs/solana-trader-proto v1.9.2-0.20240729211326-e729568a1c8d/go.mod h1:OPAXgJCllC8aCvjRO1uOvpd1eHP0x5Rfr61oQAZEX8Y=
github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs=
github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down
28 changes: 13 additions & 15 deletions provider/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func (g *GRPCClient) GetQuotes(ctx context.Context, inToken, outToken string, in

// SignAndSubmit signs the given transaction and submits it.
func (g *GRPCClient) SignAndSubmit(ctx context.Context, tx *pb.TransactionMessage,
skipPreFlight bool, frontRunningProtection bool, useStakedRPCs bool, fastBestEffort bool) (string, error) {
skipPreFlight bool, frontRunningProtection bool, useStakedRPCs bool) (string, error) {
if g.privateKey == nil {
return "", ErrPrivateKeyNotFound
}
Expand All @@ -270,8 +270,7 @@ func (g *GRPCClient) SignAndSubmit(ctx context.Context, tx *pb.TransactionMessag
response, err := g.PostSubmit(ctx, &pb.TransactionMessage{
Content: txBase64,
IsCleanup: tx.IsCleanup,
}, skipPreFlight, frontRunningProtection,
useStakedRPCs, fastBestEffort)
}, skipPreFlight, frontRunningProtection, useStakedRPCs)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -327,12 +326,11 @@ func (g *GRPCClient) PostOrder(ctx context.Context, owner, payer, market string,

// PostSubmit posts the transaction string to the Solana network.
func (g *GRPCClient) PostSubmit(ctx context.Context, tx *pb.TransactionMessage, skipPreFlight bool,
frontRunningProtection bool, useStakedRPCs bool, fastBestEffort bool) (*pb.PostSubmitResponse, error) {
frontRunningProtection bool, useStakedRPCs bool) (*pb.PostSubmitResponse, error) {
return g.apiClient.PostSubmit(ctx, &pb.PostSubmitRequest{Transaction: tx,
SkipPreFlight: skipPreFlight,
FrontRunningProtection: &frontRunningProtection,
UseStakedRPCs: &useStakedRPCs,
FastBestEffort: &fastBestEffort,
})
}

Expand Down Expand Up @@ -544,7 +542,7 @@ func (g *GRPCClient) SubmitOrder(ctx context.Context, owner, payer, market strin
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// PostCancelOrder builds a Serum cancel order.
Expand Down Expand Up @@ -583,7 +581,7 @@ func (g *GRPCClient) SubmitCancelOrder(
return "", err
}

return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// PostCancelByClientOrderID builds a Serum cancel order by client ID.
Expand Down Expand Up @@ -620,7 +618,7 @@ func (g *GRPCClient) SubmitCancelByClientOrderID(
return "", err
}

return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

func (g *GRPCClient) PostCancelAll(ctx context.Context, market, owner string, openOrders []string, project pb.Project) (*pb.PostCancelAllResponse, error) {
Expand Down Expand Up @@ -659,7 +657,7 @@ func (g *GRPCClient) SubmitSettle(ctx context.Context, owner, market, baseTokenW
return "", err
}

return g.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false)
}

func (g *GRPCClient) PostReplaceByClientOrderID(ctx context.Context, owner, payer, market string, side pb.Side, types []common.OrderType, amount, price float64, project pb.Project, opts PostOrderOpts) (*pb.PostOrderResponse, error) {
Expand All @@ -686,7 +684,7 @@ func (g *GRPCClient) SubmitReplaceByClientOrderID(ctx context.Context, owner, pa
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

func (g *GRPCClient) PostReplaceOrder(ctx context.Context, orderID, owner, payer, market string, side pb.Side, types []common.OrderType, amount, price float64, project pb.Project, opts PostOrderOpts) (*pb.PostOrderResponse, error) {
Expand Down Expand Up @@ -714,7 +712,7 @@ func (g *GRPCClient) SubmitReplaceOrder(ctx context.Context, orderID, owner, pay
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// GetOrderbookStream subscribes to a stream for changes to the requested market updates (e.g. asks and bids. Set limit to 0 for all bids/ asks).
Expand Down Expand Up @@ -963,7 +961,7 @@ func (g *GRPCClient) SubmitOrderV2(ctx context.Context, owner, payer, market str
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// SubmitOrderV2WithPriorityFee builds a Serum market order, signs it, and submits to the network with specified computeLimit and computePrice
Expand All @@ -978,7 +976,7 @@ func (g *GRPCClient) SubmitOrderV2WithPriorityFee(ctx context.Context, owner, pa
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// PostCancelOrderV2 builds a Serum cancel order.
Expand Down Expand Up @@ -1038,7 +1036,7 @@ func (g *GRPCClient) SubmitSettleV2(ctx context.Context, owner, market, baseToke
return "", err
}

return g.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false)
}

func (g *GRPCClient) PostReplaceOrderV2(ctx context.Context, orderID, owner, payer, market string, side string, orderType string, amount, price float64, opts PostOrderOpts) (*pb.PostOrderResponse, error) {
Expand All @@ -1065,5 +1063,5 @@ func (g *GRPCClient) SubmitReplaceOrderV2(ctx context.Context, orderID, owner, p
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return g.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}
30 changes: 14 additions & 16 deletions provider/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,12 @@ func (h *HTTPClient) GetQuotes(ctx context.Context, inToken, outToken string, in

// PostSubmit posts the transaction string to the Solana network.
func (h *HTTPClient) PostSubmit(ctx context.Context, txBase64 string, skipPreFlight bool,
frontRunningProtection bool, useStakedRPCs bool, fastBestEffort bool) (*pb.PostSubmitResponse, error) {
frontRunningProtection bool, useStakedRPCs bool) (*pb.PostSubmitResponse, error) {
url := fmt.Sprintf("%s/api/v1/trade/submit", h.baseURL)
request := &pb.PostSubmitRequest{Transaction: &pb.TransactionMessage{Content: txBase64},
SkipPreFlight: skipPreFlight,
FrontRunningProtection: &frontRunningProtection,
UseStakedRPCs: &useStakedRPCs,
FastBestEffort: &fastBestEffort,
}

var response pb.PostSubmitResponse
Expand All @@ -409,13 +408,12 @@ func (h *HTTPClient) PostSubmitBatch(ctx context.Context, request *pb.PostSubmit

// PostSubmitV2 posts the transaction string to the Solana network.
func (h *HTTPClient) PostSubmitV2(ctx context.Context, txBase64 string, skipPreFlight bool,
frontRunningProtection bool, useStakedRPCs bool, fastBestEffort bool) (*pb.PostSubmitResponse, error) {
frontRunningProtection bool, useStakedRPCs bool) (*pb.PostSubmitResponse, error) {
url := fmt.Sprintf("%s/api/v2/submit", h.baseURL)
request := &pb.PostSubmitRequest{Transaction: &pb.TransactionMessage{Content: txBase64},
SkipPreFlight: skipPreFlight,
FrontRunningProtection: &frontRunningProtection,
UseStakedRPCs: &useStakedRPCs,
FastBestEffort: &fastBestEffort,
}

var response pb.PostSubmitResponse
Expand All @@ -440,7 +438,7 @@ func (h *HTTPClient) PostSubmitBatchV2(ctx context.Context, request *pb.PostSubm

// SignAndSubmit signs the given transaction and submits it.
func (h *HTTPClient) SignAndSubmit(ctx context.Context, tx *pb.TransactionMessage,
skipPreFlight bool, frontRunningProtection bool, useStakedRPCs bool, fastBestEffort bool) (string, error) {
skipPreFlight bool, frontRunningProtection bool, useStakedRPCs bool) (string, error) {
if h.privateKey == nil {
return "", ErrPrivateKeyNotFound
}
Expand All @@ -449,7 +447,7 @@ func (h *HTTPClient) SignAndSubmit(ctx context.Context, tx *pb.TransactionMessag
return "", err
}

response, err := h.PostSubmit(ctx, txBase64, skipPreFlight, frontRunningProtection, useStakedRPCs, fastBestEffort)
response, err := h.PostSubmit(ctx, txBase64, skipPreFlight, frontRunningProtection, useStakedRPCs)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -709,7 +707,7 @@ func (h *HTTPClient) SubmitOrder(ctx context.Context, owner, payer, market strin
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
sig, err := h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
sig, err := h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -761,7 +759,7 @@ func (h *HTTPClient) SubmitCancelOrder(
return "", err
}

return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// PostCancelByClientOrderID builds a Serum cancel order by client ID.
Expand Down Expand Up @@ -806,7 +804,7 @@ func (h *HTTPClient) SubmitCancelByClientOrderID(
return "", err
}

return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

func (h *HTTPClient) PostCancelAll(ctx context.Context, market, owner string, openOrdersAddresses []string, project pb.Project) (*pb.PostCancelAllResponse, error) {
Expand Down Expand Up @@ -862,7 +860,7 @@ func (h *HTTPClient) SubmitSettle(ctx context.Context, owner, market, baseTokenW
return "", err
}

return h.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false)
}

func (h *HTTPClient) PostReplaceByClientOrderID(ctx context.Context, owner, payer, market string, side pb.Side, types []common.OrderType, amount, price float64, project pb.Project, opts PostOrderOpts) (*pb.PostOrderResponse, error) {
Expand Down Expand Up @@ -897,7 +895,7 @@ func (h *HTTPClient) SubmitReplaceByClientOrderID(ctx context.Context, owner, pa
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

func (h *HTTPClient) PostReplaceOrder(ctx context.Context, orderID, owner, payer, market string, side pb.Side, types []common.OrderType, amount, price float64, project pb.Project, opts PostOrderOpts) (*pb.PostOrderResponse, error) {
Expand Down Expand Up @@ -933,7 +931,7 @@ func (h *HTTPClient) SubmitReplaceOrder(ctx context.Context, orderID, owner, pay
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

// GetRecentBlockHash subscribes to a stream for getting recent block hash.
Expand Down Expand Up @@ -1092,7 +1090,7 @@ func (h *HTTPClient) SubmitOrderV2(ctx context.Context, owner, payer, market str
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
sig, err := h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
sig, err := h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
return sig, err
}

Expand All @@ -1108,7 +1106,7 @@ func (h *HTTPClient) SubmitOrderV2WithPriorityFee(ctx context.Context, owner, pa
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
sig, err := h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
sig, err := h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
return sig, err
}

Expand Down Expand Up @@ -1186,7 +1184,7 @@ func (h *HTTPClient) SubmitSettleV2(ctx context.Context, owner, market, baseToke
return "", err
}

return h.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreflight, false, false)
}

func (h *HTTPClient) PostReplaceOrderV2(ctx context.Context, orderID, owner, payer, market string, side string, orderType string, amount, price float64, opts PostOrderOpts) (*pb.PostOrderResponse, error) {
Expand Down Expand Up @@ -1221,7 +1219,7 @@ func (h *HTTPClient) SubmitReplaceOrderV2(ctx context.Context, orderID, owner, p
if opts.SkipPreFlight != nil {
skipPreFlight = *opts.SkipPreFlight
}
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false, false)
return h.SignAndSubmit(ctx, order.Transaction, skipPreFlight, false, false)
}

type stringable interface {
Expand Down
Loading