Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Flux strategy and governance monitoring #363

Merged
merged 3 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion eagleproject/core/blockchain/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@
# This contract needs 60% support to pass
CURVE_ARAGON_60 = "0xbcff8b0b9419b9a88c44546519b1e909cf330399"

# Flux Finance Governance
FLUX_TIMELOCK = "0x2c5898da4df1d45eab2b7b192a361c3b9eb18d9c"
FLUX_DAO = "0x336505ec1bcc1a020eede459f57581725d23465a"

# Name resolution
CONTRACT_ADDR_TO_NAME = {
OUSD: "OUSD Token",
Expand Down Expand Up @@ -222,7 +226,8 @@
OGV_BUYBACK_LEGACY: "OGV BuyBack (Legacy)",
OGV_BUYBACK_PROXY: "OGV BuyBack",
REWARDS_SOURCE: "RewardsSource",

FLUX_DAO: "Flux DAO",
FLUX_TIMELOCK: "Flux Timelock",

# OETH Contracts
OETH: "OETH Token",
Expand Down
6 changes: 5 additions & 1 deletion eagleproject/core/blockchain/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
RETH,
STETH,
WETH,
ETH
ETH,
FLUX_DAO,
FLUX_TIMELOCK
)

from core.blockchain.strategies import OUSD_STRATEGIES, OETH_STRATEGIES
Expand Down Expand Up @@ -177,6 +179,8 @@
CURVE_ARAGON_51,
CURVE_ARAGON_60,
CHAINLINK_KEEPER_REGISTRY,
FLUX_DAO,
FLUX_TIMELOCK
]

ETHERSCAN_CONTRACTS = [
Expand Down
8 changes: 8 additions & 0 deletions eagleproject/core/blockchain/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
OUSD_METASTRAT = "0x89eb88fedc50fc77ae8a18aad1ca0ac27f777a90"
MORPHO_AAVE = "0x79f2188ef9350a1dc11a062cca0abe90684b0197"
LUSD_METASTRAT = "0x7a192dd9cc4ea9bdedec9992df74f1da55e60a19"
FLUX_STRAT = "0x76bf500b6305dc4ea851384d3d5502f1c7a0ed44"

# OETH Contracts
OETH_VAULT = "0x39254033945aa2e4809cc2977e7087bee48bd7ab"
Expand Down Expand Up @@ -108,6 +109,13 @@
"SUPPORTED_ASSETS": OUSD_BACKING_ASSETS,
"ICON_NAME": "morpho.png",
},
"flux_strat": {
"NAME": "Flux Strategy",
"ADDRESS": FLUX_STRAT,
"FROM_BLOCK": 17877302,
"SUPPORTED_ASSETS": OUSD_BACKING_ASSETS,
"ICON_NAME": "comp-icon.svg",
},
}

# OETH Strategies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
from eth_utils import decode_hex
from eth_abi import decode_single

from core.blockchain.addresses import COMPOUND_GOVERNOR_BRAVO
from core.blockchain.addresses import (
COMPOUND_GOVERNOR_BRAVO,
FLUX_DAO,
CONTRACT_ADDR_TO_NAME,
)
from core.blockchain.sigs import SIG_EVENT_NEW_IMPLEMENTATION_BRAVO
from notify.events import event_high

DISCORD_EMBED_DESCRIPTION_LIMIT = 2048


def get_events(logs):
""" Get Mint/Redeem events """
return logs.filter(address=COMPOUND_GOVERNOR_BRAVO).filter(
return logs.filter(address__in=[COMPOUND_GOVERNOR_BRAVO, FLUX_DAO]).filter(
topic_0=SIG_EVENT_NEW_IMPLEMENTATION_BRAVO
).order_by('block_number')

Expand All @@ -27,10 +30,12 @@ def run_trigger(new_logs):
)
new_link = 'https://etherscan.io/address/{}'.format(new_address)

contract_name = CONTRACT_ADDR_TO_NAME.get(ev.address, ev.address)

events.append(event_high(
"Compound GovernorBravo implementation upgraded 🗳️ ⏫",
"Compound GovernorBravo implementation changed from {} to [{}]({})".format(
old_address, new_address, new_link
"{} implementation upgraded 🗳️ ⏫".format(contract_name),
"{} implementation changed from {} to [{}]({})".format(
contract_name, old_address, new_address, new_link
),
log_model=ev
))
Expand Down
29 changes: 19 additions & 10 deletions eagleproject/notify/triggers/compound_governorbravo_proposals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from core.blockchain.addresses import (
CONTRACT_ADDR_TO_NAME,
COMPOUND_GOVERNOR_BRAVO,
FLUX_DAO,
)
from core.blockchain.decode import decode_calls
from core.blockchain.sigs import (
Expand All @@ -24,7 +25,7 @@

def get_events(logs):
""" Get Mint/Redeem events """
return logs.filter(address=COMPOUND_GOVERNOR_BRAVO).filter(
return logs.filter(address__in=[COMPOUND_GOVERNOR_BRAVO,FLUX_DAO]).filter(
Q(topic_0=SIG_EVENT_PROPOSAL_CREATED)
| Q(topic_0=SIG_EVENT_PROPOSAL_CANCELED)
| Q(topic_0=SIG_EVENT_PROPOSAL_QUEUED)
Expand All @@ -33,17 +34,18 @@ def get_events(logs):
).order_by('block_number')


def create_prop_details(proposal_id, description, proposer, targets,
def create_prop_details(contract_name, proposal_id, description, proposer, targets,
signatures, calldatas, start_block, end_block):
return (
"A new proposal ({}) has been submitted for Compound Governor"
"A new proposal ({}) has been submitted for {}"
"\n\n"
"**Description**: \n\n{}\n\n"
"**Proposer**: {}\n"
"**Targets**: {}\n"
"**Calls**: \n - {}\n"
"**Block Range**: {}".format(
proposal_id,
contract_name,
description,
proposer,
', '.join([
Expand All @@ -61,6 +63,7 @@ def run_trigger(new_logs):
events = []

for ev in get_events(new_logs):
contract_name = CONTRACT_ADDR_TO_NAME.get(ev.address, ev.address)

if ev.topic_0 == SIG_EVENT_PROPOSAL_CREATED:
# ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description)
Expand All @@ -80,6 +83,7 @@ def run_trigger(new_logs):
)

details = create_prop_details(
contract_name,
proposal_id,
description,
proposer,
Expand All @@ -94,6 +98,7 @@ def run_trigger(new_logs):
if len(details) > DISCORD_EMBED_DESCRIPTION_LIMIT:
diff = len(details) - DISCORD_EMBED_DESCRIPTION_LIMIT
details = create_prop_details(
contract_name,
proposal_id,
truncate_elipsis(
description,
Expand All @@ -108,7 +113,8 @@ def run_trigger(new_logs):
)

events.append(event_high(
"Compound Governor Proposal Created ({}) 🗳️ 🆕".format(
"{} Proposal Created ({}) 🗳️ 🆕".format(
contract_name,
proposal_id
),
details,
Expand All @@ -119,8 +125,9 @@ def run_trigger(new_logs):
proposal_id = decode_single("(uint256)", decode_hex(ev.data))[0]

events.append(event_high(
"Compound GovernorBravo proposed cancelled 🗳️ ❌",
"Compound GovernorBravo proposal #{} has been canceled".format(
"{} proposed cancelled 🗳️ ❌".format(contract_name),
"{} proposal #{} has been canceled".format(
contract_name,
proposal_id
),
log_model=ev
Expand All @@ -135,9 +142,10 @@ def run_trigger(new_logs):
eta = datetime.utcfromtimestamp(eta_stamp)

events.append(event_high(
"Compound GovernorBravo proposed queued 🗳️ 📥",
"Compound GovernorBravo proposal #{} has been queued "
"{} proposed queued 🗳️ 📥".format(contract_name),
"{} proposal #{} has been queued "
"for {} UTC".format(
contract_name,
proposal_id,
eta,
),
Expand All @@ -148,8 +156,9 @@ def run_trigger(new_logs):
proposal_id = decode_single("(uint256)", decode_hex(ev.data))[0]

events.append(event_high(
"Compound GovernorBravo proposed executed 🗳️ ⚙️",
"Compound GovernorBravo proposal #{} has been executed".format(
"{} proposed executed 🗳️ ⚙️".format(contract_name),
"{} proposal #{} has been executed".format(
contract_name,
proposal_id,
),
log_model=ev
Expand Down
29 changes: 18 additions & 11 deletions eagleproject/notify/triggers/compound_governorbravo_votingparams.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
from eth_utils import decode_hex
from eth_abi import decode_single

from core.blockchain.addresses import COMPOUND_GOVERNOR_BRAVO
from core.blockchain.addresses import (
COMPOUND_GOVERNOR_BRAVO,
FLUX_DAO,
CONTRACT_ADDR_TO_NAME,
)
from core.blockchain.const import E_18
from core.blockchain.sigs import (
SIG_EVENT_VOTING_DELAY_SET,
Expand All @@ -18,7 +22,7 @@

def get_events(logs):
""" Get Mint/Redeem events """
return logs.filter(address=COMPOUND_GOVERNOR_BRAVO).filter(
return logs.filter(address__in=[COMPOUND_GOVERNOR_BRAVO, FLUX_DAO]).filter(
Q(topic_0=SIG_EVENT_VOTING_DELAY_SET)
| Q(topic_0=SIG_EVENT_VOTING_PERIOD_SET)
| Q(topic_0=SIG_EVENT_PROPOSAL_THRESHOLD_SET)
Expand All @@ -30,16 +34,19 @@ def run_trigger(new_logs):
events = []

for ev in get_events(new_logs):
contract_name = CONTRACT_ADDR_TO_NAME.get(ev.address, ev.address)
token_name = "ONDO" if ev.address == FLUX_DAO else "COMP"

if ev.topic_0 == SIG_EVENT_VOTING_DELAY_SET:
old_delay, new_delay = decode_single(
"(uint256,uint256)",
decode_hex(ev.data)
)

events.append(event_normal(
"Compound GovernorBravo voting delay changed 🗳️ 🕖",
"Compound GovernorBravo voting delay changed from {} blocks to {} blocks".format(
old_delay, new_delay
"{} voting delay changed 🗳️ 🕖".format(contract_name),
"{} voting delay changed from {} blocks to {} blocks".format(
contract_name, old_delay, new_delay
),
log_model=ev
))
Expand All @@ -51,9 +58,9 @@ def run_trigger(new_logs):
)

events.append(event_normal(
"Compound GovernorBravo voting delay changed 🗳️ 🕗",
"Compound GovernorBravo voting period changed from {} blocks to {} blocks".format(
old_period, new_period
"{} voting delay changed 🗳️ 🕗".format(contract_name),
"{} voting period changed from {} blocks to {} blocks".format(
contract_name, old_period, new_period
),
log_model=ev
))
Expand All @@ -68,9 +75,9 @@ def run_trigger(new_logs):
new_human = Decimal(new_threshold) / E_18

events.append(event_normal(
"Compound GovernorBravo voting threshold changed 🗳️ 🪙",
"Compound GovernorBravo voting threshold changed from {} COMP to {} COMP".format(
old_human, new_human
"{} voting threshold changed 🗳️ 🪙".format(contract_name),
"{} voting threshold changed from {} {} to {} {}".format(
contract_name, old_human, token_name, new_human, token_name
),
log_model=ev
))
Expand Down
24 changes: 16 additions & 8 deletions eagleproject/notify/triggers/compound_timelock_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from eth_utils import decode_hex
from eth_abi import decode_single

from core.blockchain.addresses import COMPOUND_TIMELOCK
from core.blockchain.addresses import (
CONTRACT_ADDR_TO_NAME,
COMPOUND_TIMELOCK,
FLUX_TIMELOCK,
)
from core.blockchain.sigs import (
SIG_EVENT_NEW_ADMIN,
SIG_EVENT_NEW_PENDING_ADMIN,
Expand All @@ -13,7 +17,7 @@

def get_events(logs):
""" Get Mint/Redeem events """
return logs.filter(address=COMPOUND_TIMELOCK).filter(
return logs.filter(address__in=[COMPOUND_TIMELOCK, FLUX_TIMELOCK]).filter(
Q(topic_0=SIG_EVENT_NEW_ADMIN)
| Q(topic_0=SIG_EVENT_NEW_PENDING_ADMIN)
).order_by('block_number')
Expand All @@ -26,23 +30,27 @@ def run_trigger(new_logs):
for ev in get_events(new_logs):
admin_address = decode_single("(address)", decode_hex(ev.topic_1))[0]

contract_name = CONTRACT_ADDR_TO_NAME.get(ev.address, ev.address)

if ev.topic_0 == SIG_EVENT_NEW_ADMIN:
events.append(event_high(
"Compound Timelock admin claimed 👮",
"A new admin has been set for the Compound Timelock "
"{} admin claimed 👮".form(contract_name),
"A new admin has been set for the {} "
"contract: {}".format(
contract_name,
admin_address
),
log_model=ev
))

elif ev.topic_0 == SIG_EVENT_NEW_PENDING_ADMIN:
events.append(event_high(
"New Compound Timelock admin proposed 👮",
"{} has been proposed as the new admin for the Compound "
"Timelock governor contract and is currently waiting to be "
"New {} admin proposed 👮".format(contract_name),
"{} has been proposed as the new admin for the {} "
"governor contract and is currently waiting to be "
"claimed.".format(
admin_address
admin_address,
contract_name
),
log_model=ev
))
Expand Down
15 changes: 11 additions & 4 deletions eagleproject/notify/triggers/compound_timelock_delay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
from eth_utils import decode_hex
from eth_abi import decode_single

from core.blockchain.addresses import COMPOUND_TIMELOCK
from core.blockchain.addresses import (
CONTRACT_ADDR_TO_NAME,
COMPOUND_TIMELOCK,
FLUX_TIMELOCK,
)
from core.blockchain.sigs import SIG_EVENT_DELAY
from notify.events import event_high


def get_events(logs):
""" Get NewDelay events """
return logs.filter(address=COMPOUND_TIMELOCK).filter(
return logs.filter(address__in=[COMPOUND_TIMELOCK, FLUX_TIMELOCK]).filter(
topic_0=SIG_EVENT_DELAY
).order_by('block_number')

Expand All @@ -20,12 +24,15 @@ def run_trigger(new_logs):
events = []

for ev in get_events(new_logs):
contract_name = CONTRACT_ADDR_TO_NAME.get(ev.address, ev.address)

delay_seconds = decode_single("(uint256)", decode_hex(ev.topic_1))[0]
delay = timedelta(seconds=delay_seconds)

events.append(event_high(
"Compound Timelock delay changed 👮",
"Compound Timelock delay has been changed to {}".format(
"{} delay changed 👮".format(contract_name),
"{} delay has been changed to {}".format(
contract_name,
delay
),
log_model=ev
Expand Down
Loading
Loading