Function hydra_dx_math::xyk::calculate_spot_price[][src]

pub fn calculate_spot_price(
    in_reserve: u128,
    out_reserve: u128,
    amount: u128
) -> Result<u128, MathError>
Expand description

Calculating spot price given reserve of selling asset and reserve of buying asset. Formula : OUT_RESERVE * AMOUNT / IN_RESERVE

  • in_reserve - reserve amount of selling asset
  • out_reserve - reserve amount of buying asset
  • amount - amount

Returns MathError in case of error