Skip to content

Commit f858153

Browse files
Merge pull request #1137 from galacticcouncil/fix/lm-min-deposit-check
fix: remove redundant min. deposit check
2 parents c16eeb7 + 5137854 commit f858153

7 files changed

Lines changed: 27 additions & 53 deletions

File tree

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/liquidity-mining/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pallet-liquidity-mining"
3-
version = "4.4.6"
3+
version = "4.4.7"
44
description = "Liquidity mining"
55
authors = ["GalacticCouncil"]
66
edition = "2021"

pallets/liquidity-mining/src/lib.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,6 @@ pub mod pallet {
249249
/// Liquidity mining is in `active` or `terminated` state and action cannot be completed.
250250
LiquidityMiningIsNotStopped,
251251

252-
/// LP shares amount is not valid.
253-
InvalidDepositAmount,
254-
255252
/// Account is not allowed to perform action.
256253
Forbidden,
257254

@@ -470,7 +467,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
470467
/// - `reward_currency`: payoff currency of rewards.
471468
/// - `owner`: liq. mining farm owner.
472469
/// - `yield_per_period`: percentage return on `reward_currency` of all pools.
473-
/// - `min_deposit`: minimum amount of LP shares to be deposited into liquidity mining by each user.
470+
/// - `min_deposit`: minimum value of LP shares to be deposited into liquidity mining by each user.
474471
/// - `price_adjustment`: price adjustment between `incentivized_asset` and `reward_currency`.
475472
/// This value should be `1` if `incentivized_asset` and `reward_currency` are the same.
476473
#[allow(clippy::too_many_arguments)]
@@ -577,7 +574,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
577574
/// - `global_farm_id`: global farm id.
578575
/// - `planned_yielding_periods`: planned number of periods to distribute `total_rewards`.
579576
/// - `yield_per_period`: percentage return on `reward_currency` of all pools.
580-
/// - `min_deposit`: minimum amount of LP shares to be deposited into liquidity mining by each user.
577+
/// - `min_deposit`: minimum value of LP shares to be deposited into liquidity mining by each user.
581578
fn update_global_farm(
582579
global_farm_id: GlobalFarmId,
583580
planned_yielding_periods: PeriodOf<T>,
@@ -1442,11 +1439,6 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
14421439
.as_mut()
14431440
.defensive_ok_or::<Error<T, I>>(InconsistentStateError::GlobalFarmNotFound.into())?;
14441441

1445-
ensure!(
1446-
deposit.shares.ge(&global_farm.min_deposit),
1447-
Error::<T, I>::InvalidDepositAmount,
1448-
);
1449-
14501442
//NOTE: If yield-farm is active also global-farm MUST be active.
14511443
ensure!(
14521444
global_farm.state.is_active(),

pallets/liquidity-mining/src/tests/deposit_lp_shares.rs

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -556,42 +556,6 @@ fn deposit_lp_shares_should_work() {
556556
});
557557
}
558558

559-
#[test]
560-
fn deposit_lp_shares_bellow_min_deposit_should_not_work() {
561-
let _ = predefined_test_ext_with_deposits().execute_with(|| {
562-
with_transaction(|| {
563-
//NOTE: min. deposit is 10
564-
let yield_farm_id = GC_BSX_TKN1_YIELD_FARM_ID;
565-
566-
assert_noop!(
567-
LiquidityMining::deposit_lp_shares(GC_FARM, yield_farm_id, BSX_TKN1_AMM, 0, |_, _, _| { Ok(10_u128) }),
568-
Error::<Test, Instance1>::InvalidDepositAmount
569-
);
570-
571-
assert_noop!(
572-
LiquidityMining::deposit_lp_shares(GC_FARM, yield_farm_id, BSX_TKN1_AMM, 1, |_, _, _| { Ok(10_u128) }),
573-
Error::<Test, Instance1>::InvalidDepositAmount
574-
);
575-
576-
assert_noop!(
577-
LiquidityMining::deposit_lp_shares(GC_FARM, yield_farm_id, BSX_TKN1_AMM, 8, |_, _, _| { Ok(10_u128) }),
578-
Error::<Test, Instance1>::InvalidDepositAmount
579-
);
580-
581-
//margin value should works
582-
assert_ok!(LiquidityMining::deposit_lp_shares(
583-
GC_FARM,
584-
yield_farm_id,
585-
BSX_TKN1_AMM,
586-
crate::MIN_DEPOSIT,
587-
|_, _, _| { Ok(crate::MIN_DEPOSIT) }
588-
));
589-
590-
TransactionOutcome::Commit(DispatchResult::Ok(()))
591-
})
592-
});
593-
}
594-
595559
#[test]
596560
fn deposit_lp_shares_non_existing_yield_farm_should_not_work() {
597561
predefined_test_ext_with_deposits().execute_with(|| {
@@ -649,3 +613,20 @@ fn deposit_lp_shares_should_not_work_when_valued_shares_are_bellow_min_deposit()
649613
})
650614
});
651615
}
616+
617+
#[test]
618+
fn deposit_lp_shares_should_work_when_valued_shares_are_euqal_to_min_deposit() {
619+
let _ = predefined_test_ext_with_deposits().execute_with(|| {
620+
with_transaction(|| {
621+
assert_ok!(LiquidityMining::deposit_lp_shares(
622+
GC_FARM,
623+
GC_BSX_TKN1_YIELD_FARM_ID,
624+
BSX_TKN1_AMM,
625+
crate::MIN_DEPOSIT,
626+
|_, _, _| { Ok(crate::MIN_DEPOSIT) }
627+
));
628+
629+
TransactionOutcome::Commit(DispatchResult::Ok(()))
630+
})
631+
});
632+
}

runtime/hydradx/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hydradx-runtime"
3-
version = "320.0.0"
3+
version = "321.0.0"
44
authors = ["GalacticCouncil"]
55
edition = "2021"
66
license = "Apache 2.0"

runtime/hydradx/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
120120
spec_name: create_runtime_str!("hydradx"),
121121
impl_name: create_runtime_str!("hydradx"),
122122
authoring_version: 1,
123-
spec_version: 320,
123+
spec_version: 321,
124124
impl_version: 0,
125125
apis: RUNTIME_API_VERSIONS,
126126
transaction_version: 1,

traits/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "hydradx-traits"
3-
version = "3.15.4"
3+
version = "3.15.5"
44
description = "Shared traits"
55
authors = ["GalacticCouncil"]
66
edition = "2021"
@@ -28,4 +28,5 @@ std = [
2828
"codec/std",
2929
"frame-support/std",
3030
"sp-std/std",
31+
"primitives/std",
3132
]

0 commit comments

Comments
 (0)