From a4fe8ad3b2773022f8c2b50e41e6f693257dcfd4 Mon Sep 17 00:00:00 2001 From: Dorin Marian Iancu Date: Tue, 20 Feb 2024 12:52:31 +0200 Subject: [PATCH] more migration remove --- common/modules/farm/config/src/config.rs | 26 ------------------------ dex/farm-concentrated-liq/src/lib.rs | 6 +----- dex/farm-with-locked-rewards/src/lib.rs | 18 +++++----------- dex/farm/src/lib.rs | 18 +++++----------- farm-staking/farm-staking/src/lib.rs | 16 ++++----------- 5 files changed, 15 insertions(+), 69 deletions(-) diff --git a/common/modules/farm/config/src/config.rs b/common/modules/farm/config/src/config.rs index a5a3a3ce6..eb13c27c0 100644 --- a/common/modules/farm/config/src/config.rs +++ b/common/modules/farm/config/src/config.rs @@ -69,28 +69,6 @@ pub trait ConfigModule: pausable::PausableModule + permissions_module::Permissio } } - fn try_set_farm_position_migration_nonce( - &self, - farm_token_mapper: NonFungibleTokenMapper, - ) { - if !self.farm_position_migration_nonce().is_empty() { - return; - } - - let migration_farm_token_nonce = if farm_token_mapper.get_token_state().is_set() { - let token_identifier = farm_token_mapper.get_token_id_ref(); - let current_nonce = self - .blockchain() - .get_current_esdt_nft_nonce(&self.blockchain().get_sc_address(), token_identifier); - current_nonce + DEFAULT_FARM_POSITION_MIGRATION_NONCE - } else { - DEFAULT_FARM_POSITION_MIGRATION_NONCE - }; - - self.farm_position_migration_nonce() - .set(migration_farm_token_nonce); - } - #[view(getFarmingTokenId)] #[storage_mapper("farming_token_id")] fn farming_token_id(&self) -> SingleValueMapper; @@ -120,8 +98,4 @@ pub trait ConfigModule: pausable::PausableModule + permissions_module::Permissio &self, user: &ManagedAddress, ) -> SingleValueMapper>; - - #[view(getFarmPositionMigrationNonce)] - #[storage_mapper("farm_position_migration_nonce")] - fn farm_position_migration_nonce(&self) -> SingleValueMapper; } diff --git a/dex/farm-concentrated-liq/src/lib.rs b/dex/farm-concentrated-liq/src/lib.rs index 9492b9fa0..9da99566d 100644 --- a/dex/farm-concentrated-liq/src/lib.rs +++ b/dex/farm-concentrated-liq/src/lib.rs @@ -79,11 +79,7 @@ pub trait Farm: } #[endpoint] - fn upgrade(&self) { - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); - } + fn upgrade(&self) {} #[payable("*")] #[endpoint(enterFarm)] diff --git a/dex/farm-with-locked-rewards/src/lib.rs b/dex/farm-with-locked-rewards/src/lib.rs index 23b3bc130..0597f9b90 100644 --- a/dex/farm-with-locked-rewards/src/lib.rs +++ b/dex/farm-with-locked-rewards/src/lib.rs @@ -67,26 +67,18 @@ pub trait Farm: admins, ); - self.penalty_percent().set_if_empty(DEFAULT_PENALTY_PERCENT); + self.penalty_percent().set(DEFAULT_PENALTY_PERCENT); self.minimum_farming_epochs() - .set_if_empty(DEFAULT_MINUMUM_FARMING_EPOCHS); - self.burn_gas_limit().set_if_empty(DEFAULT_BURN_GAS_LIMIT); + .set(DEFAULT_MINUMUM_FARMING_EPOCHS); + self.burn_gas_limit().set(DEFAULT_BURN_GAS_LIMIT); self.pair_contract_address().set(&pair_contract_address); let current_epoch = self.blockchain().get_block_epoch(); - self.first_week_start_epoch().set_if_empty(current_epoch); - - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); + self.first_week_start_epoch().set(current_epoch); } #[endpoint] - fn upgrade(&self) { - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); - } + fn upgrade(&self) {} #[payable("*")] #[endpoint(enterFarm)] diff --git a/dex/farm/src/lib.rs b/dex/farm/src/lib.rs index 91933f140..9da99566d 100644 --- a/dex/farm/src/lib.rs +++ b/dex/farm/src/lib.rs @@ -68,26 +68,18 @@ pub trait Farm: admins, ); - self.penalty_percent().set_if_empty(DEFAULT_PENALTY_PERCENT); + self.penalty_percent().set(DEFAULT_PENALTY_PERCENT); self.minimum_farming_epochs() - .set_if_empty(DEFAULT_MINUMUM_FARMING_EPOCHS); - self.burn_gas_limit().set_if_empty(DEFAULT_BURN_GAS_LIMIT); + .set(DEFAULT_MINUMUM_FARMING_EPOCHS); + self.burn_gas_limit().set(DEFAULT_BURN_GAS_LIMIT); self.pair_contract_address().set(&pair_contract_address); let current_epoch = self.blockchain().get_block_epoch(); - self.first_week_start_epoch().set_if_empty(current_epoch); - - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); + self.first_week_start_epoch().set(current_epoch); } #[endpoint] - fn upgrade(&self) { - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); - } + fn upgrade(&self) {} #[payable("*")] #[endpoint(enterFarm)] diff --git a/farm-staking/farm-staking/src/lib.rs b/farm-staking/farm-staking/src/lib.rs index 301cc3eb9..10485cbd7 100644 --- a/farm-staking/farm-staking/src/lib.rs +++ b/farm-staking/farm-staking/src/lib.rs @@ -81,25 +81,17 @@ pub trait FarmStaking: ); require!(max_apr > 0u64, "Invalid max APR percentage"); - self.max_annual_percentage_rewards().set_if_empty(&max_apr); + self.max_annual_percentage_rewards().set(&max_apr); require!( min_unbond_epochs <= MAX_MIN_UNBOND_EPOCHS, "Invalid min unbond epochs" ); - self.min_unbond_epochs().set_if_empty(min_unbond_epochs); - - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); + self.min_unbond_epochs().set(min_unbond_epochs); } #[endpoint] - fn upgrade(&self) { - // Farm position migration code - let farm_token_mapper = self.farm_token(); - self.try_set_farm_position_migration_nonce(farm_token_mapper); - } + fn upgrade(&self) {} #[payable("*")] #[endpoint(mergeFarmTokens)] @@ -121,7 +113,7 @@ pub trait FarmStaking: (merged_farm_token, boosted_rewards_payment).into() } - + #[view(calculateRewardsForGivenPosition)] fn calculate_rewards_for_given_position( &self,