Skip to content

Commit

Permalink
change disable add liq code
Browse files Browse the repository at this point in the history
  • Loading branch information
dorin-iancu committed Nov 15, 2024
1 parent 78df98b commit d3123dc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
16 changes: 8 additions & 8 deletions common/modules/disable-add-liq/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

multiversx_sc::imports!();

pub const ADD_LIQ_ENABLED: bool = false;
pub const ADD_LIQ_DISABLED: bool = true;
pub const ADD_LIQ_ENABLED: bool = true;
pub const ADD_LIQ_DISABLED: bool = false;

#[multiversx_sc::module]
pub trait DisableAddLiqModule {
#[only_owner]
#[endpoint(enableAddLiq)]
fn enable_add_liq(&self) {
self.add_liq_disabled().set(ADD_LIQ_ENABLED);
self.add_liq_enabled().set(ADD_LIQ_ENABLED);
}

#[only_owner]
#[endpoint(disableAddLiq)]
fn disable_add_liq(&self) {
self.add_liq_disabled().set(ADD_LIQ_DISABLED);
self.add_liq_enabled().set(ADD_LIQ_DISABLED);
}

fn require_add_liq_enabled(&self) {
require!(
self.add_liq_disabled().get() == ADD_LIQ_ENABLED,
self.add_liq_enabled().get() == ADD_LIQ_ENABLED,
"Add Liquidity is disabled"
);
}

#[view(isAddLiqDisabled)]
#[storage_mapper("addLiqDisabled")]
fn add_liq_disabled(&self) -> SingleValueMapper<bool>;
#[view(isAddLiqEnabled)]
#[storage_mapper("addLiqEnabled")]
fn add_liq_enabled(&self) -> SingleValueMapper<bool>;
}
4 changes: 3 additions & 1 deletion dex/pair/tests/pair_rs_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(deprecated)]

mod pair_setup;
use disable_add_liq::DisableAddLiqModule;
use disable_add_liq::{DisableAddLiqModule, ADD_LIQ_ENABLED};
use fees_collector::{
config::ConfigModule, fees_accumulation::FeesAccumulationModule, FeesCollector,
};
Expand Down Expand Up @@ -1293,6 +1293,8 @@ fn add_liquidity_through_simple_lock_proxy() {
.b_mock
.execute_tx(&locking_owner, &locking_sc_wrapper, &rust_zero, |sc| {
sc.init();
sc.add_liq_enabled().set(ADD_LIQ_ENABLED);

sc.locked_token()
.set_token_id(managed_token_id!(LOCKED_TOKEN_ID));
sc.add_lp_to_whitelist(
Expand Down
9 changes: 3 additions & 6 deletions locked-asset/proxy_dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ pub trait ProxyDexImpl:
self.require_sc_address(&old_factory_address);
self.require_sc_address(&energy_factory_address);

self.old_locked_token_id()
.set_if_empty(&old_locked_token_id);
self.old_factory_address()
.set_if_empty(&old_factory_address);
self.energy_factory_address()
.set_if_empty(&energy_factory_address);
self.old_locked_token_id().set(&old_locked_token_id);
self.old_factory_address().set(&old_factory_address);
self.energy_factory_address().set(&energy_factory_address);
}

#[upgrade]
Expand Down
3 changes: 3 additions & 0 deletions locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use common_structs::{LockedAssetTokenAttributesEx, UnlockMilestoneEx, UnlockScheduleEx};
use config::ConfigModule;
use disable_add_liq::{DisableAddLiqModule, ADD_LIQ_ENABLED};
use energy_factory::{locked_token_transfer::LockedTokenTransferModule, SimpleLockEnergy};
use energy_query::EnergyQueryModule;
use farm_boosted_yields::boosted_yields_factors::BoostedYieldsFactorsModule;
Expand Down Expand Up @@ -455,6 +456,8 @@ where
managed_address!(simple_lock_addr),
);

sc.add_liq_enabled().set(ADD_LIQ_ENABLED);

sc.wrapped_lp_token()
.set_token_id(managed_token_id!(WRAPPED_LP_TOKEN_ID));
sc.wrapped_farm_token()
Expand Down

0 comments on commit d3123dc

Please sign in to comment.