use solana_address::Address;
use super::{LegRecord, SwapMode};
use crate::route_plan::{RouteHop, RouteHopSwapInfo, RoutePlan};
pub(super) fn hop(
program: Option<&str>,
label: &str,
input_mint: &str,
output_mint: &str,
in_amount: u64,
) -> RouteHop {
RouteHop {
program: program.map(str::to_string),
swap_info: RouteHopSwapInfo {
label: Some(label.to_string()),
amm_key: program.is_none().then(|| "pool".to_string()),
input_mint: Some(input_mint.to_string()),
in_amount: Some(in_amount.to_string()),
output_mint: Some(output_mint.to_string()),
out_amount: None,
},
..RouteHop::default()
}
}
pub(super) fn plan(hops: Vec<RouteHop>) -> Option<RoutePlan> {
RoutePlan::new(hops)
}
pub(super) fn record_of(
input_mint: Address,
output_mint: Address,
amount: u64,
quoted: Option<RoutePlan>,
original: Option<RoutePlan>,
realized: Option<RoutePlan>,
) -> LegRecord {
LegRecord {
original_signature: "sig".to_string(),
input_mint,
output_mint,
amount,
swap_mode: SwapMode::ExactIn,
failed: false,
original_failed: false,
realized_output_amount: None,
original_realized_output_amount: None,
route_plan: quoted,
original_route_plan: original,
realized_route_plan: realized,
template: None,
quoted_output_amount: None,
new_output_amount: None,
error_category: None,
output_bps: None,
}
}