Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change disable add liq code #975

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion locked-asset/proxy_dex/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ multiversx_sc_wasm_adapter::endpoints! {
isSCAddressWhitelisted => is_sc_address_whitelisted
enableAddLiq => enable_add_liq
disableAddLiq => disable_add_liq
isAddLiqDisabled => add_liq_disabled
isAddLiqEnabled => add_liq_enabled
)
}

Expand Down
2 changes: 1 addition & 1 deletion locked-asset/simple-lock/wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ multiversx_sc_wasm_adapter::endpoints! {
getFarmProxyTokenId => farm_proxy_token
enableAddLiq => enable_add_liq
disableAddLiq => disable_add_liq
isAddLiqDisabled => add_liq_disabled
isAddLiqEnabled => add_liq_enabled
)
}

Expand Down
Loading