Skip to main content

stellar_xdr/generated/
liquidity_pool_withdraw_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// LiquidityPoolWithdrawOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct LiquidityPoolWithdrawOp
8/// {
9///     PoolID liquidityPoolID;
10///     int64 amount;     // amount of pool shares to withdraw
11///     int64 minAmountA; // minimum amount of first asset to withdraw
12///     int64 minAmountB; // minimum amount of second asset to withdraw
13/// };
14/// ```
15///
16#[cfg_attr(feature = "alloc", derive(Default))]
17#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
18#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
19#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
20#[cfg_attr(
21    all(feature = "serde", feature = "alloc"),
22    serde_with::serde_as,
23    derive(serde::Serialize, serde::Deserialize),
24    serde(rename_all = "snake_case")
25)]
26#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
27pub struct LiquidityPoolWithdrawOp {
28    pub liquidity_pool_id: PoolId,
29    #[cfg_attr(
30        all(feature = "serde", feature = "alloc"),
31        serde_as(as = "NumberOrString")
32    )]
33    pub amount: i64,
34    #[cfg_attr(
35        all(feature = "serde", feature = "alloc"),
36        serde_as(as = "NumberOrString")
37    )]
38    pub min_amount_a: i64,
39    #[cfg_attr(
40        all(feature = "serde", feature = "alloc"),
41        serde_as(as = "NumberOrString")
42    )]
43    pub min_amount_b: i64,
44}
45
46impl ReadXdr for LiquidityPoolWithdrawOp {
47    #[cfg(feature = "std")]
48    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
49        r.with_limited_depth(|r| {
50            Ok(Self {
51                liquidity_pool_id: PoolId::read_xdr(r)?,
52                amount: i64::read_xdr(r)?,
53                min_amount_a: i64::read_xdr(r)?,
54                min_amount_b: i64::read_xdr(r)?,
55            })
56        })
57    }
58}
59
60impl WriteXdr for LiquidityPoolWithdrawOp {
61    #[cfg(feature = "std")]
62    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
63        w.with_limited_depth(|w| {
64            self.liquidity_pool_id.write_xdr(w)?;
65            self.amount.write_xdr(w)?;
66            self.min_amount_a.write_xdr(w)?;
67            self.min_amount_b.write_xdr(w)?;
68            Ok(())
69        })
70    }
71}