decred.org/dcrdex@v1.0.5/client/asset/options.go (about)

     1  // This code is available on the terms of the project LICENSE.md file,
     2  // also available online at https://blueoakcouncil.org/license/1.0.0.
     3  
     4  package asset
     5  
     6  // BooleanConfig is set in a SwapOption to indicate that an options is a simple
     7  // boolean.
     8  type BooleanConfig struct {
     9  	// Reason should summarize the difference between on/off states.
    10  	Reason string `json:"reason"`
    11  }
    12  
    13  // XYRange is an option in which the user's setting of one value is reflected in
    14  // the other and possible values are restricted. The assumed relationship is
    15  // linear, e.g. y = mx + b. The value submitted to FundOrder/Swap/Redeem should
    16  // specify the x value.
    17  type XYRange struct {
    18  	Start  XYRangePoint `json:"start"`
    19  	End    XYRangePoint `json:"end"`
    20  	XUnit  string       `json:"xUnit"`
    21  	YUnit  string       `json:"yUnit"`
    22  	RoundX bool         `json:"roundX"`
    23  	RoundY bool         `json:"roundY"`
    24  }
    25  
    26  // XYRangePoint is a point specifying the start or end of an XYRange.
    27  type XYRangePoint struct {
    28  	Label string  `json:"label"`
    29  	X     float64 `json:"x"`
    30  	Y     float64 `json:"y"`
    31  }
    32  
    33  // OrderOption is an available option for an order.
    34  type OrderOption struct {
    35  	ConfigOption
    36  	QuoteAssetOnly bool `json:"quoteAssetOnly"`
    37  
    38  	// Fields below are mutually exclusive. The consumer should use nilness to
    39  	// determine what type of option to display.
    40  
    41  	// Boolean is a boolean option with two custom labels.
    42  	Boolean *BooleanConfig `json:"boolean,omitempty"`
    43  	// Range indicates a numeric input where the user can adjust the value
    44  	// between a pre-defined low and high.
    45  	XYRange *XYRange `json:"xyRange,omitempty"`
    46  }