def pre_deploy_setup(self, deploy=True):
        """
        Deploy DIGG System and Dynamic oracle for testing.
        """
        if not deploy:
            digg = connect_digg(digg_config.prod_json)
            self.digg = digg
            self._deploy_dynamic_oracle(self.digg.devMultisig)

            # digg.constantOracle.updateAndPush({"from": digg.devMultisig})
            # Sleep long enough that the report is valid.
            chain.sleep(digg_config.cpiOracleParams.reportDelaySec)
            return

        deployer = self.deployer
        devProxyAdminAddress = web3.toChecksumAddress(
            "0x20dce41acca85e8222d6861aa6d23b6c941777bf")
        daoProxyAdminAddress = web3.toChecksumAddress(
            "0x11a9d034b1bbfbbdcac9cb3b86ca7d5df05140f2")
        self.digg = deploy_digg_minimal(deployer,
                                        devProxyAdminAddress,
                                        daoProxyAdminAddress,
                                        owner=deployer)

        self.badger.deploy_logic("DiggRewardsFaucet", DiggRewardsFaucet)
        self._deploy_dynamic_oracle(self.deployer)
Пример #2
0
def digg_distributor_unit():
    badger = connect_badger(badger_config.prod_json)
    deployer = badger.deployer
    devProxyAdminAddress = badger.devProxyAdmin.address
    daoProxyAdminAddress = badger.daoProxyAdmin.address
    digg = deploy_digg_minimal(deployer,
                               devProxyAdminAddress,
                               daoProxyAdminAddress,
                               owner=deployer)

    # deployer should have eth but just in case
    distribute_test_ether(badger.deployer, Wei("20 ether"))

    digg.deploy_airdrop_distributor(
        digg_config.airdropRoot,
        badger.rewardsEscrow,
        digg_config.reclaimAllowedTimestamp,
    )

    totalSupply = digg.token.totalSupply()
    # 15% airdropped
    digg.token.transfer(digg.diggDistributor, totalSupply * 0.15,
                        {"from": deployer})

    return digg
Пример #3
0
def test_deploy(test=False, deploy=True):
    # These should already be deployed
    deployer = accounts.at(decouple.config("TEST_ACCOUNT"), force=True)
    # deployer = accounts.at(dao_config.initialOwner, force=True)
    devProxyAdmin = "0x20dce41acca85e8222d6861aa6d23b6c941777bf"
    daoProxyAdmin = "0x11a9d034b1bbfbbdcac9cb3b86ca7d5df05140f2"
    console.log(
        "Initialize Digg System",
        {
            "deployer": deployer,
            "devProxyAdmin": devProxyAdmin,
            "daoProxyAdmin": daoProxyAdmin,
        },
    )

    if deploy:
        digg = deploy_digg_minimal(deployer, devProxyAdmin, daoProxyAdmin)
        digg.deploy_dao_digg_timelock()
        digg.deploy_digg_team_vesting()

        if test:
            # need some sweet liquidity for testing
            distribute_from_whale(whale_registry.wbtc, digg.owner)
        # deploy trading pairs (these deploys are always idempotent)
        digg.deploy_uniswap_pairs(test=test)  # adds liqudity in test mode
    else:
        digg = connect_digg(digg_config.prod_json)

    return digg
Пример #4
0
def test_deploy(test=False, deploy=True):
    # These should already be deployed
    deployer = accounts.at(dao_config.initialOwner, force=True)
    devProxyAdmin = "0x20dce41acca85e8222d6861aa6d23b6c941777bf"
    daoProxyAdmin = "0x11a9d034b1bbfbbdcac9cb3b86ca7d5df05140f2"
    console.log(
        "Initialize Digg System",
        {
            "deployer": deployer,
            "devProxyAdmin": devProxyAdmin,
            "daoProxyAdmin": daoProxyAdmin
        },
    )

    if deploy:
        digg = deploy_digg_minimal(deployer, devProxyAdmin, daoProxyAdmin)
        digg.deploy_dao_digg_timelock()
        digg.deploy_digg_team_vesting()
    else:
        digg = connect_digg(digg_config.prod_json)

    return digg
Пример #5
0
def deploy_digg_with_existing_badger(badger,
                                     test=False,
                                     outputToFile=True,
                                     testUser=None):

    deployer = badger.deployer

    # Deploy DIGG Core
    console.print("[green]== Deploy DIGG Core ==[/green]")
    digg = deploy_digg_minimal(
        deployer,
        badger.devProxyAdmin.address,
        badger.daoProxyAdmin.address,
        owner=deployer,
    )

    # Deploy new logic contracts for DIGG Setts + Strategies
    console.print("[green]== Deploy Required Sett Logic ==[/green]")
    badger.deploy_logic("DiggRewardsFaucet", DiggRewardsFaucet)
    badger.deploy_logic("DiggSett", DiggSett)
    badger.deploy_sett_strategy_logic_for("StrategyDiggRewards")
    badger.deploy_sett_strategy_logic_for("StrategySushiDiggWbtcLpOptimizer")
    badger.deploy_sett_strategy_logic_for("StrategyDiggLpMetaFarm")

    console.print("[green]== Deploy & Configure Dynamic Oracle ==[/green]")
    # Deploy simple oracle
    digg.deploy_dynamic_oracle()

    digg.deploy_airdrop_distributor(
        digg_config.airdropRoot,
        badger.rewardsEscrow,
        digg_config.reclaimAllowedTimestamp,
    )

    # Distribute required shares to airdrop

    # Setup simple oracle as provider
    digg.marketMedianOracle.addProvider(
        digg.dynamicOracle,
        {"from": deployer},
    )

    # Add DIGG to badger object
    badger.add_existing_digg(digg)

    console.print("[green]== Deploy DIGG Native Sett ==[/green]")
    deploy_digg_native_sett(badger, digg)

    # Configure Rewards Faucet with initial distribution schedule
    # console.print("[cyan]Configure native DIGG Sett Rewards Faucet...[/cyan]")
    # strategy = badger.getStrategy(key)
    # amount = digg_config_test.geyserParams.unlockSchedules.digg[0].amount

    # print('digg.token.balanceOf(deployer)', digg.token.balanceOf(deployer), amount)
    # assert digg.token.balanceOf(deployer) >= amount

    # digg.token.transfer(rewards, amount, {"from": deployer})
    # rewards.notifyRewardAmount(
    #     chain.time(), days(7), digg.token.fragmentsToShares(amount), {"from": deployer}
    # )

    # Initial DIGG Distribution

    # Liquidity Mining Pool -> Rewards Escrow
    # Team Pool -> Team Vesting
    #

    # Verify all deployment parameters
    # Verify all initializers cannot be set twice
    # Verify all upgradability

    # Unpause All Setts

    # Unit & integration tests vs live deployment before creation

    # Test Mode: Create LP Tokens & Distribute assets to test user
    if test:
        console.print("[green]== Test Mode Activities ==[/green]")
        remainingFree = badger.digg.token.balanceOf(deployer)
        console.print(
            "Transfer remaining {} DIGG from deployer to test user {}".format(
                val(remainingFree), testUser.address))
        badger.digg.token.transfer(testUser, remainingFree, {"from": deployer})

        assert badger.digg.token.balanceOf(testUser) >= remainingFree

    console.print("[cyan]== Digg Supply ==[/cyan]")
    console.print({
        "totalShares": badger.digg.token.totalShares(),
        "totalSupply": badger.digg.token.totalSupply(),
    })

    console.log("Test: Digg System Deployed")
    if outputToFile:
        fileName = "deploy-final.json"
        console.log("Printing digg contract addresses to ", fileName)
        print_to_file(badger, fileName)
    if not test:
        post_deploy_config(digg)
    console.log("Test: Digg System Setup Complete")
    return digg