code.vegaprotocol.io/vega@v0.79.0/protos/sources/vega/markets.proto (about)

     1  syntax = "proto3";
     2  
     3  package vega;
     4  
     5  import "vega/data_source.proto";
     6  
     7  option go_package = "code.vegaprotocol.io/vega/protos/vega";
     8  
     9  // Auction duration is used to configure 3 auction periods:
    10  // 1. `duration > 0`, `volume == 0`:
    11  //   The auction will last for at least N seconds
    12  // 2. `duration == 0`, `volume > 0`:
    13  //   The auction will end once the given volume will match at uncrossing
    14  // 3. `duration > 0`, `volume > 0`:
    15  //   The auction will take at least N seconds, but can end sooner if the market can trade a certain volume
    16  message AuctionDuration {
    17    // Duration of the auction in seconds.
    18    int64 duration = 1;
    19    // Target uncrossing trading volume.
    20    uint64 volume = 2;
    21  }
    22  
    23  // Spot product definition
    24  message Spot {
    25    // Asset ID of the underlying base asset for the spot product.
    26    string base_asset = 1;
    27    // Asset ID of the underlying quote asset for the spot product.
    28    string quote_asset = 2;
    29  }
    30  
    31  // Future product definition
    32  message Future {
    33    // Underlying asset for the future.
    34    string settlement_asset = 1;
    35    // Quote name of the instrument.
    36    string quote_name = 2;
    37    // Data source specification that describes the settlement data source filter.
    38    vega.DataSourceSpec data_source_spec_for_settlement_data = 3;
    39  
    40    // Data source specification that describes the trading termination data source filter.
    41    vega.DataSourceSpec data_source_spec_for_trading_termination = 4;
    42  
    43    // Binding between the data spec and the data source.
    44    DataSourceSpecToFutureBinding data_source_spec_binding = 5;
    45    // If set, this product represents a capped future market.
    46    optional FutureCap cap = 6;
    47  }
    48  
    49  message FutureCap {
    50    // Set the maximum price for orders, and settlement data in market decimals.
    51    string max_price = 1;
    52    // If set to true, the settlement price must either be zero, or equal to the max price.
    53    optional bool binary_settlement = 2;
    54    // If set to true, positions must be fully collateralised so there is no default risk for any party.
    55    optional bool fully_collateralised = 3;
    56  }
    57  
    58  // Perpetual product definition
    59  message Perpetual {
    60    // Underlying asset for the perpetual.
    61    string settlement_asset = 1;
    62    // Quote name of the instrument.
    63    string quote_name = 2;
    64    // Controls how much the upcoming funding payment liability contributes to party's margin, in the range [0, 1].
    65    string margin_funding_factor = 3;
    66    // Continuously compounded interest rate used in funding rate calculation, in the range [-1, 1].
    67    string interest_rate = 4;
    68    // Lower bound for the clamp function used as part of the funding rate calculation, in the range [-1, 1].
    69    string clamp_lower_bound = 5;
    70    // Upper bound for the clamp function used as part of the funding rate calculation, in the range [-1, 1].
    71    string clamp_upper_bound = 6;
    72    // Data source spec describing the data source for settlement schedule.
    73    vega.DataSourceSpec data_source_spec_for_settlement_schedule = 7;
    74    // Data source spec describing the data source for settlement.
    75    vega.DataSourceSpec data_source_spec_for_settlement_data = 8;
    76    // Binding between the data source spec and the settlement data.
    77    DataSourceSpecToPerpetualBinding data_source_spec_binding = 9;
    78    // Factor applied to funding-rates. This scales the impact that spot price deviations have on funding payments.
    79    optional string funding_rate_scaling_factor = 10;
    80    // Lower bound for the funding-rate such that the funding-rate will never be lower than this value.
    81    optional string funding_rate_lower_bound = 11;
    82    // Upper bound for the funding-rate such that the funding-rate will never be higher than this value.
    83    optional string funding_rate_upper_bound = 12;
    84    // Optional configuration for the internal composite price used in funding payment calculation.
    85    optional CompositePriceConfiguration internal_composite_price_config = 13;
    86  }
    87  
    88  // DataSourceSpecToFutureBinding describes which property of the data source data is to be
    89  // used as settlement data and which to use as the trading terminated trigger
    90  message DataSourceSpecToFutureBinding {
    91    // Name of the property in the source data that should be used as settlement data.
    92    // If it is set to "prices.BTC.value", then the Future will use the value of
    93    // this property as settlement data.
    94    string settlement_data_property = 1;
    95    // Name of the property in the data source data that signals termination of trading.
    96    string trading_termination_property = 2;
    97  }
    98  
    99  // Describes which properties of the data source data is to be
   100  // used for settlement.
   101  message DataSourceSpecToPerpetualBinding {
   102    // Name of the property in the source data that should be used for settlement data.
   103    // If it is set to "prices.BTC.value" for example, then the perpetual market will use the value of
   104    // this property to get settlement data.
   105    string settlement_data_property = 1;
   106    // Name of the property in the source data that should be used to determine the perpetual's settlement schedule.
   107    string settlement_schedule_property = 2;
   108  }
   109  
   110  // Instrument metadata definition
   111  message InstrumentMetadata {
   112    // List of 0 or more tags.
   113    repeated string tags = 1;
   114  }
   115  
   116  // Instrument definition
   117  message Instrument {
   118    // Unique instrument ID.
   119    string id = 1;
   120    // Code for the instrument.
   121    string code = 2;
   122    // Name of the instrument.
   123    string name = 3;
   124    // Collection of instrument meta-data.
   125    InstrumentMetadata metadata = 4;
   126    // Product the instrument is composed of.
   127    oneof product {
   128      // Future.
   129      Future future = 100;
   130      // Spot.
   131      Spot spot = 101;
   132      // Perpetual.
   133      Perpetual perpetual = 102;
   134    }
   135  }
   136  
   137  // Risk model for log normal
   138  message LogNormalRiskModel {
   139    // Risk Aversion Parameter.
   140    double risk_aversion_parameter = 1;
   141    // Tau parameter of the risk model, projection horizon measured as a year fraction used in the expected shortfall
   142    // calculation to obtain the maintenance margin, must be a strictly non-negative real number.
   143    double tau = 2;
   144    // Risk model parameters for log normal.
   145    LogNormalModelParams params = 3;
   146    // And optional override for the risk factor calculated by the risk model.
   147    optional RiskFactorOverride risk_factor_override = 4;
   148  }
   149  
   150  // Risk factor override to control stable leverage
   151  message RiskFactorOverride {
   152    // Short Risk factor value.
   153    string short = 1;
   154    // Long Risk factor value.
   155    string long = 2;
   156  }
   157  
   158  // Risk model parameters for log normal
   159  message LogNormalModelParams {
   160    // Mu parameter, annualised growth rate of the underlying asset.
   161    double mu = 1;
   162    // R parameter, annualised growth rate of the risk-free asset, used for discounting of future cash flows, can be any real number.
   163    double r = 2;
   164    // Sigma parameter, annualised volatility of the underlying asset, must be a strictly non-negative real number.
   165    double sigma = 3;
   166  }
   167  
   168  // Risk model for simple modelling
   169  message SimpleRiskModel {
   170    // Risk model params for simple modelling.
   171    SimpleModelParams params = 1;
   172  }
   173  
   174  // Risk model parameters for simple modelling
   175  message SimpleModelParams {
   176    // Pre-defined risk factor value for long.
   177    double factor_long = 1;
   178    // Pre-defined risk factor value for short.
   179    double factor_short = 2;
   180    // Pre-defined maximum price move up that the model considers as valid.
   181    double max_move_up = 3;
   182    // Pre-defined minimum price move down that the model considers as valid.
   183    double min_move_down = 4;
   184    // Pre-defined constant probability of trading.
   185    double probability_of_trading = 5;
   186  }
   187  
   188  // Scaling Factors (for use in margin calculation)
   189  message ScalingFactors {
   190    // Collateral search level. If collateral dips below this value,
   191    // the system will search for collateral to release.
   192    double search_level = 1;
   193    // Initial margin level. This is the minimum amount of collateral
   194    // required to open a position in a market that requires margin.
   195    double initial_margin = 2;
   196    // Collateral release level. If a trader has collateral above this level,
   197    // the system will release collateral to a trader's general collateral account
   198    // for the asset.
   199    double collateral_release = 3;
   200  }
   201  
   202  // Margin Calculator definition
   203  message MarginCalculator {
   204    // Scaling factors for margin calculation.
   205    ScalingFactors scaling_factors = 1;
   206    // If set to true, positions must be fully collateralised so there is no default risk for any party (capped futures).
   207    optional bool fully_collateralised = 2;
   208  }
   209  
   210  // Tradable Instrument definition
   211  message TradableInstrument {
   212    // Details for the underlying instrument.
   213    Instrument instrument = 1;
   214    // Margin calculator for the instrument.
   215    MarginCalculator margin_calculator = 2;
   216    // Risk model for use by the instrument.
   217    oneof risk_model {
   218      // Log normal.
   219      LogNormalRiskModel log_normal_risk_model = 100;
   220      // Simple.
   221      SimpleRiskModel simple_risk_model = 101;
   222    }
   223  }
   224  
   225  // Fee factors definition
   226  message FeeFactors {
   227    // Market maker fee charged network wide.
   228    string maker_fee = 1;
   229    // Infrastructure fee charged network wide for staking and governance.
   230    string infrastructure_fee = 2;
   231    // Liquidity fee applied per market for market making.
   232    string liquidity_fee = 3;
   233    // Fees sent to network treasury for later use based on governance actions (network wide).
   234    string treasury_fee = 4;
   235    // Fees used to purchase governance tokens via regular auctions (network wide).
   236    string buy_back_fee = 5;
   237  }
   238  
   239  // Fees definition
   240  message Fees {
   241    // Fee factors.
   242    FeeFactors factors = 1;
   243    // Liquidity fee settings for the market describing how the fee was calculated.
   244    LiquidityFeeSettings liquidity_fee_settings = 2;
   245  }
   246  
   247  // PriceMonitoringTrigger holds together price projection horizon τ, probability level p, and auction extension duration
   248  message PriceMonitoringTrigger {
   249    // Price monitoring projection horizon τ in seconds.
   250    int64 horizon = 1;
   251    // Price monitoring probability level p.
   252    string probability = 2;
   253    // Price monitoring auction extension duration in seconds should the price
   254    // breach its theoretical level over the specified horizon at the specified
   255    // probability level.
   256    int64 auction_extension = 3;
   257  }
   258  
   259  // PriceMonitoringParameters contains a collection of triggers to be used for a given market
   260  message PriceMonitoringParameters {
   261    repeated PriceMonitoringTrigger triggers = 1;
   262  }
   263  
   264  // PriceMonitoringSettings contains the settings for price monitoring
   265  message PriceMonitoringSettings {
   266    // Specifies price monitoring parameters to be used for price monitoring purposes.
   267    PriceMonitoringParameters parameters = 1;
   268  }
   269  
   270  // LiquidityMonitoringParameters contains settings used for liquidity monitoring
   271  message LiquidityMonitoringParameters {
   272    // Specifies parameters related to target stake calculation.
   273    TargetStakeParameters target_stake_parameters = 1;
   274    // Specifies the triggering ratio for entering liquidity auction.
   275    string triggering_ratio = 2;
   276    // Specifies by how many seconds an auction should be extended if leaving the auction were to trigger a liquidity auction.
   277    int64 auction_extension = 3;
   278  }
   279  
   280  message LiquiditySLAParameters {
   281    reserved 3; // Deprecated "providers_fee_calculation_time_step"
   282  
   283    string price_range = 1;
   284    // Specifies the minimum fraction of time LPs must spend "on the book" providing their committed liquidity.
   285    string commitment_min_time_fraction = 2;
   286    // Specifies the number of liquidity epochs over which past performance will continue to affect rewards.
   287    uint64 performance_hysteresis_epochs = 4;
   288    // Specifies the maximum fraction of their accrued fees an LP that meets the SLA implied by market.liquidity.commitmentMinTimeFraction will lose to liquidity providers
   289    // that achieved a higher SLA performance than them.
   290    string sla_competition_factor = 5;
   291  }
   292  
   293  // Market settings that describe how the liquidity fee is calculated.
   294  message LiquidityFeeSettings {
   295    enum Method {
   296      METHOD_UNSPECIFIED = 0;
   297      // Fee is the smallest value of all bids, such that liquidity providers with nominated fees less than or equal to this value still have sufficient commitment to fulfil the market's target stake.
   298      METHOD_MARGINAL_COST = 1;
   299      // Fee is the weighted average of all liquidity providers' nominated fees, weighted by their committment.
   300      METHOD_WEIGHTED_AVERAGE = 2;
   301      // Fee is set by the market to a constant value irrespective of any liquidity provider's nominated fee.
   302      METHOD_CONSTANT = 3;
   303    }
   304    // Method used to calculate the market's liquidity fee.
   305    Method method = 1;
   306    // Constant liquidity fee used when using the constant fee method.
   307    optional string fee_constant = 2;
   308  }
   309  
   310  // TargetStakeParameters contains parameters used in target stake calculation
   311  message TargetStakeParameters {
   312    // Specifies length of time window expressed in seconds for target stake calculation.
   313    int64 time_window = 1;
   314    // Specifies scaling factors used in target stake calculation.
   315    double scaling_factor = 2;
   316  }
   317  
   318  // Market definition
   319  message Market {
   320    // Current state of the market
   321    enum State {
   322      // Default value, invalid
   323      STATE_UNSPECIFIED = 0;
   324      // Governance proposal valid and accepted
   325      STATE_PROPOSED = 1;
   326      // Outcome of governance votes is to reject the market
   327      STATE_REJECTED = 2;
   328      // Governance vote passes/wins
   329      STATE_PENDING = 3;
   330      // Market triggers cancellation condition or governance
   331      // votes to close before market becomes Active
   332      STATE_CANCELLED = 4;
   333      // Enactment date reached and usual auction exit checks pass
   334      STATE_ACTIVE = 5;
   335      // Price monitoring or liquidity monitoring trigger
   336      STATE_SUSPENDED = 6;
   337      // Governance vote to close (Not currently implemented)
   338      STATE_CLOSED = 7;
   339      // Defined by the product (i.e. from a product parameter,
   340      // specified in market definition, giving close date/time)
   341      STATE_TRADING_TERMINATED = 8;
   342      // Settlement triggered and completed as defined by product
   343      STATE_SETTLED = 9;
   344      // Market has been suspended via governance
   345      STATE_SUSPENDED_VIA_GOVERNANCE = 10;
   346    }
   347  
   348    // Trading mode the market is currently running, also referred to as 'market state'
   349    enum TradingMode {
   350      // Default value, this is invalid
   351      TRADING_MODE_UNSPECIFIED = 0;
   352      // Normal trading
   353      TRADING_MODE_CONTINUOUS = 1;
   354      // Auction trading (FBA)
   355      TRADING_MODE_BATCH_AUCTION = 2;
   356      // Opening auction
   357      TRADING_MODE_OPENING_AUCTION = 3;
   358      // Auction triggered by monitoring
   359      TRADING_MODE_MONITORING_AUCTION = 4;
   360      // No trading is allowed
   361      TRADING_MODE_NO_TRADING = 5;
   362      // Special auction mode triggered via governance
   363      TRADING_MODE_SUSPENDED_VIA_GOVERNANCE = 6;
   364      // Auction triggered globally by long block
   365      TRADING_MODE_LONG_BLOCK_AUCTION = 7;
   366      // Scheduled auction for automated purchase
   367      TRADING_MODE_PROTOCOL_AUTOMATED_PURCHASE_AUCTION = 8;
   368  
   369      // Note: If adding an enum value, add a matching entry in:
   370      //       - gateway/graphql/helpers_enum.go
   371      //       - gateway/graphql/schema.graphql (enum MarketTradingMode)
   372    }
   373  
   374    // Unique ID for the market.
   375    string id = 1;
   376    // Tradable instrument configuration.
   377    TradableInstrument tradable_instrument = 2;
   378    // Number of decimal places that a price must be shifted by in order to get a
   379    // correct price denominated in the currency of the market, for example:
   380    // `realPrice = price / 10^decimalPlaces`. On spot markets, also called 'size decimal places'.
   381    uint64 decimal_places = 3;
   382    // Fees configuration that apply to the market.
   383    Fees fees = 4;
   384    // Auction duration specifies how long the opening auction will run (minimum
   385    // duration and optionally a minimum traded volume).
   386    AuctionDuration opening_auction = 5;
   387    // PriceMonitoringSettings for the market.
   388    PriceMonitoringSettings price_monitoring_settings = 6;
   389    // LiquidityMonitoringParameters for the market.
   390    LiquidityMonitoringParameters liquidity_monitoring_parameters = 7;
   391    // Current mode of execution of the market.
   392    TradingMode trading_mode = 8;
   393    // Current state of the market.
   394    State state = 9;
   395    // Timestamps for when the market state changes.
   396    MarketTimestamps market_timestamps = 10;
   397    // The number of decimal places for a position.
   398    // On spot markets, used for order size, also known as 'size decimal places'.
   399    int64 position_decimal_places = 11;
   400    // Percentage move up and down from the mid price which specifies the range of
   401    // price levels over which automated liquidity provisions will be deployed.
   402    string lp_price_range = 12;
   403    // Linear slippage factor is used to cap the slippage component of maintenance margin - it is applied to the slippage volume.
   404    string linear_slippage_factor = 13;
   405    // Quadratic slippage factor is used to cap the slippage component of maintenance margin - it is applied to the square of the slippage volume.
   406    string quadratic_slippage_factor = 14;
   407    // ID of the market this market succeeds
   408    optional string parent_market_id = 15;
   409    // The fraction of the parent market's insurance pool that this market inherits; range 0 through 1.
   410    optional string insurance_pool_fraction = 16;
   411    // ID of the market that succeeds this market if it exists. This will be populated by the system when the successor market is enabled.
   412    optional string successor_market_id = 17;
   413    // Liquidity SLA parameters for the market.
   414    optional LiquiditySLAParameters liquidity_sla_params = 18;
   415    // Liquidation strategy used by this market.
   416    LiquidationStrategy liquidation_strategy = 19;
   417    // Mark price calculation configuration.
   418    CompositePriceConfiguration mark_price_configuration = 20;
   419    // The market tick size defines the minimum change in quote price for the market
   420    string tick_size = 21;
   421    // If enabled aggressive orders sent to the market will be delayed by the configured number of blocks
   422    bool enable_transaction_reordering = 22;
   423    // Number of allowed price levels between an AMM's fair price and its quote prices. An AMM definition that exceeds this will be rejected at submission.
   424    uint64 allowed_empty_amm_levels = 23;
   425    // Proposer of the market, to be used to restrict the sell side
   426    repeated string allowed_sellers = 24;
   427  }
   428  
   429  // Time stamps for important times about creating, enacting etc the market
   430  message MarketTimestamps {
   431    // Time when the market is first proposed.
   432    int64 proposed = 1;
   433    // Time when the market has been voted in and began its opening auction.
   434    int64 pending = 2;
   435    // Time when the market has left the opening auction and is ready to accept trades.
   436    int64 open = 3;
   437    // Time when the market closed.
   438    int64 close = 4;
   439  }
   440  
   441  // Liquidation strategy used when the network holds a position resulting from position resolution.
   442  message LiquidationStrategy {
   443    // Interval, in seconds, at which the network will attempt to close its position.
   444    int64 disposal_time_step = 1;
   445    // Fraction of the open position the market will try to close in a single attempt; range 0 through 1.
   446    string disposal_fraction = 2;
   447    // Size of the position that the network will try to close in a single attempt.
   448    uint64 full_disposal_size = 3;
   449    // Max fraction of the total volume of the orderbook, within liquidity bounds, that the network can use to close its position; range 0 through 1.
   450    string max_fraction_consumed = 4;
   451    // Decimal > 0 specifying the range range above and below the mid price within which the network will trade to dispose of its position.
   452    // The value can be > 1. For example, if set to 1.5, the minimum price will be 0, ie max(0, mid_price * (1 - 1.5)), and the maximum price will be mid_price * (1 + 1.5).
   453    string disposal_slippage_range = 5;
   454  }
   455  
   456  enum CompositePriceType {
   457    COMPOSITE_PRICE_TYPE_UNSPECIFIED = 0;
   458    // Composite price is calculated as a weighted average of the underlying mark prices.
   459    COMPOSITE_PRICE_TYPE_WEIGHTED = 1;
   460    // Composite price is calculated as a median of the underlying mark prices.
   461    COMPOSITE_PRICE_TYPE_MEDIAN = 2;
   462    // Composite price is calculated as the last trade price.
   463    COMPOSITE_PRICE_TYPE_LAST_TRADE = 3;
   464  }
   465  
   466  // Mark price configuration parameters.
   467  message CompositePriceConfiguration {
   468    // Decay weight used for calculation of mark price.
   469    string decay_weight = 1;
   470    // Decay power used for the calculation of mark price.
   471    uint64 decay_power = 2;
   472    // Cash amount, in asset decimals, used for the calculation of the mark price from the order book.
   473    string cash_amount = 3;
   474    // Weights for each composite price data source.
   475    repeated string source_weights = 4;
   476    // For how long a price source is considered valid. One entry for each data source
   477    // such that the first is for the trade based mark price, the second is for the book based price
   478    // the third is for the first oracle, followed by more oracle data source staleness tolerance.
   479    repeated string source_staleness_tolerance = 5;
   480    // Which method is used for the calculation of the composite price for the market.
   481    CompositePriceType composite_price_type = 6;
   482    // Additional price sources to be used for internal composite price calculation.
   483    repeated vega.DataSourceDefinition data_sources_spec = 7;
   484    // List of each price source and its corresponding binding
   485    repeated vega.SpecBindingForCompositePrice data_sources_spec_binding = 8;
   486  }
   487  
   488  // Describes which properties of the data source data are to be
   489  // used for automated purchase.
   490  message DataSourceSpecToAutomatedPurchaseBinding {
   491    // Name of the property in the source data that should be used to determine the automated purchase schedule.
   492    string auction_schedule_property = 1;
   493    // Name of the property in the source data that should be used to determine the schedule of the automated purchase auction.
   494    string auction_volume_snapshot_schedule_property = 2;
   495  }