Example #1
0
def main():
    configurations = json.load(open("configurations.json"))
    for i, config in enumerate(configurations["vaults"]):
        print(f"[{i}] {config['name']}")
    config = configurations["vaults"][int(
        input("choose configuration to deploy: "))]
    deployer = accounts.load(input("deployer account: "))

    if input('deploy vault? y/n: ') == 'y':
        gov = get_address("gov")
        rewards = get_address("rewards")
        vault = Vault.deploy(
            config["want"],
            gov,
            rewards,
            config["name"],
            config["symbol"],
            {"from": deployer},
        )
    else:
        vault = Vault.at(get_address('vault'))

    strategy = StrategyUniswapPairPickle.deploy(vault, config["jar"],
                                                config["pid"],
                                                {"from": deployer})
    secho(
        f"deployed {config['symbol']}\nvault: {vault}\nstrategy: {strategy}\n",
        fg="green",
    )
Example #2
0
def main():
    deployer = accounts.load(input("deployer account: "))

    if input("deploy vault? y/n: ") == "y":
        gov = get_address("gov")
        rewards = get_address("rewards")
        vault = Vault.deploy(
            "0x59A19D8c652FA0284f44113D0ff9aBa70bd46fB4",
            gov,
            rewards,
            "Balancer BAL-WETH 80-20 Pool yVault",
            "yvBal-BAL-WETH-80-20",
            {"from": deployer},
        )
    else:
        vault = Vault.at(get_address("vault"))

    strategy = StrategyBalancerLP.deploy(vault, {"from": deployer})

    deposit_limit = Wei('50 ether')
    vault.setDepositLimit(deposit_limit, {"from": deployer})
    vault.addStrategy(strategy, deposit_limit, deposit_limit, 0,
                      {"from": deployer})

    secho(
        f"deployed {config['symbol']}\nvault: {vault}\nstrategy: {strategy}\n",
        fg="green",
    )
Example #3
0
def main():
    guest = "0xcB16133a37Ef19F90C570B426292BDcca185BF47"
    gov = "0x9b5f6921302cc0560fE2eE72E8fcED9D5D26123d"
    rewards = "0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde"
    configurations = json.load(open("configurations.json"))
    for i, config in enumerate(configurations["vaults"]):
        print(f"[{i}] {config['name']}")
    config = configurations["vaults"][int(
        input("choose configuration to deploy: "))]
    deployer = accounts.load(input("deployer account: "))

    if input("deploy vault? y/n: ") == "y":
        # gov = get_address("gov")
        # rewards = get_address("rewards")
        vault = Vault.deploy(
            config["want"],
            gov,
            rewards,
            config["name"],
            config["symbol"],
            {
                "from": deployer,
                "gas_price": Wei("25 gwei")
            },
        )
    else:
        vault = Vault.at(get_address("vault"))

    strategy = StrategySushiswapPair.deploy(vault, config["pid"], {
        "from": deployer,
        "gas_price": Wei("25 gwei")
    })

    deposit_limit = Wei('10 ether')
    vault.setDepositLimit(deposit_limit, {
        "from": deployer,
        "gas_price": Wei("25 gwei")
    })
    vault.addStrategy(strategy, deposit_limit, deposit_limit, 1000, {
        "from": deployer,
        "gas_price": Wei("25 gwei")
    })

    gov = "0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52"

    vault.setGovernance(gov, {"from": deployer, "gas_price": Wei("25 gwei")})

    secho(
        f"deployed {config['symbol']}\nvault: {vault}\nstrategy: {strategy}\n",
        fg="green",
    )
Example #4
0
def main():
    print(f"You are using the '{network.show_active()}' network")
    account_name = input(f"What account to use?: ")
    dev = accounts.load(account_name)
    print(f"You are using: 'dev' [{dev.address}]")
    token = Token.at(get_address("ERC20 Token: "))
    #token = Token.at("0x6B175474E89094C44Da98b954EedeAC495271d0F")
    #gov = get_address("yEarn Governance: ")
    gov = dev
    #rewards = get_address("Rewards contract: ")
    rewards = dev
    #name = input(f"Set description ['yearn {token.name()}']: ") or ""
    name = "yDAI Test Vault V2"
    #symbol = input(f"Set symbol ['y{token.symbol()}']: ") or ""
    symbol = 'ytDAI'
    print(f"""
    Vault Parameters

   version: {PACKAGE_VERSION}
     token: {token.address}
  governer: {gov}
   rewards: {rewards}
      name: '{name or 'yearn ' + token.name()}'
    symbol: '{symbol or 'y' + token.symbol()}'
    """)
    if input("Deploy New Vault? y/[N]: ").lower() != "y":
        return
    print("Deploying Vault...")
    vault = Vault.deploy(token, gov, rewards, name, symbol, {
        'from': dev,
        'gas_price': Wei("15 gwei")
    })
Example #5
0
def main():
    dai = interface.ERC20('0x6b175474e89094c44da98b954eedeac495271d0f')
    old_strategy = YearnDaiCompStratV2.at(
        '0x5b62F24581Ea4bc6d6C5C101DD2Ae7233E422884')
    live_strategy = YearnDaiCompStratV2.at(
        '0x4C6e9d7E5d69429100Fcc8afB25Ea980065e2773')
    vault = Vault.at('0x9B142C2CDAb89941E9dcd0B6C1cf6dEa378A8D7C')

    print(f'strategy YearnDaiCompStratV2: {live_strategy.address}')
    print(f'Vault: {vault.address}')
    print(f'Vault name: {vault.name()} and symbol: {vault.symbol()}')
    strategist_confirmed = live_strategy.strategist()
    print(f'Strategy strategist: {strategist_confirmed}')

    account_name = input(f"What account to use?: ")
    dev = accounts.load(account_name)
    print(f"You are using: 'dev' [{dev.address}]")
    devDai = dai.balanceOf(dev).to('ether')
    print(f"You're DAI balance is: [{devDai}]")
    are_you_strategist = strategist_confirmed == dev.address
    print(f"Are you strategist? {are_you_strategist}")

    if input("Continue? y/[N]: ").lower() != "y":
        return

    vault.migrateStrategy(old_strategy, live_strategy, {
        "from": dev,
        'gas_price': Wei("25 gwei")
    })

    print('migrate time')
    if input("Continue? y/[N]: ").lower() != "y":
        return

    live_strategy.harvest({"from": dev, 'gas_price': Wei("25 gwei")})
Example #6
0
    def rule_new_experiment(self):
        token = self.create_token()
        print(f"Registry.newExperimentalVault({token}, {self.latest_version})")

        vault = Vault.at(
            self.registry.newExperimentalVault(token, self.gov, self.gov,
                                               self.gov, "", "").return_value)

        self.experiments[token] = [vault]
Example #7
0
def main():
    print(f"You are using the '{network.show_active()}' network")
    bot = accounts.load("bot")
    print(f"You are using: 'bot' [{bot.address}]")
    # TODO: Allow adding/removing strategies during operation
    strategies = [interface.StrategyAPI(get_address("Strategy to farm: "))]
    while input("Add another strategy? (y/[N]): ").lower() == "y":
        strategies.append(
            interface.StrategyAPI(get_address("Strategy to farm: ")))

    vault = Vault.at(strategies[0].vault())

    for strategy in strategies:
        assert (strategy.keeper() == bot.address
                ), "Bot is not set as keeper! [{strategy.address}]"
        assert strategy.vault(
        ) == vault.address, "Vault mismatch! [{strategy.address}]"

    while True:
        gas_price = get_gas_price()
        starting_balance = bot.balance()

        no_action = True
        for strategy in strategies:
            # Display some relevant statistics
            symbol = vault.symbol()[1:]
            credit = vault.creditAvailable(strategy) / 10**vault.decimals()
            print(
                f"[{strategy.address}] Credit Available: {credit:0.3f} {symbol}"
            )
            debt = vault.debtOutstanding(strategy) / 10**vault.decimals()
            print(
                f"[{strategy.address}] Debt Outstanding: {debt:0.3f} {symbol}")

            # TODO: Actually estimate gas
            if strategy.tendTrigger(40000 * gas_price):
                try:
                    strategy.tend({"from": bot, "gas_price": gas_price})
                    no_action = False
                except:
                    print("Call failed")

            elif strategy.harvestTrigger(180000 * gas_price):
                try:
                    strategy.harvest({"from": bot, "gas_price": gas_price})
                    no_action = False
                except:
                    print("Call failed")

        if no_action:
            print("Sleeping for 60 seconds...")
            sleep(60)

        if bot.balance() < 10**8 * gas_price:
            # Less than 100m gas left to spend
            print(f"Need more ether please! {bot.address}")
Example #8
0
def main():
    dai = interface.ERC20('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
    strategy = YearnWethCreamStratV2.at(
        '0x97785a81B3505Ea9026b2aFFa709dfd0C9Ef24f6')
    vault = Vault.at('0xf20731f26e98516dd83bb645dd757d33826a37b5')

    print(f'strategy YearnWethCreamStratV2: {strategy.address}')
    print(f'Vault: {vault.address}')
    print(f'Vault name: {vault.name()} and symbol: {vault.symbol()}')
    strategist_confirmed = strategy.strategist()
    print(f'Strategy strategist: {strategist_confirmed}')

    account_name = input(f"What account to use?: ")
    dev = accounts.load(account_name)
    print(f"You are using: 'dev' [{dev.address}]")
    devDai = dai.balanceOf(dev).to('ether')
    print(f"You're DAI balance is: [{devDai}]")
    are_you_strategist = strategist_confirmed == dev.address
    print(f"Are you strategist? {are_you_strategist}")

    if input("Continue? y/[N]: ").lower() != "y":
        return

    deposit_limit = Wei('500 ether')
    deposit_limit_eth = deposit_limit.to('ether')

    if input(f"Set deposit limit to: {deposit_limit_eth}?").lower() != "y":
        return

# vault.setDepositLimit(deposit_limit, {"from": dev, 'gas_price':Wei("17 gwei")})

    if input(f"Add strategy: {strategy} ?").lower() != "y":
        return

    #vault.addStrategy(strategy, deposit_limit, deposit_limit, 500, {"from": dev, 'gas_price':Wei("17 gwei")})

    amount = Wei('0.1 ether')
    amountE = amount.to('ether')

    if input(f"approve: {amountE} WETH?").lower() != "y":
        return
    #dai.approve(vault, amount*100, {"from": dev, 'gas_price':Wei("17 gwei")})

    print('deposit amount:', amount.to('ether'))
    if input("Continue? y/[N]: ").lower() != "y":
        return
    #vault.deposit(amount, {"from": dev, 'gas_price':Wei("17 gwei")})

    print('harvest time')
    if input("Continue? y/[N]: ").lower() != "y":
        return

    strategy.harvest({"from": dev, 'gas_price': Wei("25 gwei")})
Example #9
0
def main():
    deployer = accounts.load(input("deployer account: "))

    vault = Vault.at(get_address("vault"))

    deposit_limit = Wei('2000 ether')
    vault.setDepositLimit(deposit_limit, {"from": deployer})

    balance = vault.setPerformanceFee(1000, {"from": deployer})

    newGov = get_address("gov")

    vault.setGovernance(newGov, {"from": deployer})
Example #10
0
    def rule_new_deployment(self, new_token="st_bool"):
        tokens_with_stale_deployments = [
            token for token, deployments in self.vaults.items()
            if Version(deployments[-1].apiVersion()) < self.latest_version
        ]
        if new_token or len(tokens_with_stale_deployments) == 0:
            token = self.create_token()
        else:
            token = tokens_with_stale_deployments[-1]

        print(f"Registry.newVault({token}, {self.latest_version})")
        vault = Vault.at(
            self.registry.newVault(token, self.gov, self.gov, "",
                                   "").return_value)

        if token in self.vaults:
            self.vaults[token].append(vault)
        else:
            self.vaults[token] = [vault]
Example #11
0
def migrate():
    assert rpc.is_active()
    vault = Vault.at(get_address("vault"))
    gov = accounts.at(vault.governance(), force=True)
    old_strategy = StrategyBalancerLP.at(get_address("old strategy"))
    new_strategy = StrategyBalancerLP.deploy(vault, {"from": gov})
    print("pricePerShare", vault.pricePerShare().to("ether"))
    print("estimatedTotalAssets",
          old_strategy.estimatedTotalAssets().to("ether"))
    vault.migrateStrategy(old_strategy, new_strategy, {"from": gov})
    print("pricePerShare", vault.pricePerShare().to("ether"))
    print("estimatedTotalAssets",
          new_strategy.estimatedTotalAssets().to("ether"))
    keeper = accounts.at(new_strategy.keeper(), force=True)
    for i in range(2):
        new_strategy.harvest({"from": keeper})
        print("pricePerShare", vault.pricePerShare().to("ether"))
        print("estimatedTotalAssets",
              new_strategy.estimatedTotalAssets().to("ether"))
Example #12
0
def migrate():
    assert rpc.is_active()
    vault = Vault.at(get_address('vault'))
    gov = accounts.at(vault.governance(), force=True)
    old_strategy = StrategyUniswapPairPickle.at(get_address('old strategy'))
    new_strategy = StrategyUniswapPairPickle.deploy(vault, old_strategy.jar(),
                                                    old_strategy.pid(),
                                                    {'from': gov})
    print('pricePerShare', vault.pricePerShare().to('ether'))
    print('estimatedTotalAssets',
          old_strategy.estimatedTotalAssets().to('ether'))
    vault.migrateStrategy(old_strategy, new_strategy, {'from': gov})
    print('pricePerShare', vault.pricePerShare().to('ether'))
    print('estimatedTotalAssets',
          new_strategy.estimatedTotalAssets().to('ether'))
    keeper = accounts.at(new_strategy.keeper(), force=True)
    for i in range(2):
        new_strategy.harvest({'from': keeper})
        print('pricePerShare', vault.pricePerShare().to('ether'))
        print('estimatedTotalAssets',
              new_strategy.estimatedTotalAssets().to('ether'))
Example #13
0
def main():
    click.echo(f"You are using the '{network.show_active()}' network")
    dev = accounts.load(click.prompt("Account", type=click.Choice(accounts.load())))
    click.echo(f"You are using: 'dev' [{dev.address}]")

    registry = Registry.at(
        get_address("Vault Registry", default="v2.registry.ychad.eth")
    )

    latest_release = Version(registry.latestRelease())
    num_releases = registry.numReleases() - 1
    target_release_index = num_releases
    release_delta = 0
    click.echo(
        f"""
        Release Information

        latest release version: {latest_release}
          latest release index: {num_releases}
         local package version: {PACKAGE_VERSION}
        """
    )
    use_proxy = False  # NOTE: Use a proxy to save on gas for experimental Vaults
    if Version(PACKAGE_VERSION) <= latest_release:
        click.echo(
            f"""
        Recommended Releases

        DO NOT USE => 0-2
        0.3.2 => 3
        0.3.3 => 4
        0.3.4 => 5 (DO NOT USE) 
        0.3.5 => 6
        0.4.0 => 7 (DO NOT USE)
        0.4.1 => 8
        """
        )
        target_release_index = click.prompt(
            "Please select a target release index from options or press enter for latest release:",
            type=click.Choice([str(i) for i in range(num_releases + 1)]),
            default=num_releases,
        )
        if click.confirm("Deploy a Proxy Vault", default="Y"):
            use_proxy = True
    elif Version(PACKAGE_VERSION) > latest_release:
        target_release_index = num_releases + 1
        if not click.confirm(f"Deploy {PACKAGE_VERSION} as new release"):
            return

    token = Token.at(get_address("ERC20 Token"))

    if use_proxy:
        gov_default = (
            "0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7"  # strategist msig, no ENS
        )
    else:
        gov_default = "ychad.eth"
    gov = get_address("Yearn Governance", default=dev.address)

    rewards = get_address("Rewards contract", default="treasury.ychad.eth")
    guardian = get_address("Vault Guardian", default="dev.ychad.eth")
    management = get_address("Vault Management", default="brain.ychad.eth")
    name = click.prompt(f"Set description", default=DEFAULT_VAULT_NAME(token))
    symbol = click.prompt(f"Set symbol", default=DEFAULT_VAULT_SYMBOL(token))
    release_delta = num_releases - target_release_index
    target_release = (
        Vault.at(registry.releases(target_release_index)).apiVersion()
        if release_delta >= 0
        else PACKAGE_VERSION
    )

    click.echo(
        f"""
    Vault Deployment Parameters

         use proxy: {use_proxy}
    target release: {target_release}
     release delta: {release_delta}
     token address: {token.address}
      token symbol: {DEFAULT_VAULT_SYMBOL(token)}
        governance: {gov}
        management: {management}
           rewards: {rewards}
          guardian: {guardian}
              name: '{name}'
            symbol: '{symbol}'
    """
    )

    if click.confirm("Deploy New Vault"):
        args = [
            token,
            gov,
            rewards,
            # NOTE: Empty string `""` means no override (don't use click default tho)
            name if name != DEFAULT_VAULT_NAME(token) else "",
            symbol if symbol != DEFAULT_VAULT_SYMBOL(token) else "",
        ]
        if use_proxy:
            # NOTE: Must always include guardian, even if default
            args.insert(2, guardian)
            args.append(release_delta)
            txn_receipt = registry.newExperimentalVault(*args, {"from": dev, "gas_price": Wei('9 gwei'), "required_confs": 0})
            vault = Vault.at(txn_receipt.events["NewExperimentalVault"]["vault"])
            click.echo(f"Experimental Vault deployed [{vault.address}]")
            click.echo("    NOTE: Vault is not registered in Registry!")
        else:
            args.append(guardian)
            args.append(management)
            vault = Vault.deploy({"from": dev, "gas_price": Wei('9 gwei'), "required_confs": 0})
            vault.initialize(*args)
            click.echo(f"New Vault Release deployed [{vault.address}]")
            click.echo(
                "    NOTE: Vault is not registered in Registry, please register!"
            )
Example #14
0
def main():
    print(f"You are using the '{network.show_active()}' network")
    bot = accounts.load("bot")
    print(f"You are using: 'bot' [{bot.address}]")
    # TODO: Allow adding/removing strategies during operation
    strategies = [interface.StrategyAPI(get_address("Strategy to farm: "))]
    while input("Add another strategy? (y/[N]): ").lower() == "y":
        strategies.append(interface.StrategyAPI(get_address("Strategy to farm: ")))

    vault = Vault.at(strategies[0].vault())
    want = Token.at(vault.token())

    for strategy in strategies:
        assert (
            strategy.keeper() == bot.address
        ), "Bot is not set as keeper! [{strategy.address}]"
        assert (
            strategy.vault() == vault.address
        ), f"Vault mismatch! [{strategy.address}]"

    while True:
        starting_balance = bot.balance()

        calls_made = 0
        total_gas_estimate = 0
        for strategy in strategies:
            # Display some relevant statistics
            symbol = want.symbol()
            credit = vault.creditAvailable(strategy) / 10 ** vault.decimals()
            print(f"[{strategy.address}] Credit Available: {credit:0.3f} {symbol}")
            debt = vault.debtOutstanding(strategy) / 10 ** vault.decimals()
            print(f"[{strategy.address}] Debt Outstanding: {debt:0.3f} {symbol}")

            starting_gas_price = next(gas_strategy.get_gas_price())

            try:
                tend_gas_estimate = int(
                    GAS_BUFFER * strategy.tend.estimate_gas({"from": bot})
                )
                total_gas_estimate += tend_gas_estimate
            except ValueError:
                print(f"[{strategy.address}] `tend` estimate fails")
                tend_gas_estimate = None

            try:
                harvest_gas_estimate = int(
                    GAS_BUFFER * strategy.harvest.estimate_gas({"from": bot})
                )
                total_gas_estimate += harvest_gas_estimate
            except ValueError:
                print(f"[{strategy.address}] `harvest` estimate fails")
                harvest_gas_estimate = None

            if harvest_gas_estimate and strategy.harvestTrigger(
                harvest_gas_estimate * starting_gas_price
            ):
                try:
                    strategy.harvest({"from": bot, "gas_price": gas_strategy})
                    calls_made += 1
                except:
                    print(f"[{strategy.address}] `harvest` call fails")

            elif tend_gas_estimate and strategy.tendTrigger(
                tend_gas_estimate * starting_gas_price
            ):
                try:
                    strategy.tend({"from": bot, "gas_price": gas_strategy})
                    calls_made += 1
                except:
                    print(f"[{strategy.address}] `tend` call fails")

        # Check running 10 `tend`s & `harvest`s per strategy at estimated gas price
        # would empty the balance of the bot account
        if bot.balance() < 10 * total_gas_estimate * starting_gas_price:
            print(f"Need more ether please! {bot.address}")

        # Wait a minute if we didn't make any calls
        if calls_made > 0:
            gas_cost = (starting_balance - bot.balance()) / 10 ** 18
            num_harvests = bot.balance() // (starting_balance - bot.balance())
            print(f"Made {calls_made} calls, spent {gas_cost} ETH on gas.")
            print(
                f"At this rate, it'll take {num_harvests} harvests to run out of gas."
            )
        else:
            print("Sleeping for 60 seconds...")
            sleep(60)
Example #15
0
def main():
    click.echo(f"You are using the '{network.show_active()}' network")
    dev = accounts.load(
        click.prompt("Account", type=click.Choice(accounts.load())))
    click.echo(f"You are using: 'dev' [{dev.address}]")

    registry = Registry.at(
        get_address("Vault Registry", default="v2.registry.ychad.eth"))

    latest_release = Version(registry.latestRelease())
    use_proxy = False  # NOTE: Use a proxy to save on gas for experimental Vaults
    if Version(PACKAGE_VERSION) < latest_release:
        click.echo("Cannot deploy Vault for old API version")
        return
    elif Version(PACKAGE_VERSION) > latest_release:
        if not click.confirm(f"Deploy {PACKAGE_VERSION} as new release"):
            return
    else:
        if not click.confirm("Deploy Experimental Vault"):
            return
        use_proxy = True

    token = Token.at(get_address("ERC20 Token"))
    gov = get_address("Yearn Governance", default="ychad.eth")
    rewards = get_address("Rewards contract",
                          default="0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde")
    guardian = get_address("Vault Guardian", default=dev.address)
    name = click.prompt(f"Set description", default=DEFAULT_VAULT_NAME(token))
    symbol = click.prompt(f"Set symbol", default=DEFAULT_VAULT_SYMBOL(token))

    click.echo(f"""
    Vault Parameters

   version: {PACKAGE_VERSION}
     token: {token.address}
  governer: {gov}
   rewards: {rewards}
  guardian: {guardian}
      name: '{name}'
    symbol: '{symbol}'
    """)

    if click.confirm("Deploy New Vault"):
        args = [
            token,
            gov,
            rewards,
            # NOTE: Empty string `""` means no override (don't use click default tho)
            name if name != DEFAULT_VAULT_NAME(token) else "",
            symbol if symbol != DEFAULT_VAULT_SYMBOL(token) else "",
        ]
        if use_proxy:
            # NOTE: Must always include guardian, even if default
            args.insert(3, guardian)
            txn_receipt = registry.newExperimentalVault(*args, {"from": dev})
            vault = Vault.at(
                txn_receipt.events["NewExperimentalVault"]["vault"])
            click.echo(f"Experimental Vault deployed [{vault.address}]")
            click.echo("    NOTE: Vault is not registered in Registry!")
        else:
            if guardian != dev.address:
                # NOTE: Only need to include if guardian is not self
                args.push(guardian)
            vault = dev.deploy(Vault)
            vault.initialize(*args)
            click.echo(f"New Vault Release deployed [{vault.address}]")
            click.echo(
                "    NOTE: Vault is not registered in Registry, please register!"
            )
Example #16
0
def main():
    dai = interface.ERC20('0x6b175474e89094c44da98b954eedeac495271d0f')
    strategy = YearnDaiCompStratV2.at(
        '0x5b62F24581Ea4bc6d6C5C101DD2Ae7233E422884')
    vault = Vault.at('0x9B142C2CDAb89941E9dcd0B6C1cf6dEa378A8D7C')

    print(f'strategy YearnDaiCompStratV2: {strategy.address}')
    print(f'Vault: {vault.address}')
    print(f'Vault name: {vault.name()} and symbol: {vault.symbol()}')
    strategist_confirmed = strategy.strategist()
    print(f'Strategy strategist: {strategist_confirmed}')

    account_name = input(f"What account to use?: ")
    dev = accounts.load(account_name)
    print(f"You are using: 'dev' [{dev.address}]")
    devDai = dai.balanceOf(dev).to('ether')
    print(f"You're DAI balance is: [{devDai}]")
    are_you_strategist = strategist_confirmed == dev.address
    print(f"Are you strategist? {are_you_strategist}")

    if input("Continue? y/[N]: ").lower() != "y":
        return

    deposit_limit = Wei('100000 ether')
    deposit_limit_eth = deposit_limit.to('ether')

    if input(f"Set deposit limit to: {deposit_limit_eth}?").lower() != "y":
        return

    vault.setDepositLimit(deposit_limit, {
        "from": dev,
        'gas_price': Wei("17 gwei")
    })

    if input(f"Add strategy: {strategy} ?").lower() != "y":
        return

    vault.addStrategy(strategy, deposit_limit, deposit_limit, 50, {
        "from": dev,
        'gas_price': Wei("17 gwei")
    })

    amount = Wei('500 ether')
    amountE = amount.to('ether')

    if input(f"approve: {amountE} DAI?").lower() != "y":
        return
    dai.approve(vault, amount * 100, {
        "from": dev,
        'gas_price': Wei("17 gwei")
    })

    print('deposit amount:', amount.to('ether'))
    if input("Continue? y/[N]: ").lower() != "y":
        return
    vault.deposit(amount, {"from": dev, 'gas_price': Wei("17 gwei")})

    print('harvest time')
    if input("Continue? y/[N]: ").lower() != "y":
        return

    strategy.harvest({"from": dev, 'gas_price': Wei("16 gwei")})
Example #17
0
 def sign_vault_permit(
     vault: Vault,
     owner: Account,  # NOTE: Must be a eth_key account, not Brownie
     spender: str,
     allowance: int = 2**256 - 1,  # Allowance to set with `permit`
     deadline: int = 0,  # 0 means no time limit
     override_nonce: int = None,
 ):
     name = "Yearn Vault"
     version = vault.apiVersion()
     chain_id = 1  # ganache bug https://github.com/trufflesuite/ganache/issues/1643
     if override_nonce:
         nonce = override_nonce
     else:
         nonce = vault.nonces(owner.address)
     data = {
         "types": {
             "EIP712Domain": [
                 {
                     "name": "name",
                     "type": "string"
                 },
                 {
                     "name": "version",
                     "type": "string"
                 },
                 {
                     "name": "chainId",
                     "type": "uint256"
                 },
                 {
                     "name": "verifyingContract",
                     "type": "address"
                 },
             ],
             "Permit": [
                 {
                     "name": "owner",
                     "type": "address"
                 },
                 {
                     "name": "spender",
                     "type": "address"
                 },
                 {
                     "name": "value",
                     "type": "uint256"
                 },
                 {
                     "name": "nonce",
                     "type": "uint256"
                 },
                 {
                     "name": "deadline",
                     "type": "uint256"
                 },
             ],
         },
         "domain": {
             "name": name,
             "version": version,
             "chainId": chain_id,
             "verifyingContract": str(vault),
         },
         "primaryType": "Permit",
         "message": {
             "owner": owner.address,
             "spender": spender,
             "value": allowance,
             "nonce": nonce,
             "deadline": deadline,
         },
     }
     permit = encode_structured_data(data)
     return owner.sign_message(permit).signature