Ejemplo n.º 1
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    accounts_num = len(ctx.accounts)
    if accounts_num * 2 >= ctx.args.deploy_min_tokens_to_create - 4:
        print("Please increase the minimum fueling goal for the scenario.")
        sys.exit(1)

    creation_secs = ctx.remaining_time()
    total_supply = ctx.args.deploy_min_tokens_to_create - 4
    proxy_amounts = constrained_sum_sample_pos(accounts_num, total_supply / 2)
    normal_amounts = constrained_sum_sample_pos(accounts_num, total_supply / 2)
    ctx.token_amounts = [
        sum(x) for x in zip(proxy_amounts[::-1], normal_amounts)
    ]
    ctx.total_supply = sum(ctx.token_amounts)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "wait_ms": (creation_secs - 3) * 1000,
            "proxy_amounts": arr_str(proxy_amounts),
            "normal_amounts": arr_str(normal_amounts)
        })
    print("Notice: Fueling period is {} seconds so the test will wait "
          "as much".format(creation_secs))
    ctx.execute(
        expected={
            "dao_fueled": False,
            "total_supply": ctx.total_supply,
            "refund": ctx.token_amounts
        })
Ejemplo n.º 2
0
Archivo: run.py Proyecto: LiteBit/DAO
def run(framework):
    # if deployment did not already happen do it now
    if not framework.dao_addr:
        framework.run_scenario('deploy')
    else:
        print(
            "WARNING: Running the failed funding 2 scenario with a "
            "pre-deployed DAO contract. Closing time is {} which is "
            "approximately {} seconds from now.".format(
                datetime.fromtimestamp(framework.closing_time).strftime(
                    '%Y-%m-%d %H:%M:%S'
                ),
                framework.remaining_time()
            )
        )

    accounts_num = len(framework.accounts)
    if accounts_num * 2 >= framework.args.deploy_min_value - 4:
        print("Please increase the minimum funding goal for the scenario.")
        sys.exit(1)

    sale_secs = framework.remaining_time()
    total_supply = framework.args.deploy_min_value - 4
    proxy_amounts = constrained_sum_sample_pos(
        accounts_num, total_supply / 2
    )
    normal_amounts = constrained_sum_sample_pos(
        accounts_num, total_supply / 2
    )
    framework.token_amounts = [
        sum(x) for x in zip(proxy_amounts[::-1], normal_amounts)
    ]
    framework.total_supply = sum(framework.token_amounts)
    framework.create_js_file(
        substitutions={
            "dao_abi": framework.dao_abi,
            "dao_address": framework.dao_addr,
            "wait_ms": (sale_secs-3)*1000,
            "proxy_amounts": arr_str(proxy_amounts),
            "normal_amounts": arr_str(normal_amounts)
        }
    )
    print(
        "Notice: Funding period is {} seconds so the test will wait "
        "as much".format(sale_secs)
    )
    framework.execute(expected={
        "dao_funded": False,
        "total_supply": framework.total_supply,
        "refund": framework.token_amounts
    })
Ejemplo n.º 3
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    creation_secs = ctx.remaining_time()
    ctx.total_supply = (ctx.args.deploy_min_tokens_to_create +
                        random.randint(1, 100))
    ctx.token_amounts = constrained_sum_sample_pos(len(ctx.accounts),
                                                   ctx.total_supply)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "wait_ms": (creation_secs - 3) * 1000,
            "amounts": arr_str(ctx.token_amounts)
        })
    print("Notice: Fueling period is {} seconds so the test will wait "
          "as much".format(creation_secs))

    adjusted_amounts = ([
        x / 1.5 for x in ctx.token_amounts
    ] if ctx.scenario_uses_extrabalance() else ctx.token_amounts)
    adjusted_supply = (ctx.total_supply / 1.5 if
                       ctx.scenario_uses_extrabalance() else ctx.total_supply)

    ctx.execute(
        expected={
            "dao_fueled": True,
            "total_supply": adjusted_supply,
            "balances": adjusted_amounts,
            "user0_after": adjusted_amounts[0]
        })
Ejemplo n.º 4
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    accounts_num = len(ctx.accounts)
    creation_secs = ctx.remaining_time()
    ctx.total_supply = random.randint(5,
                                      ctx.args.deploy_min_tokens_to_create - 4)
    ctx.token_amounts = constrained_sum_sample_pos(accounts_num,
                                                   ctx.total_supply)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "wait_ms": (creation_secs) * 1000,
            "amounts": arr_str(ctx.token_amounts)
        })
    print("Notice: Fueling period is {} seconds so the test will wait "
          "as much".format(creation_secs))
    adjusted_supply = ctx.total_supply / 1.5

    ctx.execute(
        expected={
            "dao_fueled": False,
            "total_supply": adjusted_supply,
            "refund": ctx.token_amounts
        })
Ejemplo n.º 5
0
Archivo: run.py Proyecto: CJGuest/DAO
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    accounts_num = len(ctx.accounts)
    sale_secs = ctx.remaining_time()
    ctx.total_supply = random.randint(5, ctx.args.deploy_min_value - 4)
    ctx.token_amounts = constrained_sum_sample_pos(
        accounts_num, ctx.total_supply
    )
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "wait_ms": (sale_secs-3)*1000,
            "amounts": arr_str(ctx.token_amounts)
        }
    )
    print(
        "Notice: Fueling period is {} seconds so the test will wait "
        "as much".format(sale_secs)
    )
    ctx.execute(expected={
        "dao_fueled": False,
        "total_supply": ctx.total_supply,
        "refund": ctx.token_amounts
    })
Ejemplo n.º 6
0
def run(framework):
    # if deployment did not already happen do it now
    if not framework.dao_addr:
        framework.run_scenario('deploy')
    else:
        print(
            "WARNING: Running the failed funding scenario with a pre-deployed "
            "DAO contract. Closing time is {} which is approximately {} "
            "seconds from now.".format(
                datetime.fromtimestamp(
                    framework.closing_time).strftime('%Y-%m-%d %H:%M:%S'),
                framework.remaining_time()))

    accounts_num = len(framework.accounts)
    sale_secs = framework.remaining_time()
    framework.total_supply = random.randint(
        5, framework.args.deploy_min_value - 4)
    framework.token_amounts = constrained_sum_sample_pos(
        accounts_num, framework.total_supply)
    framework.create_js_file(
        substitutions={
            "dao_abi": framework.dao_abi,
            "dao_address": framework.dao_addr,
            "wait_ms": (sale_secs - 3) * 1000,
            "amounts": arr_str(framework.token_amounts)
        })
    print("Notice: Funding period is {} seconds so the test will wait "
          "as much".format(sale_secs))
    framework.execute(
        expected={
            "dao_funded": False,
            "total_supply": framework.total_supply,
            "refund": framework.token_amounts
        })
Ejemplo n.º 7
0
Archivo: run.py Proyecto: CJGuest/DAO
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    sale_secs = ctx.remaining_time()
    ctx.total_supply = ctx.args.deploy_min_value + random.randint(1, 100)
    ctx.token_amounts = constrained_sum_sample_pos(
        len(ctx.accounts), ctx.total_supply
    )
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "wait_ms": (sale_secs-3)*1000,
            "amounts": arr_str(ctx.token_amounts)
        }
    )
    print(
        "Notice: Fueling period is {} seconds so the test will wait "
        "as much".format(sale_secs)
    )

    ctx.execute(expected={
        "dao_fueled": True,
        "total_supply": ctx.total_supply,
        "balances": ctx.token_amounts,
        "user0_after": ctx.token_amounts[0],
    })
Ejemplo n.º 8
0
def run(framework):
    # if deployment did not already happen do it now
    if not framework.dao_addr:
        framework.run_scenario('deploy')
    else:
        print("WARNING: Running the failed funding 2 scenario with a "
              "pre-deployed DAO contract. Closing time is {} which is "
              "approximately {} seconds from now.".format(
                  datetime.fromtimestamp(
                      framework.closing_time).strftime('%Y-%m-%d %H:%M:%S'),
                  framework.remaining_time()))

    accounts_num = len(framework.accounts)
    if accounts_num * 2 >= framework.args.deploy_min_value - 4:
        print("Please increase the minimum funding goal for the scenario.")
        sys.exit(1)

    sale_secs = framework.remaining_time()
    total_supply = framework.args.deploy_min_value - 4
    proxy_amounts = constrained_sum_sample_pos(accounts_num, total_supply / 2)
    normal_amounts = constrained_sum_sample_pos(accounts_num, total_supply / 2)
    framework.token_amounts = [
        sum(x) for x in zip(proxy_amounts[::-1], normal_amounts)
    ]
    framework.total_supply = sum(framework.token_amounts)
    framework.create_js_file(
        substitutions={
            "dao_abi": framework.dao_abi,
            "dao_address": framework.dao_addr,
            "wait_ms": (sale_secs - 3) * 1000,
            "proxy_amounts": arr_str(proxy_amounts),
            "normal_amounts": arr_str(normal_amounts)
        })
    print("Notice: Funding period is {} seconds so the test will wait "
          "as much".format(sale_secs))
    framework.execute(
        expected={
            "dao_funded": False,
            "total_supply": framework.total_supply,
            "refund": framework.token_amounts
        })
Ejemplo n.º 9
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    accounts_num = len(ctx.accounts)
    if accounts_num * 2 >= ctx.args.deploy_min_tokens_to_create - 4:
        print("Please increase the minimum fueling goal for the scenario.")
        sys.exit(1)

    creation_secs = ctx.remaining_time()
    total_supply = ctx.args.deploy_min_tokens_to_create - 4
    proxy_amounts = constrained_sum_sample_pos(
        accounts_num, total_supply / 2
    )
    normal_amounts = constrained_sum_sample_pos(
        accounts_num, total_supply / 2
    )
    ctx.token_amounts = [
        sum(x) for x in zip(proxy_amounts[::-1], normal_amounts)
    ]
    ctx.total_supply = sum(ctx.token_amounts)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "wait_ms": (creation_secs-3)*1000,
            "proxy_amounts": arr_str(proxy_amounts),
            "normal_amounts": arr_str(normal_amounts)
        }
    )
    print(
        "Notice: Fueling period is {} seconds so the test will wait "
        "as much".format(creation_secs)
    )
    ctx.execute(expected={
        "dao_fueled": False,
        "total_supply": ctx.total_supply,
        "refund": ctx.token_amounts
    })
Ejemplo n.º 10
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    ctx.total_supply = (ctx.args.deploy_min_tokens_to_create +
                        random.randint(1, 100))
    ctx.token_amounts = constrained_sum_sample_pos(len(ctx.accounts),
                                                   ctx.total_supply)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "amounts": arr_str(ctx.token_amounts)
        })

    ctx.execute(expected={"min_quorum_same": True})
Ejemplo n.º 11
0
Archivo: run.py Proyecto: AlmavivA/DAO
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    ctx.total_supply = (
        ctx.args.deploy_min_tokens_to_create + random.randint(1, 100)
    )
    ctx.token_amounts = constrained_sum_sample_pos(
        len(ctx.accounts), ctx.total_supply
    )
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "amounts": arr_str(ctx.token_amounts)
        }
    )

    ctx.execute(expected={
        "min_quorum_same": True
    })
Ejemplo n.º 12
0
    def run_test_fund(self):
        # if deployment did not already happen do it now
        if not self.dao_addr:
            self.run_test_deploy()
        else:
            print(
                "WARNING: Running the funding scenario with a pre-deployed "
                "DAO contract. Closing time is {} which is approximately {} "
                "seconds from now.".format(
                    datetime.fromtimestamp(self.closing_time).strftime(
                        '%Y-%m-%d %H:%M:%S'
                    ),
                    self.closing_time - ts_now()
                )
            )

        sale_secs = self.closing_time - ts_now()
        self.total_supply = self.min_value + random.randint(1, 100)
        self.token_amounts = constrained_sum_sample_pos(
            len(self.accounts), self.total_supply
        )
        self.create_js_file(
            'fund',
            {
                "dao_abi": self.dao_abi,
                "dao_address": self.dao_addr,
                "wait_ms": (sale_secs-3)*1000,
                "amounts": arr_str(self.token_amounts)
            }
        )
        print(
            "Notice: Funding period is {} seconds so the test will wait "
            "as much".format(sale_secs)
        )
        output = self.run_script('fund.js')
        eval_test('fund', output, {
            "dao_funded": True,
            "total_supply": self.total_supply,
            "balances": self.token_amounts,
            "user0_after": self.token_amounts[0],
        })
Ejemplo n.º 13
0
Archivo: run.py Proyecto: LiteBit/DAO
def run(framework):
    # if deployment did not already happen do it now
    if not framework.dao_addr:
        framework.run_scenario('deploy')
    else:
        print(
            "WARNING: Running the funding scenario with a pre-deployed "
            "DAO contract. Closing time is {} which is approximately {} "
            "seconds from now.".format(
                datetime.fromtimestamp(framework.closing_time).strftime(
                    '%Y-%m-%d %H:%M:%S'
                ),
                framework.remaining_time()
            )
        )

    sale_secs = framework.remaining_time()
    framework.total_supply = framework.args.deploy_min_value + random.randint(1, 100)
    framework.token_amounts = constrained_sum_sample_pos(
        len(framework.accounts), framework.total_supply
    )
    framework.create_js_file(substitutions={
            "dao_abi": framework.dao_abi,
            "dao_address": framework.dao_addr,
            "wait_ms": (sale_secs-3)*1000,
            "amounts": arr_str(framework.token_amounts)
        }
    )
    print(
        "Notice: Funding period is {} seconds so the test will wait "
        "as much".format(sale_secs)
    )

    framework.execute(expected={
        "dao_funded": True,
        "total_supply": framework.total_supply,
        "balances": framework.token_amounts,
        "user0_after": framework.token_amounts[0],
    })
Ejemplo n.º 14
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    creation_secs = ctx.remaining_time()
    ctx.total_supply = (
        ctx.args.deploy_min_tokens_to_create + random.randint(1, 100)
    )
    ctx.token_amounts = constrained_sum_sample_pos(
        len(ctx.accounts), ctx.total_supply
    )
    ctx.create_js_file(substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_address,
            "wait_ms": (creation_secs-3)*1000,
            "amounts": arr_str(ctx.token_amounts)
        }
    )
    print(
        "Notice: Fueling period is {} seconds so the test will wait "
        "as much".format(creation_secs)
    )

    adjusted_amounts = (
        [x/1.5 for x in ctx.token_amounts]
        if ctx.scenario_uses_extrabalance() else ctx.token_amounts
    )
    adjusted_supply = (
        ctx.total_supply / 1.5
        if ctx.scenario_uses_extrabalance() else ctx.total_supply
    )

    ctx.execute(expected={
        "dao_fueled": True,
        "total_supply": adjusted_supply,
        "balances": adjusted_amounts,
        "user0_after": adjusted_amounts[0]
    })
Ejemplo n.º 15
0
def run(ctx):
    ctx.assert_scenario_ran('deploy')

    sale_secs = ctx.remaining_time()
    ctx.total_supply = ctx.args.deploy_min_value + random.randint(1, 100)
    ctx.token_amounts = constrained_sum_sample_pos(len(ctx.accounts),
                                                   ctx.total_supply)
    ctx.create_js_file(
        substitutions={
            "dao_abi": ctx.dao_abi,
            "dao_address": ctx.dao_addr,
            "wait_ms": (sale_secs - 3) * 1000,
            "amounts": arr_str(ctx.token_amounts)
        })
    print("Notice: Funding period is {} seconds so the test will wait "
          "as much".format(sale_secs))

    ctx.execute(
        expected={
            "dao_funded": True,
            "total_supply": ctx.total_supply,
            "balances": ctx.token_amounts,
            "user0_after": ctx.token_amounts[0],
        })
Ejemplo n.º 16
0
    df.to_hdf('clients-sim.hdf5', 'DatatasetCli')
''' PORTFOLIOS '''
if True:
    data = pd.read_hdf('processed_similarity.hdf5', 'Datataset1/X')

    columns = [
        'Asset1', 'Exposure1', 'Asset2', 'Exposure2', 'Asset3', 'Exposure3',
        'Asset4', 'Exposure4', 'Asset5', 'Exposure5', 'Asset6', 'Exposure6',
        'Asset7', 'Exposure7', 'Asset8', 'Exposure8', 'Asset9', 'Exposure9',
        'Asset10', 'Exposure10', 'Asset11', 'Exposure11', 'Asset12',
        'Exposure12', 'Asset13', 'Exposure13', 'Asset14', 'Exposure14',
        'Asset15', 'Exposure15', 'Asset16', 'Exposure16', 'Asset17',
        'Exposure17', 'Asset18', 'Exposure18', 'Asset19', 'Exposure19',
        'Asset20', 'Exposure20'
    ]
    port = []
    for j in range(0, 110):
        shares = ut.constrained_sum_sample_pos(randint(2, 20), 100)
        row = []
        for i in range(0, len(shares)):
            pick = data.iloc[randint(0, 1419)]
            row.append(pick.name)
            row.append(shares[i])
        for i in range(len(shares), 20):
            row.append(str(math.nan))
            row.append(0)
        port.append(row)
        portfolios = pd.DataFrame(port, columns=columns)

    portfolios.to_hdf('portfolios-sim.hdf5', 'DatatasetPort')