Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into sparrow/deploy_71
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrowDom committed Sep 21, 2023
2 parents 2b7d21b + b609535 commit d5d581f
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
4 changes: 2 additions & 2 deletions brownie/buyback.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ def build_buyback_tx(max_dollars=5000, max_slippage=2.0, with_fork=True):
# Display buyback amounts
print("OUSD available on contract: {}".format(c18(ousd_available)))
print("OUSD to use for transaction: {}".format(c18(buyback_amount)))
print("OUSD send to treasury: {}".format(c18(ousd_for_treasury * 10**18)))
print("OUSD to swap: {}".format(c18(ousd_to_swap * 10**18)))
print("OUSD to send to treasury: {}".format(c18(ousd_for_treasury)))
print("OUSD to swap: {}".format(c18(ousd_to_swap)))
print("----")

x = no_slippage_ogv
Expand Down
42 changes: 42 additions & 0 deletions brownie/convex.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from world import *


from oneinch import get_1inch_swap_data

def lock_cvx(with_fork=True):
if with_fork:
txs = []
Expand All @@ -16,3 +19,42 @@ def lock_cvx(with_fork=True):
else:
return cvx_locker.lock(STRATEGIST, cvx.balanceOf(STRATEGIST), 0, {'from': STRATEGIST})

def build_cvx_buyback_tx(slippage=1):
txs = []
with TemporaryFork():
oeth_balance = oeth.balanceOf(STRATEGIST)
ousd_balance = ousd.balanceOf(STRATEGIST)

# Approve 1-inch to move OETH and OUSD
txs.append(
oeth.approve(ROUTER_1INCH_V5, oeth_balance, {'from': STRATEGIST})
)
txs.append(
ousd.approve(ROUTER_1INCH_V5, ousd_balance, {'from': STRATEGIST})
)

# Swap OETH for CVX
txs.append(
get_1inch_swap_data(
OETH,
CVX,
oeth_balance,
slippage,
)
)

# Swap OUSD for CVX
txs.append(
get_1inch_swap_data(
OUSD,
CVX,
ousd_balance,
slippage,
)
)

print("Schedule the following transactions on Gnosis Safe")
for idx, item in enumerate(txs):
print("Transaction ", idx)
print("To: ", item.receiver)
print("Data (Hex encoded): ", item.input, "\n")
6 changes: 5 additions & 1 deletion brownie/oneinch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from world import *
import requests
from types import SimpleNamespace
import os

ONEINCH_SUBDOMAIN = os.getenv('ONEINCH_SUBDOMAIN')
ONEINCH_SUBDOMAIN = ONEINCH_SUBDOMAIN if len(ONEINCH_SUBDOMAIN) > 0 else 'api'

def get_1inch_swap_data(from_token, to_token, swap_amount, slippage, from_address=STRATEGIST, to_address=STRATEGIST):
req = requests.get('https://api.1inch.io/v5.0/1/swap', params={
req = requests.get('https://{}.1inch.io/v5.0/1/swap'.format(ONEINCH_SUBDOMAIN), params={
'fromTokenAddress': from_token,
'fromAddress': from_address,
'destReceiver': to_address,
Expand Down
24 changes: 24 additions & 0 deletions brownie/runlogs/2023_09_strategist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -------------------------------------
# Sep 13, 2023 - OGV Buyback
# ------------------------------------
from buyback import *

def main():
build_buyback_tx(max_dollars=14000, max_slippage=9)

# -------------------------------------
# Sep 13, 2023 - Buy CVX
# ------------------------------------
from convex import *

def main():
build_cvx_buyback_tx(slippage=1)

# -------------------------------------
# Sep 13, 2023 - Buy CVX
# ------------------------------------
from convex import *

def main():
lock_cvx()

2 changes: 2 additions & 0 deletions dapp-oeth/src/components/buySell/SwapHomepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const SwapHomepage = ({

event({
event: 'swap_started',
swap_route: selectedSwap.name,
swap_token: swapTokenUsed,
swap_amount: swapTokenAmount,
})
Expand Down Expand Up @@ -266,6 +267,7 @@ const SwapHomepage = ({
event({
event: 'swap_complete',
swap_type: swapMode,
swap_route: selectedSwap.name,
swap_token: swapTokenUsed,
swap_amount: swapTokenAmount,
})
Expand Down

0 comments on commit d5d581f

Please sign in to comment.