clmm-mine 0.1.13

Blockchain, Clmm for Solana
Documentation
use std::any::Any;
use solana_program::pubkey::Pubkey;
use clap::{Parser, Subcommand};
use common::init::{Matche};
use crate::CONFIG_FILE;

#[derive(Parser)]
#[clap(name = "aaa", author, version, about, long_about = None)]
#[clap(propagate_version = true)]
pub struct Cli {
    /// crema cli config, consistent with the solana cli config (default: $HOME/.config/solana/cli/config.yml)
    #[clap(long, short, value_parser, global = true, takes_value = true,
    default_value_t = {
    if let Some(ref config_file) = * CONFIG_FILE {
    config_file.to_string()
    } else {
    String::new()
    }
    }
    )]
    pub config_file: String,
    /// owner key default from config file Keypair
    #[clap(long, short, value_parser, global = true, takes_value = true)]
    pub owner: Option<String>,
    // config_file: String,
    // owner: String,
    #[clap(subcommand)]
    pub command: MineCli,
}

impl Matche for Cli {
    fn as_any(&self) -> &dyn Any {
        self
    }
    fn get_config_file(&self) -> &str {
        self.config_file.as_str()
    }
    fn get_owner(&self) -> &str {
        let s = self.owner.as_ref();
        if s.is_some() {
            s.unwrap().as_str()
        } else {
            ""
        }
    }
}

#[derive(Subcommand)]
pub enum MineCli {
    /// quarry command
    Quarry {
        #[clap(subcommand)]
        command: QuarryCommands,
    },
    /// rewarder command
    Rewarder {
        #[clap(subcommand)]
        command: RewarderCommands,
    },
}

#[derive(Subcommand)]
pub enum QuarryCommands {
    /// Create a quarry
    New {
        /// The rewarder address
        rewarder: Pubkey,
        /// The stake token mint address
        mint: Pubkey,
        /// The quarry's famine timestamp
        famine_ts: u64,
        /// The quarry's rewards share
        share: u64,
    },
    /// Get the quarry list
    List,
    /// Get the quarry information
    Info {
        /// The rewarder address
        rewarder: Pubkey,
        /// The stake token mint address
        mint: Pubkey,
    },
    /// Set quarry's rewarders share
    UpdateShare {
        /// The rewarder address
        rewarder: Pubkey,
        /// The stake token mint address
        mint: Pubkey,
        /// The quarry's rewarders share
        share: u64,
    },
    /// Set quarry's famine timestamp
    SetFamine {
        /// The rewarder address
        rewarder: Pubkey,
        /// The stake token mint address
        mint: Pubkey,
        /// The quarry's farmine timestamp
        ts: u64,
    }
}

#[derive(Subcommand)]
pub enum RewarderCommands {
    /// Create a rewarder
    New {
        /// The mint wrapper addresss
        wrapper: Pubkey,
        /// The rewarder annual rewards rate
        annual_rate: u64,
    },
    /// Get the rewarder list
    List,
    /// Get the rewarder information
    Info {
        /// The rewarder address
        rewarder: Pubkey,
    },
    /// Set rewarder annual rewards rate
    SetAnnualRate {
        /// The rewarder address
        rewarder: Pubkey,
        /// The new annual reward rate
        rate: u64,
    },
    /// Synchronizes quarry rewards with the rewarder.
    SyncQuarryRewards {
        /// The rewarder address
        rewarder: Pubkey,
        /// The mint public list, separated by ','
        mint: String,
    },
}