Function hydra_dx_math::stableswap::calculate_out_given_in
source · pub fn calculate_out_given_in<const N: u8, const N_Y: u8>(
balances: &[Balance],
idx_in: usize,
idx_out: usize,
amount_in: Balance,
amplification: Balance
) -> Option<Balance>
Expand description
Calculating amount to be received from the pool given the amount to be sent to the pool and both reserves. N - number of iterations to use for Newton’s formula to calculate parameter D ( it should be >=1 otherwise it wont converge at all and will always fail N_Y - number of iterations to use for Newton’s formula to calculate reserve Y ( it should be >=1 otherwise it wont converge at all and will always fail