crema-cli 0.1.0

Blockchain, Crema for Solana
Documentation
use clap::{App, SubCommand};
use clap::Arg;

pub trait PairSubCommands {
    fn pair_subcommands(self) -> Self;
}

impl PairSubCommands for App<'_, '_> {
    fn pair_subcommands(self) -> Self {
        self.subcommand(
            SubCommand::with_name("pair")
                .about("swap pair")
                .alias("pair")
                //.arg(App)
                .subcommands(
                    vec![
                        SubCommand::with_name("accept_protocol_fee_authority")
                            .about("recalled by the new `ClmmConfig` authority to accept the authority")
                            .arg(
                                Arg::with_name("clmm_config")
                                    .index(1)
                                    .value_name("CLMM_CONFIG")
                                    .required(true)
                                    .help("The clmm_config is the config of new_authority to accept"),
                            ),
                        SubCommand::with_name("collect_partner_fee")
                            .about("collect the partner fee from ata controlled by partner pda")
                            .args(
                                &[
                                    Arg::with_name("partner")
                                        .index(1).value_name("PARTNER").required(true)
                                        .help("The partner"),
                                    Arg::with_name("clmmpool")
                                        .index(2).value_name("CLMMPOOL").required(true)
                                        .help("The clmmpool"),
                                ]
                            ),
                        SubCommand::with_name("collect_protocol_fee")
                            .about("`protocol_fee_claim_authority` to collect the fee earn by the `clmmpool`")
                            .arg(
                                Arg::with_name("clmmpool")
                                    .index(1).value_name("CLMMPOOL").required(true)
                                    .help("The clmmpool"),
                            ),
                        SubCommand::with_name("create-pool-template")
                            .about("create a json template for the create-pool")
                            .arg(
                                Arg::with_name("output-file")
                                    .index(1)
                                    .value_name("OUTPUT_FILE")
                                    .help("The config file output path (default: ./clmmpool-template.yaml)"),
                            ),
                        SubCommand::with_name("create-pool")
                            .about("create a clmm_pool")
                            .arg(
                                Arg::with_name("entry_file")
                                    .index(1)
                                    .value_name("ENTRY_FILE")
                                    .help("The config file entry path (default: ./clmmpool-template.yaml)"),
                            ),
                        SubCommand::with_name("info")
                            .about("get clmm_pool info")
                            .arg(
                                Arg::with_name("pool")
                                    .index(1)
                                    .value_name("pool address")
                                    .required(true)
                                    .help("pool address to retrive"),
                            ),
                        SubCommand::with_name("ticks").about("TODO"),
                        SubCommand::with_name("create-config-template")
                            .about("create a json template for the create-config")
                            .arg(
                                Arg::with_name("output-file")
                                    .index(1)
                                    .value_name("OUTPUT_FILE")
                                    .help("The config file output path (default: ./clmm-config-template.yaml)"),
                            ),
                        SubCommand::with_name("create-config")
                            .about("create clmm_config")
                            .arg(
                                Arg::with_name("entry_file")
                                    .index(1)
                                    .value_name("ENTRY_FILE")
                                    .help("The config file entry path (default: ./clmm-config-template.yaml)"),
                            ),
                        SubCommand::with_name("config-info")
                            .about("get config_info")
                            .arg(
                                Arg::with_name("config_key")
                                    .index(1)
                                    .value_name("CONFIG_KEY")
                                    .help("The config key"),
                            ),
                        SubCommand::with_name("create-fee-tier-template")
                            .about("create a json template for the create-fee-tier")
                            .arg(
                                Arg::with_name("output-file")
                                    .index(1)
                                    .value_name("OUTPUT_FILE")
                                    .help("The config file output path (default: ./fee-tier-template.yaml)"),
                            ),
                        SubCommand::with_name("create-fee-tier")
                            .about("create fee tier")
                            .arg(
                                Arg::with_name("entry_file")
                                    .index(1)
                                    .value_name("ENTRY_FILE")
                                    .help("The config file entry path (default: ./fee-tier-template.yaml)"),
                            ),
                        SubCommand::with_name("fee-tier-info")
                            .about("get fee_tier_info")
                            .arg(
                                Arg::with_name("fee_tier_key")
                                    .index(1)
                                    .value_name("FEE_TIER_KEY")
                                    .help("The fee_tier key"),
                            ),
                        SubCommand::with_name("create-partner-template")
                            .about("create a json template for the create-partner")
                            .arg(
                                Arg::with_name("output-file")
                                    .index(1)
                                    .value_name("OUTPUT_FILE")
                                    .help("The config file output path (default: ./partner-template.yaml)"),
                            ),
                        SubCommand::with_name("create-partner")
                            .about("create partner")
                            .arg(
                                Arg::with_name("entry_file")
                                    .index(1)
                                    .value_name("ENTRY_FILE")
                                    .help("The config file entry path (default: ./partner-template.yaml)"),
                            ),
                        SubCommand::with_name("partner-info")
                            .about("get partner_info")
                            .arg(
                                Arg::with_name("partner_key")
                                    .index(1)
                                    .value_name("PARTNER_KEY")
                                    .help("The partner key"),
                            ),
                        SubCommand::with_name("create-tick-array-template")
                            .about("create a json template for the create-tick-array")
                            .arg(
                                Arg::with_name("output-file")
                                    .index(1)
                                    .value_name("OUTPUT_FILE")
                                    .help("The config file output path (default: ./tick-array-template.yaml)"),
                            ),
                        SubCommand::with_name("create-tick-array")
                            .about("create tick array")
                            .arg(
                                Arg::with_name("entry_file")
                                    .index(1)
                                    .value_name("ENTRY_FILE")
                                    .help("The config file entry path (default: ./tick-array-template.yaml)"),
                            ),
                        SubCommand::with_name("transfer_protocol_fee_authority")
                            .about("`protocol_fee_authority` of the `ClmmConfig` to another new authority")
                            .args(
                                &[
                                    Arg::with_name("clmm_config")
                                        .index(1)
                                        .value_name("CLMM_CONFIG")
                                        .required(true)
                                        .help("The clmm_config to transfer to new_authority"),
                                    Arg::with_name("new_authority")
                                        .index(2)
                                        .value_name("NEW_AUTHORITY")
                                        .required(true)
                                        .help("The new_authority will be the new authority of clmm_config"),
                                ],
                            ),
                        SubCommand::with_name("update_config_protocol_fee_rate")
                            .about("update the `protocol_fee_rate` on `ClmmConfig`")
                            .args(
                                &[
                                    Arg::with_name("clmm_config")
                                        .index(1)
                                        .value_name("CLMM_CONFIG")
                                        .required(true)
                                        .help("protocol_fee_authority is the authority to update protocol_fee_rate"),
                                    Arg::with_name("new_protocol_fee_rate")
                                        .index(2)
                                        .value_name("NEW_PROTOCOL_FEE_RATE")
                                        .required(true)
                                        .help("The new_protocol_fee_rate to update protocol config"),
                                ],
                            ),
                        SubCommand::with_name("update_fee_rate")
                            .about("update the fee_rate on the `clmmpool`")
                            .args(
                                &[
                                    Arg::with_name("fee_tier")
                                        .index(1)
                                        .value_name("FEE_TIER")
                                        .required(true)
                                        .help("The fee_rate ot this fee_tier to update clmmpool"),
                                    Arg::with_name("clmmpool")
                                        .index(2)
                                        .value_name("Clmmpool")
                                        .required(true)
                                        .help("The clmmpool to update the fee_rate"),
                                ],
                            ),
                        SubCommand::with_name("update_partner")
                            .about("update partner fee_rate or claim authority")
                            .args(
                                &[
                                    Arg::with_name("partner")
                                        .index(1)
                                        .value_name("PARTNER")
                                        .required(true)
                                        .help("partner is the existed partner to update"),
                                    Arg::with_name("new_fee_rate")
                                        .index(2)
                                        .value_name("NEW_FEE_RATE")
                                        .required(true)
                                        .help("The new fee rate to update partner"),
                                    Arg::with_name("new_claim_authority")
                                        .index(3)
                                        .value_name("NEW_CLAIM_AUTHORITY")
                                        .required(true)
                                        .help("The new claim authority to update partner"),
                                ],
                            ),
                        SubCommand::with_name("update_protocol_fee_rate")
                            .about("update the `protocol_fee_rate` on `ClmmPool`")
                            .arg(
                                Arg::with_name("clmmpool")
                                    .index(1)
                                    .value_name("Clmmpool")
                                    .required(true)
                                    .help("The clmmpool to update the fee_rate"),
                            ),
                        SubCommand::with_name("swap")
                            .about("swap")
                            .args(
                                &[
                                    Arg::with_name("clmmpool")
                                        .index(1).value_name("CLMMPOOL").required(true)
                                        .help("The clmmpool"),
                                    Arg::with_name("amount")
                                        .index(2).value_name("AMOUNT").required(true)
                                        .help("swap amount"),
                                    Arg::with_name("a_to_b")
                                        .short("d")
                                        .long("a_to_b").value_name("A_TO_B").global(true).takes_value(true).default_value("true")
                                        .help("is a to b (bool)"),
                                    Arg::with_name("by_amount_in")
                                        .short("i")
                                        .long("by_amount_in").value_name("BY_AMOUNT_IN").global(true).takes_value(true).default_value("true")
                                        .help("the amount is in or not"),
                                    Arg::with_name("price_limit_tick")
                                        .short("p")
                                        .long("price_limit_tick").value_name("PRICE_LIMIT_TICK").global(true).takes_value(true)
                                        .help("price_limit_tick"),
                                ]
                            ),
                    ]
                )
        )
    }
}