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,
impl<T> Pallet<T>where
T: Config,
sourcepub fn inner_unstake(
account: &<T as Config>::AccountId,
smart_contract: &<T as Config>::SmartContract,
amount: u128,
) -> Result<(StakeAmount, u8), DispatchError>
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.
sourcepub fn inner_unstake_from_unregistered(
account: &<T as Config>::AccountId,
smart_contract: &<T as Config>::SmartContract,
) -> Result<(StakeAmount, u8), DispatchError>
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.
sourcepub fn inner_stake(
account: &<T as Config>::AccountId,
smart_contract: &<T as Config>::SmartContract,
amount: StakeAmount,
bonus_status: u8,
) -> Result<(), DispatchError>
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.
sourcepub fn is_staker(account: &<T as Config>::AccountId) -> bool
pub fn is_staker(account: &<T as Config>::AccountId) -> bool
true
if the account is a staker, false
otherwise.
sourcepub fn era_reward_span_index(era: u32) -> u32
pub fn era_reward_span_index(era: u32) -> u32
Calculates the EraRewardSpan
index for the specified era.
sourcepub fn unlocking_period() -> u32
pub fn unlocking_period() -> u32
Unlocking period expressed in the number of blocks.
sourcepub fn get_dapp_tier_assignment() -> BTreeMap<u16, RankedTier>
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,
impl<T> Pallet<T>where
T: Config,
sourcepub fn unbond_and_unstake(
origin: <T as Config>::RuntimeOrigin,
_contract_id: <T as Config>::SmartContract,
value: u128,
) -> Result<(), DispatchError>
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.
sourcepub fn withdraw_unbonded(
origin: <T as Config>::RuntimeOrigin,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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.
sourcepub fn maintenance_mode(
origin: <T as Config>::RuntimeOrigin,
enabled: bool,
) -> Result<(), DispatchError>
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.
sourcepub fn register(
origin: <T as Config>::RuntimeOrigin,
owner: <T as Config>::AccountId,
smart_contract: <T as Config>::SmartContract,
) -> Result<(), DispatchError>
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.
sourcepub fn set_dapp_reward_beneficiary(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
beneficiary: Option<<T as Config>::AccountId>,
) -> Result<(), DispatchError>
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.
sourcepub fn set_dapp_owner(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
new_owner: <T as Config>::AccountId,
) -> Result<(), DispatchError>
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:
- when the dApp owner account is compromised, manager can change the owner to a new account
- if project wants to transfer ownership to a new account (DAO, multisig, etc.).
sourcepub fn unregister(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
) -> Result<(), DispatchError>
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.
sourcepub fn lock(
origin: <T as Config>::RuntimeOrigin,
amount: u128,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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.
sourcepub fn unlock(
origin: <T as Config>::RuntimeOrigin,
amount: u128,
) -> Result<(), DispatchError>
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.
sourcepub fn claim_unlocked(
origin: <T as Config>::RuntimeOrigin,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
pub fn claim_unlocked( origin: <T as Config>::RuntimeOrigin, ) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
Claims all of fully unlocked chunks, removing the lock from them.
pub fn relock_unlocking( origin: <T as Config>::RuntimeOrigin, ) -> Result<(), DispatchError>
sourcepub fn stake(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
amount: u128,
) -> Result<(), DispatchError>
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.
sourcepub fn unstake(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
amount: u128,
) -> Result<(), DispatchError>
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.
sourcepub fn claim_staker_rewards(
origin: <T as Config>::RuntimeOrigin,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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.
sourcepub fn claim_bonus_reward(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
) -> Result<(), DispatchError>
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.
sourcepub fn claim_dapp_reward(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
era: u32,
) -> Result<(), DispatchError>
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.
sourcepub fn unstake_from_unregistered(
origin: <T as Config>::RuntimeOrigin,
smart_contract: <T as Config>::SmartContract,
) -> Result<(), DispatchError>
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.
sourcepub fn cleanup_expired_entries(
origin: <T as Config>::RuntimeOrigin,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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:
- It’s from a past period & the account did not maintain an eligible bonus status, meaning there’s no claimable bonus reward.
- It’s from a period older than the oldest claimable period, regardless of whether the account had an eligible bonus status or not.
sourcepub fn force(
origin: <T as Config>::RuntimeOrigin,
forcing_type: ForcingType,
) -> Result<(), DispatchError>
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.
sourcepub fn claim_staker_rewards_for(
origin: <T as Config>::RuntimeOrigin,
account: <T as Config>::AccountId,
) -> Result<PostDispatchInfo, DispatchErrorWithPostInfo<PostDispatchInfo>>
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.
sourcepub fn claim_bonus_reward_for(
origin: <T as Config>::RuntimeOrigin,
account: <T as Config>::AccountId,
smart_contract: <T as Config>::SmartContract,
) -> Result<(), DispatchError>
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.
sourcepub 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>>
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.
sourcepub fn set_static_tier_params(
origin: <T as Config>::RuntimeOrigin,
params: TierParameters<<T as Config>::NumberOfTiers>,
) -> Result<(), DispatchError>
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,
impl<T> BeforeAllRuntimeMigrations for Pallet<T>where
T: Config,
source§fn before_all_runtime_migrations() -> Weight
fn before_all_runtime_migrations() -> Weight
source§impl<T> GetStorageVersion for Pallet<T>where
T: Config,
impl<T> GetStorageVersion for Pallet<T>where
T: Config,
§type InCodeStorageVersion = StorageVersion
type InCodeStorageVersion = StorageVersion
source§fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
fn in_code_storage_version() -> <Pallet<T> as GetStorageVersion>::InCodeStorageVersion
storage_version
attribute, or
[NoStorageVersionSet
] if the attribute is missing.source§fn on_chain_storage_version() -> StorageVersion
fn on_chain_storage_version() -> StorageVersion
§fn current_storage_version() -> Self::InCodeStorageVersion
fn current_storage_version() -> Self::InCodeStorageVersion
in_code_storage_version
and will be removed after March 2024.Self::current_storage_version
] instead. Read moresource§impl<T> Hooks<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
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
fn on_initialize( now: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
source§fn on_idle(
_block: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number,
remaining_weight: Weight,
) -> Weight
fn on_idle( _block: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, remaining_weight: Weight, ) -> Weight
Hooks::on_finalize
]). Read moresource§fn integrity_test()
fn integrity_test()
§fn on_finalize(_n: BlockNumber)
fn on_finalize(_n: BlockNumber)
§fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
fn on_poll(_n: BlockNumber, _weight: &mut WeightMeter)
§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Executive
pallet. Read more§fn offchain_worker(_n: BlockNumber)
fn offchain_worker(_n: BlockNumber)
source§impl<T> IntegrityTest for Pallet<T>where
T: Config,
impl<T> IntegrityTest for Pallet<T>where
T: Config,
source§fn integrity_test()
fn integrity_test()
Hooks::integrity_test
].source§impl<T> OffchainWorker<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
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,
)
fn offchain_worker( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
source§impl<T> OnFinalize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
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,
)
fn on_finalize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, )
Hooks::on_finalize
].source§impl<T> OnGenesis for Pallet<T>where
T: Config,
impl<T> OnGenesis for Pallet<T>where
T: Config,
source§fn on_genesis()
fn on_genesis()
source§impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnIdle<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
source§impl<T> OnInitialize<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
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
fn on_initialize( n: <<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number, ) -> Weight
Hooks::on_initialize
].source§impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
impl<T> OnPoll<<<<T as Config>::Block as HeaderProvider>::HeaderT as Header>::Number> for Pallet<T>where
T: Config,
source§impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
impl<T> OnRuntimeUpgrade for Pallet<T>where
T: Config,
source§fn on_runtime_upgrade() -> Weight
fn on_runtime_upgrade() -> Weight
Hooks::on_runtime_upgrade
].source§impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
impl<T> PalletInfoAccess for Pallet<T>where
T: Config,
source§fn module_name() -> &'static str
fn module_name() -> &'static str
source§fn crate_version() -> CrateVersion
fn crate_version() -> CrateVersion
source§impl<T> PartialEq for Pallet<T>
impl<T> PartialEq for Pallet<T>
source§impl<T> SafeModeNotify for Pallet<T>where
T: Config,
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§impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
impl<T> StorageInfoTrait for Pallet<T>where
T: Config,
fn storage_info() -> Vec<StorageInfo>
source§impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
impl<T> WhitelistedStorageKeys for Pallet<T>where
T: Config,
source§fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
fn whitelisted_storage_keys() -> Vec<TrackedStorageKey>
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.