diff --git a/brownie/allocations.py b/brownie/allocations.py index 7f2f8b5f6a..2741261f8b 100644 --- a/brownie/allocations.py +++ b/brownie/allocations.py @@ -1,11 +1,14 @@ import world import pandas as pd import brownie +import re NAME_TO_STRAT = { "Convex": world.convex_strat, "AAVE": world.aave_strat, "COMP": world.comp_strat, + "MORPHO_COMP": world.morpho_comp_strat, + "OUSD_META": world.ousd_meta_strat, } NAME_TO_TOKEN = { @@ -14,12 +17,32 @@ "USDT": world.usdt, } +CORE_STABLECOINS = { + "DAI": world.dai, + "USDC": world.usdc, + "USDT": world.usdt, +} + +SNAPSHOT_NAMES = { + "Aave DAI": ["AAVE", "DAI"], + "Aave USDC": ["AAVE", "USDC"], + "Aave USDT": ["AAVE", "USDT"], + "Compound DAI": ["COMP", "DAI"], + "Compound USDC": ["COMP", "USDC"], + "Compound USDT": ["COMP", "USDT"], + "Morpho Compound DAI": ["MORPHO_COMP", "DAI"], + "Morpho Compound USDC": ["MORPHO_COMP", "USDC"], + "Morpho Compound USDT": ["MORPHO_COMP", "USDT"], + "Convex DAI/USDC/USDT": ["CONVEX", "*"], + "Convex OUSD/3Crv": ["OUSD_META", "*"], +} + def load_from_blockchain(): base = pd.DataFrame.from_records( [ ["AAVE", "DAI", int(world.aave_strat.checkBalance(world.DAI) / 1e18)], - ['AAVE','USDC', int(world.aave_strat.checkBalance(world.USDC)/1e6)], + ["AAVE", "USDC", int(world.aave_strat.checkBalance(world.USDC) / 1e6)], ["AAVE", "USDT", int(world.aave_strat.checkBalance(world.USDT) / 1e6)], ["COMP", "DAI", int(world.comp_strat.checkBalance(world.DAI) / 1e18)], ["COMP", "USDC", int(world.comp_strat.checkBalance(world.USDC) / 1e6)], @@ -27,8 +50,8 @@ def load_from_blockchain(): ["MORPHO_COMP", "DAI", int(world.morpho_comp_strat.checkBalance(world.DAI) / 1e18)], ["MORPHO_COMP", "USDC", int(world.morpho_comp_strat.checkBalance(world.USDC) / 1e6)], ["MORPHO_COMP", "USDT", int(world.morpho_comp_strat.checkBalance(world.USDT) / 1e6)], - ["Convex", "*", int(world.convex_strat.checkBalance(world.DAI) * 3 / 1e18)], - ["OUSD_META", "*", int(world.ousd_metastrat.checkBalance(world.DAI) * 3 / 2 / 1e18)], + ["CONVEX", "*", int(world.convex_strat.checkBalance(world.DAI) * 3 / 1e18)], + ["OUSD_META", "*", int(world.ousd_meta_strat.checkBalance(world.DAI) * 3 / 2 / 1e18)], ], columns=["strategy", "token", "current_dollars"], ) @@ -36,170 +59,102 @@ def load_from_blockchain(): return base -def add_voting_results(base, vote_results): - vote_allocations = pd.DataFrame.from_records( - vote_results, columns=["strategy", "token", "vote_allocation"] - ) - vote_allocations["vote_allocation"] /= 100 - allocations = base.merge( - vote_allocations, how="outer", on=["strategy", "token"] - ).fillna(0) - allocations = allocations.sort_values(["token", "strategy"]) - allocations["vote_dollars"] = ( - allocations["vote_allocation"] * allocations["current_dollars"].sum() - ).astype("int64") - allocations["vote_change"] = ( - allocations["vote_dollars"] - allocations["current_dollars"] - ) - return allocations - - -def add_needed_changes(allocations): - df = allocations - MOVE_THRESHOLD = df.current_dollars.sum() * 0.005 - df["remaining_change"] = df[df["vote_change"].abs() > MOVE_THRESHOLD]["vote_change"] - df["remaining_change"] = (df["remaining_change"].fillna(0) / 100000).astype( - "int64" - ) * 100000 - df["actual_change"] = 0 +def reallocate(from_strat, to_strat, funds): + """ + Execute and return a transaction reallocating funds from one strat to another + """ + amounts = [] + coins = [] + for [dollars, coin] in funds: + amounts.append(int(dollars * 10 ** coin.decimals())) + coins.append(coin) + return world.vault_admin.reallocate(from_strat, to_strat, coins, amounts, {"from": world.STRATEGIST}) + + +def allocation_exposure(allocation): + """ + Shows how exposed we would be to a stablecoin peg loss. + + Consevitivly assumes that: + - Any Curve pool would go 100% to the peg lost coin + - DAI would follow a USDC peg loss. + + Reality may not be quite so bad. + """ + exposure_masks = { + "DAI": (allocation["token"] == "DAI") | (allocation["token"] == "*"), + "USDC": (allocation["token"] == "USDC") | (allocation["token"] == "DAI") | (allocation["token"] == "*"), + "USDT": (allocation["token"] == "USDT") | (allocation["token"] == "*"), + } + total = allocation["current_dollars"].sum() + print("Maximum exposure: ") + for coin, mask in exposure_masks.items(): + coin_exposure = allocation[mask]["current_dollars"].sum() / total + print(" {:<6} {:,.2%}".format(coin, coin_exposure)) + + +def lookup_strategy(address): + for name, contract in NAME_TO_STRAT.items(): + if contract.address.lower() == address.lower(): + return [name, contract] + + +def show_default_strategies(): + print("Default Strategies:") + for coin_name, coin in CORE_STABLECOINS.items(): + default_strat_address = world.vault_core.assetDefaultStrategies(coin) + name, strat = lookup_strategy(default_strat_address) + raw_funds = strat.checkBalance(coin) + decimals = coin.decimals() + funds = int(raw_funds / (10**decimals)) + print("{:>6} defaults to {} with {:,}".format(coin_name, name, funds)) + + +def with_target_allocations(allocation, votes): + df = allocation.copy() + df["target_allocation"] = float(0.0) + if isinstance(votes, pd.DataFrame): + df["target_allocation"] = votes["target_allocation"] + else: + for line in votes.splitlines(): + m = re.search(r"[ \t]*(.+)[ \t]([0-9.]+)", line) + if not m: + continue + strat_name = m.group(1).strip() + strat_alloc = float(m.group(2)) / 100.0 + if strat_name in SNAPSHOT_NAMES: + [internal_name, internal_coin] = SNAPSHOT_NAMES[strat_name] + mask = (df.strategy == internal_name) & (df.token == internal_coin) + df.loc[mask, "target_allocation"] += strat_alloc + elif strat_name == "Existing Allocation": + pass + df["target_allocation"] += df["current_allocation"] * strat_alloc + else: + raise Exception('Could not look up strategy name "%s"' % strat_name) + + if df["target_allocation"].sum() > 1.02: + print(df) + print(df["target_allocation"].sum()) + raise Exception("Target allocations total too high") + if df["target_allocation"].sum() < 0.98: + print(df) + print(df["target_allocation"].sum()) + raise Exception("Target allocations total too low") + + df["target_dollars"] = ( + df["current_dollars"].sum() * df["target_allocation"] / df["target_allocation"].sum() + ).astype(int) + df["delta_dollars"] = df["target_dollars"] - df["current_dollars"] return df -def plan_moves(allocations): - possible_strat_moves = [ - ["AAVE", "COMP"], - ["COMP", "AAVE"], - ["Convex", "COMP"], - ["Convex", "AAVE"], - ["AAVE", "Convex"], - ["COMP", "Convex"], - ] - tokens = ["DAI", "USDC", "USDT"] - - moves = [] - - df = allocations - for strat_from, strat_to in possible_strat_moves: - for token in tokens: - token_match = (df["token"] == token) | (df["token"] == "*") - from_filter = token_match & (df["strategy"] == strat_from) - to_filter = token_match & (df["strategy"] == strat_to) - from_row = df.loc[from_filter] - to_row = df.loc[to_filter] - from_change = from_row.remaining_change.values[0] - to_change = to_row.remaining_change.values[0] - from_strategy = from_row.strategy.values[0] - to_strategy = to_row.strategy.values[0] - - if from_change < 0 and to_change > 0: - move_change = min(to_change, -1 * from_change) - df.loc[from_filter, "remaining_change"] += move_change - df.loc[to_filter, "remaining_change"] -= move_change - df.loc[from_filter, "actual_change"] -= move_change - df.loc[to_filter, "actual_change"] += move_change - moves.append([from_strategy, to_strategy, token, move_change]) - - moves = pd.DataFrame.from_records(moves, columns=["from", "to", "token", "amount"]) - return df, moves - - -def print_headline(text): - print("------------") - print(text) - print("------------") - - -def generate_transactions(moves): - move_txs = [] - notes = [] - with world.TemporaryFork(): - before_total = world.vault_core.totalValue() - - for from_to, inner_moves in moves.groupby(["from", "to"]): - from_strategy = NAME_TO_STRAT[from_to[0]] - to_strategy = NAME_TO_STRAT[from_to[1]] - tokens = [NAME_TO_TOKEN[x] for x in inner_moves["token"]] - dollars = [x for x in inner_moves["amount"]] - raw_amounts = [ - 10 ** token.decimals() * int(amount) - for token, amount in zip(tokens, dollars) - ] - notes.append( - "- From %s to %s move %s" - % ( - from_to[0], - from_to[1], - ", ".join( - [ - "%s million %s" % (d / 1000000, t) - for t, d in zip(inner_moves["token"], dollars) - ] - ), - ) - ) - - tx = world.vault_admin.reallocate( - from_strategy, - to_strategy, - tokens, - raw_amounts, - {"from": world.strategist}, - ) - move_txs.append(tx) - - after_total = world.vault_core.totalValue() - vault_loss_raw = before_total - after_total - vault_loss_dollars = int(vault_loss_raw / 1e18) - - print_headline("After Move") - after = load_from_blockchain() - after = after.rename( - { - "current_allocation": "percent", - "current_dollars": "dollars", - } - ) - print( - after.to_string( - formatters={ - "percent": "{:,.2%}".format, - "dollars": "{:,}".format, - } - ) - ) - print("Expected loss from move: ${:,}".format(vault_loss_dollars)) - return move_txs, notes, vault_loss_raw - - -def wrap_in_loss_prevention(moves, vault_loss_raw): - max_loss = int(vault_loss_raw) + int(abs(vault_loss_raw) * 0.1) + 100 * 1e18 - new_moves = [] - with world.TemporaryFork(): - new_moves.append( - world.vault_value_checker.takeSnapshot({"from": world.STRATEGIST}) - ) - new_moves = new_moves + moves - new_moves.append( - world.vault_value_checker.checkLoss(max_loss, {"from": world.STRATEGIST}) - ) - print( - "Expected loss: ${:,} Allowed loss from move: ${:,}".format( - int(vault_loss_raw // 1e18), int(max_loss // 1e18) - ) - ) - return new_moves - - -def transactions_for_reallocation(votes): - base = load_from_blockchain() - allocations = add_needed_changes(add_voting_results(base, votes)) - allocations, moves = plan_moves(allocations) - print_headline("Current, Voting, and planned allocations") - print(allocations) - txs, notes, vault_loss_raw = generate_transactions(moves) - print_headline("Plan") - print("Planned strategist moves:") - print("\n".join(notes)) - txs = wrap_in_loss_prevention(txs, vault_loss_raw) - - return txs +def pretty_allocations(allocation, close_enough=50_000): + df = allocation.copy() + df["s"] = "" + df.loc[df["delta_dollars"].abs() < close_enough, "s"] = "✔︎" + df["current_allocation"] = df["current_allocation"].apply("{:.2%}".format) + df["target_allocation"] = df["target_allocation"].apply("{:.2%}".format) + df["current_dollars"] = df["current_dollars"].apply("{:,}".format) + df["target_dollars"] = df["target_dollars"].apply("{:,}".format) + df["delta_dollars"] = df["delta_dollars"].apply("{:,}".format) + return df.sort_values("token") diff --git a/brownie/runlogs/2022_11_strategist.py b/brownie/runlogs/2022_11_strategist.py new file mode 100644 index 0000000000..90b4251538 --- /dev/null +++ b/brownie/runlogs/2022_11_strategist.py @@ -0,0 +1,301 @@ +# -------------------------------- +# Nov 3, 2022 OGV Buyback +# + + +from world import * +from ape_safe import ApeSafe + + +MIN_PERCENT_AFTER_SLIPPAGE = 0.97 +REWARDS = "0x7d82E86CF1496f9485a8ea04012afeb3C7489397" +buyback = Contract.from_abi("Buyback", vault_core.trusteeAddress(), buyback.abi) +ogv = Contract.from_explorer("0x9c354503C38481a7A7a51629142963F98eCC12D0") + +BUYBACK_AMOUNT = ousd.balanceOf(buyback) + + +amount_no_mev = 0 + +# Nominal price sim +with TemporaryFork(): + before = ogv.balanceOf(REWARDS) + buyback.swapNow(1e18, 1, {'from': STRATEGIST}) + after = ogv.balanceOf(REWARDS) + amount_no_mev = after - before + +print("Best-case buyback amount %s OUSD for %s OGV" % ( + c18(BUYBACK_AMOUNT), + c18(amount_no_mev*BUYBACK_AMOUNT/int(1e18)) +)) +print("Best-case price $%f"%(1e18 / amount_no_mev)) + + +# Expected Swap sim +with TemporaryFork(): + before = ogv.balanceOf(REWARDS) + buyback.swapNow(BUYBACK_AMOUNT, 1, {'from': STRATEGIST}) + print(history[-1].call_trace(True)) + after = ogv.balanceOf(REWARDS) + amount_no_mev = after - before + +print("Target buyback amount %s OUSD for %s OGV"%(c18(BUYBACK_AMOUNT), c18(amount_no_mev))) +print("Target price $%f"%(BUYBACK_AMOUNT / amount_no_mev)) +print("Min amount %s OGV"%(c18(int(amount_no_mev*MIN_PERCENT_AFTER_SLIPPAGE)))) +print("Submit with 500,000 gas") + +# Actual Swap TX +txs = [ + buyback.swapNow(BUYBACK_AMOUNT, int(amount_no_mev*MIN_PERCENT_AFTER_SLIPPAGE), {'from': STRATEGIST}) +] + +# Send +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) + + + + +# -------------------------------- +# Nov 8, 2022 Initial MetaStrategy Depost +# + +from world import * +from allocations import * +from ape_safe import ApeSafe + +with TemporaryFork(): + print(load_from_blockchain()) + before = vault_core.totalValue() + txs = [ + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + vault_admin.reallocate(OUSD_META_STRAT, COMP_STRAT, [usdc], [int(481000 * 1e6)], {'from': STRATEGIST}), + vault_value_checker.checkLoss(-480800*1e18, {"from": STRATEGIST}), + ] + print("Vault change", c18(vault_core.totalValue() - before)) + print("Snapshot before", c18(vault_value_checker.snapshotValue())) + print("Vault After", c18(vault_core.totalValue())) + print("Snapshot change", c18(vault_core.totalValue()-vault_value_checker.snapshotValue())) + print(load_from_blockchain()) + print("") + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) + + + + +# -------------------------------- +# Nov 8, 2022 USDT depeg +# + +from world import * +from allocations import * +from ape_safe import ApeSafe + +with TemporaryFork(): + print(load_from_blockchain()) + before = vault_core.totalValue() + txs = [ + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + vault_admin.reallocate(OUSD_META_STRAT, COMP_STRAT, [usdc], [int(100000 * 1e6)], {'from': STRATEGIST}), + vault_value_checker.checkLoss(100000 * 1e18, {"from": STRATEGIST}), + ] + print("Vault change", c18(vault_core.totalValue() - before)) + print("Snapshot before", c18(vault_value_checker.snapshotValue())) + print("Vault After", c18(vault_core.totalValue())) + print("Snapshot change", c18(vault_core.totalValue()-vault_value_checker.snapshotValue())) + show_transfers(history[-2]) + print(load_from_blockchain()) + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) + + + +# -------------------------------- +# Nov 10, 2022 +# + +from world import * +from allocations import * +from ape_safe import ApeSafe + +with TemporaryFork(): + print(load_from_blockchain()) + before = vault_core.totalValue() + beforeOUSD = ousd.totalSupply() + txs = [ + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + vault_admin.reallocate(COMP_STRAT, OUSD_META_STRAT, [usdc], [int(3800000 * 1e6)], {'from': STRATEGIST}), + vault_value_checker.checkLoss(-7607000*1e18, {"from": STRATEGIST}), + ] + print("Vault change", c18(vault_core.totalValue() - before)) + print("Snapshot before", c18(vault_value_checker.snapshotValue())) + print("Vault After", c18(vault_core.totalValue())) + print("Snapshot change", c18(vault_core.totalValue()-vault_value_checker.snapshotValue())) + print("OUSD change", c18(ousd.totalSupply()-beforeOUSD)) + print(load_from_blockchain()) + show_transfers(history[-2]) + print("") + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) + + + + + +# -------------------------------- +# Nov 21, 2022 +# +from world import * +from allocations import * +from ape_safe import ApeSafe + + +with TemporaryFork(): + print(load_from_blockchain()) + before = vault_core.totalValue() + txs = [ + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + vault_admin.reallocate(OUSD_META_STRAT, COMP_STRAT, [usdc], [int(481000 * 1e6)], {'from': STRATEGIST}), + vault_value_checker.checkLoss(-480800*1e18, {"from": STRATEGIST}), + ] + print("Vault change", c18(vault_core.totalValue() - before)) + print("Snapshot before", c18(vault_value_checker.snapshotValue())) + print("Vault After", c18(vault_core.totalValue())) + print("Snapshot change", c18(vault_core.totalValue()-vault_value_checker.snapshotValue())) + print(load_from_blockchain()) + print("") + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) + + +# -------------------------------- +# Nov 22, 2022 +# + +# Due to an accident with with `git checkout -f`, the script for today's +# large allocation today was lost. + +# -------------------------------- +# Nov 23, 2022 +# + +from world import * +from allocations import * +from ape_safe import ApeSafe + + +with TemporaryFork(): + print(load_from_blockchain()) + before = vault_core.totalValue() + txs = [ + vault_core.rebase({"from": STRATEGIST}), + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + vault_admin.reallocate(COMP_STRAT, OUSD_META_STRAT, [usdc], [1 * int(1e6) * int(1e6)], {'from': STRATEGIST}), + vault_admin.reallocate(COMP_STRAT, OUSD_META_STRAT, [dai], [1 * int(1e6) * int(1e18)], {'from': STRATEGIST}), + vault_value_checker.checkDelta(2001418234420763011604962, 2001818234420763011604962, 2001319886861331484075056, 2001719886861331484075056, {"from": STRATEGIST}), + ] + + snapshot = vault_value_checker.snapshots(STRATEGIST) + print(snapshot) + vault_change = vault_core.totalValue() - snapshot[0] + supply_change = ousd.totalSupply() - snapshot[1] + + print("Vault change", c18(vault_change)) + print("Supply change", c18(supply_change)) + print("Profit change", c18(vault_change - supply_change)) + print(vault_change - 500 * int(1e18), vault_change + 1000 * int(1e18), supply_change - 1000 * int(1e18), supply_change + 500 * int(1e18)) + print(load_from_blockchain()) + print("") + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) + + +# -------------------------------- +# Nov 30, 2022 +# + +from world import * +from allocations import * +from ape_safe import ApeSafe + + +votes = """ + Convex OUSD/3Crv 44.73 + Aave USDT 10.42 + Compound USDT 9.07 + Morpho Compound USDT 6.74 + Morpho Compound DAI 5.39 + Morpho Compound USDC 5.39 + Compound DAI 5.35 + Compound USDC 5.35 + Aave DAI 3.27 + Aave USDC 3.27 + Convex DAI/USDC/USDT 1.02 + Existing Allocation 0 + """ + +with TemporaryFork(): + before_allocation = with_target_allocations(load_from_blockchain(), votes) + print(pretty_allocations(before_allocation)) + before = vault_core.totalValue() + txs = [ + vault_core.rebase({'from': STRATEGIST}), + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + + reallocate(AAVE_STRAT, MORPHO_COMP_STRAT, [[1_851_000, dai], [78_000, usdt]]), + reallocate(COMP_STRAT, MORPHO_COMP_STRAT, [[1_851_000, usdc]]), + reallocate(COMP_STRAT, AAVE_STRAT, [[1_183_000, usdc]]), + reallocate(COMP_STRAT, OUSD_META_STRAT, [[3_900_000, dai],[4_196_000, usdc]]), + + reallocate(AAVE_STRAT, CONVEX_STRAT, [[2_622_000, dai]]), + reallocate(COMP_STRAT, CONVEX_STRAT, [[1_433_000, dai]]), + reallocate(CONVEX_STRAT, COMP_STRAT, [[2_412_000, usdt]]), + reallocate(CONVEX_STRAT, MORPHO_COMP_STRAT, [[2_261_000, usdt]]), + + vault_admin.setAssetDefaultStrategy(DAI, COMP_STRAT, {'from': STRATEGIST}), + vault_value_checker.checkDelta(8095444597380755611167495,8096944597380755611167495,8094868973290731737987818,8096368973290731737987818, {"from": STRATEGIST}), + ] + + snapshot = vault_value_checker.snapshots(STRATEGIST) + print(snapshot) + vault_change = vault_core.totalValue() - snapshot[0] + supply_change = ousd.totalSupply() - snapshot[1] + + + print(",".join([ + str(vault_change - 500 * int(1e18)), + str(vault_change + 1000 * int(1e18)), + str(supply_change - 1000 * int(1e18)), + str(supply_change + 500 * int(1e18)) + ])) + after_allocaiton = with_target_allocations(load_from_blockchain(), votes) + print(pretty_allocations(after_allocaiton)) + allocation_exposure(after_allocaiton) + show_default_strategies() + print("Vault change", c18(vault_change)) + print("Supply change", c18(supply_change)) + print("Profit change", c18(vault_change - supply_change)) + print("") + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) \ No newline at end of file diff --git a/brownie/runlogs/2022_12_strategist.py b/brownie/runlogs/2022_12_strategist.py new file mode 100644 index 0000000000..29f657bb56 --- /dev/null +++ b/brownie/runlogs/2022_12_strategist.py @@ -0,0 +1,73 @@ +# -------------------------------- +# Dec 7, 2022 +# + +from world import * +from allocations import * +from ape_safe import ApeSafe + + +votes = """ + Convex OUSD/3Crv 30.17 + Morpho Compound USDT 16.29 + Morpho Compound DAI 8.43 + Morpho Compound USDC 5.19 + Aave USDT 4.88 + Compound USDT 4.88 + Aave DAI 1.08 + Aave USDC 1.08 + Compound DAI 1.08 + Compound USDC 1.08 + Convex DAI/USDC/USDT 1.08 + Existing Allocation 24.74 + """ + +with TemporaryFork(): + before_allocation = with_target_allocations(load_from_blockchain(), votes) + print(pretty_allocations(before_allocation)) + before = vault_core.totalValue() + txs = [ + vault_core.rebase({'from': STRATEGIST}), + vault_value_checker.takeSnapshot({"from": STRATEGIST}), + + reallocate(AAVE_STRAT, MORPHO_COMP_STRAT, [[500_000, dai], [500_000, usdc], [1_080_000, usdt]]), + reallocate(COMP_STRAT, MORPHO_COMP_STRAT, [[1_070_000, dai], [1_070_000, usdc], [700_000, usdt]]), + + + reallocate(OUSD_META_STRAT, CONVEX_STRAT, [[1_216_000, dai]]), + reallocate(MORPHO_COMP_STRAT, CONVEX_STRAT, [[1_158_000, usdc]]), + + reallocate(CONVEX_STRAT, MORPHO_COMP_STRAT, [[2_259_000, usdt]]), + + vault_admin.setAssetDefaultStrategy(DAI, MORPHO_COMP_STRAT, {'from': STRATEGIST}), + vault_admin.setAssetDefaultStrategy(USDC, MORPHO_COMP_STRAT, {'from': STRATEGIST}), + vault_admin.setAssetDefaultStrategy(USDT, MORPHO_COMP_STRAT, {'from': STRATEGIST}), + + vault_value_checker.checkDelta(-1378302004686863985848902,-1376802004686863985848902,-1378399395878459980498569,-1376899395878459980498569, {"from": STRATEGIST}), + ] + + snapshot = vault_value_checker.snapshots(STRATEGIST) + print(snapshot) + vault_change = vault_core.totalValue() - snapshot[0] + supply_change = ousd.totalSupply() - snapshot[1] + + + print(",".join([ + str(vault_change - 500 * int(1e18)), + str(vault_change + 1000 * int(1e18)), + str(supply_change - 1000 * int(1e18)), + str(supply_change + 500 * int(1e18)) + ])) + after_allocaiton = with_target_allocations(load_from_blockchain(), before_allocation) + print(pretty_allocations(after_allocaiton)) + allocation_exposure(after_allocaiton) + show_default_strategies() + print("Vault change", c18(vault_change)) + print("Supply change", c18(supply_change)) + print("Profit change", c18(vault_change - supply_change)) + print("") + +safe = ApeSafe('0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC') +safe_tx = safe.multisend_from_receipts(txs) +safe.sign_with_frame(safe_tx) +r = safe.post_transaction(safe_tx) \ No newline at end of file diff --git a/brownie/world.py b/brownie/world.py index 36b94d653a..9a894bf8e2 100644 --- a/brownie/world.py +++ b/brownie/world.py @@ -44,7 +44,7 @@ def load_contract(name, address): aave_strat = load_contract('aave_strat', AAVE_STRAT) comp_strat = load_contract('comp_strat', COMP_STRAT) convex_strat = load_contract('convex_strat', CONVEX_STRAT) -ousd_metastrat = load_contract('ousd_metastrat', OUSD_METASTRAT) +ousd_meta_strat = load_contract('ousd_metastrat', OUSD_METASTRAT) morpho_comp_strat = load_contract('comp_strat', MORPHO_COMP_STRAT) aave_incentives_controller = load_contract('aave_incentives_controller', '0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5') @@ -234,7 +234,7 @@ def show_ousd_metastrat_underlying_balance(): total_lp_owned = staked_bal for asset in (dai, usdt, usdc): - ptoken_addr = ousd_metastrat.assetToPToken(asset.address) + ptoken_addr = ousd_meta_strat.assetToPToken(asset.address) ptoken_contract = load_contract('ERC20', ptoken_addr) # Unstaked LP tokens