Beispiel #1
0
    def __init__(self,
                 hatchers=5,
                 proposals=2,
                 hatch_tribute=0.2,
                 vesting_80p_unlocked=60,
                 exit_tribute=0.35,
                 kappa=2,
                 days_to_80p_of_max_voting_weight=10,
                 max_proposal_request=0.2,
                 timesteps_days=730,
                 random_seed=None):
        self.hatchers = hatchers
        self.proposals = proposals
        self.hatch_tribute = hatch_tribute

        # 60 is 2 months until 80% of tokens are unlocked
        self.vesting_80p_unlocked = vesting_80p_unlocked
        self.exit_tribute = exit_tribute
        self.kappa = kappa  # This is the shape of the bonding curve
        self.days_to_80p_of_max_voting_weight = days_to_80p_of_max_voting_weight

        # Proposal may only request up to 20% of the funding pool
        self.max_proposal_request = max_proposal_request

        self.timesteps_days = timesteps_days  # Simulate 2*365=730 days

        self.random_seed = random_seed
        self.probability_func = new_probability_func(random_seed)
        self.exponential_func = new_exponential_func(random_seed)
        self.gamma_func = new_gamma_func(random_seed)
        self.random_number_func = new_random_number_func(random_seed)
        self.choice_func = new_choice_func(random_seed)
Beispiel #2
0
    def setUp(self):
        self.params = {
            "debug": True,
            "probability_func": new_probability_func(seed=None),
            "exponential_func": new_exponential_func(seed=None),
            "gamma_func": new_gamma_func(seed=None),
            "random_number_func": new_random_number_func(seed=None)
        }
        vesting_participants = [
            TokenBatch(1000, 1000, vesting_options=VestingOptions(10, 30))
            for _ in range(2)
        ]
        nonvesting_participants = [
            TokenBatch(0, 1000, vesting_options=VestingOptions(10, 30))
            for _ in range(2)
        ]
        self.network = bootstrap_network(
            vesting_participants + nonvesting_participants, 1, 3000, 4e6, 0.2,
            self.params["probability_func"], self.params["random_number_func"],
            self.params["gamma_func"], self.params["exponential_func"])
        self.commons = Commons(1000, 1000)

        self.network, _ = add_proposal(self.network, Proposal(100, 1),
                                       self.params["random_number_func"])
        self.default_state = {
            "network": self.network,
            "commons": self.commons,
            "funding_pool": 1000,
            "token_supply": 1000
        }
Beispiel #3
0
def get_simulation_results(c):
    df = run_simulation(c)
    df_final = df[df.substep.eq(2)]
    random_func = new_random_number_func(None)

    last_network = df_final.iloc[-1, 0]
    candidates = len(
        get_proposals(last_network, status=ProposalStatus.CANDIDATE))
    actives = len(get_proposals(last_network, status=ProposalStatus.ACTIVE))
    completed = len(
        get_proposals(last_network, status=ProposalStatus.COMPLETED))
    failed = len(get_proposals(last_network, status=ProposalStatus.FAILED))
    participants = len(get_participants(last_network))

    score = CommonsScore(params=c, df_final=df_final)

    result = {
        "timestep": list(df_final["timestep"]),
        "funding_pool": list(df_final["funding_pool"]),
        "token_price": list(df_final["token_price"]),
        "sentiment": list(df_final["sentiment"]),
        "score": score.eval(),
        "participants": participants,
        "proposals": {
            "candidates": candidates,
            "actives": actives,
            "completed": completed,
            "failed": failed,
            "total": candidates + actives + completed + failed
        }
    }
    return result, df_final
Beispiel #4
0
    def setUp(self):
        self.params = {
            "debug": False,
            "days_to_80p_of_max_voting_weight": 10,
            "probability_func": new_probability_func(seed=None),
            "exponential_func": new_exponential_func(seed=None),
            "gamma_func": new_gamma_func(seed=None),
            "random_number_func": new_random_number_func(seed=None)
        }
        self.network = bootstrap_network([
            TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2, self.params["probability_func"],
                                         self.params["random_number_func"],
                                         self.params["gamma_func"],
                                         self.params["exponential_func"])

        self.network, _ = add_proposal(self.network, Proposal(100, 1),
                                       self.params["random_number_func"])
        """
        For proper testing, we need to make sure the Proposals are CANDIDATE and
        ensure Proposal-Participant affinities are not some random value
        """
        self.network.nodes[4]["item"].status = ProposalStatus.CANDIDATE
        self.network.nodes[5]["item"].status = ProposalStatus.CANDIDATE
        support_edges = get_edges_by_type(self.network, "support")
        for u, v in support_edges:
            self.network[u][v]["support"] = self.network[u][v][
                "support"]._replace(affinity=0.9)
Beispiel #5
0
def get_simulation_results(c):
    df = run_simulation(c)
    df_final = df[df.substep.eq(2)]
    random_func = new_random_number_func(None)

    result = {
        "timestep": list(df_final["timestep"]),
        "funding_pool": list(df_final["funding_pool"]),
        "token_price": list(df_final["token_price"]),
        "sentiment": list(df_final["sentiment"]),
        "score": int(random_func() * 1000)
    }
    return result, df_final
Beispiel #6
0
 def setUp(self):
     self.params = {
         "debug": True,
         "probability_func": new_probability_func(seed=None),
         "exponential_func": new_exponential_func(seed=None),
         "gamma_func": new_gamma_func(seed=None),
         "random_number_func": new_random_number_func(seed=None)
     }
     self.network = bootstrap_network([
         TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
         for _ in range(4)
     ], 1, 3000, 4e6, 0.2, self.params["probability_func"],
                                      self.params["random_number_func"],
                                      self.params["gamma_func"],
                                      self.params["exponential_func"])
Beispiel #7
0
    def setUp(self):
        self.network = nx.DiGraph()
        self.params = {
            "probability_func": new_probability_func(seed=None),
            "exponential_func": new_exponential_func(seed=None),
            "gamma_func": new_gamma_func(seed=None),
            "random_number_func": new_random_number_func(seed=None)
        }

        for i in range(0, 10, 2):
            self.network.add_node(i,
                                  item=Participant(
                                      TokenBatch(0, 0),
                                      self.params["probability_func"],
                                      self.params["random_number_func"]))
            self.network.add_node(i + 1, item=Proposal(10, 5))
Beispiel #8
0
    def setUp(self):
        self.params = {
            "probability_func": new_probability_func(seed=None),
            "exponential_func": new_exponential_func(seed=None),
            "gamma_func": new_gamma_func(seed=None),
            "random_number_func": new_random_number_func(seed=None)
        }
        self.network = bootstrap_network([
            TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2, self.params["probability_func"],
                                         self.params["random_number_func"],
                                         self.params["gamma_func"],
                                         self.params["exponential_func"])

        self.network, _ = add_proposal(self.network, Proposal(100, 1),
                                       self.params["random_number_func"])

        self.network.nodes[4]["item"].status = ProposalStatus.ACTIVE
        self.network.nodes[5]["item"].status = ProposalStatus.ACTIVE
Beispiel #9
0
    def setUp(self):
        self.params = {
            "max_proposal_request": 0.2,
            "alpha_days_to_80p_of_max_voting_weight": 10,
            "probability_func": new_probability_func(seed=None),
            "exponential_func": new_exponential_func(seed=None),
            "gamma_func": new_gamma_func(seed=None),
            "random_number_func": new_random_number_func(seed=None)
        }
        self.commons = Commons(1000, 1000)
        self.network = bootstrap_network([
            TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2, self.params["probability_func"],
                                         self.params["random_number_func"],
                                         self.params["gamma_func"],
                                         self.params["exponential_func"])

        self.network, _ = add_proposal(self.network, Proposal(100, 1),
                                       self.params["random_number_func"])

        self.network.nodes[4]["item"].status = ProposalStatus.CANDIDATE
        self.network.nodes[5]["item"].status = ProposalStatus.CANDIDATE
Beispiel #10
0
 def test_new_random_number_func(self):
     random_number_func = utils.new_random_number_func(seed=None)
     result = random_number_func()
     self.assertTrue(result >= 0 and result <= 1)