def main():
    block = 12428803
    badger = connect_badger()

    bbadger = list(
        calculate_sett_balances(badger, "native.badger",
                                block).userBalances.keys())

    uniBadger = list(
        calculate_sett_balances(badger, "native.uniBadgerWbtc",
                                block).userBalances.keys())

    sushiBadger = list(
        calculate_sett_balances(badger, "native.sushiBadgerWbtc",
                                block).userBalances.keys())

    badger_holders, digg_holders = fetch_wallet_balances(
        1, 1, badger.digg, block)

    with open("badger_holders.json", "w") as fp:
        json.dump(
            list(
                set([
                    *bbadger, *uniBadger, *sushiBadger,
                    *list(badger_holders.keys())
                ])),
            fp,
        )
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("deploy-final.json")
    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert badger.devMultisig == expectedMultisig

    multi = GnosisSafe(badger.devMultisig)

    # Parameters
    recipient = "0xd34C1d3853214bf049B760Ef48A580bfa7A9c8a1"
    dollars = 50000

    # amount = from_dollars(badger, badger.token.address, dollars)
    amount = Wei("15907.8892303 ether")

    params = {
        "dollars": dollars,
        "recipient": recipient,
        "amount": amount,
        "amount_scaled": val(amount),
        "use_test_payment": False
    }

    console.print("===== Pre Transfer =====", style="bold cyan")

    console.print(params)
    transfer_badger(recipient, params)

    console.print("===== Post Transfer =====", style="bold cyan")
示例#3
0
def main():
    badger = connect_badger(badger_config.prod_json)
    console.print("\n[white]===== 🦡 Sett Status 🦡 =====[white]\n")
    for key in badger.sett_system.vaults.keys():
        sett = badger.getSett(key)

        admin = badger.getProxyAdmin(sett)
        sett_impl = admin.getProxyImplementation(sett)
        sett_admin = admin.getProxyAdmin(sett)

        sett_type = badger.getSettType(key)

        print(key, sett_type)

        table = []

        table.append(["Sett Key", key])
        table.append(["Sett Type", sett_type])
        table.append(["Sett Logic", sett_impl])
        table.append(["Sett Admin", sett_admin])

        if sett_type == "v1":
            snap = SnapshotManager(badger, key)
            state = snap.snap()
            snap.printPermissions()
            # snap.printTable(state)
            strategy = badger.getStrategy(key)
            strategy_impl = badger.devProxyAdmin.getProxyImplementation(
                strategy)
            strategy_admin = admin.getProxyAdmin(strategy)
            table.append(["Strategy Logic", strategy_impl])
            table.append(["Strategy Admin", strategy_admin])

        print(tabulate(table, ["Key", "Value"]))
示例#4
0
def main():
    badger = connect_badger()

    deployer = badger.deployer
    governance = badger.devMultisig
    strategist = badger.deployer
    keeper = badger.keeper
    guardian = badger.guardian

    dfdMulti = accounts.at("0x5b5cF8620292249669e1DCC73B753d01543D6Ac7", force=True)
    sharedMulti = accounts.at("0xCF7346A5E41b0821b80D5B3fdc385EEB6Dc59F44", force=True)

    logic = Disperse.at("0x3b823864cd0cbad8a1f2b65d4807906775becaa7")
    distribute_from_whales(deployer, assets=["wbtc"])

    wbtc = interface.IERC20(registry.tokens.wbtc)
    wbtc.transfer(logic, wbtc.balanceOf(deployer) // 2, {"from": deployer})

    print(logic.payees())
    print(
        logic.isPayee(dfdMulti),
        logic.isPayee(badger.devMultisig),
        logic.isPayee(deployer),
    )
    # logic.initialize([badger.devMultisig, dfdMulti], [5000, 5000], {'from': deployer})

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

    # logic.disperseToken(wbtc, {"from": deployer})
    logic.disperseToken(wbtc, {"from": dfdMulti})

    snap.snap()
    snap.diff_last_two()
示例#5
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()
示例#6
0
def main():

    badger = connect_badger("deploy-final.json")

    deployer = badger.deployer
    controller = badger.getController("native")
    governance = badger.devMultisig
    strategist = badger.deployer
    keeper = badger.keeper
    guardian = badger.guardian

    for (key, strategyName, isUniswap) in [
        ("native.sushiWbtcIbBtc", "StrategySushiLpOptimizer", False),
        # ("native.uniWbtcIbBtc", "StrategyUniGenericLp", True),
    ]:
        if isUniswap:
            params = sett_config.uni.uniGenericLp.params
            swap = UniswapSystem()
        else:
            params = sett_config.sushi.sushiWbtcIbBtc.params
            params.badgerTree = badger.badgerTree

            swap = SushiswapSystem()

        if swap.hasPair(registry.tokens.ibbtc, registry.tokens.wbtc):
            params.want = swap.getPair(registry.tokens.ibbtc, registry.tokens.wbtc)
        else:
            params.want = swap.createPair(
                registry.tokens.ibbtc, registry.tokens.wbtc, deployer,
            )

        # NB: Work w/ sushi team to setup sushi reward allocations.

        vault = badger.deploy_sett(
            key,
            params.want,
            controller,
            governance=governance,
            strategist=strategist,
            keeper=keeper,
            guardian=guardian,
        )
        time.sleep(sleep_between_tx)

        strategy = badger.deploy_strategy(
            key,
            strategyName,
            controller,
            params,
            governance=governance,
            strategist=strategist,
            keeper=keeper,
            guardian=guardian,
        )
        time.sleep(sleep_between_tx)

        badger.wire_up_sett(vault, strategy, controller)

        # TODO: Unpause vault.
        assert vault.paused()
示例#7
0
def main():
    test = False
    badger = connect_badger(load_root_proposer=True)
    nextCycle = badger.badgerTree.currentCycle() + 1

    startBlock = 0
    endBlock = chain.height

    currentRewards = fetch_current_rewards_tree(badger)

    console.log(currentRewards["startBlock"])
    console.log(currentRewards["endBlock"])

    rewards = calc_tree_rewards(badger, startBlock, endBlock, nextCycle)

    cumulative_rewards = process_cumulative_rewards(currentRewards, rewards)
    merkleTree = rewards_to_merkle_tree(cumulative_rewards, startBlock, endBlock, {})
    rootHash = web3.toHex(web3.keccak(text=merkleTree["merkleRoot"]))

    contentFileName = "rewards-" + str(chain.id) + "-" + str(rootHash) + ".json"
    console.log("Saving merkle tree as {}".format(contentFileName))
    with open(contentFileName, "w") as f:
        json.dump(merkleTree, f, indent=4)

    if not test:
        badger.badgerTree.proposeRoot(
            merkleTree["merkleRoot"],
            rootHash,
            nextCycle,
            currentRewards["startBlock"],
            currentRewards["endBlock"],
            {"from": badger.root_proposer, "gas_price": gas_strategy},
        )

        upload(contentFileName, merkleTree, publish=False)
def main():
    badger = connect_badger("deploy-final.json")

    multi = GnosisSafe(badger.opsMultisig)

    account = accounts.load("badger_proxy_deployer")
    print(account.address)

    amount = Wei("10000 ether")

    # print(badger.deployer)
    # print(badger.token.balanceOf(badger.deployer), badger.token.balanceOf(badger.opsMultisig))

    # multi.execute(MultisigTxMetadata(description="Transfer badger to EOA"), {
    #     "to": badger.token.address,
    #     "data": badger.token.transfer.encode_input(account, Wei("10000 ether"))
    # })

    # print(badger.token.balanceOf(account), badger.token.balanceOf(badger.opsMultisig))

    # assert badger.token.balanceOf(account) >= amount

    bBadger = badger.getSett("native.badger")
    # badger.token.approve(bBadger, amount, {"from": account})

    # bBadger.deposit(amount, {"from": account})
    # tx_wait()
    print(bBadger.balanceOf(account))

    airdropProxy = AirdropDistributor.at(
        "0xd17c7effa924b55951e0f6d555b3a3ea34451179")
    bBadger.transfer(airdropProxy, bBadger.balanceOf(account),
                     {"from": account})
示例#9
0
def main():
    badger = connect_badger()

    for key, sett in badger.sett_system.vaults.items():
        if key in skip:
            continue
        badger.print_logger_unlock_schedules(sett, name=key)
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()
示例#11
0
def main():
    badger = connect_badger(badger_config.prod_json)

    # Get latest block rewards were updated
    currentMerkleData = badger.badgerTree.getCurrentMerkleData()
    console.log("currentMerkleData", currentMerkleData)

    print("Run at", int(time.time()))

    currentRewards = fetch_current_rewards_tree(badger)

    lastClaimEnd = int(currentRewards["endBlock"])
    startBlock = lastClaimEnd + 1

    # Claim at current block
    claimAt = chain.height

    print("Claim Section", startBlock, claimAt)

    # If sufficient time has passed since last root proposal, propose a new root
    rootProposed = run_action(badger, {
        "action": "rootUpdater",
        "startBlock": startBlock,
        "endBlock": claimAt
    })

    # If there is a pending root, approve after independently verifying it
    rootApproved = run_action(badger, {
        "action": "guardian",
        "startBlock": startBlock,
        "endBlock": claimAt
    })
示例#12
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()
示例#13
0
def digg_distributor_unit():
    badger = connect_badger(badger_config.prod_json)
    deployer = badger.deployer
    devProxyAdminAddress = badger.devProxyAdmin.address
    daoProxyAdminAddress = badger.daoProxyAdmin.address
    digg = deploy_digg_minimal(deployer,
                               devProxyAdminAddress,
                               daoProxyAdminAddress,
                               owner=deployer)

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

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

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

    return digg
def main():
    badger = connect_badger(badger_config.prod_json,
                            load_keeper=True,
                            load_guardian=True)
    (currentRewards, startBlock, endBlock) = calc_next_cycle_range(badger)

    # If sufficient time has passed since last root proposal, propose a new root
    rootProposed = run_action(
        badger,
        {
            "action": "rootUpdater",
            "startBlock": startBlock,
            "endBlock": endBlock,
            "pastRewards": currentRewards,
        },
        test=False,
    )

    time.sleep(45)

    rootApproved = run_action(
        badger,
        {
            "action": "guardian",
            "startBlock": startBlock,
            "endBlock": endBlock,
            "pastRewards": currentRewards,
        },
        test=False,
    )
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()
示例#16
0
def main():
    badger = connect_badger("deploy-final.json")
    digg = badger.digg
    admin = badger.devProxyAdmin
    multisig = badger.devMultisig
    contracts = badger.contracts_upgradeable
    deployer = badger.deployer

    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert multisig == expectedMultisig

    safe = ApeSafe(badger.devMultisig.address)

    abi = Sett.abi

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

    voting = safe.contract_from_abi(badger.daoBadgerTimelock.address,
                                    "IVoting", interface.IVoting.abi)
    aragon = AragonSystem()
    aragonVoting = aragon.getVotingAt(
        web3.toChecksumAddress("0xdc344bfb12522bf3fa58ef0d6b9a41256fc79a1b"))

    token_registry = registry.token_system()

    dev = accounts.at(badger.devMultisig.address, force=True)

    tokens = [
        token_registry.erc20_by_address(registry.tokens.farm),
        token_registry.erc20_by_address(registry.tokens.xSushi),
        token_registry.erc20_by_address(registry.curve.pools.sbtcCrv.token),
        token_registry.erc20_by_address(registry.curve.pools.renCrv.token),
        token_registry.erc20_by_address(registry.curve.pools.tbtcCrv.token),
        token_registry.erc20_by_address(registry.sushi.lpTokens.sushiWbtcWeth),
        token_registry.erc20_by_address(registry.tokens.dfd),
    ]

    snap = BalanceSnapshotter(tokens, [badger.devMultisig, badger.dao.agent])

    snap.snap(name="Before Transfers")

    for id in vote_ids:
        voting.vote(id, True, True)
        rewardsEscrow.call(aragonVoting, 0,
                           aragonVoting.vote.encode_input(id, True, True))
        teamVesting.call(aragonVoting, 0,
                         aragonVoting.vote.encode_input(id, True, True))

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

    safe_tx = safe.multisend_from_receipts()
    safe.preview(safe_tx)
    data = safe.print_transaction(safe_tx)
    safe.post_transaction(safe_tx)
示例#17
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
    """

    badger = connect_badger("deploy-final.json")
    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert badger.devMultisig == expectedMultisig

    multi = GnosisSafe(badger.devMultisig)

    # Parameters
    recipient = "0xD73b03F1Ea390fEB20D879e4DFb83F1245C8D4be"
    dollars = 45000

    # amount = from_dollars(badger, badger.token.address, dollars)
    amount = Wei("45000 ether")

    params = {
        "dollars": dollars,
        "recipient": recipient,
        "amount": amount,
        "amount_scaled": val(amount),
        "use_test_payment": True
    }

    console.print("===== Pre Transfer =====", style="bold cyan")

    console.print(params)
    transfer_badger(recipient, params)

    console.print("===== Post Transfer =====", style="bold cyan")
示例#18
0
def setup():
    """
    Connect to badger system, and configure multisig for running transactions in local fork without access to accounts
    """

    # Connect badger system from file
    badger = connect_badger("deploy-final.json")
    digg = connect_digg("deploy-final.json")

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

    # Multisig wrapper
    multi = GnosisSafe(badger.devMultisig, testMode=True)
    manager = BadgerRewardsManager.at(
        "0x5B60952481Eb42B66bdfFC3E049025AC5b91c127")

    for key in strat_keys:
        print(key)
        strategy = badger.getStrategy(key)
        multi.execute(
            MultisigTxMetadata(
                description="Transfer Keeper for {}".format(key)),
            {
                "to": strategy.address,
                "data": strategy.setKeeper.encode_input(manager)
            },
        )

    return manager
示例#19
0
def main():
    badger = connect_badger(badger_config.prod_json,
                            load_keeper=True,
                            load_guardian=True)
    pendingContentHash = (
        "0x346ec98585b52d981d43584477e1b831ce32165cb8e0a06d14d236241b36328e")
    pendingFile = "rewards-1-" + str(pendingContentHash) + ".json"
    with open(pendingFile) as f:
        after_file = json.load(f)

    pendingRewards = after_file
    # pendingRewards = fetch_current_rewards_tree(badger)
    currentRewards = fetch_current_rewards_tree(badger)

    accounts[0].transfer(badger.keeper, Wei("5 ether"))
    accounts[0].transfer(badger.guardian, Wei("5 ether"))

    # Upgrade Rewards Tree
    multi = GnosisSafe(badger.devMultisig)

    newLogic = BadgerTree.at("0x0f81D3f48Fedb8E67a5b87A8a4De57766157f19B")

    multi.execute(
        MultisigTxMetadata(description="Upgrade Tree", ),
        {
            "to":
            badger.opsProxyAdmin.address,
            "data":
            badger.opsProxyAdmin.upgrade.encode_input(badger.badgerTree,
                                                      newLogic),
        },
    )

    assert (badger.badgerTree.hasRole(DEFAULT_ADMIN_ROLE,
                                      badger.devMultisig.address) == True)
    assert badger.badgerTree.getRoleMemberCount(DEFAULT_ADMIN_ROLE) == 1

    assert badger.badgerTree.hasRole(ROOT_PROPOSER_ROLE,
                                     badger.keeper.address) == True
    assert badger.badgerTree.getRoleMemberCount(ROOT_PROPOSER_ROLE) == 1

    # assert badger.badgerTree.hasRole(ROOT_VALIDATOR_ROLE, badger.guardian.address) == True
    # assert badger.badgerTree.getRoleMemberCount(ROOT_VALIDATOR_ROLE) == 1

    assert badger.badgerTree.hasRole(PAUSER_ROLE,
                                     badger.guardian.address) == True
    assert badger.badgerTree.getRoleMemberCount(PAUSER_ROLE) == 1

    assert badger.badgerTree.hasRole(UNPAUSER_ROLE,
                                     badger.devMultisig.address) == True
    assert badger.badgerTree.getRoleMemberCount(UNPAUSER_ROLE) == 1

    verify_rewards(
        badger,
        pendingRewards["startBlock"],
        pendingRewards["endBlock"],
        currentRewards,
        pendingRewards,
    )
示例#20
0
def main():
    badger = connect_badger(badger_config.prod_json)
    console.print("\n[white]===== 🦡 Sett Status 🦡 =====[white]\n")
    for key in badger.sett_system.vaults.keys():
        snap = SnapshotManager(badger, key)
        state = snap.snap()
        snap.printPermissions()
        snap.printTable(state)
def main():
    """
    Queue Update of Controller.rewards for 0x63cF44B2548e4493Fd099222A1eC79F3344D9682
    """
    badger = connect_badger(badger_config.prod_json)

    ## test_update_rewards(badger)
    update_rewards(badger)
示例#22
0
def main():
    console.print("[white]===== Checking Parameters for rebase =====[/white]")
    badger = connect_badger(load_deployer=True)

    console.print("=== Rebase (Eternal) ===")
    console.print("Interval between runs: {} minutes".format(to_minutes(60)))

    run_persistent(rebase, (badger, badger.deployer), run_interval=60)
示例#23
0
def main():
    badger = connect_badger()
    table = []

    for key, geyser in badger.geysers.items():
        if key in skip:
            continue
        badger.print_latest_unlock_schedules(geyser, name=key)
示例#24
0
def digg_distributor_prod_unit():
    badger = connect_badger("deploy-final.json", load_deployer=True, load_keeper=True, load_guardian=True)
    digg = connect_digg("deploy-final.json")
    digg.token = digg.uFragments

    badger.add_existing_digg(digg)
    init_prod_digg(badger, badger.deployer)
    return digg
def main():
    badger = connect_badger("deploy-final.json")
    admin = badger.devProxyAdmin
    multisig = badger.devMultisig
    contracts = badger.contracts_upgradeable
    deployer = badger.deployer

    expectedMultisig = "0xB65cef03b9B89f99517643226d76e286ee999e77"
    assert multisig == expectedMultisig
    """
    Total $BADGER 603,750

    Setts
    renbtcCRV — 83,437.5 $BADGER
    sbtcCRV — 83,437.5 $BADGER
    tbtcCRV — 83,437.5 $BADGER
    Badger — 70,000 $BADGER
    (NEW) wBTC/ETH Sushiswap LP — 40,000 $BADGER
    Badger <>wBTC Uniswap LP — 110,000 $BADGER
    (NEW) Badger <>wBTC Sushiswap LP— 50,000 $BADGER

    wbtc/eth = 34,285 $BADGER (which should be distributed evenly over 3 days ie today 1pm to tomorrow, tomorrow to wednesday, wed- thursday then new emissions)
    Badger <>wBTC Sushiswap LP— 30,000 $BADGER (10k/day)

    Super Sett
    Harvest renbtc CRV —83,437.5 $BADGER
    """

    rest = RewardsSchedule(badger)

    rest.setStart(to_timestamp(datetime.datetime(2020, 12, 31, 12, 00)))
    rest.setDuration(days(7))

    rest.setAmounts({
        "native.renCrv": Wei("83437.5 ether"),
        "native.sbtcCrv": Wei("83437.5 ether"),
        "native.tbtcCrv": Wei("83437.5 ether"),
        "native.badger": Wei("60000 ether"),
        "native.sushiWbtcEth": Wei("80000 ether"),
        "native.uniBadgerWbtc": Wei("80000 ether"),
        "native.sushiBadgerWbtc": Wei("80000 ether"),
        "harvest.renCrv": Wei("83437.5 ether"),
    })

    rest.testTransactions()

    rest.printState("Week 5 - Sushi Continues")

    total = rest.total
    expected = Wei("633750 ether")

    print("overall total ", total)
    print("expected total ", expected)

    assert total == expected

    console.print("\n[green] ✅ Total matches expected {} [/green]".format(
        val(expected)))
示例#26
0
def main():
    badger = connect_badger()
    multisig = badger.devMultisig

    safe = ApeSafe(multisig.address)

    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
    )

    wbtcToken = safe.contract_from_abi(
        registry.tokens.wbtc, "IERC20", interface.IERC20.abi
    )

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

    # TODO: Do this in bBadger going forward - this is the way.
    # Approve treasury multi to stake
    # Deposit badger -> bBadger

    snap = BalanceSnapshotter(
        [badgerToken, usdcToken, wbtcToken],
        [multisig, badger.deployer, badger.rewardsEscrow],
    )

    opolis_dest = "0x27657399177403a891CC7A22Bd6F2C00621Db7b0"

    test_usdc = 1 * 10 ** 6
    full_usdc = 499999 * 10 ** 6
    full_badger = Wei("10163.59 ether")
    full_wbtc = 3.805754301 * 10 ** 8

    console.print("Sending Amounts")

    snap.snap(name="Before Transfers")

    usdcToken.transfer(opolis_dest, full_usdc)
    rewardsEscrow.approveRecipient(opolis_dest)
    rewardsEscrow.transfer(badger.token, opolis_dest, full_badger)
    # badgerToken.transfer(opolis_dest, full_badger)
    wbtcToken.transfer(opolis_dest, full_wbtc)

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

    safe_tx = safe.multisend_from_receipts()
    safe.preview(safe_tx)
    data = safe.print_transaction(safe_tx)
    safe.post_transaction(safe_tx)
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()
示例#28
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()
示例#29
0
def main():
    badger = connect_badger(badger_config.prod_json)
    console.print("\n[white]===== 🦡 Sett Status 🦡 =====[white]\n")
    table = []
    for key in badger.sett_system.vaults.keys():
        sett = badger.getSett(key)
        logic = badger.devProxyAdmin.getProxyImplementation(sett)
        table.append([key, logic])
    print(tabulate(table, ["key", "logic"]))
示例#30
0
def test_main():
    badger = connect_badger()
    user = accounts[0]
    distribute_test_ether(user, Wei("10 ether"))
    distribute_from_whales(user)
    settConfig = {"id": "native.pancakeBnbBtcb"}
    setup_badger(badger, settConfig)
    deposit_withdraw_single_user_flow(badger, settConfig, user)
    single_user_harvest_flow(badger, settConfig, user)