pub fn compute_swap_step(
sqrt_ratio_current_x96: U160,
sqrt_ratio_target_x96: U160,
liquidity: u128,
amount_remaining: I256,
fee_pips: u32,
) -> Result<SwapStepResult>Expand description
Computes the result of swapping some amount in, or amount out, given the parameters of the swap.
§Arguments
sqrt_ratio_current_x96- The current sqrt price of the poolsqrt_ratio_target_x96- The price that cannot be exceeded, from which the direction of the swap is inferredliquidity- The usable liquidityamount_remaining- How much input or output amount is remaining to be swapped in/outfee_pips- The fee taken from the input amount, expressed in hundredths of a bip
§Errors
This function returns an error if:
- Fee adjustment calculations overflow or encounter division by zero.
- Amount or price delta calculations overflow the supported numeric range.