Skip to main content

stellar_xdr/generated/
claim_liquidity_atom.rs

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