dao-treasury 0.0.35__cp311-cp311-win_amd64.whl → 0.1.1__cp311-cp311-win_amd64.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.

Potentially problematic release.


This version of dao-treasury might be problematic. Click here for more details.

Files changed (49) hide show
  1. dao_treasury/.grafana/provisioning/dashboards/breakdowns/Expenses.json +567 -0
  2. dao_treasury/.grafana/provisioning/dashboards/breakdowns/Revenue.json +569 -0
  3. dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml +7 -57
  4. dao_treasury/.grafana/provisioning/dashboards/streams/LlamaPay.json +15 -27
  5. dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json +286 -25
  6. dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json +54 -71
  7. dao_treasury/.grafana/provisioning/dashboards/transactions/Unsorted Transactions.json +367 -0
  8. dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow (Including Unsorted).json +172 -209
  9. dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json +122 -142
  10. dao_treasury/.grafana/provisioning/dashboards/treasury/Current Treasury Assets.json +941 -0
  11. dao_treasury/.grafana/provisioning/dashboards/treasury/Historical Treasury Balances.json +3931 -0
  12. dao_treasury/.grafana/provisioning/dashboards/treasury/Operating Cashflow.json +89 -108
  13. dao_treasury/.grafana/provisioning/datasources/datasources.yaml +9 -4
  14. dao_treasury/ENVIRONMENT_VARIABLES.py +12 -0
  15. dao_treasury/__init__.py +14 -4
  16. dao_treasury/_docker.cp311-win_amd64.pyd +0 -0
  17. dao_treasury/_docker.py +44 -23
  18. dao_treasury/_nicknames.cp311-win_amd64.pyd +0 -0
  19. dao_treasury/_nicknames.py +18 -2
  20. dao_treasury/_wallet.cp311-win_amd64.pyd +0 -0
  21. dao_treasury/constants.cp311-win_amd64.pyd +0 -0
  22. dao_treasury/constants.py +24 -0
  23. dao_treasury/db.py +409 -119
  24. dao_treasury/docker-compose.yaml +19 -3
  25. dao_treasury/main.py +44 -3
  26. dao_treasury/sorting/__init__.cp311-win_amd64.pyd +0 -0
  27. dao_treasury/sorting/__init__.py +38 -21
  28. dao_treasury/sorting/_matchers.cp311-win_amd64.pyd +0 -0
  29. dao_treasury/sorting/_rules.cp311-win_amd64.pyd +0 -0
  30. dao_treasury/sorting/factory.cp311-win_amd64.pyd +0 -0
  31. dao_treasury/sorting/rule.cp311-win_amd64.pyd +0 -0
  32. dao_treasury/sorting/rule.py +8 -10
  33. dao_treasury/sorting/rules/__init__.cp311-win_amd64.pyd +0 -0
  34. dao_treasury/sorting/rules/ignore/__init__.cp311-win_amd64.pyd +0 -0
  35. dao_treasury/sorting/rules/ignore/llamapay.cp311-win_amd64.pyd +0 -0
  36. dao_treasury/streams/llamapay.py +14 -2
  37. dao_treasury/treasury.py +37 -16
  38. dao_treasury/types.cp311-win_amd64.pyd +0 -0
  39. {dao_treasury-0.0.35.dist-info → dao_treasury-0.1.1.dist-info}/METADATA +19 -3
  40. dao_treasury-0.1.1.dist-info/RECORD +53 -0
  41. dao_treasury-0.1.1.dist-info/top_level.txt +2 -0
  42. dao_treasury__mypyc.cp311-win_amd64.pyd +0 -0
  43. bf2b4fe1f86ad2ea158b__mypyc.cp311-win_amd64.pyd +0 -0
  44. dao_treasury/.grafana/provisioning/dashboards/treasury/Treasury.json +0 -2018
  45. dao_treasury/streams/__init__.cp311-win_amd64.pyd +0 -0
  46. dao_treasury/streams/llamapay.cp311-win_amd64.pyd +0 -0
  47. dao_treasury-0.0.35.dist-info/RECORD +0 -51
  48. dao_treasury-0.0.35.dist-info/top_level.txt +0 -2
  49. {dao_treasury-0.0.35.dist-info → dao_treasury-0.1.1.dist-info}/WHEEL +0 -0
@@ -3,9 +3,12 @@ networks:
3
3
  docker_eth_portfolio:
4
4
  external: true
5
5
 
6
+ volumes:
7
+ dao_treasury_pgdata:
8
+
6
9
  services:
7
10
  grafana:
8
- image: grafana/grafana:10.2.0
11
+ image: grafana/grafana:12.2.1
9
12
  ports:
10
13
  - 127.0.0.1:${DAO_TREASURY_GRAFANA_PORT:-3004}:3000
11
14
  environment:
@@ -18,9 +21,8 @@ services:
18
21
  - GF_RENDERING_SERVER_URL=http://renderer:8091/render
19
22
  - GF_RENDERING_CALLBACK_URL=http://grafana:3000/
20
23
  - GF_LOG_FILTERS=rendering:debug
21
- - GF_INSTALL_PLUGINS=volkovlabs-variable-panel,frser-sqlite-datasource
24
+ - GF_INSTALL_PLUGINS=volkovlabs-variable-panel
22
25
  volumes:
23
- - ~/.dao-treasury/:/app/dao-treasury-data
24
26
  - ./.grafana/provisioning/:/etc/grafana/provisioning/
25
27
  networks:
26
28
  - dao_treasury
@@ -39,3 +41,17 @@ services:
39
41
  - dao_treasury
40
42
  - docker_eth_portfolio
41
43
  restart: always
44
+
45
+ postgres:
46
+ image: postgres:18
47
+ restart: always
48
+ environment:
49
+ POSTGRES_USER: dao_treasury
50
+ POSTGRES_PASSWORD: dao_treasury
51
+ POSTGRES_DB: dao_treasury
52
+ volumes:
53
+ - dao_treasury_pgdata:/var/lib/postgresql
54
+ ports:
55
+ - 127.0.0.1:${DAO_TREASURY_POSTGRES_PORT:-8675}:5432
56
+ networks:
57
+ - dao_treasury
dao_treasury/main.py CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This module parses command-line arguments, sets up environment variables for
4
4
  Grafana and its renderer, and defines the entrypoint for a one-time export of
5
- DAO treasury transactions. It populates the local SQLite database and starts
5
+ DAO treasury transactions. It populates the local PostgreSQL database and starts
6
6
  the required Docker services for Grafana dashboards. Transactions are fetched
7
7
  via :class:`dao_treasury.Treasury`, sorted according to optional rules, and
8
8
  inserted using the database routines (:func:`dao_treasury.db.TreasuryTx.insert`).
@@ -29,6 +29,7 @@ from pathlib import Path
29
29
  import brownie
30
30
  import yaml
31
31
  from a_sync import create_task
32
+ from dao_treasury._nicknames import setup_address_nicknames_in_db
32
33
  from dao_treasury._wallet import load_wallets_from_yaml
33
34
  from eth_portfolio_scripts.balances import export_balances
34
35
  from eth_typing import BlockNumber
@@ -97,6 +98,12 @@ parser.add_argument(
97
98
  help="The time interval between datapoints. default: 1d",
98
99
  default="1d",
99
100
  )
101
+ parser.add_argument(
102
+ "--concurrency",
103
+ type=int,
104
+ help="The max number of historical blocks to export concurrently. default: 30",
105
+ default=30,
106
+ )
100
107
  parser.add_argument(
101
108
  "--daemon",
102
109
  action="store_true",
@@ -119,6 +126,18 @@ parser.add_argument(
119
126
  help="Port for the Grafana rendering service. Default: 8091",
120
127
  default=8091,
121
128
  )
129
+ parser.add_argument(
130
+ "--custom-bucket",
131
+ type=str,
132
+ action="append",
133
+ help=(
134
+ "Custom bucket mapping for a wallet address. "
135
+ "Specify as 'address:bucket_name'. "
136
+ "Can be used multiple times. Example: "
137
+ "--custom-bucket '0x123:My Bucket' --custom-bucket '0x456:Other Bucket'"
138
+ ),
139
+ default=None,
140
+ )
122
141
 
123
142
  args = parser.parse_args()
124
143
 
@@ -203,13 +222,35 @@ async def export(args) -> None:
203
222
  for address in addresses:
204
223
  db.Address.set_nickname(address, nickname)
205
224
 
206
- treasury = Treasury(wallets, args.sort_rules, asynchronous=True)
225
+ # Parse custom_buckets from --custom-bucket arguments
226
+ custom_buckets = None
227
+ if args.custom_bucket:
228
+ custom_buckets = {}
229
+ for item in args.custom_bucket:
230
+ if ":" not in item:
231
+ parser.error(
232
+ f"Invalid format for --custom-bucket: '{item}'. Must be 'address:bucket_name'."
233
+ )
234
+ address, bucket = item.split(":", 1)
235
+ address = address.strip()
236
+ bucket = bucket.strip()
237
+ if not address or not bucket:
238
+ parser.error(
239
+ f"Invalid format for --custom-bucket: '{item}'. Both address and bucket_name are required."
240
+ )
241
+ custom_buckets[address] = bucket
242
+
243
+ treasury = Treasury(
244
+ wallets, args.sort_rules, custom_buckets=custom_buckets, asynchronous=True
245
+ )
207
246
 
208
247
  # Start only the requested containers
209
248
  if args.start_renderer is True:
210
249
  _docker.up()
211
250
  else:
212
- _docker.up("grafana")
251
+ _docker.up("grafana", "postgres")
252
+
253
+ setup_address_nicknames_in_db()
213
254
 
214
255
  # eth-portfolio needs this present
215
256
  # TODO: we need to update eth-portfolio to honor wallet join and exit times
@@ -88,13 +88,8 @@ __all__ = [
88
88
 
89
89
  # C constants
90
90
  TxGroup: Final = db.TxGroup
91
- MUST_SORT_INBOUND_TXGROUP_DBID: Final = db.must_sort_inbound_txgroup_dbid
92
- MUST_SORT_OUTBOUND_TXGROUP_DBID: Final = db.must_sort_outbound_txgroup_dbid
93
91
 
94
- INTERNAL_TRANSFER_TXGROUP_DBID: Final = TxGroup.get_dbid(
95
- name="Internal Transfer",
96
- parent=TxGroup.get_dbid("Ignore"),
97
- )
92
+ INTERNAL_TRANSFER_TXGROUP_DBID: int | None = None
98
93
  """Database ID for the 'Internal Transfer' transaction group.
99
94
 
100
95
  This group represents transactions that occur internally between treasury-owned wallets.
@@ -104,9 +99,7 @@ See Also:
104
99
  :class:`dao_treasury.db.TxGroup`
105
100
  """
106
101
 
107
- OUT_OF_RANGE_TXGROUP_DBID = TxGroup.get_dbid(
108
- name="Out of Range", parent=TxGroup.get_dbid("Ignore")
109
- )
102
+ OUT_OF_RANGE_TXGROUP_DBID: int | None = None
110
103
  """Database ID for the 'Out of Range' transaction group.
111
104
 
112
105
  This category is assigned to transactions where neither the sender nor the recipient
@@ -143,6 +136,9 @@ def sort_basic(entry: LedgerEntry) -> TxGroupDbid:
143
136
  :func:`sort_advanced`
144
137
  :class:`dao_treasury.sorting.HashMatcher`
145
138
  """
139
+ global INTERNAL_TRANSFER_TXGROUP_DBID
140
+ global OUT_OF_RANGE_TXGROUP_DBID
141
+
146
142
  from_address = entry.from_address
147
143
  to_address = entry.to_address
148
144
  block = entry.block_number
@@ -150,8 +146,17 @@ def sort_basic(entry: LedgerEntry) -> TxGroupDbid:
150
146
  txgroup_dbid: Optional[TxGroupDbid] = None
151
147
  if TreasuryWallet.check_membership(from_address, block):
152
148
  if TreasuryWallet.check_membership(to_address, block):
149
+ if INTERNAL_TRANSFER_TXGROUP_DBID is None:
150
+ INTERNAL_TRANSFER_TXGROUP_DBID = TxGroup.get_dbid(
151
+ name="Internal Transfer",
152
+ parent=TxGroup.get_dbid("Ignore"),
153
+ )
153
154
  txgroup_dbid = INTERNAL_TRANSFER_TXGROUP_DBID
154
155
  elif not TreasuryWallet.check_membership(to_address, block):
156
+ if OUT_OF_RANGE_TXGROUP_DBID is None:
157
+ OUT_OF_RANGE_TXGROUP_DBID = TxGroup.get_dbid(
158
+ name="Out of Range", parent=TxGroup.get_dbid("Ignore")
159
+ )
155
160
  txgroup_dbid = OUT_OF_RANGE_TXGROUP_DBID
156
161
 
157
162
  if txgroup_dbid is None:
@@ -167,10 +172,10 @@ def sort_basic(entry: LedgerEntry) -> TxGroupDbid:
167
172
 
168
173
  if txgroup_dbid is None:
169
174
  if TreasuryWallet.check_membership(from_address, block):
170
- txgroup_dbid = MUST_SORT_OUTBOUND_TXGROUP_DBID
175
+ txgroup_dbid = db.must_sort_outbound_txgroup_dbid
171
176
 
172
177
  elif TreasuryWallet.check_membership(to_address, block):
173
- txgroup_dbid = MUST_SORT_INBOUND_TXGROUP_DBID
178
+ txgroup_dbid = db.must_sort_inbound_txgroup_dbid
174
179
 
175
180
  else:
176
181
  raise NotImplementedError("this isnt supposed to happen")
@@ -197,6 +202,9 @@ def sort_basic_entity(tx: db.TreasuryTx) -> TxGroupDbid:
197
202
  :func:`sort_basic`
198
203
  :func:`sort_advanced`
199
204
  """
205
+ global INTERNAL_TRANSFER_TXGROUP_DBID
206
+ global OUT_OF_RANGE_TXGROUP_DBID
207
+
200
208
  from_address = tx.from_address.address
201
209
  to_address = tx.to_address
202
210
  block = tx.block
@@ -204,11 +212,20 @@ def sort_basic_entity(tx: db.TreasuryTx) -> TxGroupDbid:
204
212
  txgroup_dbid: Optional[TxGroupDbid] = None
205
213
  if TreasuryWallet.check_membership(from_address, block):
206
214
  if TreasuryWallet.check_membership(tx.to_address.address, block):
215
+ if INTERNAL_TRANSFER_TXGROUP_DBID is None:
216
+ INTERNAL_TRANSFER_TXGROUP_DBID = TxGroup.get_dbid(
217
+ name="Internal Transfer",
218
+ parent=TxGroup.get_dbid("Ignore"),
219
+ )
207
220
  txgroup_dbid = INTERNAL_TRANSFER_TXGROUP_DBID
208
221
  elif not (
209
222
  TreasuryWallet.check_membership(tx.to_address.address, tx.block)
210
223
  or from_address in constants.DISPERSE_APP
211
224
  ):
225
+ if OUT_OF_RANGE_TXGROUP_DBID is None:
226
+ OUT_OF_RANGE_TXGROUP_DBID = TxGroup.get_dbid(
227
+ name="Out of Range", parent=TxGroup.get_dbid("Ignore")
228
+ )
212
229
  txgroup_dbid = OUT_OF_RANGE_TXGROUP_DBID
213
230
 
214
231
  if txgroup_dbid is None:
@@ -222,23 +239,23 @@ def sort_basic_entity(tx: db.TreasuryTx) -> TxGroupDbid:
222
239
 
223
240
  if txgroup_dbid is None:
224
241
  if TreasuryWallet.check_membership(from_address, block):
225
- txgroup_dbid = MUST_SORT_OUTBOUND_TXGROUP_DBID
242
+ txgroup_dbid = db.must_sort_outbound_txgroup_dbid
226
243
 
227
244
  elif TreasuryWallet.check_membership(to_address.address, block):
228
- txgroup_dbid = MUST_SORT_INBOUND_TXGROUP_DBID
245
+ txgroup_dbid = db.must_sort_inbound_txgroup_dbid
229
246
 
230
247
  elif from_address in constants.DISPERSE_APP:
231
- txgroup_dbid = MUST_SORT_OUTBOUND_TXGROUP_DBID
248
+ txgroup_dbid = db.must_sort_outbound_txgroup_dbid
232
249
 
233
250
  elif from_address in constants.DISPERSE_APP:
234
- txgroup_dbid = MUST_SORT_OUTBOUND_TXGROUP_DBID
251
+ txgroup_dbid = db.must_sort_outbound_txgroup_dbid
235
252
 
236
253
  else:
237
254
  raise NotImplementedError("this isnt supposed to happen")
238
255
 
239
256
  if txgroup_dbid not in (
240
- MUST_SORT_INBOUND_TXGROUP_DBID,
241
- MUST_SORT_OUTBOUND_TXGROUP_DBID,
257
+ db.must_sort_inbound_txgroup_dbid,
258
+ db.must_sort_outbound_txgroup_dbid,
242
259
  ):
243
260
  logger.info("Sorted %s to %s", tx, TxGroup.get_fullname(txgroup_dbid))
244
261
 
@@ -274,8 +291,8 @@ async def sort_advanced(entry: db.TreasuryTx) -> TxGroupDbid:
274
291
  txgroup_dbid = sort_basic_entity(entry)
275
292
 
276
293
  if txgroup_dbid in (
277
- MUST_SORT_INBOUND_TXGROUP_DBID,
278
- MUST_SORT_OUTBOUND_TXGROUP_DBID,
294
+ db.must_sort_inbound_txgroup_dbid,
295
+ db.must_sort_outbound_txgroup_dbid,
279
296
  ):
280
297
  for rules in SORT_RULES.values():
281
298
  for rule in rules:
@@ -286,8 +303,8 @@ async def sort_advanced(entry: db.TreasuryTx) -> TxGroupDbid:
286
303
  except ContractNotVerified:
287
304
  continue
288
305
  if txgroup_dbid not in (
289
- MUST_SORT_INBOUND_TXGROUP_DBID,
290
- MUST_SORT_OUTBOUND_TXGROUP_DBID,
306
+ db.must_sort_inbound_txgroup_dbid,
307
+ db.must_sort_outbound_txgroup_dbid,
291
308
  ):
292
309
  logger.info("Sorted %s to %s", entry, TxGroup.get_fullname(txgroup_dbid))
293
310
  await entry._set_txgroup(txgroup_dbid)
@@ -130,8 +130,6 @@ class _SortRule:
130
130
  func: Optional[SortFunction] = None
131
131
  """Custom matching function that takes a `TreasuryTx` and returns a bool or an awaitable that returns a bool."""
132
132
 
133
- # __instances__: ClassVar[List[Self]] = []
134
-
135
133
  def __post_init__(self) -> None:
136
134
  """Validate inputs, checksum addresses, and register the rule.
137
135
 
@@ -235,7 +233,7 @@ class _InboundSortRule(_SortRule):
235
233
  return (
236
234
  tx.to_address is not None
237
235
  and TreasuryWallet.check_membership(tx.to_address.address, tx.block)
238
- and await super().match(tx)
236
+ and await super(_InboundSortRule, self).match(tx)
239
237
  )
240
238
 
241
239
 
@@ -250,7 +248,7 @@ class _OutboundSortRule(_SortRule):
250
248
  async def match(self, tx: "TreasuryTx") -> bool:
251
249
  return TreasuryWallet.check_membership(
252
250
  tx.from_address.address, tx.block
253
- ) and await super().match(tx)
251
+ ) and await super(_OutboundSortRule, self).match(tx)
254
252
 
255
253
 
256
254
  @mypyc_attr(native_class=False)
@@ -267,7 +265,7 @@ class RevenueSortRule(_InboundSortRule):
267
265
  def __post_init__(self) -> None:
268
266
  """Prepends `self.txgroup` with 'Revenue:'."""
269
267
  object.__setattr__(self, "txgroup", f"Revenue:{self.txgroup}")
270
- super().__post_init__()
268
+ super(RevenueSortRule, self).__post_init__()
271
269
 
272
270
 
273
271
  @mypyc_attr(native_class=False)
@@ -280,7 +278,7 @@ class CostOfRevenueSortRule(_OutboundSortRule):
280
278
  def __post_init__(self) -> None:
281
279
  """Prepends `self.txgroup` with 'Cost of Revenue:'."""
282
280
  object.__setattr__(self, "txgroup", f"Cost of Revenue:{self.txgroup}")
283
- super().__post_init__()
281
+ super(CostOfRevenueSortRule, self).__post_init__()
284
282
 
285
283
 
286
284
  @mypyc_attr(native_class=False)
@@ -293,7 +291,7 @@ class ExpenseSortRule(_OutboundSortRule):
293
291
  def __post_init__(self) -> None:
294
292
  """Prepends `self.txgroup` with 'Expenses:'."""
295
293
  object.__setattr__(self, "txgroup", f"Expenses:{self.txgroup}")
296
- super().__post_init__()
294
+ super(ExpenseSortRule, self).__post_init__()
297
295
 
298
296
 
299
297
  @mypyc_attr(native_class=False)
@@ -306,7 +304,7 @@ class OtherIncomeSortRule(_InboundSortRule):
306
304
  def __post_init__(self) -> None:
307
305
  """Prepends `self.txgroup` with 'Other Income:'."""
308
306
  object.__setattr__(self, "txgroup", f"Other Income:{self.txgroup}")
309
- super().__post_init__()
307
+ super(OtherIncomeSortRule, self).__post_init__()
310
308
 
311
309
 
312
310
  @mypyc_attr(native_class=False)
@@ -319,7 +317,7 @@ class OtherExpenseSortRule(_OutboundSortRule):
319
317
  def __post_init__(self) -> None:
320
318
  """Prepends `self.txgroup` with 'Other Expenses:'."""
321
319
  object.__setattr__(self, "txgroup", f"Other Expenses:{self.txgroup}")
322
- super().__post_init__()
320
+ super(OtherExpenseSortRule, self).__post_init__()
323
321
 
324
322
 
325
323
  @mypyc_attr(native_class=False)
@@ -332,7 +330,7 @@ class IgnoreSortRule(_SortRule):
332
330
  def __post_init__(self) -> None:
333
331
  """Prepends `self.txgroup` with 'Ignore:'."""
334
332
  object.__setattr__(self, "txgroup", f"Ignore:{self.txgroup}")
335
- super().__post_init__()
333
+ super(IgnoreSortRule, self).__post_init__()
336
334
 
337
335
 
338
336
  TRule = TypeVar(
@@ -22,7 +22,7 @@ from eth_typing import BlockNumber, ChecksumAddress, HexAddress, HexStr
22
22
  from tqdm.asyncio import tqdm_asyncio
23
23
 
24
24
  import y
25
- from y.time import UnixTimestamp
25
+ from y.time import NoBlockFound, UnixTimestamp
26
26
  from y.utils.events import decode_logs, get_logs_asap
27
27
 
28
28
  from dao_treasury import constants
@@ -338,7 +338,19 @@ class LlamaPayProcessor:
338
338
  check_at = date_obj + timedelta(days=1) - timedelta(seconds=1)
339
339
  if check_at > now(tz=_UTC):
340
340
  await sleep((check_at - now(tz=_UTC)).total_seconds())
341
- block = await get_block_at_timestamp(check_at, sync=False)
341
+
342
+ while True:
343
+ try:
344
+ block = await get_block_at_timestamp(check_at, sync=False)
345
+ except NoBlockFound:
346
+ sleep_time = (check_at - now(tz=_UTC)).total_seconds()
347
+ logger.debug(
348
+ "no block found for %s, sleeping %ss", check_at, sleep_time
349
+ )
350
+ await sleep(sleep_time)
351
+ else:
352
+ break
353
+
342
354
  price_fut = create_task(get_price(stream_token, block, sync=False))
343
355
  start_timestamp = await _get_start_timestamp(stream_id, block)
344
356
  if start_timestamp == 0:
dao_treasury/treasury.py CHANGED
@@ -1,11 +1,28 @@
1
+ """Treasury orchestration and analytics interface.
2
+
3
+ This module defines the Treasury class, which aggregates DAO wallets, sets up
4
+ sorting rules, and manages transaction ingestion and streaming analytics.
5
+ It coordinates the end-to-end flow from wallet configuration to database
6
+ population and dashboard analytics.
7
+
8
+ Key Responsibilities:
9
+ - Aggregate and manage DAO-controlled wallets.
10
+ - Ingest and process on-chain transactions.
11
+ - Apply sorting/categorization rules.
12
+ - Integrate with streaming protocols (e.g., LlamaPay).
13
+ - Populate the database for analytics and dashboards.
14
+
15
+ This is the main entry point for orchestrating DAO treasury analytics.
16
+ """
17
+
1
18
  from asyncio import create_task, gather
2
19
  from logging import getLogger
3
20
  from pathlib import Path
4
- from typing import Final, Iterable, List, Optional, Union
21
+ from typing import Dict, Final, Iterable, List, Optional, Union
5
22
 
6
23
  import a_sync
7
24
  from a_sync.a_sync.abstract import ASyncABC
8
- from eth_typing import BlockNumber
25
+ from eth_typing import BlockNumber, HexAddress
9
26
  from eth_portfolio.structs import LedgerEntry
10
27
  from eth_portfolio.typing import PortfolioBalances
11
28
  from eth_portfolio_scripts._portfolio import ExportablePortfolio
@@ -35,6 +52,7 @@ class Treasury(a_sync.ASyncGenericBase): # type: ignore [misc]
35
52
  sort_rules: Optional[Path] = None,
36
53
  start_block: int = 0,
37
54
  label: str = "your org's treasury",
55
+ custom_buckets: Optional[Dict[HexAddress, str]] = None,
38
56
  asynchronous: bool = False,
39
57
  ) -> None:
40
58
  """Initialize the Treasury singleton for managing DAO funds.
@@ -59,20 +77,22 @@ class Treasury(a_sync.ASyncGenericBase): # type: ignore [misc]
59
77
  TypeError: If any item in `wallets` is not a str or TreasuryWallet.
60
78
 
61
79
  Examples:
62
- Create a synchronous Treasury:
63
- >>> treasury = Treasury(
64
- ... wallets=["0xAbc123...", TreasuryWallet("0xDef456...", start_block=1000)],
65
- ... sort_rules=Path("/path/to/rules"),
66
- ... start_block=500,
67
- ... label="DAO Treasury",
68
- ... asynchronous=False
69
- ... )
70
-
71
- Create an asynchronous Treasury:
72
- >>> treasury_async = Treasury(
73
- ... wallets=["0xAbc123..."],
74
- ... asynchronous=True
75
- ... )
80
+ .. code-block:: python
81
+
82
+ # Create a synchronous Treasury
83
+ treasury = Treasury(
84
+ wallets=["0xAbc123...", TreasuryWallet("0xDef456...", start_block=1000)],
85
+ sort_rules=Path("/path/to/rules"),
86
+ start_block=500,
87
+ label="DAO Treasury",
88
+ asynchronous=False
89
+ )
90
+
91
+ # Create an asynchronous Treasury
92
+ treasury_async = Treasury(
93
+ wallets=["0xAbc123..."],
94
+ asynchronous=True
95
+ )
76
96
  """
77
97
  global TREASURY
78
98
  if TREASURY is not None:
@@ -105,6 +125,7 @@ class Treasury(a_sync.ASyncGenericBase): # type: ignore [misc]
105
125
  start_block=start_block,
106
126
  label=label,
107
127
  load_prices=True,
128
+ custom_buckets=custom_buckets,
108
129
  asynchronous=asynchronous,
109
130
  )
110
131
  """An eth_portfolio.Portfolio object used for exporting tx and balance history"""
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dao_treasury
3
- Version: 0.0.35
3
+ Version: 0.1.1
4
4
  Summary: Produce comprehensive financial reports for your on-chain org
5
5
  Classifier: Development Status :: 3 - Alpha
6
6
  Classifier: Intended Audience :: Developers
@@ -14,7 +14,8 @@ Classifier: Operating System :: OS Independent
14
14
  Classifier: Topic :: Software Development :: Libraries
15
15
  Requires-Python: >=3.10,<3.13
16
16
  Description-Content-Type: text/markdown
17
- Requires-Dist: eth-portfolio-temp<0.1,>=0.0.30.dev0
17
+ Requires-Dist: eth-portfolio-temp==0.3.2
18
+ Requires-Dist: psycopg2-binary==2.9.11
18
19
  Dynamic: classifier
19
20
  Dynamic: description
20
21
  Dynamic: description-content-type
@@ -29,6 +30,7 @@ DAO Treasury is a comprehensive financial reporting and treasury management solu
29
30
  - **Financial Reporting for DAOs:** Extends core portfolio functionalities to generate detailed reports tailored for on-chain organizations.
30
31
  - **Dashboard Provisioning:** Utilizes [Grafana](https://grafana.com/) dashboards—defined in JSON files within the .grafana/provisioning directories—to offer real-time, dynamic visualizations of treasury data.
31
32
  - **Automated Data Export:** Features a treasury export tool that, once configured (with a supported [brownie network](https://eth-brownie.readthedocs.io/en/stable/network-management.html) and [Docker](https://www.docker.com/get-started/)), continuously captures financial snapshots at set intervals.
33
+ - **Custom Buckets for Wallets:** Assign custom categories ("buckets") to specific wallet addresses for more granular reporting using the `--custom-bucket` CLI option.
32
34
  - **Ease of Contribution:** Non-technical users can easily update or create dashboard visuals using Grafana’s intuitive UI. The [Contributing Guidelines](https://github.com/BobTheBuidler/dao-treasury/blob/master/CONTRIBUTING.md) document provides a step-by-step guide to defining new visuals and dashboards and integrating those changes into the repository, ensuring that anyone can contribute to the visual reporting aspect of the project.
33
35
 
34
36
  ## Requirements
@@ -41,7 +43,7 @@ DAO Treasury is a comprehensive financial reporting and treasury management solu
41
43
  - First, you will need to bring your own archive node. This can be one you run yourself, or one from one of the common providers (Tenderly, Alchemy, QuickNode, etc.). Your archive node must have tracing enabled (free-tier Alchemy nodes do not support this option).
42
44
  - You must configure a [brownie network](https://eth-brownie.readthedocs.io/en/stable/network-management.html) to use your RPC.
43
45
  - You will need an auth token for [Etherscan](https://etherscan.io/)'s API. Follow their [guide](https://docs.etherscan.io/etherscan-v2/getting-an-api-key) to get your key, and set env var `ETHERSCAN_TOKEN` with its value.
44
- - You'll also need [Docker](https://www.docker.com/get-started/) installed on your system. If on MacOS, you will need to leave Docker Desktop open while Yearn Treasury is running.
46
+ - You'll also need [Docker](https://www.docker.com/get-started/) installed on your system. If on MacOS, you will need to leave Docker Desktop open while DAO Treasury is running.
45
47
 
46
48
  ## Installation
47
49
 
@@ -63,14 +65,28 @@ For local development (from source installation), use:
63
65
  poetry run dao-treasury run --wallet 0x123 --network mainnet --interval 12h
64
66
  ```
65
67
 
68
+ **Assigning Custom Buckets to Wallets:**
69
+
70
+ You can assign custom categories ("buckets") to specific wallet addresses for more granular reporting. Use the `--custom-bucket` option one or more times, each with the format `address:bucket_name`:
71
+
72
+ ```bash
73
+ dao-treasury run --wallet 0x123 --network mainnet --custom-bucket "0x123:Operations" --custom-bucket "0x456:Grants" --custom-bucket "0x789:Investments"
74
+ ```
75
+
66
76
  **CLI Options:**
77
+ > Only optional arguments are listed here. Required arguments (such as `--wallet` or `--wallets`) are shown in the usage examples above.
78
+
67
79
  - `--network`: The id of the brownie network the exporter will connect to (default: mainnet)
68
80
  - `--interval`: The time interval between each data snapshot (default: 12h)
81
+ - `--concurrency`: The max number of historical blocks to export concurrently. (default: 30)
69
82
  - `--daemon`: Run the export process in the background (default: False) (NOTE: currently unsupported)
83
+ - `--sort-rules`: Directory containing sort rules definitions for transaction categorization.
84
+ - `--nicknames`: File containing address nicknames for reporting.
70
85
  - `--grafana-port`: Set the port for the Grafana dashboard where you can view data (default: 3004)
71
86
  - `--renderer-port`: Set the port for the report rendering service (default: 8091)
72
87
  - `--victoria-port`: Set the port for the Victoria metrics reporting endpoint (default: 8430)
73
88
  - `--start-renderer`: If set, both the Grafana and renderer containers will be started for dashboard image export. By default, only the grafana container is started.
89
+ - `--custom-bucket`: Assign a custom bucket/category to a wallet address for reporting. Specify as `address:bucket_name`. Can be used multiple times.
74
90
 
75
91
  After running the command, the export script will run continuously until you close your terminal.
76
92
  To view the dashboards, just open your browser and navigate to [http://localhost:3004](http://localhost:3004)!
@@ -0,0 +1,53 @@
1
+ dao_treasury__mypyc.cp311-win_amd64.pyd,sha256=EgbH2bP9FGZEWLznZ58naiEBC2wdcoK92hcAkaK4tgc,279552
2
+ dao_treasury/ENVIRONMENT_VARIABLES.py,sha256=LS_D4ALB3BO-vYKyh1tzRHi10QBE6f654Zy8pmJ_xPY,656
3
+ dao_treasury/__init__.py,sha256=fEHZYMeNqVUI9YAVXCHozxDB7cvJJnaF4HBRyeAlOiw,1435
4
+ dao_treasury/_docker.cp311-win_amd64.pyd,sha256=xV1vXf4k0Y1UpJ6T0gZCPG0zAXY9Yz8Mb6yGEh5rKZk,10752
5
+ dao_treasury/_docker.py,sha256=yAMcwXl48hGPN2sH5b56O_XP3wrd1gap959Xrk8KpKM,6337
6
+ dao_treasury/_nicknames.cp311-win_amd64.pyd,sha256=vWALUm21t1Z0aSs2aSAOXaItPZWghXYpfKlmr88Zb3k,10752
7
+ dao_treasury/_nicknames.py,sha256=4Smlv4y5248PM-yDEyybbR1Of1-tIHgf0PCBAXTE3Aw,1071
8
+ dao_treasury/_wallet.cp311-win_amd64.pyd,sha256=xqt3Fl8cMmttAxP75ysWjLFr4OJ_O7keT9QOy4NC6FI,10752
9
+ dao_treasury/_wallet.py,sha256=nHBAKFJstdKuYbvpskGVx2KU80YrZHGHsEh5V3TwIHs,10712
10
+ dao_treasury/constants.cp311-win_amd64.pyd,sha256=8TqggPTdOS0Q6m5HRHKPBWrMXKALR3VcaAhJ3przuwo,10752
11
+ dao_treasury/constants.py,sha256=-T0oPw7lC5YeaiplHAtYL-2ss7knvKrJKQ1LCc8kX8g,1483
12
+ dao_treasury/db.py,sha256=5-S8Ax2Buwhfg8Mo9Jad1hbn7hrbWj_r6HgCzgCmsZg,59827
13
+ dao_treasury/docker-compose.yaml,sha256=Javd6LIxF2nOpKWRsDYe-VVWBjMGprsXyUK4DGaLLO8,1670
14
+ dao_treasury/main.py,sha256=THzDHwJQPbLXUpHqbiCncQeqpvKQUz6ae63frX5LlzU,9733
15
+ dao_treasury/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ dao_treasury/treasury.py,sha256=K4XOg-5BHoP5HoRlHNu4afNpYs2-8sjCOOGwdt3M21w,7541
17
+ dao_treasury/types.cp311-win_amd64.pyd,sha256=j3AKrqWkPJ0r7-LHv8OEmkpD1_bH2qOQELzhQPy5N6Q,10752
18
+ dao_treasury/types.py,sha256=KFz4WKPp4t_RBwIT6YGwOcgbzw8tdHIOcXTFsUA0pJA,3818
19
+ dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml,sha256=to_cVfl8X6-5zVskkDxNtTE191TH52XO2peGfHPI5F0,201
20
+ dao_treasury/.grafana/provisioning/dashboards/breakdowns/Expenses.json,sha256=aBwKDj5HBkSXlSt5L7Cg_Ce5yK0VaRKAWVe19j-HCgQ,17809
21
+ dao_treasury/.grafana/provisioning/dashboards/breakdowns/Revenue.json,sha256=xzvFemq3hYoXdoOafspsuCU8jHCbC2JOtgOq_a_aFPU,17517
22
+ dao_treasury/.grafana/provisioning/dashboards/streams/LlamaPay.json,sha256=ukfBKgqIF7I43Lv8SfEnLrrYqCmRQbmSiumwd2h1a8A,6657
23
+ dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json,sha256=KMGAaagwRWBHw3IN4NljCUIIOwu-3Gp0VSnkMzDrcO4,12708
24
+ dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json,sha256=lRPynOn4Zy6WpZLz8-Px2kjflZLRcT8TA6VIz-_VGNM,13815
25
+ dao_treasury/.grafana/provisioning/dashboards/transactions/Unsorted Transactions.json,sha256=cBY3EqFpf9F7B8TaM9yESQatBpe4yFFmyLAiZEul_IE,19107
26
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow (Including Unsorted).json,sha256=k6hU_pZTmaWd2bYP8762yF_WoqR0PlVuoyiVgfrfwoM,24542
27
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json,sha256=GZmgROCKfRQnCV7TP_yBJZRFdPy3TsTs6d6GNilqyP8,17829
28
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Current Treasury Assets.json,sha256=4tsEWzkBM9eQVNnDECM9lGOO26mvcFJofltY-QDfU2M,25112
29
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Historical Treasury Balances.json,sha256=53fCotzJSElELRS1ABNkXX0_CG1_gBLHpjOthhYTDnw,136157
30
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Operating Cashflow.json,sha256=78QjkFAWl6ySUvLvpbDt0OE-WzL2hg_qC_YLYOq_faY,14155
31
+ dao_treasury/.grafana/provisioning/datasources/datasources.yaml,sha256=TGuZ9h4aHsDkDW39aSjoy9HZYwvht7zX_0oosAGdE98,427
32
+ dao_treasury/sorting/__init__.cp311-win_amd64.pyd,sha256=K0OwfCF8aRJ2cPq5t4cTYbD1TLvlHkOnidUAdVa__is,10752
33
+ dao_treasury/sorting/__init__.py,sha256=z3Bd2HUZjilZfV1cWSHUHagAPEPGyI0S8h6DtBf6w78,11448
34
+ dao_treasury/sorting/_matchers.cp311-win_amd64.pyd,sha256=Jf3u9eQTe3i3hw2RA7e29LNlZIqijhLOVfy_bweNh1k,10752
35
+ dao_treasury/sorting/_matchers.py,sha256=ACi6aXZCKW5OTiztsID7CXCGJounj5c6ivhOCg2436M,14392
36
+ dao_treasury/sorting/_rules.cp311-win_amd64.pyd,sha256=jsRhrWLOhe10xwle2cg-GUMPCF8E0sHt0iBg10udFFY,10752
37
+ dao_treasury/sorting/_rules.py,sha256=DxhdUgpS0q0LWeLl9W1Bjn5LZz9z4OLA03vQllPMH9k,9229
38
+ dao_treasury/sorting/factory.cp311-win_amd64.pyd,sha256=i98SUhA_kb7wyYOqghKyLa1mWgBv0lXPAM0YojZyDjU,10752
39
+ dao_treasury/sorting/factory.py,sha256=zlJ18xlMTxv8ACV6_MimCVIDsw3K5AZcyvKaNYY7R14,10484
40
+ dao_treasury/sorting/rule.cp311-win_amd64.pyd,sha256=_S3RF2vIzjsDe7V330EZK7eKt7C8JBB464eMpmphHmI,10752
41
+ dao_treasury/sorting/rule.py,sha256=wbL8s0-6dxcCKghUtEDSkLDBnyvggsJ3gt_RawQ6kB4,11972
42
+ dao_treasury/sorting/rules/__init__.cp311-win_amd64.pyd,sha256=KEH83Ia6RAmo1Phl5zQedQKEd5KqEfKmKlLXWjOaJsM,10752
43
+ dao_treasury/sorting/rules/__init__.py,sha256=hcLfejOEwD8RaM2RE-38Ej6_WkvL9BVGvIIGY848E6E,49
44
+ dao_treasury/sorting/rules/ignore/__init__.cp311-win_amd64.pyd,sha256=TUcCLsbINFEULPu-LttiHbWLwC_xOXbXvAryu2nAgmM,10752
45
+ dao_treasury/sorting/rules/ignore/__init__.py,sha256=16THKoGdj6qfkkytuCFVG_R1M6KSErMI4AVE1p0ukS4,58
46
+ dao_treasury/sorting/rules/ignore/llamapay.cp311-win_amd64.pyd,sha256=vmHBl6ISIERhg-svL_on-2re5DU2UH-idfrBQ78wEpg,10752
47
+ dao_treasury/sorting/rules/ignore/llamapay.py,sha256=aYyAJRlmv419IeaqkcV5o3ffx0UVfteU0lTl80j0BGo,783
48
+ dao_treasury/streams/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ dao_treasury/streams/llamapay.py,sha256=rO1Mh2ndTziR6pnRkKHnQ22a_Yx9PM_-BG7I4dspEZ8,13535
50
+ dao_treasury-0.1.1.dist-info/METADATA,sha256=mJmkyOOAPKNQD6_VxkS-TzRCLT9DJtpPVP2xyii3lOA,8306
51
+ dao_treasury-0.1.1.dist-info/WHEEL,sha256=JLOMsP7F5qtkAkINx5UnzbFguf8CqZeraV8o04b0I8I,101
52
+ dao_treasury-0.1.1.dist-info/top_level.txt,sha256=CV8aYytuSYplDhLVY4n0GphckdysXCd1lHmbqfsPxNk,33
53
+ dao_treasury-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ dao_treasury
2
+ dao_treasury__mypyc
Binary file