├── .coderabbit.yaml ├── .github └── workflows │ ├── golangci-lint.yml │ ├── pre-commit.yml │ └── run-tests.yml ├── .gitignore ├── .golangci.yml ├── .pre-commit-config.yaml ├── LICENSE.md ├── Makefile ├── NOTICE.md ├── README.md ├── auth_vote └── authz_vote.go ├── buf.gen.chain.yaml ├── buf.gen.indexer.yaml ├── chain ├── auction │ └── types │ │ ├── auction.pb.go │ │ ├── codec.go │ │ ├── genesis.pb.go │ │ ├── query.pb.go │ │ └── tx.pb.go ├── codec │ ├── codec.go │ └── types │ │ └── types.go ├── crypto │ ├── codec │ │ ├── amino.go │ │ └── proto.go │ ├── ethsecp256k1 │ │ ├── ethsecp256k1.go │ │ └── keys.pb.go │ └── hd │ │ └── algorithm.go ├── exchange │ └── types │ │ ├── authz.pb.go │ │ ├── authz_common.go │ │ ├── authz_derivative.go │ │ ├── authz_spot.go │ │ ├── codec.go │ │ ├── common_order.go │ │ ├── common_utils.go │ │ ├── conditional_orders.go │ │ ├── deposit.go │ │ ├── derivative_orders.go │ │ ├── errors.go │ │ ├── events.go │ │ ├── events.pb.go │ │ ├── exchange.go │ │ ├── exchange.pb.go │ │ ├── expected_keepers.go │ │ ├── fee_discounts.go │ │ ├── fee_validation.go │ │ ├── genesis.go │ │ ├── genesis.pb.go │ │ ├── key.go │ │ ├── market.go │ │ ├── market_admin.go │ │ ├── msgs.go │ │ ├── orderbook.go │ │ ├── params.go │ │ ├── paramset.go │ │ ├── positions.go │ │ ├── proposal.go │ │ ├── proposal.pb.go │ │ ├── query.pb.go │ │ ├── spot_orders.go │ │ ├── stake_grants.go │ │ ├── subaccount.go │ │ ├── trading_rewards.go │ │ ├── tx.pb.go │ │ ├── volume_record.go │ │ ├── wasm_privileged_action.go │ │ ├── wasm_trade_summary.go │ │ └── wasm_trades.go ├── helpers │ └── common.go ├── insurance │ └── types │ │ ├── codec.go │ │ ├── events.pb.go │ │ ├── genesis.pb.go │ │ ├── insurance.pb.go │ │ ├── query.pb.go │ │ └── tx.pb.go ├── ocr │ └── types │ │ ├── codec.go │ │ ├── errors.go │ │ ├── genesis.pb.go │ │ ├── key.go │ │ ├── ocr.pb.go │ │ ├── params.go │ │ ├── proposal.go │ │ ├── query.pb.go │ │ ├── tx.pb.go │ │ └── types.go ├── oracle │ ├── bandchain │ │ ├── hooks │ │ │ └── price │ │ │ │ └── types.go │ │ └── oracle │ │ │ └── types │ │ │ ├── constants.go │ │ │ ├── error.go │ │ │ ├── id.go │ │ │ └── keys.go │ └── types │ │ ├── codec.go │ │ ├── errors.go │ │ ├── events.pb.go │ │ ├── genesis.pb.go │ │ ├── key.go │ │ ├── msgs.go │ │ ├── oracle.go │ │ ├── oracle.pb.go │ │ ├── params.go │ │ ├── proposal.go │ │ ├── proposal.pb.go │ │ ├── query.pb.go │ │ ├── stork_oracle.go │ │ └── tx.pb.go ├── peggy │ └── types │ │ ├── abi_json.go │ │ ├── attestation.pb.go │ │ ├── batch.pb.go │ │ ├── codec.go │ │ ├── errors.go │ │ ├── ethereum.go │ │ ├── ethereum_signer.go │ │ ├── ethereum_signer.pb.go │ │ ├── events.pb.go │ │ ├── genesis.pb.go │ │ ├── key.go │ │ ├── msgs.go │ │ ├── msgs.pb.go │ │ ├── params.go │ │ ├── params.pb.go │ │ ├── pool.pb.go │ │ ├── query.pb.go │ │ ├── types.go │ │ └── types.pb.go ├── permissions │ └── types │ │ ├── codec.go │ │ ├── events.pb.go │ │ ├── genesis.pb.go │ │ ├── params.pb.go │ │ ├── permissions.pb.go │ │ ├── query.pb.go │ │ └── tx.pb.go ├── stream │ └── types │ │ └── query.pb.go ├── tokenfactory │ └── types │ │ ├── authorityMetadata.pb.go │ │ ├── codec.go │ │ ├── events.pb.go │ │ ├── genesis.pb.go │ │ ├── params.pb.go │ │ ├── query.pb.go │ │ └── tx.pb.go ├── txfees │ ├── osmosis │ │ └── types │ │ │ └── query.pb.go │ └── types │ │ ├── codec.go │ │ ├── genesis.pb.go │ │ ├── query.pb.go │ │ ├── tx.pb.go │ │ └── txfees.pb.go ├── types │ ├── account.pb.go │ ├── codec.go │ ├── config.go │ ├── tx_ext.pb.go │ ├── tx_response.pb.go │ └── util.go └── wasmx │ └── types │ ├── authz.go │ ├── authz.pb.go │ ├── codec.go │ ├── custom_execution.go │ ├── errors.go │ ├── events.pb.go │ ├── genesis.pb.go │ ├── key.go │ ├── msgs.go │ ├── params.go │ ├── proposal.go │ ├── proposal.pb.go │ ├── query.pb.go │ ├── tx.pb.go │ └── wasmx.pb.go ├── client ├── chain │ ├── chain.go │ ├── chain_test.go │ ├── chain_test_support.go │ ├── context.go │ ├── injective_data │ │ └── ofac.json │ ├── keys.go │ ├── markets_assistant.go │ ├── markets_assistant_test.go │ ├── markets_assistant_test_support.go │ ├── ofac.go │ ├── ofac_test.go │ ├── orderhash.go │ └── tx_factory.go ├── common │ ├── api_request_assistant.go │ ├── network.go │ ├── network_test.go │ ├── options.go │ └── util.go ├── constants.go ├── core │ ├── market.go │ ├── market_test.go │ ├── token.go │ ├── token_test.go │ ├── tokens_file_loader.go │ └── tokens_file_loader_test.go ├── exchange │ ├── exchange.go │ └── exchange_test_support.go ├── explorer │ └── explorer.go ├── keyring │ ├── README.md │ ├── errors.go │ ├── key_config.go │ ├── keyring.go │ ├── keyring_config.go │ ├── keyring_errors_test.go │ ├── keyring_test.go │ └── testdata │ │ └── keyring-file │ │ ├── 263117aad9ebf5759a8272ad2ae4968dd12d4602.address │ │ ├── 310322fcb0937ade77a9ba0d128f9e7f17312796.address │ │ ├── keyhash │ │ ├── test.info │ │ └── test2.info └── tm │ └── tmclient.go ├── eip712_cosmos.go ├── eip712_cosmos_test.go ├── ethereum ├── rpc │ └── block.go └── util │ ├── amounts.go │ ├── contract.go │ ├── noncecache.go │ ├── uniquify.go │ └── uniquify_test.go ├── examples ├── chain │ ├── 10_StreamEventOrderbookUpdate │ │ └── example.go │ ├── 11_DecodeTx │ │ └── 37_decode_tx.go │ ├── 12_ChainStream │ │ └── example.go │ ├── 13_BroadcastMsgWithoutSimulation │ │ └── example.go │ ├── 1_LocalOrderHash │ │ └── example.go │ ├── 2_MsgBatchCancelSpotOrders │ │ └── example.go │ ├── 3_MsgBatchCancelDerivativeOrders │ │ └── example.go │ ├── 4_MsgBatchCreateSpotLimitOrders │ │ └── example.go │ ├── 5_MsgBatchCreateDerivativeLimitOrders │ │ └── example.go │ ├── 6_MsgRegisterAsDMM │ │ └── example.go │ ├── 7_GetBlock │ │ └── example.go │ ├── 8_OfflineSigning │ │ └── example.go │ ├── 9_StreamEventOrderFail │ │ └── example.go │ ├── auction │ │ └── 1_MsgBid │ │ │ └── example.go │ ├── auth │ │ └── query │ │ │ └── 1_Account │ │ │ └── example.go │ ├── authz │ │ ├── 1_MsgGrant │ │ │ └── example.go │ │ ├── 2_MsgExec │ │ │ └── example.go │ │ ├── 3_MsgRevoke │ │ │ └── example.go │ │ └── query │ │ │ └── 1_Grants │ │ │ └── example.go │ ├── bank │ │ ├── 1_MsgSend │ │ │ └── example.go │ │ ├── 2_MsgMultiSend │ │ │ └── example.go │ │ └── query │ │ │ ├── 10_BankSendEnabled │ │ │ └── example.go │ │ │ ├── 1_BankBalance │ │ │ └── example.go │ │ │ ├── 2_BankBalances │ │ │ └── example.go │ │ │ ├── 3_BankSpendableBalances │ │ │ └── example.go │ │ │ ├── 4_BankSpendableBalancesByDenom │ │ │ └── example.go │ │ │ ├── 5_BankTotalSupply │ │ │ └── example.go │ │ │ ├── 6_BankSupplyOf │ │ │ └── example.go │ │ │ ├── 7_DenomMetadata │ │ │ └── example.go │ │ │ ├── 8_DenomsMetadata │ │ │ └── example.go │ │ │ └── 9_DenomOwners │ │ │ └── example.go │ ├── distribution │ │ ├── 1_SetWithdrawAddress │ │ │ └── example.go │ │ ├── 2_MsgWithdrawDelegatorReward │ │ │ └── example.go │ │ ├── 3_WithdrawValidatorCommission │ │ │ └── example.go │ │ ├── 4_FundCommunityPool │ │ │ └── example.go │ │ └── query │ │ │ ├── 1_ValidatorDistributionInfo │ │ │ └── example.go │ │ │ ├── 2_ValidatorOutstandingRewards │ │ │ └── example.go │ │ │ ├── 3_ValidatorCommission │ │ │ └── example.go │ │ │ ├── 4_ValidatorSlashes │ │ │ └── example.go │ │ │ ├── 5_DelegationRewards │ │ │ └── example.go │ │ │ ├── 6_DelegationTotalRewards │ │ │ └── example.go │ │ │ ├── 7_DelegatorValidators │ │ │ └── example.go │ │ │ ├── 8_DelegatorWithdrawAddress │ │ │ └── example.go │ │ │ └── 9_CommunityPool │ │ │ └── example.go │ ├── exchange │ │ ├── 10_MsgCreateDerivativeLimitOrder │ │ │ └── example.go │ │ ├── 11_MsgCreateDerivativeMarketOrder │ │ │ └── example.go │ │ ├── 12_MsgCancelDerivativeOrder │ │ │ └── example.go │ │ ├── 13_MsgInstantBinaryOptionsMarketLaunch │ │ │ └── example.go │ │ ├── 14_MsgSubaccountTransfer │ │ │ └── example.go │ │ ├── 15_MsgExternalTransfer │ │ │ └── example.go │ │ ├── 16_MsgLiquidatePosition │ │ │ └── example.go │ │ ├── 17_MsgIncreasePositionMargin │ │ │ └── example.go │ │ ├── 1_MsgDeposit │ │ │ └── example.go │ │ ├── 21_MsgRewardsOptOut │ │ │ └── example.go │ │ ├── 23_MsgDecreasePositionMargin │ │ │ └── example.go │ │ ├── 24_MsgUpdateSpotMarket │ │ │ └── example.go │ │ ├── 25_MsgUpdateDerivativeMarket │ │ │ └── example.go │ │ ├── 26_MsgAuthorizeStakeGrants │ │ │ └── example.go │ │ ├── 27_MsgActivateStakeGrant │ │ │ └── example.go │ │ ├── 2_MsgWithdraw │ │ │ └── example.go │ │ ├── 3_MsgInstantSpotMarketLaunch │ │ │ └── example.go │ │ ├── 4_MsgInstantPerpetualMarketLaunch │ │ │ └── example.go │ │ ├── 5_MsgInstantExpiryFuturesMarketLaunch │ │ │ └── example.go │ │ ├── 6_MsgCreateSpotLimitOrder │ │ │ └── example.go │ │ ├── 7_MsgCreateSpotMarketOrder │ │ │ └── example.go │ │ ├── 8_MsgCancelSpotOrder │ │ │ └── example.go │ │ ├── 9_MsgBatchUpdateOrders │ │ │ └── example.go │ │ └── query │ │ │ ├── 10_SpotMarkets │ │ │ └── example.go │ │ │ ├── 11_SpotMarket │ │ │ └── example.go │ │ │ ├── 12_FullSpotMarkets │ │ │ └── example.go │ │ │ ├── 13_FullSpotMarket │ │ │ └── example.go │ │ │ ├── 14_SpotOrderbook │ │ │ └── example.go │ │ │ ├── 15_TraderSpotOrders │ │ │ └── example.go │ │ │ ├── 16_AccountAddressSpotOrders │ │ │ └── example.go │ │ │ ├── 17_SpotOrdersByHashes │ │ │ └── example.go │ │ │ ├── 18_SubaccountOrders │ │ │ └── example.go │ │ │ ├── 19_TraderSpotTransientOrders │ │ │ └── example.go │ │ │ ├── 1_SubaccountDeposits │ │ │ └── example.go │ │ │ ├── 20_SpotMidPriceAndTOB │ │ │ └── example.go │ │ │ ├── 21_DerivativeMidPriceAndTOB │ │ │ └── example.go │ │ │ ├── 22_DerivativeOrderbook │ │ │ └── example.go │ │ │ ├── 23_TraderDerivativeOrders │ │ │ └── example.go │ │ │ ├── 24_AccountAddressDerivativeOrders │ │ │ └── example.go │ │ │ ├── 25_DerivativeOrdersByHashes │ │ │ └── example.go │ │ │ ├── 26_TraderDerivativeTransientOrders │ │ │ └── example.go │ │ │ ├── 27_DerivativeMarkets │ │ │ └── example.go │ │ │ ├── 28_DerivativeMarket │ │ │ └── example.go │ │ │ ├── 29_DerivativeMarketAddress │ │ │ └── example.go │ │ │ ├── 2_SubaccountDeposit │ │ │ └── example.go │ │ │ ├── 30_SubaccountTradeNonce │ │ │ └── example.go │ │ │ ├── 31_Positions │ │ │ └── example.go │ │ │ ├── 32_SubaccountPositions │ │ │ └── example.go │ │ │ ├── 33_SubaccountPositionInMarket │ │ │ └── example.go │ │ │ ├── 34_SubaccountEffectivePositionInMarket │ │ │ └── example.go │ │ │ ├── 35_PerpetualMarketInfo │ │ │ └── example.go │ │ │ ├── 36_ExpiryFuturesMarketInfo │ │ │ └── example.go │ │ │ ├── 37_PerpetualMarketFunding │ │ │ └── example.go │ │ │ ├── 38_SubaccountOrderMetadata │ │ │ └── example.go │ │ │ ├── 39_TradeRewardPoints │ │ │ └── example.go │ │ │ ├── 3_ExchangeBalances │ │ │ └── example.go │ │ │ ├── 40_PendingTradeRewardPoints │ │ │ └── example.go │ │ │ ├── 41_TradeRewardCampaign │ │ │ └── example.go │ │ │ ├── 42_FeeDiscountAccountInfo │ │ │ └── example.go │ │ │ ├── 43_FeeDiscountSchedule │ │ │ └── example.go │ │ │ ├── 44_BalanceMismatches │ │ │ └── example.go │ │ │ ├── 45_BalanceWithBalanceHolds │ │ │ └── example.go │ │ │ ├── 46_FeeDiscountTierStatistics │ │ │ └── example.go │ │ │ ├── 47_MitoVaultInfos │ │ │ └── example.go │ │ │ ├── 48_QueryMarketIDFromVault │ │ │ └── example.go │ │ │ ├── 49_HistoricalTradeRecords │ │ │ └── example.go │ │ │ ├── 4_AggregateVolume │ │ │ └── example.go │ │ │ ├── 50_IsOptedOutOfRewards │ │ │ └── example.go │ │ │ ├── 51_OptedOutOfRewardsAccounts │ │ │ └── example.go │ │ │ ├── 52_MarketVolatility │ │ │ └── example.go │ │ │ ├── 53_BinaryOptionsMarkets │ │ │ └── example.go │ │ │ ├── 54_TraderDerivativeConditionalOrders │ │ │ └── example.go │ │ │ ├── 55_MarketAtomicExecutionFeeMultiplier │ │ │ └── example.go │ │ │ ├── 56_L3DerivativeOrderBook │ │ │ └── example.go │ │ │ ├── 57_L3SpotOrderBook │ │ │ └── example.go │ │ │ ├── 58_MarketBalance │ │ │ └── example.go │ │ │ ├── 59_MarketBalances │ │ │ └── example.go │ │ │ ├── 5_AggregateVolumes │ │ │ └── example.go │ │ │ ├── 60_DenomMinNotional │ │ │ └── example.go │ │ │ ├── 61_DenomMinNotionals │ │ │ └── example.go │ │ │ ├── 6_AggregateMarketVolume │ │ │ └── example.go │ │ │ ├── 7_AggregateMarketVolumes │ │ │ └── example.go │ │ │ ├── 8_DenomDecimal │ │ │ └── example.go │ │ │ └── 9_DenomDecimals │ │ │ └── example.go │ ├── ibc │ │ ├── channel │ │ │ └── query │ │ │ │ ├── 10_PacketAcknowledgements │ │ │ │ └── example.go │ │ │ │ ├── 11_UnreceivedPackets │ │ │ │ └── example.go │ │ │ │ ├── 12_UnreceivedAcks │ │ │ │ └── example.go │ │ │ │ ├── 13_NextSequenceReceive │ │ │ │ └── example.go │ │ │ │ ├── 1_Channel │ │ │ │ └── example.go │ │ │ │ ├── 2_Channels │ │ │ │ └── example.go │ │ │ │ ├── 3_ConnectionChannels │ │ │ │ └── example.go │ │ │ │ ├── 4_ChannelClientState │ │ │ │ └── example.go │ │ │ │ ├── 5_ChannelConsensusState │ │ │ │ └── example.go │ │ │ │ ├── 6_PacketCommitment │ │ │ │ └── example.go │ │ │ │ ├── 7_PacketCommitments │ │ │ │ └── example.go │ │ │ │ ├── 8_PacketReceipt │ │ │ │ └── example.go │ │ │ │ └── 9_PacketAcknowledgement │ │ │ │ └── example.go │ │ ├── client │ │ │ └── query │ │ │ │ ├── 1_ClientState │ │ │ │ └── example.go │ │ │ │ ├── 2_ClientStates │ │ │ │ └── example.go │ │ │ │ ├── 3_ConsensusState │ │ │ │ └── example.go │ │ │ │ ├── 4_ConsensusStates │ │ │ │ └── example.go │ │ │ │ ├── 5_ConsensusStateHeight │ │ │ │ └── example.go │ │ │ │ ├── 6_ClientStatus │ │ │ │ └── example.go │ │ │ │ ├── 7_ClientParams │ │ │ │ └── example.go │ │ │ │ ├── 8_UpgradedClientState │ │ │ │ └── example.go │ │ │ │ └── 9_UpgradedConsensusState │ │ │ │ └── example.go │ │ ├── connection │ │ │ └── query │ │ │ │ ├── 1_Connection │ │ │ │ └── example.go │ │ │ │ ├── 2_Connections │ │ │ │ └── example.go │ │ │ │ ├── 3_ClientConnections │ │ │ │ └── example.go │ │ │ │ ├── 4_ConnectionClientState │ │ │ │ └── example.go │ │ │ │ ├── 5_ConnectionConsensusState │ │ │ │ └── example.go │ │ │ │ └── 6_ConnectionParams │ │ │ │ └── example.go │ │ └── transfer │ │ │ ├── 1_MsgTransfer │ │ │ └── example.go │ │ │ └── query │ │ │ ├── 1_DenomTrace │ │ │ └── example.go │ │ │ ├── 2_DenomTraces │ │ │ └── example.go │ │ │ ├── 3_DenomHash │ │ │ └── example.go │ │ │ ├── 4_EscrowAddress │ │ │ └── example.go │ │ │ └── 5_TotalEscrowForDenom │ │ │ └── example.go │ ├── ofac │ │ └── 1_DownloadOfacList │ │ │ └── example.go │ ├── oracle │ │ └── 1_MsgRelayPriceFeedPrice │ │ │ └── example.go │ ├── peggy │ │ └── 1_MsgSendToEth │ │ │ └── example.go │ ├── permissions │ │ ├── 1_MsgCreateNamespace │ │ │ └── example.go │ │ ├── 2_MsgUpdateNamespace │ │ │ └── example.go │ │ ├── 3_MsgUpdateActorRoles │ │ │ └── example.go │ │ ├── 4_MsgClaimVoucher │ │ │ └── example.go │ │ └── query │ │ │ ├── 10_Vouchers │ │ │ └── example.go │ │ │ ├── 11_Voucher │ │ │ └── example.go │ │ │ ├── 12_PermissionsModuleState │ │ │ └── example.go │ │ │ ├── 1_NamespaceDenoms │ │ │ └── example.go │ │ │ ├── 2_Namespaces │ │ │ └── example.go │ │ │ ├── 3_Namespace │ │ │ └── example.go │ │ │ ├── 4_RolesByActor │ │ │ └── example.go │ │ │ ├── 5_ActorsByRole │ │ │ └── example.go │ │ │ ├── 6_RoleManagers │ │ │ └── example.go │ │ │ ├── 7_RoleManager │ │ │ └── example.go │ │ │ ├── 8_PolicyStatuses │ │ │ └── example.go │ │ │ └── 9_PolicyManagerCapabilities │ │ │ └── example.go │ ├── staking │ │ └── 1_MsgDelegate │ │ │ └── example.go │ ├── tendermint │ │ └── query │ │ │ ├── 1_GetNodeInfo │ │ │ └── example.go │ │ │ ├── 2_GetSyncing │ │ │ └── example.go │ │ │ ├── 3_GetLatestBlock │ │ │ └── example.go │ │ │ ├── 4_GetBlockByHeight │ │ │ └── example.go │ │ │ ├── 5_GetLatestValidatorSet │ │ │ └── example.go │ │ │ └── 6_GetValidatorSetByHeight │ │ │ └── example.go │ ├── tokenfactory │ │ ├── 1_CreateDenom │ │ │ └── example.go │ │ ├── 2_MsgMint │ │ │ └── example.go │ │ ├── 3_MsgBurn │ │ │ └── example.go │ │ ├── 4_MsgSetDenomMetadata │ │ │ └── example.go │ │ ├── 5_MsgChangeAdmin │ │ │ └── example.go │ │ └── query │ │ │ ├── 1_DenomAuthorityMetadata │ │ │ └── example.go │ │ │ ├── 2_DenomsFromCreator │ │ │ └── example.go │ │ │ └── 3_TokenfactoryModuleState │ │ │ └── example.go │ ├── tx │ │ └── query │ │ │ └── 1_GetTx │ │ │ └── example.go │ ├── txfees │ │ └── query │ │ │ └── 1_GetEipBaseFee │ │ │ └── example.go │ ├── wasm │ │ └── query │ │ │ ├── 10_ContractsByCreator │ │ │ └── example.go │ │ │ ├── 1_ContractInfo │ │ │ └── example.go │ │ │ ├── 2_ContractHistory │ │ │ └── example.go │ │ │ ├── 3_ContractsByCode │ │ │ └── example.go │ │ │ ├── 4_AllContractsState │ │ │ └── example.go │ │ │ ├── 5_RawContractState │ │ │ └── example.go │ │ │ ├── 6_SmartContractState │ │ │ └── example.go │ │ │ ├── 7_SmartContractCode │ │ │ └── example.go │ │ │ ├── 8_SmartContractCodes │ │ │ └── example.go │ │ │ └── 9_SmartContractPinnedCodes │ │ │ └── example.go │ └── wasmx │ │ └── 1_MsgExecuteContractCompat │ │ └── example.go ├── exchange │ ├── accounts │ │ ├── 1_StreamSubaccountBalance │ │ │ └── example.go │ │ ├── 2_SubaccountBalance │ │ │ └── example.go │ │ ├── 3_SubaccountsList │ │ │ └── example.go │ │ ├── 4_SubaccountBalancesList │ │ │ └── example.go │ │ ├── 5_SubaccountHistory │ │ │ └── example.go │ │ ├── 6_SubaccountOrderSummary │ │ │ └── example.go │ │ ├── 7_OrderStates │ │ │ └── example.go │ │ ├── 8_Portfolio │ │ │ └── example.go │ │ └── 9_Rewards │ │ │ └── example.go │ ├── auction │ │ ├── 1_Auction │ │ │ └── example.go │ │ ├── 2_Auctions │ │ │ └── example.go │ │ ├── 3_StreamBids │ │ │ └── example.go │ │ └── 4_InjBurntEndpoint │ │ │ └── example.go │ ├── derivatives │ │ ├── 10_StreamPositions │ │ │ └── example.go │ │ ├── 11_StreamOrders │ │ │ └── example.go │ │ ├── 12_Trades │ │ │ └── example.go │ │ ├── 13_StreamTrades │ │ │ └── example.go │ │ ├── 14_SubaccountOrdersList │ │ │ └── example.go │ │ ├── 15_SubaccountTradesList │ │ │ └── example.go │ │ ├── 16_FundingPayments │ │ │ └── example.go │ │ ├── 17_FundingRates │ │ │ └── example.go │ │ ├── 18_HistoricalOrders │ │ │ └── example.go │ │ ├── 19_StreamHistoricalOrders │ │ │ └── example.go │ │ ├── 1_Market │ │ │ └── example.go │ │ ├── 20_LiquidablePositions │ │ │ └── example.go │ │ ├── 21_TradesV2 │ │ │ └── example.go │ │ ├── 22_StreamTradesV2 │ │ │ └── example.go │ │ ├── 2_Markets │ │ │ └── example.go │ │ ├── 3_StreamMarket │ │ │ └── example.go │ │ ├── 4_Orderbook │ │ │ └── example.go │ │ ├── 5_Orderbooks │ │ │ └── example.go │ │ ├── 6_StreamOrderbook │ │ │ └── example.go │ │ ├── 7_StreamOrderbookUpdate │ │ │ └── example.go │ │ ├── 8_Positions │ │ │ └── example.go │ │ └── 9_Orders │ │ │ └── example.go │ ├── insurance │ │ ├── 1_InsuranceFunds │ │ │ └── example.go │ │ └── 2_Redemptions │ │ │ └── example.go │ ├── meta │ │ ├── 1_Ping │ │ │ └── example.go │ │ ├── 2_Version │ │ │ └── example.go │ │ ├── 3_Info │ │ │ └── example.go │ │ └── 4_StreamKeepAlive │ │ │ └── example.go │ ├── oracle │ │ ├── 1_StreamPrices │ │ │ └── example.go │ │ ├── 2_Price │ │ │ └── example.go │ │ └── 3_OracleList │ │ │ └── example.go │ ├── portfolio │ │ ├── 1_AccountPortfolio │ │ │ └── example.go │ │ ├── 2_StreamAccountPortfolioBankBalances │ │ │ └── example.go │ │ └── 3_StreamAccountPortfolioSubaccountBalances │ │ │ └── example.go │ └── spot │ │ ├── 10_StreamTrades │ │ └── example.go │ │ ├── 11_SubaccountOrdersList │ │ └── example.go │ │ ├── 12_SubaccountTradesList │ │ └── example.go │ │ ├── 13_Orderbooks │ │ └── example.go │ │ ├── 14_HistoricalOrders │ │ └── example.go │ │ ├── 15_StreamHistoricalOrders │ │ └── example.go │ │ ├── 16_TradesV2 │ │ └── example.go │ │ ├── 17_StreamTradesV2 │ │ └── example.go │ │ ├── 1_Market │ │ └── example.go │ │ ├── 2_Markets │ │ └── example.go │ │ ├── 3_StreamMarket │ │ └── example.go │ │ ├── 4_Orderbook │ │ └── example.go │ │ ├── 5_Orders │ │ └── example.go │ │ ├── 6_Trades │ │ └── example.go │ │ ├── 7_StreamOrderbook │ │ └── example.go │ │ ├── 8_StreamOrderbookUpdate │ │ └── example.go │ │ └── 9_StreamOrders │ │ └── example.go └── explorer │ ├── 10_IBCTransfers │ └── example.go │ ├── 11_GetWasmCodes │ └── example.go │ ├── 12_GetWasmCodeById │ └── example.go │ ├── 13_GetWasmContracts │ └── example.go │ ├── 14_GetWasmContractByAddress │ └── example.go │ ├── 15_GetCW20Balance │ └── example.go │ ├── 16_GetContractTxs │ └── example.go │ ├── 17_GetContractTxsV2 │ └── example.go │ ├── 18_GetValidators │ └── example.go │ ├── 19_GetValidator │ └── example.go │ ├── 1_GetTxByHash │ └── example.go │ ├── 20_GetValidatorUptime │ └── example.go │ ├── 21_Relayers │ └── example.go │ ├── 22_GetBankTransfers │ └── example.go │ ├── 2_AccountTxs │ └── example.go │ ├── 3_Blocks │ └── example.go │ ├── 4_Block │ └── example.go │ ├── 5_TxsRequest │ └── example.go │ ├── 6_StreamTxs │ └── example.go │ ├── 7_StreamBlocks │ └── example.go │ ├── 8_PeggyDeposits │ └── example.go │ └── 9_PeggyWithdrawals │ └── example.go ├── exchange ├── accounts_rpc │ └── pb │ │ ├── goadesign_goagen_injective_accounts_rpc.pb.go │ │ └── goadesign_goagen_injective_accounts_rpc_grpc.pb.go ├── auction_rpc │ └── pb │ │ ├── goadesign_goagen_injective_auction_rpc.pb.go │ │ └── goadesign_goagen_injective_auction_rpc_grpc.pb.go ├── campaign_rpc │ └── pb │ │ ├── goadesign_goagen_injective_campaign_rpc.pb.go │ │ └── goadesign_goagen_injective_campaign_rpc_grpc.pb.go ├── derivative_exchange_rpc │ └── pb │ │ ├── goadesign_goagen_injective_derivative_exchange_rpc.pb.go │ │ └── goadesign_goagen_injective_derivative_exchange_rpc_grpc.pb.go ├── event_provider_api │ └── pb │ │ ├── goadesign_goagen_event_provider_api.pb.go │ │ └── goadesign_goagen_event_provider_api_grpc.pb.go ├── exchange_rpc │ └── pb │ │ ├── goadesign_goagen_injective_exchange_rpc.pb.go │ │ └── goadesign_goagen_injective_exchange_rpc_grpc.pb.go ├── explorer_rpc │ └── pb │ │ ├── goadesign_goagen_injective_explorer_rpc.pb.go │ │ └── goadesign_goagen_injective_explorer_rpc_grpc.pb.go ├── health_rpc │ └── pb │ │ ├── goadesign_goagen_health.pb.go │ │ └── goadesign_goagen_health_grpc.pb.go ├── insurance_rpc │ └── pb │ │ ├── goadesign_goagen_injective_insurance_rpc.pb.go │ │ └── goadesign_goagen_injective_insurance_rpc_grpc.pb.go ├── meta_rpc │ └── pb │ │ ├── goadesign_goagen_injective_meta_rpc.pb.go │ │ └── goadesign_goagen_injective_meta_rpc_grpc.pb.go ├── oracle_rpc │ └── pb │ │ ├── goadesign_goagen_injective_oracle_rpc.pb.go │ │ └── goadesign_goagen_injective_oracle_rpc_grpc.pb.go ├── portfolio_rpc │ └── pb │ │ ├── goadesign_goagen_injective_portfolio_rpc.pb.go │ │ └── goadesign_goagen_injective_portfolio_rpc_grpc.pb.go ├── spot_exchange_rpc │ └── pb │ │ ├── goadesign_goagen_injective_spot_exchange_rpc.pb.go │ │ └── goadesign_goagen_injective_spot_exchange_rpc_grpc.pb.go └── trading_rpc │ └── pb │ ├── goadesign_goagen_injective_trading_rpc.pb.go │ └── goadesign_goagen_injective_trading_rpc_grpc.pb.go ├── go.mod ├── go.sum ├── injective_data └── ofac.json ├── proto ├── buf.gen.doc.yml ├── buf.gen.gogo.yml ├── buf.gen.pulsar.yaml ├── buf.gen.swagger.yaml ├── buf.lock ├── buf.md ├── buf.yaml ├── injective │ ├── auction │ │ └── v1beta1 │ │ │ ├── auction.proto │ │ │ ├── genesis.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── crypto │ │ └── v1beta1 │ │ │ └── ethsecp256k1 │ │ │ └── keys.proto │ ├── exchange │ │ └── v1beta1 │ │ │ ├── authz.proto │ │ │ ├── events.proto │ │ │ ├── exchange.proto │ │ │ ├── genesis.proto │ │ │ ├── proposal.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── insurance │ │ └── v1beta1 │ │ │ ├── events.proto │ │ │ ├── genesis.proto │ │ │ ├── insurance.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── ocr │ │ └── v1beta1 │ │ │ ├── genesis.proto │ │ │ ├── ocr.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── oracle │ │ └── v1beta1 │ │ │ ├── events.proto │ │ │ ├── genesis.proto │ │ │ ├── oracle.proto │ │ │ ├── proposal.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── peggy │ │ └── v1 │ │ │ ├── attestation.proto │ │ │ ├── batch.proto │ │ │ ├── ethereum_signer.proto │ │ │ ├── events.proto │ │ │ ├── genesis.proto │ │ │ ├── msgs.proto │ │ │ ├── params.proto │ │ │ ├── pool.proto │ │ │ ├── query.proto │ │ │ └── types.proto │ ├── permissions │ │ └── v1beta1 │ │ │ ├── events.proto │ │ │ ├── genesis.proto │ │ │ ├── params.proto │ │ │ ├── permissions.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── stream │ │ └── v1beta1 │ │ │ └── query.proto │ ├── tokenfactory │ │ └── v1beta1 │ │ │ ├── authorityMetadata.proto │ │ │ ├── events.proto │ │ │ ├── genesis.proto │ │ │ ├── params.proto │ │ │ ├── query.proto │ │ │ └── tx.proto │ ├── txfees │ │ └── v1beta1 │ │ │ ├── genesis.proto │ │ │ ├── query.proto │ │ │ ├── tx.proto │ │ │ └── txfees.proto │ ├── types │ │ └── v1beta1 │ │ │ ├── account.proto │ │ │ ├── tx_ext.proto │ │ │ └── tx_response.proto │ └── wasmx │ │ └── v1 │ │ ├── authz.proto │ │ ├── events.proto │ │ ├── genesis.proto │ │ ├── proposal.proto │ │ ├── query.proto │ │ ├── tx.proto │ │ └── wasmx.proto └── osmosis │ └── txfees │ └── v1beta1 │ └── query.proto ├── typeddata └── typed_data.go └── wrappers ├── erc20.go └── peggy.go /.coderabbit.yaml: -------------------------------------------------------------------------------- 1 | reviews: 2 | auto_review: 3 | base_branches: 4 | - "master" 5 | - "dev" 6 | - "feat/.*" 7 | chat: 8 | auto_reply: true 9 | -------------------------------------------------------------------------------- /.github/workflows/golangci-lint.yml: -------------------------------------------------------------------------------- 1 | name: golangci-lint 2 | on: 3 | pull_request: 4 | push: 5 | branches: [master, dev] 6 | permissions: 7 | contents: read 8 | # Optional: allow read access to pull request. Use with `only-new-issues` option. 9 | pull-requests: read 10 | 11 | jobs: 12 | golangci: 13 | name: lint 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@v3 17 | - uses: actions/setup-go@v5 18 | with: 19 | go-version-file: "go.mod" 20 | check-latest: true 21 | - name: golangci-lint 22 | uses: golangci/golangci-lint-action@v6 23 | with: 24 | # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version 25 | version: latest 26 | 27 | # Optional: working directory, useful for monorepos 28 | # working-directory: somedir 29 | 30 | # Optional: golangci-lint command line arguments. 31 | args: --timeout=15m -v 32 | 33 | # Optional: show only new issues if it's a pull request. The default value is `false`. 34 | only-new-issues: true 35 | 36 | # Optional: if set to true then the all caching functionality will be complete disabled, 37 | # takes precedence over all other caching options. 38 | # skip-cache: true 39 | -------------------------------------------------------------------------------- /.github/workflows/pre-commit.yml: -------------------------------------------------------------------------------- 1 | name: pre-commit 2 | on: 3 | pull_request: 4 | push: 5 | branches: [master, dev] 6 | 7 | jobs: 8 | pre-commit: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | with: 13 | fetch-depth: 2 14 | - uses: actions/setup-go@v5 15 | with: 16 | go-version-file: "go.mod" 17 | check-latest: true 18 | - uses: pre-commit/action@v3.0.1 19 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: run-tests 2 | on: 3 | pull_request: 4 | push: 5 | branches: [ master, dev ] 6 | 7 | jobs: 8 | run-tests: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | with: 13 | fetch-depth: 2 14 | - uses: actions/setup-go@v5 15 | with: 16 | go-version-file: "go.mod" 17 | check-latest: true 18 | - name: Install pass helper 19 | run: sudo apt-get update && sudo apt-get install -y pass 20 | - name: Generate GPG key 21 | run: " 22 | echo \"%no-protection\nKey-Type: 1\nKey-Length: 4096\nSubkey-Type: 1\nSubkey-Length: 4096\nName-Comment: keyring_test\nExpire-Date: 0\" > genkey && gpg --gen-key --batch genkey" 23 | - name: Setup OS keystore 24 | run: pass init keyring_test 25 | - name: Run test and calculate coverage 26 | run: make coverage 27 | - name: Upload coverage to Codecov 28 | uses: codecov/codecov-action@v4 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .idea/ 3 | .chain_cookie 4 | .exchange_cookie 5 | coverage.out 6 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | linters: 2 | fast: false 3 | enable: 4 | - errcheck 5 | - errorlint 6 | - gas 7 | - gocritic 8 | - gofmt 9 | - goimports 10 | - gosimple 11 | - govet 12 | - ineffassign 13 | - megacheck 14 | - misspell 15 | - nakedret 16 | - prealloc 17 | - revive 18 | - staticcheck 19 | - unconvert 20 | - unparam 21 | disable: 22 | - unused 23 | 24 | linters-settings: 25 | revive: 26 | enable-all-rules: true 27 | rules: 28 | - name: var-naming 29 | arguments: 30 | - ["ID"] 31 | - name: add-constant 32 | disabled: true 33 | - name: line-length-limit 34 | arguments: 35 | - 140 36 | gocritic: 37 | enabled-tags: 38 | - performance 39 | - diagnostic 40 | - style 41 | - opinionated 42 | - experimental 43 | disabled-checks: 44 | - singleCaseSwitch 45 | - deferInLoop 46 | - hugeParam 47 | - unnamedResult 48 | issues: 49 | exclude-rules: 50 | - linters: 51 | - revive 52 | text: ALL_CAPS 53 | exclude-dirs: 54 | - chain 55 | - exchange 56 | - injective_data 57 | - proto 58 | - client/keyring/testdata 59 | max-issues-per-linter: 0 60 | 61 | run: 62 | tests: false 63 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: | 2 | (?x)^( 3 | chain/.*| 4 | exchange/.*| 5 | proto/.*| 6 | client/keyring/testdata/.* 7 | )$ 8 | repos: 9 | - repo: https://github.com/pre-commit/pre-commit-hooks 10 | rev: v4.5.0 11 | hooks: 12 | - id: trailing-whitespace 13 | - id: end-of-file-fixer 14 | - id: end-of-file-fixer 15 | - id: check-yaml 16 | -------------------------------------------------------------------------------- /NOTICE.md: -------------------------------------------------------------------------------- 1 | Copyright © 2020 - 2022 Injective Labs Inc. (https://injectivelabs.org/) 2 | 3 | 4 | 5 | Originally released by Injective Labs Inc. under:
6 | Apache License
7 | Version 2.0, January 2004
8 | http://www.apache.org/licenses/ 9 | -------------------------------------------------------------------------------- /buf.gen.chain.yaml: -------------------------------------------------------------------------------- 1 | version: v2 2 | managed: 3 | enabled: true 4 | disable: 5 | - module: buf.build/googleapis/googleapis 6 | file_option: go_package_prefix 7 | plugins: 8 | - local: protoc-gen-go-grpc 9 | out: ./chain/ 10 | opt: paths=source_relative 11 | - local: protoc-gen-gogo 12 | out: ./chain/ 13 | opt: paths=source_relative 14 | inputs: 15 | # - git_repo: https://github.com/InjectiveLabs/injective-core 16 | # tag: v1.13.0 17 | # subdir: proto 18 | - git_repo: https://github.com/InjectiveLabs/injective-core 19 | branch: f/permissions-rework 20 | subdir: proto 21 | -------------------------------------------------------------------------------- /buf.gen.indexer.yaml: -------------------------------------------------------------------------------- 1 | version: v2 2 | managed: 3 | enabled: true 4 | disable: 5 | - module: buf.build/googleapis/googleapis 6 | file_option: go_package_prefix 7 | plugins: 8 | - remote: buf.build/protocolbuffers/go:v1.34.0 9 | out: ./exchange/ 10 | opt: paths=source_relative 11 | - remote: buf.build/grpc/go:v1.3.0 12 | out: ./exchange/ 13 | opt: paths=source_relative 14 | # - local: protoc-gen-go 15 | # out: ./exchange/ 16 | # opt: paths=source_relative 17 | # - local: protoc-gen-go-grpc 18 | # out: ./exchange/ 19 | # opt: paths=source_relative 20 | inputs: 21 | - directory: local_proto 22 | -------------------------------------------------------------------------------- /chain/auction/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | "github.com/cosmos/cosmos-sdk/codec/types" 6 | cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | "github.com/cosmos/cosmos-sdk/types/msgservice" 9 | authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec" 10 | ) 11 | 12 | // RegisterLegacyAminoCodec registers the necessary x/auction interfaces and concrete types 13 | // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. 14 | func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { 15 | cdc.RegisterConcrete(&MsgBid{}, "auction/MsgBid", nil) 16 | cdc.RegisterConcrete(&MsgUpdateParams{}, "auction/MsgUpdateParams", nil) 17 | cdc.RegisterConcrete(&Params{}, "auction/Params", nil) 18 | } 19 | 20 | func RegisterInterfaces(registry types.InterfaceRegistry) { 21 | registry.RegisterImplementations((*sdk.Msg)(nil), 22 | &MsgBid{}, 23 | &MsgUpdateParams{}, 24 | ) 25 | 26 | msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) 27 | } 28 | 29 | var ( 30 | // ModuleCdc references the global x/auction module codec. Note, the codec should 31 | // ONLY be used in certain instances of tests and for JSON encoding as Amino is 32 | // still used for that purpose. 33 | // 34 | // The actual codec used for serialization should be provided to x/auction and 35 | // defined at the application level. 36 | ModuleCdc = codec.NewLegacyAmino() 37 | ) 38 | 39 | func init() { 40 | RegisterLegacyAminoCodec(ModuleCdc) 41 | cryptocodec.RegisterCrypto(ModuleCdc) 42 | 43 | RegisterLegacyAminoCodec(authzcdc.Amino) 44 | ModuleCdc.Seal() 45 | } 46 | -------------------------------------------------------------------------------- /chain/codec/codec.go: -------------------------------------------------------------------------------- 1 | package codec 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | codectypes "github.com/cosmos/cosmos-sdk/codec/types" 6 | "github.com/cosmos/cosmos-sdk/std" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | 9 | cryptocodec "github.com/InjectiveLabs/sdk-go/chain/crypto/codec" 10 | injective "github.com/InjectiveLabs/sdk-go/chain/types" 11 | ) 12 | 13 | // RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std. 14 | func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { 15 | sdk.RegisterLegacyAminoCodec(cdc) 16 | cryptocodec.RegisterCrypto(cdc) 17 | codec.RegisterEvidences(cdc) 18 | } 19 | 20 | // RegisterInterfaces registers Interfaces from types, crypto, and SDK std. 21 | func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) { 22 | std.RegisterInterfaces(interfaceRegistry) 23 | cryptocodec.RegisterInterfaces(interfaceRegistry) 24 | injective.RegisterInterfaces(interfaceRegistry) 25 | } 26 | -------------------------------------------------------------------------------- /chain/crypto/codec/amino.go: -------------------------------------------------------------------------------- 1 | package codec 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | "github.com/cosmos/cosmos-sdk/codec/legacy" 6 | cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" 7 | "github.com/cosmos/cosmos-sdk/crypto/keyring" 8 | cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" 9 | 10 | "github.com/InjectiveLabs/sdk-go/chain/crypto/ethsecp256k1" 11 | ) 12 | 13 | var amino *codec.LegacyAmino 14 | 15 | func init() { 16 | amino = codec.NewLegacyAmino() 17 | RegisterCrypto(amino) 18 | codec.RegisterEvidences(amino) 19 | amino.Seal() 20 | } 21 | 22 | var ( 23 | _ cryptotypes.PubKey = ðsecp256k1.PubKey{} 24 | _ cryptotypes.PrivKey = ðsecp256k1.PrivKey{} 25 | ) 26 | 27 | // RegisterCrypto registers all crypto dependency types with the provided Amino 28 | // codec. 29 | func RegisterCrypto(cdc *codec.LegacyAmino) { 30 | cryptocodec.RegisterCrypto(cdc) 31 | 32 | cdc.RegisterConcrete(ðsecp256k1.PubKey{}, 33 | ethsecp256k1.PubKeyName, nil) 34 | cdc.RegisterConcrete(ðsecp256k1.PrivKey{}, 35 | ethsecp256k1.PrivKeyName, nil) 36 | 37 | keyring.RegisterLegacyAminoCodec(cdc) 38 | legacy.Cdc = cdc 39 | } 40 | -------------------------------------------------------------------------------- /chain/crypto/codec/proto.go: -------------------------------------------------------------------------------- 1 | package codec 2 | 3 | import ( 4 | codectypes "github.com/cosmos/cosmos-sdk/codec/types" 5 | cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" 6 | 7 | "github.com/InjectiveLabs/sdk-go/chain/crypto/ethsecp256k1" 8 | ) 9 | 10 | var ( 11 | _ cryptotypes.PubKey = ðsecp256k1.PubKey{} 12 | _ cryptotypes.PrivKey = ðsecp256k1.PrivKey{} 13 | ) 14 | 15 | // RegisterInterfaces registers the ethsecp256k1 implementations of tendermint crypto types. 16 | func RegisterInterfaces(registry codectypes.InterfaceRegistry) { 17 | registry.RegisterImplementations((*cryptotypes.PubKey)(nil), ðsecp256k1.PubKey{}) 18 | registry.RegisterImplementations((*cryptotypes.PrivKey)(nil), ðsecp256k1.PrivKey{}) 19 | } 20 | -------------------------------------------------------------------------------- /chain/exchange/types/conditional_orders.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | func (b *ConditionalDerivativeOrderBook) HasLimitBuyOrders() bool { 4 | return len(b.LimitBuyOrders) > 0 5 | } 6 | 7 | func (b *ConditionalDerivativeOrderBook) HasLimitSellOrders() bool { 8 | return len(b.LimitSellOrders) > 0 9 | } 10 | 11 | func (b *ConditionalDerivativeOrderBook) HasMarketBuyOrders() bool { 12 | return len(b.MarketBuyOrders) > 0 13 | } 14 | 15 | func (b *ConditionalDerivativeOrderBook) HasMarketSellOrders() bool { 16 | return len(b.MarketSellOrders) > 0 17 | } 18 | 19 | func (b *ConditionalDerivativeOrderBook) IsEmpty() bool { 20 | return !b.HasLimitBuyOrders() && !b.HasLimitSellOrders() && !b.HasMarketBuyOrders() && b.HasMarketSellOrders() 21 | } 22 | 23 | func (b *ConditionalDerivativeOrderBook) GetMarketOrders() []*DerivativeMarketOrder { 24 | return append(b.MarketBuyOrders, b.MarketSellOrders...) 25 | } 26 | 27 | func (b *ConditionalDerivativeOrderBook) GetLimitOrders() []*DerivativeLimitOrder { 28 | return append(b.LimitBuyOrders, b.LimitSellOrders...) 29 | } 30 | -------------------------------------------------------------------------------- /chain/exchange/types/events.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/ethereum/go-ethereum/common" 5 | ) 6 | 7 | // Event type and attribute constants 8 | 9 | func (e *EventOrderFail) AddOrderFail(orderHash common.Hash, cid string, flag uint32) { 10 | e.Hashes = append(e.Hashes, orderHash.Bytes()) 11 | e.Flags = append(e.Flags, flag) 12 | 13 | if cid != "" { 14 | e.Cids = append(e.Cids, cid) 15 | } 16 | } 17 | 18 | func (e *EventOrderFail) IsEmpty() bool { 19 | return len(e.Flags) == 0 && len(e.Hashes) == 0 && len(e.Cids) == 0 20 | } 21 | 22 | func NewEventOrderCancelFail(marketID, subaccountID common.Hash, orderHash, cid string, err error) *EventOrderCancelFail { 23 | ev := &EventOrderCancelFail{ 24 | MarketId: marketID.Hex(), 25 | SubaccountId: subaccountID.Hex(), 26 | OrderHash: orderHash, 27 | Cid: cid, 28 | } 29 | if err != nil { 30 | ev.Description = err.Error() 31 | } 32 | return ev 33 | } 34 | -------------------------------------------------------------------------------- /chain/exchange/types/genesis.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | func NewGenesisState() GenesisState { 4 | return GenesisState{} 5 | } 6 | 7 | func (gs GenesisState) Validate() error { 8 | // TODO: validate stuff in genesis 9 | if err := gs.Params.Validate(); err != nil { 10 | return err 11 | } 12 | return nil 13 | } 14 | 15 | func DefaultGenesisState() *GenesisState { 16 | return &GenesisState{ 17 | Params: DefaultParams(), 18 | IsSpotExchangeEnabled: true, 19 | IsDerivativesExchangeEnabled: true, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chain/exchange/types/paramset.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type ( 4 | ValueValidatorFn func(value interface{}) error 5 | 6 | // ParamSetPair is used for associating paramsubspace key and field of param 7 | // structs. 8 | ParamSetPair struct { 9 | Key []byte 10 | Value interface{} 11 | ValidatorFn ValueValidatorFn 12 | } 13 | ) 14 | 15 | // NewParamSetPair creates a new ParamSetPair instance. 16 | func NewParamSetPair(key []byte, value interface{}, vfn ValueValidatorFn) ParamSetPair { 17 | return ParamSetPair{key, value, vfn} 18 | } 19 | 20 | // ParamSetPairs Slice of KeyFieldPair 21 | type ParamSetPairs []ParamSetPair 22 | 23 | // ParamSet defines an interface for structs containing parameters for a module 24 | type ParamSet interface { 25 | ParamSetPairs() ParamSetPairs 26 | } 27 | -------------------------------------------------------------------------------- /chain/exchange/types/stake_grants.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "cosmossdk.io/math" 5 | sdk "github.com/cosmos/cosmos-sdk/types" 6 | ) 7 | 8 | func NewActiveGrant(granter sdk.AccAddress, amount math.Int) *ActiveGrant { 9 | return &ActiveGrant{ 10 | Granter: granter.String(), 11 | Amount: amount, 12 | } 13 | } 14 | 15 | func NewEffectiveGrant(granter string, amount math.Int, isValid bool) *EffectiveGrant { 16 | return &EffectiveGrant{ 17 | Granter: granter, 18 | NetGrantedStake: amount, 19 | IsValid: isValid, 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /chain/exchange/types/trading_rewards.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "sort" 5 | 6 | "cosmossdk.io/math" 7 | ) 8 | 9 | type TradingRewardPoints map[string]math.LegacyDec 10 | 11 | func NewTradingRewardPoints() TradingRewardPoints { 12 | tradingRewardPoints := make(TradingRewardPoints) 13 | 14 | return tradingRewardPoints 15 | } 16 | 17 | func (l TradingRewardPoints) GetSortedAccountKeys() []string { 18 | accountKeys := make([]string, 0, len(l)) 19 | for k := range l { 20 | accountKeys = append(accountKeys, k) 21 | } 22 | sort.Strings(accountKeys) 23 | return accountKeys 24 | } 25 | 26 | func (l TradingRewardPoints) AddPointsForAddress(addr string, newPoints math.LegacyDec) { 27 | if !newPoints.IsPositive() { 28 | return 29 | } 30 | v, found := l[addr] 31 | if !found { 32 | l[addr] = newPoints 33 | } else { 34 | l[addr] = v.Add(newPoints) 35 | } 36 | } 37 | 38 | func (l *TradingRewardPoints) GetAllAccountAddresses() []string { 39 | accountAddresses := make([]string, 0) 40 | 41 | for k := range *l { 42 | accountAddresses = append(accountAddresses, k) 43 | } 44 | 45 | return accountAddresses 46 | } 47 | 48 | func MergeTradingRewardPoints(m1, m2 TradingRewardPoints) TradingRewardPoints { 49 | if len(m1) == 0 { 50 | return m2 51 | } else if len(m2) == 0 { 52 | return m1 53 | } 54 | 55 | if len(m1) >= len(m2) { 56 | for k, v := range m2 { 57 | m1.AddPointsForAddress(k, v) 58 | } 59 | return m1 60 | } else { 61 | for k, v := range m1 { 62 | m2.AddPointsForAddress(k, v) 63 | } 64 | return m2 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /chain/exchange/types/wasm_privileged_action.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "cosmossdk.io/errors" 7 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 8 | ) 9 | 10 | type PrivilegedAction struct { 11 | SyntheticTrade *SyntheticTradeAction `json:"synthetic_trade"` 12 | PositionTransfer *PositionTransfer `json:"position_transfer"` 13 | } 14 | 15 | type InjectiveAction interface { 16 | // ValidateBasic does a simple validation check that 17 | // doesn't require access to any other information. 18 | ValidateBasic() error 19 | } 20 | 21 | func ParseRequest(data []byte) (InjectiveAction, error) { 22 | if len(data) == 0 || string(data) == "null" { 23 | return nil, nil 24 | } 25 | 26 | var request PrivilegedAction 27 | err := json.Unmarshal(data, &request) 28 | 29 | if err != nil { 30 | return nil, errors.Wrap(err, "failed to parse exchange action request") 31 | } 32 | 33 | if request.SyntheticTrade != nil { 34 | err = request.SyntheticTrade.ValidateBasic() 35 | if err != nil { 36 | return request.SyntheticTrade, errors.Wrap(err, "invalid synthetic trade request") 37 | } 38 | 39 | return request.SyntheticTrade, nil 40 | } 41 | 42 | if request.PositionTransfer != nil { 43 | err = request.PositionTransfer.ValidateBasic() 44 | if err != nil { 45 | return request.PositionTransfer, errors.Wrap(err, "invalid position transfer request") 46 | } 47 | 48 | return request.PositionTransfer, nil 49 | } 50 | 51 | return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "unknown variant of InjectiveAction") 52 | } 53 | -------------------------------------------------------------------------------- /chain/helpers/common.go: -------------------------------------------------------------------------------- 1 | package helpers 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | func HasDuplicate[T comparable](elements []T) bool { 8 | seen := make(map[T]struct{}) 9 | for idx := range elements { 10 | if _, ok := seen[elements[idx]]; ok { 11 | return true // Duplicate found 12 | } 13 | seen[elements[idx]] = struct{}{} 14 | } 15 | return false 16 | } 17 | 18 | func HasDuplicateCoins(slice []sdk.Coin) bool { 19 | seen := make(map[string]struct{}) 20 | for _, item := range slice { 21 | if _, ok := seen[item.Denom]; ok { 22 | return true 23 | } 24 | seen[item.Denom] = struct{}{} 25 | } 26 | return false 27 | } 28 | -------------------------------------------------------------------------------- /chain/oracle/bandchain/hooks/price/types.go: -------------------------------------------------------------------------------- 1 | package price 2 | 3 | import "github.com/InjectiveLabs/sdk-go/chain/oracle/bandchain/oracle/types" 4 | 5 | type SymbolInput struct { 6 | Symbols []string `json:"symbols"` 7 | MinimumSourceCount uint8 `json:"minimum_source_count"` 8 | } 9 | 10 | type SymbolOutput struct { 11 | Responses []Response `json:"responses"` 12 | } 13 | 14 | type Response struct { 15 | Symbol string `json:"symbol"` 16 | ResponseCode uint8 `json:"response_code"` 17 | Rate uint64 `json:"rate"` 18 | } 19 | 20 | type Input struct { 21 | Symbols []string `json:"symbols"` 22 | Multiplier uint64 `json:"multiplier"` 23 | } 24 | 25 | type Output struct { 26 | Pxs []uint64 `json:"pxs"` 27 | } 28 | 29 | type Price struct { 30 | Symbol string `json:"symbol"` 31 | Multiplier uint64 `json:"multiplier"` 32 | Px uint64 `json:"px"` 33 | RequestID types.RequestID `json:"request_id"` 34 | ResolveTime int64 `json:"resolve_time"` 35 | } 36 | 37 | func NewPrice(symbol string, multiplier, px uint64, reqID types.RequestID, resolveTime int64) Price { 38 | return Price{ 39 | Symbol: symbol, 40 | Multiplier: multiplier, 41 | Px: px, 42 | RequestID: reqID, 43 | ResolveTime: resolveTime, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /chain/oracle/bandchain/oracle/types/constants.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // nolint 4 | const ( 5 | DoNotModify = "[do-not-modify]" 6 | 7 | MaxNameLength = 128 8 | MaxDescriptionLength = 4096 9 | MaxClientIDLength = 128 10 | MaxRequestKeyLength = 128 11 | MaxSchemaLength = 512 12 | MaxURLLength = 128 13 | 14 | MaxExecutableSize = 8 * 1024 // 8kB 15 | MaxWasmCodeSize = 512 * 1024 // 512kB 16 | MaxCompiledWasmCodeSize = 1 * 1024 * 1024 // 1MB 17 | MaxDataSize = 256 // 256B 18 | 19 | MaximumOwasmGas = 20000000 // The half of block gas limit 20 | ) 21 | 22 | // nolint 23 | var ( 24 | DoNotModifyBytes = []byte(DoNotModify) 25 | ) 26 | -------------------------------------------------------------------------------- /chain/oracle/bandchain/oracle/types/id.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | // DataSourceID is the type-safe unique identifier type for data sources. 4 | type DataSourceID int64 5 | 6 | // OracleScriptID is the type-safe unique identifier type for oracle scripts. 7 | type OracleScriptID int64 8 | 9 | // RequestID is the type-safe unique identifier type for data requests. 10 | type RequestID int64 11 | 12 | // ExternalID is the type-safe unique identifier type for raw data requests. 13 | type ExternalID int64 14 | -------------------------------------------------------------------------------- /chain/oracle/types/stork_oracle.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "bytes" 5 | "math/big" 6 | 7 | "github.com/ethereum/go-ethereum/common" 8 | "github.com/ethereum/go-ethereum/common/math" 9 | "github.com/ethereum/go-ethereum/crypto" 10 | 11 | peggytypes "github.com/InjectiveLabs/sdk-go/chain/peggy/types" 12 | ) 13 | 14 | func getMessageHash(publisher common.Address, assetPairID, timeStamp, price string) (hash common.Hash) { 15 | enc := encodePacked(publisher.Bytes(), []byte(assetPairID), encodeUint256(timeStamp), encodeUint256(price)) 16 | 17 | return crypto.Keccak256Hash(enc) 18 | } 19 | 20 | func encodePacked(input ...[]byte) []byte { 21 | return bytes.Join(input, nil) 22 | } 23 | 24 | func encodeUint256(v string) []byte { 25 | bn := new(big.Int) 26 | bn.SetString(v, 10) 27 | return math.U256Bytes(bn) 28 | } 29 | 30 | func VerifyStorkMsgSignature(oraclePubKey common.Address, assetPairID, timeStamp, price string, signature []byte) bool { 31 | hash := getMessageHash(oraclePubKey, assetPairID, timeStamp, price) 32 | 33 | recoveredPubKey, err := peggytypes.EthAddressFromSignature(hash, signature) 34 | if err != nil { 35 | return false 36 | } 37 | 38 | return recoveredPubKey == oraclePubKey 39 | } 40 | -------------------------------------------------------------------------------- /chain/peggy/types/errors.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "cosmossdk.io/errors" 5 | ) 6 | 7 | var ( 8 | ErrInternal = errors.Register(ModuleName, 1, "internal") 9 | ErrDuplicate = errors.Register(ModuleName, 2, "duplicate") 10 | ErrInvalid = errors.Register(ModuleName, 3, "invalid") 11 | ErrTimeout = errors.Register(ModuleName, 4, "timeout") 12 | ErrUnknown = errors.Register(ModuleName, 5, "unknown") 13 | ErrEmpty = errors.Register(ModuleName, 6, "empty") 14 | ErrOutdated = errors.Register(ModuleName, 7, "outdated") 15 | ErrUnsupported = errors.Register(ModuleName, 8, "unsupported") 16 | ErrNonContiguousEventNonce = errors.Register(ModuleName, 9, "non contiguous event nonce") 17 | ErrNoUnbatchedTxsFound = errors.Register(ModuleName, 10, "no unbatched txs found") 18 | ErrResetDelegateKeys = errors.Register(ModuleName, 11, "can not set orchestrator addresses more than once") 19 | ErrSupplyOverflow = errors.Register(ModuleName, 12, "supply cannot exceed max ERC20 value") 20 | ErrInvalidEthSender = errors.Register(ModuleName, 13, "invalid ethereum sender on claim") 21 | ErrInvalidEthDestination = errors.Register(ModuleName, 14, "invalid ethereum destination") 22 | ErrNoLastClaimForValidator = errors.Register(ModuleName, 15, "missing previous claim for validator") 23 | ) 24 | -------------------------------------------------------------------------------- /chain/permissions/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | cdctypes "github.com/cosmos/cosmos-sdk/codec/types" 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec" 8 | // this line is used by starport scaffolding # 1 9 | "github.com/cosmos/cosmos-sdk/types/msgservice" 10 | ) 11 | 12 | const ModuleName = "permissions" 13 | 14 | func RegisterCodec(cdc *codec.LegacyAmino) { 15 | cdc.RegisterConcrete(&MsgUpdateParams{}, "permissions/MsgUpdateParams", nil) 16 | cdc.RegisterConcrete(&MsgCreateNamespace{}, "permissions/MsgCreateNamespace", nil) 17 | cdc.RegisterConcrete(&MsgUpdateNamespace{}, "permissions/MsgUpdateNamespace", nil) 18 | cdc.RegisterConcrete(&MsgClaimVoucher{}, "permissions/MsgClaimVoucher", nil) 19 | } 20 | 21 | func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { 22 | registry.RegisterImplementations((*sdk.Msg)(nil), 23 | &MsgUpdateParams{}, 24 | &MsgCreateNamespace{}, 25 | &MsgUpdateNamespace{}, 26 | &MsgClaimVoucher{}, 27 | ) 28 | 29 | msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) 30 | } 31 | 32 | var ( 33 | ModuleCdc = codec.NewLegacyAmino() 34 | ) 35 | 36 | func init() { 37 | RegisterCodec(ModuleCdc) 38 | // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be 39 | // used to properly serialize MsgGrant and MsgExec instances 40 | sdk.RegisterLegacyAminoCodec(ModuleCdc) 41 | RegisterCodec(authzcdc.Amino) 42 | ModuleCdc.Seal() 43 | } 44 | -------------------------------------------------------------------------------- /chain/txfees/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/codec" 5 | "github.com/cosmos/cosmos-sdk/codec/types" 6 | sdk "github.com/cosmos/cosmos-sdk/types" 7 | "github.com/cosmos/cosmos-sdk/types/msgservice" 8 | authzcdc "github.com/cosmos/cosmos-sdk/x/authz/codec" 9 | ) 10 | 11 | func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { 12 | cdc.RegisterConcrete(&MsgUpdateParams{}, "txfees/MsgUpdateParams", nil) 13 | cdc.RegisterConcrete(&Params{}, "txfees/Params", nil) 14 | } 15 | 16 | func RegisterInterfaces(registry types.InterfaceRegistry) { 17 | registry.RegisterImplementations((*sdk.Msg)(nil), 18 | &MsgUpdateParams{}, 19 | ) 20 | 21 | msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) 22 | } 23 | 24 | var ( 25 | ModuleCdc = codec.NewLegacyAmino() 26 | ) 27 | 28 | func init() { 29 | RegisterLegacyAminoCodec(ModuleCdc) 30 | // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be 31 | // used to properly serialize MsgGrant and MsgExec instances 32 | sdk.RegisterLegacyAminoCodec(ModuleCdc) 33 | RegisterLegacyAminoCodec(authzcdc.Amino) 34 | 35 | ModuleCdc.Seal() 36 | } 37 | -------------------------------------------------------------------------------- /chain/types/codec.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | codectypes "github.com/cosmos/cosmos-sdk/codec/types" 5 | "github.com/cosmos/cosmos-sdk/types" 6 | "github.com/cosmos/cosmos-sdk/types/tx" 7 | authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" 8 | ) 9 | 10 | // RegisterInterfaces registers the tendermint concrete client-related 11 | // implementations and interfaces. 12 | func RegisterInterfaces(registry codectypes.InterfaceRegistry) { 13 | registry.RegisterInterface("injective.types.v1beta1.EthAccount", (*types.AccountI)(nil)) 14 | 15 | registry.RegisterImplementations( 16 | (*types.AccountI)(nil), 17 | &EthAccount{}, 18 | ) 19 | 20 | registry.RegisterImplementations( 21 | (*authtypes.GenesisAccount)(nil), 22 | &EthAccount{}, 23 | ) 24 | 25 | registry.RegisterInterface("injective.types.v1beta1.ExtensionOptionsWeb3Tx", (*tx.TxExtensionOptionI)(nil)) 26 | registry.RegisterImplementations( 27 | (*tx.TxExtensionOptionI)(nil), 28 | &ExtensionOptionsWeb3Tx{}, 29 | ) 30 | } 31 | -------------------------------------------------------------------------------- /chain/types/util.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | func HasDuplicate[T comparable](elements []T) bool { 8 | seen := make(map[T]struct{}) 9 | for idx := range elements { 10 | if _, ok := seen[elements[idx]]; ok { 11 | return true // Duplicate found 12 | } 13 | seen[elements[idx]] = struct{}{} 14 | } 15 | return false 16 | } 17 | 18 | func HasDuplicateCoins(slice []sdk.Coin) bool { 19 | seen := make(map[string]struct{}) 20 | for _, item := range slice { 21 | if _, ok := seen[item.Denom]; ok { 22 | return true 23 | } 24 | seen[item.Denom] = struct{}{} 25 | } 26 | return false 27 | } 28 | -------------------------------------------------------------------------------- /chain/wasmx/types/custom_execution.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "cosmossdk.io/errors" 7 | sdk "github.com/cosmos/cosmos-sdk/types" 8 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" 9 | ) 10 | 11 | type InjectiveExecMsg struct { 12 | ExecutionData ExecutionData `json:"injective_exec"` 13 | } 14 | 15 | type ExecutionData struct { 16 | Origin string `json:"origin"` 17 | Name string `json:"name"` 18 | Args interface{} `json:"args"` 19 | } 20 | 21 | func NewInjectiveExecMsg(origin sdk.AccAddress, data string) (*InjectiveExecMsg, error) { 22 | var e ExecutionData 23 | if err := json.Unmarshal([]byte(data), &e); err != nil { 24 | return nil, errors.Wrap(err, data) 25 | } 26 | 27 | if e.Origin == "" && origin.Empty() { 28 | return nil, errors.Wrap(sdkerrors.ErrInvalidAddress, "origin address is empty") 29 | } 30 | 31 | // override e.Origin for safety 32 | e.Origin = origin.String() 33 | 34 | return &InjectiveExecMsg{ 35 | ExecutionData: e, 36 | }, nil 37 | } 38 | -------------------------------------------------------------------------------- /chain/wasmx/types/errors.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import "cosmossdk.io/errors" 4 | 5 | var ( 6 | ErrInvalidGasLimit = errors.Register(ModuleName, 1, "invalid gas limit") 7 | ErrInvalidGasPrice = errors.Register(ModuleName, 2, "invalid gas price") 8 | ErrInvalidContractAddress = errors.Register(ModuleName, 3, "invalid contract address") 9 | ErrAlreadyRegistered = errors.Register(ModuleName, 4, "contract already registered") 10 | ErrDuplicateContract = errors.Register(ModuleName, 5, "duplicate contract") 11 | ErrNoContractAddresses = errors.Register(ModuleName, 6, "no contract addresses found") 12 | ErrInvalidCodeId = errors.Register(ModuleName, 7, "invalid code id") 13 | ErrDeductingGasFees = errors.Register(ModuleName, 8, "not possible to deduct gas fees") 14 | ErrMissingGranterAddress = errors.Register(ModuleName, 9, "missing granter address") 15 | ErrNoGranterAccount = errors.Register(ModuleName, 10, "granter address does not exist") 16 | ErrInvalidFundingMode = errors.Register(ModuleName, 11, "invalid funding mode") 17 | ) 18 | -------------------------------------------------------------------------------- /chain/wasmx/types/key.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | sdk "github.com/cosmos/cosmos-sdk/types" 5 | ) 6 | 7 | const ( 8 | // ModuleName is set to xwasm and not wasmx to avoid Potential key collision between KVStores 9 | // (see assertNoPrefix in cosmos-sdk/types/store.go) 10 | ModuleName = "xwasm" 11 | StoreKey = ModuleName 12 | TStoreKey = "transient_xwasm" 13 | ) 14 | 15 | var ( 16 | ContractsByGasPricePrefix = []byte{0x01} // key to the smart contract execution request ID 17 | ContractsIndexPrefix = []byte{0x02} 18 | ParamsKey = []byte{0x10} 19 | ) 20 | 21 | func GetContractsByGasPriceKey(gasPrice uint64, address sdk.AccAddress) []byte { 22 | return append(ContractsByGasPricePrefix, getGasPriceAddressInfix(gasPrice, address)...) 23 | } 24 | 25 | func getGasPriceAddressInfix(gasPrice uint64, address sdk.AccAddress) []byte { 26 | return append(sdk.Uint64ToBigEndian(gasPrice), address.Bytes()...) 27 | } 28 | 29 | // GetContractsIndexKey provides the key for the contract address => gasPrice 30 | func GetContractsIndexKey(address sdk.AccAddress) []byte { 31 | return append(ContractsIndexPrefix, address.Bytes()...) 32 | } 33 | -------------------------------------------------------------------------------- /client/chain/tx_factory.go: -------------------------------------------------------------------------------- 1 | package chain 2 | 3 | import ( 4 | "github.com/cosmos/cosmos-sdk/client" 5 | "github.com/cosmos/cosmos-sdk/client/tx" 6 | "github.com/cosmos/cosmos-sdk/types/tx/signing" 7 | ) 8 | 9 | func NewTxFactory(clientCtx client.Context) tx.Factory { 10 | return new(tx.Factory). 11 | WithKeybase(clientCtx.Keyring). 12 | WithTxConfig(clientCtx.TxConfig). 13 | WithAccountRetriever(clientCtx.AccountRetriever). 14 | WithSimulateAndExecute(true). 15 | WithGasAdjustment(1.5). 16 | WithChainID(clientCtx.ChainID). 17 | WithSignMode(signing.SignMode_SIGN_MODE_DIRECT). 18 | WithFromName(clientCtx.GetFromName()) 19 | } 20 | -------------------------------------------------------------------------------- /client/common/api_request_assistant.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "context" 5 | 6 | "google.golang.org/grpc" 7 | "google.golang.org/grpc/metadata" 8 | ) 9 | 10 | type APICall[Q any, R any] func(ctx context.Context, in *Q, opts ...grpc.CallOption) (*R, error) 11 | type APIStreamCall[Q any, S grpc.ClientStream] func(ctx context.Context, in *Q, opts ...grpc.CallOption) (S, error) 12 | 13 | func ExecuteCall[Q any, R any](ctx context.Context, cookieAssistant CookieAssistant, call APICall[Q, R], in *Q) (*R, error) { 14 | var header metadata.MD 15 | localCtx := metadata.NewOutgoingContext(ctx, cookieAssistant.RealMetadata()) 16 | 17 | response, err := call(localCtx, in, grpc.Header(&header)) 18 | 19 | cookieAssistant.ProcessResponseMetadata(header) 20 | 21 | return response, err 22 | } 23 | 24 | func ExecuteStreamCall[Q any, S grpc.ClientStream](ctx context.Context, cookieAssistant CookieAssistant, call APIStreamCall[Q, S], in *Q) (S, error) { 25 | localCtx := metadata.NewOutgoingContext(ctx, cookieAssistant.RealMetadata()) 26 | 27 | stream, callError := call(localCtx, in) 28 | 29 | if callError == nil { 30 | header, err := stream.Header() 31 | if err == nil { 32 | cookieAssistant.ProcessResponseMetadata(header) 33 | } 34 | } 35 | 36 | return stream, callError 37 | } 38 | -------------------------------------------------------------------------------- /client/common/util.go: -------------------------------------------------------------------------------- 1 | package common 2 | 3 | import ( 4 | "encoding/hex" 5 | "strings" 6 | 7 | "github.com/shopspring/decimal" 8 | ) 9 | 10 | func HexToBytes(str string) ([]byte, error) { 11 | str = strings.TrimPrefix(str, "0x") 12 | 13 | data, err := hex.DecodeString(str) 14 | if err != nil { 15 | return nil, err 16 | } 17 | 18 | return data, nil 19 | } 20 | 21 | func RemoveExtraDecimals(value decimal.Decimal, decimalsToRemove int32) decimal.Decimal { 22 | return value.Div(decimal.New(1, decimalsToRemove)) 23 | } 24 | -------------------------------------------------------------------------------- /client/constants.go: -------------------------------------------------------------------------------- 1 | package client 2 | 3 | const ( 4 | DefaultGasPrice = 160000000 5 | InjDenom = "inj" 6 | DefaultGasPriceWithDenom = "160000000inj" 7 | ) 8 | -------------------------------------------------------------------------------- /client/core/token.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import "github.com/shopspring/decimal" 4 | 5 | type Token struct { 6 | Name string 7 | Symbol string 8 | Denom string 9 | Address string 10 | Decimals int32 11 | Logo string 12 | Updated int64 13 | } 14 | 15 | func (t Token) ChainFormattedValue(humanReadableValue decimal.Decimal) decimal.Decimal { 16 | multiplier := decimal.New(1, t.Decimals) 17 | return humanReadableValue.Mul(multiplier) 18 | } 19 | -------------------------------------------------------------------------------- /client/core/token_test.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/huandu/go-assert" 7 | "github.com/shopspring/decimal" 8 | ) 9 | 10 | func createINJToken() Token { 11 | token := Token{ 12 | Name: "Injective Protocol", 13 | Symbol: "INJ", 14 | Denom: "inj", 15 | Address: "0xe28b3B32B6c345A34Ff64674606124Dd5Aceca30", 16 | Decimals: 18, 17 | Logo: "https://static.alchemyapi.io/images/assets/7226.png", 18 | Updated: 1681739137644, 19 | } 20 | 21 | return token 22 | } 23 | 24 | func createUSDTToken() Token { 25 | token := Token{ 26 | Name: "USDT", 27 | Symbol: "USDT", 28 | Denom: "peggy0x87aB3B4C8661e07D6372361211B96ed4Dc36B1B5", 29 | Address: "0x0000000000000000000000000000000000000000", 30 | Decimals: 6, 31 | Logo: "https://static.alchemyapi.io/images/assets/825.png", 32 | Updated: 1681739137645, 33 | } 34 | 35 | return token 36 | } 37 | 38 | func TestChainFormattedValue(t *testing.T) { 39 | value := decimal.RequireFromString("1.3456") 40 | token := createINJToken() 41 | 42 | chainFormattedValue := token.ChainFormattedValue(value) 43 | multiplier := decimal.New(1, int32(token.Decimals)) 44 | expectedValue := value.Mul(multiplier) 45 | 46 | assert.Equal(t, chainFormattedValue, expectedValue) 47 | } 48 | -------------------------------------------------------------------------------- /client/keyring/errors.go: -------------------------------------------------------------------------------- 1 | package keyring 2 | 3 | import "github.com/pkg/errors" 4 | 5 | var ( 6 | ErrCosmosKeyringCreationFailed = errors.New("cosmos keyring creation failed") 7 | ErrCosmosKeyringImportFailed = errors.New("cosmos keyring unable to import key") 8 | ErrDeriveFailed = errors.New("key derivation failed") 9 | ErrFailedToApplyConfigOption = errors.New("failed to apply config option") 10 | ErrFailedToApplyKeyConfigOption = errors.New("failed to apply a key config option") 11 | ErrFilepathIncorrect = errors.New("incorrect filepath") 12 | ErrHexFormatError = errors.New("hex format error") 13 | ErrIncompatibleOptionsProvided = errors.New("incompatible keyring options provided") 14 | ErrInsufficientKeyDetails = errors.New("insufficient cosmos key details provided") 15 | ErrKeyIncompatible = errors.New("provided key is incompatible with requested config") 16 | ErrKeyRecordNotFound = errors.New("key record not found") 17 | ErrPrivkeyConflict = errors.New("privkey conflict") 18 | ErrUnexpectedAddress = errors.New("unexpected address") 19 | ErrMultipleKeysWithDifferentSecurity = errors.New("key security is different: cannot mix keyring with privkeys") 20 | ) 21 | -------------------------------------------------------------------------------- /client/keyring/testdata/keyring-file/263117aad9ebf5759a8272ad2ae4968dd12d4602.address: -------------------------------------------------------------------------------- 1 | eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyNC0wOS0wNyAxMzo0OTowNi42NDcwMjMgKzAyMDAgQ0VTVCBtPSs4MS42NDQ1NDE5MTgiLCJlbmMiOiJBMjU2R0NNIiwicDJjIjo4MTkyLCJwMnMiOiJyY1pRdHMtbzJFaDFGZHhCIn0.-BfYEQoZEiTDwc9fsuLawiEIE_P8Q8KAKhbk3aU0b1-YQv8Brjsihg.bwXK-xKtobJd3mWC.c5rNN9FoqUpnrIjwqU3xPqcgCUgbCF8GgAUibcQfmyYk1MIvbM7aSx1y6ngO0UCRLCZdPhJgxxfBAbPZrbFe7DL4XKn5RfdbPO0a43pN0CHiHu3z86YlPwTS2ADQSta1Zup_ek2boS39GOAgXgC1kYIiox8b1aM_zOvx7M1ASdhnRqMoGu-kYth0FQoocbYRlTF9WMGR40iW-xfSFSYxvoORZDYvfgy8_hIjAYw7bfFkHQ.WWP2VXAeTBZ5L30NTqNbfg -------------------------------------------------------------------------------- /client/keyring/testdata/keyring-file/310322fcb0937ade77a9ba0d128f9e7f17312796.address: -------------------------------------------------------------------------------- 1 | eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyNC0wOS0wNyAxMzo1MzozMi41MjczNjIgKzAyMDAgQ0VTVCBtPSswLjU0NDc3NTc1MSIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjgxOTIsInAycyI6IjhGTDlhUXNlSzVZV2RlblcifQ.cc0WF0wygByoLnNwnrAeFMqRbzFduFelXwQlKVbnYg7Y7sQoVCtVzQ.qC1rIh3zSt9Lfc-V.6MPAr7OMxRwq91SM3o8G43d-NtwTqzCmjoYXFxH2bvYmxA0i2L-EH6-_MzZaR7UBV_wJk130vYM0BIrgyWhWpNIHDf0xATBq6rMhVuhEUP4WLgiQQp_cAR0AJ1qZ2pcJyxCnWpDHSdg1D3vP734H6djM77guObVRmGrk5Xp2eRcC4EEEP1DsF53xHxR_ciH8mq1RO5G5GWmitVPzPrrZGYoD1XQudT300kk3mPGnEUP6uVs-JO4.ER5W3QEeONNz7lUZAAbLIg -------------------------------------------------------------------------------- /client/keyring/testdata/keyring-file/keyhash: -------------------------------------------------------------------------------- 1 | $2a$10$dwTjlfhSfydxZcMd8dqWxOjZ06RgbCv3oCrmrkv8.M6jzKGCzx5r2 -------------------------------------------------------------------------------- /client/keyring/testdata/keyring-file/test.info: -------------------------------------------------------------------------------- 1 | eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyNC0wOS0wNyAxMzo0OTowNi42MzkyNjIgKzAyMDAgQ0VTVCBtPSs4MS42MzY3ODE1NDMiLCJlbmMiOiJBMjU2R0NNIiwicDJjIjo4MTkyLCJwMnMiOiJGMUxoTER3ajhPR2VBRVh0In0.0Sa9gloQcB_4t5RAkS1kgqlCgBu0NwZG_WCHpA7eU3B7bD2zZjKM-A.uLO-mtT3vfO1pJLx.q7FZhW_tKnFTL80UuJU9LPj8T0nFS5UOcy_j23G3UGUs-gstVs9cJEtSNZOCz14-EcsRdJtWm5T9nx0Aauh_48LySQ-LDBbbycH1BJjyEMDhxn8zf0En8uIpZWiWa6vgfeomJE7BY_tRVFnMtzXvFJ69Ky37wFjSKeBac0XaxRc2XsBYUIRJY3xqnni53nvjw55fmyHo5-gBV-OC3ZDX4LmeTQcKw71LCVfGA1oxuk7BQcsYHc2_v2Lxr5rDuoZJl1Do32r63ss2fee85-q0Htjw_unaswZa0KLfMyyMOyRyTPsw0NHik8YjqkGJt9EOfARgu_IFGYoxaTotBBnjbpxOg7dpX4467WnFjkUbXtVFWqEAvIOhRmMbobUqJIPz1Ai5t3jYN-PIKfElgXciXdXPVEVe0j7ABJsNZCFJ11FueRqWhgTw_1B0OWrXjyWQ9TM-Yba9h_v7Cw0AP4lhvk6nm95H_pwYXX_dURj_5w.DUxlLK9M5aJbnHeYmWoHZQ -------------------------------------------------------------------------------- /client/keyring/testdata/keyring-file/test2.info: -------------------------------------------------------------------------------- 1 | eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjcmVhdGVkIjoiMjAyNC0wOS0wNyAxMzo1MzozMi41MTY1MTcgKzAyMDAgQ0VTVCBtPSswLjUzMzkzMDc1MSIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjgxOTIsInAycyI6InFkWl9BbUtFUTg4UE8zb1EifQ.0XmW52t7Bn9bZKbjRLTLz0t8xPkgspFZNpzEgWgWaVUBugjlHqXm3w.mDeWYJuwq7t8UPy9.RDkxLQVylI0V1q1Ibihp73y5EnfqKYAwpQtdAKC9zcTOLVNIziYBjNBfgFKRbNE6q38AZo2_mN4GqH3o-9OwEWlj-qWe0H1EjXVuWqpteaT4EpYC7ZX9uMrk6yQyf_lfniGnL0f5j_hzMl_CVC6lGUgOf6nS1fOxZ-we00rcLNu-3W9ZZreTVwDQG-w2sCV95nreMTmkGd-z8BmgZsDDDB0YB0gnW_TDHVyn3zNi8S3SQxXEgKqXGi5KdsJTBQHkl6fx55LYb4o1sSvgiA8JcNtqtwvARNCq2tLS8ADGMMrrbIPEpmHS69Gd-6UEFpmP8vOeWKwKk52y9ozL___q9yMC-y71DkRpbOcM5zYEBZmStD2gucpYxlEJY5hEVN3szHQZz7MfW8MqiESlRi1-cRCanVDZOl3K6AbRix_F75yMxkWg3OEjwueecsKXFlqzz_Zv8MxMFJQWAYiEloXLZaNPS9GIUrWnALLO2BvySlE2lwf9.yzPjJMAGieybi_UccRHU2w -------------------------------------------------------------------------------- /ethereum/rpc/block.go: -------------------------------------------------------------------------------- 1 | package rpc 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" 8 | "google.golang.org/grpc/metadata" 9 | ) 10 | 11 | // ContextWithHeight wraps a context with the a gRPC block height header. If the provided height is 12 | // 0, it will return an empty context and the gRPC query will use the latest block height for querying. 13 | func ContextWithHeight(height int64) context.Context { 14 | if height == 0 { 15 | return context.Background() 16 | } 17 | 18 | return metadata.AppendToOutgoingContext(context.Background(), grpctypes.GRPCBlockHeightHeader, fmt.Sprintf("%d", height)) 19 | } 20 | -------------------------------------------------------------------------------- /ethereum/util/uniquify.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | // Uniquify is a type of advanced mutex. It allows to create named resource locks. 9 | type Uniquify interface { 10 | // Call executes only one callable with same id at a time. 11 | // Multilpe asynchronous calls with same id will be executed sequentally. 12 | Call(id string, callable func() error) error 13 | } 14 | 15 | // NewUniquify returns a new thread-safe uniquify object. 16 | func NewUniquify() Uniquify { 17 | return &uniquify{ 18 | tasks: make(map[string]*sync.WaitGroup), 19 | } 20 | } 21 | 22 | type uniquify struct { 23 | lock sync.Mutex 24 | tasks map[string]*sync.WaitGroup 25 | } 26 | 27 | func (u *uniquify) Call(id string, callable func() error) error { 28 | var errC = make(chan error) 29 | func() { 30 | u.lock.Lock() 31 | defer u.lock.Unlock() 32 | oldWg := u.tasks[id] 33 | if oldWg != nil { 34 | go func() { 35 | oldWg.Wait() 36 | go func() { 37 | errC <- u.Call(id, callable) 38 | }() 39 | }() 40 | return 41 | } 42 | wg := new(sync.WaitGroup) 43 | wg.Add(1) 44 | u.tasks[id] = wg 45 | 46 | go func() { 47 | var err error 48 | defer func() { 49 | errC <- err 50 | 51 | u.lock.Lock() 52 | defer u.lock.Unlock() 53 | delete(u.tasks, id) 54 | }() 55 | defer wg.Done() 56 | defer func(err *error) { 57 | if panicData := recover(); panicData != nil { 58 | if e, ok := panicData.(error); ok { 59 | *err = e 60 | return 61 | } 62 | *err = fmt.Errorf("%+v", panicData) 63 | } 64 | }(&err) 65 | err = callable() 66 | }() 67 | }() 68 | 69 | return <-errC 70 | } 71 | -------------------------------------------------------------------------------- /ethereum/util/uniquify_test.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "testing" 4 | 5 | func TestNewUniquify(t *testing.T) { 6 | u := NewUniquify() 7 | err := u.Call("kek", func() error { 8 | return nil 9 | }) 10 | if err != nil { 11 | t.Fatal(err) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /examples/chain/10_StreamEventOrderbookUpdate/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/InjectiveLabs/sdk-go/client" 7 | 8 | exchangetypes "github.com/InjectiveLabs/sdk-go/chain/exchange/types" 9 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("mainnet", "lb") 15 | 16 | clientCtx, err := chainclient.NewClientContext( 17 | network.ChainId, 18 | "", 19 | nil, 20 | ) 21 | if err != nil { 22 | panic(err) 23 | } 24 | 25 | chainClient, err := chainclient.NewChainClient( 26 | clientCtx, 27 | network, 28 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 29 | ) 30 | 31 | if err != nil { 32 | panic(err) 33 | } 34 | 35 | //0x74b17b0d6855feba39f1f7ab1e8bad0363bd510ee1dcc74e40c2adfe1502f781 36 | //0x74ee114ad750f8429a97e07b5e73e145724e9b21670a7666625ddacc03d6758d 37 | //0x26413a70c9b78a495023e5ab8003c9cf963ef963f6755f8b57255feb5744bf31 38 | marketIds := []string{ 39 | "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0", 40 | } 41 | 42 | orderbookCh := make(chan exchangetypes.Orderbook, 10000) 43 | go chainClient.StreamOrderbookUpdateEvents(chainclient.SpotOrderbook, marketIds, orderbookCh) 44 | for { 45 | ob := <-orderbookCh 46 | fmt.Println(ob) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/chain/7_GetBlock/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client/common" 8 | tmclient "github.com/InjectiveLabs/sdk-go/client/tm" 9 | ) 10 | 11 | func main() { 12 | network := common.LoadNetwork("testnet", "lb") 13 | tmClient := tmclient.NewRPCClient(network.TmEndpoint) 14 | clientCtx, cancelFn := context.WithCancel(context.Background()) 15 | defer cancelFn() 16 | 17 | res, err := tmClient.GetBlock(clientCtx, 15478013) 18 | if err != nil { 19 | fmt.Println(err) 20 | } 21 | 22 | fmt.Println(res.Block.Txs) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /examples/chain/9_StreamEventOrderFail/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/InjectiveLabs/sdk-go/client" 7 | 8 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 9 | "github.com/InjectiveLabs/sdk-go/client/common" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("mainnet", "lb") 14 | 15 | clientCtx, err := chainclient.NewClientContext( 16 | network.ChainId, 17 | "", 18 | nil, 19 | ) 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | chainClient, err := chainclient.NewChainClient( 25 | clientCtx, 26 | network, 27 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 28 | ) 29 | 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | failEventCh := make(chan map[string]uint, 10000) 35 | go chainClient.StreamEventOrderFail("inj1rwv4zn3jptsqs7l8lpa3uvzhs57y8duemete9e", failEventCh) 36 | for { 37 | e := <-failEventCh 38 | fmt.Println(e) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/chain/distribution/query/9_CommunityPool/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchCommunityPool(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/31_Positions/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchChainPositions(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/3_ExchangeBalances/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchExchangeBalances(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/41_TradeRewardCampaign/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchTradeRewardCampaign(ctx) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | str, _ := json.MarshalIndent(res, "", " ") 66 | fmt.Print(string(str)) 67 | 68 | } 69 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/43_FeeDiscountSchedule/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchFeeDiscountSchedule(ctx) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | str, _ := json.MarshalIndent(res, "", " ") 66 | fmt.Print(string(str)) 67 | 68 | } 69 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/44_BalanceMismatches/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchBalanceMismatches(ctx, 1) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | str, _ := json.MarshalIndent(res, "", " ") 66 | fmt.Print(string(str)) 67 | 68 | } 69 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/45_BalanceWithBalanceHolds/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchBalanceWithBalanceHolds(ctx) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | str, _ := json.MarshalIndent(res, "", " ") 66 | fmt.Print(string(str)) 67 | 68 | } 69 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/46_FeeDiscountTierStatistics/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchFeeDiscountTierStatistics(ctx) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | str, _ := json.MarshalIndent(res, "", " ") 66 | fmt.Print(string(str)) 67 | 68 | } 69 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/47_MitoVaultInfos/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchMitoVaultInfos(ctx) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | str, _ := json.MarshalIndent(res, "", " ") 66 | fmt.Print(string(str)) 67 | 68 | } 69 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/51_OptedOutOfRewardsAccounts/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchOptedOutOfRewardsAccounts(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/59_MarketBalances/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "os" 9 | 10 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 11 | 12 | "github.com/InjectiveLabs/sdk-go/client" 13 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 14 | "github.com/InjectiveLabs/sdk-go/client/common" 15 | ) 16 | 17 | func main() { 18 | network := common.LoadNetwork("testnet", "lb") 19 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 25 | os.Getenv("HOME")+"/.injectived", 26 | "injectived", 27 | "file", 28 | "inj-user", 29 | "12345678", 30 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 31 | false, 32 | ) 33 | 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | clientCtx, err := chainclient.NewClientContext( 39 | network.ChainId, 40 | senderAddress.String(), 41 | cosmosKeyring, 42 | ) 43 | 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 49 | 50 | chainClient, err := chainclient.NewChainClient( 51 | clientCtx, 52 | network, 53 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 54 | ) 55 | 56 | res, err := chainClient.FetchMarketBalances(context.Background()) 57 | if err != nil { 58 | log.Fatalf("Failed to fetch market balances: %v", err) 59 | } 60 | 61 | str, _ := json.MarshalIndent(res, "", " ") 62 | fmt.Print(string(str)) 63 | } 64 | -------------------------------------------------------------------------------- /examples/chain/exchange/query/61_DenomMinNotionals/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "os" 9 | 10 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 11 | 12 | "github.com/InjectiveLabs/sdk-go/client" 13 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 14 | "github.com/InjectiveLabs/sdk-go/client/common" 15 | ) 16 | 17 | func main() { 18 | network := common.LoadNetwork("devnet", "lb") 19 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 25 | os.Getenv("HOME")+"/.injectived", 26 | "injectived", 27 | "file", 28 | "inj-user", 29 | "12345678", 30 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 31 | false, 32 | ) 33 | 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | clientCtx, err := chainclient.NewClientContext( 39 | network.ChainId, 40 | senderAddress.String(), 41 | cosmosKeyring, 42 | ) 43 | 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 49 | 50 | chainClient, err := chainclient.NewChainClient( 51 | clientCtx, 52 | network, 53 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 54 | ) 55 | 56 | res, err := chainClient.FetchDenomMinNotionals(context.Background()) 57 | if err != nil { 58 | log.Fatalf("Failed to fetch denoms min notionals: %v", err) 59 | } 60 | 61 | str, _ := json.MarshalIndent(res, "", " ") 62 | fmt.Print(string(str)) 63 | } 64 | -------------------------------------------------------------------------------- /examples/chain/ibc/channel/query/4_ChannelClientState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client" 8 | 9 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 12 | 13 | "os" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | portId := "transfer" 60 | channelId := "channel-126" 61 | ctx := context.Background() 62 | 63 | res, err := chainClient.FetchIBCChannelClientState(ctx, portId, channelId) 64 | if err != nil { 65 | fmt.Println(err) 66 | } 67 | 68 | fmt.Print(res) 69 | 70 | } 71 | -------------------------------------------------------------------------------- /examples/chain/ibc/client/query/1_ClientState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client" 8 | 9 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 12 | 13 | "os" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | clientId := "07-tendermint-0" 60 | ctx := context.Background() 61 | 62 | res, err := chainClient.FetchIBCClientState(ctx, clientId) 63 | if err != nil { 64 | fmt.Println(err) 65 | } 66 | 67 | fmt.Print(res) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/ibc/client/query/7_ClientParams/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client" 9 | 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | 14 | "os" 15 | ) 16 | 17 | func main() { 18 | network := common.LoadNetwork("testnet", "lb") 19 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 25 | os.Getenv("HOME")+"/.injectived", 26 | "injectived", 27 | "file", 28 | "inj-user", 29 | "12345678", 30 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 31 | false, 32 | ) 33 | 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | clientCtx, err := chainclient.NewClientContext( 39 | network.ChainId, 40 | senderAddress.String(), 41 | cosmosKeyring, 42 | ) 43 | 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 49 | 50 | chainClient, err := chainclient.NewChainClient( 51 | clientCtx, 52 | network, 53 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 54 | ) 55 | 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | ctx := context.Background() 61 | 62 | res, err := chainClient.FetchIBCClientParams(ctx) 63 | if err != nil { 64 | fmt.Println(err) 65 | } 66 | 67 | str, _ := json.MarshalIndent(res, "", " ") 68 | fmt.Print(string(str)) 69 | 70 | } 71 | -------------------------------------------------------------------------------- /examples/chain/ibc/client/query/8_UpgradedClientState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client" 9 | 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | 14 | "os" 15 | ) 16 | 17 | func main() { 18 | network := common.LoadNetwork("testnet", "lb") 19 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 25 | os.Getenv("HOME")+"/.injectived", 26 | "injectived", 27 | "file", 28 | "inj-user", 29 | "12345678", 30 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 31 | false, 32 | ) 33 | 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | clientCtx, err := chainclient.NewClientContext( 39 | network.ChainId, 40 | senderAddress.String(), 41 | cosmosKeyring, 42 | ) 43 | 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 49 | 50 | chainClient, err := chainclient.NewChainClient( 51 | clientCtx, 52 | network, 53 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 54 | ) 55 | 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | ctx := context.Background() 61 | 62 | res, err := chainClient.FetchIBCUpgradedClientState(ctx) 63 | if err != nil { 64 | fmt.Println(err) 65 | } 66 | 67 | str, _ := json.MarshalIndent(res, "", " ") 68 | fmt.Print(string(str)) 69 | 70 | } 71 | -------------------------------------------------------------------------------- /examples/chain/ibc/client/query/9_UpgradedConsensusState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client" 9 | 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | 14 | "os" 15 | ) 16 | 17 | func main() { 18 | network := common.LoadNetwork("testnet", "lb") 19 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 25 | os.Getenv("HOME")+"/.injectived", 26 | "injectived", 27 | "file", 28 | "inj-user", 29 | "12345678", 30 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 31 | false, 32 | ) 33 | 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | clientCtx, err := chainclient.NewClientContext( 39 | network.ChainId, 40 | senderAddress.String(), 41 | cosmosKeyring, 42 | ) 43 | 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 49 | 50 | chainClient, err := chainclient.NewChainClient( 51 | clientCtx, 52 | network, 53 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 54 | ) 55 | 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | ctx := context.Background() 61 | 62 | res, err := chainClient.FetchIBCUpgradedConsensusState(ctx) 63 | if err != nil { 64 | fmt.Println(err) 65 | } 66 | 67 | str, _ := json.MarshalIndent(res, "", " ") 68 | fmt.Print(string(str)) 69 | 70 | } 71 | -------------------------------------------------------------------------------- /examples/chain/ibc/connection/query/4_ConnectionClientState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client" 8 | 9 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 12 | 13 | "os" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | connectionId := "connection-0" 60 | ctx := context.Background() 61 | 62 | res, err := chainClient.FetchIBCConnectionClientState(ctx, connectionId) 63 | if err != nil { 64 | fmt.Println(err) 65 | } 66 | 67 | fmt.Print(res) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/ibc/connection/query/6_ConnectionParams/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client" 9 | 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | 14 | "os" 15 | ) 16 | 17 | func main() { 18 | network := common.LoadNetwork("testnet", "lb") 19 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 20 | if err != nil { 21 | panic(err) 22 | } 23 | 24 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 25 | os.Getenv("HOME")+"/.injectived", 26 | "injectived", 27 | "file", 28 | "inj-user", 29 | "12345678", 30 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 31 | false, 32 | ) 33 | 34 | if err != nil { 35 | panic(err) 36 | } 37 | 38 | clientCtx, err := chainclient.NewClientContext( 39 | network.ChainId, 40 | senderAddress.String(), 41 | cosmosKeyring, 42 | ) 43 | 44 | if err != nil { 45 | panic(err) 46 | } 47 | 48 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 49 | 50 | chainClient, err := chainclient.NewChainClient( 51 | clientCtx, 52 | network, 53 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 54 | ) 55 | 56 | if err != nil { 57 | panic(err) 58 | } 59 | 60 | ctx := context.Background() 61 | 62 | res, err := chainClient.FetchIBCConnectionParams(ctx) 63 | if err != nil { 64 | fmt.Println(err) 65 | } 66 | 67 | str, _ := json.MarshalIndent(res, "", " ") 68 | fmt.Print(string(str)) 69 | 70 | } 71 | -------------------------------------------------------------------------------- /examples/chain/ofac/1_DownloadOfacList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 5 | ) 6 | 7 | func main() { 8 | err := chainclient.DownloadOfacList() 9 | if err != nil { 10 | panic(err) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /examples/chain/permissions/query/12_PermissionsModuleState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("devnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchPermissionsModuleState(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/permissions/query/1_NamespaceDenoms/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("devnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchPermissionsNamespaceDenoms(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/permissions/query/2_Namespaces/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("devnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchPermissionsNamespaces(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/tendermint/query/1_GetNodeInfo/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchNodeInfo(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/tendermint/query/2_GetSyncing/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchSyncing(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/tendermint/query/3_GetLatestBlock/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchLatestBlock(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/tendermint/query/5_GetLatestValidatorSet/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | ctx := context.Background() 59 | 60 | res, err := chainClient.FetchLatestValidatorSet(ctx) 61 | if err != nil { 62 | fmt.Println(err) 63 | } 64 | 65 | fmt.Print(res.String()) 66 | 67 | } 68 | -------------------------------------------------------------------------------- /examples/chain/tokenfactory/query/3_TokenfactoryModuleState/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchTokenfactoryModuleState(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/txfees/query/1_GetEipBaseFee/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "os" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client" 11 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 12 | "github.com/InjectiveLabs/sdk-go/client/common" 13 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 14 | ) 15 | 16 | func main() { 17 | network := common.LoadNetwork("testnet", "lb") 18 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 24 | os.Getenv("HOME")+"/.injectived", 25 | "injectived", 26 | "file", 27 | "inj-user", 28 | "12345678", 29 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 30 | false, 31 | ) 32 | 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | clientCtx, err := chainclient.NewClientContext( 38 | network.ChainId, 39 | senderAddress.String(), 40 | cosmosKeyring, 41 | ) 42 | 43 | if err != nil { 44 | panic(err) 45 | } 46 | 47 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 48 | 49 | chainClient, err := chainclient.NewChainClient( 50 | clientCtx, 51 | network, 52 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 53 | ) 54 | 55 | if err != nil { 56 | panic(err) 57 | } 58 | 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchEipBaseFee(ctx) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/chain/wasm/query/7_SmartContractCode/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "os" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client" 10 | chainclient "github.com/InjectiveLabs/sdk-go/client/chain" 11 | "github.com/InjectiveLabs/sdk-go/client/common" 12 | rpchttp "github.com/cometbft/cometbft/rpc/client/http" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | tmClient, err := rpchttp.New(network.TmEndpoint, "/websocket") 18 | if err != nil { 19 | panic(err) 20 | } 21 | 22 | senderAddress, cosmosKeyring, err := chainclient.InitCosmosKeyring( 23 | os.Getenv("HOME")+"/.injectived", 24 | "injectived", 25 | "file", 26 | "inj-user", 27 | "12345678", 28 | "5d386fbdbf11f1141010f81a46b40f94887367562bd33b452bbaa6ce1cd1381e", // keyring will be used if pk not provided 29 | false, 30 | ) 31 | 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | clientCtx, err := chainclient.NewClientContext( 37 | network.ChainId, 38 | senderAddress.String(), 39 | cosmosKeyring, 40 | ) 41 | 42 | if err != nil { 43 | panic(err) 44 | } 45 | 46 | clientCtx = clientCtx.WithNodeURI(network.TmEndpoint).WithClient(tmClient) 47 | 48 | chainClient, err := chainclient.NewChainClient( 49 | clientCtx, 50 | network, 51 | common.OptionGasPrices(client.DefaultGasPriceWithDenom), 52 | ) 53 | 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | codeId := uint64(290) 59 | ctx := context.Background() 60 | 61 | res, err := chainClient.FetchCode(ctx, codeId) 62 | if err != nil { 63 | fmt.Println(err) 64 | } 65 | 66 | str, _ := json.MarshalIndent(res, "", " ") 67 | fmt.Print(string(str)) 68 | 69 | } 70 | -------------------------------------------------------------------------------- /examples/exchange/accounts/1_StreamSubaccountBalance/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | subaccountId := "0x1b99514e320ae0087be7f87b1e3057853c43b799000000000000000000000000" 22 | stream, err := exchangeClient.StreamSubaccountBalance(ctx, subaccountId) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | for { 28 | select { 29 | case <-ctx.Done(): 30 | return 31 | default: 32 | res, err := stream.Recv() 33 | if err != nil { 34 | fmt.Println(err) 35 | return 36 | } 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/accounts/2_SubaccountBalance/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("mainnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 21 | denom := "inj" 22 | res, err := exchangeClient.GetSubaccountBalance(ctx, subaccountId, denom) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/accounts/3_SubaccountsList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | accountAddress := "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" 21 | res, err := exchangeClient.GetSubaccountsList(ctx, accountAddress) 22 | if err != nil { 23 | fmt.Println(err) 24 | } 25 | 26 | str, _ := json.MarshalIndent(res, "", " ") 27 | fmt.Print(string(str)) 28 | } 29 | -------------------------------------------------------------------------------- /examples/exchange/accounts/4_SubaccountBalancesList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 21 | res, err := exchangeClient.GetSubaccountBalancesList(ctx, subaccountId) 22 | if err != nil { 23 | fmt.Println(err) 24 | } 25 | 26 | str, _ := json.MarshalIndent(res, "", " ") 27 | fmt.Print(string(str)) 28 | } 29 | -------------------------------------------------------------------------------- /examples/exchange/accounts/5_SubaccountHistory/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | denom := "inj" 22 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 23 | transferTypes := []string{"deposit"} 24 | skip := uint64(0) 25 | limit := int32(10) 26 | 27 | req := accountPB.SubaccountHistoryRequest{ 28 | Denom: denom, 29 | SubaccountId: subaccountId, 30 | TransferTypes: transferTypes, 31 | Skip: skip, 32 | Limit: limit, 33 | } 34 | 35 | res, err := exchangeClient.GetSubaccountHistory(ctx, &req) 36 | if err != nil { 37 | fmt.Println(err) 38 | } 39 | 40 | str, _ := json.MarshalIndent(res, "", " ") 41 | fmt.Print(string(str)) 42 | } 43 | -------------------------------------------------------------------------------- /examples/exchange/accounts/6_SubaccountOrderSummary/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client/common" 8 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 9 | accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 21 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 22 | orderDirection := "buy" 23 | 24 | req := accountPB.SubaccountOrderSummaryRequest{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | OrderDirection: orderDirection, 28 | } 29 | 30 | res, err := exchangeClient.GetSubaccountOrderSummary(ctx, &req) 31 | if err != nil { 32 | fmt.Println(err) 33 | } 34 | 35 | fmt.Println("spot orders:", res.SpotOrdersTotal) 36 | fmt.Println("derivative orders:", res.DerivativeOrdersTotal) 37 | } 38 | -------------------------------------------------------------------------------- /examples/exchange/accounts/7_OrderStates/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | spotOrderHashes := []string{"0x0b156df549747187210ca5381f0291f179d76d613d0bae1a3c4fd2e3c0504b7c"} 22 | derivativeOrderHashes := []string{"0x82113f3998999bdc3892feaab2c4e53ba06c5fe887a2d5f9763397240f24da50"} 23 | 24 | req := accountPB.OrderStatesRequest{ 25 | SpotOrderHashes: spotOrderHashes, 26 | DerivativeOrderHashes: derivativeOrderHashes, 27 | } 28 | 29 | res, err := exchangeClient.GetOrderStates(ctx, &req) 30 | if err != nil { 31 | fmt.Println(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/exchange/accounts/8_Portfolio/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | accountAddress := "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" 21 | res, err := exchangeClient.GetPortfolio(ctx, accountAddress) 22 | if err != nil { 23 | fmt.Println(err) 24 | } 25 | 26 | str, _ := json.MarshalIndent(res, "", " ") 27 | fmt.Print(string(str)) 28 | } 29 | -------------------------------------------------------------------------------- /examples/exchange/accounts/9_Rewards/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | accountAddress := "inj1rwv4zn3jptsqs7l8lpa3uvzhs57y8duemete9e" 22 | epoch := int64(1) 23 | 24 | req := accountPB.RewardsRequest{ 25 | Epoch: epoch, 26 | AccountAddress: accountAddress, 27 | } 28 | 29 | res, err := exchangeClient.GetRewards(ctx, &req) 30 | if err != nil { 31 | fmt.Println(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/exchange/auction/1_Auction/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | round := int64(35) 21 | res, err := exchangeClient.GetAuction(ctx, round) 22 | if err != nil { 23 | fmt.Println(err) 24 | } 25 | 26 | str, _ := json.MarshalIndent(res, "", " ") 27 | fmt.Print(string(str)) 28 | } 29 | -------------------------------------------------------------------------------- /examples/exchange/auction/2_Auctions/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | res, err := exchangeClient.GetAuctions(ctx) 21 | if err != nil { 22 | fmt.Println(err) 23 | } 24 | 25 | str, _ := json.MarshalIndent(res, "", " ") 26 | fmt.Print(string(str)) 27 | } 28 | -------------------------------------------------------------------------------- /examples/exchange/auction/3_StreamBids/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | 21 | stream, err := exchangeClient.StreamBids(ctx) 22 | if err != nil { 23 | panic(err) 24 | } 25 | 26 | for { 27 | select { 28 | case <-ctx.Done(): 29 | return 30 | default: 31 | res, err := stream.Recv() 32 | if err != nil { 33 | fmt.Println(err) 34 | return 35 | } 36 | str, _ := json.MarshalIndent(res, "", " ") 37 | fmt.Print(string(str)) 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /examples/exchange/auction/4_InjBurntEndpoint/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "time" 8 | 9 | "github.com/InjectiveLabs/sdk-go/client/common" 10 | "github.com/InjectiveLabs/sdk-go/client/exchange" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchange.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 21 | defer cancel() 22 | 23 | // Fetch INJ burnt details 24 | injBurntResponse, err := exchangeClient.FetchInjBurnt(ctx) 25 | if err != nil { 26 | fmt.Printf("Failed to fetch INJ burnt details: %v\n", err) 27 | return 28 | } 29 | 30 | // Print JSON representation of the response 31 | jsonResponse, err := json.MarshalIndent(injBurntResponse, "", " ") 32 | if err != nil { 33 | fmt.Printf("Failed to marshal response to JSON: %v\n", err) 34 | return 35 | } 36 | 37 | fmt.Println("INJ Burnt Details:") 38 | fmt.Println(string(jsonResponse)) 39 | } 40 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/10_StreamPositions/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | 24 | req := derivativeExchangePB.StreamPositionsV2Request{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | stream, err := exchangeClient.StreamDerivativePositionsV2(ctx, &req) 29 | if err != nil { 30 | panic(err) 31 | } 32 | 33 | for { 34 | select { 35 | case <-ctx.Done(): 36 | return 37 | default: 38 | res, err := stream.Recv() 39 | if err != nil { 40 | panic(err) 41 | return 42 | } 43 | str, _ := json.MarshalIndent(res, "", " ") 44 | fmt.Print(string(str)) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/11_StreamOrders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | orderSide := "buy" 24 | 25 | req := derivativeExchangePB.StreamOrdersRequest{ 26 | MarketId: marketId, 27 | SubaccountId: subaccountId, 28 | OrderSide: orderSide, 29 | } 30 | stream, err := exchangeClient.StreamDerivativeOrders(ctx, &req) 31 | if err != nil { 32 | panic(err) 33 | } 34 | 35 | for { 36 | select { 37 | case <-ctx.Done(): 38 | return 39 | default: 40 | res, err := stream.Recv() 41 | if err != nil { 42 | panic(err) 43 | return 44 | } 45 | str, _ := json.MarshalIndent(res, "", " ") 46 | fmt.Print(string(str)) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/12_Trades/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | 24 | req := derivativeExchangePB.TradesRequest{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | 29 | res, err := exchangeClient.GetDerivativeTrades(ctx, &req) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/13_StreamTrades/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 23 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 24 | 25 | req := derivativeExchangePB.StreamTradesRequest{ 26 | MarketId: marketId, 27 | SubaccountId: subaccountId, 28 | } 29 | stream, err := exchangeClient.StreamDerivativeTrades(ctx, &req) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | for { 35 | select { 36 | case <-ctx.Done(): 37 | return 38 | default: 39 | res, err := stream.Recv() 40 | if err != nil { 41 | panic(err) 42 | return 43 | } 44 | str, _ := json.MarshalIndent(res, "", " ") 45 | fmt.Print(string(str)) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/14_SubaccountOrdersList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 23 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 24 | skip := uint64(0) 25 | limit := int32(10) 26 | 27 | req := derivativeExchangePB.SubaccountOrdersListRequest{ 28 | MarketId: marketId, 29 | SubaccountId: subaccountId, 30 | Skip: skip, 31 | Limit: limit, 32 | } 33 | 34 | res, err := exchangeClient.GetSubaccountDerivativeOrdersList(ctx, &req) 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | str, _ := json.MarshalIndent(res, "", " ") 40 | fmt.Print(string(str)) 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/15_SubaccountTradesList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 23 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 24 | skip := uint64(0) 25 | limit := int32(10) 26 | 27 | req := derivativeExchangePB.SubaccountTradesListRequest{ 28 | MarketId: marketId, 29 | SubaccountId: subaccountId, 30 | Skip: skip, 31 | Limit: limit, 32 | } 33 | 34 | res, err := exchangeClient.GetSubaccountDerivativeTradesList(ctx, &req) 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | str, _ := json.MarshalIndent(res, "", " ") 40 | fmt.Print(string(str)) 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/16_FundingPayments/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 23 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 24 | 25 | req := derivativeExchangePB.FundingPaymentsRequest{ 26 | MarketId: marketId, 27 | SubaccountId: subaccountId, 28 | } 29 | 30 | res, err := exchangeClient.GetDerivativeFundingPayments(ctx, &req) 31 | if err != nil { 32 | panic(err) 33 | } 34 | 35 | str, _ := json.MarshalIndent(res, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/17_FundingRates/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 23 | 24 | req := derivativeExchangePB.FundingRatesRequest{ 25 | MarketId: marketId, 26 | } 27 | 28 | res, err := exchangeClient.GetDerivativeFundingRates(ctx, &req) 29 | if err != nil { 30 | panic(err) 31 | } 32 | 33 | str, _ := json.MarshalIndent(res, "", " ") 34 | fmt.Print(string(str)) 35 | } 36 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/18_HistoricalOrders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" 22 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 23 | skip := uint64(0) 24 | limit := int32(10) 25 | isConditional := "false" 26 | 27 | req := derivativeExchangePB.OrdersHistoryRequest{ 28 | SubaccountId: subaccountId, 29 | MarketId: marketId, 30 | Skip: skip, 31 | Limit: limit, 32 | IsConditional: isConditional, 33 | } 34 | 35 | res, err := exchangeClient.GetHistoricalDerivativeOrders(ctx, &req) 36 | if err != nil { 37 | panic(err) 38 | } 39 | 40 | str, _ := json.MarshalIndent(res, "", " ") 41 | fmt.Print(string(str)) 42 | } 43 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/19_StreamHistoricalOrders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | direction := "buy" 24 | 25 | req := derivativeExchangePB.StreamOrdersHistoryRequest{ 26 | MarketId: marketId, 27 | SubaccountId: subaccountId, 28 | Direction: direction, 29 | } 30 | stream, err := exchangeClient.StreamHistoricalDerivativeOrders(ctx, &req) 31 | if err != nil { 32 | panic(err) 33 | } 34 | 35 | for { 36 | select { 37 | case <-ctx.Done(): 38 | return 39 | default: 40 | res, err := stream.Recv() 41 | if err != nil { 42 | panic(err) 43 | return 44 | } 45 | str, _ := json.MarshalIndent(res, "", " ") 46 | fmt.Print(string(str)) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/1_Market/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 22 | res, err := exchangeClient.GetDerivativeMarket(ctx, marketId) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/20_LiquidablePositions/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | //marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" 22 | skip := uint64(0) 23 | limit := int32(10) 24 | 25 | req := derivativeExchangePB.LiquidablePositionsRequest{ 26 | //MarketId: marketId, 27 | Skip: skip, 28 | Limit: limit, 29 | } 30 | 31 | res, err := exchangeClient.GetDerivativeLiquidablePositions(ctx, &req) 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | str, _ := json.MarshalIndent(res, "", " ") 37 | fmt.Print(string(str)) 38 | } 39 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/21_TradesV2/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | 24 | req := derivativeExchangePB.TradesV2Request{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | 29 | res, err := exchangeClient.GetDerivativeTradesV2(ctx, &req) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/22_StreamTradesV2/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | 24 | req := derivativeExchangePB.StreamTradesV2Request{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | stream, err := exchangeClient.StreamDerivativeV2Trades(ctx, &req) 29 | if err != nil { 30 | panic(err) 31 | } 32 | 33 | for { 34 | select { 35 | case <-ctx.Done(): 36 | return 37 | default: 38 | res, err := stream.Recv() 39 | if err != nil { 40 | panic(err) 41 | return 42 | } 43 | str, _ := json.MarshalIndent(res, "", " ") 44 | fmt.Print(string(str)) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/2_Markets/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("mainnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketStatus := "active" 23 | quoteDenom := "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7" 24 | 25 | req := derivativeExchangePB.MarketsRequest{ 26 | MarketStatus: marketStatus, 27 | QuoteDenom: quoteDenom, 28 | } 29 | 30 | res, err := exchangeClient.GetDerivativeMarkets(ctx, &req) 31 | if err != nil { 32 | panic(err) 33 | } 34 | 35 | str, _ := json.MarshalIndent(res, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/3_StreamMarket/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketIds := []string{"0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce"} 22 | stream, err := exchangeClient.StreamDerivativeMarket(ctx, marketIds) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | for { 28 | select { 29 | case <-ctx.Done(): 30 | return 31 | default: 32 | res, err := stream.Recv() 33 | if err != nil { 34 | panic(err) 35 | return 36 | } 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/4_Orderbook/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" 22 | res, err := exchangeClient.GetDerivativeOrderbookV2(ctx, marketId) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/5_Orderbooks/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketIds := []string{"0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce"} 22 | res, err := exchangeClient.GetDerivativeOrderbooksV2(ctx, marketIds) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/6_StreamOrderbook/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client/common" 8 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 9 | ) 10 | 11 | func main() { 12 | network := common.LoadNetwork("devnet-1", "") 13 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 14 | if err != nil { 15 | panic(err) 16 | } 17 | 18 | ctx := context.Background() 19 | marketIds := []string{"0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce"} 20 | stream, err := exchangeClient.StreamDerivativeOrderbookV2(ctx, marketIds) 21 | if err != nil { 22 | panic(err) 23 | } 24 | 25 | for { 26 | select { 27 | case <-ctx.Done(): 28 | return 29 | default: 30 | res, err := stream.Recv() 31 | if err != nil { 32 | fmt.Println(err) 33 | return 34 | } 35 | fmt.Println(res.MarketId, len(res.Orderbook.Sells), len(res.Orderbook.Buys)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/8_Positions/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6" 23 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 24 | skip := uint64(0) 25 | limit := int32(10) 26 | 27 | req := derivativeExchangePB.PositionsV2Request{ 28 | MarketId: marketId, 29 | SubaccountId: subaccountId, 30 | Skip: skip, 31 | Limit: limit, 32 | } 33 | 34 | res, err := exchangeClient.GetDerivativePositionsV2(ctx, &req) 35 | if err != nil { 36 | panic(err) 37 | } 38 | 39 | str, _ := json.MarshalIndent(res, "", " ") 40 | fmt.Print(string(str)) 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/derivatives/9_Orders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | derivativeExchangePB "github.com/InjectiveLabs/sdk-go/exchange/derivative_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" 23 | skip := uint64(0) 24 | limit := int32(10) 25 | 26 | req := derivativeExchangePB.OrdersRequest{ 27 | MarketId: marketId, 28 | Skip: skip, 29 | Limit: limit, 30 | } 31 | 32 | res, err := exchangeClient.GetDerivativeOrders(ctx, &req) 33 | if err != nil { 34 | panic(err) 35 | } 36 | 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | -------------------------------------------------------------------------------- /examples/exchange/insurance/1_InsuranceFunds/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | insurancePB "github.com/InjectiveLabs/sdk-go/exchange/insurance_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := insurancePB.FundsRequest{} 24 | 25 | res, err := exchangeClient.GetInsuranceFunds(ctx, &req) 26 | if err != nil { 27 | fmt.Println(err) 28 | } 29 | 30 | str, _ := json.MarshalIndent(res, "", " ") 31 | fmt.Print(string(str)) 32 | } 33 | -------------------------------------------------------------------------------- /examples/exchange/insurance/2_Redemptions/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | insurancePB "github.com/InjectiveLabs/sdk-go/exchange/insurance_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := insurancePB.RedemptionsRequest{} 24 | 25 | res, err := exchangeClient.GetRedemptions(ctx, &req) 26 | if err != nil { 27 | fmt.Println(err) 28 | } 29 | 30 | str, _ := json.MarshalIndent(res, "", " ") 31 | fmt.Print(string(str)) 32 | } 33 | -------------------------------------------------------------------------------- /examples/exchange/meta/1_Ping/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | metaPB "github.com/InjectiveLabs/sdk-go/exchange/meta_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := metaPB.PingRequest{} 24 | 25 | res, err := exchangeClient.Ping(ctx, &req) 26 | if err != nil { 27 | fmt.Println(err) 28 | } 29 | 30 | str, _ := json.MarshalIndent(res, "", " ") 31 | fmt.Print(string(str)) 32 | } 33 | -------------------------------------------------------------------------------- /examples/exchange/meta/2_Version/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | metaPB "github.com/InjectiveLabs/sdk-go/exchange/meta_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := metaPB.VersionRequest{} 24 | 25 | res, err := exchangeClient.GetVersion(ctx, &req) 26 | if err != nil { 27 | fmt.Println(err) 28 | } 29 | 30 | str, _ := json.MarshalIndent(res, "", " ") 31 | fmt.Print(string(str)) 32 | } 33 | -------------------------------------------------------------------------------- /examples/exchange/meta/3_Info/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | metaPB "github.com/InjectiveLabs/sdk-go/exchange/meta_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := metaPB.InfoRequest{} 24 | 25 | res, err := exchangeClient.GetInfo(ctx, &req) 26 | if err != nil { 27 | fmt.Println(err) 28 | } 29 | 30 | str, _ := json.MarshalIndent(res, "", " ") 31 | fmt.Print(string(str)) 32 | } 33 | -------------------------------------------------------------------------------- /examples/exchange/meta/4_StreamKeepAlive/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | 22 | stream, err := exchangeClient.StreamKeepalive(ctx) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | for { 28 | select { 29 | case <-ctx.Done(): 30 | return 31 | default: 32 | res, err := stream.Recv() 33 | if err != nil { 34 | fmt.Println(err) 35 | return 36 | } 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/oracle/3_OracleList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("mainnet", "lb") 14 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | res, err := exchangeClient.GetOracleList(ctx) 21 | if err != nil { 22 | fmt.Println(err) 23 | } 24 | 25 | str, _ := json.MarshalIndent(res, "", " ") 26 | fmt.Print(string(str)) 27 | } 28 | -------------------------------------------------------------------------------- /examples/exchange/portfolio/1_AccountPortfolio/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // select network: local, testnet, mainnet 14 | network := common.LoadNetwork("devnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | accountAddress := "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt" 22 | res, err := exchangeClient.GetAccountPortfolioBalances(ctx, accountAddress, true) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/portfolio/2_StreamAccountPortfolioBankBalances/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | 10 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 11 | ) 12 | 13 | func main() { 14 | // select network: local, testnet, mainnet 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | stream, err := exchangeClient.StreamAccountPortfolio(ctx, "inj1rgxjfea3y2e7n0frz5syly8n5zulagy3fc56jy", "", "") 24 | if err != nil { 25 | panic(err) 26 | } 27 | 28 | for { 29 | select { 30 | case <-ctx.Done(): 31 | return 32 | default: 33 | res, err := stream.Recv() 34 | if err != nil { 35 | fmt.Println(err) 36 | return 37 | } 38 | str, _ := json.MarshalIndent(res, "", " ") 39 | fmt.Print(string(str)) 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /examples/exchange/portfolio/3_StreamAccountPortfolioSubaccountBalances/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // select network: local, testnet, mainnet 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | 22 | stream, err := exchangeClient.StreamAccountPortfolio(ctx, "inj1clw20s2uxeyxtam6f7m84vgae92s9eh7vygagt", "0xc7dca7c15c364865f77a4fb67ab11dc95502e6fe000000000000000000000001", "total_balances") 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | for { 28 | select { 29 | case <-ctx.Done(): 30 | return 31 | default: 32 | res, err := stream.Recv() 33 | if err != nil { 34 | fmt.Println(err) 35 | return 36 | } 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/spot/10_StreamTrades/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 23 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 24 | 25 | req := spotExchangePB.StreamTradesRequest{ 26 | MarketId: marketId, 27 | SubaccountId: subaccountId, 28 | } 29 | stream, err := exchangeClient.StreamSpotTrades(ctx, &req) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | for { 35 | select { 36 | case <-ctx.Done(): 37 | return 38 | default: 39 | res, err := stream.Recv() 40 | if err != nil { 41 | fmt.Println(err) 42 | return 43 | } 44 | str, _ := json.MarshalIndent(res, "", " ") 45 | fmt.Print(string(str)) 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /examples/exchange/spot/11_SubaccountOrdersList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 23 | subaccountId := "0x0b46e339708ea4d87bd2fcc61614e109ac374bbe000000000000000000000000" 24 | skip := uint64(0) 25 | limit := int32(10) 26 | 27 | req := spotExchangePB.SubaccountOrdersListRequest{ 28 | MarketId: marketId, 29 | SubaccountId: subaccountId, 30 | Skip: skip, 31 | Limit: limit, 32 | } 33 | 34 | res, err := exchangeClient.GetSubaccountSpotOrdersList(ctx, &req) 35 | if err != nil { 36 | fmt.Println(err) 37 | } 38 | 39 | str, _ := json.MarshalIndent(res, "", " ") 40 | fmt.Print(string(str)) 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/spot/12_SubaccountTradesList/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 23 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 24 | skip := uint64(0) 25 | limit := int32(10) 26 | 27 | req := spotExchangePB.SubaccountTradesListRequest{ 28 | MarketId: marketId, 29 | SubaccountId: subaccountId, 30 | Skip: skip, 31 | Limit: limit, 32 | } 33 | 34 | res, err := exchangeClient.GetSubaccountSpotTradesList(ctx, &req) 35 | if err != nil { 36 | fmt.Println(err) 37 | } 38 | 39 | str, _ := json.MarshalIndent(res, "", " ") 40 | fmt.Print(string(str)) 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/spot/13_Orderbooks/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketIds := []string{"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"} 22 | res, err := exchangeClient.GetSpotOrderbooksV2(ctx, marketIds) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/spot/14_HistoricalOrders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" 22 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 23 | skip := uint64(0) 24 | limit := int32(10) 25 | orderTypes := []string{"buy_po"} 26 | 27 | req := spotExchangePB.OrdersHistoryRequest{ 28 | SubaccountId: subaccountId, 29 | MarketId: marketId, 30 | Skip: skip, 31 | Limit: limit, 32 | OrderTypes: orderTypes, 33 | } 34 | 35 | res, err := exchangeClient.GetHistoricalSpotOrders(ctx, &req) 36 | if err != nil { 37 | panic(err) 38 | } 39 | 40 | str, _ := json.MarshalIndent(res, "", " ") 41 | fmt.Print(string(str)) 42 | } 43 | -------------------------------------------------------------------------------- /examples/exchange/spot/15_StreamHistoricalOrders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0x0611780ba69656949525013d947713300f56c37b6175e02f26bffa495c3208fe" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | direction := "buy" 24 | 25 | req := spotExchangePB.StreamOrdersHistoryRequest{ 26 | MarketId: marketId, 27 | SubaccountId: subaccountId, 28 | Direction: direction, 29 | } 30 | stream, err := exchangeClient.StreamHistoricalSpotOrders(ctx, &req) 31 | if err != nil { 32 | panic(err) 33 | } 34 | 35 | for { 36 | select { 37 | case <-ctx.Done(): 38 | return 39 | default: 40 | res, err := stream.Recv() 41 | if err != nil { 42 | panic(err) 43 | return 44 | } 45 | str, _ := json.MarshalIndent(res, "", " ") 46 | fmt.Print(string(str)) 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/exchange/spot/16_TradesV2/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 22 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 23 | 24 | req := spotExchangePB.TradesV2Request{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | 29 | res, err := exchangeClient.GetSpotTradesV2(ctx, &req) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/exchange/spot/17_StreamTradesV2/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 22 | subaccountId := "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" 23 | 24 | req := spotExchangePB.StreamTradesV2Request{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | stream, err := exchangeClient.StreamSpotTradesV2(ctx, &req) 29 | if err != nil { 30 | panic(err) 31 | } 32 | 33 | for { 34 | select { 35 | case <-ctx.Done(): 36 | return 37 | default: 38 | res, err := stream.Recv() 39 | if err != nil { 40 | fmt.Println(err) 41 | return 42 | } 43 | str, _ := json.MarshalIndent(res, "", " ") 44 | fmt.Print(string(str)) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /examples/exchange/spot/1_Market/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 22 | res, err := exchangeClient.GetSpotMarket(ctx, marketId) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/spot/2_Markets/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketStatus := "active" 23 | quoteDenom := "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7" 24 | 25 | req := spotExchangePB.MarketsRequest{ 26 | MarketStatus: marketStatus, 27 | QuoteDenom: quoteDenom, 28 | } 29 | 30 | res, err := exchangeClient.GetSpotMarkets(ctx, &req) 31 | if err != nil { 32 | fmt.Println(err) 33 | } 34 | 35 | str, _ := json.MarshalIndent(res, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/exchange/spot/3_StreamMarket/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketIds := []string{"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"} 22 | stream, err := exchangeClient.StreamSpotMarket(ctx, marketIds) 23 | if err != nil { 24 | panic(err) 25 | } 26 | 27 | for { 28 | select { 29 | case <-ctx.Done(): 30 | return 31 | default: 32 | res, err := stream.Recv() 33 | if err != nil { 34 | fmt.Println(err) 35 | return 36 | } 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/exchange/spot/4_Orderbook/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | ) 11 | 12 | func main() { 13 | // network := common.LoadNetwork("mainnet", "k8s") 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 22 | res, err := exchangeClient.GetSpotOrderbookV2(ctx, marketId) 23 | if err != nil { 24 | fmt.Println(err) 25 | } 26 | 27 | str, _ := json.MarshalIndent(res, "", " ") 28 | fmt.Print(string(str)) 29 | } 30 | -------------------------------------------------------------------------------- /examples/exchange/spot/5_Orders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("mainnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 23 | skip := uint64(0) 24 | limit := int32(10) 25 | 26 | req := spotExchangePB.OrdersRequest{ 27 | MarketId: marketId, 28 | Skip: skip, 29 | Limit: limit, 30 | } 31 | 32 | res, err := exchangeClient.GetSpotOrders(ctx, &req) 33 | if err != nil { 34 | fmt.Println(err) 35 | } 36 | 37 | str, _ := json.MarshalIndent(res, "", " ") 38 | fmt.Print(string(str)) 39 | } 40 | -------------------------------------------------------------------------------- /examples/exchange/spot/6_Trades/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 22 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 23 | 24 | req := spotExchangePB.TradesRequest{ 25 | MarketId: marketId, 26 | SubaccountId: subaccountId, 27 | } 28 | 29 | res, err := exchangeClient.GetSpotTrades(ctx, &req) 30 | if err != nil { 31 | panic(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/exchange/spot/7_StreamOrderbook/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | 7 | "github.com/InjectiveLabs/sdk-go/client/common" 8 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 9 | ) 10 | 11 | func main() { 12 | network := common.LoadNetwork("devnet-1", "") 13 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 14 | if err != nil { 15 | panic(err) 16 | } 17 | 18 | ctx := context.Background() 19 | marketIds := []string{"0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"} 20 | stream, err := exchangeClient.StreamSpotOrderbookV2(ctx, marketIds) 21 | if err != nil { 22 | panic(err) 23 | } 24 | 25 | for { 26 | select { 27 | case <-ctx.Done(): 28 | return 29 | default: 30 | res, err := stream.Recv() 31 | if err != nil { 32 | fmt.Println(err) 33 | return 34 | } 35 | fmt.Println(res.MarketId, res.Orderbook, len(res.Orderbook.Sells), len(res.Orderbook.Buys)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/exchange/spot/9_StreamOrders/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange" 10 | spotExchangePB "github.com/InjectiveLabs/sdk-go/exchange/spot_exchange_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | // network := common.LoadNetwork("mainnet", "k8s") 15 | network := common.LoadNetwork("testnet", "lb") 16 | exchangeClient, err := exchangeclient.NewExchangeClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | marketId := "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" 23 | subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" 24 | orderSide := "buy" 25 | 26 | req := spotExchangePB.StreamOrdersRequest{ 27 | MarketId: marketId, 28 | SubaccountId: subaccountId, 29 | OrderSide: orderSide, 30 | } 31 | stream, err := exchangeClient.StreamSpotOrders(ctx, &req) 32 | if err != nil { 33 | panic(err) 34 | } 35 | 36 | for { 37 | select { 38 | case <-ctx.Done(): 39 | return 40 | default: 41 | res, err := stream.Recv() 42 | if err != nil { 43 | fmt.Println(err) 44 | return 45 | } 46 | str, _ := json.MarshalIndent(res, "", " ") 47 | fmt.Print(string(str)) 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /examples/explorer/10_IBCTransfers/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | receiver := "inj1ddcp5ftqmntudn4m6heg2adud6hn58urnwlmkh" 23 | 24 | req := explorerPB.GetIBCTransferTxsRequest{ 25 | Receiver: receiver, 26 | } 27 | 28 | res, err := explorerClient.GetIBCTransfers(ctx, &req) 29 | if err != nil { 30 | fmt.Println(err) 31 | } 32 | 33 | str, _ := json.MarshalIndent(res, "", " ") 34 | fmt.Print(string(str)) 35 | } 36 | -------------------------------------------------------------------------------- /examples/explorer/11_GetWasmCodes/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := explorerPB.GetWasmCodesRequest{ 24 | Limit: 10, 25 | } 26 | 27 | res, err := explorerClient.GetWasmCodes(ctx, &req) 28 | if err != nil { 29 | fmt.Println(err) 30 | } 31 | 32 | str, _ := json.MarshalIndent(res, "", " ") 33 | fmt.Print(string(str)) 34 | } 35 | -------------------------------------------------------------------------------- /examples/explorer/12_GetWasmCodeById/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := explorerPB.GetWasmCodeByIDRequest{ 24 | CodeId: 10, 25 | } 26 | 27 | res, err := explorerClient.GetWasmCodeByID(ctx, &req) 28 | if err != nil { 29 | fmt.Println(err) 30 | } 31 | 32 | str, _ := json.MarshalIndent(res, "", " ") 33 | fmt.Print(string(str)) 34 | } 35 | -------------------------------------------------------------------------------- /examples/explorer/13_GetWasmContracts/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := explorerPB.GetWasmContractsRequest{} 24 | 25 | res, err := explorerClient.GetWasmContracts(ctx, &req) 26 | if err != nil { 27 | fmt.Println(err) 28 | } 29 | 30 | str, _ := json.MarshalIndent(res, "", " ") 31 | fmt.Print(string(str)) 32 | } 33 | -------------------------------------------------------------------------------- /examples/explorer/14_GetWasmContractByAddress/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := explorerPB.GetWasmContractByAddressRequest{ 24 | ContractAddress: "inj1ru9nhdjtjtz8u8wrwxmcl9zsns4fh2838yr5ga", 25 | } 26 | res, err := explorerClient.GetWasmContractByAddress(ctx, &req) 27 | if err != nil { 28 | fmt.Println(err) 29 | } 30 | 31 | str, _ := json.MarshalIndent(res, "", " ") 32 | fmt.Print(string(str)) 33 | } 34 | -------------------------------------------------------------------------------- /examples/explorer/15_GetCW20Balance/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | req := explorerPB.GetCw20BalanceRequest{ 24 | Address: "inj1dc6rrxhfjaxexzdcrec5w3ryl4jn6x5t7t9j3z", 25 | } 26 | res, err := explorerClient.GetCW20Balance(ctx, &req) 27 | if err != nil { 28 | fmt.Println(err) 29 | } 30 | 31 | str, _ := json.MarshalIndent(res, "", " ") 32 | fmt.Print(string(str)) 33 | } 34 | -------------------------------------------------------------------------------- /examples/explorer/16_GetContractTxs/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | 18 | explorerClient, err := explorer.NewExplorerClient(network) 19 | if err != nil { 20 | log.Fatalf("Failed to create explorer client: %v", err) 21 | } 22 | 23 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 24 | defer cancel() 25 | 26 | // Example contract address (replace with an actual contract address) 27 | contractAddress := "inj1ady3s7whq30l4fx8sj3x6muv5mx4dfdlcpv8n7" 28 | 29 | req := &explorerPB.GetContractTxsRequest{ 30 | Address: contractAddress, 31 | Limit: 10, // Fetch 10 transactions 32 | } 33 | 34 | response, err := explorerClient.FetchContractTxs(ctx, req) 35 | if err != nil { 36 | log.Fatalf("Failed to fetch contract transactions: %v", err) 37 | } 38 | 39 | fmt.Println("Total Contract Transactions:", len(response.Data)) 40 | for _, tx := range response.Data { 41 | fmt.Printf("Tx Hash: %s, Block: %d\n", tx.Hash, tx.BlockNumber) 42 | } 43 | 44 | fmt.Printf("\n\n") 45 | fmt.Println("Full response:") 46 | str, _ := json.MarshalIndent(response, "", " ") 47 | fmt.Print(string(str)) 48 | } 49 | -------------------------------------------------------------------------------- /examples/explorer/17_GetContractTxsV2/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | 18 | explorerClient, err := explorer.NewExplorerClient(network) 19 | if err != nil { 20 | log.Fatalf("Failed to create explorer client: %v", err) 21 | } 22 | defer explorerClient.Close() 23 | 24 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 25 | defer cancel() 26 | 27 | // Example contract address (replace with an actual contract address) 28 | contractAddress := "inj1ady3s7whq30l4fx8sj3x6muv5mx4dfdlcpv8n7" 29 | 30 | req := &explorerPB.GetContractTxsV2Request{ 31 | Address: contractAddress, 32 | Limit: 10, // Fetch 10 transactions 33 | } 34 | 35 | response, err := explorerClient.FetchContractTxsV2(ctx, req) 36 | if err != nil { 37 | log.Fatalf("Failed to fetch contract transactions V2: %v", err) 38 | } 39 | 40 | fmt.Println("Total Contract Transactions:", len(response.Data)) 41 | for _, tx := range response.Data { 42 | fmt.Printf("Tx Hash: %s, Block: %d\n", tx.Hash, tx.BlockNumber) 43 | } 44 | 45 | fmt.Printf("\n\n") 46 | fmt.Println("Full response:") 47 | str, _ := json.MarshalIndent(response, "", " ") 48 | fmt.Print(string(str)) 49 | } 50 | -------------------------------------------------------------------------------- /examples/explorer/18_GetValidators/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | 17 | explorerClient, err := explorer.NewExplorerClient(network) 18 | if err != nil { 19 | log.Fatalf("Failed to create explorer client: %v", err) 20 | } 21 | defer explorerClient.Close() 22 | 23 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 24 | defer cancel() 25 | 26 | response, err := explorerClient.FetchValidators(ctx) 27 | if err != nil { 28 | log.Fatalf("Failed to fetch validators: %v", err) 29 | } 30 | 31 | fmt.Println("Full response:") 32 | str, _ := json.MarshalIndent(response, "", " ") 33 | fmt.Print(string(str)) 34 | } 35 | -------------------------------------------------------------------------------- /examples/explorer/19_GetValidator/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | 17 | explorerClient, err := explorer.NewExplorerClient(network) 18 | if err != nil { 19 | log.Fatalf("Failed to create explorer client: %v", err) 20 | } 21 | defer explorerClient.Close() 22 | 23 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 24 | defer cancel() 25 | 26 | // Example validator address (replace with an actual validator address) 27 | validatorAddress := "injvaloper1kk523rsm9pey740cx4plalp40009ncs0wrchfe" 28 | 29 | response, err := explorerClient.FetchValidator(ctx, validatorAddress) 30 | if err != nil { 31 | log.Fatalf("Failed to fetch validator: %v", err) 32 | } 33 | 34 | fmt.Println("Validator:") 35 | str, _ := json.MarshalIndent(response, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/explorer/1_GetTxByHash/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("mainnet", "sentry") 14 | explorerClient, err := explorerclient.NewExplorerClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | hash := "E5DCF04CC670A0567F58683409F7DAFC49754278DAAD507FE6EB40DFBFD71830" 21 | res, err := explorerClient.GetTxByTxHash(ctx, hash) 22 | if err != nil { 23 | fmt.Println(err) 24 | } 25 | 26 | str, _ := json.MarshalIndent(res, "", " ") 27 | fmt.Print(string(str)) 28 | } 29 | -------------------------------------------------------------------------------- /examples/explorer/20_GetValidatorUptime/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | 17 | explorerClient, err := explorer.NewExplorerClient(network) 18 | if err != nil { 19 | log.Fatalf("Failed to create explorer client: %v", err) 20 | } 21 | defer explorerClient.Close() 22 | 23 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 24 | defer cancel() 25 | 26 | // Example validator address (replace with an actual validator address) 27 | validatorAddress := "injvaloper1kk523rsm9pey740cx4plalp40009ncs0wrchfe" 28 | 29 | response, err := explorerClient.FetchValidatorUptime(ctx, validatorAddress) 30 | if err != nil { 31 | log.Fatalf("Failed to fetch validator uptime: %v", err) 32 | } 33 | 34 | fmt.Println("Validator uptime:") 35 | str, _ := json.MarshalIndent(response, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/explorer/21_Relayers/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | 17 | explorerClient, err := explorer.NewExplorerClient(network) 18 | if err != nil { 19 | log.Fatalf("Failed to create explorer client: %v", err) 20 | } 21 | defer explorerClient.Close() 22 | 23 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 24 | defer cancel() 25 | 26 | // Pass an empty list of market IDs 27 | var marketIds []string 28 | 29 | response, err := explorerClient.FetchRelayers(ctx, marketIds) 30 | if err != nil { 31 | log.Fatalf("Failed to fetch relayers: %v", err) 32 | } 33 | 34 | fmt.Println("Relayers:") 35 | str, _ := json.MarshalIndent(response, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/explorer/22_GetBankTransfers/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | "log" 8 | "time" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 13 | ) 14 | 15 | func main() { 16 | network := common.LoadNetwork("testnet", "lb") 17 | 18 | explorerClient, err := explorer.NewExplorerClient(network) 19 | if err != nil { 20 | log.Fatalf("Failed to create explorer client: %v", err) 21 | } 22 | defer explorerClient.Close() 23 | 24 | ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) 25 | defer cancel() 26 | 27 | req := &explorerPB.GetBankTransfersRequest{ 28 | Senders: []string{"inj17xpfvakm2amg962yls6f84z3kell8c5l6s5ye9"}, 29 | Limit: 5, // Limit number of transfers 30 | } 31 | 32 | response, err := explorerClient.FetchBankTransfers(ctx, req) 33 | if err != nil { 34 | log.Fatalf("Failed to fetch bank transfers: %v", err) 35 | } 36 | 37 | fmt.Println("Bank transfers:") 38 | str, _ := json.MarshalIndent(response, "", " ") 39 | fmt.Print(string(str)) 40 | } 41 | -------------------------------------------------------------------------------- /examples/explorer/2_AccountTxs/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | address := "inj1akxycslq8cjt0uffw4rjmfm3echchptu52a2dq" 22 | after := uint64(14112176) 23 | 24 | req := explorerPB.GetAccountTxsRequest{ 25 | After: after, 26 | Address: address, 27 | } 28 | 29 | ctx := context.Background() 30 | res, err := explorerClient.GetAccountTxs(ctx, &req) 31 | if err != nil { 32 | fmt.Println(err) 33 | } 34 | 35 | str, _ := json.MarshalIndent(res, "", " ") 36 | fmt.Print(string(str)) 37 | } 38 | -------------------------------------------------------------------------------- /examples/explorer/3_Blocks/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("mainnet", "lb") 14 | explorerClient, err := explorerclient.NewExplorerClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | res, err := explorerClient.GetBlocks(ctx) 21 | if err != nil { 22 | fmt.Println(err) 23 | } 24 | 25 | str, _ := json.MarshalIndent(res, "", " ") 26 | fmt.Print(string(str)) 27 | } 28 | -------------------------------------------------------------------------------- /examples/explorer/4_Block/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | explorerClient, err := explorerclient.NewExplorerClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | blockHeight := "5825046" 21 | res, err := explorerClient.GetBlock(ctx, blockHeight) 22 | if err != nil { 23 | fmt.Println(err) 24 | } 25 | 26 | str, _ := json.MarshalIndent(res, "", " ") 27 | fmt.Print(string(str)) 28 | } 29 | -------------------------------------------------------------------------------- /examples/explorer/5_TxsRequest/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 10 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 11 | ) 12 | 13 | func main() { 14 | network := common.LoadNetwork("testnet", "lb") 15 | explorerClient, err := explorerclient.NewExplorerClient(network) 16 | if err != nil { 17 | panic(err) 18 | } 19 | 20 | ctx := context.Background() 21 | 22 | before := uint64(7158400) 23 | 24 | req := explorerPB.GetTxsRequest{ 25 | Before: before, 26 | } 27 | 28 | res, err := explorerClient.GetTxs(ctx, &req) 29 | if err != nil { 30 | fmt.Println(err) 31 | } 32 | 33 | str, _ := json.MarshalIndent(res, "", " ") 34 | fmt.Print(string(str)) 35 | } 36 | -------------------------------------------------------------------------------- /examples/explorer/6_StreamTxs/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | explorerClient, err := explorerclient.NewExplorerClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | stream, err := explorerClient.StreamTxs(ctx) 21 | if err != nil { 22 | panic(err) 23 | } 24 | 25 | for { 26 | select { 27 | case <-ctx.Done(): 28 | return 29 | default: 30 | res, err := stream.Recv() 31 | if err != nil { 32 | panic(err) 33 | } 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/explorer/7_StreamBlocks/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | "github.com/InjectiveLabs/sdk-go/client/common" 9 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 10 | ) 11 | 12 | func main() { 13 | network := common.LoadNetwork("testnet", "lb") 14 | explorerClient, err := explorerclient.NewExplorerClient(network) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | ctx := context.Background() 20 | stream, err := explorerClient.StreamBlocks(ctx) 21 | if err != nil { 22 | panic(err) 23 | } 24 | 25 | for { 26 | select { 27 | case <-ctx.Done(): 28 | return 29 | default: 30 | res, err := stream.Recv() 31 | if err != nil { 32 | panic(err) 33 | } 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /examples/explorer/8_PeggyDeposits/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | 23 | receiver := "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" 24 | 25 | req := explorerPB.GetPeggyDepositTxsRequest{ 26 | Receiver: receiver, 27 | } 28 | 29 | res, err := explorerClient.GetPeggyDeposits(ctx, &req) 30 | if err != nil { 31 | fmt.Println(err) 32 | } 33 | 34 | str, _ := json.MarshalIndent(res, "", " ") 35 | fmt.Print(string(str)) 36 | } 37 | -------------------------------------------------------------------------------- /examples/explorer/9_PeggyWithdrawals/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "fmt" 7 | 8 | explorerPB "github.com/InjectiveLabs/sdk-go/exchange/explorer_rpc/pb" 9 | 10 | "github.com/InjectiveLabs/sdk-go/client/common" 11 | explorerclient "github.com/InjectiveLabs/sdk-go/client/explorer" 12 | ) 13 | 14 | func main() { 15 | network := common.LoadNetwork("testnet", "lb") 16 | explorerClient, err := explorerclient.NewExplorerClient(network) 17 | if err != nil { 18 | panic(err) 19 | } 20 | 21 | ctx := context.Background() 22 | sender := "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku" 23 | 24 | req := explorerPB.GetPeggyWithdrawalTxsRequest{ 25 | Sender: sender, 26 | } 27 | 28 | res, err := explorerClient.GetPeggyWithdrawals(ctx, &req) 29 | if err != nil { 30 | fmt.Println(err) 31 | } 32 | 33 | str, _ := json.MarshalIndent(res, "", " ") 34 | fmt.Print(string(str)) 35 | } 36 | -------------------------------------------------------------------------------- /proto/buf.gen.doc.yml: -------------------------------------------------------------------------------- 1 | version: v1 2 | plugins: 3 | - name: doc 4 | out: ../docs/proto 5 | opt: ../docs/proto/protodoc-markdown.tmpl,proto-docs.md -------------------------------------------------------------------------------- /proto/buf.gen.gogo.yml: -------------------------------------------------------------------------------- 1 | version: v1 2 | plugins: 3 | - name: gocosmos 4 | out: .. 5 | opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types 6 | - name: grpc-gateway 7 | out: .. 8 | opt: logtostderr=true,allow_colon_final_segments=true -------------------------------------------------------------------------------- /proto/buf.gen.pulsar.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | managed: 3 | enabled: true 4 | go_package_prefix: 5 | default: cosmossdk.io/api 6 | except: 7 | - buf.build/googleapis/googleapis 8 | - buf.build/cosmos/gogo-proto 9 | - buf.build/cosmos/cosmos-proto 10 | override: 11 | plugins: 12 | - name: go-pulsar 13 | out: ../api 14 | opt: paths=source_relative 15 | - name: go-grpc 16 | out: ../api 17 | opt: paths=source_relative 18 | -------------------------------------------------------------------------------- /proto/buf.gen.swagger.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | 3 | plugins: 4 | - name: swagger 5 | out: ../tmp-swagger-gen 6 | opt: 7 | - logtostderr=true 8 | - fqn_for_swagger_name=true 9 | - simple_operation_ids=true 10 | strategy: directory 11 | -------------------------------------------------------------------------------- /proto/buf.lock: -------------------------------------------------------------------------------- 1 | # Generated by buf. DO NOT EDIT. 2 | version: v1 3 | deps: 4 | - remote: buf.build 5 | owner: cosmos 6 | repository: cosmos-proto 7 | commit: 1935555c206d4afb9e94615dfd0fad31 8 | - remote: buf.build 9 | owner: cosmos 10 | repository: cosmos-sdk 11 | commit: 954f7b05f38440fc8250134b15adec47 12 | - remote: buf.build 13 | owner: cosmos 14 | repository: gogo-proto 15 | commit: 34d970b699f84aa382f3c29773a60836 16 | - remote: buf.build 17 | owner: cosmwasm 18 | repository: wasmd 19 | commit: 6f4f25f158344123aaf16b2019d36ed4 20 | - remote: buf.build 21 | owner: googleapis 22 | repository: googleapis 23 | commit: 75b4300737fb4efca0831636be94e517 24 | -------------------------------------------------------------------------------- /proto/buf.md: -------------------------------------------------------------------------------- 1 | # Protobufs 2 | 3 | This is the public protocol buffers API for [Injective core](https://github.com/InjectiveLabs/injective-core). -------------------------------------------------------------------------------- /proto/buf.yaml: -------------------------------------------------------------------------------- 1 | version: v1 2 | name: buf.build/InjectiveLabs/injective-core 3 | deps: 4 | - buf.build/googleapis/googleapis 5 | - buf.build/cosmos/cosmos-proto 6 | - buf.build/cosmos/cosmos-sdk:v0.50.5 7 | - buf.build/cosmos/gogo-proto 8 | - buf.build/cosmwasm/wasmd:v0.51.0 9 | breaking: 10 | use: 11 | - FILE 12 | lint: 13 | use: 14 | - DEFAULT 15 | - COMMENTS 16 | - FILE_LOWER_SNAKE_CASE 17 | except: 18 | - UNARY_RPC 19 | - COMMENT_FIELD 20 | - SERVICE_SUFFIX 21 | - PACKAGE_VERSION_SUFFIX 22 | - RPC_REQUEST_STANDARD_NAME 23 | - PACKAGE_DIRECTORY_MATCH 24 | -------------------------------------------------------------------------------- /proto/injective/auction/v1beta1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.auction.v1beta1; 3 | 4 | import "injective/auction/v1beta1/auction.proto"; 5 | import "gogoproto/gogo.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/auction/types"; 8 | 9 | // GenesisState defines the auction module's genesis state. 10 | message GenesisState { 11 | // params defines all the parameters of related to auction. 12 | Params params = 1 [ (gogoproto.nullable) = false ]; 13 | 14 | // current auction round 15 | uint64 auction_round = 2; 16 | 17 | // current highest bid 18 | Bid highest_bid = 3; 19 | 20 | // auction ending timestamp 21 | int64 auction_ending_timestamp = 4; 22 | 23 | // last auction result 24 | LastAuctionResult last_auction_result = 5; 25 | } 26 | -------------------------------------------------------------------------------- /proto/injective/crypto/v1beta1/ethsecp256k1/keys.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.crypto.v1beta1.ethsecp256k1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "amino/amino.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/crypto/ethsecp256k1"; 8 | 9 | // PubKey defines a type alias for an ecdsa.PublicKey that implements 10 | // Tendermint's PubKey interface. It represents the 33-byte compressed public 11 | // key format. 12 | message PubKey { 13 | option (amino.name) = "injective/PubKeyEthSecp256k1"; 14 | // The Amino encoding is simply the inner bytes field, and not the Amino 15 | // encoding of the whole PubKey struct. 16 | // 17 | // Example (JSON): 18 | // s := PubKey{Key: []byte{0x01}} 19 | // out := AminoJSONEncoder(s) 20 | // 21 | // Then we have: 22 | // out == `"MQ=="` 23 | // out != `{"key":"MQ=="}` 24 | option (amino.message_encoding) = "key_field"; 25 | 26 | option (gogoproto.goproto_stringer) = false; 27 | 28 | bytes key = 1; 29 | } 30 | 31 | // PrivKey defines a type alias for an ecdsa.PrivateKey that implements 32 | // Tendermint's PrivateKey interface. 33 | message PrivKey { 34 | option (amino.name) = "injective/PrivKeyEthSecp256k1"; 35 | option (amino.message_encoding) = "key_field"; 36 | 37 | bytes key = 1; 38 | } 39 | -------------------------------------------------------------------------------- /proto/injective/insurance/v1beta1/events.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.insurance.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "cosmos/base/v1beta1/coin.proto"; 6 | import "injective/insurance/v1beta1/insurance.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/insurance/types"; 9 | 10 | message EventInsuranceFundUpdate { InsuranceFund fund = 1; } 11 | 12 | message EventRequestRedemption { RedemptionSchedule schedule = 1; } 13 | 14 | message EventWithdrawRedemption { 15 | // redemption schedule triggered withdraw 16 | RedemptionSchedule schedule = 1; 17 | // redeem coin amount in base_currency 18 | cosmos.base.v1beta1.Coin redeem_coin = 2 [ (gogoproto.nullable) = false ]; 19 | } 20 | 21 | message EventUnderwrite { 22 | // address of the underwriter 23 | string underwriter = 1; 24 | // marketId of insurance fund for the redemption 25 | string marketId = 2; 26 | // deposit coin amount 27 | cosmos.base.v1beta1.Coin deposit = 3 [ (gogoproto.nullable) = false ]; 28 | // share coin amount 29 | cosmos.base.v1beta1.Coin shares = 4 [ (gogoproto.nullable) = false ]; 30 | } 31 | 32 | message EventInsuranceWithdraw { 33 | string market_id = 1; 34 | string market_ticker = 2; 35 | cosmos.base.v1beta1.Coin withdrawal = 3 [ (gogoproto.nullable) = false ]; 36 | } -------------------------------------------------------------------------------- /proto/injective/insurance/v1beta1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.insurance.v1beta1; 3 | 4 | import "injective/insurance/v1beta1/insurance.proto"; 5 | import "gogoproto/gogo.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/insurance/types"; 8 | 9 | // GenesisState defines the insurance module's genesis state. 10 | message GenesisState { 11 | // params defines all the parameters of related to insurance. 12 | Params params = 1 [ (gogoproto.nullable) = false ]; 13 | 14 | // insurance_funds describes the insurance funds available for derivative 15 | // markets 16 | repeated InsuranceFund insurance_funds = 2 [ (gogoproto.nullable) = false ]; 17 | 18 | // redemption_schedule describes the redemption requests pending 19 | repeated RedemptionSchedule redemption_schedule = 3 20 | [ (gogoproto.nullable) = false ]; 21 | 22 | // next_share_denom_id describes the next share denom id to be used for newly 23 | // creating insurance fund incremented by 1 per insurance fund creation 24 | uint64 next_share_denom_id = 4; 25 | 26 | // next_redemption_schedule_id describes next redemption schedule id to be 27 | // used for next schedule incremented by 1 per redemption request 28 | uint64 next_redemption_schedule_id = 5; 29 | } 30 | -------------------------------------------------------------------------------- /proto/injective/oracle/v1beta1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.oracle.v1beta1; 3 | 4 | import "injective/oracle/v1beta1/oracle.proto"; 5 | import "gogoproto/gogo.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/oracle/types"; 8 | 9 | // GenesisState defines the oracle module's genesis state. 10 | message GenesisState { 11 | // params defines all the parameters of related to oracle. 12 | Params params = 1 [ (gogoproto.nullable) = false ]; 13 | 14 | repeated string band_relayers = 2; 15 | 16 | repeated BandPriceState band_price_states = 3; 17 | 18 | repeated PriceFeedState price_feed_price_states = 4; 19 | 20 | repeated CoinbasePriceState coinbase_price_states = 5; 21 | 22 | repeated BandPriceState band_ibc_price_states = 6; 23 | 24 | repeated BandOracleRequest band_ibc_oracle_requests = 7; 25 | 26 | BandIBCParams band_ibc_params = 8 [ (gogoproto.nullable) = false ]; 27 | 28 | uint64 band_ibc_latest_client_id = 9; 29 | 30 | repeated CalldataRecord calldata_records = 10; 31 | 32 | uint64 band_ibc_latest_request_id = 11; 33 | 34 | repeated ChainlinkPriceState chainlink_price_states = 12; 35 | 36 | repeated PriceRecords historical_price_records = 13; 37 | 38 | repeated ProviderState provider_states = 14; 39 | 40 | repeated PythPriceState pyth_price_states = 15; 41 | 42 | repeated StorkPriceState stork_price_states = 16; 43 | 44 | repeated string stork_publishers = 17; 45 | } 46 | 47 | message CalldataRecord { 48 | uint64 client_id = 1; 49 | bytes calldata = 2; 50 | } -------------------------------------------------------------------------------- /proto/injective/peggy/v1/batch.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.peggy.v1; 3 | 4 | import "injective/peggy/v1/attestation.proto"; 5 | // import "injective/peggy/v1/types.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/peggy/types"; 8 | 9 | // OutgoingTxBatch represents a batch of transactions going from Peggy to ETH 10 | message OutgoingTxBatch { 11 | uint64 batch_nonce = 1; 12 | uint64 batch_timeout = 2; 13 | repeated OutgoingTransferTx transactions = 3; 14 | string token_contract = 4; 15 | uint64 block = 5; 16 | } 17 | 18 | // OutgoingTransferTx represents an individual send from Peggy to ETH 19 | message OutgoingTransferTx { 20 | uint64 id = 1; 21 | string sender = 2; 22 | string dest_address = 3; 23 | ERC20Token erc20_token = 4; 24 | ERC20Token erc20_fee = 5; 25 | } 26 | -------------------------------------------------------------------------------- /proto/injective/peggy/v1/ethereum_signer.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.peggy.v1; 3 | import "gogoproto/gogo.proto"; 4 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/peggy/types"; 5 | 6 | // SignType defines messages that have been signed by an orchestrator 7 | enum SignType { 8 | option (gogoproto.goproto_enum_prefix) = false; 9 | option (gogoproto.goproto_enum_stringer) = false; 10 | 11 | SIGN_TYPE_UNKNOWN = 0; 12 | SIGN_TYPE_ORCHESTRATOR_SIGNED_MULTI_SIG_UPDATE = 1; 13 | SIGN_TYPE_ORCHESTRATOR_SIGNED_WITHDRAW_BATCH = 2; 14 | } 15 | -------------------------------------------------------------------------------- /proto/injective/peggy/v1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.peggy.v1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "injective/peggy/v1/types.proto"; 6 | import "injective/peggy/v1/msgs.proto"; 7 | import "injective/peggy/v1/batch.proto"; 8 | import "injective/peggy/v1/attestation.proto"; 9 | import "injective/peggy/v1/params.proto"; 10 | import "cosmos/base/v1beta1/coin.proto"; 11 | 12 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/peggy/types"; 13 | 14 | // GenesisState struct 15 | message GenesisState { 16 | Params params = 1; 17 | uint64 last_observed_nonce = 2; 18 | repeated Valset valsets = 3; 19 | repeated MsgValsetConfirm valset_confirms = 4; 20 | repeated OutgoingTxBatch batches = 5; 21 | repeated MsgConfirmBatch batch_confirms = 6; 22 | repeated Attestation attestations = 7; 23 | repeated MsgSetOrchestratorAddresses orchestrator_addresses = 8; 24 | repeated ERC20ToDenom erc20_to_denoms = 9; 25 | repeated OutgoingTransferTx unbatched_transfers = 10; 26 | uint64 last_observed_ethereum_height = 11; 27 | uint64 last_outgoing_batch_id = 12; 28 | uint64 last_outgoing_pool_id = 13; 29 | Valset last_observed_valset = 14 [ (gogoproto.nullable) = false ]; 30 | repeated string ethereum_blacklist = 15; 31 | } 32 | -------------------------------------------------------------------------------- /proto/injective/peggy/v1/pool.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.peggy.v1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/peggy/types"; 7 | 8 | // IDSet represents a set of IDs 9 | message IDSet { repeated uint64 ids = 1; } 10 | 11 | message BatchFees { 12 | string token = 1; 13 | string total_fees = 2 [ 14 | (gogoproto.customtype) = "cosmossdk.io/math.Int", 15 | (gogoproto.nullable) = false 16 | ]; 17 | } -------------------------------------------------------------------------------- /proto/injective/permissions/v1beta1/events.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.permissions.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "cosmos/base/v1beta1/coin.proto"; 6 | import "cosmos/bank/v1beta1/bank.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/permissions/types"; 9 | 10 | message EventSetVoucher { 11 | string addr = 1; 12 | cosmos.base.v1beta1.Coin voucher = 2 [ (gogoproto.nullable) = false ]; 13 | } -------------------------------------------------------------------------------- /proto/injective/permissions/v1beta1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.permissions.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "injective/permissions/v1beta1/params.proto"; 6 | import "injective/permissions/v1beta1/permissions.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/permissions/types"; 9 | 10 | // GenesisState defines the permissions module's genesis state. 11 | message GenesisState { 12 | // params defines the parameters of the module. 13 | Params params = 1 [ (gogoproto.nullable) = false ]; 14 | repeated Namespace namespaces = 2 [ (gogoproto.nullable) = false ]; 15 | repeated AddressVoucher vouchers = 3; 16 | } -------------------------------------------------------------------------------- /proto/injective/permissions/v1beta1/params.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.permissions.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "cosmos_proto/cosmos.proto"; 6 | import "cosmos/base/v1beta1/coin.proto"; 7 | import "amino/amino.proto"; 8 | 9 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/permissions/types"; 10 | 11 | // Params defines the parameters for the permissions module. 12 | message Params { 13 | option (gogoproto.equal) = true; 14 | option (amino.name) = "permissions/Params"; 15 | 16 | uint64 wasm_hook_query_max_gas = 1; 17 | } 18 | -------------------------------------------------------------------------------- /proto/injective/tokenfactory/v1beta1/authorityMetadata.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.tokenfactory.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "cosmos/base/v1beta1/coin.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/tokenfactory/types"; 8 | 9 | // DenomAuthorityMetadata specifies metadata for addresses that have specific 10 | // capabilities over a token factory denom. Right now there is only one Admin 11 | // permission, but is planned to be extended to the future. 12 | message DenomAuthorityMetadata { 13 | option (gogoproto.equal) = true; 14 | 15 | // Can be empty for no admin, or a valid injective address 16 | string admin = 1 [ (gogoproto.moretags) = "yaml:\"admin\"" ]; 17 | 18 | // true if the admin can burn tokens from other addresses 19 | bool admin_burn_allowed = 2 20 | [ (gogoproto.moretags) = "yaml:\"admin_burn_allowed\"" ]; 21 | } 22 | -------------------------------------------------------------------------------- /proto/injective/tokenfactory/v1beta1/events.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.tokenfactory.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "cosmos/base/v1beta1/coin.proto"; 6 | import "cosmos/bank/v1beta1/bank.proto"; 7 | import "injective/tokenfactory/v1beta1/authorityMetadata.proto"; 8 | 9 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/tokenfactory/types"; 10 | 11 | message EventCreateDenom { 12 | string account = 1; 13 | string denom = 2; 14 | } 15 | 16 | message EventMint { 17 | string minter = 1; 18 | cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ]; 19 | string receiver = 3; 20 | } 21 | 22 | message EventBurn { 23 | string burner = 1; 24 | cosmos.base.v1beta1.Coin amount = 2 [ (gogoproto.nullable) = false ]; 25 | string burn_from = 3; 26 | } 27 | 28 | message EventChangeAdmin { 29 | string denom = 1; 30 | string new_admin_address = 2; 31 | } 32 | 33 | message EventSetDenomMetadata { 34 | string denom = 1; 35 | cosmos.bank.v1beta1.Metadata metadata = 2 [ (gogoproto.nullable) = false ]; 36 | } 37 | -------------------------------------------------------------------------------- /proto/injective/tokenfactory/v1beta1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.tokenfactory.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "injective/tokenfactory/v1beta1/authorityMetadata.proto"; 6 | import "injective/tokenfactory/v1beta1/params.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/tokenfactory/types"; 9 | 10 | // GenesisState defines the tokenfactory module's genesis state. 11 | message GenesisState { 12 | // params defines the parameters of the module. 13 | Params params = 1 [ (gogoproto.nullable) = false ]; 14 | 15 | repeated GenesisDenom factory_denoms = 2 [ 16 | (gogoproto.moretags) = "yaml:\"factory_denoms\"", 17 | (gogoproto.nullable) = false 18 | ]; 19 | } 20 | 21 | // GenesisDenom defines a tokenfactory denom that is defined within genesis 22 | // state. The structure contains DenomAuthorityMetadata which defines the 23 | // denom's admin. 24 | message GenesisDenom { 25 | option (gogoproto.equal) = true; 26 | 27 | string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; 28 | DenomAuthorityMetadata authority_metadata = 2 [ 29 | (gogoproto.moretags) = "yaml:\"authority_metadata\"", 30 | (gogoproto.nullable) = false 31 | ]; 32 | string name = 3 [ (gogoproto.moretags) = "yaml:\"name\"" ]; 33 | string symbol = 4 [ (gogoproto.moretags) = "yaml:\"symbol\"" ]; 34 | uint32 decimals = 5 [ (gogoproto.moretags) = "yaml:\"decimals\"" ]; 35 | } 36 | -------------------------------------------------------------------------------- /proto/injective/tokenfactory/v1beta1/params.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.tokenfactory.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "injective/tokenfactory/v1beta1/authorityMetadata.proto"; 6 | import "cosmos_proto/cosmos.proto"; 7 | import "cosmos/base/v1beta1/coin.proto"; 8 | import "amino/amino.proto"; 9 | 10 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/tokenfactory/types"; 11 | 12 | // Params defines the parameters for the tokenfactory module. 13 | message Params { 14 | option (amino.name) = "injective/tokenfactory/Params"; 15 | 16 | repeated cosmos.base.v1beta1.Coin denom_creation_fee = 1 [ 17 | (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", 18 | (gogoproto.moretags) = "yaml:\"denom_creation_fee\"", 19 | (gogoproto.nullable) = false 20 | ]; 21 | } 22 | -------------------------------------------------------------------------------- /proto/injective/txfees/v1beta1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.txfees.v1beta1; 3 | 4 | import "injective/txfees/v1beta1/txfees.proto"; 5 | import "gogoproto/gogo.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/txfees/types"; 8 | 9 | message GenesisState { Params params = 1 [ (gogoproto.nullable) = false ]; } 10 | -------------------------------------------------------------------------------- /proto/injective/txfees/v1beta1/query.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.txfees.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "google/api/annotations.proto"; 6 | import "injective/txfees/v1beta1/txfees.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/txfees/types"; 9 | 10 | service Query { 11 | // Params defines a gRPC query method that returns the tokenfactory module's 12 | // parameters. 13 | rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { 14 | option (google.api.http).get = "/injective/txfees/v1beta1/params"; 15 | } 16 | 17 | // Returns the current fee market EIP fee. 18 | rpc GetEipBaseFee(QueryEipBaseFeeRequest) returns (QueryEipBaseFeeResponse) { 19 | option (google.api.http) = { 20 | get : "/injective/txfees/v1beta1/cur_eip_base_fee" 21 | }; 22 | } 23 | } 24 | 25 | message EipBaseFee { 26 | string base_fee = 1 [ 27 | (gogoproto.moretags) = "yaml:\"base_fee\"", 28 | (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", 29 | (gogoproto.nullable) = false 30 | ]; 31 | } 32 | 33 | // QueryParamsRequest is the request type for the Query/Params RPC method. 34 | message QueryParamsRequest {} 35 | // QueryParamsResponse is the response type for the Query/Params RPC method. 36 | message QueryParamsResponse { 37 | // params defines the parameters of the module. 38 | Params params = 1 [ (gogoproto.nullable) = false ]; 39 | } 40 | 41 | message QueryEipBaseFeeRequest {} 42 | message QueryEipBaseFeeResponse { EipBaseFee base_fee = 1; } 43 | -------------------------------------------------------------------------------- /proto/injective/txfees/v1beta1/tx.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.txfees.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "cosmos/msg/v1/msg.proto"; 6 | import "cosmos_proto/cosmos.proto"; 7 | import "injective/txfees/v1beta1/txfees.proto"; 8 | import "amino/amino.proto"; 9 | 10 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/txfees/types"; 11 | 12 | // Msg defines the auction Msg service. 13 | service Msg { 14 | option (cosmos.msg.v1.service) = true; 15 | 16 | rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); 17 | } 18 | 19 | message MsgUpdateParams { 20 | option (cosmos.msg.v1.signer) = "authority"; 21 | option (amino.name) = "txfees/MsgUpdateParams"; 22 | 23 | // authority is the address of the governance account. 24 | string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; 25 | 26 | // params defines the ocr parameters to update. 27 | // 28 | // NOTE: All parameters must be supplied. 29 | Params params = 2 [ (gogoproto.nullable) = false ]; 30 | } 31 | 32 | message MsgUpdateParamsResponse {} -------------------------------------------------------------------------------- /proto/injective/types/v1beta1/account.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.types.v1beta1; 3 | 4 | import "cosmos/auth/v1beta1/auth.proto"; 5 | import "cosmos_proto/cosmos.proto"; 6 | import "gogoproto/gogo.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/types"; 9 | 10 | // EthAccount implements the authtypes.AccountI interface and embeds an 11 | // authtypes.BaseAccount type. It is compatible with the auth AccountKeeper. 12 | message EthAccount { 13 | option (gogoproto.goproto_getters) = false; 14 | option (gogoproto.goproto_stringer) = false; 15 | option (gogoproto.equal) = false; 16 | 17 | option (cosmos_proto.implements_interface) = "cosmos.auth.v1beta1.AccountI"; 18 | 19 | cosmos.auth.v1beta1.BaseAccount base_account = 1 [ 20 | (gogoproto.embed) = true, 21 | (gogoproto.moretags) = "yaml:\"base_account\"" 22 | ]; 23 | bytes code_hash = 2 [ (gogoproto.moretags) = "yaml:\"code_hash\"" ]; 24 | } 25 | -------------------------------------------------------------------------------- /proto/injective/types/v1beta1/tx_ext.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.types.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | 6 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/types"; 7 | 8 | message ExtensionOptionsWeb3Tx { 9 | option (gogoproto.goproto_getters) = false; 10 | 11 | // typedDataChainID used only in EIP712 Domain and should match 12 | // Ethereum network ID in a Web3 provider (e.g. Metamask). 13 | uint64 typedDataChainID = 1; 14 | 15 | // feePayer is an account address for the fee payer. It will be validated 16 | // during EIP712 signature checking. 17 | string feePayer = 2; 18 | 19 | // feePayerSig is a signature data from the fee paying account, 20 | // allows to perform fee delegation when using EIP712 Domain. 21 | bytes feePayerSig = 3; 22 | } 23 | -------------------------------------------------------------------------------- /proto/injective/types/v1beta1/tx_response.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.types.v1beta1; 3 | 4 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/types"; 5 | 6 | // base header ak message type, we can cast the bytes into corresponding message 7 | // response type 8 | message TxResponseGenericMessage { 9 | string header = 1; 10 | bytes data = 2; 11 | } 12 | 13 | // improvised message to unpack length prefixed messages in tx response data 14 | message TxResponseData { repeated TxResponseGenericMessage messages = 1; } 15 | -------------------------------------------------------------------------------- /proto/injective/wasmx/v1/authz.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.wasmx.v1; 3 | 4 | import "cosmwasm/wasm/v1/authz.proto"; 5 | import "cosmos_proto/cosmos.proto"; 6 | import "amino/amino.proto"; 7 | import "gogoproto/gogo.proto"; 8 | 9 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/wasmx/types"; 10 | 11 | // ContractExecutionAuthorization defines authorization for wasm execute. 12 | // Since: wasmd 0.30 13 | message ContractExecutionCompatAuthorization { 14 | option (amino.name) = "wasmx/ContractExecutionCompatAuthorization"; 15 | option (cosmos_proto.implements_interface) = 16 | "cosmos.authz.v1beta1.Authorization"; 17 | 18 | // Grants for contract executions 19 | repeated cosmwasm.wasm.v1.ContractGrant grants = 1 20 | [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; 21 | } -------------------------------------------------------------------------------- /proto/injective/wasmx/v1/events.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.wasmx.v1; 3 | 4 | import "injective/wasmx/v1/wasmx.proto"; 5 | import "injective/wasmx/v1/proposal.proto"; 6 | import "gogoproto/gogo.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/wasmx/types"; 9 | 10 | message EventContractExecution { 11 | string contract_address = 1; 12 | bytes response = 2; 13 | string other_error = 3; 14 | string execution_error = 4; 15 | } 16 | 17 | message EventContractRegistered { 18 | string contract_address = 1; 19 | uint64 gas_price = 3; 20 | bool should_pin_contract = 4; 21 | bool is_migration_allowed = 5; 22 | uint64 code_id = 6; 23 | string admin_address = 7; 24 | string granter_address = 8; 25 | FundingMode funding_mode = 9; 26 | } 27 | 28 | message EventContractDeregistered { string contract_address = 1; } 29 | -------------------------------------------------------------------------------- /proto/injective/wasmx/v1/genesis.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package injective.wasmx.v1; 3 | 4 | import "injective/wasmx/v1/wasmx.proto"; 5 | import "gogoproto/gogo.proto"; 6 | 7 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/wasmx/types"; 8 | 9 | message RegisteredContractWithAddress { 10 | string address = 1; 11 | 12 | RegisteredContract registered_contract = 2; 13 | } 14 | 15 | // GenesisState defines the wasmx module's genesis state. 16 | message GenesisState { 17 | // params defines all the parameters of related to wasmx. 18 | Params params = 1 [ (gogoproto.nullable) = false ]; 19 | 20 | // registered_contracts is an array containing the genesis registered 21 | // contracts 22 | repeated RegisteredContractWithAddress registered_contracts = 2 23 | [ (gogoproto.nullable) = false ]; 24 | } 25 | -------------------------------------------------------------------------------- /proto/osmosis/txfees/v1beta1/query.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package osmosis.txfees.v1beta1; 3 | 4 | import "gogoproto/gogo.proto"; 5 | import "google/api/annotations.proto"; 6 | import "google/protobuf/duration.proto"; 7 | 8 | option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/txfees/osmosis/types"; 9 | 10 | service Query { 11 | // Returns the current fee market EIP fee. 12 | rpc GetEipBaseFee(QueryEipBaseFeeRequest) returns (QueryEipBaseFeeResponse) { 13 | option (google.api.http).get = "/osmosis/txfees/v1beta1/cur_eip_base_fee"; 14 | } 15 | } 16 | 17 | message QueryEipBaseFeeRequest {} 18 | message QueryEipBaseFeeResponse { 19 | string base_fee = 1 [ 20 | (gogoproto.moretags) = "yaml:\"base_fee\"", 21 | 22 | (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", 23 | (gogoproto.nullable) = false 24 | ]; 25 | } 26 | --------------------------------------------------------------------------------