Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dorin-iancu committed Dec 3, 2024
1 parent 90f8d81 commit eb6a8d1
Show file tree
Hide file tree
Showing 50 changed files with 153 additions and 217 deletions.
11 changes: 2 additions & 9 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions common/modules/farm/config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ path = "../../../common_structs"
[dependencies.common_errors]
path = "../../../common_errors"

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

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

Expand Down
3 changes: 0 additions & 3 deletions common/modules/farm/contexts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ path = "../farm_token"
[dependencies.rewards]
path = "../rewards"

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

[dependencies.token_merge_helper]
path = "../../token_merge_helper"

Expand Down
3 changes: 0 additions & 3 deletions common/modules/farm/farm_base_impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ path = "../events"
[dependencies.contexts]
path = "../contexts"

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

[dependencies.token_merge_helper]
path = "../../token_merge_helper"

Expand Down
1 change: 0 additions & 1 deletion common/modules/farm/farm_base_impl/src/claim_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ where
pub trait BaseClaimRewardsModule:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down
1 change: 0 additions & 1 deletion common/modules/farm/farm_base_impl/src/compound_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ where
pub trait BaseCompoundRewardsModule:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down
1 change: 0 additions & 1 deletion common/modules/farm/farm_base_impl/src/enter_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ where
pub trait BaseEnterFarmModule:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down
1 change: 0 additions & 1 deletion common/modules/farm/farm_base_impl/src/exit_farm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ where
pub trait BaseExitFarmModule:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down
1 change: 0 additions & 1 deletion common/modules/farm/farm_base_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub mod exit_farm;
pub trait FarmBaseImpl:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down
3 changes: 0 additions & 3 deletions common/modules/farm/rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ path = "../config"
[dependencies.farm_token]
path = "../farm_token"

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

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

Expand Down
1 change: 1 addition & 0 deletions common/modules/farm/rewards/src/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub trait RewardsModule:
!self.produce_rewards_enabled().get(),
"Producing rewards is already enabled"
);

let current_nonce = self.blockchain().get_block_nonce();
self.produce_rewards_enabled().set(true);
self.last_reward_block_nonce().set(current_nonce);
Expand Down
27 changes: 3 additions & 24 deletions common/modules/token_send/src/token_send.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#![no_std]

use common_structs::PaymentsVec;

multiversx_sc::imports!();
multiversx_sc::derive_imports!();

Expand All @@ -8,7 +10,7 @@ pub trait TokenSendModule {
fn send_multiple_tokens_if_not_zero(
&self,
destination: &ManagedAddress,
payments: &ManagedVec<EsdtTokenPayment<Self::Api>>,
payments: &PaymentsVec<Self::Api>,
) {
let mut non_zero_payments = ManagedVec::new();
for payment in payments {
Expand All @@ -21,27 +23,4 @@ pub trait TokenSendModule {
self.send().direct_multi(destination, &non_zero_payments)
}
}

fn send_tokens_non_zero(
&self,
to: &ManagedAddress,
token_id: &TokenIdentifier,
token_nonce: u64,
amount: &BigUint,
) {
if amount == &0 {
return;
}

self.send().direct_esdt(to, token_id, token_nonce, amount);
}

fn send_payment_non_zero(&self, to: &ManagedAddress, payment: &EsdtTokenPayment<Self::Api>) {
self.send_tokens_non_zero(
to,
&payment.token_identifier,
payment.token_nonce,
&payment.amount,
);
}
}
3 changes: 0 additions & 3 deletions dex/farm-with-locked-rewards/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ path = "../../common/modules/farm/events"
[dependencies.contexts]
path = "../../common/modules/farm/contexts"

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

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

Expand Down
7 changes: 4 additions & 3 deletions dex/farm-with-locked-rewards/src/external_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use crate::NoMintWrapper;
pub trait ExternalInteractionsModule:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down Expand Up @@ -57,7 +56,8 @@ pub trait ExternalInteractionsModule:

let boosted_rewards = self.claim_only_boosted_payment(&user);
let new_farm_token = self.enter_farm::<NoMintWrapper<Self>>(user.clone());
self.send_payment_non_zero(&caller, &new_farm_token);
self.send()
.direct_non_zero_esdt_payment(&caller, &new_farm_token);

let locked_rewards_payment = if boosted_rewards == 0 {
let locked_token_id = self.get_locked_token_id();
Expand Down Expand Up @@ -90,7 +90,8 @@ pub trait ExternalInteractionsModule:

let claim_rewards_result = self.claim_rewards::<NoMintWrapper<Self>>(user.clone());

self.send_payment_non_zero(&caller, &claim_rewards_result.new_farm_token);
self.send()
.direct_non_zero_esdt_payment(&caller, &claim_rewards_result.new_farm_token);

let rewards_payment = claim_rewards_result.rewards;
let locked_rewards_payment = if rewards_payment.amount == 0 {
Expand Down
13 changes: 8 additions & 5 deletions dex/farm-with-locked-rewards/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use farm_base_impl::base_traits_impl::FarmContract;
pub trait Farm:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ locking_module::lock_with_energy_module::LockWithEnergyModule
+ farm_token::FarmTokenModule
+ utils::UtilsModule
Expand Down Expand Up @@ -111,7 +110,8 @@ pub trait Farm:
);

let new_farm_token = self.enter_farm::<NoMintWrapper<Self>>(orig_caller.clone());
self.send_payment_non_zero(&caller, &new_farm_token);
self.send()
.direct_non_zero_esdt_payment(&caller, &new_farm_token);
self.update_energy_and_progress(&orig_caller);

self.update_start_of_epoch_timestamp();
Expand All @@ -130,7 +130,8 @@ pub trait Farm:
self.migrate_old_farm_positions(&orig_caller);

let claim_rewards_result = self.claim_rewards::<NoMintWrapper<Self>>(orig_caller.clone());
self.send_payment_non_zero(&caller, &claim_rewards_result.new_farm_token);
self.send()
.direct_non_zero_esdt_payment(&caller, &claim_rewards_result.new_farm_token);

let rewards_payment = claim_rewards_result.rewards;
let locked_rewards_payment = self.send_to_lock_contract_non_zero(
Expand Down Expand Up @@ -161,7 +162,8 @@ pub trait Farm:
self.decrease_old_farm_positions(migrated_amount, &orig_caller);

let rewards = exit_farm_result.rewards;
self.send_payment_non_zero(&caller, &exit_farm_result.farming_tokens);
self.send()
.direct_non_zero_esdt_payment(&caller, &exit_farm_result.farming_tokens);

let locked_rewards_payment = self.send_to_lock_contract_non_zero(
rewards.token_identifier.clone(),
Expand Down Expand Up @@ -190,7 +192,8 @@ pub trait Farm:
let boosted_rewards = self.claim_only_boosted_payment(&orig_caller);

let merged_farm_token = self.merge_and_update_farm_tokens(orig_caller.clone());
self.send_payment_non_zero(&caller, &merged_farm_token);
self.send()
.direct_non_zero_esdt_payment(&caller, &merged_farm_token);

let locked_rewards_payment = self.send_to_lock_contract_non_zero(
self.reward_token_id().get(),
Expand Down
8 changes: 1 addition & 7 deletions dex/farm-with-locked-rewards/wasm/Cargo.lock

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

3 changes: 0 additions & 3 deletions dex/farm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ path = "../../common/modules/farm/events"
[dependencies.contexts]
path = "../../common/modules/farm/contexts"

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

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

Expand Down
1 change: 0 additions & 1 deletion dex/farm/src/base_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ impl<M: ManagedTypeApi> Into<ExitFarmResultType<M>> for ExitFarmResultWrapper<M>
pub trait BaseFunctionsModule:
rewards::RewardsModule
+ config::ConfigModule
+ token_send::TokenSendModule
+ farm_token::FarmTokenModule
+ pausable::PausableModule
+ permissions_module::PermissionsModule
Expand Down
Loading

0 comments on commit eb6a8d1

Please sign in to comment.