diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 00000000..930db111 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,8 @@ +reviews: + auto_review: + base_branches: + - "master" + - "dev" + - "feat/.*" +chat: + auto_reply: true diff --git a/auth_vote/authz_vote.go b/auth_vote/authz_vote.go new file mode 100644 index 00000000..508a7c70 --- /dev/null +++ b/auth_vote/authz_vote.go @@ -0,0 +1,104 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authztypes "github.com/cosmos/cosmos-sdk/x/authz" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "gov_account", + "", + "", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + txFactory := chainclient.NewTxFactory(clientCtx) + txFactory = txFactory.WithGasPrices(client.DefaultGasPriceWithDenom) + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionTxFactory(&txFactory), + ) + + if err != nil { + panic(err) + } + + // note that we use grantee keyring to send the msg on behalf of granter here + // sender, subaccount are from granter + validators := []string{"inj156t3yxd4udv0h9gwagfcmwnmm3quy0npqc7pks", "inj16nd8yqxe9p6ggnrz58qr7dxn5y2834yendward"} + grantee := senderAddress.String() + proposalId := uint64(375) + var msgs []sdk.Msg + + for _, validator := range validators { + msgVote := v1beta1.MsgVote{ + ProposalId: proposalId, + Voter: validator, + Option: v1beta1.OptionYes, + } + + msg0Bytes, _ := msgVote.Marshal() + msg0Any := &codectypes.Any{} + msg0Any.TypeUrl = sdk.MsgTypeURL(&msgVote) + msg0Any.Value = msg0Bytes + + msg := &authztypes.MsgExec{ + Grantee: grantee, + Msgs: []*codectypes.Any{msg0Any}, + } + + sdkMsg := sdk.Msg(msg) + msgs = append(msgs, sdkMsg) + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msgs...) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/client/chain/chain.go b/client/chain/chain.go index e5340eba..058c57df 100644 --- a/client/chain/chain.go +++ b/client/chain/chain.go @@ -7,13 +7,14 @@ import ( "encoding/json" "fmt" "math" - "os" "strconv" "strings" "sync" "sync/atomic" "time" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/types/query" "google.golang.org/grpc/credentials/insecure" @@ -24,7 +25,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cosmtypes "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" txtypes "github.com/cosmos/cosmos-sdk/types/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -59,7 +59,6 @@ const ( defaultBroadcastTimeout = 40 * time.Second defaultTimeoutHeight = 20 defaultTimeoutHeightSyncInterval = 10 * time.Second - defaultChainCookieName = ".chain_cookie" ) var ( @@ -114,8 +113,8 @@ type ChainClient interface { expireIn time.Time, ) *authztypes.MsgGrant - DefaultSubaccount(acc cosmtypes.AccAddress) eth.Hash - Subaccount(account cosmtypes.AccAddress, index int) eth.Hash + DefaultSubaccount(acc sdk.AccAddress) eth.Hash + Subaccount(account sdk.AccAddress, index int) eth.Hash GetSubAccountNonce(ctx context.Context, subaccountId eth.Hash) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) GetFeeDiscountInfo(ctx context.Context, account string) (*exchangetypes.QueryFeeDiscountAccountInfoResponse, error) @@ -167,6 +166,74 @@ type ChainClient interface { FetchDenomsFromCreator(ctx context.Context, creator string) (*tokenfactorytypes.QueryDenomsFromCreatorResponse, error) FetchTokenfactoryModuleState(ctx context.Context) (*tokenfactorytypes.QueryModuleStateResponse, error) + // distribution module + FetchValidatorDistributionInfo(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorDistributionInfoResponse, error) + FetchValidatorOutstandingRewards(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorOutstandingRewardsResponse, error) + FetchValidatorCommission(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorCommissionResponse, error) + FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight uint64, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) + FetchDelegationRewards(ctx context.Context, delegatorAddress string, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) + FetchDelegationTotalRewards(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegationTotalRewardsResponse, error) + FetchDelegatorValidators(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegatorValidatorsResponse, error) + FetchDelegatorWithdrawAddress(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegatorWithdrawAddressResponse, error) + FetchCommunityPool(ctx context.Context) (*distributiontypes.QueryCommunityPoolResponse, error) + + // chain exchange module + FetchSubaccountDeposits(ctx context.Context, subaccountID string) (*exchangetypes.QuerySubaccountDepositsResponse, error) + FetchSubaccountDeposit(ctx context.Context, subaccountId string, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) + FetchExchangeBalances(ctx context.Context) (*exchangetypes.QueryExchangeBalancesResponse, error) + FetchAggregateVolume(ctx context.Context, account string) (*exchangetypes.QueryAggregateVolumeResponse, error) + FetchAggregateVolumes(ctx context.Context, accounts []string, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) + FetchAggregateMarketVolume(ctx context.Context, marketId string) (*exchangetypes.QueryAggregateMarketVolumeResponse, error) + FetchAggregateMarketVolumes(ctx context.Context, marketIds []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) + FetchDenomDecimal(ctx context.Context, denom string) (*exchangetypes.QueryDenomDecimalResponse, error) + FetchDenomDecimals(ctx context.Context, denoms []string) (*exchangetypes.QueryDenomDecimalsResponse, error) + FetchChainSpotMarkets(ctx context.Context, status string, marketIds []string) (*exchangetypes.QuerySpotMarketsResponse, error) + FetchChainSpotMarket(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMarketResponse, error) + FetchChainFullSpotMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) + FetchChainFullSpotMarket(ctx context.Context, marketId string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketResponse, error) + FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional sdk.Dec, limitCumulativeQuantity sdk.Dec) (*exchangetypes.QuerySpotOrderbookResponse, error) + FetchChainTraderSpotOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) + FetchChainAccountAddressSpotOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) + FetchChainSpotOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) + FetchChainSubaccountOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) + FetchChainTraderSpotTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) + FetchSpotMidPriceAndTOB(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMidPriceAndTOBResponse, error) + FetchDerivativeMidPriceAndTOB(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMidPriceAndTOBResponse, error) + FetchChainDerivativeOrderbook(ctx context.Context, marketId string, limit uint64, limitCumulativeNotional sdk.Dec) (*exchangetypes.QueryDerivativeOrderbookResponse, error) + FetchChainTraderDerivativeOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) + FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) + FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) + FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) + FetchChainDerivativeMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) + FetchChainDerivativeMarket(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketResponse, error) + FetchDerivativeMarketAddress(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketAddressResponse, error) + FetchSubaccountTradeNonce(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) + FetchChainPositions(ctx context.Context) (*exchangetypes.QueryPositionsResponse, error) + FetchChainSubaccountPositions(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountPositionsResponse, error) + FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) + FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) + FetchChainPerpetualMarketInfo(ctx context.Context, marketId string) (*exchangetypes.QueryPerpetualMarketInfoResponse, error) + FetchChainExpiryFuturesMarketInfo(ctx context.Context, marketId string) (*exchangetypes.QueryExpiryFuturesMarketInfoResponse, error) + FetchChainPerpetualMarketFunding(ctx context.Context, marketId string) (*exchangetypes.QueryPerpetualMarketFundingResponse, error) + FetchSubaccountOrderMetadata(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountOrderMetadataResponse, error) + FetchTradeRewardPoints(ctx context.Context, accounts []string) (*exchangetypes.QueryTradeRewardPointsResponse, error) + FetchPendingTradeRewardPoints(ctx context.Context, accounts []string) (*exchangetypes.QueryTradeRewardPointsResponse, error) + FetchFeeDiscountAccountInfo(ctx context.Context, account string) (*exchangetypes.QueryFeeDiscountAccountInfoResponse, error) + FetchTradeRewardCampaign(ctx context.Context) (*exchangetypes.QueryTradeRewardCampaignResponse, error) + FetchFeeDiscountSchedule(ctx context.Context) (*exchangetypes.QueryFeeDiscountScheduleResponse, error) + FetchBalanceMismatches(ctx context.Context, dustFactor int64) (*exchangetypes.QueryBalanceMismatchesResponse, error) + FetchBalanceWithBalanceHolds(ctx context.Context) (*exchangetypes.QueryBalanceWithBalanceHoldsResponse, error) + FetchFeeDiscountTierStatistics(ctx context.Context) (*exchangetypes.QueryFeeDiscountTierStatisticsResponse, error) + FetchMitoVaultInfos(ctx context.Context) (*exchangetypes.MitoVaultInfosResponse, error) + FetchMarketIDFromVault(ctx context.Context, vaultAddress string) (*exchangetypes.QueryMarketIDFromVaultResponse, error) + FetchHistoricalTradeRecords(ctx context.Context, marketId string) (*exchangetypes.QueryHistoricalTradeRecordsResponse, error) + FetchIsOptedOutOfRewards(ctx context.Context, account string) (*exchangetypes.QueryIsOptedOutOfRewardsResponse, error) + FetchOptedOutOfRewardsAccounts(ctx context.Context) (*exchangetypes.QueryOptedOutOfRewardsAccountsResponse, error) + FetchMarketVolatility(ctx context.Context, marketId string, tradeHistoryOptions *exchangetypes.TradeHistoryOptions) (*exchangetypes.QueryMarketVolatilityResponse, error) + FetchChainBinaryOptionsMarkets(ctx context.Context, status string) (*exchangetypes.QueryBinaryMarketsResponse, error) + FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) + FetchMarketAtomicExecutionFeeMultiplier(ctx context.Context, marketId string) (*exchangetypes.QueryMarketAtomicExecutionFeeMultiplierResponse, error) + Close() } @@ -191,7 +258,6 @@ type chainClient struct { gasWanted uint64 gasFee string - sessionCookie string sessionEnabled bool txClient txtypes.ServiceClient @@ -202,6 +268,7 @@ type chainClient struct { wasmQueryClient wasmtypes.QueryClient chainStreamClient chainstreamtypes.StreamClient tokenfactoryQueryClient tokenfactorytypes.QueryClient + distributionQueryClient distributiontypes.QueryClient subaccountToNonce map[ethcommon.Hash]uint32 closed int64 @@ -296,6 +363,7 @@ func NewChainClient( wasmQueryClient: wasmtypes.NewQueryClient(conn), chainStreamClient: chainstreamtypes.NewStreamClient(chainStreamConn), tokenfactoryQueryClient: tokenfactorytypes.NewQueryClient(conn), + distributionQueryClient: distributiontypes.NewQueryClient(conn), subaccountToNonce: make(map[ethcommon.Hash]uint32), } @@ -312,23 +380,6 @@ func NewChainClient( go cc.syncTimeoutHeight() } - // create file if not exist - cookieFile, err := os.OpenFile(defaultChainCookieName, os.O_RDONLY|os.O_CREATE, 0666) - if err != nil { - cc.logger.Errorln(err) - } else { - defer cookieFile.Close() - } - - // attempt to load from disk - data, err := os.ReadFile(defaultChainCookieName) - if err != nil { - cc.logger.Errorln(err) - } else { - cc.sessionCookie = string(data) - cc.logger.Debugln("chain session cookie loaded from disk") - } - return cc, nil } @@ -950,11 +1001,11 @@ func (c *chainClient) GetGasFee() (string, error) { return c.gasFee, err } -func (c *chainClient) DefaultSubaccount(acc cosmtypes.AccAddress) eth.Hash { +func (c *chainClient) DefaultSubaccount(acc sdk.AccAddress) eth.Hash { return c.Subaccount(acc, 0) } -func (c *chainClient) Subaccount(account cosmtypes.AccAddress, index int) eth.Hash { +func (c *chainClient) Subaccount(account sdk.AccAddress, index int) eth.Hash { ethAddress := eth.BytesToAddress(account.Bytes()) ethLowerAddress := strings.ToLower(ethAddress.String()) @@ -1019,7 +1070,7 @@ func (c *chainClient) CreateDerivativeOrder(defaultSubaccountID eth.Hash, d *Der orderSize := market.QuantityToChainFormat(d.Quantity) orderPrice := market.PriceToChainFormat(d.Price) - orderMargin := cosmtypes.MustNewDecFromStr("0") + orderMargin := sdk.MustNewDecFromStr("0") if !d.IsReduceOnly { orderMargin = market.CalculateMarginInChainFormat(d.Quantity, d.Price, d.Leverage) @@ -1494,3 +1545,475 @@ type OrderCancelData struct { OrderHash string Cid string } + +// Distribution module +func (c *chainClient) FetchValidatorDistributionInfo(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorDistributionInfoResponse, error) { + req := &distributiontypes.QueryValidatorDistributionInfoRequest{ + ValidatorAddress: validatorAddress, + } + return c.distributionQueryClient.ValidatorDistributionInfo(ctx, req) +} + +func (c *chainClient) FetchValidatorOutstandingRewards(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorOutstandingRewardsResponse, error) { + req := &distributiontypes.QueryValidatorOutstandingRewardsRequest{ + ValidatorAddress: validatorAddress, + } + return c.distributionQueryClient.ValidatorOutstandingRewards(ctx, req) +} + +func (c *chainClient) FetchValidatorCommission(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorCommissionResponse, error) { + req := &distributiontypes.QueryValidatorCommissionRequest{ + ValidatorAddress: validatorAddress, + } + return c.distributionQueryClient.ValidatorCommission(ctx, req) +} + +func (c *chainClient) FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight uint64, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) { + req := &distributiontypes.QueryValidatorSlashesRequest{ + ValidatorAddress: validatorAddress, + StartingHeight: startingHeight, + EndingHeight: endingHeight, + Pagination: pagination, + } + return c.distributionQueryClient.ValidatorSlashes(ctx, req) +} + +func (c *chainClient) FetchDelegationRewards(ctx context.Context, delegatorAddress string, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) { + req := &distributiontypes.QueryDelegationRewardsRequest{ + DelegatorAddress: delegatorAddress, + ValidatorAddress: validatorAddress, + } + return c.distributionQueryClient.DelegationRewards(ctx, req) +} + +func (c *chainClient) FetchDelegationTotalRewards(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegationTotalRewardsResponse, error) { + req := &distributiontypes.QueryDelegationTotalRewardsRequest{ + DelegatorAddress: delegatorAddress, + } + return c.distributionQueryClient.DelegationTotalRewards(ctx, req) +} + +func (c *chainClient) FetchDelegatorValidators(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegatorValidatorsResponse, error) { + req := &distributiontypes.QueryDelegatorValidatorsRequest{ + DelegatorAddress: delegatorAddress, + } + return c.distributionQueryClient.DelegatorValidators(ctx, req) +} + +func (c *chainClient) FetchDelegatorWithdrawAddress(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegatorWithdrawAddressResponse, error) { + req := &distributiontypes.QueryDelegatorWithdrawAddressRequest{ + DelegatorAddress: delegatorAddress, + } + return c.distributionQueryClient.DelegatorWithdrawAddress(ctx, req) +} + +func (c *chainClient) FetchCommunityPool(ctx context.Context) (*distributiontypes.QueryCommunityPoolResponse, error) { + req := &distributiontypes.QueryCommunityPoolRequest{} + return c.distributionQueryClient.CommunityPool(ctx, req) +} + +// Chain exchange module +func (c *chainClient) FetchSubaccountDeposits(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountDepositsResponse, error) { + req := &exchangetypes.QuerySubaccountDepositsRequest{ + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.SubaccountDeposits(ctx, req) +} + +func (c *chainClient) FetchSubaccountDeposit(ctx context.Context, subaccountId string, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) { + req := &exchangetypes.QuerySubaccountDepositRequest{ + SubaccountId: subaccountId, + Denom: denom, + } + return c.exchangeQueryClient.SubaccountDeposit(ctx, req) +} + +func (c *chainClient) FetchExchangeBalances(ctx context.Context) (*exchangetypes.QueryExchangeBalancesResponse, error) { + req := &exchangetypes.QueryExchangeBalancesRequest{} + return c.exchangeQueryClient.ExchangeBalances(ctx, req) +} + +func (c *chainClient) FetchAggregateVolume(ctx context.Context, account string) (*exchangetypes.QueryAggregateVolumeResponse, error) { + req := &exchangetypes.QueryAggregateVolumeRequest{ + Account: account, + } + return c.exchangeQueryClient.AggregateVolume(ctx, req) +} + +func (c *chainClient) FetchAggregateVolumes(ctx context.Context, accounts []string, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { + req := &exchangetypes.QueryAggregateVolumesRequest{ + Accounts: accounts, + MarketIds: marketIds, + } + return c.exchangeQueryClient.AggregateVolumes(ctx, req) +} + +func (c *chainClient) FetchAggregateMarketVolume(ctx context.Context, marketId string) (*exchangetypes.QueryAggregateMarketVolumeResponse, error) { + req := &exchangetypes.QueryAggregateMarketVolumeRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.AggregateMarketVolume(ctx, req) +} + +func (c *chainClient) FetchAggregateMarketVolumes(ctx context.Context, marketIds []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) { + req := &exchangetypes.QueryAggregateMarketVolumesRequest{ + MarketIds: marketIds, + } + return c.exchangeQueryClient.AggregateMarketVolumes(ctx, req) +} + +func (c *chainClient) FetchDenomDecimal(ctx context.Context, denom string) (*exchangetypes.QueryDenomDecimalResponse, error) { + req := &exchangetypes.QueryDenomDecimalRequest{ + Denom: denom, + } + return c.exchangeQueryClient.DenomDecimal(ctx, req) +} + +func (c *chainClient) FetchDenomDecimals(ctx context.Context, denoms []string) (*exchangetypes.QueryDenomDecimalsResponse, error) { + req := &exchangetypes.QueryDenomDecimalsRequest{ + Denoms: denoms, + } + return c.exchangeQueryClient.DenomDecimals(ctx, req) +} + +func (c *chainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIds []string) (*exchangetypes.QuerySpotMarketsResponse, error) { + req := &exchangetypes.QuerySpotMarketsRequest{ + MarketIds: marketIds, + } + if status != "" { + req.Status = status + } + return c.exchangeQueryClient.SpotMarkets(ctx, req) +} + +func (c *chainClient) FetchChainSpotMarket(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMarketResponse, error) { + req := &exchangetypes.QuerySpotMarketRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.SpotMarket(ctx, req) +} + +func (c *chainClient) FetchChainFullSpotMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) { + req := &exchangetypes.QueryFullSpotMarketsRequest{ + MarketIds: marketIds, + WithMidPriceAndTob: withMidPriceAndTob, + } + if status != "" { + req.Status = status + } + return c.exchangeQueryClient.FullSpotMarkets(ctx, req) +} + +func (c *chainClient) FetchChainFullSpotMarket(ctx context.Context, marketId string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketResponse, error) { + req := &exchangetypes.QueryFullSpotMarketRequest{ + MarketId: marketId, + WithMidPriceAndTob: withMidPriceAndTob, + } + return c.exchangeQueryClient.FullSpotMarket(ctx, req) +} + +func (c *chainClient) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional sdk.Dec, limitCumulativeQuantity sdk.Dec) (*exchangetypes.QuerySpotOrderbookResponse, error) { + req := &exchangetypes.QuerySpotOrderbookRequest{ + MarketId: marketId, + Limit: limit, + OrderSide: orderSide, + LimitCumulativeNotional: &limitCumulativeNotional, + LimitCumulativeQuantity: &limitCumulativeQuantity, + } + return c.exchangeQueryClient.SpotOrderbook(ctx, req) +} + +func (c *chainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { + req := &exchangetypes.QueryTraderSpotOrdersRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.TraderSpotOrders(ctx, req) +} + +func (c *chainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) { + req := &exchangetypes.QueryAccountAddressSpotOrdersRequest{ + MarketId: marketId, + AccountAddress: address, + } + return c.exchangeQueryClient.AccountAddressSpotOrders(ctx, req) +} + +func (c *chainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) { + req := &exchangetypes.QuerySpotOrdersByHashesRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + OrderHashes: orderHashes, + } + return c.exchangeQueryClient.SpotOrdersByHashes(ctx, req) +} + +func (c *chainClient) FetchChainSubaccountOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) { + req := &exchangetypes.QuerySubaccountOrdersRequest{ + SubaccountId: subaccountId, + MarketId: marketId, + } + return c.exchangeQueryClient.SubaccountOrders(ctx, req) +} + +func (c *chainClient) FetchChainTraderSpotTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { + req := &exchangetypes.QueryTraderSpotOrdersRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.TraderSpotTransientOrders(ctx, req) +} + +func (c *chainClient) FetchSpotMidPriceAndTOB(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMidPriceAndTOBResponse, error) { + req := &exchangetypes.QuerySpotMidPriceAndTOBRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.SpotMidPriceAndTOB(ctx, req) +} + +func (c *chainClient) FetchDerivativeMidPriceAndTOB(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMidPriceAndTOBResponse, error) { + req := &exchangetypes.QueryDerivativeMidPriceAndTOBRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.DerivativeMidPriceAndTOB(ctx, req) +} + +func (c *chainClient) FetchChainDerivativeOrderbook(ctx context.Context, marketId string, limit uint64, limitCumulativeNotional sdk.Dec) (*exchangetypes.QueryDerivativeOrderbookResponse, error) { + req := &exchangetypes.QueryDerivativeOrderbookRequest{ + MarketId: marketId, + Limit: limit, + LimitCumulativeNotional: &limitCumulativeNotional, + } + return c.exchangeQueryClient.DerivativeOrderbook(ctx, req) +} + +func (c *chainClient) FetchChainTraderDerivativeOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { + req := &exchangetypes.QueryTraderDerivativeOrdersRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.TraderDerivativeOrders(ctx, req) +} + +func (c *chainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) { + req := &exchangetypes.QueryAccountAddressDerivativeOrdersRequest{ + MarketId: marketId, + AccountAddress: address, + } + return c.exchangeQueryClient.AccountAddressDerivativeOrders(ctx, req) +} + +func (c *chainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) { + req := &exchangetypes.QueryDerivativeOrdersByHashesRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + OrderHashes: orderHashes, + } + return c.exchangeQueryClient.DerivativeOrdersByHashes(ctx, req) +} + +func (c *chainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { + req := &exchangetypes.QueryTraderDerivativeOrdersRequest{ + MarketId: marketId, + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.TraderDerivativeTransientOrders(ctx, req) +} + +func (c *chainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) { + req := &exchangetypes.QueryDerivativeMarketsRequest{ + MarketIds: marketIds, + WithMidPriceAndTob: withMidPriceAndTob, + } + if status != "" { + req.Status = status + } + return c.exchangeQueryClient.DerivativeMarkets(ctx, req) +} + +func (c *chainClient) FetchChainDerivativeMarket(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketResponse, error) { + req := &exchangetypes.QueryDerivativeMarketRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.DerivativeMarket(ctx, req) +} + +func (c *chainClient) FetchDerivativeMarketAddress(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketAddressResponse, error) { + req := &exchangetypes.QueryDerivativeMarketAddressRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.DerivativeMarketAddress(ctx, req) +} + +func (c *chainClient) FetchSubaccountTradeNonce(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) { + req := &exchangetypes.QuerySubaccountTradeNonceRequest{ + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.SubaccountTradeNonce(ctx, req) +} + +func (c *chainClient) FetchChainPositions(ctx context.Context) (*exchangetypes.QueryPositionsResponse, error) { + req := &exchangetypes.QueryPositionsRequest{} + return c.exchangeQueryClient.Positions(ctx, req) +} + +func (c *chainClient) FetchChainSubaccountPositions(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountPositionsResponse, error) { + req := &exchangetypes.QuerySubaccountPositionsRequest{ + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.SubaccountPositions(ctx, req) +} + +func (c *chainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) { + req := &exchangetypes.QuerySubaccountPositionInMarketRequest{ + SubaccountId: subaccountId, + MarketId: marketId, + } + return c.exchangeQueryClient.SubaccountPositionInMarket(ctx, req) +} + +func (c *chainClient) FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) { + req := &exchangetypes.QuerySubaccountEffectivePositionInMarketRequest{ + SubaccountId: subaccountId, + MarketId: marketId, + } + return c.exchangeQueryClient.SubaccountEffectivePositionInMarket(ctx, req) +} + +func (c *chainClient) FetchChainPerpetualMarketInfo(ctx context.Context, marketId string) (*exchangetypes.QueryPerpetualMarketInfoResponse, error) { + req := &exchangetypes.QueryPerpetualMarketInfoRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.PerpetualMarketInfo(ctx, req) +} + +func (c *chainClient) FetchChainExpiryFuturesMarketInfo(ctx context.Context, marketId string) (*exchangetypes.QueryExpiryFuturesMarketInfoResponse, error) { + req := &exchangetypes.QueryExpiryFuturesMarketInfoRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.ExpiryFuturesMarketInfo(ctx, req) +} + +func (c *chainClient) FetchChainPerpetualMarketFunding(ctx context.Context, marketId string) (*exchangetypes.QueryPerpetualMarketFundingResponse, error) { + req := &exchangetypes.QueryPerpetualMarketFundingRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.PerpetualMarketFunding(ctx, req) +} + +func (c *chainClient) FetchSubaccountOrderMetadata(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountOrderMetadataResponse, error) { + req := &exchangetypes.QuerySubaccountOrderMetadataRequest{ + SubaccountId: subaccountId, + } + return c.exchangeQueryClient.SubaccountOrderMetadata(ctx, req) +} + +func (c *chainClient) FetchTradeRewardPoints(ctx context.Context, accounts []string) (*exchangetypes.QueryTradeRewardPointsResponse, error) { + req := &exchangetypes.QueryTradeRewardPointsRequest{ + Accounts: accounts, + } + return c.exchangeQueryClient.TradeRewardPoints(ctx, req) +} + +func (c *chainClient) FetchPendingTradeRewardPoints(ctx context.Context, accounts []string) (*exchangetypes.QueryTradeRewardPointsResponse, error) { + req := &exchangetypes.QueryTradeRewardPointsRequest{ + Accounts: accounts, + } + return c.exchangeQueryClient.PendingTradeRewardPoints(ctx, req) +} + +func (c *chainClient) FetchTradeRewardCampaign(ctx context.Context) (*exchangetypes.QueryTradeRewardCampaignResponse, error) { + req := &exchangetypes.QueryTradeRewardCampaignRequest{} + return c.exchangeQueryClient.TradeRewardCampaign(ctx, req) +} + +func (c *chainClient) FetchFeeDiscountAccountInfo(ctx context.Context, account string) (*exchangetypes.QueryFeeDiscountAccountInfoResponse, error) { + req := &exchangetypes.QueryFeeDiscountAccountInfoRequest{ + Account: account, + } + return c.exchangeQueryClient.FeeDiscountAccountInfo(ctx, req) +} + +func (c *chainClient) FetchFeeDiscountSchedule(ctx context.Context) (*exchangetypes.QueryFeeDiscountScheduleResponse, error) { + req := &exchangetypes.QueryFeeDiscountScheduleRequest{} + return c.exchangeQueryClient.FeeDiscountSchedule(ctx, req) +} + +func (c *chainClient) FetchBalanceMismatches(ctx context.Context, dustFactor int64) (*exchangetypes.QueryBalanceMismatchesResponse, error) { + req := &exchangetypes.QueryBalanceMismatchesRequest{ + DustFactor: dustFactor, + } + return c.exchangeQueryClient.BalanceMismatches(ctx, req) +} + +func (c *chainClient) FetchBalanceWithBalanceHolds(ctx context.Context) (*exchangetypes.QueryBalanceWithBalanceHoldsResponse, error) { + req := &exchangetypes.QueryBalanceWithBalanceHoldsRequest{} + return c.exchangeQueryClient.BalanceWithBalanceHolds(ctx, req) +} + +func (c *chainClient) FetchFeeDiscountTierStatistics(ctx context.Context) (*exchangetypes.QueryFeeDiscountTierStatisticsResponse, error) { + req := &exchangetypes.QueryFeeDiscountTierStatisticsRequest{} + return c.exchangeQueryClient.FeeDiscountTierStatistics(ctx, req) +} + +func (c *chainClient) FetchMitoVaultInfos(ctx context.Context) (*exchangetypes.MitoVaultInfosResponse, error) { + req := &exchangetypes.MitoVaultInfosRequest{} + return c.exchangeQueryClient.MitoVaultInfos(ctx, req) +} + +func (c *chainClient) FetchMarketIDFromVault(ctx context.Context, vaultAddress string) (*exchangetypes.QueryMarketIDFromVaultResponse, error) { + req := &exchangetypes.QueryMarketIDFromVaultRequest{ + VaultAddress: vaultAddress, + } + return c.exchangeQueryClient.QueryMarketIDFromVault(ctx, req) +} + +func (c *chainClient) FetchHistoricalTradeRecords(ctx context.Context, marketId string) (*exchangetypes.QueryHistoricalTradeRecordsResponse, error) { + req := &exchangetypes.QueryHistoricalTradeRecordsRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.HistoricalTradeRecords(ctx, req) +} + +func (c *chainClient) FetchIsOptedOutOfRewards(ctx context.Context, account string) (*exchangetypes.QueryIsOptedOutOfRewardsResponse, error) { + req := &exchangetypes.QueryIsOptedOutOfRewardsRequest{ + Account: account, + } + return c.exchangeQueryClient.IsOptedOutOfRewards(ctx, req) +} + +func (c *chainClient) FetchOptedOutOfRewardsAccounts(ctx context.Context) (*exchangetypes.QueryOptedOutOfRewardsAccountsResponse, error) { + req := &exchangetypes.QueryOptedOutOfRewardsAccountsRequest{} + return c.exchangeQueryClient.OptedOutOfRewardsAccounts(ctx, req) +} + +func (c *chainClient) FetchMarketVolatility(ctx context.Context, marketId string, tradeHistoryOptions *exchangetypes.TradeHistoryOptions) (*exchangetypes.QueryMarketVolatilityResponse, error) { + req := &exchangetypes.QueryMarketVolatilityRequest{ + MarketId: marketId, + TradeHistoryOptions: tradeHistoryOptions, + } + return c.exchangeQueryClient.MarketVolatility(ctx, req) +} + +func (c *chainClient) FetchChainBinaryOptionsMarkets(ctx context.Context, status string) (*exchangetypes.QueryBinaryMarketsResponse, error) { + req := &exchangetypes.QueryBinaryMarketsRequest{} + if status != "" { + req.Status = status + } + return c.exchangeQueryClient.BinaryOptionsMarkets(ctx, req) +} + +func (c *chainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) { + req := &exchangetypes.QueryTraderDerivativeConditionalOrdersRequest{ + SubaccountId: subaccountId, + MarketId: marketId, + } + return c.exchangeQueryClient.TraderDerivativeConditionalOrders(ctx, req) +} + +func (c *chainClient) FetchMarketAtomicExecutionFeeMultiplier(ctx context.Context, marketId string) (*exchangetypes.QueryMarketAtomicExecutionFeeMultiplierResponse, error) { + req := &exchangetypes.QueryMarketAtomicExecutionFeeMultiplierRequest{ + MarketId: marketId, + } + return c.exchangeQueryClient.MarketAtomicExecutionFeeMultiplier(ctx, req) +} diff --git a/client/chain/chain_test_support.go b/client/chain/chain_test_support.go index 5d15bd13..5ae0cfb6 100644 --- a/client/chain/chain_test_support.go +++ b/client/chain/chain_test_support.go @@ -5,6 +5,8 @@ import ( "errors" "time" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + tokenfactorytypes "github.com/InjectiveLabs/sdk-go/chain/tokenfactory/types" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" @@ -286,3 +288,261 @@ func (c *MockChainClient) FetchDenomsFromCreator(ctx context.Context, creator st func (c *MockChainClient) FetchTokenfactoryModuleState(ctx context.Context) (*tokenfactorytypes.QueryModuleStateResponse, error) { return &tokenfactorytypes.QueryModuleStateResponse{}, nil } + +// Distribution module +func (c *MockChainClient) FetchValidatorDistributionInfo(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorDistributionInfoResponse, error) { + return &distributiontypes.QueryValidatorDistributionInfoResponse{}, nil +} + +func (c *MockChainClient) FetchValidatorOutstandingRewards(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorOutstandingRewardsResponse, error) { + return &distributiontypes.QueryValidatorOutstandingRewardsResponse{}, nil +} + +func (c *MockChainClient) FetchValidatorCommission(ctx context.Context, validatorAddress string) (*distributiontypes.QueryValidatorCommissionResponse, error) { + return &distributiontypes.QueryValidatorCommissionResponse{}, nil +} + +func (c *MockChainClient) FetchValidatorSlashes(ctx context.Context, validatorAddress string, startingHeight uint64, endingHeight uint64, pagination *query.PageRequest) (*distributiontypes.QueryValidatorSlashesResponse, error) { + return &distributiontypes.QueryValidatorSlashesResponse{}, nil +} + +func (c *MockChainClient) FetchDelegationRewards(ctx context.Context, delegatorAddress string, validatorAddress string) (*distributiontypes.QueryDelegationRewardsResponse, error) { + return &distributiontypes.QueryDelegationRewardsResponse{}, nil +} + +func (c *MockChainClient) FetchDelegationTotalRewards(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegationTotalRewardsResponse, error) { + return &distributiontypes.QueryDelegationTotalRewardsResponse{}, nil +} + +func (c *MockChainClient) FetchDelegatorValidators(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegatorValidatorsResponse, error) { + return &distributiontypes.QueryDelegatorValidatorsResponse{}, nil +} + +func (c *MockChainClient) FetchDelegatorWithdrawAddress(ctx context.Context, delegatorAddress string) (*distributiontypes.QueryDelegatorWithdrawAddressResponse, error) { + return &distributiontypes.QueryDelegatorWithdrawAddressResponse{}, nil +} + +func (c *MockChainClient) FetchCommunityPool(ctx context.Context) (*distributiontypes.QueryCommunityPoolResponse, error) { + return &distributiontypes.QueryCommunityPoolResponse{}, nil +} + +// Chain exchange module +func (c *MockChainClient) FetchSubaccountDeposits(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountDepositsResponse, error) { + return &exchangetypes.QuerySubaccountDepositsResponse{}, nil +} + +func (c *MockChainClient) FetchSubaccountDeposit(ctx context.Context, subaccountId string, denom string) (*exchangetypes.QuerySubaccountDepositResponse, error) { + return &exchangetypes.QuerySubaccountDepositResponse{}, nil +} + +func (c *MockChainClient) FetchExchangeBalances(ctx context.Context) (*exchangetypes.QueryExchangeBalancesResponse, error) { + return &exchangetypes.QueryExchangeBalancesResponse{}, nil +} + +func (c *MockChainClient) FetchAggregateVolume(ctx context.Context, account string) (*exchangetypes.QueryAggregateVolumeResponse, error) { + return &exchangetypes.QueryAggregateVolumeResponse{}, nil +} + +func (c *MockChainClient) FetchAggregateVolumes(ctx context.Context, accounts []string, marketIds []string) (*exchangetypes.QueryAggregateVolumesResponse, error) { + return &exchangetypes.QueryAggregateVolumesResponse{}, nil +} + +func (c *MockChainClient) FetchAggregateMarketVolume(ctx context.Context, marketId string) (*exchangetypes.QueryAggregateMarketVolumeResponse, error) { + return &exchangetypes.QueryAggregateMarketVolumeResponse{}, nil +} + +func (c *MockChainClient) FetchAggregateMarketVolumes(ctx context.Context, marketIds []string) (*exchangetypes.QueryAggregateMarketVolumesResponse, error) { + return &exchangetypes.QueryAggregateMarketVolumesResponse{}, nil +} + +func (c *MockChainClient) FetchDenomDecimal(ctx context.Context, denom string) (*exchangetypes.QueryDenomDecimalResponse, error) { + return &exchangetypes.QueryDenomDecimalResponse{}, nil +} + +func (c *MockChainClient) FetchDenomDecimals(ctx context.Context, denoms []string) (*exchangetypes.QueryDenomDecimalsResponse, error) { + return &exchangetypes.QueryDenomDecimalsResponse{}, nil +} + +func (c *MockChainClient) FetchChainSpotMarkets(ctx context.Context, status string, marketIds []string) (*exchangetypes.QuerySpotMarketsResponse, error) { + return &exchangetypes.QuerySpotMarketsResponse{}, nil +} + +func (c *MockChainClient) FetchChainSpotMarket(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMarketResponse, error) { + return &exchangetypes.QuerySpotMarketResponse{}, nil +} + +func (c *MockChainClient) FetchChainFullSpotMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketsResponse, error) { + return &exchangetypes.QueryFullSpotMarketsResponse{}, nil +} + +func (c *MockChainClient) FetchChainFullSpotMarket(ctx context.Context, marketId string, withMidPriceAndTob bool) (*exchangetypes.QueryFullSpotMarketResponse, error) { + return &exchangetypes.QueryFullSpotMarketResponse{}, nil +} + +func (c *MockChainClient) FetchChainSpotOrderbook(ctx context.Context, marketId string, limit uint64, orderSide exchangetypes.OrderSide, limitCumulativeNotional sdk.Dec, limitCumulativeQuantity sdk.Dec) (*exchangetypes.QuerySpotOrderbookResponse, error) { + return &exchangetypes.QuerySpotOrderbookResponse{}, nil +} + +func (c *MockChainClient) FetchChainTraderSpotOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { + return &exchangetypes.QueryTraderSpotOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchChainAccountAddressSpotOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressSpotOrdersResponse, error) { + return &exchangetypes.QueryAccountAddressSpotOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchChainSpotOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QuerySpotOrdersByHashesResponse, error) { + return &exchangetypes.QuerySpotOrdersByHashesResponse{}, nil +} + +func (c *MockChainClient) FetchChainSubaccountOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountOrdersResponse, error) { + return &exchangetypes.QuerySubaccountOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchChainTraderSpotTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderSpotOrdersResponse, error) { + return &exchangetypes.QueryTraderSpotOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchSpotMidPriceAndTOB(ctx context.Context, marketId string) (*exchangetypes.QuerySpotMidPriceAndTOBResponse, error) { + return &exchangetypes.QuerySpotMidPriceAndTOBResponse{}, nil +} + +func (c *MockChainClient) FetchDerivativeMidPriceAndTOB(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMidPriceAndTOBResponse, error) { + return &exchangetypes.QueryDerivativeMidPriceAndTOBResponse{}, nil +} + +func (c *MockChainClient) FetchChainDerivativeOrderbook(ctx context.Context, marketId string, limit uint64, limitCumulativeNotional sdk.Dec) (*exchangetypes.QueryDerivativeOrderbookResponse, error) { + return &exchangetypes.QueryDerivativeOrderbookResponse{}, nil +} + +func (c *MockChainClient) FetchChainTraderDerivativeOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { + return &exchangetypes.QueryTraderDerivativeOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchChainAccountAddressDerivativeOrders(ctx context.Context, marketId string, address string) (*exchangetypes.QueryAccountAddressDerivativeOrdersResponse, error) { + return &exchangetypes.QueryAccountAddressDerivativeOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchChainDerivativeOrdersByHashes(ctx context.Context, marketId string, subaccountId string, orderHashes []string) (*exchangetypes.QueryDerivativeOrdersByHashesResponse, error) { + return &exchangetypes.QueryDerivativeOrdersByHashesResponse{}, nil +} + +func (c *MockChainClient) FetchChainTraderDerivativeTransientOrders(ctx context.Context, marketId string, subaccountId string) (*exchangetypes.QueryTraderDerivativeOrdersResponse, error) { + return &exchangetypes.QueryTraderDerivativeOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchChainDerivativeMarkets(ctx context.Context, status string, marketIds []string, withMidPriceAndTob bool) (*exchangetypes.QueryDerivativeMarketsResponse, error) { + return &exchangetypes.QueryDerivativeMarketsResponse{}, nil +} + +func (c *MockChainClient) FetchChainDerivativeMarket(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketResponse, error) { + return &exchangetypes.QueryDerivativeMarketResponse{}, nil +} + +func (c *MockChainClient) FetchDerivativeMarketAddress(ctx context.Context, marketId string) (*exchangetypes.QueryDerivativeMarketAddressResponse, error) { + return &exchangetypes.QueryDerivativeMarketAddressResponse{}, nil +} + +func (c *MockChainClient) FetchSubaccountTradeNonce(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountTradeNonceResponse, error) { + return &exchangetypes.QuerySubaccountTradeNonceResponse{}, nil +} + +func (c *MockChainClient) FetchChainPositions(ctx context.Context) (*exchangetypes.QueryPositionsResponse, error) { + return &exchangetypes.QueryPositionsResponse{}, nil +} + +func (c *MockChainClient) FetchChainSubaccountPositions(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountPositionsResponse, error) { + return &exchangetypes.QuerySubaccountPositionsResponse{}, nil +} + +func (c *MockChainClient) FetchChainSubaccountPositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountPositionInMarketResponse, error) { + return &exchangetypes.QuerySubaccountPositionInMarketResponse{}, nil +} + +func (c *MockChainClient) FetchChainSubaccountEffectivePositionInMarket(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QuerySubaccountEffectivePositionInMarketResponse, error) { + return &exchangetypes.QuerySubaccountEffectivePositionInMarketResponse{}, nil +} + +func (c *MockChainClient) FetchChainPerpetualMarketInfo(ctx context.Context, marketId string) (*exchangetypes.QueryPerpetualMarketInfoResponse, error) { + return &exchangetypes.QueryPerpetualMarketInfoResponse{}, nil +} + +func (c *MockChainClient) FetchChainExpiryFuturesMarketInfo(ctx context.Context, marketId string) (*exchangetypes.QueryExpiryFuturesMarketInfoResponse, error) { + return &exchangetypes.QueryExpiryFuturesMarketInfoResponse{}, nil +} + +func (c *MockChainClient) FetchChainPerpetualMarketFunding(ctx context.Context, marketId string) (*exchangetypes.QueryPerpetualMarketFundingResponse, error) { + return &exchangetypes.QueryPerpetualMarketFundingResponse{}, nil +} + +func (c *MockChainClient) FetchSubaccountOrderMetadata(ctx context.Context, subaccountId string) (*exchangetypes.QuerySubaccountOrderMetadataResponse, error) { + return &exchangetypes.QuerySubaccountOrderMetadataResponse{}, nil +} + +func (c *MockChainClient) FetchTradeRewardPoints(ctx context.Context, accounts []string) (*exchangetypes.QueryTradeRewardPointsResponse, error) { + return &exchangetypes.QueryTradeRewardPointsResponse{}, nil +} + +func (c *MockChainClient) FetchPendingTradeRewardPoints(ctx context.Context, accounts []string) (*exchangetypes.QueryTradeRewardPointsResponse, error) { + return &exchangetypes.QueryTradeRewardPointsResponse{}, nil +} + +func (c *MockChainClient) FetchTradeRewardCampaign(ctx context.Context) (*exchangetypes.QueryTradeRewardCampaignResponse, error) { + return &exchangetypes.QueryTradeRewardCampaignResponse{}, nil +} + +func (c *MockChainClient) FetchFeeDiscountAccountInfo(ctx context.Context, account string) (*exchangetypes.QueryFeeDiscountAccountInfoResponse, error) { + return &exchangetypes.QueryFeeDiscountAccountInfoResponse{}, nil +} + +func (c *MockChainClient) FetchFeeDiscountSchedule(ctx context.Context) (*exchangetypes.QueryFeeDiscountScheduleResponse, error) { + return &exchangetypes.QueryFeeDiscountScheduleResponse{}, nil +} + +func (c *MockChainClient) FetchBalanceMismatches(ctx context.Context, dustFactor int64) (*exchangetypes.QueryBalanceMismatchesResponse, error) { + return &exchangetypes.QueryBalanceMismatchesResponse{}, nil +} + +func (c *MockChainClient) FetchBalanceWithBalanceHolds(ctx context.Context) (*exchangetypes.QueryBalanceWithBalanceHoldsResponse, error) { + return &exchangetypes.QueryBalanceWithBalanceHoldsResponse{}, nil +} + +func (c *MockChainClient) FetchFeeDiscountTierStatistics(ctx context.Context) (*exchangetypes.QueryFeeDiscountTierStatisticsResponse, error) { + return &exchangetypes.QueryFeeDiscountTierStatisticsResponse{}, nil +} + +func (c *MockChainClient) FetchMitoVaultInfos(ctx context.Context) (*exchangetypes.MitoVaultInfosResponse, error) { + return &exchangetypes.MitoVaultInfosResponse{}, nil +} + +func (c *MockChainClient) FetchMarketIDFromVault(ctx context.Context, vaultAddress string) (*exchangetypes.QueryMarketIDFromVaultResponse, error) { + return &exchangetypes.QueryMarketIDFromVaultResponse{}, nil +} + +func (c *MockChainClient) FetchHistoricalTradeRecords(ctx context.Context, marketId string) (*exchangetypes.QueryHistoricalTradeRecordsResponse, error) { + return &exchangetypes.QueryHistoricalTradeRecordsResponse{}, nil +} + +func (c *MockChainClient) FetchIsOptedOutOfRewards(ctx context.Context, account string) (*exchangetypes.QueryIsOptedOutOfRewardsResponse, error) { + return &exchangetypes.QueryIsOptedOutOfRewardsResponse{}, nil +} + +func (c *MockChainClient) FetchOptedOutOfRewardsAccounts(ctx context.Context) (*exchangetypes.QueryOptedOutOfRewardsAccountsResponse, error) { + return &exchangetypes.QueryOptedOutOfRewardsAccountsResponse{}, nil +} + +func (c *MockChainClient) FetchMarketVolatility(ctx context.Context, marketId string, tradeHistoryOptions *exchangetypes.TradeHistoryOptions) (*exchangetypes.QueryMarketVolatilityResponse, error) { + return &exchangetypes.QueryMarketVolatilityResponse{}, nil +} + +func (c *MockChainClient) FetchChainBinaryOptionsMarkets(ctx context.Context, status string) (*exchangetypes.QueryBinaryMarketsResponse, error) { + return &exchangetypes.QueryBinaryMarketsResponse{}, nil +} + +func (c *MockChainClient) FetchTraderDerivativeConditionalOrders(ctx context.Context, subaccountId string, marketId string) (*exchangetypes.QueryTraderDerivativeConditionalOrdersResponse, error) { + return &exchangetypes.QueryTraderDerivativeConditionalOrdersResponse{}, nil +} + +func (c *MockChainClient) FetchMarketAtomicExecutionFeeMultiplier(ctx context.Context, marketId string) (*exchangetypes.QueryMarketAtomicExecutionFeeMultiplierResponse, error) { + return &exchangetypes.QueryMarketAtomicExecutionFeeMultiplierResponse{}, nil +} diff --git a/client/metadata/assets/devnet.ini b/client/metadata/assets/devnet.ini index 62979d72..2b6020db 100644 --- a/client/metadata/assets/devnet.ini +++ b/client/metadata/assets/devnet.ini @@ -164,10 +164,37 @@ min_display_quantity_tick_size = 0.00001 description = 'Devnet Spot PROJ/INJ' base = 18 quote = 18 -min_price_tick_size = 0.001 -min_display_price_tick_size = 0.001 -min_quantity_tick_size = 10000000000000 -min_display_quantity_tick_size = 0.00001 +min_price_tick_size = 0.00000001 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000000000000000 +min_display_quantity_tick_size = 1000 + +[0x2d3b8d8833dda54a717adea9119134556848105fd6028e9a4a526e4e5a122a57] +description = 'Devnet Spot KIRA/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 + +[0x42edf70cc37e155e9b9f178e04e18999bc8c404bd7b638cc4cbf41da8ef45a21] +description = 'Devnet Spot QUNT/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 + +[0xc8fafa1fcab27e16da20e98b4dc9dda45320418c27db80663b21edac72f3b597] +description = 'Devnet Spot HDRO/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 [0x1422a13427d5eabd4d8de7907c8340f7e58cb15553a9fd4ad5c90406561886f9] description = 'Devnet Derivative COMP/USDT PERP' @@ -287,10 +314,18 @@ decimals = 18 peggy_denom = peggy0xAaEf88cEa01475125522e117BFe45cF32044E238 decimals = 18 +[HDRO] +peggy_denom = factory/inj1etz0laas6h7vemg3qtd67jpr6lh8v7xz7gfzqw/hdro +decimals = 6 + [INJ] peggy_denom = inj decimals = 18 +[KIRA] +peggy_denom = factory/inj1xy3kvlr4q4wdd6lrelsrw2fk2ged0any44hhwq/KIRA +decimals = 6 + [LINK] peggy_denom = peggy0x514910771AF9Ca656af840dff83E8264EcF986CA decimals = 18 @@ -303,6 +338,10 @@ decimals = 18 peggy_denom = proj decimals = 18 +[QUNT] +peggy_denom = factory/inj127l5a2wmkyvucxdlupqyac3y0v6wqfhq03ka64/qunt +decimals = 6 + [SOMM] peggy_denom = ibc/34346A60A95EB030D62D6F5BDD4B745BE18E8A693372A8A347D5D53DBBB1328B decimals = 6 diff --git a/client/metadata/assets/mainnet.ini b/client/metadata/assets/mainnet.ini index b2430837..5f6611ef 100644 --- a/client/metadata/assets/mainnet.ini +++ b/client/metadata/assets/mainnet.ini @@ -682,6 +682,105 @@ min_display_price_tick_size = 0.000001 min_quantity_tick_size = 10000000000000000000 min_display_quantity_tick_size = 10 +[0xe6dd9895b169e2ca0087fcb8e8013805d06c3ed8ffc01ccaa31c710eef14a984] +description = 'Mainnet Spot DOJO/INJ' +base = 18 +quote = 18 +min_price_tick_size = 0.000001 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 10000000000000000000 +min_display_quantity_tick_size = 10 + +[0x0a1366c8b05658c0ccca6064e4b20aacd5ad350c02debd6ec0f4dc9178145d14] +description = 'Mainnet Spot GYEN/USDT' +base = 6 +quote = 6 +min_price_tick_size = 0.000001 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 100000000 +min_display_quantity_tick_size = 100 + +[0x9c8a91a894f773792b1e8d0b6a8224a6b748753738e9945020ee566266f817be] +description = 'Mainnet Spot USDCnb/USDT' +base = 6 +quote = 6 +min_price_tick_size = 0.0001 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 100000 +min_display_quantity_tick_size = 0.1 + +[0x9c42d763ba5135809ac4684b02082e9c880d69f6b96d258fe4c172396e9af7be] +description = 'Mainnet Spot ANDR/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000000 +min_display_price_tick_size = 0.00001 +min_quantity_tick_size = 100000 +min_display_quantity_tick_size = 0.1 + +[0x1b1e062b3306f26ae3af3c354a10c1cf38b00dcb42917f038ba3fc14978b1dd8] +description = 'Mainnet Spot hINJ/INJ' +base = 18 +quote = 18 +min_price_tick_size = 0.0001 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1000000000000000 +min_display_quantity_tick_size = 0.001 + +[0x959c9401a557ac090fff3ec11db5a1a9832e51a97a41b722d2496bb3cb0b2f72] +description = 'Mainnet Spot ANDR/INJ' +base = 6 +quote = 6 +min_price_tick_size = 0.0001 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 + +[0x697457537bc2af5ff652bc0616fe23537437a570d0e4d91566f03af279e095d5] +description = 'Mainnet Spot PHUC/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 + +[0x42edf70cc37e155e9b9f178e04e18999bc8c404bd7b638cc4cbf41da8ef45a21] +description = 'Mainnet Spot QUNT/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 + +[0x586409ac5f6d6e90a81d2585b9a8e76de0b4898d5f2c047d0bc025a036489ba1] +description = 'Mainnet Spot WHALE/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 + +[0xc8fafa1fcab27e16da20e98b4dc9dda45320418c27db80663b21edac72f3b597] +description = 'Mainnet Spot HDRO/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 + +[0xb965ebede42e67af153929339040e650d5c2af26d6aa43382c110d943c627b0a] +description = 'Mainnet Spot PYTH/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000000 +min_display_price_tick_size = 0.00001 +min_quantity_tick_size = 100000 +min_display_quantity_tick_size = 0.1 + [0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce] description = 'Mainnet Derivative BTC/USDT PERP' base = 0 @@ -736,14 +835,32 @@ min_display_price_tick_size = 0.001 min_quantity_tick_size = 0.01 min_display_quantity_tick_size = 0.01 +[0xcf18525b53e54ad7d27477426ade06d69d8d56d2f3bf35fe5ce2ad9eb97c2fbc] +description = 'Mainnet Derivative OSMO/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 1000 +min_display_price_tick_size = 0.001 +min_quantity_tick_size = 0.1 +min_display_quantity_tick_size = 0.1 + [0x06c5a306492ddc2b8dc56969766959163287ed68a6b59baa2f42330dda0aebe0] description = 'Mainnet Derivative SOL/USDT PERP' base = 0 quote = 6 min_price_tick_size = 10000 min_display_price_tick_size = 0.01 -min_quantity_tick_size = 0.1 -min_display_quantity_tick_size = 0.1 +min_quantity_tick_size = 0.001 +min_display_quantity_tick_size = 0.001 + +[0x3b7fb1d9351f7fa2e6e0e5a11b3639ee5e0486c33a6a74f629c3fc3c3043efd5] +description = 'Mainnet Derivative BONK/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 0.01 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 10000 +min_display_quantity_tick_size = 10000 [0xcd0c859a99f26bb3530e21890937ed77d20754aa7825a599c71710514fc125ef] description = 'Mainnet Derivative 1MPEPE/USDT PERP' @@ -817,10 +934,86 @@ min_display_price_tick_size = 0.00001 min_quantity_tick_size = 1 min_display_quantity_tick_size = 1 +[0x30a1463cfb4c393c80e257ab93118cecd73c1e632dc4d2d31c12a51bc0a70bd7] +description = 'Mainnet Derivative AVAX/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.01 +min_quantity_tick_size = 0.01 +min_display_quantity_tick_size = 0.01 + +[0x18b2ca44b3d20a3b87c87d3765669b09b73b5e900693896c08394c70e79ab1e7] +description = 'Mainnet Derivative SUI/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 1000 +min_display_price_tick_size = 0.001 +min_quantity_tick_size = 0.1 +min_display_quantity_tick_size = 0.1 + +[0x1a6d3a59f45904e0a4a2eed269fc2f552e7e407ac90aaaeb602c31b017573f88] +description = 'Mainnet Derivative WIF/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 100 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1 +min_display_quantity_tick_size = 1 + +[0x48fcecd66ebabbf5a331178ec693b261dfae66ddfe6f552d7446744c6e78046c] +description = 'Mainnet Derivative OP/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 1000 +min_display_price_tick_size = 0.001 +min_quantity_tick_size = 0.1 +min_display_quantity_tick_size = 0.1 + +[0x6ddf0b8fbbd888981aafdae9fc967a12c6777aac4dd100a8257b8755c0c4b7d5] +description = 'Mainnet Derivative ARB/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 1000 +min_display_price_tick_size = 0.001 +min_quantity_tick_size = 0.1 +min_display_quantity_tick_size = 0.1 + +[0xf1bc70398e9b469db459f3153433c6bd1253bd02377248ee29bd346a218e6243] +description = 'Mainnet Derivative W/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 100 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1 +min_display_quantity_tick_size = 1 + +[0x03c8da1f6aaf8aca2be26b0f4d6b89d475835c7812a1dcdb19af7dec1c6b7f60] +description = 'Mainnet Derivative LINK/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.01 +min_quantity_tick_size = 0.01 +min_display_quantity_tick_size = 0.01 + +[0x7980993e508e0efc1c2634c153a1ef90f517b74351d6406221c77c04ec4799fe] +description = 'Mainnet Derivative DOGE/USDT PERP' +base = 0 +quote = 6 +min_price_tick_size = 10 +min_display_price_tick_size = 0.00001 +min_quantity_tick_size = 10 +min_display_quantity_tick_size = 10 + [AAVE] peggy_denom = peggy0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9 decimals = 18 +[ANDR] +peggy_denom = ibc/61FA42C3F0B0F8768ED2CE380EDD3BE0E4CB7E67688F81F70DE9ECF5F8684E1E +decimals = 6 + [APE] peggy_denom = peggy0x4d224452801ACEd8B2F0aebE155379bb5D594381 decimals = 18 @@ -845,6 +1038,10 @@ decimals = 6 peggy_denom = peggy0xBB0E17EF65F82Ab018d8EDd776e8DD940327B28b decimals = 18 +[Axelar Wrapped USDC] +peggy_denom = ibc/7E1AF94AD246BE522892751046F0C959B768642E5671CC3742264068D49553C0 +decimals = 6 + [BRETT] peggy_denom = factory/inj13jjdsa953w03dvecsr43dj5r6a2vzt7n0spncv/brett decimals = 6 @@ -861,6 +1058,10 @@ decimals = 8 peggy_denom = ibc/3A6DD3358D9F7ADD18CDE79BA10B400511A5DE4AE2C037D7C9639B52ADAF35C6 decimals = 6 +[DOJO] +peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1zdj9kqnknztl2xclm5ssv25yre09f8908d4923 +decimals = 18 + [DOT] peggy_denom = ibc/624BA9DD171915A2B9EA70F69638B2CEA179959850C1A586F6C485498F29EDD4 decimals = 10 @@ -885,6 +1086,14 @@ decimals = 6 peggy_denom = peggy0xc944E90C64B2c07662A292be6244BDf05Cda44a7 decimals = 18 +[GYEN] +peggy_denom = peggy0xC08512927D12348F6620a698105e1BAac6EcD911 +decimals = 6 + +[HDRO] +peggy_denom = factory/inj1etz0laas6h7vemg3qtd67jpr6lh8v7xz7gfzqw/hdro +decimals = 6 + [HUAHUA] peggy_denom = ibc/E7807A46C0B7B44B350DA58F51F278881B863EC4DCA94635DAB39E52C30766CB decimals = 6 @@ -933,10 +1142,18 @@ decimals = 18 peggy_denom = factory/inj1xtel2knkt8hmc9dnzpjz6kdmacgcfmlv5f308w/ninja decimals = 6 +[Noble USD Coin] +peggy_denom = ibc/2CBC2EA121AE42563B08028466F37B600F2D7D4282342DE938283CC3FB2BC00E +decimals = 6 + [ORAI] peggy_denom = ibc/C20C0A822BD22B2CEF0D067400FCCFB6FAEEE9E91D360B4E0725BD522302D565 decimals = 6 +[PHUC] +peggy_denom = factory/inj1995xnrrtnmtdgjmx0g937vf28dwefhkhy6gy5e/phuc +decimals = 6 + [PUG] peggy_denom = peggy0xf9a06dE3F6639E6ee4F079095D5093644Ad85E8b decimals = 18 @@ -949,6 +1166,10 @@ decimals = 6 peggy_denom = peggy0x4a220E6096B25EADb88358cb44068A3248254675 decimals = 18 +[QUNT] +peggy_denom = factory/inj127l5a2wmkyvucxdlupqyac3y0v6wqfhq03ka64/qunt +decimals = 6 + [SNOWY] peggy_denom = factory/inj1ml33x7lkxk6x2x95d3alw4h84evlcdz2gnehmk/SNOWY decimals = 6 @@ -973,14 +1194,6 @@ decimals = 6 peggy_denom = peggy0x6B3595068778DD592e39A122f4f5a5cF09C90fE2 decimals = 18 -[SteadyBTC] -peggy_denom = peggy0x4986fD36b6b16f49b43282Ee2e24C5cF90ed166d -decimals = 18 - -[SteadyETH] -peggy_denom = peggy0x3F07A84eCdf494310D397d24c1C78B041D2fa622 -decimals = 18 - [TALIS] peggy_denom = factory/inj1maeyvxfamtn8lfyxpjca8kuvauuf2qeu6gtxm3/Talis decimals = 6 @@ -997,12 +1210,12 @@ decimals = 18 peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj1q6zlut7gtkzknkk773jecujwsdkgq882akqksk decimals = 6 -[USDC] -peggy_denom = peggy0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 +[USD Coin (Wormhole from Solana)] +peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12pwnhtv7yat2s30xuf4gdk9qm85v4j3e60dgvu decimals = 6 -[USDCso] -peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj12pwnhtv7yat2s30xuf4gdk9qm85v4j3e60dgvu +[USDC] +peggy_denom = peggy0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 decimals = 6 [USDT] @@ -1049,9 +1262,9 @@ decimals = 6 peggy_denom = peggy0xb2617246d0c6c0087f18703d576831899ca94f01 decimals = 18 -[axlUSDC] -peggy_denom = ibc/7E1AF94AD246BE522892751046F0C959B768642E5671CC3742264068D49553C0 -decimals = 6 +[hINJ] +peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj18luqttqyckgpddndh8hvaq25d5nfwjc78m56lc +decimals = 18 [nINJ] peggy_denom = factory/inj14ejqjyq8um4p3xfqj74yld5waqljf88f9eneuk/inj13xlpypcwl5fuc84uhqzzqumnrcfpptyl6w3vrf @@ -1060,3 +1273,11 @@ decimals = 18 [stINJ] peggy_denom = ibc/AC87717EA002B0123B10A05063E69BCA274BA2C44D842AEEB41558D2856DCE93 decimals = 18 + +[steadyBTC] +peggy_denom = peggy0x4986fD36b6b16f49b43282Ee2e24C5cF90ed166d +decimals = 18 + +[steadyETH] +peggy_denom = peggy0x3F07A84eCdf494310D397d24c1C78B041D2fa622 +decimals = 18 diff --git a/client/metadata/assets/testnet.ini b/client/metadata/assets/testnet.ini index d81212d8..e8b5aa61 100644 --- a/client/metadata/assets/testnet.ini +++ b/client/metadata/assets/testnet.ini @@ -142,6 +142,24 @@ min_display_price_tick_size = 0.001 min_quantity_tick_size = 10000000000000 min_display_quantity_tick_size = 0.00001 +[0x21d4ee074f37f2a310929425e58f69850fca9f734d292bfc5ee48d3c28ea1c09] +description = 'Testnet Spot TEST2/INJ' +base = 6 +quote = 18 +min_price_tick_size = 100000000 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1000 +min_display_quantity_tick_size = 0.001 + +[0xf2ced33ef12a73962be92686503450cc4966feeb9cf6c809f4dc43acad5d7efb] +description = 'Testnet Spot TEST2/USDT' +base = 6 +quote = 6 +min_price_tick_size = 0.0001 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1000 +min_display_quantity_tick_size = 0.001 + [0xf02752c2c87728af7fd10a298a8a645261859eafd0295dcda7e2c5b45c8412cf] description = 'Testnet Spot stINJ/INJ' base = 18 @@ -205,6 +223,60 @@ min_display_price_tick_size = 0.001 min_quantity_tick_size = 100000 min_display_quantity_tick_size = 0.001 +[0xe93f09f7a06d507ff8b66f2969e1af931c9eb9ec3f640a6f87dbcd3456258466] +description = 'Testnet Spot Inj' +base = 18 +quote = 8 +min_price_tick_size = 0.0000000000001 +min_display_price_tick_size = 0.001 +min_quantity_tick_size = 1000000000000000 +min_display_quantity_tick_size = 0.001 + +[0xed865fd44f1bc9d46d978db415ed00444fac4f6aef7e09e2d0235f8d140b219f] +description = 'Testnet Spot MT/INJ' +base = 6 +quote = 18 +min_price_tick_size = 10000 +min_display_price_tick_size = 0.00000001 +min_quantity_tick_size = 1000000000 +min_display_quantity_tick_size = 1000 + +[0x215970bfdea5c94d8e964a759d3ce6eae1d113900129cc8428267db5ccdb3d1a] +description = 'Testnet Spot INJ/USDC' +base = 18 +quote = 6 +min_price_tick_size = 0.000000000000001 +min_display_price_tick_size = 0.001 +min_quantity_tick_size = 10000000000000000 +min_display_quantity_tick_size = 0.01 + +[0xd8e9ea042ac67990134d8e024a251809b1b76c5f7df49f511858e040a285efca] +description = 'Testnet Spot HDRO/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 + +[0x2d7f47811527bd721ce2e4e0ff27b0f3a281f65abcd41758baf157c8ddfcd910] +description = 'Testnet Spot hINJ/INJ' +base = 18 +quote = 18 +min_price_tick_size = 0.0001 +min_display_price_tick_size = 0.0001 +min_quantity_tick_size = 1000000000000000 +min_display_quantity_tick_size = 0.001 + +[0xe4b31c0112c89e0963b2db6884b416c17101a899e0ce6dc9f5dde79e6a01b52b] +description = 'Testnet Spot TEST1/INJ' +base = 6 +quote = 18 +min_price_tick_size = 1000000 +min_display_price_tick_size = 0.000001 +min_quantity_tick_size = 1000000 +min_display_quantity_tick_size = 1 + [0x2e94326a421c3f66c15a3b663c7b1ab7fb6a5298b3a57759ecf07f0036793fc9] description = 'Testnet Derivative BTC/USDT PERP Pyth' base = 0 @@ -393,11 +465,19 @@ decimals = 18 peggy_denom = factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/atom decimals = 8 +[HDRO] +peggy_denom = factory/inj1pk7jhvjj2lufcghmvr7gl49dzwkk3xj0uqkwfk/hdro +decimals = 6 + [INJ] peggy_denom = inj decimals = 18 -[MITOTEST1] +[MT] +peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/mitotest2 +decimals = 6 + +[MitoTest1] peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/mitotest1 decimals = 18 @@ -409,6 +489,14 @@ decimals = 18 peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/projx decimals = 18 +[TEST1] +peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/test1 +decimals = 6 + +[TEST2] +peggy_denom = factory/inj1gvhyp8un5l9jpxpd90rdtj3ejd6qser2s2jxtz/test2 +decimals = 6 + [USD Coin] peggy_denom = factory/inj17vytdwqczqz72j65saukplrktd4gyfme5agf6c/usdc decimals = 6 @@ -437,6 +525,10 @@ decimals = 18 peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/uzen decimals = 18 +[hINJ] +peggy_denom = factory/inj1hdvy6tl89llqy3ze8lv6mz5qh66sx9enn0jxg6/inj1mz7mfhgx8tuvjqut03qdujrkzwlx9xhcj6yldc +decimals = 18 + [stINJ] peggy_denom = factory/inj17gkuet8f6pssxd8nycm3qr9d9y699rupv6397z/stinj decimals = 18 diff --git a/examples/chain/36_StreamEventOrderbookUpdate/example.go b/examples/chain/10_StreamEventOrderbookUpdate/example.go similarity index 100% rename from examples/chain/36_StreamEventOrderbookUpdate/example.go rename to examples/chain/10_StreamEventOrderbookUpdate/example.go diff --git a/examples/chain/37_DecodeTx/37_decode_tx.go b/examples/chain/11_DecodeTx/37_decode_tx.go similarity index 100% rename from examples/chain/37_DecodeTx/37_decode_tx.go rename to examples/chain/11_DecodeTx/37_decode_tx.go diff --git a/examples/chain/40_ChainStream/example.go b/examples/chain/12_ChainStream/example.go similarity index 100% rename from examples/chain/40_ChainStream/example.go rename to examples/chain/12_ChainStream/example.go diff --git a/examples/chain/41_BroadcastMsgWithoutSimulation/example.go b/examples/chain/13_BroadcastMsgWithoutSimulation/example.go similarity index 100% rename from examples/chain/41_BroadcastMsgWithoutSimulation/example.go rename to examples/chain/13_BroadcastMsgWithoutSimulation/example.go diff --git a/examples/chain/0_LocalOrderHash/example.go b/examples/chain/1_LocalOrderHash/example.go similarity index 100% rename from examples/chain/0_LocalOrderHash/example.go rename to examples/chain/1_LocalOrderHash/example.go diff --git a/examples/chain/9_MsgBatchCancelSpotOrders/example.go b/examples/chain/2_MsgBatchCancelSpotOrders/example.go similarity index 100% rename from examples/chain/9_MsgBatchCancelSpotOrders/example.go rename to examples/chain/2_MsgBatchCancelSpotOrders/example.go diff --git a/examples/chain/10_MsgBatchCancelDerivativeOrders/example.go b/examples/chain/3_MsgBatchCancelDerivativeOrders/example.go similarity index 100% rename from examples/chain/10_MsgBatchCancelDerivativeOrders/example.go rename to examples/chain/3_MsgBatchCancelDerivativeOrders/example.go diff --git a/examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go b/examples/chain/4_MsgBatchCreateSpotLimitOrders/example.go similarity index 100% rename from examples/chain/11_MsgBatchCreateSpotLimitOrders/example.go rename to examples/chain/4_MsgBatchCreateSpotLimitOrders/example.go diff --git a/examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go b/examples/chain/5_MsgBatchCreateDerivativeLimitOrders/example.go similarity index 100% rename from examples/chain/12_MsgBatchCreateDerivativeLimitOrders/example.go rename to examples/chain/5_MsgBatchCreateDerivativeLimitOrders/example.go diff --git a/examples/chain/24_MsgRegisterAsDMM/example.go b/examples/chain/6_MsgRegisterAsDMM/example.go similarity index 100% rename from examples/chain/24_MsgRegisterAsDMM/example.go rename to examples/chain/6_MsgRegisterAsDMM/example.go diff --git a/examples/chain/33_GetBlock/example.go b/examples/chain/7_GetBlock/example.go similarity index 100% rename from examples/chain/33_GetBlock/example.go rename to examples/chain/7_GetBlock/example.go diff --git a/examples/chain/34_OfflineSigning/example.go b/examples/chain/8_OfflineSigning/example.go similarity index 100% rename from examples/chain/34_OfflineSigning/example.go rename to examples/chain/8_OfflineSigning/example.go diff --git a/examples/chain/35_StreamEventOrderFail/example.go b/examples/chain/9_StreamEventOrderFail/example.go similarity index 100% rename from examples/chain/35_StreamEventOrderFail/example.go rename to examples/chain/9_StreamEventOrderFail/example.go diff --git a/examples/chain/18_MsgBid/example.go b/examples/chain/auction/1_MsgBid/example.go similarity index 100% rename from examples/chain/18_MsgBid/example.go rename to examples/chain/auction/1_MsgBid/example.go diff --git a/examples/chain/32_Account/example.go b/examples/chain/auth/query/1_Account/example.go similarity index 100% rename from examples/chain/32_Account/example.go rename to examples/chain/auth/query/1_Account/example.go diff --git a/examples/chain/19_MsgGrant/example.go b/examples/chain/authz/1_MsgGrant/example.go similarity index 100% rename from examples/chain/19_MsgGrant/example.go rename to examples/chain/authz/1_MsgGrant/example.go diff --git a/examples/chain/20_MsgExec/example.go b/examples/chain/authz/2_MsgExec/example.go similarity index 100% rename from examples/chain/20_MsgExec/example.go rename to examples/chain/authz/2_MsgExec/example.go diff --git a/examples/chain/21_MsgRevoke/example.go b/examples/chain/authz/3_MsgRevoke/example.go similarity index 100% rename from examples/chain/21_MsgRevoke/example.go rename to examples/chain/authz/3_MsgRevoke/example.go diff --git a/examples/chain/27_QueryAuthzGrants/example.go b/examples/chain/authz/query/1_Grants/example.go similarity index 100% rename from examples/chain/27_QueryAuthzGrants/example.go rename to examples/chain/authz/query/1_Grants/example.go diff --git a/examples/chain/1_MsgSend/example.go b/examples/chain/bank/1_MsgSend/example.go similarity index 100% rename from examples/chain/1_MsgSend/example.go rename to examples/chain/bank/1_MsgSend/example.go diff --git a/examples/chain/31_MsgMultiSend/example.go b/examples/chain/bank/2_MsgMultiSend/example.go similarity index 100% rename from examples/chain/31_MsgMultiSend/example.go rename to examples/chain/bank/2_MsgMultiSend/example.go diff --git a/examples/chain/49_BankSendEnabled/example.go b/examples/chain/bank/query/10_BankSendEnabled/example.go similarity index 100% rename from examples/chain/49_BankSendEnabled/example.go rename to examples/chain/bank/query/10_BankSendEnabled/example.go diff --git a/examples/chain/29_BankBalance/example.go b/examples/chain/bank/query/1_BankBalance/example.go similarity index 100% rename from examples/chain/29_BankBalance/example.go rename to examples/chain/bank/query/1_BankBalance/example.go diff --git a/examples/chain/28_BankBalances/example.go b/examples/chain/bank/query/2_BankBalances/example.go similarity index 100% rename from examples/chain/28_BankBalances/example.go rename to examples/chain/bank/query/2_BankBalances/example.go diff --git a/examples/chain/42_BankSpendableBalances/example.go b/examples/chain/bank/query/3_BankSpendableBalances/example.go similarity index 100% rename from examples/chain/42_BankSpendableBalances/example.go rename to examples/chain/bank/query/3_BankSpendableBalances/example.go diff --git a/examples/chain/43_BankSpendableBalancesByDenom/example.go b/examples/chain/bank/query/4_BankSpendableBalancesByDenom/example.go similarity index 100% rename from examples/chain/43_BankSpendableBalancesByDenom/example.go rename to examples/chain/bank/query/4_BankSpendableBalancesByDenom/example.go diff --git a/examples/chain/44_BankTotalSupply/example.go b/examples/chain/bank/query/5_BankTotalSupply/example.go similarity index 100% rename from examples/chain/44_BankTotalSupply/example.go rename to examples/chain/bank/query/5_BankTotalSupply/example.go diff --git a/examples/chain/45_BankSupplyOf/example.go b/examples/chain/bank/query/6_BankSupplyOf/example.go similarity index 100% rename from examples/chain/45_BankSupplyOf/example.go rename to examples/chain/bank/query/6_BankSupplyOf/example.go diff --git a/examples/chain/46_DenomMetadata/example.go b/examples/chain/bank/query/7_DenomMetadata/example.go similarity index 100% rename from examples/chain/46_DenomMetadata/example.go rename to examples/chain/bank/query/7_DenomMetadata/example.go diff --git a/examples/chain/47_DenomsMetadata/example.go b/examples/chain/bank/query/8_DenomsMetadata/example.go similarity index 100% rename from examples/chain/47_DenomsMetadata/example.go rename to examples/chain/bank/query/8_DenomsMetadata/example.go diff --git a/examples/chain/48_DenomOwners/example.go b/examples/chain/bank/query/9_DenomOwners/example.go similarity index 100% rename from examples/chain/48_DenomOwners/example.go rename to examples/chain/bank/query/9_DenomOwners/example.go diff --git a/examples/chain/distribution/1_SetWithdrawAddress/example.go b/examples/chain/distribution/1_SetWithdrawAddress/example.go new file mode 100644 index 00000000..7e0d371c --- /dev/null +++ b/examples/chain/distribution/1_SetWithdrawAddress/example.go @@ -0,0 +1,75 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/x/distribution/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + withdrawAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" + + msg := &types.MsgSetWithdrawAddress{ + DelegatorAddress: senderAddress.String(), + WithdrawAddress: withdrawAddress, + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/26_MsgWithdrawDelegatorReward/example.go b/examples/chain/distribution/2_MsgWithdrawDelegatorReward/example.go similarity index 100% rename from examples/chain/26_MsgWithdrawDelegatorReward/example.go rename to examples/chain/distribution/2_MsgWithdrawDelegatorReward/example.go diff --git a/examples/chain/distribution/3_WithdrawValidatorCommission/example.go b/examples/chain/distribution/3_WithdrawValidatorCommission/example.go new file mode 100644 index 00000000..85efe852 --- /dev/null +++ b/examples/chain/distribution/3_WithdrawValidatorCommission/example.go @@ -0,0 +1,74 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/x/distribution/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + validatorAddress := "injvaloper1ultw9r29l8nxy5u6thcgusjn95vsy2caw722q5" + + msg := &types.MsgWithdrawValidatorCommission{ + ValidatorAddress: validatorAddress, + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/distribution/4_FundCommunityPool/example.go b/examples/chain/distribution/4_FundCommunityPool/example.go new file mode 100644 index 00000000..9c2c9aeb --- /dev/null +++ b/examples/chain/distribution/4_FundCommunityPool/example.go @@ -0,0 +1,76 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/types" + distriutiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + amount := types.NewCoin("inj", types.NewInt(1)) + + msg := &distriutiontypes.MsgFundCommunityPool{ + Amount: []types.Coin{amount}, + Depositor: senderAddress.String(), + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/distribution/query/1_ValidatorDistributionInfo/example.go b/examples/chain/distribution/query/1_ValidatorDistributionInfo/example.go new file mode 100644 index 00000000..f542c779 --- /dev/null +++ b/examples/chain/distribution/query/1_ValidatorDistributionInfo/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z" + ctx := context.Background() + + res, err := chainClient.FetchValidatorDistributionInfo(ctx, validatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/2_ValidatorOutstandingRewards/example.go b/examples/chain/distribution/query/2_ValidatorOutstandingRewards/example.go new file mode 100644 index 00000000..e172cb07 --- /dev/null +++ b/examples/chain/distribution/query/2_ValidatorOutstandingRewards/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z" + ctx := context.Background() + + res, err := chainClient.FetchValidatorOutstandingRewards(ctx, validatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/3_ValidatorCommission/example.go b/examples/chain/distribution/query/3_ValidatorCommission/example.go new file mode 100644 index 00000000..b12df4bf --- /dev/null +++ b/examples/chain/distribution/query/3_ValidatorCommission/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z" + ctx := context.Background() + + res, err := chainClient.FetchValidatorCommission(ctx, validatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/4_ValidatorSlashes/example.go b/examples/chain/distribution/query/4_ValidatorSlashes/example.go new file mode 100644 index 00000000..19fb4624 --- /dev/null +++ b/examples/chain/distribution/query/4_ValidatorSlashes/example.go @@ -0,0 +1,74 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + validatorAddress := "injvaloper1jue5dpr9lerjn6wlwtrywxrsenrf28ru89z99z" + startingHeight := uint64(0) + endingHeight := uint64(0) + pagination := query.PageRequest{Limit: 10} + ctx := context.Background() + + res, err := chainClient.FetchValidatorSlashes(ctx, validatorAddress, startingHeight, endingHeight, &pagination) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/5_DelegationRewards/example.go b/examples/chain/distribution/query/5_DelegationRewards/example.go new file mode 100644 index 00000000..0d8780f2 --- /dev/null +++ b/examples/chain/distribution/query/5_DelegationRewards/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + delegatorAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" + validatorAddress := "injvaloper156t3yxd4udv0h9gwagfcmwnmm3quy0nph7tyh5" + ctx := context.Background() + + res, err := chainClient.FetchDelegationRewards(ctx, delegatorAddress, validatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/6_DelegationTotalRewards/example.go b/examples/chain/distribution/query/6_DelegationTotalRewards/example.go new file mode 100644 index 00000000..5c71a72d --- /dev/null +++ b/examples/chain/distribution/query/6_DelegationTotalRewards/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + delegatorAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" + ctx := context.Background() + + res, err := chainClient.FetchDelegationTotalRewards(ctx, delegatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/7_DelegatorValidators/example.go b/examples/chain/distribution/query/7_DelegatorValidators/example.go new file mode 100644 index 00000000..6a9e0a29 --- /dev/null +++ b/examples/chain/distribution/query/7_DelegatorValidators/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + delegatorAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" + ctx := context.Background() + + res, err := chainClient.FetchDelegatorValidators(ctx, delegatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/8_DelegatorWithdrawAddress/example.go b/examples/chain/distribution/query/8_DelegatorWithdrawAddress/example.go new file mode 100644 index 00000000..6f850e40 --- /dev/null +++ b/examples/chain/distribution/query/8_DelegatorWithdrawAddress/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + delegatorAddress := "inj1hkhdaj2a2clmq5jq6mspsggqs32vynpk228q3r" + ctx := context.Background() + + res, err := chainClient.FetchDelegatorWithdrawAddress(ctx, delegatorAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/distribution/query/9_CommunityPool/example.go b/examples/chain/distribution/query/9_CommunityPool/example.go new file mode 100644 index 00000000..4adb0ee3 --- /dev/null +++ b/examples/chain/distribution/query/9_CommunityPool/example.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchCommunityPool(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/6_MsgCreateDerivativeLimitOrder/example.go b/examples/chain/exchange/10_MsgCreateDerivativeLimitOrder/example.go similarity index 100% rename from examples/chain/6_MsgCreateDerivativeLimitOrder/example.go rename to examples/chain/exchange/10_MsgCreateDerivativeLimitOrder/example.go diff --git a/examples/chain/7_MsgCreateDerivativeMarketOrder/example.go b/examples/chain/exchange/11_MsgCreateDerivativeMarketOrder/example.go similarity index 100% rename from examples/chain/7_MsgCreateDerivativeMarketOrder/example.go rename to examples/chain/exchange/11_MsgCreateDerivativeMarketOrder/example.go diff --git a/examples/chain/8_MsgCancelDerivativeOrder/example.go b/examples/chain/exchange/12_MsgCancelDerivativeOrder/example.go similarity index 100% rename from examples/chain/8_MsgCancelDerivativeOrder/example.go rename to examples/chain/exchange/12_MsgCancelDerivativeOrder/example.go diff --git a/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go b/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go new file mode 100644 index 00000000..be7b7ddc --- /dev/null +++ b/examples/chain/exchange/13_MsgInstantBinaryOptionsMarketLaunch/example.go @@ -0,0 +1,107 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" + oracletypes "github.com/InjectiveLabs/sdk-go/chain/oracle/types" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + + "github.com/cosmos/cosmos-sdk/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + if err != nil { + panic(err) + } + + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + panic(err) + } + + ctx := context.Background() + marketsAssistant, err := chainclient.NewMarketsAssistantInitializedFromChain(ctx, exchangeClient) + if err != nil { + panic(err) + } + + quoteToken := marketsAssistant.AllTokens()["USDC"] + minPriceTickSize := types.MustNewDecFromStr("0.01") + minQuantityTickSize := types.MustNewDecFromStr("0.001") + + chainMinPriceTickSize := minPriceTickSize.Mul(types.NewDecFromIntWithPrec(types.NewInt(1), int64(quoteToken.Decimals))) + chainMinQuantityTickSize := minQuantityTickSize + + msg := &exchangetypes.MsgInstantBinaryOptionsMarketLaunch{ + Sender: senderAddress.String(), + Ticker: "UFC-KHABIB-TKO-05/30/2023", + OracleSymbol: "UFC-KHABIB-TKO-05/30/2023", + OracleProvider: "UFC", + OracleType: oracletypes.OracleType_Provider, + OracleScaleFactor: 6, + MakerFeeRate: types.MustNewDecFromStr("0.0005"), + TakerFeeRate: types.MustNewDecFromStr("0.0010"), + ExpirationTimestamp: 1680730982, + SettlementTimestamp: 1690730982, + Admin: senderAddress.String(), + QuoteDenom: quoteToken.Denom, + MinPriceTickSize: chainMinPriceTickSize, + MinQuantityTickSize: chainMinQuantityTickSize, + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/16_MsgSubaccountTransfer/example.go b/examples/chain/exchange/14_MsgSubaccountTransfer/example.go similarity index 100% rename from examples/chain/16_MsgSubaccountTransfer/example.go rename to examples/chain/exchange/14_MsgSubaccountTransfer/example.go diff --git a/examples/chain/30_MsgExternalTransfer/example.go b/examples/chain/exchange/15_MsgExternalTransfer/example.go similarity index 100% rename from examples/chain/30_MsgExternalTransfer/example.go rename to examples/chain/exchange/15_MsgExternalTransfer/example.go diff --git a/examples/chain/70_MsgLiquidatePosition/example.go b/examples/chain/exchange/16_MsgLiquidatePosition/example.go similarity index 100% rename from examples/chain/70_MsgLiquidatePosition/example.go rename to examples/chain/exchange/16_MsgLiquidatePosition/example.go diff --git a/examples/chain/13_MsgIncreasePositionMargin/example.go b/examples/chain/exchange/17_MsgIncreasePositionMargin/example.go similarity index 100% rename from examples/chain/13_MsgIncreasePositionMargin/example.go rename to examples/chain/exchange/17_MsgIncreasePositionMargin/example.go diff --git a/examples/chain/2_MsgDeposit/example.go b/examples/chain/exchange/1_MsgDeposit/example.go similarity index 100% rename from examples/chain/2_MsgDeposit/example.go rename to examples/chain/exchange/1_MsgDeposit/example.go diff --git a/examples/chain/38_MsgLiquidate/example.go b/examples/chain/exchange/21_MsgRewardsOptOut/example.go similarity index 58% rename from examples/chain/38_MsgLiquidate/example.go rename to examples/chain/exchange/21_MsgRewardsOptOut/example.go index c43327b7..ca877e9e 100644 --- a/examples/chain/38_MsgLiquidate/example.go +++ b/examples/chain/exchange/21_MsgRewardsOptOut/example.go @@ -8,20 +8,16 @@ import ( "github.com/InjectiveLabs/sdk-go/client" "github.com/InjectiveLabs/sdk-go/client/common" - rpchttp "github.com/cometbft/cometbft/rpc/client/http" - exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" ) func main() { - // network := common.LoadNetwork("mainnet", "k8s") - network := common.LoadNetwork("devnet-1", "") - tmRPC, err := rpchttp.New(network.TmEndpoint, "/websocket") - + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") if err != nil { - fmt.Println(err) - return + panic(err) } senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( @@ -45,11 +41,10 @@ func main() { ) if err != nil { - fmt.Println(err) - return + panic(err) } - clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmRPC) + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) chainClient, err := chainclient.NewChainClient( clientCtx, @@ -61,38 +56,15 @@ func main() { panic(err) } - defaultSubaccountID := chainClient.DefaultSubaccount(senderAddress) - - marketId := "0x56d0c0293c4415e2d48fc2c8503a56a0c7389247396a2ef9b0a48c01f0646705" - - liqMsg := exchangetypes.MsgLiquidatePosition{ - Sender: senderAddress.String(), - SubaccountId: defaultSubaccountID.String(), - MarketId: marketId, - Order: nil, - } - - simRes, err := chainClient.SimulateMsg(clientCtx, &liqMsg) - - if err != nil { - fmt.Println(err) - return - } - - msgLiquidatePositionResponse := exchangetypes.MsgLiquidatePositionResponse{} - msgLiquidatePositionResponse.Unmarshal(simRes.Result.MsgResponses[0].Value) - - if err != nil { - fmt.Println(err) - return + msg := &exchangetypes.MsgRewardsOptOut{ + Sender: senderAddress.String(), } //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg - err = chainClient.QueueBroadcastMsg(&liqMsg) + err = chainClient.QueueBroadcastMsg(msg) if err != nil { fmt.Println(err) - return } time.Sleep(time.Second * 5) diff --git a/examples/chain/15_MsgWithdraw/example.go b/examples/chain/exchange/2_MsgWithdraw/example.go similarity index 100% rename from examples/chain/15_MsgWithdraw/example.go rename to examples/chain/exchange/2_MsgWithdraw/example.go diff --git a/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go b/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go new file mode 100644 index 00000000..2bd6e62a --- /dev/null +++ b/examples/chain/exchange/3_MsgInstantSpotMarketLaunch/example.go @@ -0,0 +1,101 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + + "github.com/cosmos/cosmos-sdk/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + if err != nil { + panic(err) + } + + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + panic(err) + } + + ctx := context.Background() + marketsAssistant, err := chainclient.NewMarketsAssistantInitializedFromChain(ctx, exchangeClient) + if err != nil { + panic(err) + } + + baseToken := marketsAssistant.AllTokens()["INJ"] + quoteToken := marketsAssistant.AllTokens()["USDC"] + minPriceTickSize := types.MustNewDecFromStr("0.01") + minQuantityTickSize := types.MustNewDecFromStr("0.001") + + chainMinPriceTickSize := minPriceTickSize.Mul(types.NewDecFromIntWithPrec(types.NewInt(1), int64(quoteToken.Decimals))) + chainMinPriceTickSize = chainMinPriceTickSize.Quo(types.NewDecFromIntWithPrec(types.NewInt(1), int64(baseToken.Decimals))) + + chainMinQuantityTickSize := minQuantityTickSize.Mul(types.NewDecFromIntWithPrec(types.NewInt(1), int64(baseToken.Decimals))) + + msg := &exchangetypes.MsgInstantSpotMarketLaunch{ + Sender: senderAddress.String(), + Ticker: "INJ/USDC", + BaseDenom: baseToken.Denom, + QuoteDenom: quoteToken.Denom, + MinPriceTickSize: chainMinPriceTickSize, + MinQuantityTickSize: chainMinQuantityTickSize, + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go b/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go new file mode 100644 index 00000000..0792a6d2 --- /dev/null +++ b/examples/chain/exchange/4_MsgInstantPerpetualMarketLaunch/example.go @@ -0,0 +1,106 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" + oracletypes "github.com/InjectiveLabs/sdk-go/chain/oracle/types" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + + "github.com/cosmos/cosmos-sdk/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + if err != nil { + panic(err) + } + + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + panic(err) + } + + ctx := context.Background() + marketsAssistant, err := chainclient.NewMarketsAssistantInitializedFromChain(ctx, exchangeClient) + if err != nil { + panic(err) + } + + quoteToken := marketsAssistant.AllTokens()["USDC"] + minPriceTickSize := types.MustNewDecFromStr("0.01") + minQuantityTickSize := types.MustNewDecFromStr("0.001") + + chainMinPriceTickSize := minPriceTickSize.Mul(types.NewDecFromIntWithPrec(types.NewInt(1), int64(quoteToken.Decimals))) + chainMinQuantityTickSize := minQuantityTickSize + + msg := &exchangetypes.MsgInstantPerpetualMarketLaunch{ + Sender: senderAddress.String(), + Ticker: "INJ/USDC PERP", + QuoteDenom: quoteToken.Denom, + OracleBase: "INJ", + OracleQuote: "USDC", + OracleScaleFactor: 6, + OracleType: oracletypes.OracleType_Band, + MakerFeeRate: types.MustNewDecFromStr("-0.0001"), + TakerFeeRate: types.MustNewDecFromStr("0.001"), + InitialMarginRatio: types.MustNewDecFromStr("0.33"), + MaintenanceMarginRatio: types.MustNewDecFromStr("0.095"), + MinPriceTickSize: chainMinPriceTickSize, + MinQuantityTickSize: chainMinQuantityTickSize, + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go b/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go new file mode 100644 index 00000000..dac6f76f --- /dev/null +++ b/examples/chain/exchange/5_MsgInstantExpiryFuturesMarketLaunch/example.go @@ -0,0 +1,107 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" + oracletypes "github.com/InjectiveLabs/sdk-go/chain/oracle/types" + exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" + + "github.com/cosmos/cosmos-sdk/types" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + if err != nil { + panic(err) + } + + exchangeClient, err := exchangeclient.NewExchangeClient(network) + if err != nil { + panic(err) + } + + ctx := context.Background() + marketsAssistant, err := chainclient.NewMarketsAssistantInitializedFromChain(ctx, exchangeClient) + if err != nil { + panic(err) + } + + quoteToken := marketsAssistant.AllTokens()["USDC"] + minPriceTickSize := types.MustNewDecFromStr("0.01") + minQuantityTickSize := types.MustNewDecFromStr("0.001") + + chainMinPriceTickSize := minPriceTickSize.Mul(types.NewDecFromIntWithPrec(types.NewInt(1), int64(quoteToken.Decimals))) + chainMinQuantityTickSize := minQuantityTickSize + + msg := &exchangetypes.MsgInstantExpiryFuturesMarketLaunch{ + Sender: senderAddress.String(), + Ticker: "INJ/USDC FUT", + QuoteDenom: quoteToken.Denom, + OracleBase: "INJ", + OracleQuote: "USDC", + OracleScaleFactor: 6, + OracleType: oracletypes.OracleType_Band, + Expiry: 2000000000, + MakerFeeRate: types.MustNewDecFromStr("-0.0001"), + TakerFeeRate: types.MustNewDecFromStr("0.001"), + InitialMarginRatio: types.MustNewDecFromStr("0.33"), + MaintenanceMarginRatio: types.MustNewDecFromStr("0.095"), + MinPriceTickSize: chainMinPriceTickSize, + MinQuantityTickSize: chainMinQuantityTickSize, + } + + //AsyncBroadcastMsg, SyncBroadcastMsg, QueueBroadcastMsg + response, err := chainClient.AsyncBroadcastMsg(msg) + + if err != nil { + panic(err) + } + + str, _ := json.MarshalIndent(response, "", " ") + fmt.Print(string(str)) +} diff --git a/examples/chain/3_MsgCreateSpotLimitOrder/example.go b/examples/chain/exchange/6_MsgCreateSpotLimitOrder/example.go similarity index 100% rename from examples/chain/3_MsgCreateSpotLimitOrder/example.go rename to examples/chain/exchange/6_MsgCreateSpotLimitOrder/example.go diff --git a/examples/chain/4_MsgCreateSpotMarketOrder/example.go b/examples/chain/exchange/7_MsgCreateSpotMarketOrder/example.go similarity index 100% rename from examples/chain/4_MsgCreateSpotMarketOrder/example.go rename to examples/chain/exchange/7_MsgCreateSpotMarketOrder/example.go diff --git a/examples/chain/5_MsgCancelSpotOrder/example.go b/examples/chain/exchange/8_MsgCancelSpotOrder/example.go similarity index 100% rename from examples/chain/5_MsgCancelSpotOrder/example.go rename to examples/chain/exchange/8_MsgCancelSpotOrder/example.go diff --git a/examples/chain/17_MsgBatchUpdateOrders/example.go b/examples/chain/exchange/9_MsgBatchUpdateOrders/example.go similarity index 100% rename from examples/chain/17_MsgBatchUpdateOrders/example.go rename to examples/chain/exchange/9_MsgBatchUpdateOrders/example.go diff --git a/examples/chain/exchange/query/10_SpotMarkets/example.go b/examples/chain/exchange/query/10_SpotMarkets/example.go new file mode 100644 index 00000000..9bb071e4 --- /dev/null +++ b/examples/chain/exchange/query/10_SpotMarkets/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + status := "Active" + marketIds := []string{"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"} + + res, err := chainClient.FetchChainSpotMarkets(ctx, status, marketIds) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/11_SpotMarket/example.go b/examples/chain/exchange/query/11_SpotMarket/example.go new file mode 100644 index 00000000..0251543b --- /dev/null +++ b/examples/chain/exchange/query/11_SpotMarket/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + + res, err := chainClient.FetchChainSpotMarket(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/12_FullSpotMarkets/example.go b/examples/chain/exchange/query/12_FullSpotMarkets/example.go new file mode 100644 index 00000000..c560b9c3 --- /dev/null +++ b/examples/chain/exchange/query/12_FullSpotMarkets/example.go @@ -0,0 +1,73 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + status := "Active" + marketIds := []string{"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"} + withMidPriceAndTob := true + + res, err := chainClient.FetchChainFullSpotMarkets(ctx, status, marketIds, withMidPriceAndTob) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/13_FullSpotMarket/example.go b/examples/chain/exchange/query/13_FullSpotMarket/example.go new file mode 100644 index 00000000..54700709 --- /dev/null +++ b/examples/chain/exchange/query/13_FullSpotMarket/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + withMidPriceAndTob := true + + res, err := chainClient.FetchChainFullSpotMarket(ctx, marketId, withMidPriceAndTob) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/14_SpotOrderbook/example.go b/examples/chain/exchange/query/14_SpotOrderbook/example.go new file mode 100644 index 00000000..8c127a4b --- /dev/null +++ b/examples/chain/exchange/query/14_SpotOrderbook/example.go @@ -0,0 +1,78 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/InjectiveLabs/sdk-go/chain/exchange/types" + cosmostypes "github.com/cosmos/cosmos-sdk/types" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + limit := uint64(2) + orderSide := types.OrderSide_Buy + limitCumulativeNotional := cosmostypes.Dec{} + limitCumulativeQuantity := cosmostypes.Dec{} + + res, err := chainClient.FetchChainSpotOrderbook(ctx, marketId, limit, orderSide, limitCumulativeNotional, limitCumulativeQuantity) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/15_TraderSpotOrders/example.go b/examples/chain/exchange/query/15_TraderSpotOrders/example.go new file mode 100644 index 00000000..5452b06c --- /dev/null +++ b/examples/chain/exchange/query/15_TraderSpotOrders/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchChainTraderSpotOrders(ctx, marketId, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/16_AccountAddressSpotOrders/example.go b/examples/chain/exchange/query/16_AccountAddressSpotOrders/example.go new file mode 100644 index 00000000..9c5f4c05 --- /dev/null +++ b/examples/chain/exchange/query/16_AccountAddressSpotOrders/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + + res, err := chainClient.FetchChainAccountAddressSpotOrders(ctx, marketId, senderAddress.String()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/17_SpotOrdersByHashes/example.go b/examples/chain/exchange/query/17_SpotOrdersByHashes/example.go new file mode 100644 index 00000000..93dea96c --- /dev/null +++ b/examples/chain/exchange/query/17_SpotOrdersByHashes/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + subaccountId := chainClient.Subaccount(senderAddress, 0) + orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"} + + res, err := chainClient.FetchChainSpotOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/18_SubaccountOrders/example.go b/examples/chain/exchange/query/18_SubaccountOrders/example.go new file mode 100644 index 00000000..f2ccb128 --- /dev/null +++ b/examples/chain/exchange/query/18_SubaccountOrders/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchChainSubaccountOrders(ctx, subaccountId.Hex(), marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/19_TraderSpotTransientOrders/example.go b/examples/chain/exchange/query/19_TraderSpotTransientOrders/example.go new file mode 100644 index 00000000..4df67cad --- /dev/null +++ b/examples/chain/exchange/query/19_TraderSpotTransientOrders/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchChainTraderSpotTransientOrders(ctx, marketId, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/1_SubaccountDeposits/example.go b/examples/chain/exchange/query/1_SubaccountDeposits/example.go new file mode 100644 index 00000000..526edc5a --- /dev/null +++ b/examples/chain/exchange/query/1_SubaccountDeposits/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + subaccountId := chainClient.Subaccount(senderAddress, 0) + ctx := context.Background() + + res, err := chainClient.FetchSubaccountDeposits(ctx, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/20_SpotMidPriceAndTOB/example.go b/examples/chain/exchange/query/20_SpotMidPriceAndTOB/example.go new file mode 100644 index 00000000..789ceec1 --- /dev/null +++ b/examples/chain/exchange/query/20_SpotMidPriceAndTOB/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + + res, err := chainClient.FetchSpotMidPriceAndTOB(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/21_DerivativeMidPriceAndTOB/example.go b/examples/chain/exchange/query/21_DerivativeMidPriceAndTOB/example.go new file mode 100644 index 00000000..1de6d908 --- /dev/null +++ b/examples/chain/exchange/query/21_DerivativeMidPriceAndTOB/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchDerivativeMidPriceAndTOB(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/22_DerivativeOrderbook/example.go b/examples/chain/exchange/query/22_DerivativeOrderbook/example.go new file mode 100644 index 00000000..9ab20712 --- /dev/null +++ b/examples/chain/exchange/query/22_DerivativeOrderbook/example.go @@ -0,0 +1,75 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + cosmostypes "github.com/cosmos/cosmos-sdk/types" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + limit := uint64(2) + limitCumulativeNotional := cosmostypes.Dec{} + + res, err := chainClient.FetchChainDerivativeOrderbook(ctx, marketId, limit, limitCumulativeNotional) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/23_TraderDerivativeOrders/example.go b/examples/chain/exchange/query/23_TraderDerivativeOrders/example.go new file mode 100644 index 00000000..307df66c --- /dev/null +++ b/examples/chain/exchange/query/23_TraderDerivativeOrders/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchChainTraderDerivativeOrders(ctx, marketId, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/24_AccountAddressDerivativeOrders/example.go b/examples/chain/exchange/query/24_AccountAddressDerivativeOrders/example.go new file mode 100644 index 00000000..c08c7959 --- /dev/null +++ b/examples/chain/exchange/query/24_AccountAddressDerivativeOrders/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainAccountAddressDerivativeOrders(ctx, marketId, senderAddress.String()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/25_DerivativeOrdersByHashes/example.go b/examples/chain/exchange/query/25_DerivativeOrdersByHashes/example.go new file mode 100644 index 00000000..bb8ba8db --- /dev/null +++ b/examples/chain/exchange/query/25_DerivativeOrdersByHashes/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + subaccountId := chainClient.Subaccount(senderAddress, 0) + orderHashes := []string{"0x57a01cd26f1e2080860af3264e865d7c9c034a701e30946d01c1dc7a303cf2c1"} + + res, err := chainClient.FetchChainDerivativeOrdersByHashes(ctx, marketId, subaccountId.Hex(), orderHashes) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/26_TraderDerivativeTransientOrders/example.go b/examples/chain/exchange/query/26_TraderDerivativeTransientOrders/example.go new file mode 100644 index 00000000..6d4b7b22 --- /dev/null +++ b/examples/chain/exchange/query/26_TraderDerivativeTransientOrders/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchChainTraderDerivativeTransientOrders(ctx, marketId, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/27_DerivativeMarkets/example.go b/examples/chain/exchange/query/27_DerivativeMarkets/example.go new file mode 100644 index 00000000..ad4ecb6f --- /dev/null +++ b/examples/chain/exchange/query/27_DerivativeMarkets/example.go @@ -0,0 +1,73 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + status := "Active" + marketIds := []string{"0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"} + withMidPriceAndTob := true + + res, err := chainClient.FetchChainDerivativeMarkets(ctx, status, marketIds, withMidPriceAndTob) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/28_DerivativeMarket/example.go b/examples/chain/exchange/query/28_DerivativeMarket/example.go new file mode 100644 index 00000000..881ba344 --- /dev/null +++ b/examples/chain/exchange/query/28_DerivativeMarket/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainDerivativeMarket(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/29_DerivativeMarketAddress/example.go b/examples/chain/exchange/query/29_DerivativeMarketAddress/example.go new file mode 100644 index 00000000..534aa4a9 --- /dev/null +++ b/examples/chain/exchange/query/29_DerivativeMarketAddress/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchDerivativeMarketAddress(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/2_SubaccountDeposit/example.go b/examples/chain/exchange/query/2_SubaccountDeposit/example.go new file mode 100644 index 00000000..02346c0e --- /dev/null +++ b/examples/chain/exchange/query/2_SubaccountDeposit/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + subaccountId := chainClient.Subaccount(senderAddress, 0) + denom := "inj" + ctx := context.Background() + + res, err := chainClient.FetchSubaccountDeposit(ctx, subaccountId.Hex(), denom) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/30_SubaccountTradeNonce/example.go b/examples/chain/exchange/query/30_SubaccountTradeNonce/example.go new file mode 100644 index 00000000..cf0ef07c --- /dev/null +++ b/examples/chain/exchange/query/30_SubaccountTradeNonce/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchSubaccountTradeNonce(ctx, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/31_Positions/example.go b/examples/chain/exchange/query/31_Positions/example.go new file mode 100644 index 00000000..5e19feca --- /dev/null +++ b/examples/chain/exchange/query/31_Positions/example.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchChainPositions(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/32_SubaccountPositions/example.go b/examples/chain/exchange/query/32_SubaccountPositions/example.go new file mode 100644 index 00000000..0d0b423e --- /dev/null +++ b/examples/chain/exchange/query/32_SubaccountPositions/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchChainSubaccountPositions(ctx, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/33_SubaccountPositionInMarket/example.go b/examples/chain/exchange/query/33_SubaccountPositionInMarket/example.go new file mode 100644 index 00000000..5fbb4f09 --- /dev/null +++ b/examples/chain/exchange/query/33_SubaccountPositionInMarket/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + subaccountId := chainClient.Subaccount(senderAddress, 0) + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainSubaccountPositionInMarket(ctx, subaccountId.Hex(), marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/34_SubaccountEffectivePositionInMarket/example.go b/examples/chain/exchange/query/34_SubaccountEffectivePositionInMarket/example.go new file mode 100644 index 00000000..1bdb9f31 --- /dev/null +++ b/examples/chain/exchange/query/34_SubaccountEffectivePositionInMarket/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + subaccountId := chainClient.Subaccount(senderAddress, 0) + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainSubaccountEffectivePositionInMarket(ctx, subaccountId.Hex(), marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/35_PerpetualMarketInfo/example.go b/examples/chain/exchange/query/35_PerpetualMarketInfo/example.go new file mode 100644 index 00000000..eb95664c --- /dev/null +++ b/examples/chain/exchange/query/35_PerpetualMarketInfo/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainPerpetualMarketInfo(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/36_ExpiryFuturesMarketInfo/example.go b/examples/chain/exchange/query/36_ExpiryFuturesMarketInfo/example.go new file mode 100644 index 00000000..59749df0 --- /dev/null +++ b/examples/chain/exchange/query/36_ExpiryFuturesMarketInfo/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainExpiryFuturesMarketInfo(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/37_PerpetualMarketFunding/example.go b/examples/chain/exchange/query/37_PerpetualMarketFunding/example.go new file mode 100644 index 00000000..11ed5cae --- /dev/null +++ b/examples/chain/exchange/query/37_PerpetualMarketFunding/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchChainPerpetualMarketFunding(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/38_SubaccountOrderMetadata/example.go b/examples/chain/exchange/query/38_SubaccountOrderMetadata/example.go new file mode 100644 index 00000000..b9d08a15 --- /dev/null +++ b/examples/chain/exchange/query/38_SubaccountOrderMetadata/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchSubaccountOrderMetadata(ctx, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/39_TradeRewardPoints/example.go b/examples/chain/exchange/query/39_TradeRewardPoints/example.go new file mode 100644 index 00000000..c6586fe8 --- /dev/null +++ b/examples/chain/exchange/query/39_TradeRewardPoints/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + accounts := []string{senderAddress.String()} + + res, err := chainClient.FetchTradeRewardPoints(ctx, accounts) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/3_ExchangeBalances/example.go b/examples/chain/exchange/query/3_ExchangeBalances/example.go new file mode 100644 index 00000000..d8cf9d47 --- /dev/null +++ b/examples/chain/exchange/query/3_ExchangeBalances/example.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchExchangeBalances(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/40_PendingTradeRewardPoints/example.go b/examples/chain/exchange/query/40_PendingTradeRewardPoints/example.go new file mode 100644 index 00000000..f5bd8f7b --- /dev/null +++ b/examples/chain/exchange/query/40_PendingTradeRewardPoints/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + accounts := []string{senderAddress.String()} + + res, err := chainClient.FetchPendingTradeRewardPoints(ctx, accounts) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/41_TradeRewardCampaign/example.go b/examples/chain/exchange/query/41_TradeRewardCampaign/example.go new file mode 100644 index 00000000..908a3813 --- /dev/null +++ b/examples/chain/exchange/query/41_TradeRewardCampaign/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchTradeRewardCampaign(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/42_FeeDiscountAccountInfo/example.go b/examples/chain/exchange/query/42_FeeDiscountAccountInfo/example.go new file mode 100644 index 00000000..018d8393 --- /dev/null +++ b/examples/chain/exchange/query/42_FeeDiscountAccountInfo/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchFeeDiscountAccountInfo(ctx, senderAddress.String()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/43_FeeDiscountSchedule/example.go b/examples/chain/exchange/query/43_FeeDiscountSchedule/example.go new file mode 100644 index 00000000..122f239c --- /dev/null +++ b/examples/chain/exchange/query/43_FeeDiscountSchedule/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchFeeDiscountSchedule(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/44_BalanceMismatches/example.go b/examples/chain/exchange/query/44_BalanceMismatches/example.go new file mode 100644 index 00000000..f4db8308 --- /dev/null +++ b/examples/chain/exchange/query/44_BalanceMismatches/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchBalanceMismatches(ctx, 1) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/45_BalanceWithBalanceHolds/example.go b/examples/chain/exchange/query/45_BalanceWithBalanceHolds/example.go new file mode 100644 index 00000000..b3677024 --- /dev/null +++ b/examples/chain/exchange/query/45_BalanceWithBalanceHolds/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchBalanceWithBalanceHolds(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/46_FeeDiscountTierStatistics/example.go b/examples/chain/exchange/query/46_FeeDiscountTierStatistics/example.go new file mode 100644 index 00000000..2fdaf947 --- /dev/null +++ b/examples/chain/exchange/query/46_FeeDiscountTierStatistics/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchFeeDiscountTierStatistics(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/47_MitoVaultInfos/example.go b/examples/chain/exchange/query/47_MitoVaultInfos/example.go new file mode 100644 index 00000000..e6b52166 --- /dev/null +++ b/examples/chain/exchange/query/47_MitoVaultInfos/example.go @@ -0,0 +1,68 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchMitoVaultInfos(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/48_QueryMarketIDFromVault/example.go b/examples/chain/exchange/query/48_QueryMarketIDFromVault/example.go new file mode 100644 index 00000000..5e269e30 --- /dev/null +++ b/examples/chain/exchange/query/48_QueryMarketIDFromVault/example.go @@ -0,0 +1,70 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + vaultAddress := "inj1qg5ega6dykkxc307y25pecuufrjkxkag6xhp6y" + + res, err := chainClient.FetchMarketIDFromVault(ctx, vaultAddress) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/49_HistoricalTradeRecords/example.go b/examples/chain/exchange/query/49_HistoricalTradeRecords/example.go new file mode 100644 index 00000000..0d52d73a --- /dev/null +++ b/examples/chain/exchange/query/49_HistoricalTradeRecords/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + + res, err := chainClient.FetchHistoricalTradeRecords(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/4_AggregateVolume/example.go b/examples/chain/exchange/query/4_AggregateVolume/example.go new file mode 100644 index 00000000..84a66eba --- /dev/null +++ b/examples/chain/exchange/query/4_AggregateVolume/example.go @@ -0,0 +1,79 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchAggregateVolume(ctx, senderAddress.String()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + + res, err = chainClient.FetchAggregateVolume(ctx, subaccountId.Hex()) + if err != nil { + fmt.Println(err) + } + + str, _ = json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/50_IsOptedOutOfRewards/example.go b/examples/chain/exchange/query/50_IsOptedOutOfRewards/example.go new file mode 100644 index 00000000..89d915e2 --- /dev/null +++ b/examples/chain/exchange/query/50_IsOptedOutOfRewards/example.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchIsOptedOutOfRewards(ctx, senderAddress.String()) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/51_OptedOutOfRewardsAccounts/example.go b/examples/chain/exchange/query/51_OptedOutOfRewardsAccounts/example.go new file mode 100644 index 00000000..7809c836 --- /dev/null +++ b/examples/chain/exchange/query/51_OptedOutOfRewardsAccounts/example.go @@ -0,0 +1,69 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + res, err := chainClient.FetchOptedOutOfRewardsAccounts(ctx) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/52_MarketVolatility/example.go b/examples/chain/exchange/query/52_MarketVolatility/example.go new file mode 100644 index 00000000..5dc6b988 --- /dev/null +++ b/examples/chain/exchange/query/52_MarketVolatility/example.go @@ -0,0 +1,79 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/InjectiveLabs/sdk-go/chain/exchange/types" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + tradeHistoryOptions := types.TradeHistoryOptions{ + TradeGroupingSec: 10, + MaxAge: 0, + IncludeRawHistory: true, + IncludeMetadata: true, + } + + res, err := chainClient.FetchMarketVolatility(ctx, marketId, &tradeHistoryOptions) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/53_BinaryOptionsMarkets/example.go b/examples/chain/exchange/query/53_BinaryOptionsMarkets/example.go new file mode 100644 index 00000000..ba0ae6fe --- /dev/null +++ b/examples/chain/exchange/query/53_BinaryOptionsMarkets/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + status := "Active" + + res, err := chainClient.FetchChainBinaryOptionsMarkets(ctx, status) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/54_TraderDerivativeConditionalOrders/example.go b/examples/chain/exchange/query/54_TraderDerivativeConditionalOrders/example.go new file mode 100644 index 00000000..a26fb380 --- /dev/null +++ b/examples/chain/exchange/query/54_TraderDerivativeConditionalOrders/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + subaccountId := chainClient.Subaccount(senderAddress, 0) + + res, err := chainClient.FetchTraderDerivativeConditionalOrders(ctx, subaccountId.Hex(), marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/55_MarketAtomicExecutionFeeMultiplier/example.go b/examples/chain/exchange/query/55_MarketAtomicExecutionFeeMultiplier/example.go new file mode 100644 index 00000000..493f05ea --- /dev/null +++ b/examples/chain/exchange/query/55_MarketAtomicExecutionFeeMultiplier/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" + + res, err := chainClient.FetchMarketAtomicExecutionFeeMultiplier(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/5_AggregateVolumes/example.go b/examples/chain/exchange/query/5_AggregateVolumes/example.go new file mode 100644 index 00000000..0bae825c --- /dev/null +++ b/examples/chain/exchange/query/5_AggregateVolumes/example.go @@ -0,0 +1,72 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + accounts := []string{senderAddress.String()} + marketIds := []string{"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"} + + res, err := chainClient.FetchAggregateVolumes(ctx, accounts, marketIds) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/6_AggregateMarketVolume/example.go b/examples/chain/exchange/query/6_AggregateMarketVolume/example.go new file mode 100644 index 00000000..1bf1ebbc --- /dev/null +++ b/examples/chain/exchange/query/6_AggregateMarketVolume/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" + + res, err := chainClient.FetchAggregateMarketVolume(ctx, marketId) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/7_AggregateMarketVolumes/example.go b/examples/chain/exchange/query/7_AggregateMarketVolumes/example.go new file mode 100644 index 00000000..bb8c8ea5 --- /dev/null +++ b/examples/chain/exchange/query/7_AggregateMarketVolumes/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + marketIds := []string{"0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe"} + + res, err := chainClient.FetchAggregateMarketVolumes(ctx, marketIds) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/8_DenomDecimal/example.go b/examples/chain/exchange/query/8_DenomDecimal/example.go new file mode 100644 index 00000000..97663656 --- /dev/null +++ b/examples/chain/exchange/query/8_DenomDecimal/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + denom := "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5" + + res, err := chainClient.FetchDenomDecimal(ctx, denom) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/exchange/query/9_DenomDecimals/example.go b/examples/chain/exchange/query/9_DenomDecimals/example.go new file mode 100644 index 00000000..f4e9866c --- /dev/null +++ b/examples/chain/exchange/query/9_DenomDecimals/example.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "encoding/json" + "fmt" + + "os" + + "github.com/InjectiveLabs/sdk-go/client" + chainclient "github.com/InjectiveLabs/sdk-go/client/chain" + "github.com/InjectiveLabs/sdk-go/client/common" + rpchttp "github.com/cometbft/cometbft/rpc/client/http" +) + +func main() { + network := common.LoadNetwork("testnet", "lb") + tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") + if err != nil { + panic(err) + } + + senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( + os.Getenv("HOME")+"/.injectived", + "injectived", + "file", + "inj-user", + "12345678", + "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided + false, + ) + + if err != nil { + panic(err) + } + + clientCtx, err := chainclient.NewClientContext( + network.ChainId, + senderAddress.String(), + cosmosKeyring, + ) + + if err != nil { + panic(err) + } + + clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) + + chainClient, err := chainclient.NewChainClient( + clientCtx, + network, + common.OptionGasPrices(client.DefaultGasPriceWithDenom), + ) + + if err != nil { + panic(err) + } + + ctx := context.Background() + + denoms := []string{"inj", "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5"} + + res, err := chainClient.FetchDenomDecimals(ctx, denoms) + if err != nil { + fmt.Println(err) + } + + str, _ := json.MarshalIndent(res, "", " ") + fmt.Print(string(str)) + +} diff --git a/examples/chain/23_MsgRelayPriceFeedPrice/example.go b/examples/chain/oracle/1_MsgRelayPriceFeedPrice/example.go similarity index 100% rename from examples/chain/23_MsgRelayPriceFeedPrice/example.go rename to examples/chain/oracle/1_MsgRelayPriceFeedPrice/example.go diff --git a/examples/chain/22_MsgSendToEth/example.go b/examples/chain/peggy/1_MsgSendToEth/example.go similarity index 100% rename from examples/chain/22_MsgSendToEth/example.go rename to examples/chain/peggy/1_MsgSendToEth/example.go diff --git a/examples/chain/25_MsgDelegate/example.go b/examples/chain/staking/1_MsgDelegate/example.go similarity index 100% rename from examples/chain/25_MsgDelegate/example.go rename to examples/chain/staking/1_MsgDelegate/example.go diff --git a/examples/chain/64_CreateDenom/example.go b/examples/chain/tokenfactory/1_CreateDenom/example.go similarity index 100% rename from examples/chain/64_CreateDenom/example.go rename to examples/chain/tokenfactory/1_CreateDenom/example.go diff --git a/examples/chain/65_MsgMint/example.go b/examples/chain/tokenfactory/2_MsgMint/example.go similarity index 100% rename from examples/chain/65_MsgMint/example.go rename to examples/chain/tokenfactory/2_MsgMint/example.go diff --git a/examples/chain/66_MsgBurn/example.go b/examples/chain/tokenfactory/3_MsgBurn/example.go similarity index 100% rename from examples/chain/66_MsgBurn/example.go rename to examples/chain/tokenfactory/3_MsgBurn/example.go diff --git a/examples/chain/67_MsgSetDenomMetadata/example.go b/examples/chain/tokenfactory/4_MsgSetDenomMetadata/example.go similarity index 100% rename from examples/chain/67_MsgSetDenomMetadata/example.go rename to examples/chain/tokenfactory/4_MsgSetDenomMetadata/example.go diff --git a/examples/chain/68_MsgChangeAdmin/example.go b/examples/chain/tokenfactory/5_MsgChangeAdmin/example.go similarity index 100% rename from examples/chain/68_MsgChangeAdmin/example.go rename to examples/chain/tokenfactory/5_MsgChangeAdmin/example.go diff --git a/examples/chain/60_DenomAuthorityMetadata/example.go b/examples/chain/tokenfactory/query/1_DenomAuthorityMetadata/example.go similarity index 100% rename from examples/chain/60_DenomAuthorityMetadata/example.go rename to examples/chain/tokenfactory/query/1_DenomAuthorityMetadata/example.go diff --git a/examples/chain/61_DenomsFromCreator/example.go b/examples/chain/tokenfactory/query/2_DenomsFromCreator/example.go similarity index 100% rename from examples/chain/61_DenomsFromCreator/example.go rename to examples/chain/tokenfactory/query/2_DenomsFromCreator/example.go diff --git a/examples/chain/62_TokenfactoryModuleState/example.go b/examples/chain/tokenfactory/query/3_TokenfactoryModuleState/example.go similarity index 100% rename from examples/chain/62_TokenfactoryModuleState/example.go rename to examples/chain/tokenfactory/query/3_TokenfactoryModuleState/example.go diff --git a/examples/chain/39_GetTx/example.go b/examples/chain/tx/query/1_GetTx/example.go similarity index 100% rename from examples/chain/39_GetTx/example.go rename to examples/chain/tx/query/1_GetTx/example.go diff --git a/examples/chain/59_ContractsByCreator/example.go b/examples/chain/wasm/query/10_ContractsByCreator/example.go similarity index 100% rename from examples/chain/59_ContractsByCreator/example.go rename to examples/chain/wasm/query/10_ContractsByCreator/example.go diff --git a/examples/chain/50_ContractInfo/example.go b/examples/chain/wasm/query/1_ContractInfo/example.go similarity index 100% rename from examples/chain/50_ContractInfo/example.go rename to examples/chain/wasm/query/1_ContractInfo/example.go diff --git a/examples/chain/51_ContractHistory/example.go b/examples/chain/wasm/query/2_ContractHistory/example.go similarity index 100% rename from examples/chain/51_ContractHistory/example.go rename to examples/chain/wasm/query/2_ContractHistory/example.go diff --git a/examples/chain/52_ContractsByCode/example.go b/examples/chain/wasm/query/3_ContractsByCode/example.go similarity index 100% rename from examples/chain/52_ContractsByCode/example.go rename to examples/chain/wasm/query/3_ContractsByCode/example.go diff --git a/examples/chain/53_AllContractsState/example.go b/examples/chain/wasm/query/4_AllContractsState/example.go similarity index 100% rename from examples/chain/53_AllContractsState/example.go rename to examples/chain/wasm/query/4_AllContractsState/example.go diff --git a/examples/chain/54_RawContractState/example.go b/examples/chain/wasm/query/5_RawContractState/example.go similarity index 100% rename from examples/chain/54_RawContractState/example.go rename to examples/chain/wasm/query/5_RawContractState/example.go diff --git a/examples/chain/55_SmartContractState/example.go b/examples/chain/wasm/query/6_SmartContractState/example.go similarity index 100% rename from examples/chain/55_SmartContractState/example.go rename to examples/chain/wasm/query/6_SmartContractState/example.go diff --git a/examples/chain/56_SmartContractCode/example.go b/examples/chain/wasm/query/7_SmartContractCode/example.go similarity index 100% rename from examples/chain/56_SmartContractCode/example.go rename to examples/chain/wasm/query/7_SmartContractCode/example.go diff --git a/examples/chain/57_SmartContractCodes/example.go b/examples/chain/wasm/query/8_SmartContractCodes/example.go similarity index 100% rename from examples/chain/57_SmartContractCodes/example.go rename to examples/chain/wasm/query/8_SmartContractCodes/example.go diff --git a/examples/chain/58_SmartContractPinnedCodes/example.go b/examples/chain/wasm/query/9_SmartContractPinnedCodes/example.go similarity index 100% rename from examples/chain/58_SmartContractPinnedCodes/example.go rename to examples/chain/wasm/query/9_SmartContractPinnedCodes/example.go diff --git a/examples/chain/69_MsgExecuteContractCompat/example.go b/examples/chain/wasmx/1_MsgExecuteContractCompat/example.go similarity index 100% rename from examples/chain/69_MsgExecuteContractCompat/example.go rename to examples/chain/wasmx/1_MsgExecuteContractCompat/example.go