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

Trait VestedTransfer

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

    // Required method
    fn vested_transfer(
        source: &AccountId,
        target: &AccountId,
        locked: <Self::Currency as Currency<AccountId>>::Balance,
        per_block: <Self::Currency as Currency<AccountId>>::Balance,
        starting_block: Self::Moment,
    ) -> Result<(), DispatchError>;
}
Expand description

A vested transfer over a currency. This allows a transferred amount to vest over time.

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 vested_transfer( source: &AccountId, target: &AccountId, locked: <Self::Currency as Currency<AccountId>>::Balance, per_block: <Self::Currency as Currency<AccountId>>::Balance, starting_block: Self::Moment, ) -> Result<(), DispatchError>

Execute a vested transfer from source to target with the given schedule: - locked: The amount to be transferred and for the vesting schedule to apply to. - per_block: The amount to be unlocked each block. (linear vesting) - starting_block: The block where the vesting should start. This block can be in the past or future, and should adjust when the tokens become available to the user.

Example: Assume we are on block 100. If locked amount is 100, and per_block is 1: - If starting_block is 0, then the whole 100 tokens will be available right away as the vesting schedule started in the past and has fully completed. - If starting_block is 50, then 50 tokens are made available right away, and 50 more tokens will unlock one token at a time until block 150. - If starting_block is 100, then each block, 1 token will be unlocked until the whole balance is unlocked at block 200. - If starting_block is 200, then the 100 token balance will be completely locked until block 200, and then start to unlock one token at a time until block 300.

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> VestedTransfer<<T as Config>::AccountId> for Pallet<T>
where <<T as Config>::Currency as Currency<<T as Config>::AccountId>>::Balance: MaybeSerializeDeserialize + Debug,