penumbra_dex::component::router

Trait FillRoute

Source
pub trait FillRoute: StateWrite + Sized {
    // Provided method
    fn fill_route<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        input: Value,
        hops: &'life1 [Id],
        spill_price: Option<U128x128>,
    ) -> Pin<Box<dyn Future<Output = Result<SwapExecution, FillError>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Available on crate feature component only.

Provided Methods§

Source

fn fill_route<'life0, 'life1, 'async_trait>( &'life0 mut self, input: Value, hops: &'life1 [Id], spill_price: Option<U128x128>, ) -> Pin<Box<dyn Future<Output = Result<SwapExecution, FillError>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fills a trade of a given input amount along a given route of hops, optionally using spill_price to put limits on execution.

Note: this method will always execute at least one sub-trade along the route, even if it would exceed the spill price (i.e., the spill price is only used after consuming at least one position along the route). This covers an edge case in routing, which computes approximate spill prices: if there were two routes with very similar prices, and both of their estimated prices were underestimates, the routing could potentially switch back and forth between them without making progress. Ensuring we always consume at least one position prevents this possibility.

§Invariants

It is an error to call fill_route on a route that does not have at least one position for each hop.

§Errors

fill_route can fail for a number of reasons captured by the FillError enum.

§Panics

At the moment, fill_route will panic on I/O failures (e.g., if the state is corrupted, or storage fails).

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.

Implementors§