|
| 1 | +package oracle |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/Peersyst/xrpl-go/xrpl/queries/common" |
| 5 | + "github.com/Peersyst/xrpl-go/xrpl/queries/oracle/types" |
| 6 | + "github.com/Peersyst/xrpl-go/xrpl/queries/version" |
| 7 | +) |
| 8 | + |
| 9 | +// ############################################################################ |
| 10 | +// Request |
| 11 | +// ############################################################################ |
| 12 | + |
| 13 | +// The `get_aggregate_price` method retrieves the aggregate price of specified Oracle objects, |
| 14 | +// returning three price statistics: mean, median, and trimmed mean. |
| 15 | +// Returns an GetAggregatePriceResponse. |
| 16 | +type GetAggregatePriceRequest struct { |
| 17 | + common.BaseRequest |
| 18 | + // The currency code of the asset to be priced. |
| 19 | + BaseAsset string `json:"base_asset"` |
| 20 | + // The currency code of the asset to quote the price of the base asset. |
| 21 | + QuoteAsset string `json:"quote_asset"` |
| 22 | + // The oracles identifiers |
| 23 | + Oracles []types.Oracle `json:"oracles"` |
| 24 | + // The percentage of outliers to trim. Valid trim range is 1-25. If included, the API |
| 25 | + // returns statistics for the trimmed mean. |
| 26 | + Trim uint32 `json:"trim,omitempty"` |
| 27 | + // Defines a time range in seconds for filtering out older price data. Default value is 0, |
| 28 | + // which doesn't filter any data. |
| 29 | + TrimThreshold uint32 `json:"trim_threshold,omitempty"` |
| 30 | +} |
| 31 | + |
| 32 | +func (r *GetAggregatePriceRequest) Method() string { |
| 33 | + return "get_aggregate_price" |
| 34 | +} |
| 35 | + |
| 36 | +func (r *GetAggregatePriceRequest) APIVersion() int { |
| 37 | + return version.RippledAPIV2 |
| 38 | +} |
| 39 | + |
| 40 | +func (r *GetAggregatePriceRequest) Validate() error { |
| 41 | + return nil |
| 42 | +} |
| 43 | + |
| 44 | +// ############################################################################ |
| 45 | +// Response |
| 46 | +// ############################################################################ |
| 47 | + |
| 48 | +// The expected response from the get_aggregate_price method. |
| 49 | +type GetAggregatePriceResponse struct { |
| 50 | + // The statistics from the collected oracle prices. |
| 51 | + EntireSet types.Set `json:"entire_set"` |
| 52 | + // The trimmed statistics from the collected oracle prices. Only appears if the trim field was specified in the request. |
| 53 | + TrimmedSet types.Set `json:"trimmed_set,omitempty"` |
| 54 | + // The median of the collected oracle prices. |
| 55 | + Median string `json:"median"` |
| 56 | + // The most recent timestamp out of all LastUpdateTime values. |
| 57 | + Time uint `json:"time"` |
| 58 | + // The ledger index of the ledger version that was used to generate this |
| 59 | + // response. |
| 60 | + LedgerCurrentIndex common.LedgerIndex `json:"ledger_current_index"` |
| 61 | + // If included and set to true, the information in this response comes from |
| 62 | + // a validated ledger version. Otherwise, the information is subject to |
| 63 | + // change. |
| 64 | + Validated bool `json:"validated"` |
| 65 | +} |
0 commit comments