wp-solana-pool-traits 0.1.1

Traits and utilities for Solana liquidity pool operations: PoolViewer, PoolInfuser, PositionViewer
Documentation
use anyhow::Result;
use async_trait::async_trait;
use solana_client::rpc_response::RpcSimulateTransactionResult;
use solana_sdk::{pubkey::Pubkey, signature::Signature};

use crate::types::token::QuoteData;

/// Parameters for adding liquidity including amounts and price range
/// Matches Orca SDK's open_position_instructions and
/// increase_liquidity_instructions APIs
#[derive(Debug, Clone)]
pub struct HarvestFeesAndRewardsParams {
    /// List of position addresses to harvest fees from
    pub positions: Vec<Pubkey>,
    /// Recipient address that will receive the harvested fees
    pub recipient: Pubkey,
}

/// Trait for harvesting fees from liquidity positions in Solana pools (Orca
/// Whirlpools, etc.)
#[async_trait]
pub trait PoolHarvester: Send + Sync {
    /// Fetch fee and reward quote data for the given position mints.
    async fn get_quote_data(&self, position_mint: &[Pubkey]) -> Result<Vec<QuoteData>>;

    /// Harvest fees and rewards from a list of positions.
    async fn harvest_fees_and_rewards(
        &self,
        params: HarvestFeesAndRewardsParams,
    ) -> Result<HarvestFeesAndRewardsResult>;

    /// Simulate harvesting fees and rewards without sending a transaction.
    async fn simulate_harvest_fees_and_rewards(
        &self,
        params: HarvestFeesAndRewardsParams,
    ) -> Result<HarvestFeesAndRewardsSimulationResult>;
}

/// Result of harvesting fees and rewards from positions.
#[derive(Clone, Debug)]
pub struct HarvestFeesAndRewardsResult {
    /// Fee and reward data for each harvested position.
    pub results: Vec<QuoteData>,
    /// Transaction signature for the batch operation.
    pub signature: Signature,
}

/// Result of simulating a harvest fees and rewards operation.
#[derive(Clone, Debug)]
pub struct HarvestFeesAndRewardsSimulationResult {
    /// Fee and reward data for each position.
    pub results: Vec<QuoteData>,
    /// RPC simulation result with logs and compute units.
    pub simulation: RpcSimulateTransactionResult,
}