示例#1
0
def main():
    """
    $ brownie run deploy.py --network rinkeby
    :return:
    """
    acct = accounts.load('flyer')
    Token.deploy("My Real Token", "RLT", 18, 1e28, {'from': acct})
示例#2
0
def main():
    deployer = accounts.load('deployer')
    lp_token = Token.deploy("Ellipsis.finance BUSD/USDC/USDT", "3EPS", 0,
                            {"from": deployer})
    fee_converter = FeeConverter.deploy({"from": deployer})
    airdrop_distro = MerkleDistributor.deploy(
        deployer, "0x7EeAC6CDdbd1D0B8aF061742D41877D7F707289a",
        {'from': deployer})

    coins = [
        "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",  # busd
        "0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",  # usdc
        "0x55d398326f99059fF775485246999027B3197955"  # usdt
    ]
    swap = StableSwap.deploy(
        deployer,
        coins,  # coins,
        lp_token,
        1500,  # A
        4000000,  # fee
        5000000000,  # admin fee
        fee_converter,
        {"from": deployer},
    )
    lp_token.set_minter(swap, {"from": deployer})

    initial_supply = TOTAL_SUPPLY // 5 + (5000 * 10**18)
    eps = Token.deploy("Ellipsis", "EPS", initial_supply, {"from": deployer})

    cake = Contract('0x05ff2b0db69458a0750badebc4f9e13add608c7f')
    tx = cake.addLiquidityETH(eps, 5000 * 10**18, 5000 * 10**18, 10**18,
                              deployer, 2000000000, {'from': deployer})
    cakelp = tx.events['PairCreated']['pair']

    per_period = [
        int(i * 100000) * TOTAL_SUPPLY // 100000 for i in REWARD_AMOUNTS
    ]
    durations = [
        REWARD_OFFSETS[i + 1] - REWARD_OFFSETS[i]
        for i in range(len(REWARD_OFFSETS) - 1)
    ]
    rewards_per_block = [
        per_period[i] // durations[i] for i in range(len(durations))
    ] + [0]
    offsets = [i + LAUNCH_OFFSET for i in REWARD_OFFSETS]

    lp_staker = LpTokenStaker.deploy(offsets, rewards_per_block, cakelp,
                                     {"from": deployer})
    lp_staker.addPool(lp_token, 0, {'from': deployer})

    eps_staker = MultiFeeDistribution.deploy(eps, [lp_staker, airdrop_distro],
                                             {"from": deployer})
    eps_staker.addReward(coins[0], fee_converter, {'from': deployer})

    lp_staker.setMinter(eps_staker, {"from": deployer})
    eps.set_minter(eps_staker, {'from': deployer})
    fee_converter.setFeeDistributor(eps_staker, {"from": deployer})
    airdrop_distro.setMinter(eps_staker, {'from': deployer})
示例#3
0
def main():
    A = Token.deploy("Token A", "TOKA", 18, 1e21, {'from': accounts[0]})
    B = Token.deploy("Token B", "TOKB", 18, 1e21, {'from': accounts[0]})

    man = Manager.deploy(A, B, 10, 0, {'from': accounts[0]})


# A=Token.deploy("Token A", "TOKA", 18, 1e21, {'from': accounts[0]})
# B=Token.deploy("Token B", "TOKB", 18, 1e21, {'from': accounts[0]})
# man=Manager.deploy(A, B, 10, 0,{'from': accounts[0]})
示例#4
0
def main():
    acct = accounts.load("AAVE")
    A = Token.deploy("Token A", "TOKA", 18, 0, {'from': acct})
    B = Token.deploy("Token B", "TOKB", 18, 0, {'from': acct})
    Stable = Token.deploy("Dai Stablecoin", "Dai", 18, 10000000000,
                          {'from': acct})
    man = Manager.deploy(A, B, Stable, 10, 0, {'from': acct})

    A.transferPower(man, {'from': acct})
    B.transferPower(man, {'from': acct})
示例#5
0
def main():
    #user1 = accounts.load("user1")
    acct = accounts.load("AAVE")

    A = Token.at("0x982328095bC12d3a8b0B75be1e9FDce4c011202a")
    man = Manager.at("0x7927b309535ba4B1D6F42c1aF76a6757Fe45AB58")

    print("BEFORE REDEEM Atoken and Eth balance")
    # #token A balance
    print(A.balanceOf(acct))
    # # eth balance
    print(acct.balance())
    man.requestState("0x4712020ca7e184c545fd2483696c9dc36cb7c36a",
                     "ca0d86424890466f856de3e868087f81", {'from': acct})
    time.sleep(90)
    man.redeem({'from': acct})
    print("~~~~~~~~~~~~~~~~~~~~~~~~~")
    print("post redeem, pre fufill")
    #token A balance
    print(A.balanceOf(acct))
    # eth balance
    print(user1.balance())

    print("~~~~~~~~~~~~~~~~~~~~~~~~~")
    print("post redeem, POST FUFILL")
    #token A balance
    print(A.balanceOf(user1))
    # eth balance
    print(user1.balance())
示例#6
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")
    })
示例#7
0
def test_transfer_adjusts_sender_balance():
    token = Token.deploy("Test Token", "TST", 18, 10**21, {'from': accounts[0]})
    balance = token.balanceOf(accounts[0])
    
    token.transfer(accounts[1], 10**18, {'from': accounts[0]})
    
    assert token.balanceOf(accounts[0]) == balance - 10**18
示例#8
0
def main():
    token = Token.deploy({'from': accounts[0]})
    dao = Dao.deploy(token, {'from': accounts[0]})
    for account in accounts:
        token.transfer(account, Wei('1 ether'))
        token.approve(dao.address, Wei('0.1 ether'), {'from': account})
        dao.deposit(Wei('0.01 ether'), {'from': account})
    print(len(Dao))
示例#9
0
def main():
    acct = accounts[0]
    token = Token.deploy("My Real Token", "RLT", 18, 1e28, {'from': acct})
    curve = '0x93054188d876f558f4a66B2EF1d97d16eDf0895B'
    registry = '0xe80d347df1209a76dd9d2319d62912ba98c54ddd'
    wbtc = '0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599'

    adapter = CurveExchangeAdapter.deploy(curve, registry, wbtc, acct, token,
                                          {'from': acct})
示例#10
0
文件: ezToken.py 项目: asa-Q/vaults
def main():
    tk = Token.deploy("Test Token", "TST", 18, 1e21, {'from': accounts[0]})
    ac0 = accounts[0]
    ac1 = accounts[1]
    ac2 = accounts[2]
    print(tk.balanceOf(ac0))
    print(tk.balanceOf(ac1))
    tk.transfer(ac1, 5000, {'from': ac0})
    print(tk.balanceOf(ac0))
    print(tk.balanceOf(ac1))
示例#11
0
def main():
    print(f"You are using the '{network.show_active()}' network")
    dev = accounts.load("dev")
    print(f"You are using: 'dev' [{dev.address}]")
    token = Token.at(get_address("ERC20 Token: "))
    gov = get_address("Yearn Governance: ")
    rewards = get_address("Rewards contract: ")
    name = input(f"Set description ['yearn {token.name()}']: ") or ""
    symbol = input(f"Set symbol ['y{token.symbol()}']: ") or ""
    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 = dev.deploy(Vault, token, gov, rewards, name, symbol)
示例#12
0
def main():
    token = Token.deploy("Test Token", "TST", 18, 1e20, {'from': accounts[1]})

    transfer = Transfer.deploy({"from": accounts[0]})
    print(f"Gas used to deploy the contract {transfer.tx.gas_used}")
    print(f"------------------------------------------------------")

    t = accounts[0].transfer(transfer.address, 10**18)
    print(f"Gas used to pay ETH {t.gas_used}")
    print(f"------------------------------------------------------")

    t = transfer.transfer(ZERO_ADDRESS, accounts[1], 10**17,
                          {'from': accounts[0]})
    print(f"Gas used to pay ETH using the contract contract {t.gas_used}")
    print(f"------------------------------------------------------")

    t = transfer.transferAndDestruct(ZERO_ADDRESS, accounts[1], 10**17,
                                     {'from': accounts[0]})
    print(f"Gas used to pay ETH by destoying the contract {t.gas_used}")
    print(f"------------------------------------------------------")

    # Token gas usage
    transfer = Transfer.deploy({"from": accounts[0]})
    t = token.transfer(transfer.address, 10**18, {'from': accounts[1]})
    print(f"Gas used to send ERC20 to a contract {t.gas_used}")
    print(f"------------------------------------------------------")

    t = transfer.transfer(token.address, accounts[1], 10**17,
                          {'from': accounts[0]})
    print(f"Gas used to send ERC20 using the contract {t.gas_used}")
    print(f"------------------------------------------------------")

    t = transfer.transferAndDestruct(token.address, accounts[1], 10**17,
                                     {'from': accounts[0]})
    print(f"Gas used to send ERC20 by destoying the contract {t.gas_used}")
    print(f"------------------------------------------------------")
示例#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!"
            )
示例#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)
def main():
    acct = accounts.load("AAVE")
    return Token.deploy("Token A", "TOKA", 18, 1e21, {'from': acct})
示例#16
0
def main():
    acct = accounts.load("metamask")
    return Token.deploy("Test Token", "TST", 18, 1e21, {'from': acct})
示例#17
0
文件: deploy.py 项目: stegos/ERC20
def main():
    acct = accounts.load('stg')
    return Token.deploy("Stegos", "STG", 6, 1e15, {'from': acct})
示例#18
0
def main():
    accounts.load('metamask')
    return Token.deploy("Test Token", "TST", 18, 1e21, {'from': accounts[0]})
def test_transfer_fails_from_insufficient_balance():
    token = Token.deploy("Test Token", "TST", 18, 10**21, {'from': accounts[0]})
   
    with brownie.reverts("Insufficient balance"):
        token.transfer(accounts[2], 10**18, {'from': accounts[1]})
示例#20
0
def main():
    # return Token.deploy("Test Token", "TST", 18, 1e21, {'from': accounts[0]})
    return Token.deploy("Test Token", "TST", 18, 100, {'from': accounts[0]})
示例#21
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!"
            )
def main():
    return Token.deploy("Token B", "TOKB", 18, 1e21, {'from': accounts[0]})
示例#23
0
def token():
    return Token.deploy("Test Token", "TST", 18, 10**21, {'from': accounts[0]})
示例#24
0
def main():
    t = Token.deploy("Test Token", "TST", 18, 1e21, {'from': accounts[0]})
    print('owner balance: ', t.balanceOf(accounts[0]))
    return t
示例#25
0
 def sign_token_permit(
     token: Token,
     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,
 ):
     chain_id = 1  # ganache bug https://github.com/trufflesuite/ganache/issues/1643
     if override_nonce:
         nonce = override_nonce
     else:
         nonce = token.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": token.name(),
             "version": "1",
             "chainId": chain_id,
             "verifyingContract": str(token),
         },
         "primaryType": "Permit",
         "message": {
             "owner": owner.address,
             "spender": spender,
             "value": allowance,
             "nonce": nonce,
             "deadline": deadline,
         },
     }
     permit = encode_structured_data(data)
     return owner.sign_message(permit)