From 04285fa70303ea533c72e7c36d132c3c4b52667a Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Thu, 11 Jul 2024 15:55:40 +0300 Subject: [PATCH 1/5] user total farm position split --- common/modules/farm/config/src/config.rs | 61 ++-------- .../farm_base_impl/src/base_traits_impl.rs | 22 ++-- dex/farm-with-locked-rewards/src/lib.rs | 3 +- dex/farm-with-locked-rewards/wasm/src/lib.rs | 4 +- dex/farm/src/base_functions.rs | 23 ++-- dex/farm/src/lib.rs | 3 +- .../tests/farm_setup/multi_user_farm_setup.rs | 18 +-- dex/farm/wasm/src/lib.rs | 4 +- .../farm-boosted-yields/src/lib.rs | 4 +- .../tests/staking_farm_with_lp.rs | 4 +- .../mod.rs | 18 +-- .../farm-staking/src/base_impl_wrapper.rs | 29 +++-- .../src/claim_only_boosted_staking_rewards.rs | 21 ++-- .../src/claim_stake_farm_rewards.rs | 8 +- .../tests/farm_staking_energy_test.rs | 5 +- .../tests/farm_staking_setup/mod.rs | 4 +- farm-staking/farm-staking/wasm/src/lib.rs | 4 +- legacy-contracts/farm-v-13/wasm/src/lib.rs | 5 +- .../energy-factory/src/unlock_with_penalty.rs | 17 +++ .../tests/proxy_dex_test_setup/mod.rs | 4 +- .../proxy_dex/tests/proxy_farm_test.rs | 105 +++++++++--------- 21 files changed, 159 insertions(+), 207 deletions(-) diff --git a/common/modules/farm/config/src/config.rs b/common/modules/farm/config/src/config.rs index b712765e5..1f26eed6a 100644 --- a/common/modules/farm/config/src/config.rs +++ b/common/modules/farm/config/src/config.rs @@ -9,46 +9,12 @@ use pausable::State; pub const DEFAULT_NFT_DEPOSIT_MAX_LEN: usize = 10; pub const DEFAULT_FARM_POSITION_MIGRATION_NONCE: u64 = 1; -#[derive( - ManagedVecItem, - TopEncode, - TopDecode, - NestedEncode, - NestedDecode, - TypeAbi, - Clone, - PartialEq, - Debug, -)] -pub struct UserTotalFarmPosition { - pub total_farm_position: BigUint, - pub allow_external_claim_boosted_rewards: bool, -} - -impl Default for UserTotalFarmPosition { - fn default() -> Self { - Self { - total_farm_position: BigUint::zero(), - allow_external_claim_boosted_rewards: false, - } - } -} - #[multiversx_sc::module] pub trait ConfigModule: pausable::PausableModule + permissions_module::PermissionsModule { - #[endpoint(allowExternalClaimBoostedRewards)] - fn allow_external_claim_boosted_rewards(&self, allow_external_claim: bool) { + #[endpoint(setAllowExternalClaimBoostedRewards)] + fn set_allow_external_claim(&self, allow_external_claim: bool) { let caller = self.blockchain().get_caller(); - let mut user_total_farm_position = self.get_user_total_farm_position(&caller); - user_total_farm_position.allow_external_claim_boosted_rewards = allow_external_claim; - self.user_total_farm_position(&caller) - .set(user_total_farm_position); - } - - #[view(getAllowExternalClaimRewards)] - fn get_allow_external_claim_rewards(&self, user: ManagedAddress) -> bool { - let user_total_farm_position = self.get_user_total_farm_position(&user); - user_total_farm_position.allow_external_claim_boosted_rewards + self.allow_external_claim(&caller).set(allow_external_claim); } #[inline] @@ -57,18 +23,6 @@ pub trait ConfigModule: pausable::PausableModule + permissions_module::Permissio state == State::Active } - fn get_user_total_farm_position( - &self, - user: &ManagedAddress, - ) -> UserTotalFarmPosition { - let user_total_farm_position_mapper = self.user_total_farm_position(user); - if user_total_farm_position_mapper.is_empty() { - UserTotalFarmPosition::default() - } else { - user_total_farm_position_mapper.get() - } - } - fn is_old_farm_position(&self, token_nonce: Nonce) -> bool { let farm_position_migration_nonce = self.farm_position_migration_nonce().get(); token_nonce > 0 && token_nonce < farm_position_migration_nonce @@ -121,10 +75,11 @@ pub trait ConfigModule: pausable::PausableModule + permissions_module::Permissio #[view(getUserTotalFarmPosition)] #[storage_mapper("userTotalFarmPosition")] - fn user_total_farm_position( - &self, - user: &ManagedAddress, - ) -> SingleValueMapper>; + fn user_total_farm_position(&self, user: &ManagedAddress) -> SingleValueMapper; + + #[view(getAllowExternalClaim)] + #[storage_mapper("allowExternalClaim")] + fn allow_external_claim(&self, user: &ManagedAddress) -> SingleValueMapper; #[view(getFarmPositionMigrationNonce)] #[storage_mapper("farm_position_migration_nonce")] diff --git a/common/modules/farm/farm_base_impl/src/base_traits_impl.rs b/common/modules/farm/farm_base_impl/src/base_traits_impl.rs index f26b15099..f7f5014ff 100644 --- a/common/modules/farm/farm_base_impl/src/base_traits_impl.rs +++ b/common/modules/farm/farm_base_impl/src/base_traits_impl.rs @@ -230,10 +230,8 @@ pub trait FarmContract { user: &ManagedAddress<::Api>, increase_farm_position_amount: &BigUint<::Api>, ) { - let mut user_total_farm_position = sc.get_user_total_farm_position(user); - user_total_farm_position.total_farm_position += increase_farm_position_amount; sc.user_total_farm_position(user) - .set(user_total_farm_position); + .update(|total_farm_position| *total_farm_position += increase_farm_position_amount); } fn decrease_user_farm_position( @@ -248,14 +246,16 @@ pub trait FarmContract { let token_attributes: FarmTokenAttributes<::Api> = farm_token_mapper.get_token_attributes(farm_position.token_nonce); - sc.user_total_farm_position(&token_attributes.original_owner) - .update(|user_total_farm_position| { - if user_total_farm_position.total_farm_position > farm_position.amount { - user_total_farm_position.total_farm_position -= &farm_position.amount; - } else { - user_total_farm_position.total_farm_position = BigUint::zero(); - } - }); + let user_total_farm_position_mapper = + sc.user_total_farm_position(&token_attributes.original_owner); + let mut user_total_farm_position = user_total_farm_position_mapper.get(); + + if user_total_farm_position > farm_position.amount { + user_total_farm_position -= &farm_position.amount; + user_total_farm_position_mapper.set(user_total_farm_position); + } else { + user_total_farm_position_mapper.clear(); + } } } diff --git a/dex/farm-with-locked-rewards/src/lib.rs b/dex/farm-with-locked-rewards/src/lib.rs index ab57eb826..91144b387 100644 --- a/dex/farm-with-locked-rewards/src/lib.rs +++ b/dex/farm-with-locked-rewards/src/lib.rs @@ -230,10 +230,9 @@ pub trait Farm: OptionalValue::Some(user) => user, OptionalValue::None => &caller, }; - let user_total_farm_position = self.get_user_total_farm_position(user); if user != &caller { require!( - user_total_farm_position.allow_external_claim_boosted_rewards, + self.allow_external_claim(user).get(), "Cannot claim rewards for this address" ); } diff --git a/dex/farm-with-locked-rewards/wasm/src/lib.rs b/dex/farm-with-locked-rewards/wasm/src/lib.rs index 37561d256..9efe33713 100644 --- a/dex/farm-with-locked-rewards/wasm/src/lib.rs +++ b/dex/farm-with-locked-rewards/wasm/src/lib.rs @@ -32,14 +32,14 @@ multiversx_sc_wasm_adapter::endpoints! { calculateRewardsForGivenPosition => calculate_rewards_for_given_position getRewardPerShare => reward_per_share getRewardReserve => reward_reserve - allowExternalClaimBoostedRewards => allow_external_claim_boosted_rewards - getAllowExternalClaimRewards => get_allow_external_claim_rewards + setAllowExternalClaimBoostedRewards => set_allow_external_claim getFarmingTokenId => farming_token_id getRewardTokenId => reward_token_id getPerBlockRewardAmount => per_block_reward_amount getLastRewardBlockNonce => last_reward_block_nonce getDivisionSafetyConstant => division_safety_constant getUserTotalFarmPosition => user_total_farm_position + getAllowExternalClaim => allow_external_claim getFarmPositionMigrationNonce => farm_position_migration_nonce setLockingScAddress => set_locking_sc_address setLockEpochs => set_lock_epochs diff --git a/dex/farm/src/base_functions.rs b/dex/farm/src/base_functions.rs index 48a59ac56..d6455a2b7 100644 --- a/dex/farm/src/base_functions.rs +++ b/dex/farm/src/base_functions.rs @@ -218,10 +218,8 @@ pub trait BaseFunctionsModule: } if migrated_amount > 0 { - let mut user_total_farm_position = self.get_user_total_farm_position(caller); - user_total_farm_position.total_farm_position += &migrated_amount; self.user_total_farm_position(caller) - .set(user_total_farm_position); + .update(|total_farm_position| *total_farm_position += &migrated_amount); } migrated_amount @@ -231,10 +229,16 @@ pub trait BaseFunctionsModule: if migrated_amount == BigUint::zero() { return; } - self.user_total_farm_position(caller) - .update(|user_total_farm_position| { - user_total_farm_position.total_farm_position -= migrated_amount; - }); + + let user_total_farm_position_mapper = self.user_total_farm_position(caller); + let mut user_total_farm_position = user_total_farm_position_mapper.get(); + + if user_total_farm_position > migrated_amount { + user_total_farm_position -= &migrated_amount; + user_total_farm_position_mapper.set(user_total_farm_position); + } else { + user_total_farm_position_mapper.clear(); + } } fn end_produce_rewards>(&self) { @@ -281,10 +285,9 @@ where sc: &::FarmSc, caller: &ManagedAddress<<::FarmSc as ContractBase>::Api>, ) -> BigUint<<::FarmSc as ContractBase>::Api> { - let user_total_farm_position = sc.get_user_total_farm_position(caller); - let user_farm_position = user_total_farm_position.total_farm_position; + let user_total_farm_position = sc.user_total_farm_position(caller).get(); - sc.claim_boosted_yields_rewards(caller, user_farm_position) + sc.claim_boosted_yields_rewards(caller, user_total_farm_position) } } diff --git a/dex/farm/src/lib.rs b/dex/farm/src/lib.rs index d51b9989c..0987dbbce 100644 --- a/dex/farm/src/lib.rs +++ b/dex/farm/src/lib.rs @@ -221,10 +221,9 @@ pub trait Farm: OptionalValue::Some(user) => user, OptionalValue::None => &caller, }; - let user_total_farm_position = self.get_user_total_farm_position(user); if user != &caller { require!( - user_total_farm_position.allow_external_claim_boosted_rewards, + self.allow_external_claim(&user).get(), "Cannot claim rewards for this address" ); } diff --git a/dex/farm/tests/farm_setup/multi_user_farm_setup.rs b/dex/farm/tests/farm_setup/multi_user_farm_setup.rs index 60a82cea2..cb12a2a1e 100644 --- a/dex/farm/tests/farm_setup/multi_user_farm_setup.rs +++ b/dex/farm/tests/farm_setup/multi_user_farm_setup.rs @@ -2,7 +2,7 @@ #![allow(deprecated)] use common_structs::FarmTokenAttributes; -use config::{ConfigModule, UserTotalFarmPosition}; +use config::ConfigModule; use multiversx_sc::codec::multi_types::OptionalValue; use multiversx_sc::{ storage::mappers::StorageTokenWrapper, @@ -610,12 +610,8 @@ where pub fn allow_external_claim_rewards(&mut self, user: &Address, allow_external_claim: bool) { self.b_mock .execute_tx(user, &self.farm_wrapper, &rust_biguint!(0), |sc| { - sc.user_total_farm_position(&managed_address!(user)).update( - |user_total_farm_position| { - user_total_farm_position.allow_external_claim_boosted_rewards = - allow_external_claim; - }, - ); + sc.allow_external_claim(&managed_address!(user)) + .set(allow_external_claim); }) .assert_ok(); } @@ -711,12 +707,8 @@ where pub fn set_user_total_farm_position(&mut self, user_addr: &Address, new_farm_position: u64) { self.b_mock .execute_tx(&self.owner, &self.farm_wrapper, &rust_biguint!(0), |sc| { - let user_farm_position = UserTotalFarmPosition { - total_farm_position: managed_biguint!(new_farm_position), - ..Default::default() - }; sc.user_total_farm_position(&managed_address!(user_addr)) - .set(user_farm_position); + .set(managed_biguint!(new_farm_position)); }) .assert_ok(); } @@ -729,7 +721,7 @@ where if expected_amount > 0 && !user_total_farm_position_mapper.is_empty() { assert_eq!( managed_biguint!(expected_amount), - user_total_farm_position_mapper.get().total_farm_position + user_total_farm_position_mapper.get() ); } }) diff --git a/dex/farm/wasm/src/lib.rs b/dex/farm/wasm/src/lib.rs index 60fe520f8..a4b92d26e 100644 --- a/dex/farm/wasm/src/lib.rs +++ b/dex/farm/wasm/src/lib.rs @@ -33,14 +33,14 @@ multiversx_sc_wasm_adapter::endpoints! { calculateRewardsForGivenPosition => calculate_rewards_for_given_position getRewardPerShare => reward_per_share getRewardReserve => reward_reserve - allowExternalClaimBoostedRewards => allow_external_claim_boosted_rewards - getAllowExternalClaimRewards => get_allow_external_claim_rewards + setAllowExternalClaimBoostedRewards => set_allow_external_claim getFarmingTokenId => farming_token_id getRewardTokenId => reward_token_id getPerBlockRewardAmount => per_block_reward_amount getLastRewardBlockNonce => last_reward_block_nonce getDivisionSafetyConstant => division_safety_constant getUserTotalFarmPosition => user_total_farm_position + getAllowExternalClaim => allow_external_claim getFarmPositionMigrationNonce => farm_position_migration_nonce registerFarmToken => register_farm_token getFarmTokenId => farm_token diff --git a/energy-integration/farm-boosted-yields/src/lib.rs b/energy-integration/farm-boosted-yields/src/lib.rs index 09bacc676..739907b2c 100644 --- a/energy-integration/farm-boosted-yields/src/lib.rs +++ b/energy-integration/farm-boosted-yields/src/lib.rs @@ -123,12 +123,12 @@ pub trait FarmBoostedYieldsModule: fn clear_user_energy_if_needed(&self, original_caller: &ManagedAddress) { let opt_config = self.try_get_boosted_yields_config(); - let user_total_farm_position = self.get_user_total_farm_position(original_caller); + let user_total_farm_position = self.user_total_farm_position(original_caller).get(); if let Some(config) = opt_config { let boosted_yields_factors = config.get_latest_factors(); self.clear_user_energy( original_caller, - &user_total_farm_position.total_farm_position, + &user_total_farm_position, &boosted_yields_factors.min_farm_amount, ); } diff --git a/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs b/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs index 34fbe059e..1321443ee 100644 --- a/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs +++ b/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs @@ -773,7 +773,7 @@ fn claim_for_others_positive_test() { &setup.lp_farm_wrapper, &rust_biguint!(0), |sc| { - sc.allow_external_claim_boosted_rewards(true); + sc.set_allow_external_claim(true); }, ) .assert_ok(); @@ -785,7 +785,7 @@ fn claim_for_others_positive_test() { &setup.staking_farm_wrapper, &rust_biguint!(0), |sc| { - sc.allow_external_claim_boosted_rewards(true); + sc.set_allow_external_claim(true); }, ) .assert_ok(); diff --git a/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp_staking_contract_interactions/mod.rs b/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp_staking_contract_interactions/mod.rs index 151a4f5ec..aba5f5713 100644 --- a/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp_staking_contract_interactions/mod.rs +++ b/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp_staking_contract_interactions/mod.rs @@ -1,6 +1,6 @@ #![allow(deprecated)] -use config::{ConfigModule, UserTotalFarmPosition}; +use config::ConfigModule; use energy_factory::energy::EnergyModule; use energy_query::Energy; use farm_with_locked_rewards::Farm; @@ -679,12 +679,8 @@ where &self.staking_farm_wrapper, &rust_biguint!(0), |sc| { - let user_farm_position = UserTotalFarmPosition { - total_farm_position: managed_biguint!(new_farm_position), - ..Default::default() - }; sc.user_total_farm_position(&managed_address!(user_addr)) - .set(user_farm_position); + .set(managed_biguint!(new_farm_position)); }, ) .assert_ok(); @@ -697,12 +693,8 @@ where &self.lp_farm_wrapper, &rust_biguint!(0), |sc| { - let user_farm_position = UserTotalFarmPosition { - total_farm_position: managed_biguint!(new_farm_position), - ..Default::default() - }; sc.user_total_farm_position(&managed_address!(user_addr)) - .set(user_farm_position); + .set(managed_biguint!(new_farm_position)); }, ) .assert_ok(); @@ -720,7 +712,7 @@ where if expected_amount > 0 && !user_total_farm_position_mapper.is_empty() { assert_eq!( managed_biguint!(expected_amount), - user_total_farm_position_mapper.get().total_farm_position + user_total_farm_position_mapper.get() ); } }) @@ -735,7 +727,7 @@ where if expected_amount > 0 && !user_total_farm_position_mapper.is_empty() { assert_eq!( managed_biguint!(expected_amount), - user_total_farm_position_mapper.get().total_farm_position + user_total_farm_position_mapper.get() ); } }) diff --git a/farm-staking/farm-staking/src/base_impl_wrapper.rs b/farm-staking/farm-staking/src/base_impl_wrapper.rs index 357d2f048..f2208cfde 100644 --- a/farm-staking/farm-staking/src/base_impl_wrapper.rs +++ b/farm-staking/farm-staking/src/base_impl_wrapper.rs @@ -62,12 +62,11 @@ where sc: &::FarmSc, caller: &ManagedAddress<<::FarmSc as ContractBase>::Api>, ) -> BigUint<<::FarmSc as ContractBase>::Api> { - let user_total_farm_position = sc.get_user_total_farm_position(caller); - let user_farm_position = user_total_farm_position.total_farm_position; + let user_total_farm_position = sc.user_total_farm_position(caller).get(); let mut boosted_rewards = BigUint::zero(); - if user_farm_position > 0 { - boosted_rewards = sc.claim_boosted_yields_rewards(caller, user_farm_position); + if user_total_farm_position > 0 { + boosted_rewards = sc.claim_boosted_yields_rewards(caller, user_total_farm_position); } boosted_rewards @@ -228,10 +227,8 @@ where user: &ManagedAddress<::Api>, increase_farm_position_amount: &BigUint<::Api>, ) { - let mut user_total_farm_position = sc.get_user_total_farm_position(user); - user_total_farm_position.total_farm_position += increase_farm_position_amount; sc.user_total_farm_position(user) - .set(user_total_farm_position); + .update(|total_farm_position| *total_farm_position += increase_farm_position_amount); } fn decrease_user_farm_position( @@ -246,13 +243,15 @@ where let token_attributes: StakingFarmTokenAttributes<::Api> = farm_token_mapper.get_token_attributes(farm_position.token_nonce); - sc.user_total_farm_position(&token_attributes.original_owner) - .update(|user_total_farm_position| { - if user_total_farm_position.total_farm_position > farm_position.amount { - user_total_farm_position.total_farm_position -= &farm_position.amount; - } else { - user_total_farm_position.total_farm_position = BigUint::zero(); - } - }); + let user_total_farm_position_mapper = + sc.user_total_farm_position(&token_attributes.original_owner); + let mut user_total_farm_position = user_total_farm_position_mapper.get(); + + if user_total_farm_position > farm_position.amount { + user_total_farm_position -= &farm_position.amount; + user_total_farm_position_mapper.set(user_total_farm_position); + } else { + user_total_farm_position_mapper.clear(); + } } } 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 b13ccc62d..a1843a1f6 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 @@ -31,10 +31,9 @@ pub trait ClaimOnlyBoostedStakingRewardsModule: OptionalValue::Some(user) => user, OptionalValue::None => &caller, }; - let user_total_farm_position = self.get_user_total_farm_position(user); if user != &caller { require!( - user_total_farm_position.allow_external_claim_boosted_rewards, + self.allow_external_claim(user).get(), "Cannot claim rewards for this address" ); } @@ -62,10 +61,8 @@ pub trait ClaimOnlyBoostedStakingRewardsModule: } if migrated_amount > 0 { - let mut user_total_farm_position = self.get_user_total_farm_position(caller); - user_total_farm_position.total_farm_position += &migrated_amount; self.user_total_farm_position(caller) - .set(user_total_farm_position); + .update(|total_farm_position| *total_farm_position += &migrated_amount); } migrated_amount @@ -75,10 +72,16 @@ pub trait ClaimOnlyBoostedStakingRewardsModule: if migrated_amount == BigUint::zero() { return; } - self.user_total_farm_position(caller) - .update(|user_total_farm_position| { - user_total_farm_position.total_farm_position -= migrated_amount; - }); + + let user_total_farm_position_mapper = self.user_total_farm_position(caller); + let mut user_total_farm_position = user_total_farm_position_mapper.get(); + + if user_total_farm_position > migrated_amount { + user_total_farm_position -= &migrated_amount; + user_total_farm_position_mapper.set(user_total_farm_position); + } else { + user_total_farm_position_mapper.clear(); + } } // Cannot import the one from farm, as the Wrapper struct has different dependencies 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 93d4802ea..14aa23da7 100644 --- a/farm-staking/farm-staking/src/claim_stake_farm_rewards.rs +++ b/farm-staking/farm-staking/src/claim_stake_farm_rewards.rs @@ -74,11 +74,11 @@ pub trait ClaimStakeFarmRewardsModule: claim_result.storage_cache.farm_token_supply -= &virtual_farm_token.payment.amount; claim_result.storage_cache.farm_token_supply += &new_amount; - let mut user_total_farm_position = self.get_user_total_farm_position(&original_caller); - user_total_farm_position.total_farm_position -= &virtual_farm_token.payment.amount; - user_total_farm_position.total_farm_position += &new_amount; self.user_total_farm_position(&original_caller) - .set(user_total_farm_position); + .update(|total_farm_position| { + *total_farm_position -= &virtual_farm_token.payment.amount; + *total_farm_position += &new_amount; + }); virtual_farm_token.payment.amount = new_amount.clone(); virtual_farm_token.attributes.current_farm_amount = new_amount; diff --git a/farm-staking/farm-staking/tests/farm_staking_energy_test.rs b/farm-staking/farm-staking/tests/farm_staking_energy_test.rs index facc2025f..1274be166 100644 --- a/farm-staking/farm-staking/tests/farm_staking_energy_test.rs +++ b/farm-staking/farm-staking/tests/farm_staking_energy_test.rs @@ -1050,11 +1050,8 @@ fn farm_staking_farm_position_migration_test() { 0, &rust_biguint!(10), |sc| { - let mut user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&user)); - user_total_farm_position.total_farm_position = managed_biguint!(0u64); sc.user_total_farm_position(&managed_address!(&user)) - .set(user_total_farm_position); + .set(managed_biguint!(0u64)); sc.farm_position_migration_nonce().set(5); }, 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 369b029bd..0d0cd74f4 100644 --- a/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs +++ b/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs @@ -569,7 +569,7 @@ where pub fn allow_external_claim_rewards(&mut self, user: &Address, allow_claim: bool) { self.b_mock .execute_tx(user, &self.farm_wrapper, &rust_biguint!(0), |sc| { - sc.allow_external_claim_boosted_rewards(allow_claim); + sc.set_allow_external_claim(allow_claim); }) .assert_ok(); } @@ -755,7 +755,7 @@ where if expected_amount > 0 && !user_total_farm_position_mapper.is_empty() { assert_eq!( managed_biguint!(expected_amount), - user_total_farm_position_mapper.get().total_farm_position + user_total_farm_position_mapper.get() ); } }) diff --git a/farm-staking/farm-staking/wasm/src/lib.rs b/farm-staking/farm-staking/wasm/src/lib.rs index 4842309c2..a5dfd5522 100644 --- a/farm-staking/farm-staking/wasm/src/lib.rs +++ b/farm-staking/farm-staking/wasm/src/lib.rs @@ -36,14 +36,14 @@ multiversx_sc_wasm_adapter::endpoints! { getMinUnbondEpochs => min_unbond_epochs getRewardPerShare => reward_per_share getRewardReserve => reward_reserve - allowExternalClaimBoostedRewards => allow_external_claim_boosted_rewards - getAllowExternalClaimRewards => get_allow_external_claim_rewards + setAllowExternalClaimBoostedRewards => set_allow_external_claim getFarmingTokenId => farming_token_id getRewardTokenId => reward_token_id getPerBlockRewardAmount => per_block_reward_amount getLastRewardBlockNonce => last_reward_block_nonce getDivisionSafetyConstant => division_safety_constant getUserTotalFarmPosition => user_total_farm_position + getAllowExternalClaim => allow_external_claim getFarmPositionMigrationNonce => farm_position_migration_nonce registerFarmToken => register_farm_token getFarmTokenId => farm_token diff --git a/legacy-contracts/farm-v-13/wasm/src/lib.rs b/legacy-contracts/farm-v-13/wasm/src/lib.rs index 850923617..ad5759863 100644 --- a/legacy-contracts/farm-v-13/wasm/src/lib.rs +++ b/legacy-contracts/farm-v-13/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 3 +// Endpoints: 4 // Async Callback (empty): 1 -// Total number of exported functions: 6 +// Total number of exported functions: 7 #![no_std] @@ -23,6 +23,7 @@ multiversx_sc_wasm_adapter::endpoints! { exitFarm => exit_farm calculateRewardsForGivenPosition => calculate_rewards_for_given_position end_produce_rewards => end_produce_rewards + getFarmingTokenId => farming_token_id ) } diff --git a/locked-asset/energy-factory/src/unlock_with_penalty.rs b/locked-asset/energy-factory/src/unlock_with_penalty.rs index 102565ed5..a92285128 100644 --- a/locked-asset/energy-factory/src/unlock_with_penalty.rs +++ b/locked-asset/energy-factory/src/unlock_with_penalty.rs @@ -195,3 +195,20 @@ pub trait UnlockWithPenaltyModule: token_amount * penalty_percentage_unlock / MAX_PENALTY_PERCENTAGE } } + + +// ‘4687451965350631993632991850’ +// ‘0015306081845241142641261742’ + +// { +// oldEnergyEntry: { +// amount: , +// lastUpdateEpoch: 1174, +// totalLockedTokens: ‘3253583484335230397626951’ +// }, +// newEnergyEntry: { +// amount: , +// lastUpdateEpoch: 1174, +// totalLockedTokens: ‘398’ +// } +// } diff --git a/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs b/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs index 322fedd61..73dd9d9c9 100644 --- a/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs +++ b/locked-asset/proxy_dex/tests/proxy_dex_test_setup/mod.rs @@ -1,3 +1,4 @@ +#![allow(dead_code)] #![allow(deprecated)] use common_structs::{LockedAssetTokenAttributesEx, UnlockMilestoneEx, UnlockScheduleEx}; @@ -157,7 +158,7 @@ where unlock_percent: 10_000, unlock_epoch: LOCK_OPTIONS[0], }); - + let old_token_attributes = LockedAssetTokenAttributesEx { is_merged: false, unlock_schedule: UnlockScheduleEx { unlock_milestones }, @@ -169,7 +170,6 @@ where &rust_biguint!(USER_BALANCE), &old_token_attributes, ); - // users lock tokens b_mock diff --git a/locked-asset/proxy_dex/tests/proxy_farm_test.rs b/locked-asset/proxy_dex/tests/proxy_farm_test.rs index 7f7a23b60..8e162a1e4 100644 --- a/locked-asset/proxy_dex/tests/proxy_farm_test.rs +++ b/locked-asset/proxy_dex/tests/proxy_farm_test.rs @@ -1221,12 +1221,10 @@ fn total_farm_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); - assert_eq!( - first_user_total_farm_position.total_farm_position, - managed_biguint!(0) - ); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); + assert_eq!(first_user_total_farm_position, managed_biguint!(0)); }) .assert_ok(); @@ -1250,10 +1248,11 @@ fn total_farm_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(USER_BALANCE) ); }) @@ -1280,10 +1279,11 @@ fn total_farm_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(USER_BALANCE * 2) ); }) @@ -1348,10 +1348,11 @@ fn total_farm_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(USER_BALANCE * 2) ); }) @@ -2379,12 +2380,8 @@ fn total_farm_position_migration_through_proxy_dex_test() { &setup.farm_locked_wrapper, &rust_biguint!(0), |sc| { - let mut first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); - first_user_total_farm_position.total_farm_position = managed_biguint!(0u64); - sc.user_total_farm_position(&managed_address!(&first_user)) - .set(first_user_total_farm_position); + .set(managed_biguint!(0u64)); sc.farm_position_migration_nonce().set(2u64); }, ) @@ -2393,12 +2390,10 @@ fn total_farm_position_migration_through_proxy_dex_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); - assert_eq!( - first_user_total_farm_position.total_farm_position, - managed_biguint!(0) - ); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); + assert_eq!(first_user_total_farm_position, managed_biguint!(0)); }) .assert_ok(); @@ -2420,10 +2415,11 @@ fn total_farm_position_migration_through_proxy_dex_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(USER_BALANCE) ); }) @@ -2453,10 +2449,11 @@ fn total_farm_position_migration_through_proxy_dex_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(USER_BALANCE * 2) ); }) @@ -2617,12 +2614,8 @@ fn total_farm_position_migration_mechanism_test() { &setup.farm_locked_wrapper, &rust_biguint!(0), |sc| { - let mut first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); - first_user_total_farm_position.total_farm_position = managed_biguint!(0u64); - sc.user_total_farm_position(&managed_address!(&first_user)) - .set(first_user_total_farm_position); + .set(managed_biguint!(0u64)); sc.farm_position_migration_nonce().set(6u64); }, ) @@ -2631,12 +2624,10 @@ fn total_farm_position_migration_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); - assert_eq!( - first_user_total_farm_position.total_farm_position, - managed_biguint!(0) - ); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); + assert_eq!(first_user_total_farm_position, managed_biguint!(0)); }) .assert_ok(); @@ -2665,10 +2656,11 @@ fn total_farm_position_migration_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(user_total_farm_position) ); }) @@ -2694,10 +2686,11 @@ fn total_farm_position_migration_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(user_total_farm_position) ); }) @@ -2722,10 +2715,11 @@ fn total_farm_position_migration_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(user_total_farm_position) ); }) @@ -2757,10 +2751,11 @@ fn total_farm_position_migration_mechanism_test() { setup .b_mock .execute_query(&setup.farm_locked_wrapper, |sc| { - let first_user_total_farm_position = - sc.get_user_total_farm_position(&managed_address!(&first_user)); + let first_user_total_farm_position = sc + .user_total_farm_position(&managed_address!(&first_user)) + .get(); assert_eq!( - first_user_total_farm_position.total_farm_position, + first_user_total_farm_position, managed_biguint!(user_total_farm_position) ); }) From 8fedc8fd81e3a539d1cf206e213a0de6b9612d5d Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Thu, 11 Jul 2024 16:09:31 +0300 Subject: [PATCH 2/5] clippy fix --- dex/farm/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dex/farm/src/lib.rs b/dex/farm/src/lib.rs index 0987dbbce..08d447830 100644 --- a/dex/farm/src/lib.rs +++ b/dex/farm/src/lib.rs @@ -223,7 +223,7 @@ pub trait Farm: }; if user != &caller { require!( - self.allow_external_claim(&user).get(), + self.allow_external_claim(user).get(), "Cannot claim rewards for this address" ); } From 81b6253f4bd8fbc901da79c5935d184d3aeee410 Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Fri, 12 Jul 2024 10:51:14 +0300 Subject: [PATCH 3/5] remove comments --- .../energy-factory/src/unlock_with_penalty.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/locked-asset/energy-factory/src/unlock_with_penalty.rs b/locked-asset/energy-factory/src/unlock_with_penalty.rs index a92285128..102565ed5 100644 --- a/locked-asset/energy-factory/src/unlock_with_penalty.rs +++ b/locked-asset/energy-factory/src/unlock_with_penalty.rs @@ -195,20 +195,3 @@ pub trait UnlockWithPenaltyModule: token_amount * penalty_percentage_unlock / MAX_PENALTY_PERCENTAGE } } - - -// ‘4687451965350631993632991850’ -// ‘0015306081845241142641261742’ - -// { -// oldEnergyEntry: { -// amount: , -// lastUpdateEpoch: 1174, -// totalLockedTokens: ‘3253583484335230397626951’ -// }, -// newEnergyEntry: { -// amount: , -// lastUpdateEpoch: 1174, -// totalLockedTokens: ‘398’ -// } -// } From 4e5e21cde3601d0ba1a0792d35920952b9334bf1 Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Wed, 17 Jul 2024 12:18:47 +0300 Subject: [PATCH 4/5] remove setAllowExternalClaim --- common/modules/farm/config/src/config.rs | 11 ++++++----- dex/farm-with-locked-rewards/wasm/src/lib.rs | 5 ++--- dex/farm/wasm/src/lib.rs | 5 ++--- energy-integration/fees-collector/src/config.rs | 13 +++++++------ energy-integration/fees-collector/wasm/src/lib.rs | 5 ++--- .../tests/staking_farm_with_lp.rs | 6 ++++-- .../farm-staking/tests/farm_staking_setup/mod.rs | 3 ++- farm-staking/farm-staking/wasm/src/lib.rs | 5 ++--- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/common/modules/farm/config/src/config.rs b/common/modules/farm/config/src/config.rs index 1f26eed6a..46564e5c0 100644 --- a/common/modules/farm/config/src/config.rs +++ b/common/modules/farm/config/src/config.rs @@ -11,11 +11,12 @@ pub const DEFAULT_FARM_POSITION_MIGRATION_NONCE: u64 = 1; #[multiversx_sc::module] pub trait ConfigModule: pausable::PausableModule + permissions_module::PermissionsModule { - #[endpoint(setAllowExternalClaimBoostedRewards)] - fn set_allow_external_claim(&self, allow_external_claim: bool) { - let caller = self.blockchain().get_caller(); - self.allow_external_claim(&caller).set(allow_external_claim); - } + // Disabled for this version of the exchange + // #[endpoint(setAllowExternalClaimBoostedRewards)] + // fn set_allow_external_claim(&self, allow_external_claim: bool) { + // let caller = self.blockchain().get_caller(); + // self.allow_external_claim(&caller).set(allow_external_claim); + // } #[inline] fn is_active(&self) -> bool { diff --git a/dex/farm-with-locked-rewards/wasm/src/lib.rs b/dex/farm-with-locked-rewards/wasm/src/lib.rs index 9efe33713..e8aa3099f 100644 --- a/dex/farm-with-locked-rewards/wasm/src/lib.rs +++ b/dex/farm-with-locked-rewards/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 67 +// Endpoints: 66 // Async Callback: 1 -// Total number of exported functions: 70 +// Total number of exported functions: 69 #![no_std] @@ -32,7 +32,6 @@ multiversx_sc_wasm_adapter::endpoints! { calculateRewardsForGivenPosition => calculate_rewards_for_given_position getRewardPerShare => reward_per_share getRewardReserve => reward_reserve - setAllowExternalClaimBoostedRewards => set_allow_external_claim getFarmingTokenId => farming_token_id getRewardTokenId => reward_token_id getPerBlockRewardAmount => per_block_reward_amount diff --git a/dex/farm/wasm/src/lib.rs b/dex/farm/wasm/src/lib.rs index a4b92d26e..525d76239 100644 --- a/dex/farm/wasm/src/lib.rs +++ b/dex/farm/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 64 +// Endpoints: 63 // Async Callback: 1 -// Total number of exported functions: 67 +// Total number of exported functions: 66 #![no_std] @@ -33,7 +33,6 @@ multiversx_sc_wasm_adapter::endpoints! { calculateRewardsForGivenPosition => calculate_rewards_for_given_position getRewardPerShare => reward_per_share getRewardReserve => reward_reserve - setAllowExternalClaimBoostedRewards => set_allow_external_claim getFarmingTokenId => farming_token_id getRewardTokenId => reward_token_id getPerBlockRewardAmount => per_block_reward_amount diff --git a/energy-integration/fees-collector/src/config.rs b/energy-integration/fees-collector/src/config.rs index a21dc6d6b..e65282d17 100644 --- a/energy-integration/fees-collector/src/config.rs +++ b/energy-integration/fees-collector/src/config.rs @@ -60,12 +60,13 @@ pub trait ConfigModule { self.all_tokens().set(&all_tokens_vec); } - #[endpoint(setAllowExternalClaimRewards)] - fn set_allow_external_claim_rewards(&self, allow_external_claim_rewards: bool) { - let caller = self.blockchain().get_caller(); - self.allow_external_claim_rewards(&caller) - .set(allow_external_claim_rewards); - } + // Disabled for this version of the exchange + // #[endpoint(setAllowExternalClaimRewards)] + // fn set_allow_external_claim_rewards(&self, allow_external_claim_rewards: bool) { + // let caller = self.blockchain().get_caller(); + // self.allow_external_claim_rewards(&caller) + // .set(allow_external_claim_rewards); + // } #[view(getLockedTokenId)] #[storage_mapper("lockedTokenId")] diff --git a/energy-integration/fees-collector/wasm/src/lib.rs b/energy-integration/fees-collector/wasm/src/lib.rs index 283f21a67..77034bd4a 100644 --- a/energy-integration/fees-collector/wasm/src/lib.rs +++ b/energy-integration/fees-collector/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 38 +// Endpoints: 37 // Async Callback (empty): 1 -// Total number of exported functions: 41 +// Total number of exported functions: 40 #![no_std] @@ -26,7 +26,6 @@ multiversx_sc_wasm_adapter::endpoints! { removeKnownContracts => remove_known_contracts addKnownTokens => add_known_tokens removeKnownTokens => remove_known_tokens - setAllowExternalClaimRewards => set_allow_external_claim_rewards getLockedTokenId => locked_token_id getAllTokens => get_all_tokens getAllKnownContracts => known_contracts diff --git a/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs b/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs index 1321443ee..50b62cb93 100644 --- a/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs +++ b/farm-staking/farm-staking-proxy/tests/staking_farm_with_lp.rs @@ -773,7 +773,8 @@ fn claim_for_others_positive_test() { &setup.lp_farm_wrapper, &rust_biguint!(0), |sc| { - sc.set_allow_external_claim(true); + sc.allow_external_claim(&managed_address!(&user_address)) + .set(true); }, ) .assert_ok(); @@ -785,7 +786,8 @@ fn claim_for_others_positive_test() { &setup.staking_farm_wrapper, &rust_biguint!(0), |sc| { - sc.set_allow_external_claim(true); + sc.allow_external_claim(&managed_address!(&user_address)) + .set(true); }, ) .assert_ok(); 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 0d0cd74f4..90513e2d6 100644 --- a/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs +++ b/farm-staking/farm-staking/tests/farm_staking_setup/mod.rs @@ -569,7 +569,8 @@ where pub fn allow_external_claim_rewards(&mut self, user: &Address, allow_claim: bool) { self.b_mock .execute_tx(user, &self.farm_wrapper, &rust_biguint!(0), |sc| { - sc.set_allow_external_claim(allow_claim); + sc.allow_external_claim(&managed_address!(user)) + .set(allow_claim); }) .assert_ok(); } diff --git a/farm-staking/farm-staking/wasm/src/lib.rs b/farm-staking/farm-staking/wasm/src/lib.rs index a5dfd5522..9489b1d7e 100644 --- a/farm-staking/farm-staking/wasm/src/lib.rs +++ b/farm-staking/farm-staking/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 70 +// Endpoints: 69 // Async Callback: 1 -// Total number of exported functions: 73 +// Total number of exported functions: 72 #![no_std] @@ -36,7 +36,6 @@ multiversx_sc_wasm_adapter::endpoints! { getMinUnbondEpochs => min_unbond_epochs getRewardPerShare => reward_per_share getRewardReserve => reward_reserve - setAllowExternalClaimBoostedRewards => set_allow_external_claim getFarmingTokenId => farming_token_id getRewardTokenId => reward_token_id getPerBlockRewardAmount => per_block_reward_amount From 04782742190a035e577440cc1122279365b7fe5e Mon Sep 17 00:00:00 2001 From: Sorin Petreasca Date: Wed, 31 Jul 2024 13:54:40 +0300 Subject: [PATCH 5/5] remove commented code --- common/modules/farm/config/src/config.rs | 8 +------- energy-integration/fees-collector/src/config.rs | 9 +-------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/common/modules/farm/config/src/config.rs b/common/modules/farm/config/src/config.rs index 46564e5c0..88858153e 100644 --- a/common/modules/farm/config/src/config.rs +++ b/common/modules/farm/config/src/config.rs @@ -11,13 +11,6 @@ pub const DEFAULT_FARM_POSITION_MIGRATION_NONCE: u64 = 1; #[multiversx_sc::module] pub trait ConfigModule: pausable::PausableModule + permissions_module::PermissionsModule { - // Disabled for this version of the exchange - // #[endpoint(setAllowExternalClaimBoostedRewards)] - // fn set_allow_external_claim(&self, allow_external_claim: bool) { - // let caller = self.blockchain().get_caller(); - // self.allow_external_claim(&caller).set(allow_external_claim); - // } - #[inline] fn is_active(&self) -> bool { let state = self.state().get(); @@ -78,6 +71,7 @@ pub trait ConfigModule: pausable::PausableModule + permissions_module::Permissio #[storage_mapper("userTotalFarmPosition")] fn user_total_farm_position(&self, user: &ManagedAddress) -> SingleValueMapper; + // Update for this storage disabled for this version of the exchange #[view(getAllowExternalClaim)] #[storage_mapper("allowExternalClaim")] fn allow_external_claim(&self, user: &ManagedAddress) -> SingleValueMapper; diff --git a/energy-integration/fees-collector/src/config.rs b/energy-integration/fees-collector/src/config.rs index e65282d17..72fa1fc70 100644 --- a/energy-integration/fees-collector/src/config.rs +++ b/energy-integration/fees-collector/src/config.rs @@ -60,14 +60,6 @@ pub trait ConfigModule { self.all_tokens().set(&all_tokens_vec); } - // Disabled for this version of the exchange - // #[endpoint(setAllowExternalClaimRewards)] - // fn set_allow_external_claim_rewards(&self, allow_external_claim_rewards: bool) { - // let caller = self.blockchain().get_caller(); - // self.allow_external_claim_rewards(&caller) - // .set(allow_external_claim_rewards); - // } - #[view(getLockedTokenId)] #[storage_mapper("lockedTokenId")] fn locked_token_id(&self) -> SingleValueMapper; @@ -87,6 +79,7 @@ pub trait ConfigModule { #[storage_mapper("allTokens")] fn all_tokens(&self) -> SingleValueMapper>; + // Update for this storage disabled for this version of the exchange #[view(getAllowExternalClaimRewards)] #[storage_mapper("allowExternalClaimRewards")] fn allow_external_claim_rewards(&self, user: &ManagedAddress) -> SingleValueMapper;