diff --git a/integration-tests/src/xyk_liquidity_mining.rs b/integration-tests/src/xyk_liquidity_mining.rs index ce5519a1e..07467acfa 100644 --- a/integration-tests/src/xyk_liquidity_mining.rs +++ b/integration-tests/src/xyk_liquidity_mining.rs @@ -481,7 +481,7 @@ fn add_liquidity_and_join_farms_should_work_with_multiple_farm_entries() { ]; let deposit_id = 1; let liquidity_amount = 5_000_000 * UNITS; - //Act + //Act assert_ok!(XYKLiquidityMining::add_liquidity_and_join_farms( RuntimeOrigin::signed(BOB.into()), PEPE, @@ -1203,7 +1203,7 @@ fn exit_farm_should_work_on_multiple_different_farms() { (deposit_id, yield_farm_2_id, asset_pair), (deposit_id2, yield_farm_3_id, asset_pair2), ]; - //Act + //Act assert_ok!(XYKLiquidityMining::exit_farms( RuntimeOrigin::signed(DAVE.into()), exit_entries.try_into().unwrap() diff --git a/pallets/xyk-liquidity-mining/src/lib.rs b/pallets/xyk-liquidity-mining/src/lib.rs index 1d5caa91d..c1d9e5f14 100644 --- a/pallets/xyk-liquidity-mining/src/lib.rs +++ b/pallets/xyk-liquidity-mining/src/lib.rs @@ -73,8 +73,8 @@ type PeriodOf = BlockNumberFor; pub mod pallet { use super::*; use frame_system::pallet_prelude::BlockNumberFor; - use hydradx_traits::AmmAddLiquidity; use hydradx_traits::pools::DustRemovalAccountWhitelist; + use hydradx_traits::AmmAddLiquidity; const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); @@ -709,7 +709,14 @@ pub mod pallet { let who = ensure_signed(origin)?; let amm_share_token = T::AMM::get_share_token(asset_pair); - Self::do_deposit_shares(who, global_farm_id, yield_farm_id, asset_pair,amm_share_token, shares_amount)?; + Self::do_deposit_shares( + who, + global_farm_id, + yield_farm_id, + asset_pair, + amm_share_token, + shares_amount, + )?; Ok(()) } @@ -740,8 +747,14 @@ pub mod pallet { let (global_farm_id, yield_farm_id) = farm_entries.first().ok_or(Error::::NoFarmsSpecified)?; let amm_share_token = T::AMM::get_share_token(asset_pair); - let deposit_id = - Self::do_deposit_shares(who.clone(), *global_farm_id, *yield_farm_id, asset_pair, amm_share_token, shares_amount)?; + let deposit_id = Self::do_deposit_shares( + who.clone(), + *global_farm_id, + *yield_farm_id, + asset_pair, + amm_share_token, + shares_amount, + )?; for (global_farm_id, yield_farm_id) in farm_entries.into_iter().skip(1) { let (redeposited_amount, _) = T::LiquidityMiningHandler::redeposit_lp_shares( diff --git a/pallets/xyk-liquidity-mining/src/tests/join_farms.rs b/pallets/xyk-liquidity-mining/src/tests/join_farms.rs index c4a1add4c..8167a429c 100644 --- a/pallets/xyk-liquidity-mining/src/tests/join_farms.rs +++ b/pallets/xyk-liquidity-mining/src/tests/join_farms.rs @@ -62,7 +62,7 @@ fn join_farms_should_work_with_multiple_farm_pairs() { set_block_number(1_800); let deposited_amount = 50 * ONE; let global_farm_2 = 2; - let farm_entries = vec![(BSX_FARM, 5), (BSX_FARM, 6), (BSX_FARM, 7), (global_farm_2,8)]; + let farm_entries = vec![(BSX_FARM, 5), (BSX_FARM, 6), (BSX_FARM, 7), (global_farm_2, 8)]; // Act assert_ok!(LiquidityMining::join_farms( diff --git a/pallets/xyk-liquidity-mining/src/tests/mock.rs b/pallets/xyk-liquidity-mining/src/tests/mock.rs index 5d6941a39..6d28455b6 100644 --- a/pallets/xyk-liquidity-mining/src/tests/mock.rs +++ b/pallets/xyk-liquidity-mining/src/tests/mock.rs @@ -618,16 +618,22 @@ impl hydradx_traits::liquidity_mining::Mutate f ) -> Result { let farm_id = get_next_farm_id(); - YIELD_FARMS.with(|v| { - let mut p = v.borrow_mut(); - let yield_farm = p.iter_mut().find(|(_, farm)| farm.amm_pool_id == amm_pool_id && farm.global_farm_id == global_farm_id); - - if yield_farm.is_some() { - return Err(sp_runtime::DispatchError::Other("Yield Farm already exists in global farm")); - } - - Ok::<(), Self::Error>(()) - }).unwrap(); + YIELD_FARMS + .with(|v| { + let mut p = v.borrow_mut(); + let yield_farm = p + .iter_mut() + .find(|(_, farm)| farm.amm_pool_id == amm_pool_id && farm.global_farm_id == global_farm_id); + + if yield_farm.is_some() { + return Err(sp_runtime::DispatchError::Other( + "Yield Farm already exists in global farm", + )); + } + + Ok::<(), Self::Error>(()) + }) + .unwrap(); YIELD_FARMS.with(|v| { v.borrow_mut().insert(