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