Beispiel #1
0
def test_tip_after_withdrawn(ygift, token, giftee, chain, duration):
    amount = Wei("1000 ether")
    tip = amount / 2
    start = chain[-1].timestamp
    token.approve(ygift, 2**256 - 1)
    ygift.mint(giftee, token, amount, "name", "msg", "url", start, duration)
    chain.sleep(duration)
    ygift.collect(0, 2**256 - 1, {"from": giftee})
    ygift.tip(0, tip, "tip")
    ygift.collect(0, 2**256 - 1, {"from": giftee})
    gift = ygift.gifts(0).dict()
    assert gift["amount"] == 0
    assert gift["tipped"] == 0
    assert token.balanceOf(giftee) == amount + tip
Beispiel #2
0
def test_change_debt_with_profit(gov, token, vault, dudesahn, whale, strategy,
                                 curveVoterProxyStrategy):
    token.approve(vault, 2**256 - 1, {"from": whale})
    vault.deposit(100e18, {"from": whale})
    strategy.harvest({"from": dudesahn})
    prev_params = vault.strategies(strategy).dict()

    currentDebt = vault.strategies(strategy)[2]
    vault.updateStrategyDebtRatio(strategy, currentDebt / 2, {"from": gov})
    token.transfer(strategy, Wei("100 ether"), {"from": whale})

    # need to harvest our other strategy first so we don't pay all of the management fee from this strategy
    curveVoterProxyStrategy.harvest({"from": gov})
    strategy.harvest({"from": dudesahn})
    new_params = vault.strategies(strategy).dict()

    assert new_params["totalGain"] > prev_params["totalGain"]
    assert new_params["totalGain"] - prev_params["totalGain"] > Wei(
        "100 ether")
    assert new_params["debtRatio"] == currentDebt / 2
    assert new_params["totalLoss"] == prev_params["totalLoss"]
    assert approx(vault.totalAssets() * 0.012,
                  Wei("1 ether")) == strategy.estimatedTotalAssets()
def test_revoke_live(token_ecrv, strategy_ecrv_live, vault_ecrv_live, whale,
                     gov_live):
    token_ecrv.approve(vault_ecrv_live, 2**256 - 1, {"from": whale})
    vault_ecrv_live.deposit(Wei("100 ether"), {"from": whale})
    strategy_ecrv_live.harvest({"from": gov_live})

    genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live)
    genericStateOfVault(vault_ecrv_live, token_ecrv)

    vault_ecrv_live.revokeStrategy(strategy_ecrv_live, {"from": gov_live})
    strategy_ecrv_live.harvest({"from": gov_live})

    genericStateOfStrat(strategy_ecrv_live, token_ecrv, vault_ecrv_live)
    genericStateOfVault(vault_ecrv_live, token_ecrv)
Beispiel #4
0
def test_wrapped_props(accounts, distributor, launcpad, dai, niftsy20, weth):
    for i in range(distributor.balanceOf(launcpad)):
        logging.info('tokenId={}, erc20Balance={}, {}, ETHBalance = {}'.format(
            distributor.tokenOfOwnerByIndex(launcpad, i),
            Wei(
                distributor.getERC20CollateralBalance(
                    distributor.tokenOfOwnerByIndex(launcpad, i),
                    niftsy20)).to('ether'),
            Wei(
                distributor.getERC20CollateralBalance(
                    distributor.tokenOfOwnerByIndex(launcpad, i),
                    weth)).to('ether'),
            distributor.getTokenValue(
                distributor.tokenOfOwnerByIndex(launcpad, i))[0]))
        assert distributor.getERC20CollateralBalance(
            distributor.tokenOfOwnerByIndex(launcpad, i),
            niftsy20) == ERC20_COLLATERAL_AMOUNT
        assert distributor.getERC20CollateralBalance(
            distributor.tokenOfOwnerByIndex(launcpad, i),
            weth) == ERC20_COLLATERAL_AMOUNT_WETH
        assert distributor.getTokenValue(
            distributor.tokenOfOwnerByIndex(launcpad,
                                            i))[0] == Wei(ETH_AMOUNT) / COUNT
Beispiel #5
0
def main():
    tree = json.load(open("snapshot/04-merkle.json"))
    user = get_user()
    dist = MerkleDistributor.at(DISTRIBUTOR, owner=user)
    if user not in tree["claims"]:
        return click.secho(f"{user} is not included in the distribution", fg="red")
    claim = tree["claims"][user]
    if dist.isClaimed(claim["index"]):
        return click.secho(f"{user} has already claimed", fg="yellow")

    amount = Wei(claim["amount"]).to("ether")
    _amount = click.style(f"{amount:,.2f} PYTHO", fg="green", bold=True)
    print(f"Claimable amount: {_amount}")
    dist.claim(claim["index"], user, claim["amount"], claim["proof"])
Beispiel #6
0
def test_good_migration(
    strategy, chain, Strategy, web3, vault, currency, whale, rando, gov, strategist
):
    # Call this once to seed the strategy with debt
    deposit_limit = Wei("1000 ether")
    vault.setDepositLimit(deposit_limit, {"from": gov})
    vault.addStrategy(strategy, 10_000, 0, 2 ** 256 - 1, 50, {"from": gov})

    amount1 = Wei("500 ether")
    deposit(amount1, whale, currency, vault)

    amount1 = Wei("50 ether")
    deposit(amount1, gov, currency, vault)

    strategy.harvest({"from": gov})
    sleep(chain, 10)
    strategy.harvest({"from": gov})

    strategy_debt = vault.strategies(strategy).dict()["totalDebt"]
    prior_position = strategy.estimatedTotalAssets()
    assert strategy_debt > 0

    new_strategy = strategist.deploy(Strategy, vault)
    assert vault.strategies(new_strategy).dict()["totalDebt"] == 0
    assert currency.balanceOf(new_strategy) == 0

    # Only Governance can migrate
    with brownie.reverts():
        vault.migrateStrategy(strategy, new_strategy, {"from": rando})

    vault.migrateStrategy(strategy, new_strategy, {"from": gov})
    assert vault.strategies(strategy).dict()["totalDebt"] == 0
    assert vault.strategies(new_strategy).dict()["totalDebt"] == strategy_debt
    assert (
        new_strategy.estimatedTotalAssets() > prior_position * 0.999
        or new_strategy.estimatedTotalAssets() < prior_position * 1.001
    )
Beispiel #7
0
def test_various(
    chain,
    gov,
    vault,
    rewards,
    strategist,
    strategy,
    wFTM,
    wFTM_whale,
    alice,
    bob,
    fUSD,
    fusdVault,
    fUSD_whale,
):
    wFTM.transfer(alice, Wei("1000 ether"), {"from": wFTM_whale})
    wFTM.approve(vault, 2 ** 256 - 1, {"from": alice})
    vault.deposit({"from": alice})

    # harvest
    strategy.harvest({"from": gov})
    chain.sleep(604800)  # 1 week
    chain.mine(1)

    # Donate some fUSD to the fusdVault to mock earnings
    fUSD.transfer(fusdVault, Wei("10 ether"), {"from": fUSD_whale})

    wFTM.transfer(bob, Wei("2000 ether"), {"from": wFTM_whale})
    wFTM.approve(vault, 2 ** 256 - 1, {"from": bob})
    vault.deposit({"from": bob})

    # Run Harvest
    strategy.harvest({"from": gov})
    chain.sleep(604800)  # 1 week
    chain.mine(1)
    vault.withdraw({"from": alice})

    # Donate some fUSD to the fusdVault to mock earnings
    fUSD.transfer(fusdVault, Wei("100 ether"), {"from": fUSD_whale})
    # Run Harvest
    strategy.harvest({"from": gov})
    chain.sleep(604800)  # 1 week
    chain.mine(1)
    vault.withdraw({"from": bob})

    assert wFTM.balanceOf(alice) > Wei("1000 ether")
    assert wFTM.balanceOf(bob) > Wei("1000 ether")
    assert strategy.balanceOfCollateral() == 0
    assert strategy.balanceOfDebt() == 0
    assert strategy.balanceOfFusd() < Wei("0.5 ether")  # rounding error
    assert strategy.balanceOfFusdInVault() == 0
    assert fusdVault.totalAssets() == 0
def test_claim_allocation_1(accounts,  launcpadWLNative, distributor, dai, niftsy20, weth, ERC721Distr, whitelist):

    whitelist.increaseAllocationBatch([accounts[2], accounts[3]], zero_address, [Wei(ETH_AMOUNT)/10, 2*Wei(ETH_AMOUNT)/10], {"from": accounts[0]})
    assert whitelist.availableAllocation(accounts[2], zero_address) == Wei(ETH_AMOUNT)/10
    assert whitelist.availableAllocation(accounts[3], zero_address) == 2*Wei(ETH_AMOUNT)/10

    whitelist.decreaseAllocationBatch([accounts[2], accounts[3]], zero_address, [0.4*Wei(ETH_AMOUNT)/10, Wei(ETH_AMOUNT)/10], {"from": accounts[0]})
    assert whitelist.availableAllocation(accounts[2], zero_address) == 0.6*Wei(ETH_AMOUNT)/10
    assert whitelist.availableAllocation(accounts[3], zero_address) == Wei(ETH_AMOUNT)/10
def test_claim_Ether(accounts, launcpadWL, distributor, dai, niftsy20, weth,
                     ERC721Distr):
    #not enough ether
    with reverts("Received amount less then price"):
        launcpadWL.claimNFT(1, zero_address, {"value": '0.01 ether'})

    #enough ether and there is the change - claim
    bbe1 = accounts[0].balance()
    payAmount = launcpadWL.getWNFTPrice(1, zero_address) + Wei(change_amount)
    launcpadWL.claimNFT(1, zero_address, {"value": payAmount})

    assert accounts[0].balance() == bbe1 - launcpadWL.getWNFTPrice(
        1, zero_address)
    assert launcpadWL.balance() == launcpadWL.getWNFTPrice(1, zero_address)
    assert distributor.balanceOf(launcpadWL) == COUNT - 1
    assert distributor.balanceOf(accounts[0]) == 1

    #unwrap claimed token
    bbe0 = accounts[0].balance()
    bbn0 = niftsy20.balanceOf(accounts[0])
    bbw0 = weth.balanceOf(accounts[0])

    bbeD = distributor.balance()
    bbnD = niftsy20.balanceOf(distributor)
    bbwD = weth.balanceOf(distributor)

    distributor.unWrap721(1)

    assert bbe0 + Wei(ETH_AMOUNT) / COUNT == accounts[0].balance()
    assert bbn0 + ERC20_COLLATERAL_AMOUNT == niftsy20.balanceOf(accounts[0])
    assert bbw0 + ERC20_COLLATERAL_AMOUNT_WETH == weth.balanceOf(accounts[0])

    assert bbeD - Wei(ETH_AMOUNT) / COUNT == distributor.balance()
    assert bbnD - ERC20_COLLATERAL_AMOUNT == niftsy20.balanceOf(distributor)
    assert bbwD - ERC20_COLLATERAL_AMOUNT_WETH == weth.balanceOf(distributor)

    assert distributor.balanceOf(accounts[0]) == 0
Beispiel #10
0
def test_apr(gov, vault, hegic, hegicStaking, strategy):
    hegic.approve(vault, 2**256 - 1, {"from": gov})
    vault.addStrategy(
        strategy,
        10_000,
        0,
        500,
        {"from": gov},  # 500 bps fee for strategist
    )

    vault.deposit(Wei("888000 ether"), {"from": gov})
    strategy.harvest()
    assert hegic.balanceOf(strategy) == 0
    startingBalance = vault.totalAssets()
    assert startingBalance == Wei("888000 ether")

    stateOfStrat(strategy, hegic, hegicStaking)
    stateOfVault(vault, strategy)

    for i in range(10):
        day = (1 + i) * ONE_DAY
        print(f"\n----Day {day/ONE_DAY}----")

        hegicStaking.sendProfit({"value": Wei("0.1 ether")})
        strategy.harvest()
        stateOfStrat(strategy, hegic, hegicStaking)
        stateOfVault(vault, strategy)

        profit = (vault.totalAssets() - startingBalance).to("ether")
        strState = vault.strategies(strategy)
        totalReturns = strState[6]
        totaleth = totalReturns.to("ether")
        print(f"Real Profit: {profit:.5f}")

        day = (1 + i) * ONE_DAY
        apr = (totalReturns / startingBalance) * (DAYS_PER_YEAR / day)
        print(f"implied apr: {apr:.8%}")
Beispiel #11
0
def test_withdraw_before_and_after_transfer(ygift, token, giftee, receiver,
                                            chain):
    amount = Wei("100 ether")
    start = chain[-1].timestamp
    token.approve(ygift, 2**256 - 1)
    ygift.mint(giftee, token, amount, "name", "msg", "url", start, 0)
    ygift.collect(0, amount / 2, {"from": giftee})
    gift = ygift.gifts(0).dict()
    assert gift["amount"] == amount / 2
    assert token.balanceOf(giftee) == amount / 2
    ygift.safeTransferFrom(giftee, receiver, 0, {"from": giftee})
    ygift.collect(0, amount / 4, {"from": receiver})
    gift = ygift.gifts(0).dict()
    assert gift["amount"] == amount / 4
    assert token.balanceOf(receiver) == amount / 4
def test_transfer_liquidity(liquid_lgt, accounts):
    sender, recipient = accounts[:2]
    sender_initial_liquidity = liquid_lgt.poolBalanceOf(sender)
    recipient_initial_liquidity = liquid_lgt.poolBalanceOf(recipient)
    transfer_amount = Wei("0.01 ether")
    tx = liquid_lgt.poolTransfer(recipient, transfer_amount, {'from': sender})
    assert tx.return_value
    event = tx.events['TransferLiquidity']
    assert event["from"] == sender
    assert event["to"] == recipient
    assert event["value"] == transfer_amount
    assert sender_initial_liquidity - transfer_amount == liquid_lgt.poolBalanceOf(
        sender)
    assert recipient_initial_liquidity + transfer_amount == liquid_lgt.poolBalanceOf(
        recipient)
Beispiel #13
0
def test_cannot_withdraw_not_owned_gift(ygift, token, giftee, chain, receiver):
    amount = Wei("100 ether")
    start = chain[-1].timestamp
    token.approve(ygift, 2**256 - 1)
    ygift.mint(giftee, token, amount * 10, "name", "msg", "url", start, 0)
    with brownie.reverts("yGift: You are not the NFT owner"):
        ygift.collect(0, amount, {"from": receiver})
    with brownie.reverts("yGift: You are not the NFT owner"):
        ygift.collect(0, amount * 10, {"from": receiver})
    with brownie.reverts("yGift: You are not the NFT owner"):
        ygift.collect(0, amount * 100, {"from": receiver})

    ygift.collect(0, amount * 5, {"from": giftee})
    with brownie.reverts("yGift: You are not the NFT owner"):
        ygift.collect(0, amount * 5, {"from": receiver})
Beispiel #14
0
def test_revoke(token_ecrv, strategy_ecrv, vault_ecrv, whale, gov, strategist):
    token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale})
    vault_ecrv.deposit(Wei("100 ether"), {"from": whale})
    strategy_ecrv.harvest({"from": strategist})
    assert token_ecrv.balanceOf(vault_ecrv) < dust

    genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv)
    genericStateOfVault(vault_ecrv, token_ecrv)

    vault_ecrv.revokeStrategy(strategy_ecrv, {"from": gov})

    strategy_ecrv.harvest({"from": strategist})

    genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv)
    genericStateOfVault(vault_ecrv, token_ecrv)
def whale(accounts, web3, weth, gov, chain):
    #big binance7 wallet
    #acc = accounts.at('0xBE0eB53F46cd790Cd13851d5EFf43D12404d33E8', force=True)
    #big binance8 wallet
    acc = accounts.at('0xf977814e90da44bfa03b6295a0616a897441acec', force=True)

    #lots of weth account
    wethAcc = accounts.at('0x767Ecb395def19Ab8d1b2FCc89B3DDfBeD28fD6b', force=True)

    weth.transfer(acc, weth.balanceOf(wethAcc),{"from": wethAcc} )

    weth.transfer(gov, Wei('100 ether'),{"from": acc} )

    assert  weth.balanceOf(acc) > 0
    yield acc
Beispiel #16
0
def test_withdraw_gas(nftbox, voucher, minter, accounts, chain):
    voucher.setCaller(nftbox, True, {'from':minter})
    nftbox.setBoxVoucher(voucher, {'from':minter})
    nftbox.createBoxMould(50, 50, 20, Wei('0.1 ether'), [], [], "This is a test box", "", "", "", "", {'from':minter})
    for i in range(1, 6):
        voucher.safeTransferFrom(minter, accounts[i], 1, 4, "", {'from':minter})
        with brownie.reverts('!price'):
            nftbox.reserveBoxes(1, 4, {'from':accounts[i]})
        nftbox.reserveBoxes(1, 4, {'from':accounts[i], 'value': Wei('0.1 ether') * 4 * 21 // 20})
    nftbox.setLockOnBox(1, False, {'from':minter})
    with brownie.reverts('ERC1155: burn amount exceeds balance'):
        nftbox.buyBoxesWithVouchers(1, 2, {'from':accounts[0], 'value':Wei('0.1 ether') * 2})
    nftbox.distributeReservedBoxes(1, 10, {'from':minter})
    assert nftbox.getReservationCount(1) == 10
    assert nftbox.voucherValidityInterval(1) == 0
    nftbox.distributeReservedBoxes(1, 13, {'from':minter})
    assert nftbox.getReservationCount(1) == 0
    assert nftbox.voucherValidityInterval(1) != 0
    for i in range(1, 6):
        assert nftbox.balanceOf(accounts[i]) == 4
    pre = minter.balance()
    nftbox.withdrawGasMoney({'from':minter})
    assert minter.balance() == pre + 20 * 5 * Wei('0.1 ether') // 100
    assert nftbox.balance() == 20 * Wei('0.1 ether')
Beispiel #17
0
def test_forward_with_value_exact(liquid_lgt, relayer, storage, accounts):
    """ send 0.2 ether with the call and buy 2 tokens """
    initial_tokens = liquid_lgt.poolTokenReserves()
    initial_balance = accounts[0].balance()
    calldata = "bc25bd200000000000000000000000000000000000000000000000000000000000000000"
    expected_eth_sold = liquid_lgt.getEthToTokenOutputPrice(6)
    total_ether = Wei(expected_eth_sold + "0.2 ether")
    tx = relayer.forward(6, DEADLINE, storage, "0.2 ether", calldata, {
        'from': accounts[0],
        'value': total_ether
    })
    assert tx.return_value == expected_eth_sold
    assert storage.get() == "0.2 ether"
    assert initial_tokens - 6 == liquid_lgt.poolTokenReserves()
    assert initial_balance - total_ether == accounts[0].balance()
def badger_hunt_unit():
    deployer = accounts[0]
    badger = deploy_badger_minimal(deployer)
    distribute_from_whales(deployer)

    badger.deploy_logic("BadgerHunt", BadgerHunt)
    badger.deploy_badger_hunt()

    source = accounts.at("0x394DCfbCf25C5400fcC147EbD9970eD34A474543",
                         force=True)

    badger.token.transfer(badger.badgerHunt, Wei("100000 ether"),
                          {"from": source})

    return badger
Beispiel #19
0
def main():
    badger = connect_badger(load_deployer=True)

    safe = ApeSafe(badger.opsMultisig.address)
    helper = ApeSafeHelper(badger, safe)
    logger = helper.contract_from_abi(badger.rewardsLogger.address,
                                      "RewardsLogger", RewardsLogger.abi)

    schedules = []

    # Concat schedules for all vaults
    for key in vaults_to_run:
        vault = badger.getSett(key)

        start = 1625158800
        duration = days(7)
        end = start + duration

        badger_amount = Wei("360 ether")

        schedules.append(
            LoggerUnlockSchedule((
                vault,
                badger.token.address,
                badger_amount,
                start,
                end,
                duration,
            )), )

    # Add all schedules to logger
    for i in range(0, len(schedules)):
        schedule = schedules[i]
        logger.setUnlockSchedule(
            schedule.beneficiary,
            schedule.token,
            schedule.amount,
            schedule.start,
            schedule.end,
            schedule.duration,
        )

    # Print
    for key in vaults_to_run:
        vault = badger.getSett(key)
        badger.print_logger_unlock_schedules(vault, name=vault.name())

    helper.publish()
Beispiel #20
0
def test_owner_recovers_only_eth(deployer, stranger, steth_token):
    insurance_purchaser = InsurancePurchaser.deploy(steth_to_eth_max_slippage,
                                                    ldo_to_steth_max_slippage,
                                                    {"from": deployer})

    stranger.transfer(insurance_purchaser.address, "1 ether")
    deployer_eth_before = deployer.balance()

    steth_balance = steth_token.balanceOf(deployer)

    # you can pass here any token
    insurance_purchaser.recover_erc20(steth_token.address, steth_balance,
                                      {"from": deployer})

    assert insurance_purchaser.balance() == 0
    assert deployer.balance() - deployer_eth_before == Wei("1 ether")
def testLoaner(accounts, requireMainnetFork, flashLoaner, WETH, iETH):
    print("flashLoaner.address", flashLoaner.address)

    amount = Wei('500 ether')

    tx = flashLoaner.doStuffWithFlashLoan(WETH.address, iETH.address, amount)

    balances = tx.events["BalanceOf"]
    assert (balances[0]["balance"] == 0)
    assert (balances[1]["balance"] == amount)
    assert (balances[2]["balance"] == 0)

    executeOperation = tx.events['ExecuteOperation']
    assert (executeOperation[0]["loanToken"] == WETH.address)
    assert (executeOperation[0]["iToken"] == iETH.address)
    assert (executeOperation[0]["loanAmount"] == amount)
Beispiel #22
0
def test_tip(ygift, token, giftee, chain):
    amount = Wei("1000 ether")
    tip = amount * 2
    start = chain[-1].timestamp
    token.approve(ygift, 2**256 - 1)
    ygift.mint(giftee, token, amount, "name", "msg", "url", start, 1000)
    ygift.tip(0, tip, "tip")
    gift = ygift.gifts(0).dict()
    assert gift["amount"] == amount
    assert gift["tipped"] == tip
    # tips are available instantly
    chain.sleep(500)
    chain.mine()
    assert ygift.collectible(0) >= tip
    ygift.collect(0, tip, {"from": giftee})
    assert token.balanceOf(giftee) == tip
def main():
    safe = ApeSafe('0xD089cc83f5B803993E266ACEB929e52A993Ca2C8')
    agent_address = '0x3e40d73eb977dc6a537af587d48316fee66e9c8c'

    eth_spent = 0

    for cover in unslashed_covers:
        print("Calc cover for ", cover["policy_name"])
        eth_to_cover = cover["damage_eth_covered"]

        if eth_to_cover == 0:
            continue

        um = safe.contract(cover["marketAddress"])
        ut = interface.ERC20(cover["premiumToken"])

        deposit_delta = um.coverToPremiumTokens(
            eth_to_cover * 1e18) * um.premiumTokenPrice18eRatio() / 1e18

        print("Cover for", eth_to_cover, " ETH")
        print("ETH required to make deposit: ", deposit_delta / 1e18)

        premium_balance_before = ut.balanceOf(agent_address)
        um.depositPremium({'value': deposit_delta})
        premium_balance_after = ut.balanceOf(agent_address)
        print("Premium tokens delta: ",
              (premium_balance_after - premium_balance_before) / 1e18)
        print("Premium tokens balance after: ", (premium_balance_after) / 1e18)
        print("ETH amount", Wei(deposit_delta), deposit_delta / 1e18)

        eth_spent += deposit_delta

    print("total ETH to spend", eth_spent / 1e18)

    safe_tx = safe.multisend_from_receipts()
    print("safe tx preview:")
    safe.preview(safe_tx)

    sys.stdout.write('Are you sure (y/n)? ')

    if not prompt_bool():
        print('Aborting')
        return

    safe.post_transaction(safe_tx)

    print("safe tx sent!")
Beispiel #24
0
def test_not_buyable_edition_many(nftbox, minter, accounts):
    nftbox.createBoxMould(5, Wei('0.01 ether'), [1, 2, 3, 4], [], [], "This is a test box", {'from':minter})
    with brownie.reverts("NFTBoxes: Minting too many boxes."):
        nftbox.buyManyBoxes(1, 6, {'from':accounts[0], "value": Wei("0.01 ether") * 6})
    nftbox.buyManyBoxes(1, 3, {'from':accounts[0], "value": Wei("0.01 ether") * 3})
    with brownie.reverts("NFTBoxes: Minting too many boxes."):
        nftbox.buyManyBoxes(1, 6, {'from':accounts[0], "value": Wei("0.01 ether") * 6})
    nftbox.buyManyBoxes(1, 2, {'from':accounts[0], "value": Wei("0.01 ether") * 2})

    with brownie.reverts("NFTBoxes: Minting too many boxes."):
        nftbox.buyManyBoxes(1, 1, {'from':accounts[0], "value": Wei("0.01 ether")})
Beispiel #25
0
def test_mint(ygift, token, giftee, chain):
    amount = Wei("1000 ether")
    start = chain[-1].timestamp + 1000
    duration = 1000
    token.approve(ygift, 2**256 - 1)
    ygift.mint(giftee, token, amount, "name", "msg", "url", start, duration)
    gift = ygift.gifts(0).dict()
    assert gift == {
        "token": token,
        "name": "name",
        "message": "msg",
        "url": "url",
        "amount": amount,
        "tipped": 0,
        "start": start,
        "duration": duration,
    }
Beispiel #26
0
def test_revoke(token_ecrv, strategy_ecrv, vault_ecrv, whale, gov, strategist):
    debt_ratio = 10_000
    vault_ecrv.addStrategy(strategy_ecrv, debt_ratio, 0, 1000, {"from": gov})

    token_ecrv.approve(vault_ecrv, 2**256 - 1, {"from": whale})
    vault_ecrv.deposit(Wei("100 ether"), {"from": whale})
    strategy_ecrv.harvest({"from": strategist})

    genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv)
    genericStateOfVault(vault_ecrv, token_ecrv)

    vault_ecrv.revokeStrategy(strategy_ecrv, {"from": gov})

    strategy_ecrv.harvest({"from": strategist})

    genericStateOfStrat(strategy_ecrv, token_ecrv, vault_ecrv)
    genericStateOfVault(vault_ecrv, token_ecrv)
def test_clone(gov, vault, keeper, strategy, strategist, Strategy):

    # Do the regular add strategy with the regular one
    vault.setDepositLimit(Wei("1000000 ether"), {"from": gov})
    vault.addStrategy(strategy, 10_000, 0, 2**256 - 1, 1_000, {"from": gov})

    # Switch rewards with keeper to make sure the proxy worked
    tx = strategy.clone(vault, strategist, keeper, strategist)
    new_strategy = Strategy.at(tx.return_value)

    # Check that we have the same thing but with keeper/rewards switched
    assert new_strategy.keeper() != new_strategy.rewards()
    assert strategy.keeper() == new_strategy.rewards()
    assert strategy.rewards() == new_strategy.keeper()

    # Migrate to the new proxied strategy
    vault.migrateStrategy(strategy, new_strategy, {"from": gov})
Beispiel #28
0
def test_harvest(accounts,  farming, niftsy20):
    collateral = farming.getERC20CollateralBalance(1, niftsy20)
    logging.info('col = {}'.format(collateral))
    logging.info('avail = {}'.format(farming.getAvailableRewardAmount(1, niftsy20)))
    logging.info('rasch = {}'.format(farming.getRewardSettings(niftsy20)[3][1]*farming.getERC20CollateralBalance(1, niftsy20)/10000))
    rewards = farming.rewards(1)
    farming.harvest(1, niftsy20.address, {'from':accounts[0]})
    logging.info('getERC20CollateralBalance({},{})={}'.format(
        1,
        niftsy20,
        Wei(farming.getERC20CollateralBalance(1, niftsy20)).to('ether')
    ))

    assert collateral + farming.getRewardSettings(niftsy20)[3][1]*collateral/10000 == farming.getERC20CollateralBalance(1, niftsy20)
    assert rewards[0] < farming.rewards(1)[0]
    logging.info('rewwww = {}'.format(farming.rewards(1)[1]))
    assert farming.rewards(1)[1] == 0
Beispiel #29
0
def test_balances(gov, hegic, hegicStaking, vault, strategy):
    hegic.approve(vault, 2**256 - 1, {"from": gov})
    vault.addStrategy(strategy, 10_000, 0, 0, {"from": gov})

    # deposit 888001 in total to test
    vault.deposit(Wei("888001 ether"), {"from": gov})
    strategy.harvest()
    hegicStaking.sendProfit({"value": Wei("1 ether")})

    assert strategy.balanceOfWant() == Wei("1 ether")
    assert strategy.balanceOfStake() == Wei("888000 ether")
    assert strategy.ethFutureProfit() == Wei("1 ether")
    assert strategy.hegicFutureProfit() == Wei("3076 ether")
Beispiel #30
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",
    )