Function hydra_dx_math::xyk::calculate_out_given_in
source · pub fn calculate_out_given_in(
in_reserve: u128,
out_reserve: u128,
amount_in: u128
) -> Result<u128, MathError>
Expand description
Calculating amount to be received from the pool given the amount to be sent to the pool and both reserves. Formula : OUT_RESERVE * AMOUNT_IN / (IN_RESERVE + AMOUNT_IN)
in_reserve
- reserve amount of selling assetout_reserve
- reserve amount of buying assetamount_in
- amount
Returns MathError in case of error