use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use crate::error::Result;
use crate::route::{Fill, Route};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct SwapInstructions {
pub serialized: Vec<u8>,
pub describe: String,
}
#[async_trait]
pub trait VenueExecutor: Send + Sync {
async fn build(&self, route: &Route) -> Result<SwapInstructions>;
async fn execute(&self, route: &Route) -> Result<Fill>;
}
pub struct SimVenueExecutor;
#[async_trait]
impl VenueExecutor for SimVenueExecutor {
async fn build(&self, route: &Route) -> Result<SwapInstructions> {
Ok(SwapInstructions {
serialized: Vec::new(),
describe: format!("sim: {} leg(s)", route.legs.len()),
})
}
async fn execute(&self, route: &Route) -> Result<Fill> {
Ok(Fill {
amount_out: route.expected_out,
executed_unix: 0,
})
}
}