dao-treasury 0.0.42__cp311-cp311-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.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 (51) hide show
  1. bf2b4fe1f86ad2ea158b__mypyc.cpython-311-i386-linux-gnu.so +0 -0
  2. dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml +60 -0
  3. dao_treasury/.grafana/provisioning/dashboards/streams/LlamaPay.json +225 -0
  4. dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json +107 -0
  5. dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json +387 -0
  6. dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow (Including Unsorted).json +835 -0
  7. dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json +615 -0
  8. dao_treasury/.grafana/provisioning/dashboards/treasury/Operating Cashflow.json +492 -0
  9. dao_treasury/.grafana/provisioning/dashboards/treasury/Treasury.json +2018 -0
  10. dao_treasury/.grafana/provisioning/datasources/datasources.yaml +17 -0
  11. dao_treasury/ENVIRONMENT_VARIABLES.py +20 -0
  12. dao_treasury/__init__.py +62 -0
  13. dao_treasury/_docker.cpython-311-i386-linux-gnu.so +0 -0
  14. dao_treasury/_docker.py +190 -0
  15. dao_treasury/_nicknames.cpython-311-i386-linux-gnu.so +0 -0
  16. dao_treasury/_nicknames.py +32 -0
  17. dao_treasury/_wallet.cpython-311-i386-linux-gnu.so +0 -0
  18. dao_treasury/_wallet.py +250 -0
  19. dao_treasury/constants.cpython-311-i386-linux-gnu.so +0 -0
  20. dao_treasury/constants.py +34 -0
  21. dao_treasury/db.py +1408 -0
  22. dao_treasury/docker-compose.yaml +41 -0
  23. dao_treasury/main.py +247 -0
  24. dao_treasury/py.typed +0 -0
  25. dao_treasury/sorting/__init__.cpython-311-i386-linux-gnu.so +0 -0
  26. dao_treasury/sorting/__init__.py +295 -0
  27. dao_treasury/sorting/_matchers.cpython-311-i386-linux-gnu.so +0 -0
  28. dao_treasury/sorting/_matchers.py +387 -0
  29. dao_treasury/sorting/_rules.cpython-311-i386-linux-gnu.so +0 -0
  30. dao_treasury/sorting/_rules.py +235 -0
  31. dao_treasury/sorting/factory.cpython-311-i386-linux-gnu.so +0 -0
  32. dao_treasury/sorting/factory.py +299 -0
  33. dao_treasury/sorting/rule.cpython-311-i386-linux-gnu.so +0 -0
  34. dao_treasury/sorting/rule.py +346 -0
  35. dao_treasury/sorting/rules/__init__.cpython-311-i386-linux-gnu.so +0 -0
  36. dao_treasury/sorting/rules/__init__.py +1 -0
  37. dao_treasury/sorting/rules/ignore/__init__.cpython-311-i386-linux-gnu.so +0 -0
  38. dao_treasury/sorting/rules/ignore/__init__.py +1 -0
  39. dao_treasury/sorting/rules/ignore/llamapay.cpython-311-i386-linux-gnu.so +0 -0
  40. dao_treasury/sorting/rules/ignore/llamapay.py +20 -0
  41. dao_treasury/streams/__init__.cpython-311-i386-linux-gnu.so +0 -0
  42. dao_treasury/streams/__init__.py +0 -0
  43. dao_treasury/streams/llamapay.cpython-311-i386-linux-gnu.so +0 -0
  44. dao_treasury/streams/llamapay.py +388 -0
  45. dao_treasury/treasury.py +191 -0
  46. dao_treasury/types.cpython-311-i386-linux-gnu.so +0 -0
  47. dao_treasury/types.py +133 -0
  48. dao_treasury-0.0.42.dist-info/METADATA +119 -0
  49. dao_treasury-0.0.42.dist-info/RECORD +51 -0
  50. dao_treasury-0.0.42.dist-info/WHEEL +7 -0
  51. dao_treasury-0.0.42.dist-info/top_level.txt +2 -0
@@ -0,0 +1,17 @@
1
+ apiVersion: 1
2
+
3
+ datasources:
4
+ - name: SQLite
5
+ type: frser-sqlite-datasource
6
+ isDefault: true
7
+ editable: false
8
+ jsonData:
9
+ path: /app/dao-treasury-data/dao-treasury.sqlite
10
+ secureJsonData: {}
11
+
12
+ - name: 'PROMETHEUS'
13
+ type: 'prometheus'
14
+ access: 'proxy'
15
+ url: 'http://victoria-metrics:8428'
16
+ version: 1
17
+ editable: false
@@ -0,0 +1,20 @@
1
+ """Environment variable configuration for DAO Treasury.
2
+
3
+ Defines and loads environment variables (with types and defaults) used for
4
+ system configuration, such as SQL debugging. Uses :mod:`typed_envs` for convenience and safety.
5
+
6
+ Key Responsibilities:
7
+ - Define and load environment variables for the system.
8
+ - Provide type-safe access to configuration options.
9
+
10
+ This is the single source of truth for environment-based settings.
11
+ """
12
+
13
+ from typing import Final
14
+
15
+ from typed_envs import EnvVarFactory
16
+
17
+
18
+ _factory = EnvVarFactory("DAO_TREASURY")
19
+
20
+ SQL_DEBUG: Final = _factory.create_env("SQL_DEBUG", bool, default=False, verbose=False)
@@ -0,0 +1,62 @@
1
+ """DAO Treasury package initializer.
2
+
3
+ Exposes the main public API for the library, including the Treasury class,
4
+ wallet management, sorting rules, and database models. Sets up address
5
+ nicknames and enables SQL debugging if configured.
6
+
7
+ Key Responsibilities:
8
+ - Import and expose core classes and functions.
9
+ - Initialize address nicknames in the database.
10
+ - Configure SQL debugging for development.
11
+
12
+ This is the main import point for users and integrations.
13
+ """
14
+
15
+ from dao_treasury import ENVIRONMENT_VARIABLES as ENVS
16
+ from dao_treasury._nicknames import setup_address_nicknames_in_db
17
+ from dao_treasury._wallet import TreasuryWallet
18
+ from dao_treasury.db import TreasuryTx
19
+ from dao_treasury.sorting import (
20
+ CostOfRevenueSortRule,
21
+ ExpenseSortRule,
22
+ IgnoreSortRule,
23
+ OtherExpenseSortRule,
24
+ OtherIncomeSortRule,
25
+ RevenueSortRule,
26
+ SortRuleFactory,
27
+ cost_of_revenue,
28
+ expense,
29
+ ignore,
30
+ other_expense,
31
+ other_income,
32
+ revenue,
33
+ )
34
+ from dao_treasury.treasury import Treasury
35
+
36
+
37
+ setup_address_nicknames_in_db()
38
+
39
+
40
+ if ENVS.SQL_DEBUG:
41
+ import pony.orm
42
+
43
+ pony.orm.sql_debug(True)
44
+
45
+ __all__ = [
46
+ "Treasury",
47
+ "TreasuryWallet",
48
+ "CostOfRevenueSortRule",
49
+ "ExpenseSortRule",
50
+ "IgnoreSortRule",
51
+ "OtherExpenseSortRule",
52
+ "OtherIncomeSortRule",
53
+ "RevenueSortRule",
54
+ "cost_of_revenue",
55
+ "expense",
56
+ "ignore",
57
+ "other_expense",
58
+ "other_income",
59
+ "revenue",
60
+ "TreasuryTx",
61
+ "SortRuleFactory",
62
+ ]
@@ -0,0 +1,190 @@
1
+ """Docker orchestration utilities for DAO Treasury.
2
+
3
+ Provides functions to build, start, and stop Docker Compose services
4
+ required for analytics dashboards (Grafana, renderer). Integrates with
5
+ eth-portfolio's Docker setup and ensures all containers are managed
6
+ consistently for local analytics.
7
+
8
+ Key Responsibilities:
9
+ - Build and manage Grafana and renderer containers.
10
+ - Integrate with eth-portfolio Docker services.
11
+ - Provide decorators/utilities for container lifecycle management.
12
+
13
+ This is the main entry for all Docker-based orchestration.
14
+ """
15
+
16
+ import logging
17
+ from importlib import resources
18
+ import subprocess
19
+ from functools import wraps
20
+ from typing import Any, Callable, Coroutine, Final, Iterable, Tuple, TypeVar, List
21
+
22
+ import eth_portfolio_scripts.docker
23
+ from typing_extensions import ParamSpec
24
+
25
+ logger: Final = logging.getLogger(__name__)
26
+
27
+ compose_file: Final = str(
28
+ resources.files("dao_treasury").joinpath("docker-compose.yaml")
29
+ )
30
+ """The path of dao-treasury's docker-compose.yaml file on your machine"""
31
+
32
+
33
+ def up(*services: str) -> None:
34
+ """Build and start the specified containers defined in the compose file.
35
+
36
+ Args:
37
+ services: service names to bring up.
38
+
39
+ This function first builds the Docker services by invoking
40
+ :func:`build` and then starts the specified services in detached mode using
41
+ Docker Compose. If Docker Compose is not available, it falls back
42
+ to the legacy ``docker-compose`` command.
43
+
44
+ Examples:
45
+ >>> up('grafana')
46
+ starting the grafana container
47
+ >>> up()
48
+ starting all containers (grafana and renderer)
49
+
50
+ See Also:
51
+ :func:`build`
52
+ :func:`down`
53
+ :func:`_exec_command`
54
+ """
55
+ # eth-portfolio containers must be started first so dao-treasury can attach to the eth-portfolio docker network
56
+ eth_portfolio_scripts.docker.up("victoria-metrics")
57
+ build(*services)
58
+ print(f"starting the {', '.join(services) if services else 'grafana'} container(s)")
59
+ _exec_command(["up", "-d", *services])
60
+
61
+
62
+ def down() -> None:
63
+ """Stop and remove Grafana containers.
64
+
65
+ This function brings down the Docker Compose services defined
66
+ in the compose file. Any positional arguments passed are ignored.
67
+
68
+ Examples:
69
+ >>> down()
70
+ # Stops containers
71
+
72
+ See Also:
73
+ :func:`up`
74
+ """
75
+ _exec_command(["down"])
76
+
77
+
78
+ def build(*services: str) -> None:
79
+ """Build Docker images for Grafana containers.
80
+
81
+ This function builds all services defined in the Docker Compose
82
+ configuration file. It is a prerequisite step before starting
83
+ containers with :func:`up`.
84
+
85
+ Examples:
86
+ >>> build()
87
+ building the grafana containers
88
+
89
+ See Also:
90
+ :func:`up`
91
+ :func:`_exec_command`
92
+ """
93
+ print("building the grafana containers")
94
+ _exec_command(["build", *services])
95
+
96
+
97
+ _P = ParamSpec("_P")
98
+ _T = TypeVar("_T")
99
+
100
+
101
+ def ensure_containers(
102
+ fn: Callable[_P, Coroutine[Any, Any, _T]],
103
+ ) -> Callable[_P, Coroutine[Any, Any, _T]]:
104
+ """Decorator to ensure Grafana containers are running before execution.
105
+
106
+ This async decorator starts the Docker Compose services via
107
+ :func:`up` before invoking the wrapped coroutine function. Once
108
+ the wrapped function completes or raises an exception, the containers
109
+ can be torn down by calling :func:`down`, although teardown is
110
+ currently commented out.
111
+
112
+ Args:
113
+ fn: The asynchronous function to wrap.
114
+
115
+ Returns:
116
+ A new coroutine function that wraps the original.
117
+
118
+ Examples:
119
+ >>> @ensure_containers
120
+ ... async def main_task():
121
+ ... # Container-dependent logic here
122
+ ... pass
123
+ >>> import asyncio
124
+ >>> asyncio.run(main_task())
125
+
126
+ See Also:
127
+ :func:`up`
128
+ :func:`down`
129
+ """
130
+
131
+ @wraps(fn)
132
+ async def compose_wrap(*args: _P.args, **kwargs: _P.kwargs) -> _T:
133
+ # register shutdown sequence
134
+ # TODO: argument to leave them up
135
+ # NOTE: do we need both this and the finally?
136
+ # signal.signal(signal.SIGINT, down)
137
+
138
+ # start Grafana containers
139
+ up("grafana")
140
+
141
+ try:
142
+ # attempt to run `fn`
143
+ return await fn(*args, **kwargs)
144
+ finally:
145
+ # stop and remove containers
146
+ # down()
147
+ pass
148
+
149
+ return compose_wrap
150
+
151
+
152
+ def _exec_command(command: List[str], *, compose_options: Tuple[str, ...] = ()) -> None:
153
+ """Execute a Docker Compose command with system checks and fallback.
154
+
155
+ This internal function ensures that Docker and Docker Compose
156
+ are installed by calling :func:`check_system`. It then executes the
157
+ specified command using the ``docker compose`` CLI. If that fails,
158
+ it falls back to the legacy ``docker-compose`` command.
159
+
160
+ Args:
161
+ command: The sequence of command arguments for Docker Compose
162
+ (e.g., ``['up', '-d']`` or ``['down']``).
163
+ compose_options: Additional options to pass before specifying
164
+ the compose file (not commonly used).
165
+
166
+ Raises:
167
+ RuntimeError: If both ``docker compose`` and ``docker-compose``
168
+ invocations fail.
169
+
170
+ Examples:
171
+ >>> _exec_command(['up', '-d'])
172
+ # Executes `docker compose -f docker-compose.yaml up -d`
173
+
174
+ See Also:
175
+ :func:`check_system`
176
+ """
177
+ eth_portfolio_scripts.docker.check_system()
178
+ try:
179
+ subprocess.check_output(
180
+ ["docker", "compose", *compose_options, "-f", compose_file, *command]
181
+ )
182
+ except (subprocess.CalledProcessError, FileNotFoundError) as e:
183
+ try:
184
+ subprocess.check_output(
185
+ ["docker-compose", *compose_options, "-f", compose_file, *command]
186
+ )
187
+ except (subprocess.CalledProcessError, FileNotFoundError) as _e:
188
+ raise RuntimeError(
189
+ f"Error occurred while running {' '.join(command)}: {_e}"
190
+ ) from _e
@@ -0,0 +1,32 @@
1
+ """Address nickname setup utilities.
2
+
3
+ This module provides functions to assign human-readable nicknames to
4
+ important on-chain addresses (e.g., Zero Address, Disperse.app, tokens).
5
+ It is used at package initialization to ensure all analytics and dashboards
6
+ display professional, consistent labels.
7
+
8
+ Key Responsibilities:
9
+ - Set nicknames for core addresses in the database.
10
+ - Integrate with constants and token metadata.
11
+ - Support professional, readable analytics outputs.
12
+
13
+ This is called automatically on package import.
14
+ """
15
+
16
+ from typing import Final
17
+
18
+ from pony.orm import db_session
19
+
20
+ from dao_treasury import constants
21
+ from dao_treasury.db import Address, _set_address_nicknames_for_tokens
22
+
23
+
24
+ set_nickname: Final = Address.set_nickname
25
+
26
+
27
+ def setup_address_nicknames_in_db() -> None:
28
+ with db_session:
29
+ set_nickname(constants.ZERO_ADDRESS, "Zero Address")
30
+ for address in constants.DISPERSE_APP:
31
+ set_nickname(address, "Disperse.app")
32
+ _set_address_nicknames_for_tokens()
@@ -0,0 +1,250 @@
1
+ from dataclasses import dataclass
2
+ from pathlib import Path
3
+ from typing import Dict, Final, List, Optional, final
4
+
5
+ import yaml
6
+ from brownie.convert.datatypes import EthAddress
7
+ from eth_typing import BlockNumber, ChecksumAddress, HexAddress
8
+ from y import convert
9
+ from y.time import closest_block_after_timestamp
10
+
11
+ from dao_treasury.constants import CHAINID
12
+
13
+
14
+ WALLETS: Final[Dict[ChecksumAddress, "TreasuryWallet"]] = {}
15
+
16
+ to_address: Final = convert.to_address
17
+
18
+
19
+ @final
20
+ @dataclass
21
+ class TreasuryWallet:
22
+ """A dataclass used to supplement a treasury wallet address with some extra context if needed for your use case"""
23
+
24
+ address: EthAddress
25
+ """The wallet address you need to include with supplemental information."""
26
+
27
+ start_block: Optional[int] = None
28
+ """The first block at which this wallet was considered owned by the DAO, if it wasn't always included in the treasury. If `start_block` is provided, you cannot provide a `start_timestamp`."""
29
+
30
+ end_block: Optional[int] = None
31
+ """The last block at which this wallet was considered owned by the DAO, if it wasn't always included in the treasury. If `end_block` is provided, you cannot provide an `end_timestamp`."""
32
+
33
+ start_timestamp: Optional[int] = None
34
+ """The first timestamp at which this wallet was considered owned by the DAO, if it wasn't always included in the treasury. If `start_timestamp` is provided, you cannot provide a `start_block`."""
35
+
36
+ end_timestamp: Optional[int] = None
37
+ """The last timestamp at which this wallet was considered owned by the DAO, if it wasn't always included in the treasury. If `end_timestamp` is provided, you cannot provide an `end_block`."""
38
+
39
+ networks: Optional[List[int]] = None
40
+ """The networks where the DAO owns this wallet. If not provided, the wallet will be active on all networks."""
41
+
42
+ def __post_init__(self) -> None:
43
+ # If a user provides a wallets yaml file but forgets to wrap the address
44
+ # keys with quotes, it will be an integer we must convert to an address.
45
+ self.address = EthAddress(to_address(self.address))
46
+
47
+ start_block = self.start_block
48
+ start_timestamp = self.start_timestamp
49
+ if start_block is not None:
50
+ if start_timestamp is not None:
51
+ raise ValueError(
52
+ "You can only pass a start block or a start timestamp, not both."
53
+ )
54
+ elif start_block < 0:
55
+ raise ValueError("start_block can not be negative")
56
+ if start_timestamp is not None and start_timestamp < 0:
57
+ raise ValueError("start_timestamp can not be negative")
58
+
59
+ end_block = self.end_block
60
+ end_timestamp = self.end_timestamp
61
+ if end_block is not None:
62
+ if end_timestamp is not None:
63
+ raise ValueError(
64
+ "You can only pass an end block or an end timestamp, not both."
65
+ )
66
+ elif end_block < 0:
67
+ raise ValueError("end_block can not be negative")
68
+ if end_timestamp is not None and end_timestamp < 0:
69
+ raise ValueError("end_timestamp can not be negative")
70
+
71
+ addr = ChecksumAddress(str(self.address))
72
+ if addr in WALLETS:
73
+ raise ValueError(f"TreasuryWallet {addr} already exists")
74
+ WALLETS[addr] = self
75
+
76
+ @staticmethod
77
+ def check_membership(
78
+ address: Optional[HexAddress], block: Optional[BlockNumber] = None
79
+ ) -> bool:
80
+ if address is None:
81
+ return False
82
+ wallet = TreasuryWallet._get_instance(address)
83
+ if wallet is None:
84
+ return False
85
+ # If networks filter is set, only include if current chain is listed
86
+ if wallet.networks and CHAINID not in wallet.networks:
87
+ return False
88
+ return block is None or (
89
+ wallet._start_block <= block
90
+ and (wallet._end_block is None or wallet._end_block >= block)
91
+ )
92
+
93
+ @property
94
+ def _start_block(self) -> BlockNumber:
95
+ start_block = self.start_block
96
+ if start_block is not None:
97
+ return start_block
98
+ start_timestamp = self.start_timestamp
99
+ if start_timestamp is not None:
100
+ return closest_block_after_timestamp(start_timestamp) - 1
101
+ return BlockNumber(0)
102
+
103
+ @property
104
+ def _end_block(self) -> Optional[BlockNumber]:
105
+ end_block = self.end_block
106
+ if end_block is not None:
107
+ return end_block
108
+ end_timestamp = self.end_timestamp
109
+ if end_timestamp is not None:
110
+ return closest_block_after_timestamp(end_timestamp) - 1
111
+ return None
112
+
113
+ @staticmethod
114
+ def _get_instance(address: HexAddress) -> Optional["TreasuryWallet"]:
115
+ # sourcery skip: use-contextlib-suppress
116
+ try:
117
+ instance = WALLETS[address]
118
+ except KeyError:
119
+ checksummed = to_address(address)
120
+ try:
121
+ instance = WALLETS[address] = WALLETS[checksummed]
122
+ except KeyError:
123
+ return None
124
+ if instance.networks and CHAINID not in instance.networks:
125
+ return None
126
+ return instance
127
+
128
+
129
+ def load_wallets_from_yaml(path: Path) -> List[TreasuryWallet]:
130
+ """
131
+ Load a YAML mapping of wallet addresses to configuration and return a list of TreasuryWallets.
132
+ 'timestamp' in top-level start/end is universal.
133
+ 'block' in top-level start/end must be provided under the chain ID key.
134
+ Optional 'networks' key lists chain IDs where this wallet is active.
135
+ """
136
+ try:
137
+ data = yaml.safe_load(path.read_bytes())
138
+ except Exception as e:
139
+ raise ValueError(f"Failed to parse wallets YAML: {e}")
140
+
141
+ if not isinstance(data, dict):
142
+ raise ValueError("Wallets YAML file must be a mapping of address to config")
143
+
144
+ wallets: List[TreasuryWallet] = []
145
+ for address, cfg in data.items():
146
+ # Allow bare keys
147
+ if cfg is None:
148
+ cfg = {}
149
+ elif not isinstance(cfg, dict):
150
+ raise ValueError(f"Invalid config for wallet {address}, expected mapping")
151
+
152
+ kwargs = {"address": address}
153
+
154
+ # Extract optional networks list
155
+ networks = cfg.get("networks")
156
+ if networks:
157
+ if not isinstance(networks, list) or not all(
158
+ isinstance(n, int) for n in networks
159
+ ):
160
+ raise ValueError(
161
+ f"'networks' for wallet {address} must be a list of integers, got {networks}"
162
+ )
163
+ kwargs["networks"] = networks
164
+
165
+ # Parse start: timestamp universal, block under chain key
166
+ start_cfg = cfg.get("start", {})
167
+ if not isinstance(start_cfg, dict):
168
+ raise ValueError(
169
+ f"Invalid 'start' for wallet {address}. Expected mapping, got {start_cfg}."
170
+ )
171
+ for key, value in start_cfg.items():
172
+ if key == "timestamp":
173
+ if "start_block" in kwargs:
174
+ raise ValueError(
175
+ "You cannot provide both a start block and a start timestamp"
176
+ )
177
+ kwargs["start_timestamp"] = value
178
+ elif key == "block":
179
+ if not isinstance(value, dict):
180
+ raise ValueError(
181
+ f"Invalid start block for wallet {address}. Expected mapping, got {value}."
182
+ )
183
+ for chainid, start_block in value.items():
184
+ if not isinstance(chainid, int):
185
+ raise ValueError(
186
+ f"Invalid chainid for wallet {address} start block. Expected integer, got {chainid}."
187
+ )
188
+ if not isinstance(start_block, int):
189
+ raise ValueError(
190
+ f"Invalid start block for wallet {address}. Expected integer, got {start_block}."
191
+ )
192
+ if chainid == CHAINID:
193
+ if "start_timestamp" in kwargs:
194
+ raise ValueError(
195
+ "You cannot provide both a start block and a start timestamp"
196
+ )
197
+ kwargs["start_block"] = start_block
198
+ else:
199
+ raise ValueError(
200
+ f"Invalid key: {key}. Valid options are 'block' or 'timestamp'."
201
+ )
202
+
203
+ chain_block = start_cfg.get(str(CHAINID)) or start_cfg.get(CHAINID)
204
+ if chain_block is not None:
205
+ if not isinstance(chain_block, int):
206
+ raise ValueError(
207
+ f"Invalid start.block for chain {CHAINID} on {address}"
208
+ )
209
+ kwargs["start_block"] = chain_block
210
+
211
+ # Parse end: timestamp universal, block under chain key
212
+ end_cfg = cfg.get("end", {})
213
+ if not isinstance(end_cfg, dict):
214
+ raise ValueError(
215
+ f"Invalid 'end' for wallet {address}. Expected mapping, got {end_cfg}."
216
+ )
217
+
218
+ for key, value in end_cfg.items():
219
+ if key == "timestamp":
220
+ if "end_block" in kwargs:
221
+ raise ValueError(
222
+ "You cannot provide both an end block and an end timestamp"
223
+ )
224
+ kwargs["end_timestamp"] = value
225
+ elif key == "block":
226
+ if not isinstance(value, dict):
227
+ raise ValueError(
228
+ f"Invalid end block for wallet {address}. Expected mapping, got {value}."
229
+ )
230
+ for chainid, end_block in value.items():
231
+ if not isinstance(chainid, int):
232
+ raise ValueError(
233
+ f"Invalid chainid for wallet {address} end block. Expected integer, got {chainid}."
234
+ )
235
+ if not isinstance(end_block, int):
236
+ raise ValueError(
237
+ f"Invalid end block for wallet {address}. Expected integer, got {end_block}."
238
+ )
239
+ if chainid == CHAINID:
240
+ kwargs["end_block"] = end_block
241
+ else:
242
+ raise ValueError(
243
+ f"Invalid key: {key}. Valid options are 'block' or 'timestamp'."
244
+ )
245
+
246
+ wallet = TreasuryWallet(**kwargs)
247
+ print(f"initialized {wallet}")
248
+ wallets.append(wallet)
249
+
250
+ return wallets
@@ -0,0 +1,34 @@
1
+ """Core constants for DAO Treasury.
2
+
3
+ All constants are marked with `Final`, ensuring immutability and allowing
4
+ mypyc to compile them as extremely fast C-level constants for maximum
5
+ performance. Defines chain IDs, zero address, and key contract addresses
6
+ (e.g., Disperse.app) used throughout the system for transaction processing,
7
+ nickname assignment, and analytics.
8
+
9
+ Key Responsibilities:
10
+ - Provide canonical addresses and chain IDs.
11
+ - Support nickname setup and transaction categorization.
12
+ - Guarantee fast, immutable constants at runtime.
13
+
14
+ This is the single source of truth for system-wide constants.
15
+ """
16
+
17
+ from typing import Final
18
+
19
+ import y.constants
20
+
21
+
22
+ CHAINID: Final = y.constants.CHAINID
23
+ # TODO: add docstring
24
+
25
+ ZERO_ADDRESS: Final = "0x0000000000000000000000000000000000000000"
26
+ # TODO: add docstring
27
+
28
+ # TODO: move disperse.app stuff from yearn-treasury to dao-treasury and then write a docs file
29
+ DISPERSE_APP: Final = (
30
+ "0xD152f549545093347A162Dce210e7293f1452150",
31
+ "0xd15fE25eD0Dba12fE05e7029C88b10C25e8880E3",
32
+ )
33
+ """If your treasury sends funds to disperse.app, we create additional txs in the db so each individual send can be accounted for."""
34
+ # TODO: all crosslink to disperse.py once ready