Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic token distribution pallet #229

Open
arrudagates opened this issue Apr 3, 2024 · 0 comments
Open

Automatic token distribution pallet #229

arrudagates opened this issue Apr 3, 2024 · 0 comments

Comments

@arrudagates
Copy link
Member

arrudagates commented Apr 3, 2024

Pallet

enum List {
  Simple(Vec<AccountId>),
  Weighted(Vec<(AccountId, u32)>)
}

trait ListSourceTrait {
  fn get_list(&self) -> List;
}

trait config {
  type ListSource: ListSourceTrait
}

storages {
  CustomLists: Hash -> List;

  RegisteredAddresses: AccountId -> T::ListSource;
}

calls {
  fn distribute_to_list(list: T::ListSource, amount: Balance);

  fn register_address_to_list(list: T::ListSource); // Creates a pure proxy

  fn distribute_to_address(address: AccountId); // search RegisteredAddresses for the list
}

struct CustomListSource(Hash);

impl CustomListSource {
  fn get(hash: Hash) -> List { Self(hash).get_list() }
}

impl ListSourceTrait for CustomListSource {
  fn get_list(&self) -> List { CustomLists::get(self.0) }
}

Runtime

enum ListSource {
  CoreMembers(CoreId),
  CoreMembersWeighted(CoreId),
  OcifCoreStakers(CoreId),
  OcifCoreStakersWeighted(CoreId),
  CustomList(Hash)
}

impl ListSourceTrait for ListSource {
  fn get_list(&self) -> List {
    match self {
      CoreMembers => // get core members and return List::Simple
      CoreMembersWeighted => // get core members and return List::Weighted
      OcifCoreStakers => // get core stakers and return List::Simple
      OcifCoreStakersWeighted => // get core stakers and return List::Weighted
      CustomList(hash) => // pallet::CustomListSource::get(hash)
    }
  }
}

impl Pallet {
  type ListSource = ListSource;
}

Research

How can we have pallet_balances transfers automatically distribute through this pallet if the address lookup returns a list (without modifying pallet_balances as it's a foundational pallet of the network).

It would need to return proper weights, as these lists can be massive and would definitely use more weight than the amount allocated to a simple balance transfer.

This would definitely be really interesting, but if we decide not to hook into pallet_balances then we also don't need to have the RegisteredAccounts storage and we don't have to generate accounts that map to lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant