pub fn compute_lp_amount_for_deposit(
        &self,
        deposit_c_amounts: &Vec<Balance>, // deposit tokens in comparable precision,
        old_c_amounts: &Vec<Balance>, // current in-pool tokens in comparable precision,
        pool_token_supply: Balance, // current share supply
        fees: &Fees,
    ) -> Option<(Balance, Balance)> {
        let n_coins = old_c_amounts.len();
        
        // Initial invariant
        let d_0 = self.compute_d(old_c_amounts)?;

        let mut new_balances = vec![0_u128; n_coins];
        for (index, value) in deposit_c_amounts.iter().enumerate() {
            new_balances[index] = old_c_amounts[index].checked_add(*value)?;
        }
        // Invariant after change
        let d_1 = self.compute_d(&new_balances)?;
        if d_1 <= d_0 {
            None
        } else {
            // Recalculate the invariant accounting for fees
            for i in 0..new_balances.len() {
                let ideal_balance = d_1
                    .checked_mul(old_c_amounts[i].into())?
                    .checked_div(d_0)?
                    .as_u128();
                let difference = if ideal_balance > new_balances[i] {
                    ideal_balance.checked_sub(new_balances[i])?
                } else {
                    new_balances[i].checked_sub(ideal_balance)?
                };
                let fee = fees.normalized_trade_fee(n_coins as u32, difference);
                new_balances[i] = new_balances[i].checked_sub(fee)?;
            }

            let d_2 = self.compute_d(&new_balances)?;

            // d1 > d2 > d0, 
            // (d2-d0) => mint_shares (charged fee),
            // (d1-d0) => diff_shares (without fee),
            // (d1-d2) => fee part,
            // diff_shares = mint_shares + fee part

            let mint_shares = U256::from(pool_token_supply)
                .checked_mul(d_2.checked_sub(d_0)?)?
                .checked_div(d_0)?
                .as_u128();
            
            let diff_shares = U256::from(pool_token_supply)
                .checked_mul(d_1.checked_sub(d_0)?)?
                .checked_div(d_0)?
                .as_u128();

            Some((mint_shares, diff_shares-mint_shares))
        }
    }
/// Compute the amount of LP tokens to mint after a deposit
/// return <lp_amount_to_mint, lp_fees_part>
Compute the amount of LP tokens to mint after a deposit
return 
Compute the amount of LP tokens to mint after a deposit return
pub fn compute_lp_amount_for_deposit(
        &self,
        deposit_c_amounts: &Vec<Balance>, // deposit tokens in comparable precision,
        old_c_amounts: &Vec<Balance>, // current in-pool tokens in comparable precision,
        pool_token_supply: Balance, // current share supply
        fees: &Fees,
    ) -> Option<(Balance, Balance)> {
        let n_coins = old_c_amounts.len();
        // Initial invariant
        let d_0 = self.compute_d(old_c_amounts)?;
        let mut new_balances = vec![0_u128; n_coins];
        for (index, value) in deposit_c_amounts.iter().enumerate() {
            new_balances[index] = old_c_amounts[index].checked_add(*value)?;
        }
        // Invariant after change
        let d_1 = self.compute_d(&new_balances)?;
        if d_1 <= d_0 {
            None
        } else {
            // Recalculate the invariant accounting for fees
            for i in 0..new_balances.len() {
                let ideal_balance = d_1
                    .checked_mul(old_c_amounts[i].into())?
                    .checked_div(d_0)?
                    .as_u128();
                let difference = if ideal_balance > new_balances[i] {
                    ideal_balance.checked_sub(new_balances[i])?
                } else {
                    new_balances[i].checked_sub(ideal_balance)?
                };
                let fee = fees.normalized_trade_fee(n_coins as u32, difference);
                new_balances[i] = new_balances[i].checked_sub(fee)?;
            }
            let d_2 = self.compute_d(&new_balances)?;
            // d1 > d2 > d0, 
            // (d2-d0) => mint_shares (charged fee),
            // (d1-d0) => diff_shares (without fee),
            // (d1-d2) => fee part,
            // diff_shares = mint_shares + fee part
            let mint_shares = U256::from(pool_token_supply)
                .checked_mul(d_2.checked_sub(d_0)?)?
                .checked_div(d_0)?
                .as_u128();
            let diff_shares = U256::from(pool_token_supply)
                .checked_mul(d_1.checked_sub(d_0)?)?
                .checked_div(d_0)?
                .as_u128();
            Some((mint_shares, diff_shares-mint_shares))
        }
    }
pub fn compute_lp_amount_for_deposit ( & self , deposit_c_amounts : & Vec < Balance > , // deposit tokens in comparable precision, old_c_amounts : & Vec < Balance > , // current in-pool tokens in comparable precision, pool_token_supply : Balance , // current share supply fees : & Fees , ) -> Option < ( Balance , Balance ) > { let n_coins = old_c_amounts . len ( ) ; // Initial invariant let d_0 = self . compute_d ( old_c_amounts ) ? ; let mut new_balances = vec ! [ 0_u128 n_coins ] ; for ( index , value ) in deposit_c_amounts . iter ( ) . enumerate ( ) { new_balances [ index ] = old_c_amounts [ index ] . checked_add ( * value ) ? ; } // Invariant after change let d_1 = self . compute_d ( & new_balances ) ? ; if d_1 <= d_0 { None } else { // Recalculate the invariant accounting for fees for i in 0 .. new_balances . len ( ) { let ideal_balance = d_1 . checked_mul ( old_c_amounts [ i ] . into ( ) ) ? . checked_div ( d_0 ) ? . as_u128 ( ) ; let difference = if ideal_balance > new_balances [ i ] { ideal_balance . checked_sub ( new_balances [ i ] ) ? } else { new_balances [ i ] . checked_sub ( ideal_balance ) ? } ; let fee = fees . normalized_trade_fee ( n_coins as u32 , difference ) ; new_balances [ i ] = new_balances [ i ] . checked_sub ( fee ) ? ; } let d_2 = self . compute_d ( & new_balances ) ? ; // d1 > d2 > d0,  // (d2-d0) => mint_shares (charged fee), // (d1-d0) => diff_shares (without fee), // (d1-d2) => fee part, // diff_shares = mint_shares + fee part let mint_shares = U256 :: from ( pool_token_supply ) . checked_mul ( d_2 . checked_sub ( d_0 ) ? ) ? . checked_div ( d_0 ) ? . as_u128 ( ) ; let diff_shares = U256 :: from ( pool_token_supply ) . checked_mul ( d_1 . checked_sub ( d_0 ) ? ) ? . checked_div ( d_0 ) ? . as_u128 ( ) ; Some ( ( mint_shares , diff_shares - mint_shares ) ) } }
Compute the amount of LP tokens to mint after a deposit
return <lp_amount_to_mint, lp_fees_part>
Compute the amount of LP tokens to mint after a deposit return <lp_amount_to_mint lp_fees_part >
&self
deposit_c_amounts
&Vec<Balance>
old_c_amounts
&Vec<Balance>
pool_token_supply
Balance
fees
&Fees
&self
deposit_c_amounts
&Vec<Balance>
old_c_amounts
&Vec<Balance>
pool_token_supply
Balance
fees
&Fees