pub trait RewardsPool<AccountId> {
type AssetId;
type BlockNumber;
type PoolId;
type Balance;
// Required methods
fn create_pool(
creator: &AccountId,
staked_asset_id: Self::AssetId,
reward_asset_id: Self::AssetId,
reward_rate_per_block: Self::Balance,
expiry: DispatchTime<Self::BlockNumber>,
admin: &AccountId,
) -> Result<Self::PoolId, DispatchError>;
fn set_pool_reward_rate_per_block(
admin: &AccountId,
pool_id: Self::PoolId,
new_reward_rate_per_block: Self::Balance,
) -> DispatchResult;
fn set_pool_admin(
admin: &AccountId,
pool_id: Self::PoolId,
new_admin: AccountId,
) -> DispatchResult;
fn set_pool_expiry_block(
admin: &AccountId,
pool_id: Self::PoolId,
new_expiry: DispatchTime<Self::BlockNumber>,
) -> DispatchResult;
}Expand description
A trait for managing a rewards pool.
Required Associated Types§
Required Methods§
Sourcefn create_pool(
creator: &AccountId,
staked_asset_id: Self::AssetId,
reward_asset_id: Self::AssetId,
reward_rate_per_block: Self::Balance,
expiry: DispatchTime<Self::BlockNumber>,
admin: &AccountId,
) -> Result<Self::PoolId, DispatchError>
fn create_pool( creator: &AccountId, staked_asset_id: Self::AssetId, reward_asset_id: Self::AssetId, reward_rate_per_block: Self::Balance, expiry: DispatchTime<Self::BlockNumber>, admin: &AccountId, ) -> Result<Self::PoolId, DispatchError>
Create a new reward pool.
Parameters:
creator: The account to pay for on-chain stroage deposit;staked_asset_id: the asset to be staked in the pool;reward_asset_id: the asset to be distributed as rewards;reward_rate_per_block: the amount of reward tokens distributed per block;expiry: the block number at which the pool will cease to accumulate rewards. TheDispatchTime::Aftervariant evaluated at the execution time.admin: the account allowed to extend the pool expiration, increase the rewards rate and receive the unutilized reward tokens back after the pool completion.
Sourcefn set_pool_reward_rate_per_block(
admin: &AccountId,
pool_id: Self::PoolId,
new_reward_rate_per_block: Self::Balance,
) -> DispatchResult
fn set_pool_reward_rate_per_block( admin: &AccountId, pool_id: Self::PoolId, new_reward_rate_per_block: Self::Balance, ) -> DispatchResult
Modify a pool reward rate.
The reward rate can only be increased.
Only the pool admin may perform this operation.
Sourcefn set_pool_admin(
admin: &AccountId,
pool_id: Self::PoolId,
new_admin: AccountId,
) -> DispatchResult
fn set_pool_admin( admin: &AccountId, pool_id: Self::PoolId, new_admin: AccountId, ) -> DispatchResult
Modify a pool admin.
Only the pool admin may perform this operation.
Sourcefn set_pool_expiry_block(
admin: &AccountId,
pool_id: Self::PoolId,
new_expiry: DispatchTime<Self::BlockNumber>,
) -> DispatchResult
fn set_pool_expiry_block( admin: &AccountId, pool_id: Self::PoolId, new_expiry: DispatchTime<Self::BlockNumber>, ) -> DispatchResult
Set when the pool should expire.
The expiry block can only be extended.
Only the pool admin may perform this operation.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.