Function hydra_dx_math::xyk::calculate_liquidity_out[][src]

pub fn calculate_liquidity_out(
    asset_a_reserve: u128,
    asset_b_reserve: u128,
    amount: u128,
    total_liquidity: u128
) -> Result<(u128, u128), MathError>
Expand description

Calculating amount of assets returned when removing liquidity. Formula A: AMOUNT * ASSET_A_RESERVE / TOTAL_LIQUIDITY Formula B: AMOUNT * ASSET_B_RESERVE / TOTAL_LIQUIDITY

  • asset_a_reserve - reserve amount of asset a
  • asset_b_reserve - reserve amount of asset b
  • amount - liquidity amount

Returns MathError in case of error