Skip to content

Create smart contract for distributions #1

@friedger

Description

@friedger

The contract should have the following tables

  • board (could be eosio.token with 21 tokens minted)

    • name
    • balance
  • members

    • name
    • balance
    • contribution_ratio
  • config

    • board_ratio (=20)
    • total_shares
    • total_board (=21)
    • payout_ongoing (=false)

There should be the following actions

  • register_board(user, seats)

    boards.put(user,seats)
    
  • register_member(user, ratio)

    members.put(user, ratio,0)
    
  • add_contribution (user, amount_hours)

    assert(!config.payout_ongoing)
    member = members.get(user)
    new_shares = amount_hours * member.contribution_ratio
    config.total_share += new_shares
    member.balance += new_shares
    
  • start_payout

      config.payout_ongoing = true
    
  • payout_amount (amount)

    assert(payout)
    assert(amount <= contract.balance)
    board_distributions = amount * config.board_ratio/100
    member_distributions = amount * (100 - config.board_ratio)/100
    for (member in members) 
       if (member.balance > 0)
         member_amount = member.balance/config.total_shares * member_distributions
         transfer(member, member_amount)
      if (has_board_seat(member))
         board_member = board.get(member)
         board_amount = board_member.balance/config.total_board * board_distributions
         transfer(member, board_amount)
    
  • end_payout

    config.payout_ongoing = false
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions