use crate::types::QuoteResponse;
pub struct ProfitabilityParams {
pub token: String,
pub amount: f64,
pub expected_revenue: f64,
pub jito_tip: f64,
pub priority_fee: f64,
}
pub struct ProfitabilityResult {
pub profitable: bool,
pub net_profit: f64,
pub breakdown: ProfitabilityBreakdown,
pub recommendation: Recommendation,
}
pub struct ProfitabilityBreakdown {
pub revenue: f64,
pub vaea_fee: f64,
pub network_fee: f64,
pub priority_fee: f64,
pub jito_tip: f64,
pub total_cost: f64,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Recommendation {
Send,
Wait,
Abort,
}
pub fn calculate_profitability(
quote: &QuoteResponse,
params: &ProfitabilityParams,
) -> ProfitabilityResult {
let vaea_fee = quote.fee_breakdown.vaea_fee;
let network_fee = 0.000005; let priority_fee = params.priority_fee;
let jito_tip = params.jito_tip;
let total_cost = vaea_fee + network_fee + priority_fee + jito_tip;
let net_profit = params.expected_revenue - total_cost;
let recommendation = if net_profit > total_cost * 2.0 {
Recommendation::Send
} else if net_profit > 0.0 {
Recommendation::Wait
} else {
Recommendation::Abort
};
ProfitabilityResult {
profitable: net_profit > 0.0,
net_profit,
breakdown: ProfitabilityBreakdown {
revenue: params.expected_revenue,
vaea_fee,
network_fee,
priority_fee,
jito_tip,
total_cost,
},
recommendation,
}
}