Skip to main content

simulate_pool_path

Function simulate_pool_path 

Source
pub fn simulate_pool_path<D>(
    path: &Path<'_, D>,
    market: &MarketState,
    token_prices: Option<&TokenGasPrices>,
    amount_in: BigUint,
) -> Result<RouteResult, AlgorithmError>
Expand description

Swaps amount_in along a path, one pool at a time, and reports what comes out.

Each pool’s post-swap state is carried forward, so a path crossing the same component twice pays the second time what it really would.

net_amount_out is the output less gas priced in the output token, and can be negative when the gas estimate exceeds what the route pays.

§Errors

AlgorithmError::DataNotFound for a token, component, state or gas price the market does not hold, and AlgorithmError::Other when a pool refuses the swap.