dao-treasury 0.0.34__cp312-cp312-win32.whl → 0.0.72__cp312-cp312-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.

Potentially problematic release.


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

Files changed (48) hide show
  1. dao_treasury/.grafana/provisioning/dashboards/breakdowns/Expenses.json +553 -0
  2. dao_treasury/.grafana/provisioning/dashboards/breakdowns/Revenue.json +555 -0
  3. dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml +7 -57
  4. dao_treasury/.grafana/provisioning/dashboards/streams/LlamaPay.json +124 -20
  5. dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json +284 -22
  6. dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json +47 -63
  7. dao_treasury/.grafana/provisioning/dashboards/transactions/Unsorted Transactions.json +368 -0
  8. dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow (Including Unsorted).json +122 -149
  9. dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json +87 -100
  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 +64 -78
  13. dao_treasury/ENVIRONMENT_VARIABLES.py +12 -0
  14. dao_treasury/__init__.py +14 -0
  15. dao_treasury/_docker.cp312-win32.pyd +0 -0
  16. dao_treasury/_docker.py +38 -21
  17. dao_treasury/_nicknames.cp312-win32.pyd +0 -0
  18. dao_treasury/_nicknames.py +15 -0
  19. dao_treasury/_wallet.cp312-win32.pyd +0 -0
  20. dao_treasury/_wallet.py +14 -10
  21. dao_treasury/constants.cp312-win32.pyd +0 -0
  22. dao_treasury/constants.py +24 -0
  23. dao_treasury/db.py +116 -25
  24. dao_treasury/docker-compose.yaml +1 -5
  25. dao_treasury/main.py +39 -1
  26. dao_treasury/sorting/__init__.cp312-win32.pyd +0 -0
  27. dao_treasury/sorting/_matchers.cp312-win32.pyd +0 -0
  28. dao_treasury/sorting/_rules.cp312-win32.pyd +0 -0
  29. dao_treasury/sorting/factory.cp312-win32.pyd +0 -0
  30. dao_treasury/sorting/rule.cp312-win32.pyd +0 -0
  31. dao_treasury/sorting/rule.py +8 -10
  32. dao_treasury/sorting/rules/__init__.cp312-win32.pyd +0 -0
  33. dao_treasury/sorting/rules/ignore/__init__.cp312-win32.pyd +0 -0
  34. dao_treasury/sorting/rules/ignore/llamapay.cp312-win32.pyd +0 -0
  35. dao_treasury/streams/__init__.cp312-win32.pyd +0 -0
  36. dao_treasury/streams/llamapay.cp312-win32.pyd +0 -0
  37. dao_treasury/streams/llamapay.py +14 -2
  38. dao_treasury/treasury.py +37 -16
  39. dao_treasury/types.cp312-win32.pyd +0 -0
  40. {dao_treasury-0.0.34.dist-info → dao_treasury-0.0.72.dist-info}/METADATA +18 -3
  41. dao_treasury-0.0.72.dist-info/RECORD +55 -0
  42. dao_treasury-0.0.72.dist-info/top_level.txt +2 -0
  43. dao_treasury__mypyc.cp312-win32.pyd +0 -0
  44. bf2b4fe1f86ad2ea158b__mypyc.cp312-win32.pyd +0 -0
  45. dao_treasury/.grafana/provisioning/dashboards/treasury/Treasury.json +0 -2018
  46. dao_treasury-0.0.34.dist-info/RECORD +0 -51
  47. dao_treasury-0.0.34.dist-info/top_level.txt +0 -2
  48. {dao_treasury-0.0.34.dist-info → dao_treasury-0.0.72.dist-info}/WHEEL +0 -0
dao_treasury/db.py CHANGED
@@ -3,6 +3,7 @@
3
3
  Database models and utilities for DAO treasury reporting.
4
4
 
5
5
  This module defines Pony ORM entities for:
6
+
6
7
  - Blockchain networks (:class:`Chain`)
7
8
  - On-chain addresses (:class:`Address`)
8
9
  - ERC-20 tokens and native coin placeholder (:class:`Token`)
@@ -17,27 +18,41 @@ and creating SQL views for reporting.
17
18
 
18
19
  import typing
19
20
  from asyncio import Semaphore
21
+ from collections import OrderedDict
20
22
  from decimal import Decimal, InvalidOperation
21
23
  from functools import lru_cache
22
24
  from logging import getLogger
23
25
  from os import path
24
26
  from pathlib import Path
25
- from typing import TYPE_CHECKING, Dict, Final, Tuple, Union, final
27
+ from typing import (
28
+ TYPE_CHECKING,
29
+ Any,
30
+ Coroutine,
31
+ Dict,
32
+ Final,
33
+ Literal,
34
+ Tuple,
35
+ Union,
36
+ final,
37
+ overload,
38
+ )
26
39
  from datetime import date, datetime, time, timezone
27
40
 
41
+ import eth_portfolio
28
42
  from a_sync import AsyncThreadPoolExecutor
29
43
  from brownie import chain
30
44
  from brownie.convert.datatypes import HexString
31
45
  from brownie.exceptions import EventLookupError
32
46
  from brownie.network.event import EventDict, _EventItem
33
47
  from brownie.network.transaction import TransactionReceipt
34
- from eth_typing import ChecksumAddress, HexAddress, HexStr
35
48
  from eth_portfolio.structs import (
36
49
  InternalTransfer,
37
50
  LedgerEntry,
38
51
  TokenTransfer,
39
52
  Transaction,
40
53
  )
54
+ from eth_retry import auto_retry
55
+ from eth_typing import ChecksumAddress, HexAddress, HexStr
41
56
  from pony.orm import (
42
57
  Database,
43
58
  InterfaceError,
@@ -53,6 +68,7 @@ from pony.orm import (
53
68
  select,
54
69
  )
55
70
  from y import EEE_ADDRESS, Contract, Network, convert, get_block_timestamp_async
71
+ from y._db.decorators import retry_locked
56
72
  from y.contracts import _get_code
57
73
  from y.exceptions import ContractNotVerified
58
74
 
@@ -60,6 +76,9 @@ from dao_treasury.constants import CHAINID
60
76
  from dao_treasury.types import TxGroupDbid, TxGroupName
61
77
 
62
78
 
79
+ EventItem = _EventItem[_EventItem[OrderedDict[str, Any]]]
80
+
81
+
63
82
  SQLITE_DIR = Path(path.expanduser("~")) / ".dao-treasury"
64
83
  """Path to the directory in the user's home where the DAO treasury SQLite database is stored."""
65
84
 
@@ -68,6 +87,7 @@ SQLITE_DIR.mkdir(parents=True, exist_ok=True)
68
87
 
69
88
  _INSERT_THREAD = AsyncThreadPoolExecutor(1)
70
89
  _SORT_THREAD = AsyncThreadPoolExecutor(1)
90
+ _EVENTS_THREADS = AsyncThreadPoolExecutor(16)
71
91
  _SORT_SEMAPHORE = Semaphore(50)
72
92
 
73
93
  _UTC = timezone.utc
@@ -234,6 +254,10 @@ class Address(DbEntity):
234
254
  def contract(self) -> Contract:
235
255
  return Contract(self.address)
236
256
 
257
+ @property
258
+ def contract_coro(self) -> Coroutine[Any, Any, Contract]:
259
+ return Contract.coroutine(self.address)
260
+
237
261
  @staticmethod
238
262
  @lru_cache(maxsize=None)
239
263
  def get_dbid(address: HexAddress) -> int:
@@ -294,7 +318,6 @@ class Address(DbEntity):
294
318
  )
295
319
 
296
320
  commit()
297
-
298
321
  return entity # type: ignore [no-any-return]
299
322
 
300
323
  @staticmethod
@@ -405,6 +428,10 @@ class Token(DbEntity):
405
428
  def contract(self) -> Contract:
406
429
  return Contract(self.address.address)
407
430
 
431
+ @property
432
+ def contract_coro(self) -> Coroutine[Any, Any, Contract]:
433
+ return Contract.coroutine(self.address.address)
434
+
408
435
  @property
409
436
  def scale(self) -> int:
410
437
  """Base for division according to `decimals`, e.g., `10**decimals`.
@@ -719,6 +746,10 @@ class TreasuryTx(DbEntity):
719
746
  """Human-readable label for the sender address."""
720
747
  return self.from_address.nickname or self.from_address.address # type: ignore [union-attr]
721
748
 
749
+ @property
750
+ def token_address(self) -> ChecksumAddress:
751
+ return self.token.address.address
752
+
722
753
  @property
723
754
  def symbol(self) -> str:
724
755
  """Ticker symbol for the transferred token."""
@@ -729,7 +760,23 @@ class TreasuryTx(DbEntity):
729
760
  """Decoded event logs for this transaction."""
730
761
  return self._transaction.events
731
762
 
732
- def get_events(self, event_name: str) -> _EventItem:
763
+ async def events_async(self) -> EventDict:
764
+ """Asynchronously fetch decoded event logs for this transaction."""
765
+ tx = self._transaction
766
+ events = tx._events
767
+ if events is None:
768
+ events = await _EVENTS_THREADS.run(getattr, tx, "events")
769
+ return events
770
+
771
+ @overload
772
+ def get_events(
773
+ self, event_name: str, sync: Literal[False]
774
+ ) -> Coroutine[Any, Any, EventItem]: ...
775
+ @overload
776
+ def get_events(self, event_name: str, sync: bool = True) -> EventItem: ...
777
+ def get_events(self, event_name: str, sync: bool = True) -> EventItem:
778
+ if not sync:
779
+ return _EVENTS_THREADS.run(self.get_events, event_name)
733
780
  try:
734
781
  return self.events[event_name]
735
782
  except EventLookupError:
@@ -746,6 +793,7 @@ class TreasuryTx(DbEntity):
746
793
  return get_transaction(self.hash)
747
794
 
748
795
  @staticmethod
796
+ @auto_retry
749
797
  async def insert(entry: LedgerEntry) -> None:
750
798
  """Asynchronously insert and sort a ledger entry.
751
799
 
@@ -863,27 +911,48 @@ class TreasuryTx(DbEntity):
863
911
  },
864
912
  ) from e
865
913
  except InvalidOperation as e:
866
- logger.error(e)
867
- logger.error(
868
- {
869
- "chain": Chain.get_dbid(CHAINID),
870
- "block": entry.block_number,
871
- "timestamp": ts,
872
- "hash": entry.hash.hex(),
873
- "log_index": log_index,
874
- "from_address": from_address,
875
- "to_address": to_address,
876
- "token": token,
877
- "amount": entry.value,
878
- "price": entry.price,
879
- "value_usd": entry.value_usd,
880
- # TODO: nuke db and add this column
881
- # gas = gas,
882
- "gas_used": gas_used,
883
- "gas_price": gas_price,
884
- "txgroup": txgroup_dbid,
885
- }
886
- )
914
+ with db_session:
915
+ from_address_entity = Address[from_address]
916
+ to_address_entity = Address[to_address]
917
+ token_entity = Token[token]
918
+ logger.error(e)
919
+ logger.error(
920
+ {
921
+ "chain": Chain.get_dbid(CHAINID),
922
+ "block": entry.block_number,
923
+ "timestamp": ts,
924
+ "hash": entry.hash.hex(),
925
+ "log_index": log_index,
926
+ "from_address": {
927
+ "dbid": from_address,
928
+ "address": from_address_entity.address,
929
+ "nickname": from_address_entity.nickname,
930
+ },
931
+ "to_address": {
932
+ "dbid": to_address,
933
+ "address": to_address_entity.address,
934
+ "nickname": to_address_entity.nickname,
935
+ },
936
+ "token": {
937
+ "dbid": token,
938
+ "address": token_entity.address.address,
939
+ "name": token_entity.name,
940
+ "symbol": token_entity.symbol,
941
+ "decimals": token_entity.decimals,
942
+ },
943
+ "amount": entry.value,
944
+ "price": entry.price,
945
+ "value_usd": entry.value_usd,
946
+ # TODO: nuke db and add this column
947
+ # gas = gas,
948
+ "gas_used": gas_used,
949
+ "gas_price": gas_price,
950
+ "txgroup": {
951
+ "dbid": txgroup_dbid,
952
+ "fullname": TxGroup[txgroup_dbid].fullname,
953
+ },
954
+ }
955
+ )
887
956
  return None
888
957
  except TransactionIntegrityError as e:
889
958
  return _validate_integrity_error(entry, log_index)
@@ -902,6 +971,7 @@ class TreasuryTx(DbEntity):
902
971
  return dbid # type: ignore [no-any-return]
903
972
 
904
973
  @staticmethod
974
+ @retry_locked
905
975
  def __set_txgroup(treasury_tx_dbid: int, txgroup_dbid: TxGroupDbid) -> None:
906
976
  with db_session:
907
977
  TreasuryTx[treasury_tx_dbid].txgroup = txgroup_dbid
@@ -1361,3 +1431,24 @@ def _validate_integrity_error(
1361
1431
  )
1362
1432
  else None
1363
1433
  )
1434
+
1435
+
1436
+ def _drop_shitcoin_txs() -> None:
1437
+ """
1438
+ Purge any shitcoin txs from the db.
1439
+
1440
+ These should not be frequent, and only occur if a user populated the db before a shitcoin was added to the SHITCOINS mapping.
1441
+ """
1442
+ shitcoins = eth_portfolio.SHITCOINS[CHAINID]
1443
+ with db_session:
1444
+ shitcoin_txs = select(
1445
+ tx for tx in TreasuryTx if tx.token.address.address in shitcoins
1446
+ )
1447
+ if count := shitcoin_txs.count():
1448
+ logger.info(f"Purging {count} shitcoin txs from the database...")
1449
+ for tx in shitcoin_txs:
1450
+ tx.delete()
1451
+ logger.info("Shitcoin tx purge complete.")
1452
+
1453
+
1454
+ _drop_shitcoin_txs()
@@ -3,12 +3,9 @@ networks:
3
3
  docker_eth_portfolio:
4
4
  external: true
5
5
 
6
- volumes:
7
- grafana_data: {}
8
-
9
6
  services:
10
7
  grafana:
11
- image: grafana/grafana:10.2.0
8
+ image: grafana/grafana:12.2.1
12
9
  ports:
13
10
  - 127.0.0.1:${DAO_TREASURY_GRAFANA_PORT:-3004}:3000
14
11
  environment:
@@ -24,7 +21,6 @@ services:
24
21
  - GF_INSTALL_PLUGINS=volkovlabs-variable-panel,frser-sqlite-datasource
25
22
  volumes:
26
23
  - ~/.dao-treasury/:/app/dao-treasury-data
27
- - grafana_data:/var/lib/grafana
28
24
  - ./.grafana/provisioning/:/etc/grafana/provisioning/
29
25
  networks:
30
26
  - dao_treasury
dao_treasury/main.py CHANGED
@@ -97,6 +97,12 @@ parser.add_argument(
97
97
  help="The time interval between datapoints. default: 1d",
98
98
  default="1d",
99
99
  )
100
+ parser.add_argument(
101
+ "--concurrency",
102
+ type=int,
103
+ help="The max number of historical blocks to export concurrently. default: 30",
104
+ default=30,
105
+ )
100
106
  parser.add_argument(
101
107
  "--daemon",
102
108
  action="store_true",
@@ -119,6 +125,18 @@ parser.add_argument(
119
125
  help="Port for the Grafana rendering service. Default: 8091",
120
126
  default=8091,
121
127
  )
128
+ parser.add_argument(
129
+ "--custom-bucket",
130
+ type=str,
131
+ action="append",
132
+ help=(
133
+ "Custom bucket mapping for a wallet address. "
134
+ "Specify as 'address:bucket_name'. "
135
+ "Can be used multiple times. Example: "
136
+ "--custom-bucket '0x123:My Bucket' --custom-bucket '0x456:Other Bucket'"
137
+ ),
138
+ default=None,
139
+ )
122
140
 
123
141
  args = parser.parse_args()
124
142
 
@@ -203,7 +221,27 @@ async def export(args) -> None:
203
221
  for address in addresses:
204
222
  db.Address.set_nickname(address, nickname)
205
223
 
206
- treasury = Treasury(wallets, args.sort_rules, asynchronous=True)
224
+ # Parse custom_buckets from --custom-bucket arguments
225
+ custom_buckets = None
226
+ if args.custom_bucket:
227
+ custom_buckets = {}
228
+ for item in args.custom_bucket:
229
+ if ":" not in item:
230
+ parser.error(
231
+ f"Invalid format for --custom-bucket: '{item}'. Must be 'address:bucket_name'."
232
+ )
233
+ address, bucket = item.split(":", 1)
234
+ address = address.strip()
235
+ bucket = bucket.strip()
236
+ if not address or not bucket:
237
+ parser.error(
238
+ f"Invalid format for --custom-bucket: '{item}'. Both address and bucket_name are required."
239
+ )
240
+ custom_buckets[address] = bucket
241
+
242
+ treasury = Treasury(
243
+ wallets, args.sort_rules, custom_buckets=custom_buckets, asynchronous=True
244
+ )
207
245
 
208
246
  # Start only the requested containers
209
247
  if args.start_renderer is True:
Binary file
Binary file
@@ -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.34
3
+ Version: 0.0.72
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,7 @@ 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.1
18
18
  Dynamic: classifier
19
19
  Dynamic: description
20
20
  Dynamic: description-content-type
@@ -29,6 +29,7 @@ DAO Treasury is a comprehensive financial reporting and treasury management solu
29
29
  - **Financial Reporting for DAOs:** Extends core portfolio functionalities to generate detailed reports tailored for on-chain organizations.
30
30
  - **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
31
  - **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.
32
+ - **Custom Buckets for Wallets:** Assign custom categories ("buckets") to specific wallet addresses for more granular reporting using the `--custom-bucket` CLI option.
32
33
  - **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
34
 
34
35
  ## Requirements
@@ -41,7 +42,7 @@ DAO Treasury is a comprehensive financial reporting and treasury management solu
41
42
  - 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
43
  - You must configure a [brownie network](https://eth-brownie.readthedocs.io/en/stable/network-management.html) to use your RPC.
43
44
  - 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.
45
+ - 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
46
 
46
47
  ## Installation
47
48
 
@@ -63,14 +64,28 @@ For local development (from source installation), use:
63
64
  poetry run dao-treasury run --wallet 0x123 --network mainnet --interval 12h
64
65
  ```
65
66
 
67
+ **Assigning Custom Buckets to Wallets:**
68
+
69
+ 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`:
70
+
71
+ ```bash
72
+ dao-treasury run --wallet 0x123 --network mainnet --custom-bucket "0x123:Operations" --custom-bucket "0x456:Grants" --custom-bucket "0x789:Investments"
73
+ ```
74
+
66
75
  **CLI Options:**
76
+ > Only optional arguments are listed here. Required arguments (such as `--wallet` or `--wallets`) are shown in the usage examples above.
77
+
67
78
  - `--network`: The id of the brownie network the exporter will connect to (default: mainnet)
68
79
  - `--interval`: The time interval between each data snapshot (default: 12h)
80
+ - `--concurrency`: The max number of historical blocks to export concurrently. (default: 30)
69
81
  - `--daemon`: Run the export process in the background (default: False) (NOTE: currently unsupported)
82
+ - `--sort-rules`: Directory containing sort rules definitions for transaction categorization.
83
+ - `--nicknames`: File containing address nicknames for reporting.
70
84
  - `--grafana-port`: Set the port for the Grafana dashboard where you can view data (default: 3004)
71
85
  - `--renderer-port`: Set the port for the report rendering service (default: 8091)
72
86
  - `--victoria-port`: Set the port for the Victoria metrics reporting endpoint (default: 8430)
73
87
  - `--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.
88
+ - `--custom-bucket`: Assign a custom bucket/category to a wallet address for reporting. Specify as `address:bucket_name`. Can be used multiple times.
74
89
 
75
90
  After running the command, the export script will run continuously until you close your terminal.
76
91
  To view the dashboards, just open your browser and navigate to [http://localhost:3004](http://localhost:3004)!