1use bitcoin::Amount;
2#[cfg(feature = "utoipa")]
3use utoipa::ToSchema;
4use ark::fees::PpmFeeRate;
5
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
8#[cfg_attr(feature = "utoipa", derive(ToSchema))]
9pub struct FeeSchedule {
10 pub board: BoardFees,
11 pub offboard: OffboardFees,
12 pub refresh: RefreshFees,
13 pub lightning_receive: LightningReceiveFees,
14 pub lightning_send: LightningSendFees,
15}
16
17impl From<ark::fees::FeeSchedule> for FeeSchedule {
18 fn from(v: ark::fees::FeeSchedule) -> Self {
19 Self {
20 board: v.board.into(),
21 offboard: v.offboard.into(),
22 refresh: v.refresh.into(),
23 lightning_receive: v.lightning_receive.into(),
24 lightning_send: v.lightning_send.into(),
25 }
26 }
27}
28
29impl From<FeeSchedule> for ark::fees::FeeSchedule {
30 fn from(v: FeeSchedule) -> Self {
31 Self {
32 board: v.board.into(),
33 offboard: v.offboard.into(),
34 refresh: v.refresh.into(),
35 lightning_receive: v.lightning_receive.into(),
36 lightning_send: v.lightning_send.into(),
37 }
38 }
39}
40
41#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
44#[cfg_attr(feature = "utoipa", derive(ToSchema))]
45pub struct PpmExpiryFeeEntry {
46 pub expiry_blocks_threshold: u32,
51 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
53 pub ppm: PpmFeeRate,
54}
55
56impl From<ark::fees::PpmExpiryFeeEntry> for PpmExpiryFeeEntry {
57 fn from(v: ark::fees::PpmExpiryFeeEntry) -> Self {
58 Self {
59 expiry_blocks_threshold: v.expiry_blocks_threshold,
60 ppm: v.ppm,
61 }
62 }
63}
64
65impl From<PpmExpiryFeeEntry> for ark::fees::PpmExpiryFeeEntry {
66 fn from(v: PpmExpiryFeeEntry) -> Self {
67 Self {
68 expiry_blocks_threshold: v.expiry_blocks_threshold,
69 ppm: v.ppm,
70 }
71 }
72}
73
74#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
76#[cfg_attr(feature = "utoipa", derive(ToSchema))]
77pub struct BoardFees {
78 #[serde(rename = "min_fee_sat", with = "bitcoin::amount::serde::as_sat")]
80 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
81 pub min_fee: Amount,
82 #[serde(rename = "base_fee_sat", with = "bitcoin::amount::serde::as_sat")]
84 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
85 pub base_fee: Amount,
86 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
88 pub ppm: PpmFeeRate,
89}
90
91impl From<ark::fees::BoardFees> for BoardFees {
92 fn from(v: ark::fees::BoardFees) -> Self {
93 Self {
94 min_fee: v.min_fee,
95 base_fee: v.base_fee,
96 ppm: v.ppm,
97 }
98 }
99}
100
101impl From<BoardFees> for ark::fees::BoardFees {
102 fn from(v: BoardFees) -> Self {
103 Self {
104 min_fee: v.min_fee,
105 base_fee: v.base_fee,
106 ppm: v.ppm,
107 }
108 }
109}
110
111#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
113#[cfg_attr(feature = "utoipa", derive(ToSchema))]
114pub struct OffboardFees {
115 #[serde(rename = "base_fee_sat", with = "bitcoin::amount::serde::as_sat")]
117 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
118 pub base_fee: Amount,
119 pub fixed_additional_vb: u64,
125 pub ppm_expiry_table: Vec<PpmExpiryFeeEntry>,
128}
129
130impl From<ark::fees::OffboardFees> for OffboardFees {
131 fn from(v: ark::fees::OffboardFees) -> Self {
132 Self {
133 base_fee: v.base_fee,
134 fixed_additional_vb: v.fixed_additional_vb,
135 ppm_expiry_table: v.ppm_expiry_table.into_iter().map(Into::into).collect(),
136 }
137 }
138}
139
140impl From<OffboardFees> for ark::fees::OffboardFees {
141 fn from(v: OffboardFees) -> Self {
142 Self {
143 base_fee: v.base_fee,
144 fixed_additional_vb: v.fixed_additional_vb,
145 ppm_expiry_table: v.ppm_expiry_table.into_iter().map(Into::into).collect(),
146 }
147 }
148}
149
150#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
152#[cfg_attr(feature = "utoipa", derive(ToSchema))]
153pub struct RefreshFees {
154 #[serde(rename = "base_fee_sat", with = "bitcoin::amount::serde::as_sat")]
156 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
157 pub base_fee: Amount,
158 pub ppm_expiry_table: Vec<PpmExpiryFeeEntry>,
161}
162
163impl From<ark::fees::RefreshFees> for RefreshFees {
164 fn from(v: ark::fees::RefreshFees) -> Self {
165 Self {
166 base_fee: v.base_fee,
167 ppm_expiry_table: v.ppm_expiry_table.into_iter().map(Into::into).collect(),
168 }
169 }
170}
171
172impl From<RefreshFees> for ark::fees::RefreshFees {
173 fn from(v: RefreshFees) -> Self {
174 Self {
175 base_fee: v.base_fee,
176 ppm_expiry_table: v.ppm_expiry_table.into_iter().map(Into::into).collect(),
177 }
178 }
179}
180
181#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]
183#[cfg_attr(feature = "utoipa", derive(ToSchema))]
184pub struct LightningReceiveFees {
185 #[serde(rename = "base_fee_sat", with = "bitcoin::amount::serde::as_sat")]
187 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
188 pub base_fee: Amount,
189 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
191 pub ppm: PpmFeeRate,
192}
193
194impl From<ark::fees::LightningReceiveFees> for LightningReceiveFees {
195 fn from(v: ark::fees::LightningReceiveFees) -> Self {
196 Self {
197 base_fee: v.base_fee,
198 ppm: v.ppm,
199 }
200 }
201}
202
203impl From<LightningReceiveFees> for ark::fees::LightningReceiveFees {
204 fn from(v: LightningReceiveFees) -> Self {
205 Self {
206 base_fee: v.base_fee,
207 ppm: v.ppm,
208 }
209 }
210}
211
212#[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize, Serialize)]
214#[cfg_attr(feature = "utoipa", derive(ToSchema))]
215pub struct LightningSendFees {
216 #[serde(rename = "min_fee_sat", with = "bitcoin::amount::serde::as_sat")]
218 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
219 pub min_fee: Amount,
220 #[serde(rename = "base_fee_sat", with = "bitcoin::amount::serde::as_sat")]
222 #[cfg_attr(feature = "utoipa", schema(value_type = u64))]
223 pub base_fee: Amount,
224 pub ppm_expiry_table: Vec<PpmExpiryFeeEntry>,
227}
228
229impl From<ark::fees::LightningSendFees> for LightningSendFees {
230 fn from(v: ark::fees::LightningSendFees) -> Self {
231 Self {
232 min_fee: v.min_fee,
233 base_fee: v.base_fee,
234 ppm_expiry_table: v.ppm_expiry_table.into_iter().map(Into::into).collect(),
235 }
236 }
237}
238
239impl From<LightningSendFees> for ark::fees::LightningSendFees {
240 fn from(v: LightningSendFees) -> Self {
241 Self {
242 min_fee: v.min_fee,
243 base_fee: v.base_fee,
244 ppm_expiry_table: v.ppm_expiry_table.into_iter().map(Into::into).collect(),
245 }
246 }
247}