コード例 #1
0
def test_deploy_plain_pool_revert(base_pool, new_factory, new_factory_setup,
                                  bob):
    coin = ERC20(decimals=7)
    new_factory.deploy_metapool(base_pool, "Name", "SYM", coin, 12345,
                                50000000, 0, {"from": bob})
    existing_coin = base_pool.coins(0)
    assert new_factory.base_pool_assets(existing_coin)
    coins = [existing_coin, ERC20(decimals=9), ZERO_ADDRESS, ZERO_ADDRESS]
    # should revert because a metapool already exists for one of the coins
    with brownie.reverts("Invalid asset, deploy a metapool"):
        new_factory.deploy_plain_pool("Test Plain", "TST", coins, 12345,
                                      50000000, {"from": bob})
コード例 #2
0
ファイル: coins.py プロジェクト: skellet0r/curve-factory
def _plain_coins(alice, decimals):
    return_true_revert = [
        ERC20(decimals=precision, deployer=alice) for precision in decimals
    ]
    return_true_false = [
        ERC20(fail=False, decimals=precision, deployer=alice)
        for precision in decimals
    ]
    return_none_revert = [
        ERC20(success=None, decimals=precision, deployer=alice)
        for precision in decimals
    ]
    return [return_true_revert, return_true_false, return_none_revert]
コード例 #3
0
def test_state_machine(state_machine, accounts):
    # setup
    owner = accounts[0]
    distributor = accounts[1]
    duration = DAY * 10

    # deploy reward token, and mint
    reward_token = ERC20()

    # deploy stream and approve
    reward_stream = owner.deploy(RewardStream, owner, distributor,
                                 reward_token, duration)

    # settings = {"stateful_step_count": 25}

    state_machine(
        StateMachine,
        accounts,
        owner,
        distributor,
        duration,
        reward_token,
        reward_stream,
        # settings=settings,
    )
コード例 #4
0
def token(request, alice):
    success, fail = request.param
    if None in (fail, success) and fail is not success:
        pytest.skip()
    contract = ERC20(success=success, fail=fail)
    contract._mint_for_testing(alice, 10**18, {"from": alice})
    yield (contract, success, fail)
コード例 #5
0
def test_base_rewards_and_additional_rewards_are_distributed(
        alice, chain, base_gauge, meta_gauge, coin_reward):
    # base rewards aren't distributed over the course of a week, instead they are instantly
    # distributed amongst the LPs in the pool. This is because the base_gauge already has some form
    # of delay, adding a second delay would not make much sense.
    dummy_reward = ERC20()
    dummy_reward._mint_for_testing(alice, REWARD, {"from": alice})
    dummy_reward.approve(meta_gauge, 2**256 - 1, {"from": alice})

    base_gauge.set_rewards(ZERO_ADDRESS, "0x0",
                           [coin_reward] + [ZERO_ADDRESS] * 7, {"from": alice})
    coin_reward._mint_for_testing(base_gauge, REWARD, {"from": alice})

    assert coin_reward.balanceOf(alice) == 0

    meta_gauge.add_reward(dummy_reward, alice, {"from": alice})
    meta_gauge.deposit_reward_token(dummy_reward, REWARD, {"from": alice})

    chain.sleep(86400)

    meta_gauge.claim_rewards({"from": alice})

    assert coin_reward.balanceOf(alice) == REWARD
    assert math.isclose(dummy_reward.balanceOf(alice),
                        REWARD // 7,
                        rel_tol=0.0001)
コード例 #6
0
def test_state_machine(state_machine, accounts, VotingEscrow):
    token = ERC20("", "", 18)
    voting_escrow = VotingEscrow.deploy(
        token, "Voting-escrowed CRV", "veCRV", "veCRV_0.99", {"from": accounts[0]}
    )

    state_machine(StateMachine, accounts[:10], token, voting_escrow, settings={"max_examples": 30})
コード例 #7
0
def test_pool_count(new_factory, coins, new_factory_setup, bob, base_pool):

    tx = new_factory.deploy_plain_pool("Test Plain", "TST", coins, 12345,
                                       50000000, 0, 0, {"from": bob})
    assert tx.return_value == tx.new_contracts[0]
    assert new_factory.pool_count() == 1

    coin = ERC20(decimals=7)
    tx = new_factory.deploy_metapool(base_pool, "Name", "SYM", coin, 12345,
                                     50000000, 0, {"from": bob})
    assert tx.return_value == tx.new_contracts[0]
    assert new_factory.pool_count() == 2

    coin = ERC20(decimals=7)
    pool = Contract("0x7fC77b5c7614E1533320Ea6DDc2Eb61fa00A9714")
    tx = new_factory.deploy_metapool(pool, "Name", "SYM", coin, 123456,
                                     50000000, 0, {"from": bob})
    assert new_factory.pool_count() == 3
コード例 #8
0
def test_deploy_metapool(MetaImplementationUSD, factory, base_pool, alice, bob):
    coin = ERC20(decimals=7)

    tx = factory.deploy_metapool(base_pool, "Name", "SYM", coin, 12345, 50000000, {'from': bob})
    assert tx.return_value == tx.new_contracts[0]
    swap = MetaImplementationUSD.at(tx.return_value)

    assert swap.coins(0) == coin
    assert swap.A() == 12345
    assert swap.fee() == 50000000
    assert swap.admin() == alice

    assert factory.pool_count() == 3
    assert factory.pool_list(2) == swap
    assert factory.get_decimals(swap) == [7, 18]
コード例 #9
0
def test_deploy_metapool(MetaUSD, new_factory, new_factory_setup, base_pool,
                         bob):
    coin = ERC20(decimals=7)

    tx = new_factory.deploy_metapool(base_pool, "Name", "SYM", coin, 12345,
                                     50000000, 0, {"from": bob})
    assert tx.return_value == tx.new_contracts[0]
    swap = MetaUSD.at(tx.return_value)

    assert swap.coins(0) == coin
    assert swap.A() == 12345
    assert swap.fee() == 50000000

    assert new_factory.pool_count() == 1
    assert new_factory.pool_list(0) == swap
    assert new_factory.get_decimals(swap) == [7, 18, 0, 0]
コード例 #10
0
def new_base_pool(alice, CurveTokenV3, CurvePool, registry):
    lp_token = CurveTokenV3.deploy("Test LP Token", "Tester", {"from": alice})
    base_coins = [ERC20() for _ in range(3)]
    pool = CurvePool.deploy(alice, base_coins, lp_token, 200, 3000000,
                            5000000000, {"from": alice})
    lp_token.set_minter(pool, {"from": alice})

    registry.add_pool_without_underlying(
        pool,
        3,
        lp_token,
        "0x0",
        pack_values([18, 18, 18]),
        pack_values([0, 0, 0]),
        True,
        False,
        "Test Base Pool",
    )
    return pool
コード例 #11
0
ファイル: coins.py プロジェクト: skellet0r/curve-factory
def coin_reward():
    return ERC20()
コード例 #12
0
ファイル: coins.py プロジェクト: skellet0r/curve-factory
def coin_b():
    return ERC20()
コード例 #13
0
ファイル: coins.py プロジェクト: skellet0r/curve-factory
def coin_a():
    return ERC20()
コード例 #14
0
def coin(pytestconfig):
    yield ERC20(
        decimals=pytestconfig.getoption('decimals'),
        success=eval(pytestconfig.getoption('return_value')),
    )
コード例 #15
0
def test_cant_exceed_max(alice, gauge):
    for _ in range(8):
        gauge.add_reward(ERC20(), alice, {"from": alice})
    with brownie.reverts():
        gauge.add_reward(ERC20(), alice, {"from": alice})
コード例 #16
0
def coins(alice):
    contracts = [ERC20() for i in range(3)]
    for c in contracts:
        c._mint_for_testing(alice, 10**18, {'from': alice})
    return contracts
コード例 #17
0
def token2(bob, swap, lp_token):
    contract = ERC20()
    contract._mint_for_testing(bob, 1000000 * 10**18)
    contract.approve(lp_token, 2**256 - 1, {'from': bob})
    return contract
コード例 #18
0
def reward_token(bob):
    token = ERC20()
    token._mint_for_testing(bob, 10**19)
    return token
コード例 #19
0
def token2(alice, bob):
    contract = ERC20()
    contract._mint_for_testing(alice, 1000000 * 10**18)
    contract._mint_for_testing(bob, 1000000 * 10**18)
    yield contract
コード例 #20
0
ファイル: coins.py プロジェクト: skellet0r/curve-factory
def base_coins(alice):
    return [ERC20(deployer=alice) for _ in range(3)]
コード例 #21
0
def coin_b():
    yield ERC20("Coin B", "USDB", 18)
コード例 #22
0
def coin_reward():
    yield ERC20("YFIIIIII Funance", "YFIIIIII", 18)
コード例 #23
0
def coins(alice):
    yield [ERC20() for i in range(3)]
コード例 #24
0
def coin_c():
    yield ERC20("Coin C", "mWBTC", 8)
コード例 #25
0
ファイル: conftest.py プロジェクト: pickle-finance/protocol
def coin_a():
    yield ERC20("Coin A", "USDA", 18)