Ejemplo n.º 1
0
def main(acct=CALLER, claim_threshold=CLAIM_THRESHOLD):
    lp_tripool = Contract("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490")
    distributor = Contract("0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc")
    proxy = Contract("0xeCb456EA5365865EbAb8a2661B0c503410e9B347")
    btc_burner = Contract("0x00702BbDEaD24C40647f235F15971dB0867F6bdB")
    underlying_burner = Contract("0x874210cF3dC563B98c137927e7C951491A2e9AF3")

    initial_balance = lp_tripool.balanceOf(distributor)

    # get list of active pools
    pool_list = _get_pool_list()

    # withdraw pool fees to pool proxy
    to_claim = []
    for i in range(len(pool_list)):

        # check claimable amount
        claimable = _get_admin_balances(pool_list[i])
        if sum(claimable) >= claim_threshold:
            to_claim.append(pool_list[i])

        if i == len(pool_list) - 1 or len(to_claim) == 20:
            to_claim += [ZERO_ADDRESS] * (20-len(to_claim))
            proxy.withdraw_many(to_claim, {'from': acct, 'gas_price': gas_strategy})
            to_claim = []

    # call burners to convert fee tokens to 3CRV
    burn_start = 0
    to_burn = []
    for i in range(len(COINS)):
        if Contract(COINS[i]).balanceOf(proxy) > 0:
            # no point in burning if we have a zero balance
            to_burn.append(COINS[i])

        to_burn_padded = to_burn + [ZERO_ADDRESS] * (20-len(to_burn))

        # estimate gas to decide when to burn - some of the burners are gas guzzlers
        if i == len(COINS) - 1 or proxy.burn_many.estimate_gas(to_burn_padded, {'from': acct}) > 2000000:
            tx = proxy.burn_many(to_burn_padded, {'from': acct, 'gas_price': gas_strategy})
            to_burn = []
            if not burn_start:
                # record the timestamp of the first tx - need to
                # know how long to wait to finalize synth swaps
                burn_start = tx.timestamp

    # wait on synths to finalize
    time.sleep(max(burn_start + 180 - time.time(), 0))

    # call `execute` on burners
    # for btc burner, this converts sUSD to USDC and sends to the underlying burner
    btc_burner.execute({'from': acct, 'gas_price': gas_strategy})
    # for underlying burner, this deposits USDC/USDT/DAI into 3CRV and sends to the distributor
    underlying_burner.execute({'from': acct, 'gas_price': gas_strategy})

    # finally, call to burn 3CRV - this also triggers a token checkpoint
    proxy.burn(lp_tripool, {'from': acct, 'gas_price': gas_strategy})

    final = lp_tripool.balanceOf(distributor)
    print(f"Success! Total 3CRV fowarded to distributor: {(final-initial_balance)/1e18:.4f}")
def main(acct=CALLER):
    lp_tripool = Contract("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490")
    distributor = Contract("0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc")
    proxy = Contract("0xeCb456EA5365865EbAb8a2661B0c503410e9B347")
    btc_burner = Contract("0x00702BbDEaD24C40647f235F15971dB0867F6bdB")
    underlying_burner = Contract("0x874210cF3dC563B98c137927e7C951491A2e9AF3")

    initial_balance = lp_tripool.balanceOf(distributor)

    # get list of active pools
    provider = Contract("0x0000000022D53366457F9d5E68Ec105046FC4383")
    registry = Contract(provider.get_registry())
    pool_list = [
        Contract(registry.pool_list(i)) for i in range(registry.pool_count())
    ]

    # withdraw pool fees to pool proxy
    for i in range(0, len(pool_list), 20):
        pools = pool_list[i:i + 20]
        pools += [ZERO_ADDRESS] * (20 - len(pools))
        proxy.withdraw_many(pools, {'from': acct, 'gas_price': gas_strategy})

    # call burners to convert fee tokens to 3CRV
    burn_start = 0
    to_burn = []
    for i in range(len(COINS)):
        to_burn.append(COINS[i])
        to_burn_padded = to_burn + [ZERO_ADDRESS] * (20 - len(to_burn))

        # estimate gas to decide when to burn - some of the burners are gas guzzlers
        if i == len(COINS) - 1 or proxy.burn_many.estimate_gas(
                to_burn_padded, {'from': acct}) > 2000000:
            tx = proxy.burn_many(to_burn_padded, {
                'from': acct,
                'gas_price': gas_strategy
            })
            to_burn = []
            if not burn_start:
                # record the timestamp of the first tx - need to
                # know how long to wait to finalize synth swaps
                burn_start = tx.timestamp

    # wait on synths to finalize
    time.sleep(burn_start + 180 - time.time())

    # call `execute` on burners
    # for btc burner, this converts sUSD to USDC and sends to the underlying burner
    btc_burner.execute({'from': acct, 'gas_price': gas_strategy})
    # for underlying burner, this deposits USDC/USDT/DAI into 3CRV and sends to the distributor
    underlying_burner.execute({'from': acct, 'gas_price': gas_strategy})

    # finally, call to burn 3CRV - this also triggers a token checkpoint
    proxy.burn(lp_tripool, {'from': acct, 'gas_price': gas_strategy})

    final = lp_tripool.balanceOf(distributor)
    print(
        f"Success! Total 3CRV fowarded to distributor: {final-initial_balance/1e18:.4f}"
    )
def main(acct=CALLER, claim_threshold=CLAIM_THRESHOLD):
    lp_tripool = Contract("0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490")
    distributor = Contract("0xA464e6DCda8AC41e03616F95f4BC98a13b8922Dc")
    proxy = Contract("0xeCb456EA5365865EbAb8a2661B0c503410e9B347")

    initial_balance = lp_tripool.balanceOf(distributor)

    # get list of active pools
    pool_list = _get_pool_list()

    # withdraw pool fees to pool proxy
    to_claim = []
    for i in range(len(pool_list)):

        # check claimable amount
        sys.stdout.write(
            f"\rQuerying pending fee amounts ({i}/{len(pool_list)})...")
        sys.stdout.flush()
        claimable = _get_admin_balances(pool_list[i])
        if sum(claimable) >= claim_threshold:
            to_claim.append(pool_list[i])

        if i == len(pool_list) - 1 or len(to_claim) == 20:
            to_claim += [ZERO_ADDRESS] * (20 - len(to_claim))
            proxy.withdraw_many(to_claim, {
                'from': acct,
                'gas_price': gas_strategy
            })
            to_claim = []

    # call burners to convert fee tokens to 3CRV
    burn_start = 0
    to_burn = []
    for i in range(len(COINS)):
        # no point in burning if we have a zero balance
        if COINS[i] == ETH_ADDRESS:
            if proxy.balance() > 0:
                to_burn.append(COINS[i])
        elif Contract(COINS[i]).balanceOf(proxy) > 0:
            to_burn.append(COINS[i])

        to_burn_padded = to_burn + [ZERO_ADDRESS] * (20 - len(to_burn))

        # estimate gas to decide when to burn - some of the burners are gas guzzlers
        if i == len(COINS) - 1 or proxy.burn_many.estimate_gas(
                to_burn_padded, {'from': acct}) > 2000000:
            tx = proxy.burn_many(to_burn_padded, {
                'from': acct,
                'gas_price': gas_strategy
            })
            to_burn = []
            if not burn_start:
                # record the timestamp of the first tx - need to
                # know how long to wait to finalize synth swaps
                burn_start = tx.timestamp

    # wait on synths to finalize
    time.sleep(max(burn_start + 180 - time.time(), 0))

    # call `execute` on synth burners that require it
    # converts settled sUSD to USDC and sends to the underlying burner
    susd = Contract("0x57Ab1ec28D129707052df4dF418D58a2D46d5f51")
    exchanger = Contract("0x0bfDc04B38251394542586969E2356d0D731f7DE")
    susd_currency_key = "0x7355534400000000000000000000000000000000000000000000000000000000"
    for burner in SYNTH_BURNERS:
        if susd.balanceOf(burner) > 0:
            settlement_time = exchanger.maxSecsLeftInWaitingPeriod(
                burner, susd_currency_key)
            if settlement_time:
                print("Sleeping until synths have time to settle...")
                time.sleep(settlement_time)
            Contract(burner).execute({'from': acct, 'gas_price': gas_strategy})

    # call `execute` on the underlying burner
    # deposits DAI/USDC/USDT into 3pool and transfers the 3CRV to the fee distributor
    underlying_burner = Contract("0x874210cF3dC563B98c137927e7C951491A2e9AF3")
    underlying_burner.execute({'from': acct, 'gas_price': gas_strategy})

    # finally, call to burn 3CRV - this also triggers a token checkpoint
    proxy.burn(lp_tripool, {'from': acct, 'gas_price': gas_strategy})

    final = lp_tripool.balanceOf(distributor)
    print(
        f"Success! Total 3CRV fowarded to distributor: {(final-initial_balance)/1e18:.4f}"
    )
Ejemplo n.º 4
0
def main():
    deploy = accounts.load("curve-deploy")
    admin = Contract("0x7EAfd3cd937628b9671d5f8B9c823f4AAc914808")

    # withdraw admin fees to the burners
    swap = Contract("0x445FE580eF8d70FF569aB36e80c647af338db351")
    swap_btc = Contract("0xC2d95EEF97Ec6C17551d45e77B590dc1F9117C67")
    admin.execute(
        swap,
        swap.withdraw_admin_fees.encode_input(),
        {
            "from": deploy,
            "required_confs": 0
        },
    )
    admin.execute(
        swap_btc,
        swap_btc.withdraw_admin_fees.encode_input(),
        {
            "from": deploy,
            "required_confs": 0
        },
    )
    history.wait()

    # burn am3CRV fees
    burner = Contract("0xA237034249290De2B07988Ac64b96f22c0E76fE0")
    for i in range(3):
        try:
            burner.burn(
                swap.coins(i),
                {
                    "from": deploy,
                    "gas_limit": 2000000,
                    "required_confs": 0
                },
            )
        except Exception:
            pass

    # burn renBTC fees
    burner = Contract("0x5109Abc063164d49C148A7AE970F631FEBbDa4FA")
    for i in range(2):
        try:
            burner.burn(
                swap_btc.coins(i),
                {
                    "from": deploy,
                    "gas_limit": 2000000,
                    "required_confs": 0
                },
            )
        except Exception:
            pass

    # burn tricrypto3
    burner = Contract("0x43450Feccf936FbA3143e03F35D3Cc608D5fE1d2")
    burner.burn("0xdAD97F7713Ae9437fa9249920eC8507e5FbB23d3", {
        'from': deploy,
        'gas_limit': 2000000,
        'required_confs': 0
    })

    history.wait()

    # send USDC over the bridge
    usdc = Contract("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174")
    bridge = Contract("0x4473243A61b5193670D1324872368d015081822f")
    amount = usdc.balanceOf(bridge)
    tx = admin.execute(bridge, bridge.withdraw.encode_input(usdc),
                       {"from": deploy})

    print(
        f"Burning phase 1 complete!\nAmount: {amount/1e6:,.2f} USDC\nBridge txid: {tx.txid}"
    )
    print(
        "\nUse `brownie run exit --network mainnet` to claim on ETH once the checkpoint is added"
    )