#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(feature = "scale")]
use codec::{Decode, Encode};
#[cfg(feature = "scale")]
use scale_info::TypeInfo;
pub trait Currency: Ord + Clone {}
impl<T: Ord + Clone> Currency for T {}
pub trait Amount: Copy + TryInto<u128> + TryFrom<u128> {}
impl<T: Copy + TryInto<u128> + TryFrom<u128>> Amount for T {}
pub trait Provider: Ord + Clone {}
impl<T: Ord + Clone> Provider for T {}
#[derive(Clone, Eq, PartialEq, Debug, Ord, PartialOrd)]
#[cfg_attr(feature = "scale", derive(Encode, Decode, TypeInfo))]
pub struct Pair<C: Currency> {
pub source: C,
pub target: C,
}
#[derive(Clone, Eq, PartialEq, Debug, Ord, PartialOrd)]
#[cfg_attr(feature = "scale", derive(Encode, Decode, TypeInfo))]
pub struct ProviderPair<C: Currency, P: Provider> {
pub pair: Pair<C>,
pub provider: P,
}
#[derive(Clone, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "scale", derive(Encode, Decode, TypeInfo))]
pub struct PricePath<C: Currency, A: Amount, P: Provider> {
pub total_cost: A,
pub steps: Vec<PathStep<C, A, P>>,
}
#[derive(Clone, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "scale", derive(Encode, Decode, TypeInfo))]
pub struct PathStep<C: Currency, A: Amount, P: Provider> {
pub pair: Pair<C>,
pub provider: P,
pub cost: A,
}
#[derive(Debug)]
pub enum CalculatorError {
NegativeCyclesError,
ConversionError,
}