github.com/InjectiveLabs/sdk-go@v1.53.0/proto/injective/exchange/v1beta1/exchange.proto (about)

     1  syntax = "proto3";
     2  package injective.exchange.v1beta1;
     3  
     4  import "gogoproto/gogo.proto";
     5  import "cosmos/base/v1beta1/coin.proto";
     6  import "injective/oracle/v1beta1/oracle.proto";
     7  import "amino/amino.proto";
     8  
     9  option go_package = "github.com/InjectiveLabs/injective-core/injective-chain/modules/exchange/types";
    10  
    11  enum AtomicMarketOrderAccessLevel {
    12    Nobody = 0;
    13    // currently unsupported
    14    BeginBlockerSmartContractsOnly = 1;
    15    SmartContractsOnly = 2;
    16    Everyone = 3;
    17  }
    18  
    19  message Params {
    20    option (gogoproto.equal) = true;
    21    option (amino.name) = "exchange/Params";
    22  
    23    // spot_market_instant_listing_fee defines the expedited fee in INJ required
    24    // to create a spot market by bypassing governance
    25    cosmos.base.v1beta1.Coin spot_market_instant_listing_fee = 1
    26        [ (gogoproto.nullable) = false ];
    27  
    28    // derivative_market_instant_listing_fee defines the expedited fee in INJ
    29    // required to create a derivative market by bypassing governance
    30    cosmos.base.v1beta1.Coin derivative_market_instant_listing_fee = 2
    31        [ (gogoproto.nullable) = false ];
    32  
    33    // default_spot_maker_fee defines the default exchange trade fee for makers on
    34    // a spot market
    35    string default_spot_maker_fee_rate = 3 [
    36      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    37      (gogoproto.nullable) = false
    38    ];
    39  
    40    // default_spot_taker_fee_rate defines the default exchange trade fee rate for
    41    // takers on a new spot market
    42    string default_spot_taker_fee_rate = 4 [
    43      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    44      (gogoproto.nullable) = false
    45    ];
    46  
    47    // default_derivative_maker_fee defines the default exchange trade fee for
    48    // makers on a new derivative market
    49    string default_derivative_maker_fee_rate = 5 [
    50      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    51      (gogoproto.nullable) = false
    52    ];
    53  
    54    // default_derivative_taker_fee defines the default exchange trade fee for
    55    // takers on a new derivative market
    56    string default_derivative_taker_fee_rate = 6 [
    57      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    58      (gogoproto.nullable) = false
    59    ];
    60  
    61    // default_initial_margin_ratio defines the default initial margin ratio on a
    62    // new derivative market
    63    string default_initial_margin_ratio = 7 [
    64      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    65      (gogoproto.nullable) = false
    66    ];
    67  
    68    // default_maintenance_margin_ratio defines the default maintenance margin
    69    // ratio on a new derivative market
    70    string default_maintenance_margin_ratio = 8 [
    71      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    72      (gogoproto.nullable) = false
    73    ];
    74  
    75    // default_funding_interval defines the default funding interval on a
    76    // derivative market
    77    int64 default_funding_interval = 9;
    78  
    79    // funding_multiple defines the timestamp multiple that the funding timestamp
    80    // should be a multiple of
    81    int64 funding_multiple = 10;
    82  
    83    // relayer_fee_share_rate defines the trade fee share percentage that goes to
    84    // relayers
    85    string relayer_fee_share_rate = 11 [
    86      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    87      (gogoproto.nullable) = false
    88    ];
    89  
    90    // default_hourly_funding_rate_cap defines the default maximum absolute value
    91    // of the hourly funding rate
    92    string default_hourly_funding_rate_cap = 12 [
    93      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
    94      (gogoproto.nullable) = false
    95    ];
    96  
    97    // hourly_interest_rate defines the hourly interest rate
    98    string default_hourly_interest_rate = 13 [
    99      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   100      (gogoproto.nullable) = false
   101    ];
   102  
   103    // max_derivative_order_side_count defines the maximum number of derivative
   104    // active orders a subaccount can have for a given orderbook side
   105    uint32 max_derivative_order_side_count = 14;
   106  
   107    // inj_reward_staked_requirement_threshold defines the threshold on INJ
   108    // rewards after which one also needs staked INJ to receive more
   109    string inj_reward_staked_requirement_threshold = 15 [
   110      (gogoproto.customtype) = "cosmossdk.io/math.Int",
   111      (gogoproto.nullable) = false
   112    ];
   113  
   114    // the trading_rewards_vesting_duration defines the vesting times for trading
   115    // rewards
   116    int64 trading_rewards_vesting_duration = 16;
   117  
   118    // liquidator_reward_share_rate defines the ratio of the split of the surplus
   119    // collateral that goes to the liquidator
   120    string liquidator_reward_share_rate = 17 [
   121      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   122      (gogoproto.nullable) = false
   123    ];
   124    // binary_options_market_instant_listing_fee defines the expedited fee in INJ
   125    // required to create a derivative market by bypassing governance
   126    cosmos.base.v1beta1.Coin binary_options_market_instant_listing_fee = 18
   127        [ (gogoproto.nullable) = false ];
   128    // atomic_market_order_access_level defines the required access permissions
   129    // for executing atomic market orders
   130    AtomicMarketOrderAccessLevel atomic_market_order_access_level = 19;
   131  
   132    // spot_atomic_market_order_fee_multiplier defines the default multiplier for
   133    // executing atomic market orders in spot markets
   134    string spot_atomic_market_order_fee_multiplier = 20 [
   135      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   136      (gogoproto.nullable) = false
   137    ];
   138  
   139    // derivative_atomic_market_order_fee_multiplier defines the default
   140    // multiplier for executing atomic market orders in derivative markets
   141    string derivative_atomic_market_order_fee_multiplier = 21 [
   142      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   143      (gogoproto.nullable) = false
   144    ];
   145  
   146    // binary_options_atomic_market_order_fee_multiplier defines the default
   147    // multiplier for executing atomic market orders in binary markets
   148    string binary_options_atomic_market_order_fee_multiplier = 22 [
   149      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   150      (gogoproto.nullable) = false
   151    ];
   152  
   153    // minimal_protocol_fee_rate defines the minimal protocol fee rate
   154    string minimal_protocol_fee_rate = 23 [
   155      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   156      (gogoproto.nullable) = false
   157    ];
   158  
   159    // is_instant_derivative_market_launch_enabled defines whether instant
   160    // derivative market launch is enabled
   161    bool is_instant_derivative_market_launch_enabled = 24;
   162  
   163    int64 post_only_mode_height_threshold = 25;
   164  
   165    // Maximum time in seconds since the last mark price update to allow a
   166    // decrease in margin
   167    int64 margin_decrease_price_timestamp_threshold_seconds = 26;
   168  
   169    // List of addresses that are allowed to perform exchange admin operations
   170    repeated string exchange_admins = 27;
   171  
   172    // inj_auction_max_cap defines the maximum cap for INJ sent to auction
   173    string inj_auction_max_cap = 28 [
   174      (gogoproto.customtype) = "cosmossdk.io/math.Int",
   175      (gogoproto.nullable) = false
   176    ];
   177  }
   178  
   179  enum MarketStatus {
   180    Unspecified = 0;
   181    Active = 1;
   182    Paused = 2;
   183    Demolished = 3;
   184    Expired = 4;
   185  }
   186  
   187  message MarketFeeMultiplier {
   188    option (gogoproto.goproto_getters) = false;
   189  
   190    string market_id = 1;
   191  
   192    string fee_multiplier = 2 [
   193      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   194      (gogoproto.nullable) = false
   195    ];
   196  }
   197  
   198  // An object describing a derivative market in the Injective Futures Protocol.
   199  message DerivativeMarket {
   200    option (gogoproto.goproto_getters) = false;
   201  
   202    // Ticker for the derivative contract.
   203    string ticker = 1;
   204    // Oracle base currency
   205    string oracle_base = 2;
   206    // Oracle quote currency
   207    string oracle_quote = 3;
   208    // Oracle type
   209    injective.oracle.v1beta1.OracleType oracle_type = 4;
   210    // Scale factor for oracle prices.
   211    uint32 oracle_scale_factor = 5;
   212    // Address of the quote currency denomination for the derivative contract
   213    string quote_denom = 6;
   214    // Unique market ID.
   215    string market_id = 7;
   216    // initial_margin_ratio defines the initial margin ratio of a derivative
   217    // market
   218    string initial_margin_ratio = 8 [
   219      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   220      (gogoproto.nullable) = false
   221    ];
   222    // maintenance_margin_ratio defines the maintenance margin ratio of a
   223    // derivative market
   224    string maintenance_margin_ratio = 9 [
   225      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   226      (gogoproto.nullable) = false
   227    ];
   228    // maker_fee_rate defines the maker fee rate of a derivative market
   229    string maker_fee_rate = 10 [
   230      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   231      (gogoproto.nullable) = false
   232    ];
   233    // taker_fee_rate defines the taker fee rate of a derivative market
   234    string taker_fee_rate = 11 [
   235      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   236      (gogoproto.nullable) = false
   237    ];
   238    // relayer_fee_share_rate defines the percentage of the transaction fee shared
   239    // with the relayer in a derivative market
   240    string relayer_fee_share_rate = 12 [
   241      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   242      (gogoproto.nullable) = false
   243    ];
   244    // true if the market is a perpetual market. false if the market is an expiry
   245    // futures market
   246    bool isPerpetual = 13;
   247    // Status of the market
   248    MarketStatus status = 14;
   249    // min_price_tick_size defines the minimum tick size that the price and margin
   250    // required for orders in the market
   251    string min_price_tick_size = 15 [
   252      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   253      (gogoproto.nullable) = false
   254    ];
   255    // min_quantity_tick_size defines the minimum tick size of the quantity
   256    // required for orders in the market
   257    string min_quantity_tick_size = 16 [
   258      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   259      (gogoproto.nullable) = false
   260    ];
   261    // min_notional defines the minimum notional (in quote asset) required for
   262    // orders in the market
   263    string min_notional = 17 [
   264      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   265      (gogoproto.nullable) = false
   266    ];
   267  
   268    // current market admin
   269    string admin = 18;
   270    // level of admin permissions
   271    uint32 admin_permissions = 19;
   272  }
   273  // An object describing a binary options market in Injective Protocol.
   274  message BinaryOptionsMarket {
   275    option (gogoproto.goproto_getters) = false;
   276  
   277    // Ticker for the derivative contract.
   278    string ticker = 1;
   279    // Oracle symbol
   280    string oracle_symbol = 2;
   281    // Oracle Provider
   282    string oracle_provider = 3;
   283    // Oracle type
   284    injective.oracle.v1beta1.OracleType oracle_type = 4;
   285    // Scale factor for oracle prices.
   286    uint32 oracle_scale_factor = 5;
   287    // expiration timestamp
   288    int64 expiration_timestamp = 6;
   289    // expiration timestamp
   290    int64 settlement_timestamp = 7;
   291    // admin of the market
   292    string admin = 8;
   293    // Address of the quote currency denomination for the binary options contract
   294    string quote_denom = 9;
   295    // Unique market ID.
   296    string market_id = 10;
   297    // maker_fee_rate defines the maker fee rate of a binary options market
   298    string maker_fee_rate = 11 [
   299      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   300      (gogoproto.nullable) = false
   301    ];
   302    // taker_fee_rate defines the taker fee rate of a derivative market
   303    string taker_fee_rate = 12 [
   304      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   305      (gogoproto.nullable) = false
   306    ];
   307    // relayer_fee_share_rate defines the percentage of the transaction fee shared
   308    // with the relayer in a derivative market
   309    string relayer_fee_share_rate = 13 [
   310      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   311      (gogoproto.nullable) = false
   312    ];
   313    // Status of the market
   314    MarketStatus status = 14;
   315    // min_price_tick_size defines the minimum tick size that the price and margin
   316    // required for orders in the market
   317    string min_price_tick_size = 15 [
   318      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   319      (gogoproto.nullable) = false
   320    ];
   321    // min_quantity_tick_size defines the minimum tick size of the quantity
   322    // required for orders in the market
   323    string min_quantity_tick_size = 16 [
   324      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   325      (gogoproto.nullable) = false
   326    ];
   327  
   328    string settlement_price = 17 [
   329      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   330      (gogoproto.nullable) = true
   331    ];
   332    // min_notional defines the minimum notional (in quote asset) required for
   333    // orders in the market
   334    string min_notional = 18 [
   335      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   336      (gogoproto.nullable) = false
   337    ];
   338    // level of admin permissions
   339    uint32 admin_permissions = 19;
   340  }
   341  
   342  message ExpiryFuturesMarketInfo {
   343    // market ID.
   344    string market_id = 1;
   345    // expiration_timestamp defines the expiration time for a time expiry futures
   346    // market.
   347    int64 expiration_timestamp = 2;
   348    // expiration_twap_start_timestamp defines the start time of the TWAP
   349    // calculation window
   350    int64 twap_start_timestamp = 3;
   351    // expiration_twap_start_price_cumulative defines the cumulative price for the
   352    // start of the TWAP window
   353    string expiration_twap_start_price_cumulative = 4 [
   354      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   355      (gogoproto.nullable) = false
   356    ];
   357    // settlement_price defines the settlement price for a time expiry futures
   358    // market.
   359    string settlement_price = 5 [
   360      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   361      (gogoproto.nullable) = false
   362    ];
   363  }
   364  
   365  message PerpetualMarketInfo {
   366    // market ID.
   367    string market_id = 1;
   368    // hourly_funding_rate_cap defines the maximum absolute value of the hourly
   369    // funding rate
   370    string hourly_funding_rate_cap = 2 [
   371      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   372      (gogoproto.nullable) = false
   373    ];
   374    // hourly_interest_rate defines the hourly interest rate
   375    string hourly_interest_rate = 3 [
   376      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   377      (gogoproto.nullable) = false
   378    ];
   379    // next_funding_timestamp defines the next funding timestamp in seconds of a
   380    // perpetual market
   381    int64 next_funding_timestamp = 4;
   382    // funding_interval defines the next funding interval in seconds of a
   383    // perpetual market.
   384    int64 funding_interval = 5;
   385  }
   386  
   387  message PerpetualMarketFunding {
   388    // cumulative_funding defines the cumulative funding of a perpetual market.
   389    string cumulative_funding = 1 [
   390      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   391      (gogoproto.nullable) = false
   392    ];
   393    // cumulative_price defines the cumulative price for the current hour up to
   394    // the last timestamp
   395    string cumulative_price = 2 [
   396      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   397      (gogoproto.nullable) = false
   398    ];
   399    int64 last_timestamp = 3;
   400  }
   401  
   402  message DerivativeMarketSettlementInfo {
   403    // market ID.
   404    string market_id = 1;
   405    // settlement_price defines the settlement price
   406    string settlement_price = 2 [
   407      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   408      (gogoproto.nullable) = false
   409    ];
   410  }
   411  
   412  message NextFundingTimestamp { int64 next_timestamp = 1; }
   413  
   414  message MidPriceAndTOB {
   415    // mid price of the market
   416    string mid_price = 1 [
   417      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   418      (gogoproto.nullable) = true
   419    ];
   420    // best buy price of the market
   421    string best_buy_price = 2 [
   422      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   423      (gogoproto.nullable) = true
   424    ];
   425    // best sell price of the market
   426    string best_sell_price = 3 [
   427      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   428      (gogoproto.nullable) = true
   429    ];
   430  }
   431  
   432  // An object describing trade pair of two assets.
   433  message SpotMarket {
   434    // A name of the pair in format AAA/BBB, where AAA is base asset, BBB is quote
   435    // asset.
   436    string ticker = 1;
   437    // Coin denom used for the base asset
   438    string base_denom = 2;
   439    // Coin used for the quote asset
   440    string quote_denom = 3;
   441    // maker_fee_rate defines the fee percentage makers pay when trading
   442    string maker_fee_rate = 4 [
   443      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   444      (gogoproto.nullable) = false
   445    ];
   446    // taker_fee_rate defines the fee percentage takers pay when trading
   447    string taker_fee_rate = 5 [
   448      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   449      (gogoproto.nullable) = false
   450    ];
   451    // relayer_fee_share_rate defines the percentage of the transaction fee shared
   452    // with the relayer in a derivative market
   453    string relayer_fee_share_rate = 6 [
   454      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   455      (gogoproto.nullable) = false
   456    ];
   457    // Unique market ID.
   458    string market_id = 7;
   459    // Status of the market
   460    MarketStatus status = 8;
   461    // min_price_tick_size defines the minimum tick size that the price required
   462    // for orders in the market
   463    string min_price_tick_size = 9 [
   464      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   465      (gogoproto.nullable) = false
   466    ];
   467    // min_quantity_tick_size defines the minimum tick size of the quantity
   468    // required for orders in the market
   469    string min_quantity_tick_size = 10 [
   470      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   471      (gogoproto.nullable) = false
   472    ];
   473    // min_notional defines the minimum notional (in quote asset) required for
   474    // orders in the market
   475    string min_notional = 11 [
   476      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   477      (gogoproto.nullable) = false
   478    ];
   479  
   480    // current market admin
   481    string admin = 12;
   482    // level of admin permissions
   483    uint32 admin_permissions = 13;
   484  }
   485  
   486  // A subaccount's deposit for a given base currency
   487  message Deposit {
   488    string available_balance = 1 [
   489      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   490      (gogoproto.nullable) = false
   491    ];
   492    string total_balance = 2 [
   493      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   494      (gogoproto.nullable) = false
   495    ];
   496  }
   497  
   498  message SubaccountTradeNonce { uint32 nonce = 1; }
   499  
   500  message OrderInfo {
   501    // bytes32 subaccount ID that created the order
   502    string subaccount_id = 1;
   503    // address fee_recipient address that will receive fees for the order
   504    string fee_recipient = 2;
   505    // price of the order
   506    string price = 3 [
   507      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   508      (gogoproto.nullable) = false
   509    ];
   510    // quantity of the order
   511    string quantity = 4 [
   512      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   513      (gogoproto.nullable) = false
   514    ];
   515    string cid = 5;
   516  }
   517  
   518  enum OrderType {
   519    UNSPECIFIED = 0 [ (gogoproto.enumvalue_customname) = "UNSPECIFIED" ];
   520    BUY = 1 [ (gogoproto.enumvalue_customname) = "BUY" ];
   521    SELL = 2 [ (gogoproto.enumvalue_customname) = "SELL" ];
   522    STOP_BUY = 3 [ (gogoproto.enumvalue_customname) = "STOP_BUY" ];
   523    STOP_SELL = 4 [ (gogoproto.enumvalue_customname) = "STOP_SELL" ];
   524    TAKE_BUY = 5 [ (gogoproto.enumvalue_customname) = "TAKE_BUY" ];
   525    TAKE_SELL = 6 [ (gogoproto.enumvalue_customname) = "TAKE_SELL" ];
   526    BUY_PO = 7 [ (gogoproto.enumvalue_customname) = "BUY_PO" ];
   527    SELL_PO = 8 [ (gogoproto.enumvalue_customname) = "SELL_PO" ];
   528    BUY_ATOMIC = 9 [ (gogoproto.enumvalue_customname) = "BUY_ATOMIC" ];
   529    SELL_ATOMIC = 10 [ (gogoproto.enumvalue_customname) = "SELL_ATOMIC" ];
   530  }
   531  
   532  message SpotOrder {
   533    // market_id represents the unique ID of the market
   534    string market_id = 1;
   535    // order_info contains the information of the order
   536    OrderInfo order_info = 2 [ (gogoproto.nullable) = false ];
   537    // order types
   538    OrderType order_type = 3;
   539    // trigger_price is the trigger price used by stop/take orders
   540    string trigger_price = 4 [
   541      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   542      (gogoproto.nullable) = true
   543    ];
   544  }
   545  
   546  // A valid Spot limit order with Metadata.
   547  message SpotLimitOrder {
   548    // order_info contains the information of the order
   549    OrderInfo order_info = 1 [ (gogoproto.nullable) = false ];
   550    // order types
   551    OrderType order_type = 2;
   552    // the amount of the quantity remaining fillable
   553    string fillable = 3 [
   554      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   555      (gogoproto.nullable) = false
   556    ];
   557    // trigger_price is the trigger price used by stop/take orders
   558    string trigger_price = 4 [
   559      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   560      (gogoproto.nullable) = true
   561    ];
   562    bytes order_hash = 5;
   563  }
   564  
   565  // A valid Spot market order with Metadata.
   566  message SpotMarketOrder {
   567    // order_info contains the information of the order
   568    OrderInfo order_info = 1 [ (gogoproto.nullable) = false ];
   569    string balance_hold = 2 [
   570      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   571      (gogoproto.nullable) = false
   572    ];
   573    bytes order_hash = 3;
   574    // order types
   575    OrderType order_type = 4;
   576    // trigger_price is the trigger price used by stop/take orders
   577    string trigger_price = 5 [
   578      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   579      (gogoproto.nullable) = true
   580    ];
   581  }
   582  
   583  message DerivativeOrder {
   584    // market_id represents the unique ID of the market
   585    string market_id = 1;
   586    // order_info contains the information of the order
   587    OrderInfo order_info = 2 [ (gogoproto.nullable) = false ];
   588    // order types
   589    OrderType order_type = 3;
   590    // margin is the margin used by the limit order
   591    string margin = 4 [
   592      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   593      (gogoproto.nullable) = false
   594    ];
   595    // trigger_price is the trigger price used by stop/take orders
   596    string trigger_price = 5 [
   597      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   598      (gogoproto.nullable) = true
   599    ];
   600  }
   601  
   602  message SubaccountOrderbookMetadata {
   603    uint32 vanilla_limit_order_count = 1;
   604    uint32 reduce_only_limit_order_count = 2;
   605    // AggregateReduceOnlyQuantity is the aggregate fillable quantity of the
   606    // subaccount's reduce-only limit orders in the given direction.
   607    string aggregate_reduce_only_quantity = 3 [
   608      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   609      (gogoproto.nullable) = false
   610    ];
   611    // AggregateVanillaQuantity is the aggregate fillable quantity of the
   612    // subaccount's vanilla limit orders in the given direction.
   613    string aggregate_vanilla_quantity = 4 [
   614      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   615      (gogoproto.nullable) = false
   616    ];
   617  
   618    uint32 vanilla_conditional_order_count = 5;
   619    uint32 reduce_only_conditional_order_count = 6;
   620  }
   621  
   622  message SubaccountOrder {
   623    // price of the order
   624    string price = 1 [
   625      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   626      (gogoproto.nullable) = false
   627    ];
   628    // the amount of the quantity remaining fillable
   629    string quantity = 2 [
   630      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   631      (gogoproto.nullable) = false
   632    ];
   633    bool isReduceOnly = 3;
   634    string cid = 4;
   635  }
   636  
   637  message SubaccountOrderData {
   638    SubaccountOrder order = 1;
   639    bytes order_hash = 2;
   640  }
   641  
   642  // A valid Derivative limit order with Metadata.
   643  message DerivativeLimitOrder {
   644    // order_info contains the information of the order
   645    OrderInfo order_info = 1 [ (gogoproto.nullable) = false ];
   646    // order types
   647    OrderType order_type = 2;
   648    // margin is the margin used by the limit order
   649    string margin = 3 [
   650      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   651      (gogoproto.nullable) = false
   652    ];
   653    // the amount of the quantity remaining fillable
   654    string fillable = 4 [
   655      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   656      (gogoproto.nullable) = false
   657    ];
   658    // trigger_price is the trigger price used by stop/take orders
   659    string trigger_price = 5 [
   660      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   661      (gogoproto.nullable) = true
   662    ];
   663    bytes order_hash = 6;
   664  }
   665  
   666  // A valid Derivative market order with Metadata.
   667  message DerivativeMarketOrder {
   668    // order_info contains the information of the order
   669    OrderInfo order_info = 1 [ (gogoproto.nullable) = false ];
   670    // order types
   671    OrderType order_type = 2;
   672    string margin = 3 [
   673      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   674      (gogoproto.nullable) = false
   675    ];
   676    string margin_hold = 4 [
   677      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   678      (gogoproto.nullable) = false
   679    ];
   680    // trigger_price is the trigger price used by stop/take orders
   681    string trigger_price = 5 [
   682      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   683      (gogoproto.nullable) = true
   684    ];
   685    bytes order_hash = 6;
   686  }
   687  
   688  message Position {
   689    bool isLong = 1;
   690    string quantity = 2 [
   691      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   692      (gogoproto.nullable) = false
   693    ];
   694    string entry_price = 3 [
   695      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   696      (gogoproto.nullable) = false
   697    ];
   698    string margin = 4 [
   699      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   700      (gogoproto.nullable) = false
   701    ];
   702    string cumulative_funding_entry = 5 [
   703      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   704      (gogoproto.nullable) = false
   705    ];
   706  }
   707  
   708  message MarketOrderIndicator {
   709    // market_id represents the unique ID of the market
   710    string market_id = 1;
   711    bool isBuy = 2;
   712  }
   713  
   714  message TradeLog {
   715    string quantity = 1 [
   716      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   717      (gogoproto.nullable) = false
   718    ];
   719    string price = 2 [
   720      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   721      (gogoproto.nullable) = false
   722    ];
   723    // bytes32 subaccount ID that executed the trade
   724    bytes subaccount_id = 3;
   725    string fee = 4 [
   726      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   727      (gogoproto.nullable) = false
   728    ];
   729    bytes order_hash = 5;
   730    bytes fee_recipient_address = 6 [ (gogoproto.nullable) = true ];
   731    string cid = 7;
   732  }
   733  
   734  message PositionDelta {
   735    bool is_long = 1;
   736    string execution_quantity = 2 [
   737      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   738      (gogoproto.nullable) = false
   739    ];
   740    string execution_margin = 3 [
   741      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   742      (gogoproto.nullable) = false
   743    ];
   744    string execution_price = 4 [
   745      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   746      (gogoproto.nullable) = false
   747    ];
   748  }
   749  
   750  message DerivativeTradeLog {
   751    bytes subaccount_id = 1;
   752    PositionDelta position_delta = 2;
   753    string payout = 3 [
   754      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   755      (gogoproto.nullable) = false
   756    ];
   757    string fee = 4 [
   758      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   759      (gogoproto.nullable) = false
   760    ];
   761    bytes order_hash = 5;
   762    bytes fee_recipient_address = 6 [ (gogoproto.nullable) = true ];
   763    string cid = 7;
   764    string pnl = 8 [
   765      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   766      (gogoproto.nullable) = false
   767    ];
   768  }
   769  
   770  enum ExecutionType {
   771    UnspecifiedExecutionType = 0;
   772    Market = 1;
   773    LimitFill = 2;
   774    LimitMatchRestingOrder = 3;
   775    LimitMatchNewOrder = 4;
   776    MarketLiquidation = 5;
   777    ExpiryMarketSettlement = 6;
   778  }
   779  
   780  message SubaccountPosition {
   781    Position position = 1;
   782    bytes subaccount_id = 2;
   783  }
   784  
   785  message SubaccountDeposit {
   786    bytes subaccount_id = 1;
   787    Deposit deposit = 2;
   788  }
   789  
   790  message DepositUpdate {
   791    string denom = 1;
   792    repeated SubaccountDeposit deposits = 2;
   793  }
   794  
   795  message PointsMultiplier {
   796    string maker_points_multiplier = 1 [
   797      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   798      (gogoproto.nullable) = false
   799    ];
   800    string taker_points_multiplier = 2 [
   801      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   802      (gogoproto.nullable) = false
   803    ];
   804  }
   805  
   806  message TradingRewardCampaignBoostInfo {
   807    repeated string boosted_spot_market_ids = 1;
   808    repeated PointsMultiplier spot_market_multipliers = 2
   809        [ (gogoproto.nullable) = false ];
   810    repeated string boosted_derivative_market_ids = 3;
   811    repeated PointsMultiplier derivative_market_multipliers = 4
   812        [ (gogoproto.nullable) = false ];
   813  }
   814  
   815  message CampaignRewardPool {
   816    int64 start_timestamp = 1;
   817    // max_campaign_rewards are the maximum reward amounts to be disbursed at the
   818    // end of the campaign
   819    repeated cosmos.base.v1beta1.Coin max_campaign_rewards = 2 [
   820      (gogoproto.nullable) = false,
   821      (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
   822    ];
   823  }
   824  
   825  message TradingRewardCampaignInfo {
   826    // number of seconds of the duration of each campaign
   827    int64 campaign_duration_seconds = 1;
   828    // the trading fee quote denoms which will be counted for the rewards
   829    repeated string quote_denoms = 2;
   830    // the optional boost info for markets
   831    TradingRewardCampaignBoostInfo trading_reward_boost_info = 3;
   832    // the marketIDs which are disqualified from being rewarded
   833    repeated string disqualified_market_ids = 4;
   834  }
   835  
   836  message FeeDiscountTierInfo {
   837    string maker_discount_rate = 1 [
   838      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   839      (gogoproto.nullable) = false
   840    ];
   841    string taker_discount_rate = 2 [
   842      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   843      (gogoproto.nullable) = false
   844    ];
   845    string staked_amount = 3 [
   846      (gogoproto.customtype) = "cosmossdk.io/math.Int",
   847      (gogoproto.nullable) = false
   848    ];
   849    string volume = 4 [
   850      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   851      (gogoproto.nullable) = false
   852    ];
   853  }
   854  
   855  message FeeDiscountSchedule {
   856    uint64 bucket_count = 1;
   857    int64 bucket_duration = 2;
   858    // the trading fee quote denoms which will be counted for the fee paid
   859    // contribution
   860    repeated string quote_denoms = 3;
   861    // the fee discount tiers
   862    repeated FeeDiscountTierInfo tier_infos = 4;
   863    // the marketIDs which are disqualified from contributing to the fee paid
   864    // amount
   865    repeated string disqualified_market_ids = 5;
   866  }
   867  
   868  message FeeDiscountTierTTL {
   869    uint64 tier = 1;
   870    int64 ttl_timestamp = 2;
   871  }
   872  
   873  message VolumeRecord {
   874    string maker_volume = 1 [
   875      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   876      (gogoproto.nullable) = false
   877    ];
   878    string taker_volume = 2 [
   879      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   880      (gogoproto.nullable) = false
   881    ];
   882  }
   883  
   884  message AccountRewards {
   885    string account = 1;
   886    repeated cosmos.base.v1beta1.Coin rewards = 2 [
   887      (gogoproto.nullable) = false,
   888      (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
   889    ];
   890  }
   891  
   892  message TradeRecords {
   893    string market_id = 1;
   894    repeated TradeRecord latest_trade_records = 2;
   895  }
   896  
   897  message SubaccountIDs { repeated bytes subaccount_ids = 1; }
   898  
   899  message TradeRecord {
   900    int64 timestamp = 1;
   901  
   902    string price = 2 [
   903      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   904      (gogoproto.nullable) = false
   905    ];
   906  
   907    string quantity = 3 [
   908      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   909      (gogoproto.nullable) = false
   910    ];
   911  }
   912  
   913  enum OrderMask {
   914    UNUSED = 0 [ (gogoproto.enumvalue_customname) = "UNUSED" ];
   915    ANY = 1 [ (gogoproto.enumvalue_customname) = "ANY" ];
   916    REGULAR = 2 [ (gogoproto.enumvalue_customname) = "REGULAR" ];
   917    CONDITIONAL = 4 [ (gogoproto.enumvalue_customname) = "CONDITIONAL" ];
   918    DIRECTION_BUY_OR_HIGHER = 8
   919        [ (gogoproto.enumvalue_customname) =
   920              "BUY_OR_HIGHER" ]; // for conditional orders means HIGHER
   921    DIRECTION_SELL_OR_LOWER = 16
   922        [ (gogoproto.enumvalue_customname) =
   923              "SELL_OR_LOWER" ]; // for conditional orders means LOWER
   924    TYPE_MARKET = 32 [ (gogoproto.enumvalue_customname) = "MARKET" ];
   925    TYPE_LIMIT = 64 [ (gogoproto.enumvalue_customname) = "LIMIT" ];
   926  }
   927  
   928  message Level {
   929    // price
   930    string p = 1 [
   931      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   932      (gogoproto.nullable) = false
   933    ];
   934    // quantity
   935    string q = 2 [
   936      (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
   937      (gogoproto.nullable) = false
   938    ];
   939  }
   940  
   941  message AggregateSubaccountVolumeRecord {
   942    string subaccount_id = 1;
   943    repeated MarketVolume market_volumes = 2;
   944  }
   945  
   946  message AggregateAccountVolumeRecord {
   947    string account = 1;
   948    repeated MarketVolume market_volumes = 2;
   949  }
   950  
   951  message MarketVolume {
   952    string market_id = 1;
   953    VolumeRecord volume = 2 [ (gogoproto.nullable) = false ];
   954  }
   955  
   956  message DenomDecimals {
   957    string denom = 1;
   958    uint64 decimals = 2;
   959  }
   960  
   961  message GrantAuthorization {
   962    string grantee = 1;
   963    string amount = 2 [
   964      (gogoproto.customtype) = "cosmossdk.io/math.Int",
   965      (gogoproto.nullable) = false
   966    ];
   967  }
   968  
   969  message ActiveGrant {
   970    string granter = 1;
   971    string amount = 2 [
   972      (gogoproto.customtype) = "cosmossdk.io/math.Int",
   973      (gogoproto.nullable) = false
   974    ];
   975  }
   976  
   977  message EffectiveGrant {
   978    string granter = 1;
   979    string net_granted_stake = 2 [
   980      (gogoproto.customtype) = "cosmossdk.io/math.Int",
   981      (gogoproto.nullable) = false
   982    ];
   983    bool is_valid = 3;
   984  }