pub trait PoolInterface:
Debug
+ Send
+ Sync
+ PoolTypeTrait
+ EventApplicable {
Show 15 methods
// Required methods
fn calculate_output(
&self,
token_in: &Address,
amount_in: U256,
) -> Result<U256>;
fn calculate_input(
&self,
token_out: &Address,
amount_out: U256,
) -> Result<U256>;
fn apply_swap(
&mut self,
token_in: &Address,
amount_in: U256,
amount_out: U256,
) -> Result<()>;
fn address(&self) -> Address;
fn tokens(&self) -> (Address, Address);
fn fee(&self) -> f64;
fn fee_raw(&self) -> u64;
fn id(&self) -> String;
fn contains_token(&self, token: &Address) -> bool;
fn clone_box(&self) -> Box<dyn PoolInterface + Send + Sync>;
fn log_summary(&self) -> String;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &mut dyn Any;
// Provided methods
fn token0(&self) -> Address { ... }
fn token1(&self) -> Address { ... }
}Required Methods§
Sourcefn calculate_output(&self, token_in: &Address, amount_in: U256) -> Result<U256>
fn calculate_output(&self, token_in: &Address, amount_in: U256) -> Result<U256>
Calculate output amount for a swap given an input amount and token
Sourcefn calculate_input(&self, token_out: &Address, amount_out: U256) -> Result<U256>
fn calculate_input(&self, token_out: &Address, amount_out: U256) -> Result<U256>
Calculate input amount for a swap given an output amount and token
Sourcefn apply_swap(
&mut self,
token_in: &Address,
amount_in: U256,
amount_out: U256,
) -> Result<()>
fn apply_swap( &mut self, token_in: &Address, amount_in: U256, amount_out: U256, ) -> Result<()>
Apply a swap to the pool state
fn fee_raw(&self) -> u64
Sourcefn contains_token(&self, token: &Address) -> bool
fn contains_token(&self, token: &Address) -> bool
Check if the pool contains a token
Sourcefn log_summary(&self) -> String
fn log_summary(&self) -> String
Log summary of the pool
fn as_any_mut(&mut self) -> &mut dyn Any
Provided Methods§
Implementations§
Source§impl dyn PoolInterface + Send + Sync
impl dyn PoolInterface + Send + Sync
Sourcepub fn downcast_ref<T: 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: 'static>(&self) -> Option<&T>
Downcast to a concrete pool type
Sourcepub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>
Downcast to a concrete pool type (mutable)