Skip to content

Commit 2196daa

Browse files
authored
Strategist actions for Curve Response (#1729)
* Strategist actions for Curve Response
1 parent db50d1e commit 2196daa

File tree

3 files changed

+366
-1
lines changed

3 files changed

+366
-1
lines changed

brownie/runlogs/2023_07_strategist.py

Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,297 @@ def main():
443443
print("Transaction ", idx)
444444
print("To: ", item.receiver)
445445
print("Data (Hex encoded): ", item.input, "\n")
446+
447+
448+
449+
450+
451+
452+
# --------------------------------
453+
# July 30, 2023 - OETH Funds Pull
454+
# --------------------------------
455+
456+
from world import *
457+
458+
txs = []
459+
with TemporaryFork():
460+
# Before
461+
txs.append(vault_oeth_core.rebase({'from':STRATEGIST}))
462+
txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST}))
463+
464+
# Strategist
465+
txs.append(vault_oeth_admin.withdrawAllFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, {'from': STRATEGIST}))
466+
467+
#After
468+
vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0]
469+
supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1]
470+
profit = vault_change - supply_change
471+
txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (2000 * 10**18), {'from': STRATEGIST}))
472+
print("-----")
473+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
474+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
475+
print("-----")
476+
print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs])))
477+
478+
print("Schedule the following transactions on Gnosis Safe")
479+
for idx, item in enumerate(txs):
480+
print("Transaction ", idx)
481+
print("To: ", item.receiver)
482+
print("Data (Hex encoded): ", item.input, "\n")
483+
484+
485+
486+
# --------------------------------
487+
# July 30, 2023 - OUSD Funds Pull
488+
# --------------------------------
489+
490+
from world import *
491+
492+
txs = []
493+
with TemporaryFork():
494+
# Before
495+
txs.append(vault_core.rebase({'from':STRATEGIST}))
496+
txs.append(vault_value_checker.takeSnapshot({'from':STRATEGIST}))
497+
498+
# Withdraw 19.2M USDT from Morpho Aave
499+
txs.append(vault_admin.withdrawAllFromStrategy(OUSD_METASTRAT, {'from': STRATEGIST}))
500+
501+
# After
502+
vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0]
503+
supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1]
504+
profit = vault_change - supply_change
505+
506+
txs.append(vault_value_checker.checkDelta(profit, (500 * 10**18), vault_change, (500 * 10**18), {'from': STRATEGIST}))
507+
print("-----")
508+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
509+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
510+
511+
print("Schedule the following transactions on Gnosis Safe")
512+
for idx, item in enumerate(txs):
513+
print("Transaction ", idx)
514+
print("To: ", item.receiver)
515+
print("Data (Hex encoded): ", item.input, "\n")
516+
517+
518+
519+
# --------------------------------
520+
# July 30, 2023 - OUSD All Funds Pull
521+
# --------------------------------
522+
523+
from world import *
524+
525+
txs = []
526+
with TemporaryFork():
527+
# Before
528+
txs.append(vault_core.rebase({'from':STRATEGIST}))
529+
txs.append(vault_value_checker.takeSnapshot({'from':STRATEGIST}))
530+
531+
# Withdraw 19.2M USDT from Morpho Aave
532+
txs.append(vault_admin.withdrawAllFromStrategies({'from': STRATEGIST}))
533+
534+
# After
535+
vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0]
536+
supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1]
537+
profit = vault_change - supply_change
538+
539+
txs.append(vault_value_checker.checkDelta(profit, (500 * 10**18), vault_change, (300000 * 10**18), {'from': STRATEGIST}))
540+
print("-----")
541+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
542+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
543+
544+
print("Schedule the following transactions on Gnosis Safe")
545+
for idx, item in enumerate(txs):
546+
print("Transaction ", idx)
547+
print("To: ", item.receiver)
548+
print("Data (Hex encoded): ", item.input, "\n")
549+
550+
551+
# --------------------------------
552+
# July 30, 2023 - OETH All Funds Pull
553+
# --------------------------------
554+
555+
from world import *
556+
557+
txs = []
558+
with TemporaryFork():
559+
# Before
560+
txs.append(vault_oeth_core.rebase({'from':STRATEGIST}))
561+
txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST}))
562+
563+
# Strategist
564+
txs.append(vault_oeth_admin.withdrawAllFromStrategies({'from': STRATEGIST}))
565+
566+
#After
567+
vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0]
568+
supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1]
569+
profit = vault_change - supply_change
570+
txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (2000 * 10**18), {'from': STRATEGIST}))
571+
print("-----")
572+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
573+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
574+
print("-----")
575+
print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs])))
576+
577+
print("Schedule the following transactions on Gnosis Safe")
578+
for idx, item in enumerate(txs):
579+
print("Transaction ", idx)
580+
print("To: ", item.receiver)
581+
print("Data (Hex encoded): ", item.input, "\n")
582+
583+
584+
# --------------------------------
585+
# July 30, 2023 - Vault Buffers
586+
# --------------------------------
587+
588+
from world import *
589+
590+
txs = []
591+
with TemporaryFork():
592+
593+
# Strategist
594+
txs.append(vault_oeth_admin.setVaultBuffer(10**18, {'from':STRATEGIST}))
595+
txs.append(vault_admin.setVaultBuffer(10**18, {'from':STRATEGIST}))
596+
597+
print("-----")
598+
print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs])))
599+
600+
print("Schedule the following transactions on Gnosis Safe")
601+
for idx, item in enumerate(txs):
602+
print("Transaction ", idx)
603+
print("To: ", item.receiver)
604+
print("Data (Hex encoded): ", item.input, "\n")
605+
606+
607+
# ---------------------------------------
608+
# July 31, 2023 - OUSD back into earning
609+
# --------------------------------------
610+
611+
from world import *
612+
from allocations import *
613+
import json
614+
import time
615+
616+
def to_gnosis_json(txs):
617+
main = {
618+
"version": "1.0",
619+
"chainId": "1",
620+
"createdAt": int(time.time()),
621+
"meta": {
622+
"name": "Transactions Batch",
623+
"description": "",
624+
"txBuilderVersion": "1.16.1",
625+
"createdFromSafeAddress": "0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC",
626+
"createdFromOwnerAddress": "",
627+
# "checksum": "0x"
628+
},
629+
"transactions": []
630+
}
631+
for tx in txs:
632+
main['transactions'].append({
633+
"to": tx.receiver,
634+
"value": "0",
635+
"data": tx.input,
636+
"contractMethod": None,
637+
"contractInputsValues": None
638+
})
639+
return json.dumps(main)
640+
641+
642+
txs = []
643+
with TemporaryFork():
644+
# Before
645+
txs.append(vault_core.rebase({'from':STRATEGIST}))
646+
txs.append(vault_value_checker.takeSnapshot({'from':STRATEGIST}))
647+
648+
txs.append(to_strat(OUSD_METASTRAT, [[4_688_314, usdt]]))
649+
650+
txs.append(vault_admin.setVaultBuffer(0, {'from':STRATEGIST}))
651+
txs.append(vault_admin.setAssetDefaultStrategy(dai, MORPHO_COMP_STRAT,{'from':STRATEGIST}))
652+
txs.append(vault_admin.setAssetDefaultStrategy(usdc, MORPHO_COMP_STRAT,{'from':STRATEGIST}))
653+
txs.append(vault_admin.setAssetDefaultStrategy(usdt, MORPHO_COMP_STRAT,{'from':STRATEGIST}))
654+
txs.append(vault_core.allocate({'from': STRATEGIST}))
655+
656+
# After
657+
vault_change = vault_core.totalValue() - vault_value_checker.snapshots(STRATEGIST)[0]
658+
supply_change = ousd.totalSupply() - vault_value_checker.snapshots(STRATEGIST)[1]
659+
profit = vault_change - supply_change
660+
661+
txs.append(vault_value_checker.checkDelta(profit, (500 * 10**18), vault_change, (300000 * 10**18), {'from': STRATEGIST}))
662+
print("-----")
663+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
664+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
665+
print("-----")
666+
print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs])))
667+
print("-----")
668+
print(load_from_blockchain())
669+
670+
print("Schedule the following transactions on Gnosis Safe")
671+
for idx, item in enumerate(txs):
672+
print("Transaction ", idx)
673+
print("To: ", item.receiver)
674+
print("Data (Hex encoded): ", item.input, "\n")
675+
print(to_gnosis_json(txs))
676+
677+
# ---------------------------------------
678+
# July 31, 2023 - OETH back into earning
679+
# --------------------------------------
680+
681+
682+
from world import *
683+
import json
684+
import time
685+
686+
def to_gnosis_json(txs):
687+
main = {
688+
"version": "1.0",
689+
"chainId": "1",
690+
"createdAt": int(time.time()),
691+
"meta": {
692+
"name": "Transactions Batch",
693+
"description": "",
694+
"txBuilderVersion": "1.16.1",
695+
"createdFromSafeAddress": "0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC",
696+
"createdFromOwnerAddress": "",
697+
# "checksum": "0x"
698+
},
699+
"transactions": []
700+
}
701+
for tx in txs:
702+
main['transactions'].append({
703+
"to": tx.receiver,
704+
"value": "0",
705+
"data": tx.input,
706+
"contractMethod": None,
707+
"contractInputsValues": None
708+
})
709+
return json.dumps(main)
710+
711+
txs = []
712+
with TemporaryFork():
713+
# Before
714+
txs.append(vault_oeth_core.rebase({'from':STRATEGIST}))
715+
txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST}))
716+
717+
# Strategist
718+
txs.append(vault_oeth_admin.depositToStrategy(OETH_CONVEX_OETH_ETH_STRAT, [weth], [2_445*1e18], {'from': STRATEGIST}))
719+
txs.append(vault_oeth_admin.setVaultBuffer(0, {'from':STRATEGIST}))
720+
txs.append(vault_oeth_core.allocate({'from': STRATEGIST}))
721+
722+
#After
723+
vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0]
724+
supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1]
725+
profit = vault_change - supply_change
726+
txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (2000 * 10**18), {'from': STRATEGIST}))
727+
print("-----")
728+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
729+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
730+
print("-----")
731+
print("Est Gas Max: {:,}".format(1.10*sum([x.gas_used for x in txs])))
732+
733+
print("Schedule the following transactions on Gnosis Safe")
734+
for idx, item in enumerate(txs):
735+
print("Transaction ", idx)
736+
print("To: ", item.receiver)
737+
print("Data (Hex encoded): ", item.input, "\n")
738+
print("----")
739+
print(to_gnosis_json(txs))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from world import *
2+
3+
4+
with TemporaryForkForReallocations() as txs:
5+
# Before
6+
txs.append(vault_oeth_core.rebase({'from':STRATEGIST}))
7+
txs.append(oeth_vault_value_checker.takeSnapshot({'from':STRATEGIST}))
8+
9+
# Strategist
10+
txs.append(vault_oeth_admin.withdrawAllFromStrategy(OETH_CONVEX_OETH_ETH_STRAT, {'from': STRATEGIST}))
11+
txs.append(vault_oeth_admin.depositToStrategy(OETH_CONVEX_OETH_ETH_STRAT, [weth], [4_853*1e18], {'from': STRATEGIST}))
12+
13+
#After
14+
vault_change = vault_oeth_core.totalValue() - oeth_vault_value_checker.snapshots(STRATEGIST)[0]
15+
supply_change = oeth.totalSupply() - oeth_vault_value_checker.snapshots(STRATEGIST)[1]
16+
profit = vault_change - supply_change
17+
txs.append(oeth_vault_value_checker.checkDelta(profit, (0.1 * 10**18), vault_change, (1000 * 10**18), {'from': STRATEGIST}))
18+
print("-----")
19+
print("Profit", "{:.6f}".format(profit / 10**18), profit)
20+
print("Vault Change", "{:.6f}".format(vault_change / 10**18), vault_change)
21+
print("-----")

brownie/world.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,57 @@ def show_governance_action(i, to, sig, data):
405405
print(" >> ", nice_contract_address(v))
406406
else:
407407
print(" >> ", ORANGE+str(v)+ENDC)
408-
408+
409+
def to_gnosis_json(txs):
410+
main = {
411+
"version": "1.0",
412+
"chainId": "1",
413+
"createdAt": int(time.time()),
414+
"meta": {
415+
"name": "Transactions Batch",
416+
"description": "",
417+
"txBuilderVersion": "1.16.1",
418+
"createdFromSafeAddress": "0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC",
419+
"createdFromOwnerAddress": "",
420+
# "checksum": "0x"
421+
},
422+
"transactions": [],
423+
}
424+
for tx in txs:
425+
main["transactions"].append(
426+
{
427+
"to": tx.receiver,
428+
"value": "0",
429+
"data": tx.input,
430+
"contractMethod": None,
431+
"contractInputsValues": None,
432+
}
433+
)
434+
return json.dumps(main)
435+
436+
437+
def show_txs_data(txs):
438+
print("Schedule the following transactions on Gnosis Safe")
439+
for idx, item in enumerate(txs):
440+
print("Transaction ", idx)
441+
print("To: ", item.receiver)
442+
print("Data (Hex encoded): ", item.input, "\n")
443+
444+
445+
class TemporaryForkForReallocations:
446+
def __enter__(self):
447+
self.txs = []
448+
brownie.chain.snapshot()
449+
return self.txs
450+
451+
def __exit__(self, *args, **kwargs):
452+
brownie.chain.revert()
453+
print("----")
454+
print("Gnosis json:")
455+
print(to_gnosis_json(self.txs))
456+
print("----")
457+
print("Est Gas Max: {:,}".format(1.10 * sum([x.gas_used for x in self.txs])))
458+
409459

410460
def show_governor_four_proposal_actions(proposal_id):
411461
actions = governor.getActions(proposal_id)

0 commit comments

Comments
 (0)