pub trait AutomatedMarketMaker {
// Required methods
fn address(&self) -> Felt;
fn tokens(&self) -> Vec<Felt>;
fn sync<'life0, 'async_trait, P>(
&'life0 mut self,
provider: Arc<P>,
) -> Pin<Box<dyn Future<Output = Result<(), StarknetError>> + Send + 'async_trait>>
where P: Provider + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn calculate_price(
&self,
base_token: Felt,
quote_token: Felt,
) -> Result<f64, StarknetError>;
fn simulate_swap<'life0, 'async_trait, P>(
&'life0 self,
base_token: Felt,
amount_in: Felt,
provider: Arc<P>,
) -> Pin<Box<dyn Future<Output = Result<Felt, StarknetError>> + Send + 'async_trait>>
where P: Provider + Send + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait;
fn simulate_swap_mut(
&mut self,
base_token: Felt,
quote_token: Felt,
amount_in: Felt,
) -> Result<Felt, StarknetError>;
}Required Methods§
fn sync<'life0, 'async_trait, P>( &'life0 mut self, provider: Arc<P>, ) -> Pin<Box<dyn Future<Output = Result<(), StarknetError>> + Send + 'async_trait>>
Sourcefn calculate_price(
&self,
base_token: Felt,
quote_token: Felt,
) -> Result<f64, StarknetError>
fn calculate_price( &self, base_token: Felt, quote_token: Felt, ) -> Result<f64, StarknetError>
Calculates a f64 representation of base token price in the AMM.
Sourcefn simulate_swap<'life0, 'async_trait, P>(
&'life0 self,
base_token: Felt,
amount_in: Felt,
provider: Arc<P>,
) -> Pin<Box<dyn Future<Output = Result<Felt, StarknetError>> + Send + 'async_trait>>
fn simulate_swap<'life0, 'async_trait, P>( &'life0 self, base_token: Felt, amount_in: Felt, provider: Arc<P>, ) -> Pin<Box<dyn Future<Output = Result<Felt, StarknetError>> + Send + 'async_trait>>
Locally simulates a swap in the AMM.
Returns the amount received for amount_in of token_in.
Sourcefn simulate_swap_mut(
&mut self,
base_token: Felt,
quote_token: Felt,
amount_in: Felt,
) -> Result<Felt, StarknetError>
fn simulate_swap_mut( &mut self, base_token: Felt, quote_token: Felt, amount_in: Felt, ) -> Result<Felt, StarknetError>
Locally simulates a swap in the AMM.
Mutates the AMM state to the state of the AMM after swapping.
Returns the amount received for amount_in of token_in.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.