Skip to content

Commit

Permalink
Merge pull request #647 from ElrondNetwork/add-pause-metabonding-staking
Browse files Browse the repository at this point in the history
add pause module
  • Loading branch information
sasurobert authored Dec 8, 2022
2 parents 4dce890 + 370b432 commit a4827c0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
1 change: 0 additions & 1 deletion common/common_structs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(generic_associated_types)]

elrond_wasm::imports!();
elrond_wasm::derive_imports!();
Expand Down
1 change: 0 additions & 1 deletion common/modules/token_merge/src/token_merge.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(generic_associated_types)]

elrond_wasm::imports!();
elrond_wasm::derive_imports!();
Expand Down
18 changes: 16 additions & 2 deletions dex/farm-staking-contracts/metabonding-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@ pub const UNBOND_EPOCHS: u64 = 0;

#[elrond_wasm::contract]
pub trait MetabondingStaking:
locked_asset_token::LockedAssetTokenModule + events::EventsModule
locked_asset_token::LockedAssetTokenModule
+ events::EventsModule
+ elrond_wasm_modules::pause::PauseModule
{
#[init]
fn init(&self) {}
fn init(&self) {
self.set_paused(true);
}

#[payable("*")]
#[endpoint(stakeLockedAsset)]
fn stake_locked_asset(&self) {
self.require_not_paused();

let payments = self.call_value().all_esdt_transfers();
self.require_all_locked_asset_payments(&payments);

Expand All @@ -38,6 +44,8 @@ pub trait MetabondingStaking:

#[endpoint]
fn unstake(&self, amount: BigUint) {
self.require_not_paused();

let caller = self.blockchain().get_caller();
let entry_mapper = self.entry_for_user(&caller);
require!(!entry_mapper.is_empty(), "Must stake first");
Expand All @@ -60,6 +68,8 @@ pub trait MetabondingStaking:

#[endpoint]
fn unbond(&self) {
self.require_not_paused();

let caller = self.blockchain().get_caller();
let entry_mapper = self.entry_for_user(&caller);
require!(!entry_mapper.is_empty(), "Must stake first");
Expand Down Expand Up @@ -132,4 +142,8 @@ pub trait MetabondingStaking:

result
}

fn require_not_paused(&self) {
require!(self.not_paused(), "SC is paused");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ elrond_wasm_node::wasm_endpoints! {
getTotalLockedAssetSupply
getUserEntry
getUserList
isPaused
pause
stakeLockedAsset
unbond
unpause
unstake
)
}
Expand Down
1 change: 0 additions & 1 deletion locked-asset/factory/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![no_std]
#![feature(generic_associated_types)]
#![feature(exact_size_is_empty)]

mod attr_ex_helper;
Expand Down

0 comments on commit a4827c0

Please sign in to comment.