diff --git a/Cargo.lock b/Cargo.lock index ef3daaeaa..4c1af8f17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1202,18 +1202,6 @@ dependencies = [ "multiversx-sc", ] -[[package]] -name = "metabonding-staking" -version = "0.0.0" -dependencies = [ - "common_structs", - "factory", - "multiversx-sc", - "multiversx-sc-modules", - "multiversx-sc-scenario", - "num-bigint", -] - [[package]] name = "metabonding-staking-legacy" version = "0.0.0" @@ -1231,14 +1219,6 @@ dependencies = [ "multiversx-sc-meta-lib", ] -[[package]] -name = "metabonding-staking-meta" -version = "0.0.0" -dependencies = [ - "metabonding-staking", - "multiversx-sc-meta-lib", -] - [[package]] name = "multiversx-chain-scenario-format" version = "0.23.0" diff --git a/Cargo.toml b/Cargo.toml index 6e5e1da62..3907b6d37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,6 @@ members = [ "farm-staking/farm-staking/meta", "farm-staking/farm-staking-proxy", "farm-staking/farm-staking-proxy/meta", - "farm-staking/metabonding-staking", - "farm-staking/metabonding-staking/meta", "legacy-contracts/simple-lock-legacy", "legacy-contracts/simple-lock-legacy/meta", diff --git a/farm-staking/metabonding-staking/.gitignore b/farm-staking/metabonding-staking/.gitignore deleted file mode 100644 index 920d759a2..000000000 --- a/farm-staking/metabonding-staking/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -*/target/ - -# The erdpy output -output* diff --git a/farm-staking/metabonding-staking/Cargo.toml b/farm-staking/metabonding-staking/Cargo.toml deleted file mode 100644 index 61822eff9..000000000 --- a/farm-staking/metabonding-staking/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "metabonding-staking" -version = "0.0.0" -authors = ["MultiversX "] -edition = "2021" -publish = false - -[lib] -path = "src/lib.rs" - -[dependencies.multiversx-sc] -version = "=0.53.2" -features = ["esdt-token-payment-legacy-decode"] - -[dependencies.multiversx-sc-modules] -version = "=0.53.2" - -[dependencies.factory] -path = "../../locked-asset/factory" - -[dev-dependencies] -num-bigint = "0.4.2" - -[dev-dependencies.multiversx-sc-scenario] -version = "=0.53.2" - -[dev-dependencies.common_structs] -path = "../../common/common_structs" diff --git a/farm-staking/metabonding-staking/README.md b/farm-staking/metabonding-staking/README.md deleted file mode 100644 index dd18a194d..000000000 --- a/farm-staking/metabonding-staking/README.md +++ /dev/null @@ -1,57 +0,0 @@ -# Metabonding Staking Contract - -## Abstract - -Metabonding is a new community bootstrapping product, that allows users to receive tokens from projects enrolled in the Metabonding program, based on their staked eGLD and locked tokens. - -## Introduction - -The Metabonding staking contract works in conjunction with the main Metabonding contract. -The workflow can be summarized like so: -- Projects apply to the Metabonding program, by allocating a fixed number of tokens that will be distributed to users based on weekly snapshots. -- The user can stake his locked assets, along with his staked eGLD that is included by default in the snapshots, in order to get a portion of the allocated tokens. -- Daily snapshots are taken, with weekly reward distribution based on the average staked balance. - -The Metabonding staking contract takes care of the staking part of the workflow, by storing the staked locked token amounts. - -## Endpoints - -### stakeLockedAsset - -```rust - #[payable("*")] - #[endpoint(stakeLockedAsset)] - fn stake_locked_asset(&self); -``` - -Payable endpoint that allows the user to stake his locked assets. If the user already has a staking position, the tokens are merged through the locked asset factory contract. An user entry is stored, containing the information as shown below, along with the total locked asset staked supply. - -```rust -pub struct UserEntry { - pub token_nonce: u64, - pub stake_amount: BigUint, - pub unstake_amount: BigUint, - pub unbond_epoch: u64, -} -``` - -### unstake - -```rust - #[endpoint] - fn unstake( - &self, - amount: BigUint - ); -``` - -Endpoint that allows the user to specify how many locked assets he wants to unstake. When calling the endpoint, the user does not actually receive the tokens back, but he sort of states the intention to take back the tokens. Based on the current unbond duration, the user storage entry is updated with the amount he wants to unstake and the unbonding duration. In case of a second unstake, if the unbonding period is not finished, the unbonding counter is reset. - -### unbond - -```rust - #[endpoint] - fn unbond(&self); -``` - -Endpoint the allows the user to receive his tokens, considering the unbonding period is over. He receives the amount that he previously unstaked, with the corresponding token nonce. diff --git a/farm-staking/metabonding-staking/elrond.json b/farm-staking/metabonding-staking/elrond.json deleted file mode 100644 index 736553962..000000000 --- a/farm-staking/metabonding-staking/elrond.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "language": "rust" -} \ No newline at end of file diff --git a/farm-staking/metabonding-staking/meta/Cargo.toml b/farm-staking/metabonding-staking/meta/Cargo.toml deleted file mode 100644 index db0316656..000000000 --- a/farm-staking/metabonding-staking/meta/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "metabonding-staking-meta" -version = "0.0.0" -edition = "2021" -publish = false -authors = ["MultiversX "] - -[dev-dependencies] - -[dependencies.metabonding-staking] -path = ".." - -[dependencies.multiversx-sc-meta-lib] -version = "0.53.2" -default-features = false diff --git a/farm-staking/metabonding-staking/meta/src/main.rs b/farm-staking/metabonding-staking/meta/src/main.rs deleted file mode 100644 index 68dc59c5b..000000000 --- a/farm-staking/metabonding-staking/meta/src/main.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - multiversx_sc_meta_lib::cli_main::(); -} diff --git a/farm-staking/metabonding-staking/multiversx.json b/farm-staking/metabonding-staking/multiversx.json deleted file mode 100644 index 736553962..000000000 --- a/farm-staking/metabonding-staking/multiversx.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "language": "rust" -} \ No newline at end of file diff --git a/farm-staking/metabonding-staking/src/events.rs b/farm-staking/metabonding-staking/src/events.rs deleted file mode 100644 index 5614ab534..000000000 --- a/farm-staking/metabonding-staking/src/events.rs +++ /dev/null @@ -1,27 +0,0 @@ -multiversx_sc::imports!(); - -use crate::locked_asset_token::UserEntry; - -#[multiversx_sc::module] -pub trait EventsModule { - #[event("stakeEvent")] - fn stake_event( - &self, - #[indexed] user_address: &ManagedAddress, - entry_after_action: &UserEntry, - ); - - #[event("unstakeEvent")] - fn unstake_event( - &self, - #[indexed] user_address: &ManagedAddress, - entry_after_action: &UserEntry, - ); - - #[event("unbondEvent")] - fn unbond_event( - &self, - #[indexed] user_address: &ManagedAddress, - opt_entry_after_action: Option<&UserEntry>, - ); -} diff --git a/farm-staking/metabonding-staking/src/lib.rs b/farm-staking/metabonding-staking/src/lib.rs deleted file mode 100644 index d15ce3c90..000000000 --- a/farm-staking/metabonding-staking/src/lib.rs +++ /dev/null @@ -1,152 +0,0 @@ -#![no_std] - -multiversx_sc::imports!(); - -pub mod events; -pub mod locked_asset_token; - -use locked_asset_token::UserEntry; - -pub type SnapshotEntry = MultiValue2, BigUint>; -pub const UNBOND_EPOCHS: u64 = 3; - -#[multiversx_sc::contract] -pub trait MetabondingStaking: - locked_asset_token::LockedAssetTokenModule + events::EventsModule -{ - #[init] - fn init( - &self, - locked_asset_token_id: TokenIdentifier, - locked_asset_factory_address: ManagedAddress, - ) { - self.locked_asset_token_id() - .set_if_empty(&locked_asset_token_id); - self.locked_asset_factory_address() - .set_if_empty(&locked_asset_factory_address); - } - - #[upgrade] - fn upgrade(&self) {} - - #[payable("*")] - #[endpoint(stakeLockedAsset)] - fn stake_locked_asset(&self) { - let payments = self.call_value().all_esdt_transfers().clone_value(); - self.require_all_locked_asset_payments(&payments); - - let caller = self.blockchain().get_caller(); - let entry_mapper = self.entry_for_user(&caller); - let new_entry = self.create_new_entry_by_merging_tokens(&entry_mapper, payments); - - self.total_locked_asset_supply() - .update(|total_supply| *total_supply += new_entry.get_total_amount()); - - self.stake_event(&caller, &new_entry); - - entry_mapper.set(&new_entry); - let _ = self.user_list().insert(caller); - } - - #[endpoint] - fn unstake(&self, amount: BigUint) { - let caller = self.blockchain().get_caller(); - let entry_mapper = self.entry_for_user(&caller); - require!(!entry_mapper.is_empty(), "Must stake first"); - - let mut user_entry: UserEntry = entry_mapper.get(); - require!( - amount <= user_entry.stake_amount, - "Trying to unstake too much" - ); - - let current_epoch = self.blockchain().get_block_epoch(); - user_entry.unbond_epoch = current_epoch + UNBOND_EPOCHS; - user_entry.stake_amount -= &amount; - user_entry.unstake_amount += amount; - - self.unstake_event(&caller, &user_entry); - - entry_mapper.set(&user_entry); - } - - #[endpoint] - fn unbond(&self) { - let caller = self.blockchain().get_caller(); - let entry_mapper = self.entry_for_user(&caller); - require!(!entry_mapper.is_empty(), "Must stake first"); - - let mut user_entry: UserEntry = entry_mapper.get(); - let unstake_amount = user_entry.unstake_amount; - require!(unstake_amount > 0, "Must unstake first"); - - let current_epoch = self.blockchain().get_block_epoch(); - require!( - current_epoch >= user_entry.unbond_epoch, - "Unbond period in progress" - ); - - self.total_locked_asset_supply() - .update(|total_supply| *total_supply -= &unstake_amount); - - let opt_entry_after_action = if user_entry.stake_amount == 0 { - entry_mapper.clear(); - self.user_list().swap_remove(&caller); - - None - } else { - user_entry.unstake_amount = BigUint::zero(); - user_entry.unbond_epoch = u64::MAX; - entry_mapper.set(&user_entry); - - Some(&user_entry) - }; - - let locked_asset_token_id = self.locked_asset_token_id().get(); - self.send().direct_esdt( - &caller, - &locked_asset_token_id, - user_entry.token_nonce, - &unstake_amount, - ); - - self.unbond_event(&caller, opt_entry_after_action); - } - - #[view(getStakedAmountForUser)] - fn get_staked_amount_for_user(&self, user_address: ManagedAddress) -> BigUint { - let entry_mapper = self.entry_for_user(&user_address); - if entry_mapper.is_empty() { - BigUint::zero() - } else { - let entry: UserEntry = entry_mapper.get(); - - entry.stake_amount - } - } - - #[view(getUserEntry)] - fn get_user_entry(&self, user_address: ManagedAddress) -> OptionalValue> { - let entry_mapper = self.entry_for_user(&user_address); - - if !entry_mapper.is_empty() { - OptionalValue::Some(entry_mapper.get()) - } else { - OptionalValue::None - } - } - - #[view(getSnapshot)] - fn get_snapshot(&self) -> MultiValueEncoded> { - let mut result = MultiValueEncoded::new(); - - for user_address in self.user_list().iter() { - let entry: UserEntry = self.entry_for_user(&user_address).get(); - if entry.stake_amount > 0 { - result.push((user_address, entry.stake_amount).into()); - } - } - - result - } -} diff --git a/farm-staking/metabonding-staking/src/locked_asset_token.rs b/farm-staking/metabonding-staking/src/locked_asset_token.rs deleted file mode 100644 index c5c354fab..000000000 --- a/farm-staking/metabonding-staking/src/locked_asset_token.rs +++ /dev/null @@ -1,118 +0,0 @@ -multiversx_sc::imports!(); -multiversx_sc::derive_imports!(); - -use factory::locked_asset_token_merge::ProxyTrait as _; - -pub type PaymentsVec = ManagedVec>; - -#[derive(TypeAbi, TopEncode, TopDecode, NestedEncode, Debug, PartialEq)] -pub struct UserEntry { - pub token_nonce: u64, - pub stake_amount: BigUint, - pub unstake_amount: BigUint, - pub unbond_epoch: u64, -} - -impl UserEntry { - pub fn new(token_nonce: u64, stake_amount: BigUint) -> Self { - Self { - token_nonce, - stake_amount, - unstake_amount: BigUint::zero(), - unbond_epoch: u64::MAX, - } - } - - pub fn get_total_amount(&self) -> BigUint { - &self.stake_amount + &self.unstake_amount - } -} - -#[multiversx_sc::module] -pub trait LockedAssetTokenModule { - fn require_all_locked_asset_payments(&self, payments: &PaymentsVec) { - require!(!payments.is_empty(), "No payments"); - - let locked_asset_token_id = self.locked_asset_token_id().get(); - for p in payments { - require!( - p.token_identifier == locked_asset_token_id, - "Invalid payment" - ); - } - } - - fn create_new_entry_by_merging_tokens( - &self, - entry_mapper: &SingleValueMapper>, - mut new_tokens: PaymentsVec, - ) -> UserEntry { - if entry_mapper.is_empty() { - let merged_tokens = self.merge_locked_asset_tokens(new_tokens); - - return UserEntry::new(merged_tokens.token_nonce, merged_tokens.amount); - } - - let mut prev_entry: UserEntry = entry_mapper.get(); - let prev_entry_total_tokens = prev_entry.get_total_amount(); - self.total_locked_asset_supply() - .update(|total_supply| *total_supply -= &prev_entry_total_tokens); - - let prev_entry_as_payment = EsdtTokenPayment::new( - self.locked_asset_token_id().get(), - prev_entry.token_nonce, - prev_entry_total_tokens, - ); - new_tokens.push(prev_entry_as_payment); - - let merged_tokens = self.merge_locked_asset_tokens(new_tokens); - prev_entry.token_nonce = merged_tokens.token_nonce; - prev_entry.stake_amount = &merged_tokens.amount - &prev_entry.unstake_amount; - - prev_entry - } - - fn merge_locked_asset_tokens( - &self, - tokens: PaymentsVec, - ) -> EsdtTokenPayment { - if tokens.len() == 1 { - return tokens.get(0); - } - - let locked_asset_factory_address = self.locked_asset_factory_address().get(); - self.locked_asset_factory_proxy(locked_asset_factory_address) - .merge_tokens() - .with_multi_token_transfer(tokens) - .execute_on_dest_context() - } - - // proxies - - #[proxy] - fn locked_asset_factory_proxy(&self, sc_address: ManagedAddress) -> factory::Proxy; - - // storage - - #[view(getLockedAssetTokenId)] - #[storage_mapper("lockedAssetTokenId")] - fn locked_asset_token_id(&self) -> SingleValueMapper; - - #[view(getLockedAssetFactoryAddress)] - #[storage_mapper("lockedAssetFactoryAddress")] - fn locked_asset_factory_address(&self) -> SingleValueMapper; - - #[view(getTotalLockedAssetSupply)] - #[storage_mapper("totalLockedAssetSupply")] - fn total_locked_asset_supply(&self) -> SingleValueMapper; - - #[storage_mapper("entryForUser")] - fn entry_for_user( - &self, - user_address: &ManagedAddress, - ) -> SingleValueMapper>; - - #[view(getUserList)] - #[storage_mapper("userList")] - fn user_list(&self) -> UnorderedSetMapper; -} diff --git a/farm-staking/metabonding-staking/testnet.toml b/farm-staking/metabonding-staking/testnet.toml deleted file mode 100644 index e69de29bb..000000000 diff --git a/farm-staking/metabonding-staking/tests/metabonding_staking_setup/mod.rs b/farm-staking/metabonding-staking/tests/metabonding_staking_setup/mod.rs deleted file mode 100644 index a4b8effeb..000000000 --- a/farm-staking/metabonding-staking/tests/metabonding_staking_setup/mod.rs +++ /dev/null @@ -1,251 +0,0 @@ -#![allow(deprecated)] - -use common_structs::{ - LockedAssetTokenAttributesEx, UnlockMilestone, UnlockMilestoneEx, UnlockScheduleEx, -}; -use factory::locked_asset::LockedAssetModule; -use factory::*; -use metabonding_staking::MetabondingStaking; -use multiversx_sc::storage::mappers::StorageTokenWrapper; -use multiversx_sc::types::{Address, EsdtLocalRole, ManagedVec}; -use multiversx_sc_modules::pause::PauseModule; -use multiversx_sc_scenario::whitebox_legacy::{TxResult, TxTokenTransfer}; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, managed_token_id, rust_biguint, whitebox_legacy::*, DebugApi, -}; - -pub const METABONDING_STAKING_WASM_PATH: &str = "1.wasm"; -pub const LOCKED_ASSET_FACTORY_WASM_PATH: &str = "2.wasm"; -pub const ASSET_TOKEN_ID: &[u8] = b"MEX-123456"; -pub const LOCKED_ASSET_TOKEN_ID: &[u8] = b"LKMEX-123456"; - -pub struct MetabondingStakingSetup -where - MetabondingStakingObjBuilder: - 'static + Copy + Fn() -> metabonding_staking::ContractObj, - LockedAssetFactoryObjBuilder: 'static + Copy + Fn() -> factory::ContractObj, -{ - pub b_mock: BlockchainStateWrapper, - pub owner_address: Address, - pub user_address: Address, - pub mbs_wrapper: ContractObjWrapper< - metabonding_staking::ContractObj, - MetabondingStakingObjBuilder, - >, - pub laf_wrapper: - ContractObjWrapper, LockedAssetFactoryObjBuilder>, -} - -impl - MetabondingStakingSetup -where - MetabondingStakingObjBuilder: - 'static + Copy + Fn() -> metabonding_staking::ContractObj, - LockedAssetFactoryObjBuilder: 'static + Copy + Fn() -> factory::ContractObj, -{ - pub fn new( - mbs_builder: MetabondingStakingObjBuilder, - laf_builder: LockedAssetFactoryObjBuilder, - ) -> Self { - DebugApi::dummy(); - - let rust_zero = rust_biguint!(0u64); - let mut b_mock = BlockchainStateWrapper::new(); - let owner_addr = b_mock.create_user_account(&rust_zero); - let user_addr = b_mock.create_user_account(&rust_zero); - - let laf_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner_addr), - laf_builder, - LOCKED_ASSET_FACTORY_WASM_PATH, - ); - let mbs_wrapper = b_mock.create_sc_account( - &rust_zero, - Some(&owner_addr), - mbs_builder, - METABONDING_STAKING_WASM_PATH, - ); - - // set initial user balance - - // 100_000_000 - let attr1 = LockedAssetTokenAttributesEx:: { - unlock_schedule: UnlockScheduleEx { - unlock_milestones: ManagedVec::from(vec![ - UnlockMilestoneEx { - unlock_epoch: 0, - unlock_percent: 10_000, - }, - UnlockMilestoneEx { - unlock_epoch: 360, - unlock_percent: 15_000, - }, - UnlockMilestoneEx { - unlock_epoch: 390, - unlock_percent: 15_000, - }, - UnlockMilestoneEx { - unlock_epoch: 420, - unlock_percent: 15_000, - }, - UnlockMilestoneEx { - unlock_epoch: 450, - unlock_percent: 15_000, - }, - UnlockMilestoneEx { - unlock_epoch: 480, - unlock_percent: 15_000, - }, - UnlockMilestoneEx { - unlock_epoch: 510, - unlock_percent: 15_000, - }, - ]), - }, - is_merged: false, - }; - // 1_000_000 - let attr2 = LockedAssetTokenAttributesEx:: { - unlock_schedule: UnlockScheduleEx { - unlock_milestones: ManagedVec::from(vec![ - UnlockMilestoneEx { - unlock_epoch: 360, - unlock_percent: 16_000, - }, - UnlockMilestoneEx { - unlock_epoch: 390, - unlock_percent: 16_000, - }, - UnlockMilestoneEx { - unlock_epoch: 420, - unlock_percent: 17_000, - }, - UnlockMilestoneEx { - unlock_epoch: 450, - unlock_percent: 17_000, - }, - UnlockMilestoneEx { - unlock_epoch: 480, - unlock_percent: 17_000, - }, - UnlockMilestoneEx { - unlock_epoch: 510, - unlock_percent: 17_000, - }, - ]), - }, - is_merged: false, - }; - - b_mock.set_nft_balance( - &user_addr, - LOCKED_ASSET_TOKEN_ID, - 3, - &rust_biguint!(100_000_000), - &attr1, - ); - b_mock.set_nft_balance( - &user_addr, - LOCKED_ASSET_TOKEN_ID, - 4, - &rust_biguint!(1_000_000), - &attr2, - ); - - // init Locked Asset Factory contract - - b_mock - .execute_tx(&owner_addr, &laf_wrapper, &rust_zero, |sc| { - let asset_token_id = managed_token_id!(ASSET_TOKEN_ID); - let unlocked_percents = ManagedVec::from_single_item(UnlockMilestone { - unlock_epoch: 5, - unlock_percent: 100, - }); - - sc.init(asset_token_id, unlocked_percents.into()); - - let locked_asset_token_id = managed_token_id!(LOCKED_ASSET_TOKEN_ID); - sc.locked_asset_token().set_token_id(locked_asset_token_id); - - sc.set_paused(false); - }) - .assert_ok(); - - let locked_asset_token_roles = [ - EsdtLocalRole::NftCreate, - EsdtLocalRole::NftAddQuantity, - EsdtLocalRole::NftBurn, - ]; - b_mock.set_esdt_local_roles( - laf_wrapper.address_ref(), - LOCKED_ASSET_TOKEN_ID, - &locked_asset_token_roles[..], - ); - - // init Metabonding Staking contract - - b_mock - .execute_tx(&owner_addr, &mbs_wrapper, &rust_zero, |sc| { - let locked_asset_token_id = managed_token_id!(LOCKED_ASSET_TOKEN_ID); - let locked_asset_factory_addr = managed_address!(laf_wrapper.address_ref()); - - sc.init(locked_asset_token_id, locked_asset_factory_addr); - }) - .assert_ok(); - - Self { - b_mock, - laf_wrapper, - mbs_wrapper, - owner_address: owner_addr, - user_address: user_addr, - } - } - - pub fn call_stake_locked_asset(&mut self, token_nonce: u64, amount: u64) -> TxResult { - self.b_mock.execute_esdt_transfer( - &self.user_address, - &self.mbs_wrapper, - LOCKED_ASSET_TOKEN_ID, - token_nonce, - &rust_biguint!(amount), - |sc| { - sc.stake_locked_asset(); - }, - ) - } - - pub fn call_stake_locked_asset_multiple(&mut self, payments: &[TxTokenTransfer]) -> TxResult { - self.b_mock.execute_esdt_multi_transfer( - &self.user_address, - &self.mbs_wrapper, - payments, - |sc| { - sc.stake_locked_asset(); - }, - ) - } - - pub fn call_unstake(&mut self, amount: u64) -> TxResult { - self.b_mock.execute_tx( - &self.user_address, - &self.mbs_wrapper, - &rust_biguint!(0), - |sc| { - sc.unstake(managed_biguint!(amount)); - }, - ) - } - - pub fn call_unbond(&mut self) -> TxResult { - self.b_mock.execute_tx( - &self.user_address, - &self.mbs_wrapper, - &rust_biguint!(0), - |sc| { - sc.unbond(); - }, - ) - } -} diff --git a/farm-staking/metabonding-staking/tests/metabonding_staking_test.rs b/farm-staking/metabonding-staking/tests/metabonding_staking_test.rs deleted file mode 100644 index c83be6726..000000000 --- a/farm-staking/metabonding-staking/tests/metabonding_staking_test.rs +++ /dev/null @@ -1,342 +0,0 @@ -#![allow(deprecated)] - -pub mod metabonding_staking_setup; -use metabonding_staking::{ - locked_asset_token::{LockedAssetTokenModule, UserEntry}, - UNBOND_EPOCHS, -}; -use metabonding_staking_setup::*; -use multiversx_sc_scenario::{ - managed_address, managed_biguint, rust_biguint, whitebox_legacy::TxTokenTransfer, -}; - -#[test] -fn test_init() { - let _ = MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); -} - -#[test] -fn test_stake_first() { - let mut setup = - MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); - setup.call_stake_locked_asset(3, 100_000_000).assert_ok(); - - let user_addr = setup.user_address.clone(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry::new(3, managed_biguint!(100_000_000)); - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); -} - -#[test] -fn test_stake_second() { - let mut setup = - MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); - setup.call_stake_locked_asset(3, 100_000_000).assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_supply = managed_biguint!(100_000_000); - let actual_supply = sc.total_locked_asset_supply().get(); - assert_eq!(actual_supply, expected_supply); - }) - .assert_ok(); - - setup.call_stake_locked_asset(4, 1_000_000).assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_supply = managed_biguint!(101_000_000); - let actual_supply = sc.total_locked_asset_supply().get(); - assert_eq!(actual_supply, expected_supply); - }) - .assert_ok(); - - // tokens are merged into a single one - let user_addr = setup.user_address.clone(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry::new(1, managed_biguint!(101_000_000)); - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); -} - -#[test] -fn test_stake_multiple() { - let mut setup = - MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); - let payments = [ - TxTokenTransfer { - token_identifier: LOCKED_ASSET_TOKEN_ID.to_vec(), - nonce: 3, - value: rust_biguint!(100_000_000), - }, - TxTokenTransfer { - token_identifier: LOCKED_ASSET_TOKEN_ID.to_vec(), - nonce: 4, - value: rust_biguint!(1_000_000), - }, - ]; - - setup - .call_stake_locked_asset_multiple(&payments) - .assert_ok(); - - // tokens are merged into a single one - let user_addr = setup.user_address.clone(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry::new(1, managed_biguint!(101_000_000)); - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); -} - -#[test] -fn test_unstake() { - let mut setup = - MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); - setup.call_stake_locked_asset(3, 100_000_000).assert_ok(); - setup.call_stake_locked_asset(4, 1_000_000).assert_ok(); - - // tokens are merged into a single one - let user_addr = setup.user_address.clone(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry::new(1, managed_biguint!(101_000_000)); - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - setup.call_unstake(101_000_000).assert_ok(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry { - token_nonce: 1, - stake_amount: managed_biguint!(0), - unstake_amount: managed_biguint!(101_000_000), - unbond_epoch: 3, - }; - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - // try unstake again - setup - .call_unstake(101_000_000) - .assert_user_error("Trying to unstake too much"); -} - -#[test] -fn test_partial_unstake() { - let mut setup = - MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); - setup.call_stake_locked_asset(3, 90_000_000).assert_ok(); - setup.call_stake_locked_asset(4, 1_000_000).assert_ok(); - - // tokens are merged into a single one - let user_addr = setup.user_address.clone(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry::new(1, managed_biguint!(91_000_000)); - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - setup.call_unstake(51_000_000).assert_ok(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry { - token_nonce: 1, - stake_amount: managed_biguint!(40_000_000), - unstake_amount: managed_biguint!(51_000_000), - unbond_epoch: 3, - }; - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - // unstake too much - setup - .call_unstake(101_000_000) - .assert_user_error("Trying to unstake too much"); - - // unstake ok - setup.b_mock.set_block_epoch(5); - setup.call_unstake(30_000_000).assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry { - token_nonce: 1, - stake_amount: managed_biguint!(10_000_000), - unstake_amount: managed_biguint!(81_000_000), - unbond_epoch: 8, - }; - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - // stake after unstake - setup.call_stake_locked_asset(3, 10_000_000).assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry { - token_nonce: 2, - stake_amount: managed_biguint!(20_000_000), - unstake_amount: managed_biguint!(81_000_000), - unbond_epoch: 8, - }; - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - // unbond - - setup.b_mock.set_block_epoch(15); - setup.call_unbond().assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry { - token_nonce: 2, - stake_amount: managed_biguint!(20_000_000), - unstake_amount: managed_biguint!(0), - unbond_epoch: u64::MAX, - }; - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - // checking attributes for LKMEX tokens is out of scope - // so we just check with the raw expected value - let attributes: Vec = vec![ - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 173, 0, 0, 0, 0, 0, 0, 1, 104, 0, - 0, 0, 0, 0, 0, 58, 162, 0, 0, 0, 0, 0, 0, 1, 134, 0, 0, 0, 0, 0, 0, 58, 162, 0, 0, 0, 0, 0, - 0, 1, 164, 0, 0, 0, 0, 0, 0, 58, 171, 0, 0, 0, 0, 0, 0, 1, 194, 0, 0, 0, 0, 0, 0, 58, 172, - 0, 0, 0, 0, 0, 0, 1, 224, 0, 0, 0, 0, 0, 0, 58, 172, 0, 0, 0, 0, 0, 0, 1, 254, 0, 0, 0, 0, - 0, 0, 58, 172, 1, - ]; - setup.b_mock.check_nft_balance( - &setup.user_address, - LOCKED_ASSET_TOKEN_ID, - 2, - &rust_biguint!(81_000_000), - Some(&attributes), - ); -} - -#[test] -fn test_unbond() { - let mut setup = - MetabondingStakingSetup::new(metabonding_staking::contract_obj, factory::contract_obj); - - setup.call_stake_locked_asset(3, 100_000_000).assert_ok(); - setup.call_stake_locked_asset(4, 1_000_000).assert_ok(); - - // tokens are merged into a single one - let user_addr = setup.user_address.clone(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry::new(1, managed_biguint!(101_000_000)); - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - // try unbond before unstake - setup.call_unbond().assert_user_error("Must unstake first"); - - setup.call_unstake(101_000_000).assert_ok(); - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_entry = UserEntry { - token_nonce: 1, - stake_amount: managed_biguint!(0), - unstake_amount: managed_biguint!(101_000_000), - unbond_epoch: 3, - }; - let actual_entry = sc.entry_for_user(&managed_address!(&user_addr)).get(); - assert_eq!(actual_entry, expected_entry); - }) - .assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_supply = managed_biguint!(101_000_000); - let actual_supply = sc.total_locked_asset_supply().get(); - assert_eq!(actual_supply, expected_supply); - }) - .assert_ok(); - - // try unbond too early - setup - .call_unbond() - .assert_user_error("Unbond period in progress"); - - setup.b_mock.set_block_epoch(UNBOND_EPOCHS); - setup.call_unbond().assert_ok(); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let expected_supply = managed_biguint!(0); - let actual_supply = sc.total_locked_asset_supply().get(); - assert_eq!(actual_supply, expected_supply); - }) - .assert_ok(); - - // checking attributes for LKMEX tokens is out of scope - // so we just check with the raw expected value - let attributes: Vec = vec![ - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 38, 173, 0, 0, 0, 0, 0, 0, 1, 104, 0, - 0, 0, 0, 0, 0, 58, 162, 0, 0, 0, 0, 0, 0, 1, 134, 0, 0, 0, 0, 0, 0, 58, 162, 0, 0, 0, 0, 0, - 0, 1, 164, 0, 0, 0, 0, 0, 0, 58, 171, 0, 0, 0, 0, 0, 0, 1, 194, 0, 0, 0, 0, 0, 0, 58, 172, - 0, 0, 0, 0, 0, 0, 1, 224, 0, 0, 0, 0, 0, 0, 58, 172, 0, 0, 0, 0, 0, 0, 1, 254, 0, 0, 0, 0, - 0, 0, 58, 172, 1, - ]; - setup.b_mock.check_nft_balance( - &setup.user_address, - LOCKED_ASSET_TOKEN_ID, - 1, - &rust_biguint!(101_000_000), - Some(&attributes), - ); - - setup - .b_mock - .execute_query(&setup.mbs_wrapper, |sc| { - let entry_is_empty = sc.entry_for_user(&managed_address!(&user_addr)).is_empty(); - assert!(entry_is_empty); - }) - .assert_ok(); -} diff --git a/farm-staking/metabonding-staking/wasm/Cargo.lock b/farm-staking/metabonding-staking/wasm/Cargo.lock deleted file mode 100644 index 89a2ba993..000000000 --- a/farm-staking/metabonding-staking/wasm/Cargo.lock +++ /dev/null @@ -1,397 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "arrayvec" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" - -[[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 = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - -[[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 = "factory" -version = "0.0.0" -dependencies = [ - "arrayvec", - "common_errors", - "common_structs", - "energy-factory", - "itertools", - "multiversx-sc", - "multiversx-sc-modules", - "token_merge_helper", - "token_send", - "wee_alloc", -] - -[[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 = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "math" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "mergeable" -version = "0.0.0" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "metabonding-staking" -version = "0.0.0" -dependencies = [ - "factory", - "multiversx-sc", - "multiversx-sc-modules", -] - -[[package]] -name = "metabonding-staking-wasm" -version = "0.0.0" -dependencies = [ - "metabonding-staking", - "multiversx-sc-wasm-adapter", -] - -[[package]] -name = "multiversx-sc" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75ea89a26f0aacda21437a8ae5ccfbefab99d8191942b3d2eddbcbf84f9866d7" -dependencies = [ - "bitflags", - "hex-literal", - "multiversx-sc-codec", - "multiversx-sc-derive", - "num-traits", - "unwrap-infallible", -] - -[[package]] -name = "multiversx-sc-codec" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "007d7a5a8534e5dc9128cb8f15a65a21dd378e135c6016c7cd1491cd012bc8cb" -dependencies = [ - "arrayvec", - "multiversx-sc-codec-derive", - "unwrap-infallible", -] - -[[package]] -name = "multiversx-sc-codec-derive" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dffba1dce273ed5b61ee1b90aeea5c8c744617d0f12624f620768c144d83e753" -dependencies = [ - "hex", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "multiversx-sc-derive" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c17fdf90fafca2f19085ae67b0502d9f71bf8ab1be3c83808eb88e02a8c18b9" -dependencies = [ - "hex", - "proc-macro2", - "quote", - "radix_trie", - "syn", -] - -[[package]] -name = "multiversx-sc-modules" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daeb48acbd39255868a3241798df2f85050f0ae8d82d6417bd2cd0e30a241855" -dependencies = [ - "multiversx-sc", -] - -[[package]] -name = "multiversx-sc-wasm-adapter" -version = "0.53.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20659915a4377d375c46d7f237e810053a03f7e084fad6362dd5748a7233defb" -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.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -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 = "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.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -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 = "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", -] - -[[package]] -name = "utils" -version = "0.0.0" -dependencies = [ - "common_structs", - "fixed-supply-token", - "mergeable", - "multiversx-sc", -] - -[[package]] -name = "wee_alloc" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e" -dependencies = [ - "cfg-if", - "libc", - "memory_units", - "winapi", -] - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/farm-staking/metabonding-staking/wasm/Cargo.toml b/farm-staking/metabonding-staking/wasm/Cargo.toml deleted file mode 100644 index 3e6162e7d..000000000 --- a/farm-staking/metabonding-staking/wasm/Cargo.toml +++ /dev/null @@ -1,34 +0,0 @@ -# Code generated by the multiversx-sc build system. DO NOT EDIT. - -# ########################################## -# ############## AUTO-GENERATED ############# -# ########################################## - -[package] -name = "metabonding-staking-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.metabonding-staking] -path = ".." - -[dependencies.multiversx-sc-wasm-adapter] -version = "=0.53.2" - -[workspace] -members = ["."] diff --git a/farm-staking/metabonding-staking/wasm/src/lib.rs b/farm-staking/metabonding-staking/wasm/src/lib.rs deleted file mode 100644 index 22b6f6de2..000000000 --- a/farm-staking/metabonding-staking/wasm/src/lib.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by the multiversx-sc build system. DO NOT EDIT. - -//////////////////////////////////////////////////// -////////////////// AUTO-GENERATED ////////////////// -//////////////////////////////////////////////////// - -// Init: 1 -// Upgrade: 1 -// Endpoints: 10 -// Async Callback (empty): 1 -// Total number of exported functions: 13 - -#![no_std] - -multiversx_sc_wasm_adapter::allocator!(); -multiversx_sc_wasm_adapter::panic_handler!(); - -multiversx_sc_wasm_adapter::endpoints! { - metabonding_staking - ( - init => init - upgrade => upgrade - stakeLockedAsset => stake_locked_asset - unstake => unstake - unbond => unbond - getStakedAmountForUser => get_staked_amount_for_user - getUserEntry => get_user_entry - getSnapshot => get_snapshot - getLockedAssetTokenId => locked_asset_token_id - getLockedAssetFactoryAddress => locked_asset_factory_address - getTotalLockedAssetSupply => total_locked_asset_supply - getUserList => user_list - ) -} - -multiversx_sc_wasm_adapter::async_callback_empty! {} diff --git a/legacy-contracts/metabonding-staking-legacy/src/lib.rs b/legacy-contracts/metabonding-staking-legacy/src/lib.rs index 0dc1366f6..1d78ee973 100644 --- a/legacy-contracts/metabonding-staking-legacy/src/lib.rs +++ b/legacy-contracts/metabonding-staking-legacy/src/lib.rs @@ -39,6 +39,18 @@ pub trait MetabondingStakingLegacy { sc_panic!(ERROR_LEGACY_CONTRACT); } + #[only_owner] + #[endpoint(pause)] + fn pause_endpoint(&self) { + sc_panic!(ERROR_LEGACY_CONTRACT); + } + + #[only_owner] + #[endpoint(unpause)] + fn unpause_endpoint(&self) { + sc_panic!(ERROR_LEGACY_CONTRACT); + } + #[view(getStakedAmountForUser)] fn get_staked_amount_for_user(&self, _user_address: ManagedAddress) -> BigUint { sc_panic!(ERROR_LEGACY_CONTRACT); @@ -77,4 +89,8 @@ pub trait MetabondingStakingLegacy { #[view(getUserList)] #[storage_mapper("userList")] fn user_list(&self) -> UnorderedSetMapper; + + #[view(isPaused)] + #[storage_get("pause_module:paused")] + fn is_paused(&self) -> bool; } diff --git a/legacy-contracts/metabonding-staking-legacy/wasm/src/lib.rs b/legacy-contracts/metabonding-staking-legacy/wasm/src/lib.rs index 63d9927c8..e175e4eec 100644 --- a/legacy-contracts/metabonding-staking-legacy/wasm/src/lib.rs +++ b/legacy-contracts/metabonding-staking-legacy/wasm/src/lib.rs @@ -6,9 +6,9 @@ // Init: 1 // Upgrade: 1 -// Endpoints: 10 +// Endpoints: 13 // Async Callback (empty): 1 -// Total number of exported functions: 13 +// Total number of exported functions: 16 #![no_std] @@ -23,6 +23,8 @@ multiversx_sc_wasm_adapter::endpoints! { stakeLockedAsset => stake_locked_asset unstake => unstake unbond => unbond + pause => pause_endpoint + unpause => unpause_endpoint getStakedAmountForUser => get_staked_amount_for_user getUserEntry => get_user_entry getSnapshot => get_snapshot @@ -30,6 +32,7 @@ multiversx_sc_wasm_adapter::endpoints! { getLockedAssetFactoryAddress => locked_asset_factory_address getTotalLockedAssetSupply => total_locked_asset_supply getUserList => user_list + isPaused => is_paused ) }