soroban_cli/commands/tx/new/
liquidity_pool_withdraw.rs1use clap::Parser;
2
3use crate::{commands::tx, tx::builder, xdr};
4
5#[derive(Parser, Debug, Clone)]
6#[group(skip)]
7pub struct Cmd {
8 #[command(flatten)]
9 pub tx: tx::Args,
10 #[clap(flatten)]
11 pub op: Args,
12}
13
14#[derive(Debug, clap::Args, Clone)]
15pub struct Args {
16 #[arg(long)]
18 pub liquidity_pool_id: String,
19
20 #[arg(long)]
22 pub amount: builder::Amount,
23
24 #[arg(long)]
26 pub min_amount_a: builder::Amount,
27
28 #[arg(long)]
30 pub min_amount_b: builder::Amount,
31}
32
33impl TryFrom<&Cmd> for xdr::OperationBody {
34 type Error = tx::args::Error;
35 fn try_from(
36 Cmd {
37 tx: _,
38 op:
39 Args {
40 liquidity_pool_id,
41 amount,
42 min_amount_a,
43 min_amount_b,
44 },
45 }: &Cmd,
46 ) -> Result<Self, Self::Error> {
47 let pool_id: xdr::PoolId = liquidity_pool_id
48 .parse()
49 .map_err(|_| tx::args::Error::InvalidPoolId(liquidity_pool_id.clone()))?;
50
51 Ok(xdr::OperationBody::LiquidityPoolWithdraw(
52 xdr::LiquidityPoolWithdrawOp {
53 liquidity_pool_id: pool_id,
54 amount: amount.into(),
55 min_amount_a: min_amount_a.into(),
56 min_amount_b: min_amount_b.into(),
57 },
58 ))
59 }
60}