From 042c7f14b3c02f804f5a29283aa1e7de368a1659 Mon Sep 17 00:00:00 2001 From: Dorin Marian Iancu Date: Tue, 20 Feb 2024 12:14:00 +0200 Subject: [PATCH] farm concentrated liq - copy farm --- Cargo.lock | 41 ++ Cargo.toml | 2 + dex/farm-concentrated-liq/Cargo.toml | 91 +++ dex/farm-concentrated-liq/meta/Cargo.toml | 13 + dex/farm-concentrated-liq/meta/src/main.rs | 3 + dex/farm-concentrated-liq/multiversx.json | 3 + .../src/base_functions.rs | 370 ++++++++++++ dex/farm-concentrated-liq/src/exit_penalty.rs | 75 +++ dex/farm-concentrated-liq/src/lib.rs | 265 +++++++++ dex/farm-concentrated-liq/wasm/Cargo.lock | 538 ++++++++++++++++++ dex/farm-concentrated-liq/wasm/Cargo.toml | 31 + dex/farm-concentrated-liq/wasm/src/lib.rs | 91 +++ 12 files changed, 1523 insertions(+) create mode 100644 dex/farm-concentrated-liq/Cargo.toml create mode 100644 dex/farm-concentrated-liq/meta/Cargo.toml create mode 100644 dex/farm-concentrated-liq/meta/src/main.rs create mode 100644 dex/farm-concentrated-liq/multiversx.json create mode 100644 dex/farm-concentrated-liq/src/base_functions.rs create mode 100644 dex/farm-concentrated-liq/src/exit_penalty.rs create mode 100644 dex/farm-concentrated-liq/src/lib.rs create mode 100644 dex/farm-concentrated-liq/wasm/Cargo.lock create mode 100644 dex/farm-concentrated-liq/wasm/Cargo.toml create mode 100644 dex/farm-concentrated-liq/wasm/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index fe863b981..dc1da0bf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -777,6 +777,47 @@ dependencies = [ "weekly-rewards-splitting", ] +[[package]] +name = "farm-concentrated-liq" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "energy-factory-mock", + "energy-query", + "energy-update", + "events", + "farm-boosted-yields", + "farm_base_impl", + "farm_token", + "fixed-supply-token", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "pair", + "pausable", + "permissions_module", + "rewards", + "sc_whitelist_module", + "simple-lock", + "token_send", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-concentrated-liq-abi" +version = "0.0.0" +dependencies = [ + "farm-concentrated-liq", + "multiversx-sc-meta", +] + [[package]] name = "farm-staking" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index dbdd0d3ec..fc023520e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,8 @@ members = [ "dex", "dex/farm", "dex/farm/meta", + "dex/farm-concentrated-liq", + "dex/farm-concentrated-liq/meta", "dex/farm-with-locked-rewards", "dex/farm-with-locked-rewards/meta", "dex/pair", diff --git a/dex/farm-concentrated-liq/Cargo.toml b/dex/farm-concentrated-liq/Cargo.toml new file mode 100644 index 000000000..8a73b96fa --- /dev/null +++ b/dex/farm-concentrated-liq/Cargo.toml @@ -0,0 +1,91 @@ +[package] +name = "farm-concentrated-liq" +version = "0.0.0" +authors = ["MultiversX "] +edition = "2021" +publish = false + +[lib] +path = "src/lib.rs" + +[dependencies.farm_base_impl] +path = "../../common/modules/farm/farm_base_impl" + +[dependencies.config] +path = "../../common/modules/farm/config" + +[dependencies.farm_token] +path = "../../common/modules/farm/farm_token" + +[dependencies.rewards] +path = "../../common/modules/farm/rewards" + +[dependencies.events] +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" + +[dependencies.pausable] +path = "../../common/modules/pausable" + +[dependencies.permissions_module] +path = "../../common/modules/permissions_module" + +[dependencies.sc_whitelist_module] +path = "../../common/modules/sc_whitelist_module" + +[dependencies.pair] +path = "../pair" + +[dependencies.common_structs] +path = "../../common/common_structs" + +[dependencies.common_errors] +path = "../../common/common_errors" + +[dependencies.mergeable] +path = "../../common/traits/mergeable" + +[dependencies.fixed-supply-token] +path = "../../common/traits/fixed-supply-token" + +[dependencies.farm-boosted-yields] +path = "../../energy-integration/farm-boosted-yields" + +[dependencies.week-timekeeping] +path = "../../energy-integration/common-modules/week-timekeeping" + +[dependencies.weekly-rewards-splitting] +path = "../../energy-integration/common-modules/weekly-rewards-splitting" + +[dependencies.energy-query] +path = "../../energy-integration/common-modules/energy-query" + +[dependencies.multiversx-sc] +version = "=0.46.1" +features = ["esdt-token-payment-legacy-decode"] + +[dependencies.multiversx-sc-modules] +version = "=0.46.1" + +[dev-dependencies] +num-bigint = "0.4.2" + +[dev-dependencies.energy-update] +path = "../../energy-integration/energy-update" + +[dev-dependencies.multiversx-sc-scenario] +version = "=0.46.1" + +[dev-dependencies.energy-factory-mock] +path = "../../energy-integration/energy-factory-mock" + +[dev-dependencies.simple-lock] +path = "../../locked-asset/simple-lock" diff --git a/dex/farm-concentrated-liq/meta/Cargo.toml b/dex/farm-concentrated-liq/meta/Cargo.toml new file mode 100644 index 000000000..526fdda08 --- /dev/null +++ b/dex/farm-concentrated-liq/meta/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "farm-concentrated-liq-abi" +version = "0.0.0" +authors = ["MultiversX "] +edition = "2021" +publish = false + +[dependencies.farm-concentrated-liq] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.46.1" +default-features = false diff --git a/dex/farm-concentrated-liq/meta/src/main.rs b/dex/farm-concentrated-liq/meta/src/main.rs new file mode 100644 index 000000000..731b7cad7 --- /dev/null +++ b/dex/farm-concentrated-liq/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/dex/farm-concentrated-liq/multiversx.json b/dex/farm-concentrated-liq/multiversx.json new file mode 100644 index 000000000..736553962 --- /dev/null +++ b/dex/farm-concentrated-liq/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/dex/farm-concentrated-liq/src/base_functions.rs b/dex/farm-concentrated-liq/src/base_functions.rs new file mode 100644 index 000000000..968e3381d --- /dev/null +++ b/dex/farm-concentrated-liq/src/base_functions.rs @@ -0,0 +1,370 @@ +#![allow(clippy::too_many_arguments)] +#![allow(clippy::from_over_into)] + +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +use core::marker::PhantomData; + +use common_errors::ERROR_ZERO_AMOUNT; +use common_structs::FarmTokenAttributes; +use contexts::storage_cache::StorageCache; + +use farm_base_impl::base_traits_impl::{DefaultFarmWrapper, FarmContract}; +use fixed_supply_token::FixedSupplyToken; + +use crate::exit_penalty; + +pub type DoubleMultiPayment = MultiValue2, EsdtTokenPayment>; +pub type ClaimRewardsResultType = DoubleMultiPayment; +pub type ExitFarmResultType = DoubleMultiPayment; + +pub const DEFAULT_FARM_POSITION_MIGRATION_NONCE: u64 = 1; + +pub struct ClaimRewardsResultWrapper { + pub new_farm_token: EsdtTokenPayment, + pub rewards: EsdtTokenPayment, +} + +pub struct ExitFarmResultWrapper { + pub farming_tokens: EsdtTokenPayment, + pub rewards: EsdtTokenPayment, +} + +impl Into> for ClaimRewardsResultWrapper { + fn into(self) -> ClaimRewardsResultType { + (self.new_farm_token, self.rewards).into() + } +} + +impl Into> for ExitFarmResultWrapper { + fn into(self) -> ExitFarmResultType { + (self.farming_tokens, self.rewards).into() + } +} + +#[multiversx_sc::module] +pub trait BaseFunctionsModule: + rewards::RewardsModule + + config::ConfigModule + + token_send::TokenSendModule + + farm_token::FarmTokenModule + + pausable::PausableModule + + permissions_module::PermissionsModule + + events::EventsModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + exit_penalty::ExitPenaltyModule + + farm_base_impl::base_farm_init::BaseFarmInitModule + + farm_base_impl::base_farm_validation::BaseFarmValidationModule + + farm_base_impl::enter_farm::BaseEnterFarmModule + + farm_base_impl::claim_rewards::BaseClaimRewardsModule + + farm_base_impl::compound_rewards::BaseCompoundRewardsModule + + farm_base_impl::exit_farm::BaseExitFarmModule + + utils::UtilsModule + + farm_boosted_yields::FarmBoostedYieldsModule + + farm_boosted_yields::boosted_yields_factors::BoostedYieldsFactorsModule + + week_timekeeping::WeekTimekeepingModule + + weekly_rewards_splitting::WeeklyRewardsSplittingModule + + weekly_rewards_splitting::events::WeeklyRewardsSplittingEventsModule + + weekly_rewards_splitting::global_info::WeeklyRewardsGlobalInfo + + weekly_rewards_splitting::locked_token_buckets::WeeklyRewardsLockedTokenBucketsModule + + weekly_rewards_splitting::update_claim_progress_energy::UpdateClaimProgressEnergyModule + + energy_query::EnergyQueryModule +{ + fn enter_farm>( + &self, + caller: ManagedAddress, + ) -> EsdtTokenPayment { + let payments = self.call_value().all_esdt_transfers().clone_value(); + let base_enter_farm_result = self.enter_farm_base::(caller.clone(), payments); + + self.set_farm_supply_for_current_week( + &base_enter_farm_result.storage_cache.farm_token_supply, + ); + + self.emit_enter_farm_event( + &caller, + base_enter_farm_result.context.farming_token_payment, + base_enter_farm_result.new_farm_token.clone(), + base_enter_farm_result.created_with_merge, + base_enter_farm_result.storage_cache, + ); + + base_enter_farm_result.new_farm_token.payment + } + + fn claim_rewards>( + &self, + caller: ManagedAddress, + ) -> ClaimRewardsResultWrapper { + let payments = self.call_value().all_esdt_transfers().clone_value(); + let base_claim_rewards_result = self.claim_rewards_base::(caller.clone(), payments); + + let output_farm_token_payment = base_claim_rewards_result.new_farm_token.payment.clone(); + let rewards_payment = base_claim_rewards_result.rewards; + + self.set_farm_supply_for_current_week( + &base_claim_rewards_result.storage_cache.farm_token_supply, + ); + + self.emit_claim_rewards_event( + &caller, + base_claim_rewards_result.context, + base_claim_rewards_result.new_farm_token, + rewards_payment.clone(), + base_claim_rewards_result.created_with_merge, + base_claim_rewards_result.storage_cache, + ); + + ClaimRewardsResultWrapper { + new_farm_token: output_farm_token_payment, + rewards: rewards_payment, + } + } + + fn compound_rewards>( + &self, + caller: ManagedAddress, + ) -> EsdtTokenPayment { + let payments = self.call_value().all_esdt_transfers().clone_value(); + let base_compound_rewards_result = + self.compound_rewards_base::(caller.clone(), payments); + + let output_farm_token_payment = base_compound_rewards_result.new_farm_token.payment.clone(); + + self.set_farm_supply_for_current_week( + &base_compound_rewards_result.storage_cache.farm_token_supply, + ); + + self.emit_compound_rewards_event( + &caller, + base_compound_rewards_result.context, + base_compound_rewards_result.new_farm_token, + base_compound_rewards_result.compounded_rewards, + base_compound_rewards_result.created_with_merge, + base_compound_rewards_result.storage_cache, + ); + + output_farm_token_payment + } + + fn exit_farm>( + &self, + caller: ManagedAddress, + payment: EsdtTokenPayment, + ) -> ExitFarmResultWrapper { + let base_exit_farm_result = self.exit_farm_base::(caller.clone(), payment); + + let mut farming_token_payment = base_exit_farm_result.farming_token_payment; + let reward_payment = base_exit_farm_result.reward_payment; + + self.set_farm_supply_for_current_week( + &base_exit_farm_result.storage_cache.farm_token_supply, + ); + + FC::apply_penalty( + self, + &mut farming_token_payment.amount, + &base_exit_farm_result.context.farm_token.attributes, + &base_exit_farm_result.storage_cache, + ); + + self.emit_exit_farm_event( + &caller, + base_exit_farm_result.context, + farming_token_payment.clone(), + reward_payment.clone(), + base_exit_farm_result.storage_cache, + ); + + ExitFarmResultWrapper { + farming_tokens: farming_token_payment, + rewards: reward_payment, + } + } + + fn merge_farm_tokens>(&self) -> EsdtTokenPayment { + let payments = self.get_non_empty_payments(); + let token_mapper = self.farm_token(); + token_mapper.require_all_same_token(&payments); + + let caller = self.blockchain().get_caller(); + FC::check_and_update_user_farm_position(self, &caller, &payments); + + let output_attributes: FC::AttributesType = + self.merge_from_payments_and_burn(payments, &token_mapper); + let new_token_amount = output_attributes.get_total_supply(); + token_mapper.nft_create(new_token_amount, &output_attributes) + } + + fn claim_only_boosted_payment(&self, caller: &ManagedAddress) -> BigUint { + let reward = Wrapper::::calculate_boosted_rewards(self, caller); + if reward > 0 { + self.reward_reserve().update(|reserve| *reserve -= &reward); + } + + reward + } + + fn migrate_old_farm_positions(&self, caller: &ManagedAddress) -> BigUint { + let payments = self.get_non_empty_payments(); + let farm_token_mapper = self.farm_token(); + let farm_token_id = farm_token_mapper.get_token_id(); + let mut migrated_amount = BigUint::zero(); + for farm_position in &payments { + if farm_position.token_identifier == farm_token_id + && self.is_old_farm_position(farm_position.token_nonce) + { + migrated_amount += farm_position.amount; + } + } + + 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); + } + + migrated_amount + } + + fn decrease_old_farm_positions(&self, migrated_amount: BigUint, caller: &ManagedAddress) { + 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; + }); + } + + fn end_produce_rewards>(&self) { + let mut storage = StorageCache::new(self); + FC::generate_aggregated_rewards(self, &mut storage); + + self.produce_rewards_enabled().set(false); + } + + fn set_per_block_rewards>(&self, per_block_amount: BigUint) { + require!(per_block_amount != 0u64, ERROR_ZERO_AMOUNT); + + let mut storage = StorageCache::new(self); + FC::generate_aggregated_rewards(self, &mut storage); + + self.per_block_reward_amount().set(&per_block_amount); + } + + fn require_queried(&self) { + let caller = self.blockchain().get_caller(); + let sc_address = self.blockchain().get_sc_address(); + require!( + caller == sc_address, + "May only call this function through VM query" + ); + } +} + +pub struct Wrapper< + T: BaseFunctionsModule + + farm_boosted_yields::FarmBoostedYieldsModule + + crate::exit_penalty::ExitPenaltyModule, +> { + _phantom: PhantomData, +} + +impl Wrapper +where + T: BaseFunctionsModule + + farm_boosted_yields::FarmBoostedYieldsModule + + crate::exit_penalty::ExitPenaltyModule, +{ + pub fn calculate_boosted_rewards( + 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; + + sc.claim_boosted_yields_rewards(caller, user_farm_position) + } +} + +impl FarmContract for Wrapper +where + T: BaseFunctionsModule + + farm_boosted_yields::FarmBoostedYieldsModule + + crate::exit_penalty::ExitPenaltyModule, +{ + type FarmSc = T; + type AttributesType = FarmTokenAttributes<::Api>; + + fn generate_aggregated_rewards( + sc: &Self::FarmSc, + storage_cache: &mut StorageCache, + ) { + let total_reward = Self::mint_per_block_rewards(sc, &storage_cache.reward_token_id); + if total_reward > 0u64 { + storage_cache.reward_reserve += &total_reward; + let split_rewards = sc.take_reward_slice(total_reward); + + if storage_cache.farm_token_supply != 0u64 { + let increase = (&split_rewards.base_farm * &storage_cache.division_safety_constant) + / &storage_cache.farm_token_supply; + storage_cache.reward_per_share += &increase; + } + } + } + + fn calculate_rewards( + sc: &Self::FarmSc, + caller: &ManagedAddress<::Api>, + farm_token_amount: &BigUint<::Api>, + token_attributes: &Self::AttributesType, + storage_cache: &StorageCache, + ) -> BigUint<::Api> { + let base_farm_reward = DefaultFarmWrapper::::calculate_rewards( + sc, + caller, + farm_token_amount, + token_attributes, + storage_cache, + ); + let boosted_yield_rewards = Self::calculate_boosted_rewards(sc, caller); + + base_farm_reward + boosted_yield_rewards + } + + fn get_exit_penalty( + sc: &Self::FarmSc, + total_exit_amount: &BigUint<::Api>, + token_attributes: &Self::AttributesType, + ) -> BigUint<::Api> { + let current_epoch = sc.blockchain().get_block_epoch(); + let user_farming_epochs = current_epoch - token_attributes.entering_epoch; + let min_farming_epochs = sc.minimum_farming_epochs().get(); + if user_farming_epochs >= min_farming_epochs { + BigUint::zero() + } else { + total_exit_amount * sc.penalty_percent().get() / exit_penalty::MAX_PERCENT + } + } + + fn apply_penalty( + sc: &Self::FarmSc, + total_exit_amount: &mut BigUint<::Api>, + token_attributes: &Self::AttributesType, + storage_cache: &StorageCache, + ) { + let penalty_amount = Self::get_exit_penalty(sc, total_exit_amount, token_attributes); + if penalty_amount > 0 { + *total_exit_amount -= &penalty_amount; + + sc.burn_farming_tokens( + &penalty_amount, + &storage_cache.farming_token_id, + &storage_cache.reward_token_id, + ); + } + } +} diff --git a/dex/farm-concentrated-liq/src/exit_penalty.rs b/dex/farm-concentrated-liq/src/exit_penalty.rs new file mode 100644 index 000000000..e8905fade --- /dev/null +++ b/dex/farm-concentrated-liq/src/exit_penalty.rs @@ -0,0 +1,75 @@ +multiversx_sc::imports!(); + +use common_errors::ERROR_PARAMETERS; +use common_structs::Epoch; +use pair::pair_actions::remove_liq::ProxyTrait as _; + +pub const MAX_PERCENT: u64 = 10_000; +pub const DEFAULT_PENALTY_PERCENT: u64 = 100; +pub const DEFAULT_MINUMUM_FARMING_EPOCHS: u64 = 3; +pub const DEFAULT_BURN_GAS_LIMIT: u64 = 50_000_000; +pub const DEFAULT_NFT_DEPOSIT_MAX_LEN: usize = 10; +pub const MAX_MINIMUM_FARMING_EPOCHS: u64 = 30; + +#[multiversx_sc::module] +pub trait ExitPenaltyModule: permissions_module::PermissionsModule { + #[only_owner] + #[endpoint] + fn set_penalty_percent(&self, percent: u64) { + require!(percent < MAX_PERCENT, ERROR_PARAMETERS); + self.penalty_percent().set(percent); + } + + #[endpoint] + fn set_minimum_farming_epochs(&self, epochs: Epoch) { + self.require_caller_has_admin_permissions(); + require!(epochs <= MAX_MINIMUM_FARMING_EPOCHS, ERROR_PARAMETERS); + + self.minimum_farming_epochs().set(epochs); + } + + #[only_owner] + #[endpoint] + fn set_burn_gas_limit(&self, gas_limit: u64) { + self.burn_gas_limit().set(gas_limit); + } + + fn burn_farming_tokens( + &self, + farming_amount: &BigUint, + farming_token_id: &TokenIdentifier, + reward_token_id: &TokenIdentifier, + ) { + let pair_contract_address = self.pair_contract_address().get(); + if pair_contract_address.is_zero() { + self.send() + .esdt_local_burn(farming_token_id, 0, farming_amount); + } else { + let gas_limit = self.burn_gas_limit().get(); + self.pair_contract_proxy(pair_contract_address) + .remove_liquidity_and_burn_token(reward_token_id.clone()) + .with_esdt_transfer((farming_token_id.clone(), 0, farming_amount.clone())) + .with_gas_limit(gas_limit) + .transfer_execute(); + } + } + + #[proxy] + fn pair_contract_proxy(&self, to: ManagedAddress) -> pair::Proxy; + + #[view(getPenaltyPercent)] + #[storage_mapper("penalty_percent")] + fn penalty_percent(&self) -> SingleValueMapper; + + #[view(getMinimumFarmingEpoch)] + #[storage_mapper("minimum_farming_epochs")] + fn minimum_farming_epochs(&self) -> SingleValueMapper; + + #[view(getBurnGasLimit)] + #[storage_mapper("burn_gas_limit")] + fn burn_gas_limit(&self) -> SingleValueMapper; + + #[view(getPairContractManagedAddress)] + #[storage_mapper("pair_contract_address")] + fn pair_contract_address(&self) -> SingleValueMapper; +} diff --git a/dex/farm-concentrated-liq/src/lib.rs b/dex/farm-concentrated-liq/src/lib.rs new file mode 100644 index 000000000..48cf893f1 --- /dev/null +++ b/dex/farm-concentrated-liq/src/lib.rs @@ -0,0 +1,265 @@ +#![no_std] +#![allow(clippy::too_many_arguments)] +#![feature(exact_size_is_empty)] + +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +pub mod base_functions; +pub mod exit_penalty; + +use base_functions::{ClaimRewardsResultType, DoubleMultiPayment, Wrapper}; +use common_structs::FarmTokenAttributes; +use contexts::storage_cache::StorageCache; + +use exit_penalty::{ + DEFAULT_BURN_GAS_LIMIT, DEFAULT_MINUMUM_FARMING_EPOCHS, DEFAULT_PENALTY_PERCENT, +}; +use farm_base_impl::base_traits_impl::FarmContract; + +pub type EnterFarmResultType = DoubleMultiPayment; +pub type ExitFarmWithPartialPosResultType = DoubleMultiPayment; + +#[multiversx_sc::contract] +pub trait Farm: + rewards::RewardsModule + + config::ConfigModule + + token_send::TokenSendModule + + farm_token::FarmTokenModule + + pausable::PausableModule + + permissions_module::PermissionsModule + + sc_whitelist_module::SCWhitelistModule + + events::EventsModule + + multiversx_sc_modules::default_issue_callbacks::DefaultIssueCallbacksModule + + base_functions::BaseFunctionsModule + + exit_penalty::ExitPenaltyModule + + farm_base_impl::base_farm_init::BaseFarmInitModule + + farm_base_impl::base_farm_validation::BaseFarmValidationModule + + farm_base_impl::enter_farm::BaseEnterFarmModule + + farm_base_impl::claim_rewards::BaseClaimRewardsModule + + farm_base_impl::compound_rewards::BaseCompoundRewardsModule + + farm_base_impl::exit_farm::BaseExitFarmModule + + farm_boosted_yields::FarmBoostedYieldsModule + + farm_boosted_yields::boosted_yields_factors::BoostedYieldsFactorsModule + + week_timekeeping::WeekTimekeepingModule + + weekly_rewards_splitting::WeeklyRewardsSplittingModule + + weekly_rewards_splitting::events::WeeklyRewardsSplittingEventsModule + + weekly_rewards_splitting::global_info::WeeklyRewardsGlobalInfo + + weekly_rewards_splitting::locked_token_buckets::WeeklyRewardsLockedTokenBucketsModule + + weekly_rewards_splitting::update_claim_progress_energy::UpdateClaimProgressEnergyModule + + energy_query::EnergyQueryModule + + utils::UtilsModule +{ + #[init] + fn init( + &self, + reward_token_id: TokenIdentifier, + farming_token_id: TokenIdentifier, + division_safety_constant: BigUint, + pair_contract_address: ManagedAddress, + owner: ManagedAddress, + admins: MultiValueEncoded, + ) { + self.base_farm_init( + reward_token_id, + farming_token_id, + division_safety_constant, + owner, + admins, + ); + + self.penalty_percent().set_if_empty(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); + 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); + } + + #[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); + } + + #[payable("*")] + #[endpoint(enterFarm)] + fn enter_farm_endpoint( + &self, + opt_orig_caller: OptionalValue, + ) -> EnterFarmResultType { + let caller = self.blockchain().get_caller(); + let orig_caller = self.get_orig_caller_from_opt(&caller, opt_orig_caller); + + self.migrate_old_farm_positions(&orig_caller); + let boosted_rewards = self.claim_only_boosted_payment(&orig_caller); + let boosted_rewards_payment = + 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.update_energy_and_progress(&orig_caller); + + (new_farm_token, boosted_rewards_payment).into() + } + + #[payable("*")] + #[endpoint(claimRewards)] + fn claim_rewards_endpoint( + &self, + opt_orig_caller: OptionalValue, + ) -> ClaimRewardsResultType { + let caller = self.blockchain().get_caller(); + let orig_caller = self.get_orig_caller_from_opt(&caller, opt_orig_caller); + + 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); + + claim_rewards_result.into() + } + + #[payable("*")] + #[endpoint(compoundRewards)] + fn compound_rewards_endpoint( + &self, + opt_orig_caller: OptionalValue, + ) -> EsdtTokenPayment { + let caller = self.blockchain().get_caller(); + let orig_caller = self.get_orig_caller_from_opt(&caller, opt_orig_caller); + + 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.update_energy_and_progress(&orig_caller); + + output_farm_token_payment + } + + #[payable("*")] + #[endpoint(exitFarm)] + fn exit_farm_endpoint( + &self, + opt_orig_caller: OptionalValue, + ) -> ExitFarmWithPartialPosResultType { + let caller = self.blockchain().get_caller(); + let orig_caller = self.get_orig_caller_from_opt(&caller, opt_orig_caller); + + let payment = self.call_value().single_esdt(); + + let migrated_amount = self.migrate_old_farm_positions(&orig_caller); + + 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.clear_user_energy_if_needed(&orig_caller); + + (exit_farm_result.farming_tokens, exit_farm_result.rewards).into() + } + + #[payable("*")] + #[endpoint(mergeFarmTokens)] + fn merge_farm_tokens_endpoint( + &self, + opt_orig_caller: OptionalValue, + ) -> DoubleMultiPayment { + let caller = self.blockchain().get_caller(); + let orig_caller = self.get_orig_caller_from_opt(&caller, opt_orig_caller); + self.migrate_old_farm_positions(&orig_caller); + + let boosted_rewards = self.claim_only_boosted_payment(&orig_caller); + let boosted_rewards_payment = + EsdtTokenPayment::new(self.reward_token_id().get(), 0, boosted_rewards); + + let merged_farm_token = self.merge_farm_tokens::>(); + self.send_payment_non_zero(&caller, &merged_farm_token); + self.send_payment_non_zero(&caller, &boosted_rewards_payment); + + (merged_farm_token, boosted_rewards_payment).into() + } + + #[endpoint(claimBoostedRewards)] + fn claim_boosted_rewards( + &self, + opt_user: OptionalValue, + ) -> EsdtTokenPayment { + let caller = self.blockchain().get_caller(); + let user = match &opt_user { + 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, + "Cannot claim rewards for this address" + ); + } + + let boosted_rewards = self.claim_only_boosted_payment(user); + let boosted_rewards_payment = + EsdtTokenPayment::new(self.reward_token_id().get(), 0, boosted_rewards); + + self.send_payment_non_zero(user, &boosted_rewards_payment); + + boosted_rewards_payment + } + + #[endpoint(startProduceRewards)] + fn start_produce_rewards_endpoint(&self) { + self.require_caller_has_admin_permissions(); + self.start_produce_rewards(); + } + + #[endpoint(endProduceRewards)] + fn end_produce_rewards_endpoint(&self) { + self.require_caller_has_admin_permissions(); + self.end_produce_rewards::>(); + } + + #[endpoint(setPerBlockRewardAmount)] + fn set_per_block_rewards_endpoint(&self, per_block_amount: BigUint) { + self.require_caller_has_admin_permissions(); + self.set_per_block_rewards::>(per_block_amount); + } + + #[view(calculateRewardsForGivenPosition)] + fn calculate_rewards_for_given_position( + &self, + user: ManagedAddress, + farm_token_amount: BigUint, + attributes: FarmTokenAttributes, + ) -> BigUint { + self.require_queried(); + + let mut storage_cache = StorageCache::new(self); + Wrapper::::generate_aggregated_rewards(self, &mut storage_cache); + + Wrapper::::calculate_rewards( + self, + &user, + &farm_token_amount, + &attributes, + &storage_cache, + ) + } +} diff --git a/dex/farm-concentrated-liq/wasm/Cargo.lock b/dex/farm-concentrated-liq/wasm/Cargo.lock new file mode 100644 index 000000000..52aa29daa --- /dev/null +++ b/dex/farm-concentrated-liq/wasm/Cargo.lock @@ -0,0 +1,538 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "common-types" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "common_errors" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "common_structs" +version = "0.0.0" +dependencies = [ + "fixed-supply-token", + "math", + "mergeable", + "multiversx-sc", + "unwrappable", +] + +[[package]] +name = "config" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "multiversx-sc", + "pausable", + "permissions_module", + "token_send", +] + +[[package]] +name = "contexts" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "farm_token", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "rewards", + "token_merge_helper", + "token_send", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "energy-factory" +version = "0.0.0" +dependencies = [ + "common_structs", + "legacy_token_decode_module", + "math", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "sc_whitelist_module", + "simple-lock", + "unwrappable", + "utils", +] + +[[package]] +name = "energy-query" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc", +] + +[[package]] +name = "events" +version = "0.0.0" +dependencies = [ + "common_structs", + "contexts", + "multiversx-sc", +] + +[[package]] +name = "farm-boosted-yields" +version = "0.0.0" +dependencies = [ + "common-types", + "config", + "energy-query", + "multiversx-sc", + "pausable", + "permissions_module", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-concentrated-liq" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "energy-query", + "events", + "farm-boosted-yields", + "farm_base_impl", + "farm_token", + "fixed-supply-token", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "pair", + "pausable", + "permissions_module", + "rewards", + "sc_whitelist_module", + "token_send", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "farm-concentrated-liq-wasm" +version = "0.0.0" +dependencies = [ + "farm-concentrated-liq", + "multiversx-sc-wasm-adapter", +] + +[[package]] +name = "farm_base_impl" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "contexts", + "events", + "farm_token", + "fixed-supply-token", + "mergeable", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "rewards", + "token_merge_helper", + "token_send", + "utils", +] + +[[package]] +name = "farm_token" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "token_send", +] + +[[package]] +name = "fees-collector" +version = "0.0.0" +dependencies = [ + "common-types", + "common_errors", + "energy-factory", + "energy-query", + "locking_module", + "multiversx-sc", + "multiversx-sc-modules", + "sc_whitelist_module", + "simple-lock", + "utils", + "week-timekeeping", + "weekly-rewards-splitting", +] + +[[package]] +name = "fixed-supply-token" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "legacy_token_decode_module" +version = "0.0.0" +dependencies = [ + "common_structs", + "multiversx-sc", + "utils", +] + +[[package]] +name = "locking_module" +version = "0.0.0" +dependencies = [ + "energy-factory", + "multiversx-sc", + "simple-lock", +] + +[[package]] +name = "math" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "mergeable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c94b173dc5ff0e157f767275fe6b7a1b4d2ad343bef7b66cd22a6353e016b93" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19908153158c03df4582af08f47c0eb39fb52a7dff4736b301a66acbbb9955d3" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b03b43f9cad320992f54ed162de2ed63e3ec83ed01361e57ee9c1865fba5a2" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b78945957036c281ad6ee21bb5120dcefa2017688adf43ec94e3e7c982efb09" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c63ffaba95e630ff75981e2f5f50da64f523219b52f484234c66f3adc248885f" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9579f40c00da56a5a68e010ff851fa48ac7b9c6a16ad4314795cb32d889d9e78" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "nibble_vec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43" +dependencies = [ + "smallvec", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "pair" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "fees-collector", + "itertools", + "multiversx-sc", + "pausable", + "permissions_module", + "simple-lock", + "token_send", + "utils", +] + +[[package]] +name = "pausable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", + "permissions_module", +] + +[[package]] +name = "permissions_module" +version = "0.0.0" +dependencies = [ + "bitflags", + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "proc-macro2" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "907a61bd0f64c2f29cd1cf1dc34d05176426a3f504a78010f08416ddb7b13708" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radix_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd" +dependencies = [ + "endian-type", + "nibble_vec", +] + +[[package]] +name = "rewards" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "config", + "farm_token", + "multiversx-sc", + "multiversx-sc-modules", + "pausable", + "permissions_module", + "token_send", +] + +[[package]] +name = "sc_whitelist_module" +version = "0.0.0" +dependencies = [ + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "simple-lock" +version = "0.0.0" +dependencies = [ + "common_structs", + "multiversx-sc", + "multiversx-sc-modules", +] + +[[package]] +name = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "token_merge_helper" +version = "0.0.0" +dependencies = [ + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "token_send" +version = "0.0.0" +dependencies = [ + "common_errors", + "common_structs", + "multiversx-sc", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrappable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "utils" +version = "0.0.0" +dependencies = [ + "common_structs", + "fixed-supply-token", + "mergeable", + "multiversx-sc", +] + +[[package]] +name = "week-timekeeping" +version = "0.0.0" +dependencies = [ + "common-types", + "multiversx-sc", +] + +[[package]] +name = "weekly-rewards-splitting" +version = "0.0.0" +dependencies = [ + "common-types", + "energy-query", + "math", + "multiversx-sc", + "unwrappable", + "week-timekeeping", +] diff --git a/dex/farm-concentrated-liq/wasm/Cargo.toml b/dex/farm-concentrated-liq/wasm/Cargo.toml new file mode 100644 index 000000000..9f9fc90d3 --- /dev/null +++ b/dex/farm-concentrated-liq/wasm/Cargo.toml @@ -0,0 +1,31 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "farm-concentrated-liq-wasm" +version = "0.0.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[profile.release] +codegen-units = 1 +opt-level = "z" +lto = true +debug = false +panic = "abort" +overflow-checks = false + +[dependencies.farm-concentrated-liq] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "=0.46.1" + +[workspace] +members = ["."] diff --git a/dex/farm-concentrated-liq/wasm/src/lib.rs b/dex/farm-concentrated-liq/wasm/src/lib.rs new file mode 100644 index 000000000..b4109c2b1 --- /dev/null +++ b/dex/farm-concentrated-liq/wasm/src/lib.rs @@ -0,0 +1,91 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 65 +// Async Callback: 1 +// Total number of exported functions: 67 + +#![no_std] +#![allow(internal_features)] +#![feature(lang_items)] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + farm_concentrated_liq + ( + init => init + upgrade => upgrade + enterFarm => enter_farm_endpoint + claimRewards => claim_rewards_endpoint + compoundRewards => compound_rewards_endpoint + exitFarm => exit_farm_endpoint + mergeFarmTokens => merge_farm_tokens_endpoint + claimBoostedRewards => claim_boosted_rewards + startProduceRewards => start_produce_rewards_endpoint + endProduceRewards => end_produce_rewards_endpoint + setPerBlockRewardAmount => set_per_block_rewards_endpoint + 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 + 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 + getFarmPositionMigrationNonce => farm_position_migration_nonce + registerFarmToken => register_farm_token + getFarmTokenId => farm_token + getFarmTokenSupply => farm_token_supply + addToPauseWhitelist => add_to_pause_whitelist + removeFromPauseWhitelist => remove_from_pause_whitelist + pause => pause + resume => resume + getState => state + addAdmin => add_admin_endpoint + removeAdmin => remove_admin_endpoint + updateOwnerOrAdmin => update_owner_or_admin_endpoint + getPermissions => permissions + addSCAddressToWhitelist => add_sc_address_to_whitelist + removeSCAddressFromWhitelist => remove_sc_address_from_whitelist + isSCAddressWhitelisted => is_sc_address_whitelisted + set_penalty_percent => set_penalty_percent + set_minimum_farming_epochs => set_minimum_farming_epochs + set_burn_gas_limit => set_burn_gas_limit + getPenaltyPercent => penalty_percent + getMinimumFarmingEpoch => minimum_farming_epochs + getBurnGasLimit => burn_gas_limit + getPairContractManagedAddress => pair_contract_address + setBoostedYieldsRewardsPercentage => set_boosted_yields_rewards_percentage + collectUndistributedBoostedRewards => collect_undistributed_boosted_rewards + getBoostedYieldsRewardsPercentage => boosted_yields_rewards_percentage + getAccumulatedRewardsForWeek => accumulated_rewards_for_week + getFarmSupplyForWeek => farm_supply_for_week + getRemainingBoostedRewardsToDistribute => remaining_boosted_rewards_to_distribute + getUndistributedBoostedRewards => undistributed_boosted_rewards + setBoostedYieldsFactors => set_boosted_yields_factors + getBoostedYieldsFactors => get_boosted_yields_factors + getCurrentWeek => get_current_week + getFirstWeekStartEpoch => first_week_start_epoch + getLastActiveWeekForUser => get_last_active_week_for_user_view + getUserEnergyForWeek => get_user_energy_for_week_view + getLastGlobalUpdateWeek => last_global_update_week + getTotalRewardsForWeek => total_rewards_for_week + getTotalEnergyForWeek => total_energy_for_week + getTotalLockedTokensForWeek => total_locked_tokens_for_week + updateEnergyForUser => update_energy_for_user + getCurrentClaimProgress => current_claim_progress + setEnergyFactoryAddress => set_energy_factory_address + getEnergyFactoryAddress => energy_factory_address + ) +} + +multiversx_sc_wasm_adapter::async_callback! { farm_concentrated_liq }