예제 #1
0
def main():
    accounts.from_mnemonic(SEED)
    admin = accounts[0]


    token = ERC20CRV.deploy("Curve DAO Token", "CRV", 18, {'from': admin, 'required_confs': confs})
    voting_escrow = VotingEscrow.deploy(
        token, "Vote-escrowed CRV", "veCRV", "veCRV_1.0.0", {'from': admin, 'required_confs': confs}
    )


    coin_a = ERC20.deploy("Coin A", "USDA", 18, {'from': admin, 'required_confs': confs})
    coin_b = ERC20.deploy("Coin B", "USDB", 18, {'from': admin, 'required_confs': confs})
    coin_a._mint_for_testing(10 ** 9 * 10 ** 18, {'from': admin, 'required_confs': confs})
    coin_b._mint_for_testing(10 ** 9 * 10 ** 18, {'from': admin, 'required_confs': confs})

    lp_token = ERC20LP.deploy("Some pool", "cPool", 18, 0, {'from': admin, 'required_confs': confs})
    pool = CurvePool.deploy([coin_a, coin_b], lp_token, 100, 4 * 10 ** 6, {'from': admin, 'required_confs': confs})
    lp_token.set_minter(pool, {'from': admin, 'required_confs': confs})

    coin_a.approve(pool, "1000000000000000000000", {'from': admin})
    coin_b.approve(pool, "1000000000000000000000", {'from': admin})
    pool.add_liquidity(["100000000000000", "200000000000000"], 0, {'from': admin})

    contract = CurveRewards.deploy(lp_token, coin_a, {'from': accounts[0], 'required_confs': confs})
    contract.setRewardDistribution(accounts[0], {'from': accounts[0], 'required_confs': confs})
    registry = Registry.deploy([ZERO_ADDRESS] * 4, {'from': admin, 'required_confs': confs})

    coin_a.transfer(contract, 100e18, {'from': accounts[0], 'required_confs': confs})

    liquidity_gauge_rewards = LiquidityGaugeReward.deploy(lp_token, '0xbE45e0E4a72aEbF9D08F93E64701964d2CC4cF96', contract, coin_a, {'from': admin, 'required_confs': confs})

    for account in DISTRIBUTION_ADDRESSES:
        coin_a.transfer(account, DISTRIBUTION_AMOUNT, {'from': admin, 'required_confs': confs})
        coin_b.transfer(account, DISTRIBUTION_AMOUNT, {'from': admin, 'required_confs': confs})

    pool.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs})
    pool.apply_transfer_ownership({'from': admin, 'required_confs': confs})
    registry.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs})
    registry.apply_transfer_ownership({'from': admin, 'required_confs': confs})

    gauge_controller = GaugeController.deploy(token, voting_escrow, {'from': admin, 'required_confs': confs})
    minter = Minter.deploy(token, gauge_controller, {'from': admin, 'required_confs': confs})
    liquidity_gauge = LiquidityGauge.deploy(lp_token, minter, {'from': admin, 'required_confs': confs})

    token.set_minter(minter, {'from': admin, 'required_confs': confs})
    gauge_controller.add_type(b'Liquidity', {'from': admin, 'required_confs': confs})
    gauge_controller.change_type_weight(0, 10 ** 18, {'from': admin, 'required_confs': confs})
    gauge_controller.add_gauge(liquidity_gauge, 0, 10 ** 18, {'from': admin, 'required_confs': confs})

    gauge_controller.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs})
    gauge_controller.apply_transfer_ownership({'from': admin, 'required_confs': confs})
    voting_escrow.commit_transfer_ownership(ARAGON_AGENT, {'from': admin, 'required_confs': confs})
    voting_escrow.apply_transfer_ownership({'from': admin, 'required_confs': confs})

    PoolProxy.deploy({'from': admin, 'required_confs': confs})
예제 #2
0
def transfer_ownership(admin, new_admin, gauge_controller, voting_escrow, pool_proxy, erc20crv, confs=1):
    gauge_controller = GaugeController.at(gauge_controller)
    voting_escrow = VotingEscrow.at(voting_escrow)
    pool_proxy = PoolProxy.at(pool_proxy)
    erc20crv = ERC20CRV.at(erc20crv)

    gauge_controller.commit_transfer_ownership(new_admin, {'from': admin, 'required_confs': confs})
    gauge_controller.apply_transfer_ownership({'from': admin, 'required_confs': confs})

    #just a dummy method for compatibility with Aragon, not needed to be transferred to DAO
    #voting_escrow.changeController(new_admin, {'from': admin, 'required_confs': confs})
    voting_escrow.commit_transfer_ownership(new_admin, {'from': admin, 'required_confs': confs})
    voting_escrow.apply_transfer_ownership({'from': admin, 'required_confs': confs})

    pool_proxy.commit_set_admins(
        new_admin, new_admin, new_admin, {'from': admin, 'required_confs': confs}
    )
    pool_proxy.apply_set_admins({'from': admin, 'required_confs': confs})

    erc20crv.set_admin(new_admin, {'from': admin, 'required_confs': confs})
예제 #3
0
def transfer_ownership(admin,
                       new_admin,
                       gauge_controller,
                       voting_escrow,
                       pool_proxy,
                       erc20crv,
                       confs=1):
    gauge_controller = GaugeController.at(gauge_controller)
    voting_escrow = VotingEscrow.at(voting_escrow)
    pool_proxy = PoolProxy.at(pool_proxy)
    erc20crv = ERC20CRV.at(erc20crv)

    gauge_controller.commit_transfer_ownership(new_admin, {
        'from': admin,
        'required_confs': confs
    })
    gauge_controller.apply_transfer_ownership({
        'from': admin,
        'required_confs': confs
    })

    voting_escrow.commit_transfer_ownership(new_admin, {
        'from': admin,
        'required_confs': confs
    })
    voting_escrow.apply_transfer_ownership({
        'from': admin,
        'required_confs': confs
    })

    pool_proxy.commit_set_admins(new_admin, new_admin, new_admin, {
        'from': admin,
        'required_confs': confs
    })
    pool_proxy.apply_set_admins({'from': admin, 'required_confs': confs})

    erc20crv.set_admin(new_admin, {'from': admin, 'required_confs': confs})
예제 #4
0
def deploy_part_two(admin, token, voting_escrow, confs=1, deployments_json=None):
    gauge_controller = GaugeController.deploy(
        token, voting_escrow, {"from": admin, "required_confs": confs}
    )
    for name, weight in GAUGE_TYPES:
        gauge_controller.add_type(name, weight, {"from": admin, "required_confs": confs})

    pool_proxy = PoolProxy.deploy({"from": admin, "required_confs": confs})
    minter = Minter.deploy(token, gauge_controller, {"from": admin, "required_confs": confs})
    token.set_minter(minter, {"from": admin, "required_confs": confs})

    deployments = {
        "ERC20CRV": token.address,
        "VotingEscrow": voting_escrow.address,
        "GaugeController": gauge_controller.address,
        "Minter": minter.address,
        "LiquidityGauge": {},
        "LiquidityGaugeReward": {},
        "PoolProxy": pool_proxy.address,
    }
    for name, (lp_token, weight) in POOL_TOKENS.items():
        gauge = LiquidityGauge.deploy(lp_token, minter, {"from": admin, "required_confs": confs})
        gauge_controller.add_gauge(gauge, 0, weight, {"from": admin, "required_confs": confs})
        deployments["LiquidityGauge"][name] = gauge.address

    for (name, (lp_token, reward_claim, reward_token, weight)) in REWARD_POOL_TOKENS.items():
        gauge = LiquidityGaugeReward.deploy(
            lp_token, minter, reward_claim, reward_token, {"from": admin, "required_confs": confs}
        )
        gauge_controller.add_gauge(gauge, 0, weight, {"from": admin, "required_confs": confs})
        deployments["LiquidityGaugeReward"][name] = gauge.address

    print(f"Deployment complete! Total gas used: {sum(i.gas_used for i in history)}")
    if deployments_json is not None:
        with open(deployments_json, "w") as fp:
            json.dump(deployments, fp)
        print(f"Deployment addresses saved to {deployments_json}")