Type Alias astar_runtime::DappStaking

source ·
pub type DappStaking = Pallet<Runtime>;

Aliased Type§

struct DappStaking(/* private fields */);

Implementations

source§

impl<T> Pallet<T>
where T: Config,

source

pub fn inner_unstake( account: &<T as Config>::AccountId, smart_contract: &<T as Config>::SmartContract, amount: u128, ) -> Result<(StakeAmount, u8), DispatchError>

Inner unstake functionality for an active smart contract. If successful returns the StakeAmount that was unstaked, and the updated bonus status.

  • Ensures the contract is still registered.
  • Updates staker info, ledger, and contract stake info.
  • Returns the unstaked amount and updated bonus status.
source

pub fn inner_unstake_from_unregistered( account: &<T as Config>::AccountId, smart_contract: &<T as Config>::SmartContract, ) -> Result<(StakeAmount, u8), DispatchError>

Handles unstaking from an unregistered smart contract.

  • Ensures the contract is no longer active.
  • Updates staker info and ledger.
  • Returns the unstaked amount and preserves the original bonus status.
source

pub fn inner_stake( account: &<T as Config>::AccountId, smart_contract: &<T as Config>::SmartContract, amount: StakeAmount, bonus_status: u8, ) -> Result<(), DispatchError>

Inner stake functionality.

Specifies the amount in the form of the StakeAmount struct, allowing simultaneous update of both voting and build_and_earn amounts. The bonus_status is used to determine if the staker is still eligible for the bonus reward. This is useful for the move extrinsic.

source

pub fn is_staker(account: &<T as Config>::AccountId) -> bool

true if the account is a staker, false otherwise.

source

pub fn era_reward_span_index(era: u32) -> u32

Calculates the EraRewardSpan index for the specified era.

source

pub fn unlocking_period() -> u32

Unlocking period expressed in the number of blocks.

source

pub fn get_dapp_tier_assignment() -> BTreeMap<u16, RankedTier>

Returns the dApp tier assignment for the current era, based on the current stake amounts.

source§

impl<T> Pallet<T>
where T: Config,

source

pub fn unbond_and_unstake( origin: <T as Config>::RuntimeOrigin, _contract_id: <T as Config>::SmartContract, value: u128, ) -> Result<(), DispatchError>

Wrapper around legacy-like unbond_and_unstake.

Used to support legacy Ledger users so they can start the unlocking process for their funds.

source

pub fn withdraw_unbonded( origin: <T as Config>::RuntimeOrigin, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Wrapper around legacy-like withdraw_unbonded.

Used to support legacy Ledger users so they can reclaim unlocked chunks back into their transferable free balance.

source

pub fn maintenance_mode( origin: <T as Config>::RuntimeOrigin, enabled: bool, ) -> Result<(), DispatchError>

Used to enable or disable maintenance mode. Can only be called by manager origin.

source

pub fn register( origin: <T as Config>::RuntimeOrigin, owner: <T as Config>::AccountId, smart_contract: <T as Config>::SmartContract, ) -> Result<(), DispatchError>

Used to register a new contract for dApp staking.

If successful, smart contract will be assigned a simple, unique numerical identifier. Owner is set to be initial beneficiary & manager of the dApp.

source

pub fn set_dapp_reward_beneficiary( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, beneficiary: Option<<T as Config>::AccountId>, ) -> Result<(), DispatchError>

Used to modify the reward beneficiary account for a dApp.

Caller has to be dApp owner. If set to None, rewards will be deposited to the dApp owner. After this call, all existing & future rewards will be paid out to the beneficiary.

source

pub fn set_dapp_owner( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, new_owner: <T as Config>::AccountId, ) -> Result<(), DispatchError>

Used to change dApp owner.

Can be called by dApp owner or dApp staking manager origin. This is useful in two cases:

  1. when the dApp owner account is compromised, manager can change the owner to a new account
  2. if project wants to transfer ownership to a new account (DAO, multisig, etc.).
source

pub fn unregister( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, ) -> Result<(), DispatchError>

Unregister dApp from dApp staking protocol, making it ineligible for future rewards. This doesn’t remove the dApp completely from the system just yet, but it can no longer be used for staking.

Can be called by dApp staking manager origin.

source

pub fn lock( origin: <T as Config>::RuntimeOrigin, amount: u128, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Locks additional funds into dApp staking.

In case caller account doesn’t have sufficient balance to cover the specified amount, everything is locked. After adjustment, lock amount must be greater than zero and in total must be equal or greater than the minimum locked amount.

Locked amount can immediately be used for staking.

source

pub fn unlock( origin: <T as Config>::RuntimeOrigin, amount: u128, ) -> Result<(), DispatchError>

Attempts to start the unlocking process for the specified amount.

Only the amount that isn’t actively used for staking can be unlocked. If the amount is greater than the available amount for unlocking, everything is unlocked. If the remaining locked amount would take the account below the minimum locked amount, everything is unlocked.

source

pub fn claim_unlocked( origin: <T as Config>::RuntimeOrigin, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Claims all of fully unlocked chunks, removing the lock from them.

source

pub fn relock_unlocking( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>

source

pub fn stake( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, amount: u128, ) -> Result<(), DispatchError>

Stake the specified amount on a smart contract. The precise amount specified must be available for staking. The total amount staked on a dApp must be greater than the minimum required value.

Depending on the period type, appropriate stake amount will be updated. During Voting subperiod, voting stake amount is updated, and same for Build&Earn subperiod.

Staked amount is only eligible for rewards from the next era onwards.

source

pub fn unstake( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, amount: u128, ) -> Result<(), DispatchError>

Unstake the specified amount from a smart contract. The amount specified must not exceed what’s staked, otherwise the call will fail.

If unstaking the specified amount would take staker below the minimum stake threshold, everything is unstaked.

Depending on the period type, appropriate stake amount will be updated. In case amount is unstaked during Voting subperiod, the voting amount is reduced. In case amount is unstaked during Build&Earn subperiod, first the build_and_earn is reduced, and any spillover is subtracted from the voting amount.

source

pub fn claim_staker_rewards( origin: <T as Config>::RuntimeOrigin, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Claims some staker rewards, if user has any. In the case of a successful call, at least one era will be claimed, with the possibility of multiple claims happening.

source

pub fn claim_bonus_reward( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, ) -> Result<(), DispatchError>

Used to claim bonus reward for a smart contract, if eligible.

source

pub fn claim_dapp_reward( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, era: u32, ) -> Result<(), DispatchError>

Used to claim dApp reward for the specified era.

source

pub fn unstake_from_unregistered( origin: <T as Config>::RuntimeOrigin, smart_contract: <T as Config>::SmartContract, ) -> Result<(), DispatchError>

Used to unstake funds from a contract that was unregistered after an account staked on it. This is required if staker wants to re-stake these funds on another active contract during the ongoing period.

source

pub fn cleanup_expired_entries( origin: <T as Config>::RuntimeOrigin, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Cleanup expired stake entries for the contract.

Entry is considered to be expired if:

  1. It’s from a past period & the account did not maintain an eligible bonus status, meaning there’s no claimable bonus reward.
  2. It’s from a period older than the oldest claimable period, regardless of whether the account had an eligible bonus status or not.
source

pub fn force( origin: <T as Config>::RuntimeOrigin, forcing_type: ForcingType, ) -> Result<(), DispatchError>

Used to force a change of era or subperiod. The effect isn’t immediate but will happen on the next block.

Used for testing purposes, when we want to force an era change, or a subperiod change. Not intended to be used in production, except in case of unforeseen circumstances.

Can only be called by the root origin.

source

pub fn claim_staker_rewards_for( origin: <T as Config>::RuntimeOrigin, account: <T as Config>::AccountId, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Claims some staker rewards for the specified account, if they have any. In the case of a successful call, at least one era will be claimed, with the possibility of multiple claims happening.

source

pub fn claim_bonus_reward_for( origin: <T as Config>::RuntimeOrigin, account: <T as Config>::AccountId, smart_contract: <T as Config>::SmartContract, ) -> Result<(), DispatchError>

Used to claim bonus reward for a smart contract on behalf of the specified account, if eligible.

source

pub fn move_stake( origin: <T as Config>::RuntimeOrigin, source_contract: <T as Config>::SmartContract, destination_contract: <T as Config>::SmartContract, amount: u128, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>

Transfers stake between two smart contracts, ensuring bonus status preservation if eligible. Emits a StakeMoved event.

source

pub fn set_static_tier_params( origin: <T as Config>::RuntimeOrigin, params: TierParameters<<T as Config>::NumberOfTiers>, ) -> Result<(), DispatchError>

Used to set static tier parameters, which are used to calculate tier configuration. Tier configuration defines tier entry threshold values, number of slots, and reward portions.

This is a delicate call and great care should be taken when changing these values since it has a significant impact on the reward system.

Trait Implementations

source§

impl<T> BeforeAllRuntimeMigrations for Pallet<T>
where T: Config,

source§

fn before_all_runtime_migrations() -> Weight

Something that should happen before runtime migrations are executed.
source§

impl<T> Callable<T> for Pallet<T>
where T: Config,

source§

impl<T> Clone for Pallet<T>

source§

fn clone(&self) -> Pallet<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for Pallet<T>

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<T> GetStorageVersion for Pallet<T>
where T: Config,

§

type InCodeStorageVersion = StorageVersion

This type is generated by the pallet macro. Read more
source§

fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion

Returns the in-code storage version as specified in the storage_version attribute, or [NoStorageVersionSet] if the attribute is missing.
source§

fn on_chain_storage_version() -> StorageVersion

Returns the storage version of the pallet as last set in the actual on-chain storage.
§

fn current_storage_version() -> Self::InCodeStorageVersion

👎Deprecated: This method has been renamed to in_code_storage_version and will be removed after March 2024.
DEPRECATED: Use [Self::current_storage_version] instead. Read more
source§

impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

source§

fn on_initialize( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight

Block initialization hook. This is called at the very beginning of block execution. Read more
source§

fn on_idle( _block: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, remaining_weight: Weight, ) -> Weight

Hook to consume a block’s idle time. This will run when the block is being finalized (before [Hooks::on_finalize]). Read more
source§

fn integrity_test()

Check the integrity of this pallet’s configuration. Read more
§

fn on_finalize(_n: BlockNumber)

Block finalization hook. This is called at the very end of block execution. Read more
§

fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)

A hook to run logic after inherent application. Read more
§

fn on_runtime_upgrade() -> Weight

Hook executed when a code change (aka. a “runtime upgrade”) is detected by the FRAME Executive pallet. Read more
§

fn offchain_worker(_n: BlockNumber)

Implementing this function on a pallet allows you to perform long-running tasks that are dispatched as separate threads, and entirely independent of the main blockchain execution. Read more
source§

impl<T> IntegrityTest for Pallet<T>
where T: Config,

source§

fn integrity_test()

See [Hooks::integrity_test].
source§

impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

source§

fn offchain_worker( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )

This function is being called after every block import (when fully synced). Read more
source§

impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

source§

fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )

See [Hooks::on_finalize].
source§

impl<T> OnGenesis for Pallet<T>
where T: Config,

source§

fn on_genesis()

Something that should happen at genesis.
source§

impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

source§

fn on_idle( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, remaining_weight: Weight, ) -> Weight

See [Hooks::on_idle].
source§

impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

source§

fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight

See [Hooks::on_initialize].
source§

impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>
where T: Config,

source§

fn on_poll( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, weight: &mut WeightMeter, )

Code to execute every now and then at the beginning of the block after inherent application. Read more
source§

impl<T> OnRuntimeUpgrade for Pallet<T>
where T: Config,

source§

fn on_runtime_upgrade() -> Weight

See [Hooks::on_runtime_upgrade].
source§

impl<T> PalletInfoAccess for Pallet<T>
where T: Config,

source§

fn index() -> usize

Index of the pallet as configured in the runtime.
source§

fn name() -> &'static str

Name of the pallet as configured in the runtime.
source§

fn name_hash() -> [u8; 16]

Two128 hash of name.
source§

fn module_name() -> &'static str

Name of the Rust module containing the pallet.
source§

fn crate_version() -> CrateVersion

Version of the crate containing the pallet.
source§

impl<T> PalletsInfoAccess for Pallet<T>
where T: Config,

source§

fn count() -> usize

The number of pallets’ information that this type represents. Read more
source§

fn infos() -> Vec<PalletInfoData>

All of the pallets’ information that this type represents.
source§

impl<T> PartialEq for Pallet<T>

source§

fn eq(&self, other: &Pallet<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> SafeModeNotify for Pallet<T>
where T: Config,

Implementation of the SafeModeNotify trait for the DappStaking pallet. This integration ensures that the dApp staking protocol transitions to and from maintenance mode when the runtime enters or exits safe mode.

source§

fn entered()

Called when the runtime enters safe mode.
source§

fn exited()

Called when the runtime exits safe mode.
source§

impl<T> StorageInfoTrait for Pallet<T>
where T: Config,

source§

fn storage_info() -> Vec<StorageInfo>

source§

impl<T> WhitelistedStorageKeys for Pallet<T>
where T: Config,

source§

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.
source§

impl<T> Eq for Pallet<T>