def main():
    """
    Transfer badger to recipient, ensuring they are approved as recipient first
    Use test tx, full tx model
    Can convert from dollar value
    """

    badger = connect_badger()
    multisig = badger.devMultisig

    safe = ApeSafe(multisig.address)
    helper = ApeSafeHelper(badger, safe)

    rewardsEscrow = safe.contract(badger.rewardsEscrow.address)

    recipient = badger.badgerRewardsManager

    # token = badger.token
    # amount = Wei("30000 ether")

    token = badger.digg.token
    amount = Wei("2 gwei")

    if not rewardsEscrow.isApproved(recipient):
        rewardsEscrow.approveRecipient(recipient)

    rewardsEscrow.transfer(token, recipient, amount)

    helper.publish()
예제 #2
0
def main():
    badger = connect_badger()
    digg = badger.digg
    safe = ApeSafe(badger.devMultisig.address)

    abi = Sett.abi

    badgerToken = safe.contract(badger.token.address)
    diggToken = safe.contract(digg.token.address)
    bBadger = safe.contract_from_abi(
        badger.getSett("native.badger").address, "Sett", abi)
    bDigg = safe.contract_from_abi(
        badger.getSett("native.digg").address, "Sett", abi)
    rewardsEscrow = safe.contract(badger.rewardsEscrow.address)

    # Exchange renBTC for wBTC

    wbtc = tokens.erc20_by_key("wbtc")
    renbtc = tokens.erc20_by_key("renbtc")

    snap = BalanceSnapshotter([wbtc, renbtc], [badger.devMultisig])

    snap.snap(name="Before", print=True)

    crv_swap(badger, safe, amount_in=367606868, max_slippage=0.005)

    snap.snap(name="After")
    snap.diff_last_two()

    helper = ApeSafeHelper(badger, safe)
    helper.publish()
def main():
    """
    First, swap half of the USDC into DAI
    Deposit USDC portion in to Yearn USDC Vault V2
    Deposit DAI portion in to Yearn DAI Vault V2
    For the deposits, create small test transactions first
    """

    badger = connect_badger()

    safe = ApeSafe(badger.paymentsMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    # Fetch tokens for snap + interactions
    usdc = safe.contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
    dai = safe.contract("0x6B175474E89094C44Da98b954EedeAC495271d0F")
    yDai = safe.contract("0x19D3364A399d251E894aC732651be8B0E4e85001")
    yUsdc = safe.contract("0x5f18C75AbDAe578b483E5F43f12a39cF75b973a9")

    usdc_to_swap = 35000 * 10**6  ## 1.5 * 10^6 (Million) * 10^6 (Decimals)

    # TODO: Track the balances of the tokens representing your position here: AAVE USDC (aUSDC), Compound USDC (cUSDC), y3Crv Vault Position (y3Crv)
    snap = BalanceSnapshotter(
        [usdc, dai, yDai, yUsdc],
        [
            badger.paymentsMultisig,
        ],
    )
    snap.snap()

    current_dai_balance = dai.balanceOf(badger.devMultisig.address)

    ## NOTE: Swap to DAI with Curve
    ## Coins[0] == DAI
    ## Coins[1] == UDC
    curve_pool = safe.contract("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7")
    dai_out = curve_pool.get_dy(1, 0, usdc_to_swap)

    with_slippage = dai_out * 0.99
    print("With slippage")
    print(with_slippage)

    usdc.approve(curve_pool.address, usdc_to_swap)
    curve_pool.exchange(1, 0, usdc_to_swap, with_slippage)

    post_swap_balance = dai.balanceOf(badger.devMultisig.address)
    dai_to_deposit = post_swap_balance - current_dai_balance
    print("dai_to_deposit")
    print(dai_to_deposit)

    chain.sleep(10)
    chain.mine()

    snap.snap()
    snap.diff_last_two()

    ## Publish all Txs
    helper.publish()
예제 #4
0
def main():
    badger = connect_badger()
    safe = ApeSafe(badger.devMultisig.address)
    badgerTree = safe.contract(badger.badgerTree.address)
    badgerTree.grantRole(ROOT_PROPOSER_ROLE, to_add)
    badgerTree.revokeRole(ROOT_PROPOSER_ROLE, to_remove)

    helper = ApeSafeHelper(badger, safe)
    helper.publish()
예제 #5
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()
def main():
    badger = connect_badger()
    safe = ApeSafe(badger.testMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    for source_key in to_approve:
        source = badger.getStrategy(source_key).address
        # source = helper.contract_from_abi(badger.getStrategy(source_key), "StrategyConvexStakingOptimizer", StrategyConvexStakingOptimizer.abi)
        for dest_key in destination_setts:
            destination = helper.contract_from_abi(
                badger.getSett(dest_key).address, "SettV3", SettV3.abi)
            console.print(
                f"Approve [green]{source}[/green] on Sett [yellow]{dest_key} ({destination.address})"
            )
            destination.approveContractAccess(source)

    helper.publish()
예제 #7
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 = build_weekly_schedules(badger, start, duration)
    console.print(schedules)
    set_schedules(logger, schedules)

    for key in badger.getAllSettIds():
        sett = badger.getSett(key)
        badger.print_logger_unlock_schedules(sett.address, name=sett.name())

    helper.publish()
def main():
    # Connect badger system from file
    badger = connect_badger()

    # Sanity check file addresses
    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert badger.devMultisig == expectedMultisig

    safe = ApeSafe(badger.devMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    setts = [
        helper.getSett("native.renCrv"),
        helper.getSett("native.tbtcCrv"),
        helper.getSett("native.sbtcCrv"),
        helper.getSett("native.sushiWbtcEth"),
    ]

    for contract in contracts_to_approve:
        for sett in setts:
            console.print(
                f"Approving contract access for: \n {contract} on \n [green]{sett.address}"
            )
            sett.approveContractAccess(contract)
            assert sett.approved(contract) == True

    helper.publish()
예제 #9
0
def main():
    badger = connect_badger()

    bDigg = badger.getSett("native.digg")

    # rug = accounts.at(web3.toChecksumAddress("0x533e3c0e6b48010873b947bddc4721b1bdff9648"), force=True)
    # print(bDigg.balanceOf(rug))
    # bDigg.transfer(badger.devMultisig, amount, {"from": rug})

    bDigg_to_deposit = amount
    print("bDigg_to_deposit", bDigg_to_deposit)
    round_1 = Wei("1 ether")
    round_2 = bDigg_to_deposit - round_1

    safe = ApeSafe(badger.devMultisig.address)
    bDigg = safe.contract_from_abi(
        "0x7e7E112A68d8D2E221E11047a72fFC1065c38e1a", "Sett", Sett.abi)
    dropt = safe.contract_from_abi(
        web3.toChecksumAddress("0x02660b54750efab874fb43b4b613c135c7815eef"),
        "SyntheticToken",
        SyntheticToken.abi,
    )
    kpiOptions = safe.contract_from_abi(
        web3.toChecksumAddress("0xbc044745f137d4693c2aa823c760f855254fad42"),
        "ExpiringMultiParty",
        ExpiringMultiParty.abi,
    )

    snap = BalanceSnapshotter([bDigg, dropt],
                              [badger.devMultisig, kpiOptions, dropt])

    snap.snap()

    bDigg.approve(kpiOptions, bDigg_to_deposit)
    kpiOptions.create([round_1], [int(round_1 * 1000)])
    kpiOptions.create([round_2], [int(round_2 * 1000)])
    chain.mine()

    snap.snap()

    snap.diff_last_two()

    helper = ApeSafeHelper(badger, safe)
    helper.publish()
예제 #10
0
def main():
    # Connect badger system from file
    badger = connect_badger()

    # Sanity check file addresses
    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert badger.devMultisig == expectedMultisig

    safe = ApeSafe(badger.devMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    sett = helper.getSett("native.renCrv")

    for contract in contracts_to_approve:
        sett.approveContractAccess(contract)

    assert sett.approved(contract) == True

    helper.publish()
def main():
    """
    Add contracts manually to guest list. They will now be approved regardless of merkle root situation
    """
    badger = connect_badger()
    safe = ApeSafe(badger.testMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    for sett_key in setts:
        sett = helper.contract_from_abi(
            badger.getSett(sett_key).address, "SettV4", SettV4.abi)
        guestList = badger.getGuestList(sett_key)

        old_state = {
            "guestList": sett.guestList(),
            "guestRoot": guestList.guestRoot(),
            "totalCap": guestList.totalDepositCap(),
            "userCap": guestList.userDepositCap(),
            "wrapper": guestList.wrapper(),
        }

        sett.setGuestList(guestList)

        print("proxyAdmin", badger.getProxyAdmin(guestList))

        new_state = {
            "guestList": sett.guestList(),
            "guestRoot": guestList.guestRoot(),
            "totalCap": guestList.totalDepositCap(),
            "userCap": guestList.userDepositCap(),
            "wrapper": guestList.wrapper(),
        }

        assert new_state["guestList"] != old_state["guestList"]
        assert new_state["guestList"] == guestList

        assert new_state["guestRoot"] == old_state["guestRoot"]
        assert new_state["totalCap"] == old_state["totalCap"]
        assert new_state["userCap"] == old_state["userCap"]
        assert new_state["wrapper"] == old_state["wrapper"]

    helper.publish()
예제 #12
0
def test_main():
    """
    What contracts are required?
    Sett (Proxy)
    GuestList (Proxy)
    Strategy (Logic + Proxy)

    What addresses do I need?
    Fee splitter
    Mushroom fee address
    All that good stuff
    """
    badger = connect_badger()
    digg = badger.digg
    dev = badger.deployer

    distribute_from_whales(dev, assets=["digg"])
    digg.token.transfer(badger.devMultisig, digg.token.balanceOf(dev), {"from": dev})

    multi = GnosisSafe(badger.devMultisig)
    safe = ApeSafe(badger.devMultisig.address)
    ops = ApeSafe(badger.opsMultisig.address)
    helper = ApeSafeHelper(badger, safe)
    controller = safe.contract("0x9b4efA18c0c6b4822225b81D150f3518160f8609")

    controller.setVault()

    """
    address _token,
    address _controller,
    address _governance,
    address _keeper,
    address _guardian,
    bool _overrideTokenName,
    string memory _namePrefix,
    string memory _symbolPrefix
    """

    for i in range(0, len(assets)):
        asset = interface.IERC20(assets[i])
        vault = interface.ISett(vaults[i])

        vault.initialize(
            asset,
            controller,
            badger.devMultisig,
            badger.keeper,
            badger.guardian,
            False,
            "",
            "",
        )

        controller.setVault(asset, vault)
예제 #13
0
def main():
    badger = connect_badger(load_deployer=True)
    admin = badger.devProxyAdmin
    multisig = badger.devMultisig
    contracts = badger.contracts_upgradeable
    deployer = badger.deployer

    safe = ApeSafe(badger.opsMultisig.address)
    logger = safe.contract(badger.rewardsLogger.address)

    experimental_vault = "0x8a8ffec8f4a0c8c9585da95d9d97e8cd6de273de"

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

    badger_amount = int(Wei("4000 ether") * .9)
    digg_amount = int(fragments_to_shares(0.4) * .9)
    dfd_amount = int(Wei("205131 ether") * .9)

    schedules = [
        LoggerUnlockSchedule((experimental_vault, badger.token.address, badger_amount, start, end, duration)),
        LoggerUnlockSchedule((experimental_vault, badger.digg.token.address, digg_amount, start, end, duration)),
        LoggerUnlockSchedule((experimental_vault, registry.tokens.dfd, dfd_amount, start, end, duration))
    ]

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

    badger.print_logger_unlock_schedules(experimental_vault, name="Experimental iBBTC Vault")
    
    helper = ApeSafeHelper(badger, safe)
    helper.publish()
예제 #14
0
def main():
    """
    Add contracts manually to guest list. They will now be approved regardless of merkle root situation
    """
    badger = connect_badger()
    safe = ApeSafe(badger.testMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    for guest_list_key in guest_lists_by_id:
        guestList = helper.contract_from_abi(
            badger.getGuestList(guest_list_key).address,
            "VipCappedGuestListBbtcUpgradeable",
            VipCappedGuestListBbtcUpgradeable.abi,
        )
        console.print(
            f"Set guest root to [green]{root}[/green] on Guest list [yellow]{guest_list_key} ({guestList.address})[/yellow]"
        )
        guestList.setGuestRoot(root)
        assert guestList.guestRoot() == root

    helper.publish()
예제 #15
0
def main():
    """
    Promote an experimental vault to official status
    """

    key = "experimental.sushiIBbtcWbtc"

    badger = connect_badger()
    safe = ApeSafe(badger.devMultisig.address)
    ops = ApeSafe(badger.opsMultisig.address)

    experimental_controller = safe.contract(
        badger.getController("experimental").address
    )
    native_controller = ops.contract(badger.getController("native").address)

    # Set experimental strategist to ops multisig
    experimental_controller.setStrategist(badger.opsMultisig)

    # Move contract upgradability behind timelock
    admin = ops.contract(badger.opsProxyAdmin.address)
    sett = ops.contract(badger.getSett("experimental.sushiIBbtcWbtc").address)
    strategy = ops.contract(badger.getStrategy("experimental.sushiIBbtcWbtc").address)

    assert badger.getProxyAdmin(sett) == badger.opsProxyAdmin
    assert badger.getProxyAdmin(strategy) == badger.opsProxyAdmin

    admin.changeProxyAdmin(sett, badger.devProxyAdmin)
    admin.changeProxyAdmin(strategy, badger.devProxyAdmin)

    assert badger.devProxyAdmin.owner() == badger.governanceTimelock

    # Move Sett to native controller
    sett.setController(native_controller)
    native_controller.setVault(sett.token(), sett)
    native_controller.approveStrategy(sett.token(), strategy)
    native_controller.setStrategy(sett.token(), strategy)

    helper = ApeSafeHelper(badger, safe)
    helper.publish()
예제 #16
0
def main():
    """
    Add contracts manually to guest list. They will now be approved regardless of merkle root situation
    """
    badger = connect_badger()
    safe = ApeSafe(badger.testMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    for strategy_key in strategies_to_approve:
        strategy_address = badger.getStrategy(strategy_key).address
        source = helper.contract_from_abi(
            badger.getStrategy(strategy_key).address,
            "StrategyConvexStakingOptimizer",
            StrategyConvexStakingOptimizer.abi,
        )

        for guest_list_key in guest_lists_by_id:
            guestList = helper.contract_from_abi(
                badger.getGuestList(guest_list_key).address,
                "VipCappedGuestListBbtcUpgradeable",
                VipCappedGuestListBbtcUpgradeable.abi,
            )
            console.print(
                f"Approve [green]{strategy_address}[/green] on Guest list [yellow]{guest_list_key} ({guestList.address})[/yellow]"
            )
            guestList.setGuests([strategy_address], [True])
            assert guestList.guests(strategy_address) == True

    helper.publish()
예제 #17
0
def main():
    badger = connect_badger()

    if rpc.is_active():
        dev_multi = ApeSafe(badger.testMultisig.address)
        helper = ApeSafeHelper(badger, dev_multi)
    else:
        from helpers.gas_utils import gas_strategies

        gas_strategies.set_default(gas_strategies.exponentialScalingFast)

    # Deploy logic
    logic = GatedMiniMeController.deploy({"from": badger.deployer})
    logic.initialize(badger.token)

    # Deploy proxy

    # Create Aragon Vote

    # Execute Aragon Vote
    # badger.voteWithSystemContracts(voteId)

    helper.publish()
예제 #18
0
def main():
    """
    Promote an experimental vault to official status
    """
    badger = connect_badger(load_deployer=True)

    if rpc.is_active():
        dev_multi = ApeSafe(badger.testMultisig.address)
        helper = ApeSafeHelper(badger, dev_multi)
        assert True
    else:
        from helpers.gas_utils import gas_strategies

        gas_strategies.set_default(gas_strategies.exponentialScalingFast)
예제 #19
0
def main():
    """
    Transfer badger to recipient, ensuring they are approved as recipient first
    Use test tx, full tx model
    Can convert from dollar value

    Assumes each token is a safeContract
    """

    badger = connect_badger()
    digg = badger.digg
    multisig = badger.devMultisig

    safe = ApeSafe(multisig.address)
    helper = ApeSafeHelper(badger, safe)

    rewardsEscrow = helper.contract_from_abi(badger.rewardsEscrow.address,
                                             "RewardsEscrow",
                                             RewardsEscrow.abi)
    vesting = helper.contract_from_abi(badger.digg.daoDiggTimelock.address,
                                       "SimpleTimelock", SimpleTimelock.abi)
    # dfd = helper.contract_from_abi(registry.token_address_by_key("dfd"), "IERC20", interface.IERC20.abi)
    diggToken = helper.contract_from_abi(badger.digg.token.address, "IERC20",
                                         interface.IERC20.abi)

    transfers = [
        TransferOp(badger.paymentsMultisig, badger.token, Wei("51222 ether")),
        # TransferOp(badger.badgerTree, badger.token, Wei("20000 ether")),
        # TransferOp(badger.badgerTree, dfd, Wei("200000 ether")),
        # TransferOp(badger.badgerRewardsManager, badger.token, Wei("10000 ether")),
        # TransferOp(badger.badgerRewardsManager, diggToken, Wei("2 gwei")),
    ]

    snap = BalanceSnapshotter(
        [badger.token, badger.digg.token],
        [
            badger.badgerTree,
            badger.badgerRewardsManager,
            badger.devMultisig,
            badger.rewardsEscrow,
            badger.paymentsMultisig,
        ],
    )
    snap.snap()

    rewards_escrow_tokens = [badger.token]

    for transfer in transfers:
        recipient = transfer.recipient
        token = transfer.token
        amount = transfer.amount

        console.print("Transfer", recipient, token, amount)

        # Transfer from rewards escrow
        if token.address in rewards_escrow_tokens:
            if not rewardsEscrow.isApproved(recipient):
                rewardsEscrow.approveRecipient(recipient)
            rewardsEscrow.transfer(token, recipient, amount)

        # Default: Transfer from treasury
        else:
            # Unlock from vesting
            if token.address == badger.digg.token.address:
                vesting.release(amount)
            token.transfer(recipient, amount)

    snap.snap()
    snap.diff_last_two()

    helper.publish()
예제 #20
0
def main():
    badger = connect_badger()
    multisig = badger.paymentsMultisig

    safe = ApeSafe(multisig.address)
    helper = ApeSafeHelper(badger, safe)

    payments = load_ltcc_recipients("data/ltcc_recipients.csv")
    payments.calc_totals()
    payments.print_recipients()

    abi = Sett.abi
    bBadger = safe.contract_from_abi(
        badger.getSett("native.badger").address, "Sett", abi)

    usdcToken = safe.contract_from_abi(registry.tokens.usdc, "IERC20",
                                       interface.IERC20.abi)
    badgerToken = safe.contract_from_abi(badger.token.address, "IERC20",
                                         interface.IERC20.abi)

    snap = BalanceSnapshotter(
        [badgerToken, bBadger, usdcToken],
        [multisig, badger.deployer, badger.rewardsEscrow],
    )
    snap.snap()
    # TODO: Do this in bBadger going forward - this is the way.
    # Approve treasury multi to stake
    # Deposit badger -> bBadger
    # console.print(f"Converting total of {val(payments.totals['badger'])} badger into bBadger")

    # badgerToken.approve(bBadger, payments.totals['badger'])
    # bBadger.deposit(payments.totals['badger'])

    # snap.snap()
    # snap.diff_last_two()

    # helper.publish()
    # return True

    for recipient in payments.recipients:
        snap.add_account(recipient.address)

    snap.snap(name="Before Transfers")

    for recipient in payments.recipients:
        bBadger_amount = badger_to_bBadger(badger,
                                           recipient.get_amount("badger"))
        console.print(recipient.address, recipient.get_amount("badger"),
                      bBadger_amount)
        diff = bBadger_amount - bBadger.balanceOf(multisig)

        console.print(bBadger.balanceOf(multisig), diff)

        if bBadger.balanceOf(multisig) < bBadger_amount:
            assert diff < Wei("0.1 ether")
            bBadger_amount = bBadger.balanceOf(multisig)

        tx = usdcToken.transfer(recipient.address,
                                recipient.get_amount("usdc"))
        tx = bBadger.transfer(recipient.address, bBadger_amount)

    snap.snap(name="After Transfers")
    snap.diff_last_two()

    helper.publish()
예제 #21
0
def main():
    """
    First, swap half of the USDC into DAI
    Deposit USDC portion in to Yearn USDC Vault V2
    Deposit DAI portion in to Yearn DAI Vault V2
    For the deposits, create small test transactions first
    """

    badger = connect_badger()
    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert badger.devMultisig == expectedMultisig

    safe = ApeSafe(badger.devMultisig.address)
    helper = ApeSafeHelper(badger, safe)

    # Fetch tokens for snap + interactions
    usdc = safe.contract("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
    dai = safe.contract("0x6B175474E89094C44Da98b954EedeAC495271d0F")
    yDai = safe.contract("0x19D3364A399d251E894aC732651be8B0E4e85001")
    yUsdc = safe.contract("0x5f18C75AbDAe578b483E5F43f12a39cF75b973a9")

    usdc_to_deposit = "1500000000000"
    usdc_to_swap = "1500000000000"  ## 1.5 * 10^6 (Million) * 10^6 (Decimals)

    # TODO: Track the balances of the tokens representing your position here: AAVE USDC (aUSDC), Compound USDC (cUSDC), y3Crv Vault Position (y3Crv)
    snap = BalanceSnapshotter(
        [usdc, dai, yDai, yUsdc],
        [
            badger.devMultisig,
        ],
    )
    snap.snap()

    current_dai_balance = dai.balanceOf(badger.devMultisig.address)

    ## NOTE: Swap to DAI with Curve
    ## Coins[0] == DAI
    ## Coins[1] == UDC
    curve_pool = safe.contract("0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7")
    dai_out = curve_pool.get_dy(1, 0, usdc_to_swap)

    with_slippage = dai_out * 0.99
    print("With slippage")
    print(with_slippage)

    usdc.approve(curve_pool.address, usdc_to_swap)
    curve_pool.exchange(1, 0, usdc_to_swap, with_slippage)

    post_swap_balance = dai.balanceOf(badger.devMultisig.address)
    dai_to_deposit = post_swap_balance - current_dai_balance
    print("dai_to_deposit")
    print(dai_to_deposit)

    snap.snap()
    snap.diff_last_two()

    ## NOTE: Deposit DAI to Yearn
    ## TODO: Get balance of DAI to determine how to deposit
    yDaiVault = helper.contract_from_abi(
        "0x19D3364A399d251E894aC732651be8B0E4e85001",
        "yDaiVault",
        interface.VaultAPI.abi,
    )
    dai.approve(yDaiVault.address, dai_to_deposit)
    yDaiVault.deposit(dai_to_deposit)

    snap.snap()
    snap.diff_last_two()

    ## NOTE: Deposit USDC to Yearn
    yUsdcVault = helper.contract_from_abi(
        "0x5f18C75AbDAe578b483E5F43f12a39cF75b973a9",
        "yUsdcVault",
        iinterface.VaultAPI.abi,
    )

    usdc.approve(yUsdcVault.address, usdc_to_deposit)
    yUsdcVault.deposit(usdc_deposit_amount)

    ## DONE

    snap.snap()
    snap.diff_last_two()

    ## Publish all Txs
    helper.publish()
예제 #22
0
def main():
    """
    AAVE
    Compoound
    y3Crv
    """

    badger = connect_badger()
    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert badger.devMultisig == expectedMultisig

    # AAVE
    aave = registry.aave_system()
    tokens = registry.token_system()
    compound = registry.compound_system()
    usdc = tokens.erc20_by_key("usdc")
    dfd = tokens.erc20_by_key("dfd")
    ausdc = tokens.erc20_by_key("ausdc")
    cusdc = compound.ctoken("usdc")

    safe = ApeSafe(badger.devMultisig.address)

    # TODO: Track the balances of the tokens representing your position here: AAVE USDC (aUSDC), Compound USDC (cUSDC), y3Crv Vault Position (y3Crv)

    # TODO: Figure out the addresses of these derived tokens

    # TODO: Track the balances of all the appropriate contracts where the USDC ends up
    snap = BalanceSnapshotter(
        [usdc, ausdc, cusdc, dfd, badger.token],
        [
            badger.devMultisig,
            aave.lendingPool,
            cusdc,
            compound.comptroller,
            badger.badgerTree,
        ],
    )

    usdc_per_position = Wei("3237154580000 wei")  # szabo = 10^6
    round_1 = Wei("1000000 wei")
    round_2 = usdc_per_position - round_1

    print(round_1, round_2)
    lendingPool = safe.contract(aave.lendingPool.address)
    usdcToken = safe.contract(usdc.address)
    dfd = safe.contract(dfd.address)
    rewardsEscrow = safe.contract(badger.rewardsEscrow.address)
    comptroller = safe.contract(compound.comptroller.address)
    cusdc = safe.contract(cusdc.address)

    snap.snap()

    # Tree Tokens
    """
    Deposit badger from rewardsEscrow, and DFD from self. About 200k tokens.
    60k Badger
    200k DFD
    (We have plenty of DIGG)
    """
    # rewardsEscrow.transfer(badger.token, badger.badgerTree, Wei("50000 ether"))
    # dfd.transfer(badger.badgerTree, Wei("200000 ether"))

    # # AAVE Deposit Test
    # usdcToken.approve(aave.lendingPool, round_1)
    # lendingPool.deposit(usdc, round_1, badger.devMultisig, 0)

    # Compound Deposit Test
    """
    comptroller.enterMarkets([usdc])
    usdc.approve(cUSDC)
    cUSDC.mint(<usdc amount>)
    """

    # comptroller.enterMarkets([usdc])
    # usdcToken.approve(cusdc, round_1)
    # cusdc.redeem(round_1)
    # lendingPool.withdraw(usdc, round_1, badger.devMultisig)

    snap.snap()
    snap.diff_last_two()

    # AAVE Deposit Full
    usdcToken.approve(aave.lendingPool, round_2)
    lendingPool.deposit(usdc, round_2, badger.devMultisig, 0)

    # Compound Deposit Full
    usdcToken.approve(cusdc, round_2)
    cusdc.mint(round_2)

    snap.snap()
    snap.diff_last_two()

    helper = ApeSafeHelper(badger, safe)
    helper.publish()
    """