yearn-treasury 0.1.7__cp310-cp310-win32.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. yearn_treasury/__init__.py +19 -0
  2. yearn_treasury/_db.cp310-win32.pyd +0 -0
  3. yearn_treasury/_db.py +50 -0
  4. yearn_treasury/_ens.cp310-win32.pyd +0 -0
  5. yearn_treasury/_ens.py +30 -0
  6. yearn_treasury/_logging.cp310-win32.pyd +0 -0
  7. yearn_treasury/_logging.py +41 -0
  8. yearn_treasury/address_labels.yaml +39 -0
  9. yearn_treasury/budget/__init__.cp310-win32.pyd +0 -0
  10. yearn_treasury/budget/__init__.py +6 -0
  11. yearn_treasury/budget/_request.cp310-win32.pyd +0 -0
  12. yearn_treasury/budget/_request.py +43 -0
  13. yearn_treasury/budget/_requests.cp310-win32.pyd +0 -0
  14. yearn_treasury/budget/_requests.py +96 -0
  15. yearn_treasury/constants.py +91 -0
  16. yearn_treasury/main.py +175 -0
  17. yearn_treasury/py.typed +1 -0
  18. yearn_treasury/rules/__init__.py +20 -0
  19. yearn_treasury/rules/constants.cp310-win32.pyd +0 -0
  20. yearn_treasury/rules/constants.py +15 -0
  21. yearn_treasury/rules/cost_of_revenue/__init__.py +1 -0
  22. yearn_treasury/rules/cost_of_revenue/gas.cp310-win32.pyd +0 -0
  23. yearn_treasury/rules/cost_of_revenue/gas.py +64 -0
  24. yearn_treasury/rules/cost_of_revenue/match_on_hash.yaml +12 -0
  25. yearn_treasury/rules/expense/__init__.cp310-win32.pyd +0 -0
  26. yearn_treasury/rules/expense/__init__.py +4 -0
  27. yearn_treasury/rules/expense/general.cp310-win32.pyd +0 -0
  28. yearn_treasury/rules/expense/general.py +13 -0
  29. yearn_treasury/rules/expense/infrastructure.cp310-win32.pyd +0 -0
  30. yearn_treasury/rules/expense/infrastructure.py +46 -0
  31. yearn_treasury/rules/expense/match_on_hash.yaml +48 -0
  32. yearn_treasury/rules/expense/match_on_to_address.yaml +7 -0
  33. yearn_treasury/rules/expense/people.cp310-win32.pyd +0 -0
  34. yearn_treasury/rules/expense/people.py +83 -0
  35. yearn_treasury/rules/expense/security.cp310-win32.pyd +0 -0
  36. yearn_treasury/rules/expense/security.py +146 -0
  37. yearn_treasury/rules/ignore/__init__.py +8 -0
  38. yearn_treasury/rules/ignore/general.cp310-win32.pyd +0 -0
  39. yearn_treasury/rules/ignore/general.py +11 -0
  40. yearn_treasury/rules/ignore/maker.py +91 -0
  41. yearn_treasury/rules/ignore/passthru.py +309 -0
  42. yearn_treasury/rules/ignore/staking.py +101 -0
  43. yearn_treasury/rules/ignore/swaps/__init__.py +24 -0
  44. yearn_treasury/rules/ignore/swaps/_skip_tokens.py +8 -0
  45. yearn_treasury/rules/ignore/swaps/aave.py +68 -0
  46. yearn_treasury/rules/ignore/swaps/auctions.cp310-win32.pyd +0 -0
  47. yearn_treasury/rules/ignore/swaps/auctions.py +30 -0
  48. yearn_treasury/rules/ignore/swaps/compound.py +57 -0
  49. yearn_treasury/rules/ignore/swaps/conversion_factory.cp310-win32.pyd +0 -0
  50. yearn_treasury/rules/ignore/swaps/conversion_factory.py +20 -0
  51. yearn_treasury/rules/ignore/swaps/cowswap.py +86 -0
  52. yearn_treasury/rules/ignore/swaps/curve.py +174 -0
  53. yearn_treasury/rules/ignore/swaps/gearbox.cp310-win32.pyd +0 -0
  54. yearn_treasury/rules/ignore/swaps/gearbox.py +36 -0
  55. yearn_treasury/rules/ignore/swaps/iearn.cp310-win32.pyd +0 -0
  56. yearn_treasury/rules/ignore/swaps/iearn.py +41 -0
  57. yearn_treasury/rules/ignore/swaps/otc.cp310-win32.pyd +0 -0
  58. yearn_treasury/rules/ignore/swaps/otc.py +58 -0
  59. yearn_treasury/rules/ignore/swaps/pooltogether.cp310-win32.pyd +0 -0
  60. yearn_treasury/rules/ignore/swaps/pooltogether.py +23 -0
  61. yearn_treasury/rules/ignore/swaps/synthetix.cp310-win32.pyd +0 -0
  62. yearn_treasury/rules/ignore/swaps/synthetix.py +10 -0
  63. yearn_treasury/rules/ignore/swaps/uniswap.py +293 -0
  64. yearn_treasury/rules/ignore/swaps/unwrapper.cp310-win32.pyd +0 -0
  65. yearn_treasury/rules/ignore/swaps/unwrapper.py +17 -0
  66. yearn_treasury/rules/ignore/swaps/vaults.cp310-win32.pyd +0 -0
  67. yearn_treasury/rules/ignore/swaps/vaults.py +263 -0
  68. yearn_treasury/rules/ignore/swaps/woofy.cp310-win32.pyd +0 -0
  69. yearn_treasury/rules/ignore/swaps/woofy.py +79 -0
  70. yearn_treasury/rules/ignore/swaps/yfi.cp310-win32.pyd +0 -0
  71. yearn_treasury/rules/ignore/swaps/yfi.py +110 -0
  72. yearn_treasury/rules/ignore/swaps/yla.cp310-win32.pyd +0 -0
  73. yearn_treasury/rules/ignore/swaps/yla.py +27 -0
  74. yearn_treasury/rules/ignore/unit.cp310-win32.pyd +0 -0
  75. yearn_treasury/rules/ignore/unit.py +39 -0
  76. yearn_treasury/rules/ignore/weth.cp310-win32.pyd +0 -0
  77. yearn_treasury/rules/ignore/weth.py +47 -0
  78. yearn_treasury/rules/ignore/ygov.cp310-win32.pyd +0 -0
  79. yearn_treasury/rules/ignore/ygov.py +15 -0
  80. yearn_treasury/rules/other_expense/__init__.cp310-win32.pyd +0 -0
  81. yearn_treasury/rules/other_expense/__init__.py +7 -0
  82. yearn_treasury/rules/other_expense/boost.cp310-win32.pyd +0 -0
  83. yearn_treasury/rules/other_expense/boost.py +49 -0
  84. yearn_treasury/rules/other_expense/bugs.cp310-win32.pyd +0 -0
  85. yearn_treasury/rules/other_expense/bugs.py +80 -0
  86. yearn_treasury/rules/other_expense/donations.cp310-win32.pyd +0 -0
  87. yearn_treasury/rules/other_expense/donations.py +42 -0
  88. yearn_treasury/rules/other_expense/dyfi.cp310-win32.pyd +0 -0
  89. yearn_treasury/rules/other_expense/dyfi.py +28 -0
  90. yearn_treasury/rules/other_expense/events.cp310-win32.pyd +0 -0
  91. yearn_treasury/rules/other_expense/events.py +20 -0
  92. yearn_treasury/rules/other_expense/match_on_hash.yaml +43 -0
  93. yearn_treasury/rules/other_expense/match_on_to_address.yaml +8 -0
  94. yearn_treasury/rules/other_expense/misc.cp310-win32.pyd +0 -0
  95. yearn_treasury/rules/other_expense/misc.py +48 -0
  96. yearn_treasury/rules/other_expense/revshare.cp310-win32.pyd +0 -0
  97. yearn_treasury/rules/other_expense/revshare.py +19 -0
  98. yearn_treasury/rules/other_income/__init__.cp310-win32.pyd +0 -0
  99. yearn_treasury/rules/other_income/__init__.py +2 -0
  100. yearn_treasury/rules/other_income/airdrops.cp310-win32.pyd +0 -0
  101. yearn_treasury/rules/other_income/airdrops.py +29 -0
  102. yearn_treasury/rules/other_income/match_on_hash.yaml +21 -0
  103. yearn_treasury/rules/other_income/misc.cp310-win32.pyd +0 -0
  104. yearn_treasury/rules/other_income/misc.py +78 -0
  105. yearn_treasury/rules/revenue/__init__.py +6 -0
  106. yearn_treasury/rules/revenue/bribes.cp310-win32.pyd +0 -0
  107. yearn_treasury/rules/revenue/bribes.py +25 -0
  108. yearn_treasury/rules/revenue/farming.cp310-win32.pyd +0 -0
  109. yearn_treasury/rules/revenue/farming.py +55 -0
  110. yearn_treasury/rules/revenue/keepcoins.cp310-win32.pyd +0 -0
  111. yearn_treasury/rules/revenue/keepcoins.py +61 -0
  112. yearn_treasury/rules/revenue/match_on_hash.yaml +4 -0
  113. yearn_treasury/rules/revenue/seasolver.cp310-win32.pyd +0 -0
  114. yearn_treasury/rules/revenue/seasolver.py +23 -0
  115. yearn_treasury/rules/revenue/vaults.py +171 -0
  116. yearn_treasury/rules/revenue/yteams.cp310-win32.pyd +0 -0
  117. yearn_treasury/rules/revenue/yteams.py +16 -0
  118. yearn_treasury/shitcoins.py +143 -0
  119. yearn_treasury/vaults.cp310-win32.pyd +0 -0
  120. yearn_treasury/vaults.py +49 -0
  121. yearn_treasury/wallets.yaml +54 -0
  122. yearn_treasury/yteams.py +207 -0
  123. yearn_treasury-0.1.7.dist-info/METADATA +85 -0
  124. yearn_treasury-0.1.7.dist-info/RECORD +128 -0
  125. yearn_treasury-0.1.7.dist-info/WHEEL +5 -0
  126. yearn_treasury-0.1.7.dist-info/entry_points.txt +2 -0
  127. yearn_treasury-0.1.7.dist-info/top_level.txt +2 -0
  128. yearn_treasury__mypyc.cp310-win32.pyd +0 -0
@@ -0,0 +1,19 @@
1
+ import warnings
2
+
3
+ from yearn_treasury import budget
4
+ from yearn_treasury._db import prepare_db
5
+ from yearn_treasury._logging import setup_eth_portfolio_logging
6
+
7
+ prepare_db()
8
+ setup_eth_portfolio_logging()
9
+
10
+
11
+ warnings.filterwarnings(
12
+ "ignore",
13
+ message=".Event log does not contain enough topics for the given ABI.",
14
+ category=UserWarning,
15
+ module="brownie.network.event",
16
+ )
17
+
18
+
19
+ __all__ = ["budget"]
Binary file
yearn_treasury/_db.py ADDED
@@ -0,0 +1,50 @@
1
+ """
2
+ Database labeling utility for Yearn Treasury.
3
+
4
+ This module provides a helper function to set up address nicknames
5
+ in the database, mapping key Yearn Treasury addresses to human-readable
6
+ labels. It is used during database preparation to ensure that wallet
7
+ addresses are clearly labeled in analytics and reporting.
8
+
9
+ When Yearn Treasury is imported, this module maps important addresses
10
+ to descriptive nicknames within the DAO Treasury database entity system
11
+ for improved data clarity and prettification of reports.
12
+ """
13
+
14
+ import time
15
+
16
+ import dao_treasury._docker
17
+ from dao_treasury.db import Address, init_db
18
+ from y import Network
19
+ from y.constants import CHAINID
20
+
21
+ from yearn_treasury import constants
22
+
23
+
24
+ def prepare_db() -> None:
25
+ """
26
+ Set up address nicknames in the Yearn Treasury database.
27
+
28
+ Maps key Yearn Treasury addresses to human-readable labels for improved
29
+ clarity in analytics and reporting. This function is typically called
30
+ during database preparation to ensure wallet addresses are labeled
31
+ within the DAO Treasury database entity system.
32
+ """
33
+ # We need to start the postgres container earlier than dao-treasury does
34
+ dao_treasury._docker.up("postgres")
35
+
36
+ time.sleep(5)
37
+
38
+ init_db()
39
+
40
+ chad = {Network.Mainnet: "y", Network.Fantom: "f"}[CHAINID] # type: ignore [index]
41
+
42
+ labels = {
43
+ constants.TREASURY_MULTISIG: "Yearn Treasury",
44
+ constants.YCHAD_MULTISIG: f"Yearn {chad}Chad Multisig",
45
+ # constants.STRATEGIST_MULTISIG: "Yearn Strategist Multisig",
46
+ # This wallet is an EOA that has been used to assist in bridging tokens across chains.
47
+ "0x5FcdC32DfC361a32e9d5AB9A384b890C62D0b8AC": "Bridge Assistooor EOA",
48
+ }
49
+
50
+ Address.set_nicknames(labels)
Binary file
yearn_treasury/_ens.py ADDED
@@ -0,0 +1,30 @@
1
+ """
2
+ ENS resolver and event topic utilities for Yearn Treasury.
3
+
4
+ This module defines the ENS resolver contract and event topic set
5
+ used for dynamic vault discovery and event processing. It supports
6
+ vault mapping and analytics by enabling on-chain lookups and event
7
+ filtering for Yearn vaults.
8
+
9
+ Key Responsibilities:
10
+ - Provide the ENS resolver contract for vault registry lookups.
11
+ - Construct event topic sets for AddressChanged events.
12
+ - Used by vault discovery, analytics, and reporting modules.
13
+ """
14
+
15
+ from typing import Final
16
+
17
+ from brownie import web3
18
+ from web3._utils.abi import filter_by_name
19
+ from web3._utils.events import construct_event_topic_set
20
+ from y import Contract
21
+
22
+ resolver: Final[Contract] = Contract("0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41")
23
+
24
+ topics: Final = construct_event_topic_set(
25
+ filter_by_name("AddressChanged", resolver.abi)[0], # type: ignore [arg-type]
26
+ web3.codec,
27
+ {"node": web3.ens.namehash("v2.registry.ychad.eth")}, # type: ignore [union-attr]
28
+ )
29
+
30
+ __all__ = ["resolver", "topics"]
Binary file
@@ -0,0 +1,41 @@
1
+ """
2
+ Error log suppression utilities for the Yearn Treasury exporter.
3
+
4
+ This module suppresses noisy or irrelevant eth-portfolio error logs for specific
5
+ token addresses that are known to be deprecated or otherwise unpricable.
6
+
7
+ To suppress logs for additional tokens, add their addresses to the
8
+ `suppress_logs_for[Network.<chain>]` mapping. The rest will be done
9
+ automatically on package import.
10
+ """
11
+
12
+ from typing import Final
13
+
14
+ from cchecksum import to_checksum_address
15
+ from eth_portfolio._utils import SUPPRESS_ERROR_LOGS
16
+ from eth_typing import HexAddress
17
+ from y import Network
18
+
19
+ from yearn_treasury.constants import CHAINID
20
+
21
+ suppress_logs_for: Final[dict[Network, list[HexAddress]]] = {
22
+ Network.Mainnet: [
23
+ "0xBF7AA989192b020a8d3e1C65a558e123834325cA", # unpriceable yvWBTC - This vault had a bug and does not have a pricePerShare
24
+ "0x5aFE3855358E112B5647B952709E6165e1c1eEEe", # SAFE - This was not tradeable at the time of the first airdrops
25
+ "0x718AbE90777F5B778B52D553a5aBaa148DD0dc5D", # yvCurve-alETH - The underlying curve pool had an issue and is unpriceable
26
+ "0x3819f64f282bf135d62168C1e513280dAF905e06", # HDRN
27
+ "0x5fAa989Af96Af85384b8a938c2EdE4A7378D9875", # GAL
28
+ ],
29
+ }
30
+
31
+
32
+ def setup_eth_portfolio_logging() -> None:
33
+ """
34
+ Suppress eth-portfolio error logs for specific tokens on the current chain.
35
+
36
+ Appends token addresses from the suppress_logs_for mapping (for the current
37
+ CHAINID) to the SUPPRESS_ERROR_LOGS list, preventing error logs for these
38
+ tokens from being emitted during analytics and reporting.
39
+ """
40
+ for token in suppress_logs_for.get(CHAINID, []): # type: ignore [call-overload]
41
+ SUPPRESS_ERROR_LOGS.append(to_checksum_address(token))
@@ -0,0 +1,39 @@
1
+ 1:
2
+ Yearn Treasury V1:
3
+ - "0xb99a40fcE04cb740EB79fC04976CA15aF69AaaaE"
4
+ Yearn Strategist Multisig: # refactor this to do from python from constants file
5
+ - "0x16388463d60FFE0661Cf7F1f31a7D658aC790ff7"
6
+ yMechs Multisig:
7
+ - "0x2C01B4AD51a67E2d8F02208F54dF9aC4c0B778B6"
8
+ ySwap Multisig:
9
+ - "0x7d2aB9CA511EBD6F03971Fb417d3492aA82513f0"
10
+ Yearn KP3R Wallet:
11
+ - "0x8d12a197cb00d4747a1fe03395095ce2a5cc6819"
12
+ Token Dumper Multisig:
13
+ - "0xC001d00d425Fa92C4F840baA8f1e0c27c4297a0B"
14
+ Cowswap Multisig:
15
+ - "0xA03be496e67Ec29bC62F01a428683D7F9c204930"
16
+ dYFI Redemption Contract:
17
+ - "0x7dC3A74F0684fc026f9163C6D5c3C99fda2cf60a"
18
+ Yearn veFarming Multisig:
19
+ - "0x4fc1b14cD213e7B6212145Ba4f180C3d53d1A11e"
20
+ CRV Buyer Contract (DAI):
21
+ - "0x0000000000007F150Bd6f54c40A34d7C3d5e9f56"
22
+ CRV Buyer Contract (USDT):
23
+ - "0x0000000000005117Dd3A72E64a705198753FDD54"
24
+ YFI Buyer Contract:
25
+ - "0x0000000000884A0E1fB44F9E24Fa3BDB19514fAE"
26
+ - "0x0000000000051666BBfBB42925C3eE5d50cF6B10"
27
+ Multichain Fantom Bridge:
28
+ - "0xC564EE9f21Ed8A2d8E7e76c085740d5e4c5FaFbE"
29
+ yLockers Multisig:
30
+ - "0x4444AAAACDBa5580282365e25b16309Bd770ce4a"
31
+ yRoboTreasury Treasury Contract:
32
+ - "0xEf77cc176c748d291EfB6CdC982c5744fC7211c8"
33
+ yRoboTreasury Stables Reserve:
34
+ - "0x278374fFb10B7D16E7633444c13e6E565EA57c28"
35
+ yearn.fi Dutch Auctions:
36
+ - "0x861fE45742f70054917B65bE18904662bD0dBd30"
37
+ 250:
38
+ Yearn Strategist Multisig:
39
+ - "0x72a34AbafAB09b15E7191822A679f28E067C4a16"
@@ -0,0 +1,6 @@
1
+ from yearn_treasury.budget._request import BudgetRequest
2
+ from yearn_treasury.budget._requests import approved_requests, budget_requests, rejected_requests
3
+
4
+ # TODO test
5
+
6
+ __all__ = ["BudgetRequest", "budget_requests", "approved_requests", "rejected_requests"]
@@ -0,0 +1,43 @@
1
+ """
2
+ Budget request data model for Yearn Treasury.
3
+
4
+ This module defines the BudgetRequest dataclass, which models a single
5
+ budget request and its state. It provides methods for checking approval,
6
+ rejection, streaming, vesting, and payment status.
7
+ """
8
+
9
+ from dataclasses import dataclass
10
+ from logging import getLogger
11
+ from typing import Final, final
12
+
13
+ logger: Final = getLogger(__name__)
14
+
15
+
16
+ @final
17
+ @dataclass(frozen=True)
18
+ class BudgetRequest:
19
+ id: int
20
+ number: int
21
+ title: str
22
+ state: str
23
+ url: str
24
+ created_at: str
25
+ updated_at: str
26
+ closed_at: str | None
27
+ body: str | None
28
+ labels: set[str]
29
+
30
+ def is_approved(self) -> bool:
31
+ return "approved" in self.labels
32
+
33
+ def is_rejected(self) -> bool:
34
+ return "rejected" in self.labels
35
+
36
+ def is_stream(self) -> bool:
37
+ return "stream" in self.labels
38
+
39
+ def is_vesting(self) -> bool:
40
+ return "vesting" in self.labels
41
+
42
+ def is_paid(self) -> bool:
43
+ return "paid" in self.labels
@@ -0,0 +1,96 @@
1
+ """
2
+ Budget request ingestion and filtering for Yearn Treasury.
3
+
4
+ This module fetches budget requests from GitHub, parses them into
5
+ BudgetRequest objects, and provides lists of approved and rejected
6
+ requests.
7
+ """
8
+
9
+ import os
10
+ import time
11
+ from typing import Any, Final
12
+
13
+ import requests
14
+
15
+ from yearn_treasury.budget._request import BudgetRequest
16
+
17
+ API_URL: Final = "https://api.github.com/repos/yearn/budget/issues"
18
+ """URL to fetch issues from the repo."""
19
+
20
+ # Optionally use a GitHub personal access token for higher API rate limits.
21
+ # TODO move this to envs file and document
22
+ _TOKEN: Final = os.environ.get("GITHUB_TOKEN")
23
+ _HEADERS: Final = {"Authorization": f"token {_TOKEN}"} if _TOKEN else {}
24
+
25
+
26
+ def fetch_brs() -> list[BudgetRequest]:
27
+ # Use parameters to fetch issues in all states, up to 100 per page.
28
+ current_page = 1
29
+ params = {"state": "all", "per_page": 100, "page": current_page}
30
+
31
+ brs = []
32
+ retries = 0
33
+ while True:
34
+ response = _make_get_request(params=params)
35
+
36
+ data: list[dict] = response.json() # type: ignore [type-arg]
37
+ if not data: # If the current page is empty, we are done.
38
+ break
39
+
40
+ for item in data:
41
+ # GitHub's issues API returns pull requests as well.
42
+ if "pull_request" in item:
43
+ continue
44
+
45
+ # TODO labels table in db (also dataclass) with the descriptions included
46
+ # Extract the label names (tags) from the "labels" key.
47
+ label_objs: list[dict] = item.get("labels", []) # type: ignore [type-arg]
48
+ labels = {label.get("name") for label in label_objs}
49
+
50
+ if "budget request" not in labels:
51
+ continue
52
+
53
+ br = BudgetRequest(
54
+ id=item.get("id"), # type: ignore [arg-type]
55
+ number=item.get("number"), # type: ignore [arg-type]
56
+ title=item.get("title"), # type: ignore [arg-type]
57
+ state=item.get("state"), # type: ignore [arg-type]
58
+ url=item.get("html_url"), # type: ignore [arg-type]
59
+ created_at=item.get("created_at"), # type: ignore [arg-type]
60
+ updated_at=item.get("updated_at"), # type: ignore [arg-type]
61
+ closed_at=item.get("closed_at"), # type: ignore [arg-type]
62
+ body=item.get("body"), # type: ignore [arg-type]
63
+ labels=labels, # type: ignore [arg-type]
64
+ )
65
+ brs.append(br)
66
+
67
+ # Move on to the next page.
68
+ current_page += 1
69
+ params["page"] = current_page
70
+
71
+ return brs
72
+
73
+
74
+ def _make_get_request(params: dict[str, Any]) -> Any:
75
+ retries = 0
76
+ while True:
77
+ try:
78
+ response = requests.get(API_URL, headers=_HEADERS, params=params)
79
+ response.raise_for_status()
80
+ return response
81
+ except requests.HTTPError as e:
82
+ if "rate limit exceeded" in str(e):
83
+ print("Github API rate limited...")
84
+ elif retries < 5:
85
+ print(e)
86
+ else:
87
+ raise ConnectionError(
88
+ f"Failed to fetch issues: {response.status_code} {response.text}"
89
+ ) from e
90
+ retries += 1
91
+ time.sleep(5 * (retries + 1))
92
+
93
+
94
+ budget_requests: Final = fetch_brs()
95
+ approved_requests: Final = [r for r in budget_requests if r.is_approved()]
96
+ rejected_requests: Final = [r for r in budget_requests if r.is_rejected()]
@@ -0,0 +1,91 @@
1
+ from pathlib import Path
2
+ from typing import Final
3
+
4
+ import y.constants
5
+ from eth_typing import BlockNumber
6
+ from y import Network, convert
7
+
8
+ CHAINID: Final = y.constants.CHAINID
9
+
10
+ EEE_ADDRESS: Final = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
11
+ ZERO_ADDRESS: Final = "0x0000000000000000000000000000000000000000"
12
+
13
+ _YEARN_TREASURY_ROOT_DIR: Final = Path(__file__).parent
14
+
15
+ TREASURY_MULTISIGS: Final = {
16
+ Network.Mainnet: "0x93A62dA5a14C80f265DAbC077fCEE437B1a0Efde",
17
+ Network.Fantom: "0x89716Ad7EDC3be3B35695789C475F3e7A3Deb12a",
18
+ Network.Arbitrum: "0x1deb47dcc9a35ad454bf7f0fcdb03c09792c08c1",
19
+ Network.Optimism: "0x84654e35E504452769757AAe5a8C7C6599cBf954",
20
+ Network.Base: "0x02ff746D8cb62709aEEc611CeC9B17d7dD1D3480",
21
+ }
22
+
23
+ YCHAD_MULTISIGS: Final = {
24
+ Network.Mainnet: "0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52",
25
+ Network.Fantom: "0xC0E2830724C946a6748dDFE09753613cd38f6767",
26
+ Network.Gnosis: "0x22eAe41c7Da367b9a15e942EB6227DF849Bb498C",
27
+ Network.Arbitrum: "0xb6bc033d34733329971b938fef32fad7e98e56ad",
28
+ Network.Optimism: "0xF5d9D6133b698cE29567a90Ab35CfB874204B3A7",
29
+ Network.Base: "0xbfAABa9F56A39B814281D68d2Ad949e88D06b02E",
30
+ }
31
+
32
+ YSWAP_MULTISIGS: Final = {
33
+ Network.Mainnet: "0x7d2aB9CA511EBD6F03971Fb417d3492aA82513f0",
34
+ }
35
+
36
+
37
+ if CHAINID not in TREASURY_MULTISIGS or CHAINID not in YCHAD_MULTISIGS:
38
+ raise RuntimeError(f"{Network(CHAINID)} is not supported")
39
+
40
+
41
+ TREASURY_MULTISIG: Final = convert.to_address(TREASURY_MULTISIGS[CHAINID]) # type: ignore [index]
42
+
43
+ YCHAD_MULTISIG: Final = convert.to_address(YCHAD_MULTISIGS[CHAINID]) # type: ignore [index]
44
+
45
+ __yswap_multisig = YSWAP_MULTISIGS.get(CHAINID) # type: ignore [call-overload]
46
+ YSWAP_MULTISIG: Final = convert.to_address(__yswap_multisig) if __yswap_multisig else None
47
+
48
+ _TREASURY_WALLETS: Final = {
49
+ Network.Mainnet: {
50
+ TREASURY_MULTISIG,
51
+ YCHAD_MULTISIG,
52
+ "0xb99a40fcE04cb740EB79fC04976CA15aF69AaaaE", # Yearn Treasury V1
53
+ "0x5f0845101857d2A91627478e302357860b1598a1", # Yearn KP3R Wallet
54
+ YSWAP_MULTISIG,
55
+ "0x2C01B4AD51a67E2d8F02208F54dF9aC4c0B778B6", # yMechs Multisig
56
+ "0xE376e8e8E3B0793CD61C6F1283bA18548b726C2e", # Fee Reimbursement Stash
57
+ "0xC001d00d425Fa92C4F840baA8f1e0c27c4297a0B", # New token dumping wallet
58
+ "0x4fc1b14cD213e7B6212145Ba4f180C3d53d1A11e", # veFarming wallet
59
+ },
60
+ }
61
+
62
+ TREASURY_WALLETS: Final = {
63
+ convert.to_address(address) for address in _TREASURY_WALLETS.get(CHAINID, set()) # type: ignore [call-overload]
64
+ }
65
+
66
+
67
+ YFI: Final = {
68
+ Network.Mainnet: "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
69
+ Network.Fantom: "0x29b0Da86e484E1C0029B56e817912d778aC0EC69",
70
+ Network.Arbitrum: "0x82e3A8F066a6989666b031d916c43672085b1582",
71
+ Network.Polygon: "0xDA537104D6A5edd53c6fBba9A898708E465260b6",
72
+ }.get(
73
+ CHAINID, None
74
+ ) # type: ignore [call-overload]
75
+
76
+
77
+ class Args:
78
+ wallets: Final[Path] = _YEARN_TREASURY_ROOT_DIR / "wallets.yaml"
79
+ # TODO: update dashboard def to use this label (we will need to migrate the provisioning files to yearn-treasury but we need to do this anyway for yearn-specific additions)
80
+ label: Final[str] = "Treasury" # "Yearn"
81
+ first_tx_block: Final = BlockNumber({Network.Mainnet: 10_502_337}.get(CHAINID, 0)) # type: ignore [call-overload]
82
+ export_start_block: Final = first_tx_block
83
+
84
+ sort_rules: Final[Path] = _YEARN_TREASURY_ROOT_DIR / "rules"
85
+ """The path where the sort rules for dao-treasury are defined."""
86
+
87
+ nicknames: Final[Path] = _YEARN_TREASURY_ROOT_DIR / "address_labels.yaml"
88
+ """The path where yearn-treasury's address nicknames are defined."""
89
+
90
+ custom_bucket: Final[list[str]] = [f"{YFI}:YFI"]
91
+ """Custom bucket mapping for token addresses, tells DAO Treasury to categorize YFI and YFI wrappers as special bucket 'YFI'."""
yearn_treasury/main.py ADDED
@@ -0,0 +1,175 @@
1
+ """
2
+ Command-line interface for the Yearn Treasury exporter.
3
+
4
+ This module provides the `yearn-treasury` CLI, which connects to a Brownie network
5
+ (based on the `--network` option or the `BROWNIE_NETWORK_ID` environment variable),
6
+ periodically snapshots treasury metrics, and pushes them to Victoria Metrics.
7
+ It also launches Yearn Treasury's Grafana dashboard and an optional renderer for visual reports.
8
+
9
+ Example:
10
+ Run export every 12 hours on mainnet:
11
+
12
+ .. code-block:: bash
13
+
14
+ yearn-treasury run --network mainnet --interval 12h
15
+
16
+ CLI Options:
17
+ --network Brownie network identifier (default: mainnet)
18
+ --interval Time interval between datapoints (default: 12h)
19
+ --concurrency Max number of historical blocks to export concurrently (default: 30)
20
+ --daemon Run as a background daemon (currently unsupported)
21
+ --grafana-port Port for the Grafana dashboard (default: 3004)
22
+ --victoria-port Port for the Victoria metrics endpoint (default: 8430)
23
+ --start-renderer Start the Grafana renderer container for dashboard image export
24
+ --renderer-port Port for the renderer service (default: 8080)
25
+ """
26
+
27
+ import asyncio
28
+ import os
29
+ from argparse import ArgumentParser
30
+ from typing import Final, final
31
+
32
+ from yearn_treasury import yteams
33
+
34
+ parser = ArgumentParser(description="Treasury CLI")
35
+ subparsers = parser.add_subparsers(dest="command", required=True)
36
+
37
+ run_parser = subparsers.add_parser("run", help="Run the treasury export tool")
38
+ run_parser.add_argument(
39
+ "--network",
40
+ type=str,
41
+ help="The brownie network identifier for the RPC to use. Overrides BROWNIE_NETWORK_ID env var if unset.",
42
+ default="mainnet",
43
+ )
44
+ run_parser.add_argument(
45
+ "--interval",
46
+ type=str,
47
+ help="The time interval between datapoints. Default: 12h",
48
+ default="12h",
49
+ )
50
+ run_parser.add_argument(
51
+ "--concurrency",
52
+ type=int,
53
+ help="The max number of historical blocks to export concurrently. default: 30",
54
+ default=30,
55
+ )
56
+ run_parser.add_argument(
57
+ "--daemon",
58
+ action="store_true",
59
+ help="Run as a background daemon (currently unsupported).",
60
+ )
61
+ run_parser.add_argument(
62
+ "--grafana-port",
63
+ type=int,
64
+ help="Port for the Grafana dashboard where you can view your data. Default: 3004",
65
+ default=3004,
66
+ )
67
+ run_parser.add_argument(
68
+ "--victoria-port",
69
+ type=int,
70
+ help="Port for the Victoria metrics reporting endpoint. Default: 8430",
71
+ default=8430,
72
+ )
73
+ run_parser.add_argument(
74
+ "--start-renderer",
75
+ action="store_true",
76
+ help="If set, the Grafana renderer container will be started for dashboard image export. By default, only the grafana container is started.",
77
+ )
78
+ run_parser.add_argument(
79
+ "--renderer-port",
80
+ type=int,
81
+ help="Port for the service that renders visual reports. Default: 8080",
82
+ default=8080,
83
+ )
84
+ args = run_parser.parse_args()
85
+
86
+ # Set BROWNIE_NETWORK_ID from --network flag if not already set
87
+ os.environ.setdefault("BROWNIE_NETWORK_ID", args.network)
88
+ BROWNIE_NETWORK = os.environ["BROWNIE_NETWORK_ID"]
89
+
90
+
91
+ # TODO: run forever arg
92
+ def main() -> None:
93
+ """
94
+ Connect to the configured Brownie network, clean up the database, and start the export loop.
95
+
96
+ This function is registered as a console script entrypoint under
97
+ ``yearn-treasury``. It performs the following steps:
98
+ 1. Reads the ``BROWNIE_NETWORK_ID`` environment variable (populated from
99
+ the ``--network`` option or existing env var).
100
+ 2. Connects to the specified Brownie network.
101
+ 3. Merges local SHITCOINS into eth_portfolio's config to skip tokens we don't care about.
102
+ 4. Drops any shitcoin transactions that might be in the database.
103
+ 5. Constructs an immutable Args subclass to pass CLI parameters to
104
+ :func:`dao_treasury.main.export`.
105
+ 6. Exports ports for external services into environment variables.
106
+ 7. Runs both the DAO Treasury export and Yearn team revenue/expenses calculation concurrently under asyncio.
107
+ """
108
+ import dao_treasury.db
109
+ import eth_portfolio
110
+
111
+ from . import constants, rules, shitcoins
112
+
113
+ # Merge local SHITCOINS into eth_portfolio's config to skip tokens we don't care about
114
+ eth_portfolio.SHITCOINS[constants.CHAINID].update(shitcoins.SHITCOINS) # type: ignore [index]
115
+
116
+ # Drop any shitcoin txs that might be in the db
117
+ dao_treasury.db._drop_shitcoin_txs()
118
+
119
+ @final
120
+ class Args(constants.Args):
121
+ """
122
+ Immutable container of CLI arguments for export and dashboard/renderer configuration.
123
+
124
+ Inherits from DAO Treasury's :class:`constants.Args` and is used to pass runtime
125
+ parameters to the DAO Treasury export and related services.
126
+ """
127
+
128
+ network: Final[str] = args.network
129
+ """Brownie network to connect to."""
130
+
131
+ interval: Final[str] = args.interval
132
+ """Time interval between snapshots."""
133
+
134
+ concurrency: Final[int] = args.concurrency
135
+ """The max number of historical blocks to export concurrently."""
136
+
137
+ grafana_port: Final[int] = args.grafana_port
138
+ """Grafana port."""
139
+
140
+ victoria_port: Final[int] = args.victoria_port
141
+ """Victoria metrics port."""
142
+
143
+ start_renderer: Final[bool] = args.start_renderer
144
+ """Boolean indicating whether to start the renderer container."""
145
+
146
+ renderer_port: Final[int] = args.renderer_port
147
+ """Report renderer port."""
148
+
149
+ daemon: Final[bool] = args.daemon
150
+ """Whether to run in daemon mode."""
151
+
152
+ import dao_treasury.main
153
+
154
+ # Export ports for external services (must come after import)
155
+ os.environ["DAO_TREASURY_GRAFANA_PORT"] = str(Args.grafana_port)
156
+ os.environ["DAO_TREASURY_RENDERER_PORT"] = str(Args.renderer_port)
157
+ os.environ["VICTORIA_PORT"] = str(Args.victoria_port)
158
+
159
+ async def yearn_wrapper():
160
+ """
161
+ Run the DAO Treasury export and Yearn team revenue/expenses calculation concurrently.
162
+
163
+ This coroutine gathers:
164
+ - The main DAO Treasury export process (dao_treasury.main.export)
165
+ - The Yearn teams' revenue and expenses calculation (yteams.calculate_teams_revenue_expenses)
166
+ """
167
+ return await asyncio.gather(
168
+ dao_treasury.main.export(Args),
169
+ yteams.calculate_teams_revenue_expenses(),
170
+ )
171
+
172
+ # Start the balance export routine
173
+ asyncio.get_event_loop().run_until_complete(yearn_wrapper())
174
+
175
+ rules # I just put this here so the import isn't flagged as unused
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,20 @@
1
+ import os
2
+
3
+ __ALRU_ENV_NAME = "ASYNC_LRU_ALLOW_SYNC"
4
+ __ALRU_ENV_VAL = os.environ.get(__ALRU_ENV_NAME)
5
+ os.environ[__ALRU_ENV_NAME] = "1"
6
+
7
+ from yearn_treasury.rules.cost_of_revenue import *
8
+ from yearn_treasury.rules.expense import *
9
+ from yearn_treasury.rules.ignore import *
10
+ from yearn_treasury.rules.other_expense import *
11
+ from yearn_treasury.rules.other_income import *
12
+ from yearn_treasury.rules.revenue import *
13
+
14
+ if __ALRU_ENV_VAL is None:
15
+ os.environ.pop(__ALRU_ENV_NAME)
16
+ else:
17
+ os.environ[__ALRU_ENV_NAME] = __ALRU_ENV_VAL
18
+
19
+ del __ALRU_ENV_NAME
20
+ del __ALRU_ENV_VAL
@@ -0,0 +1,15 @@
1
+ from typing import Final
2
+
3
+ from y import Network
4
+ from y.constants import CHAINID
5
+
6
+ EEE_ADDRESS: Final = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"
7
+ ZERO_ADDRESS: Final = "0x0000000000000000000000000000000000000000"
8
+
9
+
10
+ YFI: Final = {
11
+ Network.Mainnet: "0x0bc529c00C6401aEF6D220BE8C6Ea1667F6Ad93e",
12
+ Network.Fantom: "0x29b0Da86e484E1C0029B56e817912d778aC0EC69",
13
+ Network.Arbitrum: "0x82e3A8F066a6989666b031d916c43672085b1582",
14
+ Network.Polygon: "0xDA537104D6A5edd53c6fBba9A898708E465260b6",
15
+ }[CHAINID]
@@ -0,0 +1 @@
1
+ from yearn_treasury.rules.cost_of_revenue.gas import *