def bootstrap_simulation(c: CommonsSimulationConfiguration):
    contributions = [np.random.rand() * 10e5 for i in range(c.hatchers)]
    token_batches, initial_token_supply = create_token_batches(
        contributions, 0.1, c.vesting_80p_unlocked)

    commons = Commons(sum(contributions), initial_token_supply,
                      hatch_tribute=c.hatch_tribute, exit_tribute=c.exit_tribute, kappa=c.kappa)
    network = bootstrap_network(
        token_batches, c.proposals, commons._funding_pool, commons._token_supply, c.max_proposal_request)

    initial_conditions = {
        "network": network,
        "commons": commons,
        "funding_pool": commons._funding_pool,
        "collateral_pool": commons._collateral_pool,
        "token_supply": commons._token_supply,
        "sentiment": 0.5
    }

    # TODO: make it explicit that 1 timestep is 1 day
    simulation_parameters = {
        'T': range(30),
        'N': 1,
        'M': {
            # "sentiment_decay": 0.01, #termed mu in the state update function
            # "min_proposal_age_days": 7, # minimum periods passed before a proposal can pass,
            # "sentiment_sensitivity": 0.75,
            # 'min_supp':50, #number of tokens that must be stake for a proposal to be a candidate
            "debug": True,
            "days_to_80p_of_max_voting_weight": c.days_to_80p_of_max_voting_weight,
            "max_proposal_request": c.max_proposal_request,
        }
    }

    return initial_conditions, simulation_parameters
Esempio n. 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
        }
Esempio n. 3
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)
    def setUp(self):
        self.commons = Commons(10000, 1000)
        self.sentiment = 0.5
        self.network = bootstrap_network([
            TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2)

        self.params = {"debug": False}
Esempio n. 5
0
    def setUp(self):
        self.network = bootstrap_network(
            [TokenBatch(1000, VestingOptions(10, 30)) for _ in range(4)], 1,
            3000, 4e6)

        self.network, _ = add_proposal(self.network, Proposal(100, 1))

        self.network.nodes[4]["item"].status = ProposalStatus.ACTIVE
        self.network.nodes[5]["item"].status = ProposalStatus.ACTIVE
Esempio n. 6
0
def bootstrap_simulation(c: CommonsSimulationConfiguration):
    contributions = [c.random_number_func() * 10e5 for i in range(c.hatchers)]
    cliff_days, halflife_days = c.cliff_and_halflife()
    token_batches, initial_token_supply = create_token_batches(
        contributions, 0.1, cliff_days, halflife_days)

    commons = Commons(sum(contributions),
                      initial_token_supply,
                      hatch_tribute=c.hatch_tribute,
                      exit_tribute=c.exit_tribute,
                      kappa=c.kappa)
    network = bootstrap_network(token_batches, c.proposals,
                                commons._funding_pool, commons._token_supply,
                                c.max_proposal_request, c.probability_func,
                                c.random_number_func, c.gamma_func,
                                c.exponential_func)

    initial_conditions = {
        "network": network,
        "commons": commons,
        "funding_pool": commons._funding_pool,
        "collateral_pool": commons._collateral_pool,
        "token_supply": commons._token_supply,
        "token_price": commons.token_price(),
        "policy_output": None,
        "sentiment": 0.75
    }

    simulation_parameters = {
        'T': range(c.timesteps_days),
        'N': 1,
        'M': {
            # "sentiment_decay": 0.01, #termed mu in the state update function
            # "min_proposal_age_days": 7, # minimum periods passed before a proposal can pass,
            # "sentiment_sensitivity": 0.75,
            # 'min_supp':50, #number of tokens that must be stake for a proposal to be a candidate
            "debug": False,
            "alpha_days_to_80p_of_max_voting_weight": c.alpha(),
            "max_proposal_request": c.max_proposal_request,
            "random_seed": c.random_seed,
            "probability_func": c.probability_func,
            "exponential_func": c.exponential_func,
            "gamma_func": c.gamma_func,
            "random_number_func": c.random_number_func,
            "choice_func": c.choice_func,
            "speculation_days": c.speculation_days,
            "multiplier_new_participants": c.multiplier_new_participants
        }
    }

    return initial_conditions, simulation_parameters
    def setUp(self):
        self.network = bootstrap_network([
            TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2)

        self.network, _ = add_proposal(self.network, Proposal(100, 1))

        self.network.nodes[4]["item"].status = ProposalStatus.CANDIDATE
        self.network.nodes[5]["item"].status = ProposalStatus.CANDIDATE
        self.params = {
            "max_proposal_request": 0.2,
            "alpha_days_to_80p_of_max_voting_weight": 10
        }
    def test_bootstrap_network(self):
        """
        Tests that the network was created and that the subcomponents work too.
        """
        token_batches = [TokenBatch(1000, VestingOptions(10, 30))
                         for _ in range(4)]
        network = bootstrap_network(token_batches, 1, 3000, 4e6, 0.2)

        edges = list(network.edges(data="type"))
        _, _, edge_types = list(zip(*edges))

        self.assertEqual(edge_types.count('support'), 4)
        self.assertEqual(len(get_participants(network)), 4)
        self.assertEqual(len(get_proposals(network)), 1)
    def setUp(self):
        self.network = bootstrap_network([
            TokenBatch(1000, 1000, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2)
        self.commons = Commons(1000, 1000)

        self.network, _ = add_proposal(self.network, Proposal(100, 1))
        self.params = {"debug": True}
        self.default_state = {
            "network": self.network,
            "commons": self.commons,
            "funding_pool": 1000,
            "token_supply": 1000
        }
Esempio n. 10
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"])
Esempio n. 11
0
    def setUp(self):
        self.network = bootstrap_network([
            TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
            for _ in range(4)
        ], 1, 3000, 4e6, 0.2)

        self.network, _ = add_proposal(self.network, Proposal(100, 1))
        self.params = {"debug": False, "days_to_80p_of_max_voting_weight": 10}
        """
        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]["affinity"] = 0.9
Esempio n. 12
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
Esempio n. 13
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
Esempio n. 14
0
 def setUp(self):
     self.network = bootstrap_network([
         TokenBatch(1000, 0, vesting_options=VestingOptions(10, 30))
         for _ in range(4)
     ], 1, 3000, 4e6, 0.2)
     self.params = {"max_proposal_request": 0.2}
Esempio n. 15
0
 def setUp(self):
     self.network = bootstrap_network(
         [TokenBatch(1000, VestingOptions(10, 30)) for _ in range(4)], 1,
         3000, 4e6)
Esempio n. 16
0
 def setUp(self):
     self.commons = Commons(10000, 1000)
     self.sentiment = 0.5
     self.network = bootstrap_network(
         [TokenBatch(1000, VestingOptions(10, 30)) for _ in range(4)], 1,
         3000, 4e6)