Struct pallet_tidefi_stake::pallet::Pallet
source · pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations§
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn stake(
origin: OriginFor<T>,
currency_id: CurrencyId,
amount: Balance,
duration: T::BlockNumber
) -> DispatchResultWithPostInfo
pub fn stake(
origin: OriginFor<T>,
currency_id: CurrencyId,
amount: Balance,
duration: T::BlockNumber
) -> DispatchResultWithPostInfo
Stake currency
currency_id
: The currency to stakeamount
: The amount to stakeduration
: The duration is in numbers of blocks. (blocks are ~6seconds)
Emits Staked
event when successful.
Weight: O(1)
sourcepub fn unstake(
origin: OriginFor<T>,
stake_id: Hash,
force_unstake: bool
) -> DispatchResultWithPostInfo
pub fn unstake(
origin: OriginFor<T>,
stake_id: Hash,
force_unstake: bool
) -> DispatchResultWithPostInfo
Unstake
stake_id
: Unique Stake IDforce_unstake
: Unstake with extra fees, even if the staking is not expired
Emits Unstaked
event when successful.
Weight: O(1)
sourcepub fn set_operator_account_id(
origin: OriginFor<T>,
new_operator_account_id: T::AccountId
) -> DispatchResultWithPostInfo
pub fn set_operator_account_id(
origin: OriginFor<T>,
new_operator_account_id: T::AccountId
) -> DispatchResultWithPostInfo
Set Staking Operator Account TODO: Benchmark weight
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
pub fn account_id() -> T::AccountId
pub fn operator_account() -> T::AccountId
pub fn add_account_stake(
account_id: &T::AccountId,
currency_id: CurrencyId,
amount: Balance,
duration: T::BlockNumber
) -> Result<Hash, DispatchError>
pub fn do_on_idle_compound(remaining_weight: Weight) -> Weight
pub fn do_on_idle_unstake(remaining_weight: Weight) -> Weight
pub fn get_account_stakes(
account_id: &T::AccountId
) -> Vec<(CurrencyId, Stake<BalanceInfo, T::BlockNumber>)> ⓘ
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn staking_pool<KArg>(k: KArg) -> Option<Balance>where
KArg: EncodeLike<CurrencyId>,
pub fn staking_pool<KArg>(k: KArg) -> Option<Balance>where
KArg: EncodeLike<CurrencyId>,
Staking pool
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn staking_rewards(
) -> BoundedVec<(T::BlockNumber, Percent), T::StakingRewardCap>
pub fn staking_rewards(
) -> BoundedVec<(T::BlockNumber, Percent), T::StakingRewardCap>
Staking rewards defined by the council
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn staking_meta<KArg>(k: KArg) -> Option<StakeCurrencyMeta<Balance>>where
KArg: EncodeLike<CurrencyId>,
pub fn staking_meta<KArg>(k: KArg) -> Option<StakeCurrencyMeta<Balance>>where
KArg: EncodeLike<CurrencyId>,
Staking metadata defined by the council (minimum and maximum stake amount)
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn unstake_fee() -> Percent
pub fn unstake_fee() -> Percent
The percentage of fee when unstake is done before the ending.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn interest_compound_last_session() -> SessionIndex
pub fn interest_compound_last_session() -> SessionIndex
The last session we should compound the account interests.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn pending_sessions<KArg>(
k: KArg
) -> Option<BoundedVec<(CurrencyId, Balance), T::StakingRewardCap>>where
KArg: EncodeLike<SessionIndex>,
pub fn pending_sessions<KArg>(
k: KArg
) -> Option<BoundedVec<(CurrencyId, Balance), T::StakingRewardCap>>where
KArg: EncodeLike<SessionIndex>,
Map from all pending stored sessions.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn session_total_fees<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Balancewhere
KArg1: EncodeLike<SessionIndex>,
KArg2: EncodeLike<CurrencyId>,
pub fn session_total_fees<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Balancewhere
KArg1: EncodeLike<SessionIndex>,
KArg2: EncodeLike<CurrencyId>,
The total fees for the session. If total hasn’t been set or has been removed then 0 stake is returned.
source§impl<T: Config> Pallet<T>
impl<T: Config> Pallet<T>
sourcepub fn account_stakes<KArg>(
k: KArg
) -> BoundedVec<Stake<Balance, T::BlockNumber>, T::StakeAccountCap>where
KArg: EncodeLike<T::AccountId>,
pub fn account_stakes<KArg>(
k: KArg
) -> BoundedVec<Stake<Balance, T::BlockNumber>, T::StakeAccountCap>where
KArg: EncodeLike<T::AccountId>,
Account staking by CurrencyID
Trait Implementations§
source§impl<T: Config> GetStorageVersion for Pallet<T>
impl<T: Config> GetStorageVersion for Pallet<T>
source§fn current_storage_version() -> StorageVersion
fn current_storage_version() -> StorageVersion
Returns the current storage version as supported by the pallet.
source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
Returns the on-chain storage version of the pallet as stored in the storage.
source§impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> Hooks<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_idle(_n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight
fn on_idle(_n: BlockNumberFor<T>, remaining_weight: Weight) -> Weight
Try to compute when chain is idle
source§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
The block is being finalized. Implement to have something happen.
source§fn on_initialize(_n: BlockNumber) -> Weight
fn on_initialize(_n: BlockNumber) -> Weight
The block is being initialized. Implement to have something happen. Read more
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
source§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
Implementing this function on a module allows you to perform long-running tasks
that make (by default) validators generate transactions that feed results
of those long-running computations back on chain. Read more
source§fn integrity_test()
fn integrity_test()
Run integrity test. Read more
source§impl<T: Config> IntegrityTest for Pallet<T>
impl<T: Config> IntegrityTest for Pallet<T>
source§fn integrity_test()
fn integrity_test()
Run integrity test. Read more
source§impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OffchainWorker<<T as Config>::BlockNumber> for Pallet<T>
source§fn offchain_worker(n: <T as Config>::BlockNumber)
fn offchain_worker(n: <T as Config>::BlockNumber)
This function is being called after every block import (when fully synced). Read more
source§impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnFinalize<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_finalize(n: <T as Config>::BlockNumber)
fn on_finalize(n: <T as Config>::BlockNumber)
The block is being finalized. Implement to have something happen. Read more
source§impl<T: Config> OnGenesis for Pallet<T>
impl<T: Config> OnGenesis for Pallet<T>
source§fn on_genesis()
fn on_genesis()
Something that should happen at genesis.
source§impl<T: Config> OnIdle<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnIdle<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
fn on_idle(n: <T as Config>::BlockNumber, remaining_weight: Weight) -> Weight
The block is being finalized.
Implement to have something happen in case there is leftover weight.
Check the passed
remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read moresource§impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
impl<T: Config> OnInitialize<<T as Config>::BlockNumber> for Pallet<T>
source§fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
fn on_initialize(n: <T as Config>::BlockNumber) -> Weight
The block is being initialized. Implement to have something happen. Read more
source§impl<T: Config> OnRuntimeUpgrade for Pallet<T>
impl<T: Config> OnRuntimeUpgrade for Pallet<T>
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Perform a module upgrade. Read more
source§impl<T: Config> PalletInfoAccess for Pallet<T>
impl<T: Config> PalletInfoAccess for Pallet<T>
source§fn module_name() -> &'static str
fn module_name() -> &'static str
Name of the Rust module containing the pallet.
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
Version of the crate containing the pallet.
source§impl<T: Config> PalletsInfoAccess for Pallet<T>
impl<T: Config> PalletsInfoAccess for Pallet<T>
source§impl<T: Config> StakingExt<<T as Config>::AccountId> for Pallet<T>
impl<T: Config> StakingExt<<T as Config>::AccountId> for Pallet<T>
source§fn account_id() -> T::AccountId
fn account_id() -> T::AccountId
Get the staking account id where the funds are transfered
source§fn account_stakes_size() -> u64
fn account_stakes_size() -> u64
Get the size of
AccountStakes
, used to predict the weight of on_session_end
source§fn on_session_end(
session_index: SessionIndex,
session_trade_values: Vec<(CurrencyId, Balance)>,
fees_account_id: T::AccountId
) -> Result<(), DispatchError>
fn on_session_end(
session_index: SessionIndex,
session_trade_values: Vec<(CurrencyId, Balance)>,
fees_account_id: T::AccountId
) -> Result<(), DispatchError>
Triggered when a session end in the Fee pallet
source§impl<T: Config> StorageInfoTrait for Pallet<T>
impl<T: Config> StorageInfoTrait for Pallet<T>
fn storage_info() -> Vec<StorageInfo> ⓘ
source§impl<T: Config> WhitelistedStorageKeys for Pallet<T>
impl<T: Config> WhitelistedStorageKeys for Pallet<T>
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey> ⓘ
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey> ⓘ
Returns a
Vec<TrackedStorageKey>
indicating the storage keys that
should be whitelisted during benchmarking. This means that those keys
will be excluded from the benchmarking performance calculation. Read moreimpl<T> Eq for Pallet<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Pallet<T>where
T: RefUnwindSafe,
impl<T> Send for Pallet<T>where
T: Send,
impl<T> Sync for Pallet<T>where
T: Sync,
impl<T> Unpin for Pallet<T>where
T: Unpin,
impl<T> UnwindSafe for Pallet<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read moresource§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read moresource§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read moresource§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
impl<T, Outer> IsWrappedBy<Outer> for Twhere
Outer: AsRef<T> + AsMut<T> + From<T>,
T: From<Outer>,
source§impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for Twhere
T: GetStorageVersion + PalletInfoAccess,
fn migrate(db_weight: &RuntimeDbWeight) -> Weight
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T
. Read moresource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from
.source§impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
impl<T, S> UniqueSaturatedInto<T> for Swhere
T: Bounded,
S: TryInto<T>,
source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T
.