github.com/InjectiveLabs/sdk-go@v1.53.0/examples/exchange/spot/11_SubaccountOrdersList/example.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  	"fmt"
     7  
     8  	"github.com/InjectiveLabs/sdk-go/client/common"
     9  	exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange"
    10  	spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb"
    11  )
    12  
    13  func main() {
    14  	// network := common.LoadNetwork("mainnet", "k8s")
    15  	network := common.LoadNetwork("testnet", "lb")
    16  	exchangeClient, err := exchangeclient.NewExchangeClient(network)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	ctx := context.Background()
    22  	marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"
    23  	subaccountId := "0x0b46e339708ea4d87bd2fcc61614e109ac374bbe000000000000000000000000"
    24  	skip := uint64(0)
    25  	limit := int32(10)
    26  
    27  	req := spotExchangePB.SubaccountOrdersListRequest{
    28  		MarketId:     marketId,
    29  		SubaccountId: subaccountId,
    30  		Skip:         skip,
    31  		Limit:        limit,
    32  	}
    33  
    34  	res, err := exchangeClient.GetSubaccountSpotOrdersList(ctx, &req)
    35  	if err != nil {
    36  		fmt.Println(err)
    37  	}
    38  
    39  	str, _ := json.MarshalIndent(res, "", " ")
    40  	fmt.Print(string(str))
    41  }