open-web3-stack/open-runtime-module-library

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
  • Trait
    • Currency: frame_support::traits::LockableCurrency
  • Storages
    • Vestings: map AccountId => Vec<VestingSchedule>
      • Make it configuable in chain spec
  • Calls
    • fn claim(origin)
    • fn add_vesting(origin, from: AccountId, to: AccountId, vesting: VestingSchedule)
      • transfer amount from from to to and add lock
    • 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