vaea_flash_sdk/
profitability.rs1use crate::types::QuoteResponse;
7
8pub struct ProfitabilityParams {
10 pub token: String,
12 pub amount: f64,
14 pub expected_revenue: f64,
16 pub jito_tip: f64,
18 pub priority_fee: f64,
20}
21
22pub struct ProfitabilityResult {
24 pub profitable: bool,
26 pub net_profit: f64,
28 pub breakdown: ProfitabilityBreakdown,
30 pub recommendation: Recommendation,
32}
33
34pub struct ProfitabilityBreakdown {
35 pub revenue: f64,
36 pub vaea_fee: f64,
37 pub network_fee: f64,
38 pub priority_fee: f64,
39 pub jito_tip: f64,
40 pub total_cost: f64,
41}
42
43#[derive(Debug, Clone, Copy, PartialEq)]
44pub enum Recommendation {
45 Send,
47 Wait,
49 Abort,
51}
52
53pub fn calculate_profitability(
55 quote: &QuoteResponse,
56 params: &ProfitabilityParams,
57) -> ProfitabilityResult {
58 let vaea_fee = quote.fee_breakdown.vaea_fee;
59 let network_fee = 0.000005; let priority_fee = params.priority_fee;
61 let jito_tip = params.jito_tip;
62
63 let total_cost = vaea_fee + network_fee + priority_fee + jito_tip;
64 let net_profit = params.expected_revenue - total_cost;
65
66 let recommendation = if net_profit > total_cost * 2.0 {
67 Recommendation::Send
68 } else if net_profit > 0.0 {
69 Recommendation::Wait
70 } else {
71 Recommendation::Abort
72 };
73
74 ProfitabilityResult {
75 profitable: net_profit > 0.0,
76 net_profit,
77 breakdown: ProfitabilityBreakdown {
78 revenue: params.expected_revenue,
79 vaea_fee,
80 network_fee,
81 priority_fee,
82 jito_tip,
83 total_cost,
84 },
85 recommendation,
86 }
87}