diff --git a/Cargo.lock b/Cargo.lock index 42951acbf..32820097b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" @@ -209,7 +209,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -232,7 +231,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -533,7 +531,6 @@ dependencies = [ "sc_whitelist_module", "simple-lock", "timestamp-oracle", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -595,7 +592,6 @@ dependencies = [ "rewards", "sc_whitelist_module", "timestamp-oracle", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -782,7 +778,6 @@ dependencies = [ "sc_whitelist_module", "simple-lock", "timestamp-oracle", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -815,7 +810,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -1593,6 +1587,7 @@ dependencies = [ "pausable", "permissions_module", "timestamp-oracle", + "utils", ] [[package]] @@ -1739,7 +1734,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -1752,7 +1746,6 @@ dependencies = [ "pair", "pausable", "simple-lock", - "token_send", ] [[package]] diff --git a/common/modules/farm/config/Cargo.toml b/common/modules/farm/config/Cargo.toml index 42868939f..9d0af913a 100644 --- a/common/modules/farm/config/Cargo.toml +++ b/common/modules/farm/config/Cargo.toml @@ -13,9 +13,6 @@ path = "../../../common_structs" [dependencies.common_errors] path = "../../../common_errors" -[dependencies.token_send] -path = "../../token_send" - [dependencies.pausable] path = "../../pausable" diff --git a/common/modules/farm/contexts/Cargo.toml b/common/modules/farm/contexts/Cargo.toml index 1e09c2bed..d71d02191 100644 --- a/common/modules/farm/contexts/Cargo.toml +++ b/common/modules/farm/contexts/Cargo.toml @@ -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" diff --git a/common/modules/farm/farm_base_impl/Cargo.toml b/common/modules/farm/farm_base_impl/Cargo.toml index e8c7462d3..75af37198 100644 --- a/common/modules/farm/farm_base_impl/Cargo.toml +++ b/common/modules/farm/farm_base_impl/Cargo.toml @@ -22,9 +22,6 @@ path = "../events" [dependencies.contexts] path = "../contexts" -[dependencies.token_send] -path = "../../token_send" - [dependencies.token_merge_helper] path = "../../token_merge_helper" diff --git a/common/modules/farm/farm_base_impl/src/claim_rewards.rs b/common/modules/farm/farm_base_impl/src/claim_rewards.rs index b862b1355..4bd52d82e 100644 --- a/common/modules/farm/farm_base_impl/src/claim_rewards.rs +++ b/common/modules/farm/farm_base_impl/src/claim_rewards.rs @@ -24,7 +24,6 @@ where pub trait BaseClaimRewardsModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule diff --git a/common/modules/farm/farm_base_impl/src/compound_rewards.rs b/common/modules/farm/farm_base_impl/src/compound_rewards.rs index cbde8f124..e988d0329 100644 --- a/common/modules/farm/farm_base_impl/src/compound_rewards.rs +++ b/common/modules/farm/farm_base_impl/src/compound_rewards.rs @@ -25,7 +25,6 @@ where pub trait BaseCompoundRewardsModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule diff --git a/common/modules/farm/farm_base_impl/src/enter_farm.rs b/common/modules/farm/farm_base_impl/src/enter_farm.rs index 5ef08c699..9a0e074c9 100644 --- a/common/modules/farm/farm_base_impl/src/enter_farm.rs +++ b/common/modules/farm/farm_base_impl/src/enter_farm.rs @@ -22,7 +22,6 @@ where pub trait BaseEnterFarmModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule diff --git a/common/modules/farm/farm_base_impl/src/exit_farm.rs b/common/modules/farm/farm_base_impl/src/exit_farm.rs index 6cb9d8f05..6c135049d 100644 --- a/common/modules/farm/farm_base_impl/src/exit_farm.rs +++ b/common/modules/farm/farm_base_impl/src/exit_farm.rs @@ -22,7 +22,6 @@ where pub trait BaseExitFarmModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule diff --git a/common/modules/farm/farm_base_impl/src/lib.rs b/common/modules/farm/farm_base_impl/src/lib.rs index 24e156d2a..e92e12c98 100644 --- a/common/modules/farm/farm_base_impl/src/lib.rs +++ b/common/modules/farm/farm_base_impl/src/lib.rs @@ -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 diff --git a/common/modules/farm/rewards/Cargo.toml b/common/modules/farm/rewards/Cargo.toml index 06bed7548..066136193 100644 --- a/common/modules/farm/rewards/Cargo.toml +++ b/common/modules/farm/rewards/Cargo.toml @@ -19,9 +19,6 @@ path = "../config" [dependencies.farm_token] path = "../farm_token" -[dependencies.token_send] -path = "../../token_send" - [dependencies.pausable] path = "../../pausable" diff --git a/common/modules/farm/rewards/src/rewards.rs b/common/modules/farm/rewards/src/rewards.rs index acd9349df..bc7b57d58 100644 --- a/common/modules/farm/rewards/src/rewards.rs +++ b/common/modules/farm/rewards/src/rewards.rs @@ -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); diff --git a/common/modules/token_send/src/token_send.rs b/common/modules/token_send/src/token_send.rs index aefee5cb3..24cb54011 100644 --- a/common/modules/token_send/src/token_send.rs +++ b/common/modules/token_send/src/token_send.rs @@ -1,5 +1,7 @@ #![no_std] +use common_structs::PaymentsVec; + multiversx_sc::imports!(); multiversx_sc::derive_imports!(); @@ -8,7 +10,7 @@ pub trait TokenSendModule { fn send_multiple_tokens_if_not_zero( &self, destination: &ManagedAddress, - payments: &ManagedVec>, + payments: &PaymentsVec, ) { let mut non_zero_payments = ManagedVec::new(); for payment in payments { @@ -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.send_tokens_non_zero( - to, - &payment.token_identifier, - payment.token_nonce, - &payment.amount, - ); - } } diff --git a/dex/farm-with-locked-rewards/Cargo.toml b/dex/farm-with-locked-rewards/Cargo.toml index 1968a43a9..e767c3278 100644 --- a/dex/farm-with-locked-rewards/Cargo.toml +++ b/dex/farm-with-locked-rewards/Cargo.toml @@ -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" diff --git a/dex/farm-with-locked-rewards/src/external_interaction.rs b/dex/farm-with-locked-rewards/src/external_interaction.rs index e435812d1..67c22e5b6 100644 --- a/dex/farm-with-locked-rewards/src/external_interaction.rs +++ b/dex/farm-with-locked-rewards/src/external_interaction.rs @@ -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 @@ -57,7 +56,8 @@ pub trait ExternalInteractionsModule: let boosted_rewards = self.claim_only_boosted_payment(&user); let new_farm_token = self.enter_farm::>(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(); @@ -90,7 +90,8 @@ pub trait ExternalInteractionsModule: let claim_rewards_result = self.claim_rewards::>(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 { diff --git a/dex/farm-with-locked-rewards/src/lib.rs b/dex/farm-with-locked-rewards/src/lib.rs index 98a048dfe..243c3f94f 100644 --- a/dex/farm-with-locked-rewards/src/lib.rs +++ b/dex/farm-with-locked-rewards/src/lib.rs @@ -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 @@ -111,7 +110,8 @@ pub trait Farm: ); let new_farm_token = self.enter_farm::>(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(); @@ -130,7 +130,8 @@ pub trait Farm: self.migrate_old_farm_positions(&orig_caller); let claim_rewards_result = self.claim_rewards::>(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( @@ -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(), @@ -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(), diff --git a/dex/farm-with-locked-rewards/wasm/Cargo.lock b/dex/farm-with-locked-rewards/wasm/Cargo.lock index 87136c504..0a81da735 100644 --- a/dex/farm-with-locked-rewards/wasm/Cargo.lock +++ b/dex/farm-with-locked-rewards/wasm/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "arrayvec" @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -187,7 +184,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -219,7 +215,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -493,7 +488,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/dex/farm/Cargo.toml b/dex/farm/Cargo.toml index f2e0e3202..80150786b 100644 --- a/dex/farm/Cargo.toml +++ b/dex/farm/Cargo.toml @@ -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" diff --git a/dex/farm/src/base_functions.rs b/dex/farm/src/base_functions.rs index 57fa89d41..7402eafb6 100644 --- a/dex/farm/src/base_functions.rs +++ b/dex/farm/src/base_functions.rs @@ -44,7 +44,6 @@ impl Into> for ExitFarmResultWrapper pub trait BaseFunctionsModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule diff --git a/dex/farm/src/external_interaction.rs b/dex/farm/src/external_interaction.rs index 99f602c36..db3275e36 100644 --- a/dex/farm/src/external_interaction.rs +++ b/dex/farm/src/external_interaction.rs @@ -11,7 +11,6 @@ use crate::{ pub trait ExternalInteractionsModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule @@ -59,8 +58,10 @@ pub trait ExternalInteractionsModule: EsdtTokenPayment::new(self.reward_token_id().get(), 0, boosted_rewards); let new_farm_token = self.enter_farm::>(user.clone()); - self.send_payment_non_zero(&caller, &new_farm_token); - self.send_payment_non_zero(&user, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&user, &boosted_rewards_payment); self.update_energy_and_progress(&user); @@ -82,8 +83,10 @@ pub trait ExternalInteractionsModule: let claim_rewards_result = self.claim_rewards::>(user.clone()); - self.send_payment_non_zero(&caller, &claim_rewards_result.new_farm_token); - self.send_payment_non_zero(&user, &claim_rewards_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &claim_rewards_result.new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&user, &claim_rewards_result.rewards); claim_rewards_result.into() } diff --git a/dex/farm/src/lib.rs b/dex/farm/src/lib.rs index 93f06c8cc..10c0179e7 100644 --- a/dex/farm/src/lib.rs +++ b/dex/farm/src/lib.rs @@ -22,7 +22,6 @@ pub const MAX_PERCENT: u64 = 10_000; pub trait Farm: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + pausable::PausableModule + permissions_module::PermissionsModule @@ -105,8 +104,10 @@ pub trait Farm: EsdtTokenPayment::new(self.reward_token_id().get(), 0, boosted_rewards); let new_farm_token = self.enter_farm::>(orig_caller.clone()); - self.send_payment_non_zero(&caller, &new_farm_token); - self.send_payment_non_zero(&caller, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &boosted_rewards_payment); self.update_energy_and_progress(&orig_caller); self.update_start_of_epoch_timestamp(); @@ -126,8 +127,10 @@ pub trait Farm: self.migrate_old_farm_positions(&orig_caller); let claim_rewards_result = self.claim_rewards::>(orig_caller); - self.send_payment_non_zero(&caller, &claim_rewards_result.new_farm_token); - self.send_payment_non_zero(&caller, &claim_rewards_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &claim_rewards_result.new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &claim_rewards_result.rewards); self.update_start_of_epoch_timestamp(); @@ -146,7 +149,8 @@ pub trait Farm: self.migrate_old_farm_positions(&orig_caller); let output_farm_token_payment = self.compound_rewards::>(orig_caller.clone()); - self.send_payment_non_zero(&caller, &output_farm_token_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &output_farm_token_payment); self.update_energy_and_progress(&orig_caller); self.update_start_of_epoch_timestamp(); @@ -167,8 +171,10 @@ pub trait Farm: let exit_farm_result = self.exit_farm::>(orig_caller.clone(), payment); self.decrease_old_farm_positions(migrated_amount, &orig_caller); - self.send_payment_non_zero(&caller, &exit_farm_result.farming_tokens); - self.send_payment_non_zero(&caller, &exit_farm_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &exit_farm_result.farming_tokens); + self.send() + .direct_non_zero_esdt_payment(&caller, &exit_farm_result.rewards); self.clear_user_energy_if_needed(&orig_caller); self.update_start_of_epoch_timestamp(); @@ -192,8 +198,10 @@ pub trait Farm: let merged_farm_token = self.merge_and_update_farm_tokens(orig_caller); - self.send_payment_non_zero(&caller, &merged_farm_token); - self.send_payment_non_zero(&caller, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &merged_farm_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &boosted_rewards_payment); self.update_start_of_epoch_timestamp(); @@ -241,7 +249,8 @@ pub trait Farm: self.set_farm_supply_for_current_week(&storage_cache.farm_token_supply); - self.send_payment_non_zero(user, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(user, &boosted_rewards_payment); // Don't need to call update here too, the internal functions call it already diff --git a/dex/farm/wasm/Cargo.lock b/dex/farm/wasm/Cargo.lock index cceb61c15..c8ae95f12 100644 --- a/dex/farm/wasm/Cargo.lock +++ b/dex/farm/wasm/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "arrayvec" @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -186,7 +183,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -460,7 +456,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/dex/proxy-deployer/Cargo.toml b/dex/proxy-deployer/Cargo.toml index 5043ec5a9..0a6fa03f0 100644 --- a/dex/proxy-deployer/Cargo.toml +++ b/dex/proxy-deployer/Cargo.toml @@ -24,6 +24,9 @@ path = "../../common/modules/permissions_module" [dependencies.pausable] path = "../../common/modules/pausable" +[dependencies.utils] +path = "../../common/modules/utils" + [dependencies.farm-boosted-yields] path = "../../energy-integration/farm-boosted-yields" diff --git a/dex/proxy-deployer/src/lib.rs b/dex/proxy-deployer/src/lib.rs index fa82e8bee..18cfbc580 100644 --- a/dex/proxy-deployer/src/lib.rs +++ b/dex/proxy-deployer/src/lib.rs @@ -18,6 +18,7 @@ pub trait ProxyDeployer: + remove_contracts::RemoveContractsModule + storage::StorageModule + views::ViewModule + + utils::UtilsModule { #[init] fn init( @@ -27,16 +28,9 @@ pub trait ProxyDeployer: timestamp_oracle_address: ManagedAddress, boosted_yields_factors: BoostedYieldsFactors, ) { - require!( - self.blockchain().is_smart_contract(&template_address), - "Invalid farm template address" - ); + self.require_sc_address(&template_address); + self.require_sc_address(×tamp_oracle_address); require!(deployer_type != DeployerType::None, "Invalid deployer type"); - require!( - self.blockchain() - .is_smart_contract(×tamp_oracle_address), - "Invalid timestamp oracle address" - ); self.template_address().set(template_address); self.deployer_type().set(deployer_type); diff --git a/dex/proxy-deployer/wasm/Cargo.lock b/dex/proxy-deployer/wasm/Cargo.lock index ba8ce0e7c..eef769ff7 100644 --- a/dex/proxy-deployer/wasm/Cargo.lock +++ b/dex/proxy-deployer/wasm/Cargo.lock @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -188,7 +185,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -212,7 +208,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -465,6 +460,7 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", + "utils", ] [[package]] @@ -506,7 +502,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/dex/router/Cargo.toml b/dex/router/Cargo.toml index 4ecf1aa3c..eba41f885 100644 --- a/dex/router/Cargo.toml +++ b/dex/router/Cargo.toml @@ -8,9 +8,6 @@ publish = false [lib] path = "src/contract.rs" -[dependencies.token_send] -path = "../../common/modules/token_send" - [dependencies.pausable] path = "../../common/modules/pausable" diff --git a/dex/router/src/contract.rs b/dex/router/src/contract.rs index 800a20b91..c46458879 100644 --- a/dex/router/src/contract.rs +++ b/dex/router/src/contract.rs @@ -30,7 +30,6 @@ pub trait Router: + factory::FactoryModule + events::EventsModule + multi_pair_swap::MultiPairSwap - + token_send::TokenSendModule + enable_swap_by_user::EnableSwapByUserModule { #[init] diff --git a/dex/router/src/multi_pair_swap.rs b/dex/router/src/multi_pair_swap.rs index 8a09bfb9f..78bab40cc 100644 --- a/dex/router/src/multi_pair_swap.rs +++ b/dex/router/src/multi_pair_swap.rs @@ -16,7 +16,6 @@ pub trait MultiPairSwap: config::ConfigModule + read_pair_storage::ReadPairStorageModule + factory::FactoryModule - + token_send::TokenSendModule + events::EventsModule { #[payable("*")] diff --git a/dex/router/wasm/Cargo.lock b/dex/router/wasm/Cargo.lock index 7bddc11e7..0c15aab7f 100644 --- a/dex/router/wasm/Cargo.lock +++ b/dex/router/wasm/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "arrayvec" @@ -308,7 +308,6 @@ dependencies = [ "pair", "pausable", "simple-lock", - "token_send", ] [[package]] diff --git a/energy-integration/energy-update/wasm/Cargo.lock b/energy-integration/energy-update/wasm/Cargo.lock index 414f83b21..d819138cd 100644 --- a/energy-integration/energy-update/wasm/Cargo.lock +++ b/energy-integration/energy-update/wasm/Cargo.lock @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -155,7 +153,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -196,7 +193,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -470,7 +466,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/farm-staking/farm-staking-proxy/src/proxy_actions/external_interaction.rs b/farm-staking/farm-staking-proxy/src/proxy_actions/external_interaction.rs index 722bc2eb8..9ab575624 100644 --- a/farm-staking/farm-staking-proxy/src/proxy_actions/external_interaction.rs +++ b/farm-staking/farm-staking-proxy/src/proxy_actions/external_interaction.rs @@ -32,9 +32,16 @@ pub trait ProxyExternalInteractionsModule: let output_payments = self.stake_farm_tokens_common(original_owner.clone(), payments); - self.send_payment_non_zero(&original_owner, &output_payments.lp_farm_boosted_rewards); - self.send_payment_non_zero(&original_owner, &output_payments.staking_boosted_rewards); - self.send_payment_non_zero(&caller, &output_payments.dual_yield_tokens); + self.send().direct_non_zero_esdt_payment( + &original_owner, + &output_payments.lp_farm_boosted_rewards, + ); + self.send().direct_non_zero_esdt_payment( + &original_owner, + &output_payments.staking_boosted_rewards, + ); + self.send() + .direct_non_zero_esdt_payment(&caller, &output_payments.dual_yield_tokens); output_payments } @@ -50,9 +57,12 @@ pub trait ProxyExternalInteractionsModule: let claim_result = self.claim_dual_yield_common(original_owner.clone(), payment); - self.send_payment_non_zero(&original_owner, &claim_result.lp_farm_rewards); - self.send_payment_non_zero(&original_owner, &claim_result.staking_farm_rewards); - self.send_payment_non_zero(&caller, &claim_result.new_dual_yield_tokens); + self.send() + .direct_non_zero_esdt_payment(&original_owner, &claim_result.lp_farm_rewards); + self.send() + .direct_non_zero_esdt_payment(&original_owner, &claim_result.staking_farm_rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &claim_result.new_dual_yield_tokens); claim_result } diff --git a/farm-staking/farm-staking-proxy/src/proxy_actions/stake.rs b/farm-staking/farm-staking-proxy/src/proxy_actions/stake.rs index 9c4ee127a..f03ddbd13 100644 --- a/farm-staking/farm-staking-proxy/src/proxy_actions/stake.rs +++ b/farm-staking/farm-staking-proxy/src/proxy_actions/stake.rs @@ -25,7 +25,7 @@ pub trait ProxyStakeModule: let output_payments = self.stake_farm_tokens_common(orig_caller, payments); - output_payments.send_and_return(self, &caller) + output_payments.send_and_return(self.send(), &caller) } fn stake_farm_tokens_common( diff --git a/farm-staking/farm-staking-proxy/src/result_types.rs b/farm-staking/farm-staking-proxy/src/result_types.rs index 2130fd696..c2cd2544c 100644 --- a/farm-staking/farm-staking-proxy/src/result_types.rs +++ b/farm-staking/farm-staking-proxy/src/result_types.rs @@ -1,3 +1,8 @@ +use multiversx_sc::{ + api::{CallTypeApi, StorageReadApi}, + contract_base::SendWrapper, +}; + multiversx_sc::imports!(); multiversx_sc::derive_imports!(); @@ -48,15 +53,11 @@ pub struct StakeProxyResult { pub lp_farm_boosted_rewards: EsdtTokenPayment, } -impl StakeProxyResult { - pub fn send_and_return>( - self, - sc: &SC, - to: &ManagedAddress, - ) -> Self { - sc.send_payment_non_zero(to, &self.dual_yield_tokens); - sc.send_payment_non_zero(to, &self.staking_boosted_rewards); - sc.send_payment_non_zero(to, &self.lp_farm_boosted_rewards); +impl StakeProxyResult { + pub fn send_and_return(self, send_wrapper: SendWrapper, to: &ManagedAddress) -> Self { + send_wrapper.direct_non_zero_esdt_payment(to, &self.dual_yield_tokens); + send_wrapper.direct_non_zero_esdt_payment(to, &self.staking_boosted_rewards); + send_wrapper.direct_non_zero_esdt_payment(to, &self.lp_farm_boosted_rewards); self } diff --git a/farm-staking/farm-staking-proxy/wasm/Cargo.lock b/farm-staking/farm-staking-proxy/wasm/Cargo.lock index fdebecdd2..c83e068d7 100644 --- a/farm-staking/farm-staking-proxy/wasm/Cargo.lock +++ b/farm-staking/farm-staking-proxy/wasm/Cargo.lock @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -188,7 +185,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -255,7 +251,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -279,7 +274,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -559,7 +553,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/farm-staking/farm-staking/Cargo.toml b/farm-staking/farm-staking/Cargo.toml index 11ec5acb0..0bdf246e5 100644 --- a/farm-staking/farm-staking/Cargo.toml +++ b/farm-staking/farm-staking/Cargo.toml @@ -44,9 +44,6 @@ path = "../../common/modules/farm/contexts" [dependencies.utils] path = "../../common/modules/utils" -[dependencies.token_send] -path = "../../common/modules/token_send" - [dependencies.pausable] path = "../../common/modules/pausable" diff --git a/farm-staking/farm-staking/src/claim_only_boosted_staking_rewards.rs b/farm-staking/farm-staking/src/claim_only_boosted_staking_rewards.rs index 68bee7d69..73ac70a2b 100644 --- a/farm-staking/farm-staking/src/claim_only_boosted_staking_rewards.rs +++ b/farm-staking/farm-staking/src/claim_only_boosted_staking_rewards.rs @@ -21,7 +21,6 @@ pub trait ClaimOnlyBoostedStakingRewardsModule: + weekly_rewards_splitting::update_claim_progress_energy::UpdateClaimProgressEnergyModule + farm_base_impl::base_farm_validation::BaseFarmValidationModule + energy_query::EnergyQueryModule - + token_send::TokenSendModule + events::EventsModule + utils::UtilsModule + farm_boosted_yields::FarmBoostedYieldsModule @@ -58,7 +57,8 @@ pub trait ClaimOnlyBoostedStakingRewardsModule: self.set_farm_supply_for_current_week(&storage_cache.farm_token_supply); - self.send_payment_non_zero(user, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(user, &boosted_rewards_payment); boosted_rewards_payment } diff --git a/farm-staking/farm-staking/src/claim_stake_farm_rewards.rs b/farm-staking/farm-staking/src/claim_stake_farm_rewards.rs index 3f4bb5bd3..6911332e8 100644 --- a/farm-staking/farm-staking/src/claim_stake_farm_rewards.rs +++ b/farm-staking/farm-staking/src/claim_stake_farm_rewards.rs @@ -11,7 +11,6 @@ pub trait ClaimStakeFarmRewardsModule: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -98,8 +97,10 @@ pub trait ClaimStakeFarmRewardsModule: virtual_farm_token.payment.token_nonce = new_farm_token_nonce; let caller = self.blockchain().get_caller(); - self.send_payment_non_zero(&caller, &virtual_farm_token.payment); - self.send_payment_non_zero(&caller, &claim_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &virtual_farm_token.payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &claim_result.rewards); self.emit_claim_rewards_event( &caller, diff --git a/farm-staking/farm-staking/src/compound_stake_farm_rewards.rs b/farm-staking/farm-staking/src/compound_stake_farm_rewards.rs index 52a4ce909..a355c413a 100644 --- a/farm-staking/farm-staking/src/compound_stake_farm_rewards.rs +++ b/farm-staking/farm-staking/src/compound_stake_farm_rewards.rs @@ -9,7 +9,6 @@ pub trait CompoundStakeFarmRewardsModule: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -41,7 +40,8 @@ pub trait CompoundStakeFarmRewardsModule: self.compound_rewards_base::>(caller.clone(), payments); let new_farm_token = compound_result.new_farm_token.payment.clone(); - self.send_payment_non_zero(&caller, &new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_farm_token); self.set_farm_supply_for_current_week(&compound_result.storage_cache.farm_token_supply); diff --git a/farm-staking/farm-staking/src/custom_rewards.rs b/farm-staking/farm-staking/src/custom_rewards.rs index b1ba4935c..5ff732125 100644 --- a/farm-staking/farm-staking/src/custom_rewards.rs +++ b/farm-staking/farm-staking/src/custom_rewards.rs @@ -1,23 +1,24 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); -use common_structs::Epoch; +use common_structs::{Epoch, Percent}; use contexts::storage_cache::StorageCache; use farm_base_impl::base_traits_impl::FarmContract; use crate::base_impl_wrapper::FarmStakingWrapper; -pub const MAX_PERCENT: u64 = 10_000; +// TODO: Will need to be changed when block duration changes pub const BLOCKS_IN_YEAR: u64 = 31_536_000 / 6; // seconds_in_year / 6_seconds_per_block -pub const MAX_MIN_UNBOND_EPOCHS: u64 = 30; -pub const WITHDRAW_AMOUNT_TOO_HIGH: &str = - "Withdraw amount is higher than the remaining uncollected rewards!"; + +pub const MAX_PERCENT: Percent = 10_000; +pub const MAX_MIN_UNBOND_EPOCHS: Epoch = 30; +pub static WITHDRAW_AMOUNT_TOO_HIGH: &[u8] = + b"Withdraw amount is higher than the remaining uncollected rewards"; #[multiversx_sc::module] pub trait CustomRewardsModule: rewards::RewardsModule + config::ConfigModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + utils::UtilsModule + pausable::PausableModule @@ -48,7 +49,6 @@ pub trait CustomRewardsModule: self.update_start_of_epoch_timestamp(); } - #[payable("*")] #[endpoint(withdrawRewards)] fn withdraw_rewards(&self, withdraw_amount: BigUint) { self.require_caller_has_admin_permissions(); @@ -56,26 +56,29 @@ pub trait CustomRewardsModule: let mut storage_cache = StorageCache::new(self); FarmStakingWrapper::::generate_aggregated_rewards(self, &mut storage_cache); - let reward_capacity_mapper = self.reward_capacity(); - let accumulated_rewards_mapper = self.accumulated_rewards(); - let remaining_rewards = reward_capacity_mapper.get() - accumulated_rewards_mapper.get(); + let reward_capactiy = self.reward_capacity().get(); + let accumulated_rewards = self.accumulated_rewards().get(); + let remaining_rewards = &reward_capactiy - &accumulated_rewards; require!( withdraw_amount <= remaining_rewards, WITHDRAW_AMOUNT_TOO_HIGH ); + require!( + reward_capactiy >= withdraw_amount, + "Not enough rewards to withdraw" + ); - reward_capacity_mapper.update(|rewards| { - require!( - *rewards >= withdraw_amount, - "Not enough rewards to withdraw" - ); - - *rewards -= withdraw_amount.clone() - }); + let new_capacity = &reward_capactiy - &withdraw_amount; + self.reward_capacity().set(new_capacity); let caller = self.blockchain().get_caller(); let reward_token_id = self.reward_token_id().get(); - self.send_tokens_non_zero(&caller, &reward_token_id, 0, &withdraw_amount); + self.send().direct_non_zero( + &caller, + &EgldOrEsdtTokenIdentifier::esdt(reward_token_id), + 0, + &withdraw_amount, + ); self.update_start_of_epoch_timestamp(); } diff --git a/farm-staking/farm-staking/src/external_interaction.rs b/farm-staking/farm-staking/src/external_interaction.rs index 3e99d1465..c7505fe21 100644 --- a/farm-staking/farm-staking/src/external_interaction.rs +++ b/farm-staking/farm-staking/src/external_interaction.rs @@ -14,7 +14,6 @@ pub trait ExternalInteractionsModule: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -68,8 +67,10 @@ pub trait ExternalInteractionsModule: let enter_result = self.enter_farm_base::>(user.clone(), payments); let new_farm_token = enter_result.new_farm_token.payment.clone(); - self.send_payment_non_zero(&caller, &new_farm_token); - self.send_payment_non_zero(&user, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&user, &boosted_rewards_payment); self.set_farm_supply_for_current_week(&enter_result.storage_cache.farm_token_supply); @@ -117,8 +118,10 @@ pub trait ExternalInteractionsModule: virtual_farm_token.payment.token_nonce = new_farm_token_nonce; let caller = self.blockchain().get_caller(); - self.send_payment_non_zero(&caller, &virtual_farm_token.payment); - self.send_payment_non_zero(&user, &claim_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &virtual_farm_token.payment); + self.send() + .direct_non_zero_esdt_payment(&user, &claim_result.rewards); self.emit_claim_rewards_event( &caller, diff --git a/farm-staking/farm-staking/src/lib.rs b/farm-staking/farm-staking/src/lib.rs index 7399c4602..21d509a65 100644 --- a/farm-staking/farm-staking/src/lib.rs +++ b/farm-staking/farm-staking/src/lib.rs @@ -5,6 +5,7 @@ multiversx_sc::imports!(); multiversx_sc::derive_imports!(); use base_impl_wrapper::FarmStakingWrapper; +use common_structs::Epoch; use contexts::storage_cache::StorageCache; use farm::{base_functions::DoubleMultiPayment, MAX_PERCENT}; use farm_base_impl::base_traits_impl::FarmContract; @@ -31,7 +32,6 @@ pub trait FarmStaking: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -71,7 +71,7 @@ pub trait FarmStaking: farming_token_id: TokenIdentifier, division_safety_constant: BigUint, max_apr: BigUint, - min_unbond_epochs: u64, + min_unbond_epochs: Epoch, owner: ManagedAddress, timestamp_oracle_address: ManagedAddress, admins: MultiValueEncoded, @@ -126,8 +126,10 @@ pub trait FarmStaking: let merged_farm_token = self.merge_and_update_farm_tokens(caller.clone()); - self.send_payment_non_zero(&caller, &merged_farm_token); - self.send_payment_non_zero(&caller, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &merged_farm_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &boosted_rewards_payment); self.update_start_of_epoch_timestamp(); diff --git a/farm-staking/farm-staking/src/stake_farm.rs b/farm-staking/farm-staking/src/stake_farm.rs index ae6e8dbed..2ffba0f46 100644 --- a/farm-staking/farm-staking/src/stake_farm.rs +++ b/farm-staking/farm-staking/src/stake_farm.rs @@ -12,7 +12,6 @@ pub trait StakeFarmModule: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -83,8 +82,10 @@ pub trait StakeFarmModule: self.enter_farm_base::>(original_caller.clone(), payments); let new_farm_token = enter_result.new_farm_token.payment.clone(); - self.send_payment_non_zero(&caller, &new_farm_token); - self.send_payment_non_zero(&caller, &boosted_rewards_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_farm_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &boosted_rewards_payment); self.set_farm_supply_for_current_week(&enter_result.storage_cache.farm_token_supply); diff --git a/farm-staking/farm-staking/src/unbond_farm.rs b/farm-staking/farm-staking/src/unbond_farm.rs index 964afb6ab..bbe0ea235 100644 --- a/farm-staking/farm-staking/src/unbond_farm.rs +++ b/farm-staking/farm-staking/src/unbond_farm.rs @@ -10,7 +10,6 @@ pub trait UnbondFarmModule: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -53,7 +52,8 @@ pub trait UnbondFarmModule: let caller = self.blockchain().get_caller(); let farming_tokens = EsdtTokenPayment::new(storage_cache.farming_token_id.clone(), 0, payment.amount); - self.send_payment_non_zero(&caller, &farming_tokens); + self.send() + .direct_non_zero_esdt_payment(&caller, &farming_tokens); self.update_start_of_epoch_timestamp(); diff --git a/farm-staking/farm-staking/src/unstake_farm.rs b/farm-staking/farm-staking/src/unstake_farm.rs index ff5015331..7de1ebf79 100644 --- a/farm-staking/farm-staking/src/unstake_farm.rs +++ b/farm-staking/farm-staking/src/unstake_farm.rs @@ -11,7 +11,6 @@ pub trait UnstakeFarmModule: + rewards::RewardsModule + config::ConfigModule + events::EventsModule - + token_send::TokenSendModule + farm_token::FarmTokenModule + sc_whitelist_module::SCWhitelistModule + pausable::PausableModule @@ -88,7 +87,8 @@ pub trait UnstakeFarmModule: let unbond_farm_token = self.create_and_send_unbond_tokens(&caller, farm_token_id, unbond_token_amount); - self.send_payment_non_zero(&caller, &exit_result.reward_payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &exit_result.reward_payment); self.clear_user_energy_if_needed(&original_caller); self.set_farm_supply_for_current_week(&exit_result.storage_cache.farm_token_supply); diff --git a/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs b/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs index 66235a25a..6a9234ea5 100644 --- a/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs +++ b/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs @@ -50,7 +50,7 @@ pub const USER_REWARDS_FARM_CONST: u64 = 2; pub const MIN_ENERGY_AMOUNT_FOR_BOOSTED_YIELDS: u64 = 1; pub const MIN_FARM_AMOUNT_FOR_BOOSTED_YIELDS: u64 = 1; pub static WITHDRAW_AMOUNT_TOO_HIGH: &str = - "Withdraw amount is higher than the remaining uncollected rewards!"; + "Withdraw amount is higher than the remaining uncollected rewards"; pub const TIMESTAMP_PER_EPOCH: Timestamp = 24 * 60 * 60; diff --git a/farm-staking/farm-staking/wasm/Cargo.lock b/farm-staking/farm-staking/wasm/Cargo.lock index 5bdef3ac7..eaf5d96fd 100644 --- a/farm-staking/farm-staking/wasm/Cargo.lock +++ b/farm-staking/farm-staking/wasm/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "arrayvec" @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -188,7 +185,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -220,7 +216,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -494,7 +489,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/legacy-contracts/farm-staking-proxy-v13/wasm/Cargo.lock b/legacy-contracts/farm-staking-proxy-v13/wasm/Cargo.lock index 6b1ff77aa..fc10f641f 100644 --- a/legacy-contracts/farm-staking-proxy-v13/wasm/Cargo.lock +++ b/legacy-contracts/farm-staking-proxy-v13/wasm/Cargo.lock @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -188,7 +185,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -240,7 +236,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -514,7 +509,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]] diff --git a/locked-asset/proxy_dex/src/proxy_farm.rs b/locked-asset/proxy_dex/src/proxy_farm.rs index 0e96a8848..e43b6111e 100644 --- a/locked-asset/proxy_dex/src/proxy_farm.rs +++ b/locked-asset/proxy_dex/src/proxy_farm.rs @@ -104,8 +104,10 @@ pub trait ProxyFarmModule: } }; - self.send_payment_non_zero(&caller, &new_wrapped_farm_token.payment); - self.send_payment_non_zero(&caller, &enter_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_wrapped_farm_token.payment); + self.send() + .direct_non_zero_esdt_payment(&caller, &enter_result.rewards); self.emit_enter_farm_proxy_event( &original_caller, @@ -218,8 +220,10 @@ pub trait ProxyFarmModule: exit_result.farming_tokens.amount, ); - self.send_payment_non_zero(&caller, &initial_proxy_farming_tokens); - self.send_payment_non_zero(&caller, &exit_result.reward_tokens); + self.send() + .direct_non_zero_esdt_payment(&caller, &initial_proxy_farming_tokens); + self.send() + .direct_non_zero_esdt_payment(&caller, &exit_result.reward_tokens); wrapped_farm_token_mapper.nft_burn(payment.token_nonce, &payment.amount); @@ -322,8 +326,10 @@ pub trait ProxyFarmModule: let new_wrapped_token = wrapped_farm_token_mapper.nft_create(new_token_amount, &new_wrapped_farm_attributes); - self.send_payment_non_zero(&caller, &new_wrapped_token); - self.send_payment_non_zero(&caller, &claim_result.rewards); + self.send() + .direct_non_zero_esdt_payment(&caller, &new_wrapped_token); + self.send() + .direct_non_zero_esdt_payment(&caller, &claim_result.rewards); // Burn farm token wrapped_farm_token_mapper.nft_burn(payment.token_nonce, &payment.amount); diff --git a/locked-asset/proxy_dex/src/wrapped_farm_token_merge.rs b/locked-asset/proxy_dex/src/wrapped_farm_token_merge.rs index 5b071a2f1..801cb213b 100644 --- a/locked-asset/proxy_dex/src/wrapped_farm_token_merge.rs +++ b/locked-asset/proxy_dex/src/wrapped_farm_token_merge.rs @@ -40,7 +40,8 @@ pub trait WrappedFarmTokenMerge: let merged_tokens = self .merge_wrapped_farm_tokens(&caller, farm_address, wrapped_farm_tokens) .payment; - self.send_payment_non_zero(&caller, &merged_tokens); + self.send() + .direct_non_zero_esdt_payment(&caller, &merged_tokens); merged_tokens } diff --git a/locked-asset/proxy_dex/src/wrapped_lp_token_merge.rs b/locked-asset/proxy_dex/src/wrapped_lp_token_merge.rs index 9b25a7ef0..d7a027d91 100644 --- a/locked-asset/proxy_dex/src/wrapped_lp_token_merge.rs +++ b/locked-asset/proxy_dex/src/wrapped_lp_token_merge.rs @@ -35,7 +35,8 @@ pub trait WrappedLpTokenMerge: let merged_tokens = self .merge_wrapped_lp_tokens(&caller, wrapped_lp_tokens) .payment; - self.send_payment_non_zero(&caller, &merged_tokens); + self.send() + .direct_non_zero_esdt_payment(&caller, &merged_tokens); merged_tokens } diff --git a/locked-asset/proxy_dex/wasm/Cargo.lock b/locked-asset/proxy_dex/wasm/Cargo.lock index 1264b51fa..234b06826 100644 --- a/locked-asset/proxy_dex/wasm/Cargo.lock +++ b/locked-asset/proxy_dex/wasm/Cargo.lock @@ -47,7 +47,6 @@ dependencies = [ "multiversx-sc", "pausable", "permissions_module", - "token_send", ] [[package]] @@ -64,7 +63,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", ] [[package]] @@ -137,7 +135,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -187,7 +184,6 @@ dependencies = [ "permissions_module", "rewards", "sc_whitelist_module", - "token_send", "utils", "week-timekeeping", "weekly-rewards-splitting", @@ -211,7 +207,6 @@ dependencies = [ "permissions_module", "rewards", "token_merge_helper", - "token_send", "utils", ] @@ -517,7 +512,6 @@ dependencies = [ "multiversx-sc-modules", "pausable", "permissions_module", - "token_send", ] [[package]]