Skip to content

implement referral logic (partly done, to implement TIMEFRAME) #6

@jellegerbrandy

Description

@jellegerbrandy

https://trello.com/c/XvBbXnjS/1-specify-referral-logic

x% out of reputation and tokens awarded to referral in time frame y from registration on top of ...
x = 10%, y = 1 month.
In a further version x can depend inversely on some measure of engagement such as the amount of reputation/tokens created via contributions.

Todo for this:

  • extend User model with a "referrer" - which is the id of the user that has given the referral
  • create_user should get an optional referrer argument
  • need to check that the referrer is an existing user in the DB, upon creation of the new user and in every action involving the referrer.
  • (the API should be correspondingly extended)
  • add contract parameters:
  1. referral_reward_fraction - this is the fraction of the referred user's gained reputation or tokens that should be rewarded to the referrer.
  2. referral_timeframe - this is the time frame in which after a new user has been created following a referral the referrer will be rewarded for the referred user's consensused contributions.
  • caclulate payout to referrer when user is awarded tokens and reputation following a consensused contribution.
    if time_since_referred_user_created <= referral_timeframe
    referrer_reputation_reward = referral_reward_fraction * earned_reputation
    referrer_token_reward = referral_reward_fraction * earned_tokens
  • it should be noted that what the referrer gets is not at the expense of the referred, i.e. the referred does not need to pay the referrer.

neet to update pseudocode:

In pseudocode:

def create_evaluation(...):
      ...
     reward_previous_evaluations
     reward_contributor

     for user in previous_evaluators + [contributor]:
          user_rep_reward_delta  = soething # the rewards the user has gotten as a contributor or prev evaluator
          if datetime.now() - user.creation_time <= self.REFERAL_TIMEFRAME:
             if user.referrer:
                   user.referrer += self.REFERAL_REWARD * user_rep_reward_delta
     # and hte same for evaluation

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions