Skip to content

Commit

Permalink
Merge pull request #976 from multiversx/impl-auto-buyback-and-burn
Browse files Browse the repository at this point in the history
Router refactor
  • Loading branch information
dorin-iancu authored Dec 2, 2024
2 parents 17b9601 + 68c2d7b commit 8080e9a
Show file tree
Hide file tree
Showing 22 changed files with 789 additions and 664 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion dex/router/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ edition = "2021"
publish = false

[lib]
path = "src/contract.rs"
path = "src/lib.rs"

[dependencies.token_send]
path = "../../common/modules/token_send"

[dependencies.pausable]
path = "../../common/modules/pausable"

[dependencies.common_structs]
path = "../../common/common_structs"

[dependencies.multiversx-sc]
version = "=0.53.2"
features = ["esdt-token-payment-legacy-decode"]
Expand Down
43 changes: 11 additions & 32 deletions dex/router/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
multiversx_sc::imports!();
multiversx_sc::derive_imports!();

use crate::{enable_swap_by_user::EnableSwapByUserConfig, factory::PairTokens};
use crate::pair_actions::create::PairTokens;
use pair::read_pair_storage;

#[multiversx_sc::module]
pub trait ConfigModule: read_pair_storage::ReadPairStorageModule {
fn is_active(&self) -> bool {
self.state().get()
#[only_owner]
#[endpoint(setPairTemplateAddress)]
fn set_pair_template_address(&self, address: ManagedAddress) {
self.pair_template_address().set(&address);
}

#[only_owner]
#[endpoint(setPairCreationEnabled)]
fn set_pair_creation_enabled(&self, enabled: bool) {
self.pair_creation_enabled().set(enabled);
}

fn check_is_pair_sc(&self, pair_address: &ManagedAddress) {
Expand Down Expand Up @@ -40,46 +48,17 @@ pub trait ConfigModule: read_pair_storage::ReadPairStorageModule {
#[storage_mapper("pair_creation_enabled")]
fn pair_creation_enabled(&self) -> SingleValueMapper<bool>;

#[view(getState)]
#[storage_mapper("state")]
fn state(&self) -> SingleValueMapper<bool>;

#[view(getOwner)]
#[storage_mapper("owner")]
fn owner(&self) -> SingleValueMapper<ManagedAddress>;

#[only_owner]
#[endpoint(setTemporaryOwnerPeriod)]
fn set_temporary_owner_period(&self, period_blocks: u64) {
self.temporary_owner_period().set(period_blocks);
}

#[only_owner]
#[endpoint(setPairTemplateAddress)]
fn set_pair_template_address(&self, address: ManagedAddress) {
self.pair_template_address().set(&address);
}

#[storage_mapper("pair_map")]
fn pair_map(&self) -> MapMapper<PairTokens<Self::Api>, ManagedAddress>;

#[view(getPairTemplateAddress)]
#[storage_mapper("pair_template_address")]
fn pair_template_address(&self) -> SingleValueMapper<ManagedAddress>;

#[view(getTemporaryOwnerPeriod)]
#[storage_mapper("temporary_owner_period")]
fn temporary_owner_period(&self) -> SingleValueMapper<u64>;

#[storage_mapper("pair_temporary_owner")]
fn pair_temporary_owner(&self) -> MapMapper<ManagedAddress, (ManagedAddress, u64)>;

#[storage_mapper("enableSwapByUserConfig")]
fn enable_swap_by_user_config(
&self,
token_id: &TokenIdentifier,
) -> SingleValueMapper<EnableSwapByUserConfig<Self::Api>>;

#[view(getCommonTokensForUserPairs)]
#[storage_mapper("commonTokensForUserPairs")]
fn common_tokens_for_user_pairs(&self) -> UnorderedSetMapper<TokenIdentifier>;
Expand Down
Loading

0 comments on commit 8080e9a

Please sign in to comment.