Vesting module
Closed this issue · 0 comments
xlc commented
- Types
- struct VestingSchedule
- start: BlockNumber
- period: BlockNumber
- period_count: BlockNumber
- per_period: Balance // amount of balance to grant for each
period
of blocks
- struct VestingSchedule
- Trait
- Currency: frame_support::traits::LockableCurrency
- Storages
- Vestings: map AccountId => Vec<VestingSchedule>
- Make it configuable in chain spec
- Vestings: map AccountId => Vec<VestingSchedule>
- Calls
- fn claim(origin)
- fn add_vesting(origin, from: AccountId, to: AccountId, vesting: VestingSchedule)
- transfer
amount
fromfrom
toto
and add lock
- transfer
- fn update_vesting(origin, who: AccountId, vesting: Vec<VestingSchedule>)
- ensure root
- Module
- fn claim(who: AccountId)
- update locks based on vesting schedule
- calculate how much is still locked
let locked = Self::vestings(who).map(|x| max((now - x.start) / period, 1) * amount).fold(0, |a, b| a + b)
- Set lock with this amount
- fn claim(who: AccountId)