referrerpolicy=no-referrer-when-downgrade
polkadot_sdk_frame::token::currency

Trait VestingSchedule

pub trait VestingSchedule<AccountId> {
    type Moment;
    type Currency: Currency<AccountId>;

    // Required methods
    fn vesting_balance(
        who: &AccountId,
    ) -> Option<<Self::Currency as Currency<AccountId>>::Balance>;
    fn add_vesting_schedule(
        who: &AccountId,
        locked: <Self::Currency as Currency<AccountId>>::Balance,
        per_block: <Self::Currency as Currency<AccountId>>::Balance,
        starting_block: Self::Moment,
    ) -> Result<(), DispatchError>;
    fn can_add_vesting_schedule(
        who: &AccountId,
        locked: <Self::Currency as Currency<AccountId>>::Balance,
        per_block: <Self::Currency as Currency<AccountId>>::Balance,
        starting_block: Self::Moment,
    ) -> Result<(), DispatchError>;
    fn remove_vesting_schedule(
        who: &AccountId,
        schedule_index: u32,
    ) -> Result<(), DispatchError>;
}
Expand description

A vesting schedule over a currency. This allows a particular currency to have vesting limits applied to it.

Required Associated Types§

type Moment

The quantity used to denote time; usually just a BlockNumber.

type Currency: Currency<AccountId>

The currency that this schedule applies to.

Required Methods§

fn vesting_balance( who: &AccountId, ) -> Option<<Self::Currency as Currency<AccountId>>::Balance>

Get the amount that is currently being vested and cannot be transferred out of this account. Returns None if the account has no vesting schedule.

fn add_vesting_schedule( who: &AccountId, locked: <Self::Currency as Currency<AccountId>>::Balance, per_block: <Self::Currency as Currency<AccountId>>::Balance, starting_block: Self::Moment, ) -> Result<(), DispatchError>

Adds a vesting schedule to a given account.

If the account has MaxVestingSchedules, an Error is returned and nothing is updated.

Is a no-op if the amount to be vested is zero.

NOTE: This doesn’t alter the free balance of the account.

fn can_add_vesting_schedule( who: &AccountId, locked: <Self::Currency as Currency<AccountId>>::Balance, per_block: <Self::Currency as Currency<AccountId>>::Balance, starting_block: Self::Moment, ) -> Result<(), DispatchError>

Checks if add_vesting_schedule would work against who.

fn remove_vesting_schedule( who: &AccountId, schedule_index: u32, ) -> Result<(), DispatchError>

Remove a vesting schedule for a given account.

NOTE: This doesn’t alter the free balance of the account.

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.

Implementors§

impl<T: Config> VestingSchedule<<T as Config>::AccountId> for Pallet<T>
where <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance: MaybeSerializeDeserialize + Debug,