Skip to content

Commit

Permalink
feat: sort txs (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Aug 31, 2023
1 parent a84a0d6 commit 375812c
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 11 deletions.
4 changes: 4 additions & 0 deletions yearn/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

YFI = {
Network.Mainnet: "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
Network.Fantom: "0x29b0Da86e484E1C0029B56e817912d778aC0EC69",
Network.Arbitrum: "0x82e3A8F066a6989666b031d916c43672085b1582",
Network.Polygon: "0xDA537104D6A5edd53c6fBba9A898708E465260b6",
}.get(chain.id, None)

WRAPPED_GAS_COIN = {
Expand All @@ -15,6 +18,7 @@
Network.Arbitrum: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
Network.Gnosis: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d",
Network.Optimism: "0x4200000000000000000000000000000000000006",
Network.Polygon: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
}.get(chain.id, None)

YEARN_ADDRESSES_PROVIDER = "0x9be19Ee7Bc4099D62737a7255f5c227fBcd6dB93"
Expand Down
3 changes: 3 additions & 0 deletions yearn/treasury/accountant/expenses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@
grants.create_child("Zootroop [BR#xxx]", people.is_zootroop)
grants.create_child("Corn [BR#xxx]", people.is_corn)
grants.create_child("Tapir [BR#xxx]", people.is_tapir)
grants.create_child("Hipsterman", people.is_hipsterman)
grants.create_child("Worms", people.is_worms)
grants.create_child("ySecurity 2 [BR#xxx]", people.is_ysecurity_2)
grants.create_child("yBudget [BR#xxx]", people.is_ybudget)
grants.create_child("ySupport [BR#xxx]", people.is_ysupport)
grants.create_child("Rantom [BR#xxx]", people.is_rantom)
4 changes: 3 additions & 1 deletion yearn/treasury/accountant/expenses/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

def is_servers(tx: TreasuryTx) -> bool:
return tx in HashMatcher([
["0x08ef1aacdf7d0f16be5e6fd0a64ebd0ba3b0c3dd0a7884a9a470aa89a7fe1a06", Filter('log_index', 222)]
["0x08ef1aacdf7d0f16be5e6fd0a64ebd0ba3b0c3dd0a7884a9a470aa89a7fe1a06", Filter('log_index', 222)],
["0x0c59e87027bcdcaa718e322a28bc436106d73ae8623071930437bdb0706c4d65", Filter('token', "DAI")],
])

def is_tenderly(tx: TreasuryTx) -> bool:
Expand Down Expand Up @@ -34,5 +35,6 @@ def is_generic(tx: TreasuryTx) -> bool:
["0x5deca5d6c934372c174bbef8be9a1e103e06d8b93fd3bf8d77865dfeb34fe3be", Filter('log_index', 98)],
"0x3160b025085b17ee4bc3810c753c2d1fe9c556d2fb4cdf2ec7669cc878a94c68",
"0x17a72a66512aa302a4f89b7d894519abf335156deac2a4801c884283181daa83",
"0xb9b5eef15987d97448d6cae146231c47910ba937db7dc30cfb253d64cbc5515d",
]
return tx in HashMatcher(hashes)
13 changes: 11 additions & 2 deletions yearn/treasury/accountant/expenses/people.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def is_other_grant(tx: TreasuryTx) -> bool:
["0xca372ad75b957bfce7e7fbca879399f46f923f9ca17299e310150da8666703b9", Filter('log_index', 515)],
["0x9681276a8668f5870551908fc17be3553c82cf6a9fedbd2fdb43f1c05385dca1", Filter('log_index', 181)],
"0xa96246a18846cd6966fc87571313a2021d8e1e38466132e2b7fe79acbbd2c589",
["0x47bcb48367b5c724780b40a19eed7ba4f623de619e98c30807f52be934d28faf", Filter('_symbol', "DAI")]
["0x47bcb48367b5c724780b40a19eed7ba4f623de619e98c30807f52be934d28faf", Filter('_symbol', "DAI")],
["0xa0aa1d29e11589350db4df09adc496102a1d9db8a778fc7108d2fb99fb40b6d0", IterFilter("log_index", [391, 394])],
]
disperse_hashes = [
"0x1e411c81fc83abfe260f58072c74bfa91e38e27e0066da07ea06f75d9c8f4a00",
Expand Down Expand Up @@ -160,12 +161,16 @@ def is_yearn_exporter(tx: TreasuryTx) -> bool:
return True
elif tx._symbol == "DAI" and tx.amount == 23_025:
return True
if tx.hash == "0x1dc86ccdeb96d8d3d314eb2c1fdad0f4dd11c9ea54dfddedcc9340e71f98aa9e":
tx.amount *= -1
return True
return False

# TODO figure out why these didn't sort
_xopowo_hashes = [
"0xea1ce33495faf84892826ce4d25b9010ef1b035215f38e537164237cff07c459",
"0x1969a5ebdedc96057feaa7a156adbdfd2e452868d0bb8258df767f12db26895d",
"0xa8eb68338106aa60aba95406ed201b098821884c8c1893c93b400ee994a7facc",
]

def is_xopowo(tx: TreasuryTx) -> bool:
Expand Down Expand Up @@ -200,6 +205,7 @@ def is_s2_team(tx: TreasuryTx) -> bool:
_ycreative_hashes = [
"0x1969a5ebdedc96057feaa7a156adbdfd2e452868d0bb8258df767f12db26895d",
"0xea1ce33495faf84892826ce4d25b9010ef1b035215f38e537164237cff07c459",
"0x53cbb8189b9ce895f0fc9b5fb0660f47c406c5d1879e053fe0bec3ff3321676c",
]

def is_ycreative(tx: TreasuryTx) -> bool:
Expand Down Expand Up @@ -258,4 +264,7 @@ def is_ysupport(tx: TreasuryTx) -> bool:
return tx.to_address.address == "0xbd7B3Bc2C4581Fd173362c830AE45fB9506B3dA5"

def is_rantom(tx: TreasuryTx) -> bool:
return tx.to_address.address == "0x254b42CaCf7290e72e2C84c0337E36E645784Ce1"
return tx.to_address.address == "0x254b42CaCf7290e72e2C84c0337E36E645784Ce1"

def is_tx_creator(tx: TreasuryTx) -> bool:
return tx.to_address.address == "0x4007c53A48DefaB0b9D2F05F34df7bd3088B3299"
2 changes: 2 additions & 0 deletions yearn/treasury/accountant/other_expenses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
other_expense_txgroup.create_child("yChute", general.is_ychute)
other_expense_txgroup.create_child("EthOnline Prizes", general.is_eth_online_prizes)
other_expense_txgroup.create_child("4626 Alliance Grant", general.is_4626_alliance)
other_expense_txgroup.create_child("yETH Bootstrap", general.is_yeth_bootstrap)
other_expense_txgroup.create_child("Warroom Games 2023 Prizes", general.is_warroom_games)

# Bugs
if chain.id == Network.Mainnet:
Expand Down
8 changes: 7 additions & 1 deletion yearn/treasury/accountant/other_expenses/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,10 @@ def is_eth_online_prizes(tx: TreasuryTx) -> bool:
def is_4626_alliance(tx: TreasuryTx) -> bool:
return tx in HashMatcher([
["0xca61496c32806ba34f0deb331c32969eda11c947fdd6235173e6fa13d9a1c288", Filter('log_index', 150)],
])
])

def is_yeth_bootstrap(tx: TreasuryTx) -> bool:
return tx.token == "ETH" and tx.hash == '0x0c59e87027bcdcaa718e322a28bc436106d73ae8623071930437bdb0706c4d65'

def is_warroom_games(tx: TreasuryTx) -> bool:
return tx.hash == "0x8f17ead9cea87166cf99ed2cdbc46dfdf98c04c261de5b5167caddce5f704cb2" and tx.log_index in [429,430,431]
1 change: 1 addition & 0 deletions yearn/treasury/accountant/other_income/airdrop.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def is_airdrop(tx: TreasuryTx) -> bool:
["0xe8b5a4ebf1f04048f6226b22b2865a33621e88ea255dcea0cfd7a975a3a7e387", Filter('log_index', 72)], # Gnosis SAFE airdrop
"0x44f7d3b2030799ea45932baf6049528a059aabd6387f3128993d646d01c8e877", # TKX
"0xf2dbe58dffd3bc1476755e9f74e2ae07531579d0a3ea9e2aaac2ef902e080c2a", # TKX
"0x8079e9cae847da196dc5507561bc9d1434f765f05045bc1a82df735ec83bc6ec", # MTV
],
}.get(chain.id, [])
return tx in HashMatcher(hashes)
17 changes: 10 additions & 7 deletions yearn/treasury/treasury.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from y.exceptions import NonStandardERC20
from y.networks import Network

from yearn.constants import STRATEGIST_MULTISIG, TREASURY_WALLETS
from yearn import constants
from yearn.outputs.victoria.victoria import _build_item

logger = logging.getLogger(__name__)
Expand All @@ -24,6 +24,12 @@ async def _get_symbol(token):
return await ERC20(token, asynchronous=True).symbol
except NonStandardERC20:
return None

async def _get_bucket(token) -> str:
if token == constants.YFI:
return "Other long term assets"
else:
return await get_token_bucket(token)

class ExportablePortfolio(Portfolio):
""" Adds methods to export full portoflio data. """
Expand Down Expand Up @@ -56,10 +62,7 @@ async def _process_token(self, ts, section: str, wallet: str, token: str, bals:
if protocol is not None:
wallet = f'{protocol} | {wallet}'

symbol, bucket = await asyncio.gather(
_get_symbol(token),
get_token_bucket(token),
)
symbol, bucket = await asyncio.gather(_get_symbol(token), _get_bucket(token))

items = []

Expand Down Expand Up @@ -92,7 +95,7 @@ def __init__(self, asynchronous: bool = False, load_prices: bool = False) -> Non
Network.Optimism: datetime(2022, 8, 6, 20, 1, 18, tzinfo=timezone.utc), # create contract blocks 18100336
}[chain.id]
'''
super().__init__(TREASURY_WALLETS, label='treasury', start_block=start_block, asynchronous=asynchronous, load_prices=load_prices)
super().__init__(constants.TREASURY_WALLETS, label='treasury', start_block=start_block, asynchronous=asynchronous, load_prices=load_prices)

# TODO link this in
async def partners_debt(self, block: int = None) -> dict:
Expand Down Expand Up @@ -120,7 +123,7 @@ def __init__(self, asynchronous: bool = False, load_prices: bool = False) -> Non
Network.Arbitrum: 2_434_174,
Network.Optimism: 18_084_577,
}[chain.id]
super().__init__(STRATEGIST_MULTISIG, label='sms', start_block=start_block, asynchronous=asynchronous, load_prices=load_prices)
super().__init__(constants.STRATEGIST_MULTISIG, label='sms', start_block=start_block, asynchronous=asynchronous, load_prices=load_prices)

""" TODO check these
start = {
Expand Down

0 comments on commit 375812c

Please sign in to comment.