agentswap 0.13.0

AgentSwap CLI for requesting quotes, inspecting tokens and pools, managing intents, and registering an API key against the AgentSwap service.
// Clap arguments for the `intent` subcommands: place, list and status.
// Exports: IntentCommands.
// Deps: clap derive macros, crate::tokens for the published chain-selector copy.

use crate::tokens::{CHAIN_ID_HELP, PROTOCOL_CHAINS_NOTE};
use crate::service::submit::EXIT_STATUS_HELP;
use clap::Subcommand;

#[derive(Subcommand)]
pub enum IntentCommands {
    /// Preview an unsigned intent, or sign and announce with --allow-trade.
    #[command(after_help = format!("{PROTOCOL_CHAINS_NOTE}\n\n{EXIT_STATUS_HELP}"))]
    Place {
        #[arg(short, long = "chainid", help = CHAIN_ID_HELP)]
        chain_id: String,
        /// Owner wallet; on Ethereum the signer must be this owner, with a deployed V7 proxy
        #[arg(long)]
        proxy_owner: String,
        /// Input token symbol or raw address; a raw address must answer decimals() on that chain
        #[arg(short, long)]
        from: String,
        /// Output token symbol or raw address; a raw address must answer decimals() on that chain
        #[arg(short, long)]
        to: String,
        /// Unsigned decimal input amount in the token's smallest unit.
        #[arg(short, long)]
        amount: String,
        /// Unsigned decimal starting output in the token's smallest unit.
        #[arg(long)]
        start_out: String,
        /// Unsigned decimal ending output in the token's smallest unit.
        #[arg(long)]
        end_out: String,
        /// Seconds over which the output decays from --start-out to --end-out; defaults to the
        /// window and is capped at it. Must be greater than zero.
        #[arg(long)]
        decay_secs: Option<u64>,
        /// Intent window in seconds from now; default 600.
        #[arg(long)]
        duration_secs: Option<u64>,
        /// Seconds from now for the agent authorization deadline. Defaults to the end of the
        /// intent window on V6; unavailable for Ethereum owner intents. A shorter deadline is refused with both
        /// numbers named.
        #[arg(long)]
        deadline_secs: Option<u64>,
        /// Have the AgentSwap relay publish the signed intent, to the off-chain stream or with an
        /// on-chain announce; it always posts to https://app.agentswap.co, not to --url. Exclusive with
        /// --self-submit and --broadcast; a live placement needs exactly one submission mode.
        /// Unavailable on Ethereum.
        #[arg(long)]
        relay: bool,
        /// Send IntentSettlerV3.announce yourself from the --key-file wallet, which pays the
        /// gas, and wait a bounded time for the receipt. Exclusive with --relay and --broadcast. Exits 3
        /// when the announce reverts and 4 when it was sent but no receipt was read; both print
        /// its hash and status.
        #[arg(long)]
        self_submit: bool,
        /// Publish the signed intent to the off-chain broadcast network under agentswap-v6.
        /// Requires --allow-trade; exclusive with --relay and --self-submit.
        /// Admission may be unknown on failure; re-running after an error signs a new intent
        /// and may duplicate a still-active intent.
        #[arg(long)]
        broadcast: bool,
        /// Return the unsigned intent and digest after on-chain hash parity checks; V6 includes authorization.
        /// Never sign, create an envelope, relay, publish or send a transaction. Signature-based authorization
        /// validation runs only on the live path. Forced on unless --allow-trade is set.
        #[arg(long)]
        dry_run: bool,
    },
    /// List intents by owner from the intent index, including intents published only to the
    /// off-chain stream; by agent, or when the index does not answer, from IntentAnnounced logs
    #[command(after_help = PROTOCOL_CHAINS_NOTE)]
    List {
        #[arg(short, long = "chainid", help = CHAIN_ID_HELP)]
        chain_id: String,
        /// Owner wallet whose intents to list; required unless --agent is given
        #[arg(long, conflicts_with = "agent", required_unless_present = "agent")]
        owner: Option<String>,
        /// Agent wallet that placed the intents; required unless --owner is given
        #[arg(long, conflicts_with = "owner", required_unless_present = "owner")]
        agent: Option<String>,
        /// Blocks scanned for IntentAnnounced events when logs are read; defaults to 200,000, or
        /// 9,000 on Ethereum or BNB Smart Chain with the built-in public RPC
        #[arg(long)]
        lookback_blocks: Option<u64>,
    },
    /// Inspect an intent by bytes32 id: the intent index first, so intents published only to the
    /// off-chain stream resolve, then IntentAnnounced logs, then the settler's filled or cancelled state
    #[command(after_help = PROTOCOL_CHAINS_NOTE)]
    Status {
        #[arg(short, long = "chainid", help = CHAIN_ID_HELP)]
        chain_id: String,
        /// Intent id (bytes32), the order hash
        #[arg(long)]
        id: String,
        /// Blocks scanned for the IntentAnnounced event when the index does not hold the intent;
        /// defaults to 200,000, or 9,000 on Ethereum or BNB Smart Chain with the built-in public RPC
        #[arg(long)]
        lookback_blocks: Option<u64>,
    },
}