pub fn remove_liquidity_by_shares(
        &mut self,
        sender_id: &AccountId,
        shares: Balance,
        min_amounts: Vec<Balance>,
    ) -> Vec<Balance> {
        let n_coins = self.token_account_ids.len();
        assert_eq!(min_amounts.len(), n_coins, "{}", ERR64_TOKENS_COUNT_ILLEGAL);
        let prev_shares_amount = self.shares.get(&sender_id).expect(ERR13_LP_NOT_REGISTERED);
        assert!(
            prev_shares_amount >= shares,
            "{}",
            ERR34_INSUFFICIENT_LP_SHARES
        );
        let mut result = vec![0u128; n_coins];

        for i in 0..n_coins {
            result[i] = U256::from(self.c_amounts[i])
                .checked_mul(shares.into())
                .unwrap()
                .checked_div(self.shares_total_supply.into())
                .unwrap()
                .as_u128();
            self.c_amounts[i] = self.c_amounts[i].checked_sub(result[i]).unwrap();
            self.assert_min_reserve(self.c_amounts[i]);
            result[i] = self.c_amount_to_amount(result[i], i);
            assert!(result[i] >= min_amounts[i], "{}", ERR68_SLIPPAGE);
        }

        self.burn_shares(&sender_id, prev_shares_amount, shares);
        
        env::log(
            format!(
                "LP {} remove {} shares to gain tokens {:?}",
                sender_id, shares, result
            )
            .as_bytes(),
        );

        result
    }
/// balanced removal of liquidity would be free of charge.
balanced removal of liquidity would be free of charge.
balanced removal of liquidity would be free of charge .
pub fn remove_liquidity_by_shares(
        &mut self,
        sender_id: &AccountId,
        shares: Balance,
        min_amounts: Vec<Balance>,
    ) -> Vec<Balance> {
        let n_coins = self.token_account_ids.len();
        assert_eq!(min_amounts.len(), n_coins, "{}", ERR64_TOKENS_COUNT_ILLEGAL);
        let prev_shares_amount = self.shares.get(&sender_id).expect(ERR13_LP_NOT_REGISTERED);
        assert!(
            prev_shares_amount >= shares,
            "{}",
            ERR34_INSUFFICIENT_LP_SHARES
        );
        let mut result = vec![0u128; n_coins];
        for i in 0..n_coins {
            result[i] = U256::from(self.c_amounts[i])
                .checked_mul(shares.into())
                .unwrap()
                .checked_div(self.shares_total_supply.into())
                .unwrap()
                .as_u128();
            self.c_amounts[i] = self.c_amounts[i].checked_sub(result[i]).unwrap();
            self.assert_min_reserve(self.c_amounts[i]);
            result[i] = self.c_amount_to_amount(result[i], i);
            assert!(result[i] >= min_amounts[i], "{}", ERR68_SLIPPAGE);
        }
        self.burn_shares(&sender_id, prev_shares_amount, shares);
        env::log(
            format!(
                "LP {} remove {} shares to gain tokens {:?}",
                sender_id, shares, result
            )
            .as_bytes(),
        );
        result
    }
pub fn remove_liquidity_by_shares ( & mut self , sender_id : & AccountId , shares : Balance , min_amounts : Vec < Balance > , ) -> Vec < Balance > { let n_coins = self . token_account_ids . len ( ) ; assert_eq ! ( min_amounts len ( ) n_coins " " ERR64_TOKENS_COUNT_ILLEGAL ) ; let prev_shares_amount = self . shares . get ( & sender_id ) . expect ( ERR13_LP_NOT_REGISTERED ) ; assert ! ( prev_shares_amount shares " " ERR34_INSUFFICIENT_LP_SHARES ) ; let mut result = vec ! [ 0u128 n_coins ] ; for i in 0 .. n_coins { result [ i ] = U256 :: from ( self . c_amounts [ i ] ) . checked_mul ( shares . into ( ) ) . unwrap ( ) . checked_div ( self . shares_total_supply . into ( ) ) . unwrap ( ) . as_u128 ( ) ; self . c_amounts [ i ] = self . c_amounts [ i ] . checked_sub ( result [ i ] ) . unwrap ( ) ; self . assert_min_reserve ( self . c_amounts [ i ] ) ; result [ i ] = self . c_amount_to_amount ( result [ i ] , i ) ; assert ! ( result [ i ] min_amounts [ i ] " " ERR68_SLIPPAGE ) ; } self . burn_shares ( & sender_id , prev_shares_amount , shares ) ; env :: log ( format ! ( " " sender_id shares result ) . as_bytes ( ) , ) ; result }
balanced removal of liquidity would be free of charge.
balanced removal of liquidity would be free of charge .
&mut self
sender_id
&AccountId
shares
Balance
min_amounts
Vec<Balance>
&mut self
sender_id
&AccountId
shares
Balance
min_amounts
Vec<Balance>