xrpl_api/api/
fee.rs

1//! The fee command reports the current state of the open-ledger requirements
2//! for the transaction cost.
3//!
4//! <https://xrpl.org/fee.html>
5
6use crate::Request;
7use serde::{Deserialize, Serialize};
8
9#[derive(Default, Debug, Clone, Serialize)]
10pub struct FeeRequest {}
11
12impl Request for FeeRequest {
13    type Response = FeeResponse;
14
15    fn method(&self) -> String {
16        "fee".to_owned()
17    }
18}
19
20impl FeeRequest {
21    pub fn new() -> Self {
22        Self::default()
23    }
24}
25
26/// Various information about the transaction cost (the Fee field of a transaction),
27/// in drops of XRP.
28#[derive(Debug, Deserialize)]
29pub struct Drops {
30    /// The transaction cost required for a reference transaction to be included
31    /// in a ledger under minimum load, represented in drops of XRP.
32    pub base_fee: String,
33    /// An approximation of the median transaction cost among transactions included
34    /// in the previous validated ledger, represented in drops of XRP.
35    pub median_fee: String,
36    /// The minimum transaction cost for a reference transaction to be queued for
37    /// a later ledger, represented in drops of XRP. If greater than base_fee,
38    /// the transaction queue is full.
39    pub minimum_fee: String,
40    /// The minimum transaction cost that a reference transaction must pay to be
41    /// included in the current open ledger, represented in drops of XRP.
42    pub open_ledger_fee: String,
43}
44
45/// Various information about the transaction cost, in fee levels. The ratio
46/// in fee levels applies to any transaction relative to the minimum cost of that
47/// particular transaction.
48#[derive(Debug, Deserialize)]
49pub struct Levels {
50    /// The median transaction cost among transactions in the previous validated
51    /// ledger, represented in fee levels.
52    pub median_level: String,
53    /// The minimum transaction cost required to be queued for a future ledger,
54    /// represented in fee levels.
55    pub minimum_level: String,
56    /// The minimum transaction cost required to be included in the current open
57    /// ledger, represented in fee levels.
58    pub open_ledger_level: String,
59    /// The equivalent of the minimum transaction cost, represented in fee levels.
60    pub reference_level: String,
61}
62
63#[derive(Debug, Deserialize)]
64pub struct FeeResponse {
65    /// Number of transactions provisionally included in the in-progress ledger.
66    pub current_ledger_size: String,
67    /// Number of transactions currently queued for the next ledger.
68    pub current_queue_size: String,
69    /// Various information about the transaction cost (the Fee field of a
70    /// transaction), in drops of XRP.
71    pub drops: Drops,
72    /// The approximate number of transactions expected to be included in the current ledger. This is based on the number of transactions in the previous ledger.
73    pub expected_ledger_size: String,
74    /// The Ledger Index of the current open ledger these stats describe.
75    pub ledger_current_index: u32,
76    /// Various information about the transaction cost, in fee levels. The ratio
77    /// in fee levels applies to any transaction relative to the minimum cost
78    /// of that particular transaction.
79    pub levels: Levels,
80    /// The maximum number of transactions that the transaction queue can currently
81    /// hold.
82    pub max_queue_size: String,
83}