diff --git a/Cargo.lock b/Cargo.lock index f4091b679..ad010ebcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -884,6 +884,28 @@ dependencies = [ "utils", ] +[[package]] +name = "farm-staking-proxy-legacy" +version = "0.0.0" +dependencies = [ + "common_structs", + "hex", + "multiversx-sc", + "multiversx-sc-modules", + "multiversx-sc-scenario", + "num-bigint", + "num-traits", + "token_merge_helper", +] + +[[package]] +name = "farm-staking-proxy-legacy-meta" +version = "0.0.0" +dependencies = [ + "farm-staking-proxy-legacy", + "multiversx-sc-meta", +] + [[package]] name = "farm-staking-proxy-meta" version = "0.0.0" diff --git a/Cargo.toml b/Cargo.toml index 0944e273b..1b7132c07 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,8 @@ members = [ "legacy-contracts/simple-lock-legacy", "legacy-contracts/simple-lock-legacy/meta", + "legacy-contracts/farm-staking-proxy-legacy", + "legacy-contracts/farm-staking-proxy-legacy/meta", "locked-asset/", "locked-asset/distribution", diff --git a/legacy-contracts/farm-staking-proxy-legacy/.gitignore b/legacy-contracts/farm-staking-proxy-legacy/.gitignore new file mode 100644 index 000000000..eaf5915bd --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/.gitignore @@ -0,0 +1,7 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +*/target/ + +# The erdpy output +output diff --git a/legacy-contracts/farm-staking-proxy-legacy/Cargo.toml b/legacy-contracts/farm-staking-proxy-legacy/Cargo.toml new file mode 100644 index 000000000..8804de4a4 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "farm-staking-proxy-legacy" +version = "0.0.0" +authors = ["MultiversX "] +edition = "2021" +publish = false + +[lib] +path = "src/lib.rs" + +[dependencies.multiversx-sc] +version = "=0.50.4" +features = ["esdt-token-payment-legacy-decode"] + +[dependencies.multiversx-sc-modules] +version = "=0.50.4" + +[dependencies.token_merge_helper] +path = "../../common/modules/token_merge_helper" + +[dependencies.common_structs] +path = "../../common/common_structs" + +[dev-dependencies] +num-bigint = "0.4.2" +num-traits = "0.2" +hex = "0.4" + +[dev-dependencies.multiversx-sc-scenario] +version = "=0.50.4" diff --git a/legacy-contracts/farm-staking-proxy-legacy/meta/Cargo.toml b/legacy-contracts/farm-staking-proxy-legacy/meta/Cargo.toml new file mode 100644 index 000000000..4f7087bb4 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/meta/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "farm-staking-proxy-legacy-meta" +version = "0.0.0" +edition = "2021" +publish = false +authors = ["MultiversX "] + +[dependencies.farm-staking-proxy-legacy] +path = ".." + +[dependencies.multiversx-sc-meta] +version = "0.50.4" +default-features = false diff --git a/legacy-contracts/farm-staking-proxy-legacy/meta/src/main.rs b/legacy-contracts/farm-staking-proxy-legacy/meta/src/main.rs new file mode 100644 index 000000000..98ff6943a --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/meta/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + multiversx_sc_meta::cli_main::(); +} diff --git a/legacy-contracts/farm-staking-proxy-legacy/multiversx.json b/legacy-contracts/farm-staking-proxy-legacy/multiversx.json new file mode 100644 index 000000000..736553962 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/multiversx.json @@ -0,0 +1,3 @@ +{ + "language": "rust" +} \ No newline at end of file diff --git a/legacy-contracts/farm-staking-proxy-legacy/src/dual_yield_token.rs b/legacy-contracts/farm-staking-proxy-legacy/src/dual_yield_token.rs new file mode 100644 index 000000000..0c57f52ca --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/src/dual_yield_token.rs @@ -0,0 +1,108 @@ +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +#[derive(TypeAbi, TopEncode, TopDecode, PartialEq, Debug)] +pub struct DualYieldTokenAttributes { + pub lp_farm_token_nonce: u64, + pub lp_farm_token_amount: BigUint, + pub staking_farm_token_nonce: u64, + pub staking_farm_token_amount: BigUint, +} + +impl DualYieldTokenAttributes { + /// dual yield tokens are always created with an amount equal to staking_farm_token_amount, + /// so we just return this field instead of duplicating + #[inline] + pub fn get_total_dual_yield_tokens_for_position(&self) -> &BigUint { + &self.staking_farm_token_amount + } +} + +#[multiversx_sc::module] +pub trait DualYieldTokenModule: token_merge_helper::TokenMergeHelperModule { + #[only_owner] + #[endpoint(setTransferRoleDualYieldToken)] + fn set_transfer_role_dual_yield_token(&self, opt_address: OptionalValue) { + let address = self.resolve_address(opt_address); + let token_id = self.dual_yield_token_id().get(); + let roles = [EsdtLocalRole::Transfer]; + + self.send() + .esdt_system_sc_proxy() + .set_special_roles(&address, &token_id, roles.iter().cloned()) + .async_call_and_exit() + } + + fn resolve_address(&self, opt_address: OptionalValue) -> ManagedAddress { + match opt_address { + OptionalValue::Some(addr) => addr, + OptionalValue::None => self.blockchain().get_sc_address(), + } + } + + fn require_dual_yield_token(&self, token_id: &TokenIdentifier) { + let dual_yield_token_id = self.dual_yield_token_id().get(); + require!(token_id == &dual_yield_token_id, "Invalid payment token"); + } + + fn require_all_payments_dual_yield_tokens( + &self, + payments: &ManagedVec>, + ) { + if payments.is_empty() { + return; + } + + let dual_yield_token_id = self.dual_yield_token_id().get(); + for p in payments { + require!( + p.token_identifier == dual_yield_token_id, + "Invalid payment token" + ); + } + } + + fn burn_dual_yield_tokens(&self, sft_nonce: u64, amount: &BigUint) { + let dual_yield_token_id = self.dual_yield_token_id().get(); + self.send() + .esdt_local_burn(&dual_yield_token_id, sft_nonce, amount); + } + + fn get_dual_yield_token_attributes( + &self, + dual_yield_token_nonce: u64, + ) -> DualYieldTokenAttributes { + let own_sc_address = self.blockchain().get_sc_address(); + let dual_yield_token_id = self.dual_yield_token_id().get(); + let token_info = self.blockchain().get_esdt_token_data( + &own_sc_address, + &dual_yield_token_id, + dual_yield_token_nonce, + ); + + token_info.decode_attributes() + } + + fn get_lp_farm_token_amount_equivalent( + &self, + attributes: &DualYieldTokenAttributes, + amount: &BigUint, + ) -> BigUint { + self.rule_of_three_non_zero_result( + amount, + attributes.get_total_dual_yield_tokens_for_position(), + &attributes.lp_farm_token_amount, + ) + } + + #[inline] + fn get_staking_farm_token_amount_equivalent(&self, amount: &BigUint) -> BigUint { + // since staking_farm_token_amount is equal to the total dual yield tokens, + // we simply return the amount + amount.clone() + } + + #[view(getDualYieldTokenId)] + #[storage_mapper("dualYieldTokenId")] + fn dual_yield_token_id(&self) -> SingleValueMapper; +} diff --git a/legacy-contracts/farm-staking-proxy-legacy/src/external_contracts_interactions.rs b/legacy-contracts/farm-staking-proxy-legacy/src/external_contracts_interactions.rs new file mode 100644 index 000000000..a6826771b --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/src/external_contracts_interactions.rs @@ -0,0 +1,236 @@ +multiversx_sc::imports!(); + +use common_structs::{RawResultWrapper, RawResultsType}; + +use crate::result_types::*; + +mod farm_proxy { + multiversx_sc::imports!(); + + #[multiversx_sc::proxy] + pub trait FarmProxy { + #[payable("*")] + #[endpoint(exitFarm)] + fn exit_farm(&self) -> MultiValue2; + + #[view(getFarmingTokenId)] + fn farming_token_id(&self) -> TokenIdentifier; + } +} + +mod farm_staking_proxy { + multiversx_sc::imports!(); + + #[multiversx_sc::proxy] + pub trait FarmStakingProxy { + #[payable("*")] + #[endpoint(unstakeFarmThroughProxy)] + fn unstake_farm_through_proxy( + &self, + original_caller: ManagedAddress, + ) -> MultiValue2; + } +} + +mod pair_proxy { + multiversx_sc::imports!(); + + #[multiversx_sc::proxy] + pub trait PairProxy { + #[payable("*")] + #[endpoint(removeLiquidity)] + fn remove_liquidity( + &self, + first_token_amount_min: BigUint, + second_token_amount_min: BigUint, + ) -> MultiValue2; + + #[endpoint(updateAndGetTokensForGivenPositionWithSafePrice)] + fn update_and_get_tokens_for_given_position_with_safe_price( + &self, + liquidity: BigUint, + ) -> MultiValue2; + } +} + +#[multiversx_sc::module] +pub trait ExternalContractsInteractionsModule: + crate::lp_farm_token::LpFarmTokenModule + token_merge_helper::TokenMergeHelperModule +{ + // lp farm + + fn lp_farm_exit( + &self, + lp_farm_token_nonce: u64, + lp_farm_token_amount: BigUint, + ) -> LpFarmExitResult { + let lp_farm_token_id = self.lp_farm_token_id().get(); + let lp_farm_address = self.lp_farm_address().get(); + let raw_results: RawResultsType = self + .lp_farm_proxy_obj(lp_farm_address) + .exit_farm() + .with_esdt_transfer((lp_farm_token_id, lp_farm_token_nonce, lp_farm_token_amount)) + .execute_on_dest_context(); + + let mut results_wrapper = RawResultWrapper::new(raw_results); + results_wrapper.trim_results_front(2); + + let mut lp_tokens: EsdtTokenPayment = results_wrapper.decode_next_result(); + let mut lp_farm_rewards: EsdtTokenPayment = results_wrapper.decode_next_result(); + + let received_lp_token_identifier = lp_tokens.token_identifier.clone(); + let lp_token_identifier = self.get_lp_farming_token_identifier(); + + if lp_token_identifier != received_lp_token_identifier { + core::mem::swap(&mut lp_tokens, &mut lp_farm_rewards); + } + + LpFarmExitResult { + lp_tokens, + lp_farm_rewards, + } + } + + fn get_lp_farming_token_identifier(&self) -> TokenIdentifier { + let lp_farm_address = self.lp_farm_address().get(); + self.lp_farm_proxy_obj(lp_farm_address) + .farming_token_id() + .execute_on_dest_context() + } + + // staking farm + + fn staking_farm_unstake( + &self, + orig_caller: ManagedAddress, + staking_tokens: EsdtTokenPayment, + farm_token_nonce: u64, + farm_token_amount: BigUint, + ) -> StakingFarmExitResult { + let staking_farm_token_id = self.staking_farm_token_id().get(); + let mut payments = ManagedVec::from_single_item(staking_tokens); + payments.push(EsdtTokenPayment::new( + staking_farm_token_id, + farm_token_nonce, + farm_token_amount, + )); + + let staking_farm_address = self.staking_farm_address().get(); + let raw_results: RawResultsType = self + .staking_farm_proxy_obj(staking_farm_address) + .unstake_farm_through_proxy(orig_caller) + .with_multi_token_transfer(payments) + .execute_on_dest_context(); + + let mut results_wrapper = RawResultWrapper::new(raw_results); + results_wrapper.trim_results_front(2); + + let unbond_staking_farm_token = results_wrapper.decode_next_result(); + let staking_rewards = results_wrapper.decode_next_result(); + + StakingFarmExitResult { + unbond_staking_farm_token, + staking_rewards, + } + } + + // pair + + fn pair_remove_liquidity( + &self, + lp_tokens: EsdtTokenPayment, + pair_first_token_min_amount: BigUint, + pair_second_token_min_amount: BigUint, + ) -> PairRemoveLiquidityResult { + let pair_address = self.pair_address().get(); + let raw_results: RawResultsType = self + .pair_proxy_obj(pair_address) + .remove_liquidity(pair_first_token_min_amount, pair_second_token_min_amount) + .with_esdt_transfer(( + lp_tokens.token_identifier, + lp_tokens.token_nonce, + lp_tokens.amount, + )) + .execute_on_dest_context(); + + let mut results_wrapper = RawResultWrapper::new(raw_results); + results_wrapper.trim_results_front(2); + + let pair_first_token_payment: EsdtTokenPayment = results_wrapper.decode_next_result(); + let pair_second_token_payment: EsdtTokenPayment = results_wrapper.decode_next_result(); + + let staking_token_id = self.staking_token_id().get(); + let (staking_token_payment, other_token_payment) = + if pair_first_token_payment.token_identifier == staking_token_id { + (pair_first_token_payment, pair_second_token_payment) + } else if pair_second_token_payment.token_identifier == staking_token_id { + (pair_second_token_payment, pair_first_token_payment) + } else { + sc_panic!("Invalid payments received from Pair"); + }; + + PairRemoveLiquidityResult { + staking_token_payment, + other_token_payment, + } + } + + fn get_lp_tokens_safe_price(&self, lp_tokens_amount: BigUint) -> BigUint { + let pair_address = self.pair_address().get(); + let raw_results: RawResultsType = self + .pair_proxy_obj(pair_address) + .update_and_get_tokens_for_given_position_with_safe_price(lp_tokens_amount) + .execute_on_dest_context(); + + let mut results_wrapper = RawResultWrapper::new(raw_results); + results_wrapper.trim_results_front(2); + + let first_token_info: EsdtTokenPayment = results_wrapper.decode_next_result(); + let second_token_info: EsdtTokenPayment = results_wrapper.decode_next_result(); + + let staking_token_id = self.staking_token_id().get(); + if first_token_info.token_identifier == staking_token_id { + first_token_info.amount + } else if second_token_info.token_identifier == staking_token_id { + second_token_info.amount + } else { + sc_panic!("Invalid Pair contract called"); + } + } + + // proxies + + #[proxy] + fn staking_farm_proxy_obj( + &self, + sc_address: ManagedAddress, + ) -> farm_staking_proxy::Proxy; + + #[proxy] + fn lp_farm_proxy_obj(&self, sc_address: ManagedAddress) -> farm_proxy::Proxy; + + #[proxy] + fn pair_proxy_obj(&self, sc_address: ManagedAddress) -> pair_proxy::Proxy; + + // storage + + #[view(getLpFarmAddress)] + #[storage_mapper("lpFarmAddress")] + fn lp_farm_address(&self) -> SingleValueMapper; + + #[view(getStakingFarmAddress)] + #[storage_mapper("stakingFarmAddress")] + fn staking_farm_address(&self) -> SingleValueMapper; + + #[view(getPairAddress)] + #[storage_mapper("pairAddress")] + fn pair_address(&self) -> SingleValueMapper; + + #[view(getStakingTokenId)] + #[storage_mapper("stakingTokenId")] + fn staking_token_id(&self) -> SingleValueMapper; + + #[view(getFarmTokenId)] + #[storage_mapper("farmTokenId")] + fn staking_farm_token_id(&self) -> SingleValueMapper; +} diff --git a/legacy-contracts/farm-staking-proxy-legacy/src/lib.rs b/legacy-contracts/farm-staking-proxy-legacy/src/lib.rs new file mode 100644 index 000000000..957285429 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/src/lib.rs @@ -0,0 +1,91 @@ +#![no_std] + +multiversx_sc::imports!(); + +pub mod dual_yield_token; +pub mod external_contracts_interactions; +pub mod lp_farm_token; +pub mod result_types; + +pub type UnstakeResult = MultiValueEncoded>; + +#[multiversx_sc::contract] +pub trait FarmStakingProxy: + dual_yield_token::DualYieldTokenModule + + external_contracts_interactions::ExternalContractsInteractionsModule + + lp_farm_token::LpFarmTokenModule + + token_merge_helper::TokenMergeHelperModule +{ + #[init] + fn init(&self) {} + + #[payable("*")] + #[endpoint(unstakeFarmTokens)] + fn unstake_farm_tokens( + &self, + pair_first_token_min_amount: BigUint, + pair_second_token_min_amount: BigUint, + ) -> UnstakeResult { + let caller = self.blockchain().get_caller(); + let (payment_token, payment_nonce, payment_amount) = + self.call_value().single_esdt().into_tuple(); + self.require_dual_yield_token(&payment_token); + + let attributes = self.get_dual_yield_token_attributes(payment_nonce); + let lp_farm_token_amount = + self.get_lp_farm_token_amount_equivalent(&attributes, &payment_amount); + let lp_farm_exit_result = + self.lp_farm_exit(attributes.lp_farm_token_nonce, lp_farm_token_amount); + + let remove_liq_result = self.pair_remove_liquidity( + lp_farm_exit_result.lp_tokens, + pair_first_token_min_amount, + pair_second_token_min_amount, + ); + + let staking_farm_token_amount = + self.get_staking_farm_token_amount_equivalent(&payment_amount); + let staking_farm_exit_result = self.staking_farm_unstake( + caller.clone(), + remove_liq_result.staking_token_payment, + attributes.staking_farm_token_nonce, + staking_farm_token_amount, + ); + let unstake_result = self.send_unstake_payments( + &caller, + remove_liq_result.other_token_payment, + lp_farm_exit_result.lp_farm_rewards, + staking_farm_exit_result.staking_rewards, + staking_farm_exit_result.unbond_staking_farm_token, + ); + + self.burn_dual_yield_tokens(payment_nonce, &payment_amount); + + unstake_result + } + + fn send_unstake_payments( + &self, + caller: &ManagedAddress, + other_token_payment: EsdtTokenPayment, + lp_farm_rewards: EsdtTokenPayment, + staking_rewards: EsdtTokenPayment, + unbond_staking_farm_token: EsdtTokenPayment, + ) -> UnstakeResult { + let mut user_payments = ManagedVec::new(); + if other_token_payment.amount > 0 { + user_payments.push(other_token_payment); + } + if lp_farm_rewards.amount > 0 { + user_payments.push(lp_farm_rewards); + } + if staking_rewards.amount > 0 { + user_payments.push(staking_rewards); + } + user_payments.push(unbond_staking_farm_token); + + self.send().direct_multi(caller, &user_payments); + + user_payments.into() + } +} diff --git a/legacy-contracts/farm-staking-proxy-legacy/src/lp_farm_token.rs b/legacy-contracts/farm-staking-proxy-legacy/src/lp_farm_token.rs new file mode 100644 index 000000000..d917a0f99 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/src/lp_farm_token.rs @@ -0,0 +1,50 @@ +multiversx_sc::imports!(); +multiversx_sc::derive_imports!(); + +#[derive( + ManagedVecItem, + TopEncode, + TopDecode, + NestedEncode, + NestedDecode, + TypeAbi, + Clone, + PartialEq, + Debug, +)] +pub struct FarmTokenAttributes { + pub reward_per_share: BigUint, + pub original_entering_epoch: u64, + pub entering_epoch: u64, + pub initial_farming_amount: BigUint, + pub compounded_reward: BigUint, + pub current_farm_amount: BigUint, +} + +#[multiversx_sc::module] +pub trait LpFarmTokenModule: token_merge_helper::TokenMergeHelperModule { + fn get_lp_tokens_in_farm_position( + &self, + farm_token_nonce: u64, + farm_token_amount: &BigUint, + ) -> BigUint { + let own_sc_address = self.blockchain().get_sc_address(); + let lp_farm_token_id = self.lp_farm_token_id().get(); + let token_data = self.blockchain().get_esdt_token_data( + &own_sc_address, + &lp_farm_token_id, + farm_token_nonce, + ); + let attributes = token_data.decode_attributes::>(); + + self.rule_of_three_non_zero_result( + farm_token_amount, + &attributes.current_farm_amount, + &attributes.initial_farming_amount, + ) + } + + #[view(getLpFarmTokenId)] + #[storage_mapper("lpFarmTokenId")] + fn lp_farm_token_id(&self) -> SingleValueMapper; +} diff --git a/legacy-contracts/farm-staking-proxy-legacy/src/result_types.rs b/legacy-contracts/farm-staking-proxy-legacy/src/result_types.rs new file mode 100644 index 000000000..a27c2e1f2 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/src/result_types.rs @@ -0,0 +1,38 @@ +multiversx_sc::imports!(); + +pub type PaymentsVec = ManagedVec>; + +// lp farm + +pub struct LpFarmClaimRewardsResult { + pub new_lp_farm_tokens: EsdtTokenPayment, + pub lp_farm_rewards: EsdtTokenPayment, +} + +pub struct LpFarmExitResult { + pub lp_tokens: EsdtTokenPayment, + pub lp_farm_rewards: EsdtTokenPayment, +} + +// staking farm + +pub struct StakingFarmEnterResult { + pub received_staking_farm_token: EsdtTokenPayment, +} + +pub struct StakingFarmClaimRewardsResult { + pub new_staking_farm_tokens: EsdtTokenPayment, + pub staking_farm_rewards: EsdtTokenPayment, +} + +pub struct StakingFarmExitResult { + pub unbond_staking_farm_token: EsdtTokenPayment, + pub staking_rewards: EsdtTokenPayment, +} + +// pair + +pub struct PairRemoveLiquidityResult { + pub staking_token_payment: EsdtTokenPayment, + pub other_token_payment: EsdtTokenPayment, +} diff --git a/legacy-contracts/farm-staking-proxy-legacy/wasm/Cargo.lock b/legacy-contracts/farm-staking-proxy-legacy/wasm/Cargo.lock new file mode 100644 index 000000000..1c15ac5fa --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/wasm/Cargo.lock @@ -0,0 +1,254 @@ +# 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.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[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 = "endian-type" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" + +[[package]] +name = "farm-staking-proxy-legacy" +version = "0.0.0" +dependencies = [ + "common_structs", + "multiversx-sc", + "multiversx-sc-modules", + "token_merge_helper", +] + +[[package]] +name = "farm-staking-proxy-legacy-wasm" +version = "0.0.0" +dependencies = [ + "farm-staking-proxy-legacy", + "multiversx-sc-wasm-adapter", +] + +[[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 = "math" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "mergeable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "748a370a86e9a3c51e0609c4a6c0c9a5cceaeb742656ee3284c0620504a3d7a5" +dependencies = [ + "bitflags", + "hex-literal", + "multiversx-sc-codec", + "multiversx-sc-derive", + "num-traits", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c94397b2fba14e40edfa55905b3f453ed57aa06c9b1960ad6a0ca6bfb7a236" +dependencies = [ + "arrayvec", + "multiversx-sc-codec-derive", + "unwrap-infallible", +] + +[[package]] +name = "multiversx-sc-codec-derive" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf72a8042da0bc19da0b8f0d4f61b4c66ae853560fefc69cd8fea87bf1aa8c14" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "multiversx-sc-derive" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6ca88f27a90b0a1b17d5b645cc859e0480f4321c551525873a59a954bfbcb53" +dependencies = [ + "hex", + "proc-macro2", + "quote", + "radix_trie", + "syn", +] + +[[package]] +name = "multiversx-sc-modules" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97c7153d996ef412f5fc687a6799fc9173cb221adef283c217d160eebebe7d4" +dependencies = [ + "multiversx-sc", +] + +[[package]] +name = "multiversx-sc-wasm-adapter" +version = "0.50.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37f083d6844a0919a39d87c2552b8e9ea30e365775265d31b419d24f6aa93eee" +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.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "proc-macro2" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +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 = "smallvec" +version = "1.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" + +[[package]] +name = "syn" +version = "2.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "token_merge_helper" +version = "0.0.0" +dependencies = [ + "common_errors", + "multiversx-sc", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwrap-infallible" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "151ac09978d3c2862c4e39b557f4eceee2cc72150bc4cb4f16abf061b6e381fb" + +[[package]] +name = "unwrappable" +version = "0.0.0" +dependencies = [ + "multiversx-sc", +] diff --git a/legacy-contracts/farm-staking-proxy-legacy/wasm/Cargo.toml b/legacy-contracts/farm-staking-proxy-legacy/wasm/Cargo.toml new file mode 100644 index 000000000..0990dd0b6 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/wasm/Cargo.toml @@ -0,0 +1,34 @@ +# Code generated by the multiversx-sc build system. DO NOT EDIT. + +# ########################################## +# ############## AUTO-GENERATED ############# +# ########################################## + +[package] +name = "farm-staking-proxy-legacy-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 + +[profile.dev] +panic = "abort" + +[dependencies.farm-staking-proxy-legacy] +path = ".." + +[dependencies.multiversx-sc-wasm-adapter] +version = "=0.50.4" + +[workspace] +members = ["."] diff --git a/legacy-contracts/farm-staking-proxy-legacy/wasm/src/lib.rs b/legacy-contracts/farm-staking-proxy-legacy/wasm/src/lib.rs new file mode 100644 index 000000000..2ed024e96 --- /dev/null +++ b/legacy-contracts/farm-staking-proxy-legacy/wasm/src/lib.rs @@ -0,0 +1,33 @@ +// Code generated by the multiversx-sc build system. DO NOT EDIT. + +//////////////////////////////////////////////////// +////////////////// AUTO-GENERATED ////////////////// +//////////////////////////////////////////////////// + +// Init: 1 +// Endpoints: 9 +// Async Callback (empty): 1 +// Total number of exported functions: 11 + +#![no_std] + +multiversx_sc_wasm_adapter::allocator!(); +multiversx_sc_wasm_adapter::panic_handler!(); + +multiversx_sc_wasm_adapter::endpoints! { + farm_staking_proxy_legacy + ( + init => init + unstakeFarmTokens => unstake_farm_tokens + setTransferRoleDualYieldToken => set_transfer_role_dual_yield_token + getDualYieldTokenId => dual_yield_token_id + getLpFarmAddress => lp_farm_address + getStakingFarmAddress => staking_farm_address + getPairAddress => pair_address + getStakingTokenId => staking_token_id + getFarmTokenId => staking_farm_token_id + getLpFarmTokenId => lp_farm_token_id + ) +} + +multiversx_sc_wasm_adapter::async_callback_empty! {}