doublezero-revenue-distribution 0.0.2__tar.gz → 0.0.3__tar.gz

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 (17) hide show
  1. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/PKG-INFO +1 -1
  2. doublezero_revenue_distribution-0.0.3/examples/fetch.py +126 -0
  3. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/pyproject.toml +1 -1
  4. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/state.py +3 -3
  5. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/.gitignore +0 -0
  6. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/__init__.py +0 -0
  7. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/client.py +0 -0
  8. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/config.py +0 -0
  9. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/discriminator.py +0 -0
  10. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/oracle.py +0 -0
  11. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/pda.py +0 -0
  12. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/reserved.py +0 -0
  13. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/rpc.py +0 -0
  14. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/tests/__init__.py +0 -0
  15. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/tests/test_compat.py +0 -0
  16. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/tests/test_fixtures.py +0 -0
  17. {doublezero_revenue_distribution-0.0.2 → doublezero_revenue_distribution-0.0.3}/revdist/tests/test_pda.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: doublezero-revenue-distribution
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Summary: DoubleZero Revenue Distribution SDK
5
5
  Requires-Python: >=3.10
6
6
  Requires-Dist: base58>=2.1
@@ -0,0 +1,126 @@
1
+ #!/usr/bin/env python3
2
+ """Example CLI that fetches and displays revenue distribution data."""
3
+
4
+ import argparse
5
+ import sys
6
+
7
+ from revdist.client import Client
8
+
9
+
10
+ def main() -> None:
11
+ parser = argparse.ArgumentParser(description="Fetch revenue distribution data")
12
+ parser.add_argument(
13
+ "--env",
14
+ default="mainnet-beta",
15
+ choices=["mainnet-beta", "testnet", "devnet", "localnet"],
16
+ help="Environment to connect to",
17
+ )
18
+ parser.add_argument(
19
+ "--epoch",
20
+ type=int,
21
+ default=0,
22
+ help="Specific epoch to fetch distribution for (0 = use latest from config)",
23
+ )
24
+ args = parser.parse_args()
25
+
26
+ print(f"Fetching revenue distribution data from {args.env}...\n")
27
+
28
+ client = Client.from_env(args.env)
29
+
30
+ # Fetch program config
31
+ try:
32
+ config = client.fetch_config()
33
+ except Exception as e:
34
+ print(f"Error fetching config: {e}")
35
+ sys.exit(1)
36
+
37
+ print("=== Program Config ===")
38
+ print(f"Admin: {config.admin_key}")
39
+ print(f"Debt Accountant: {config.debt_accountant_key}")
40
+ print(f"Rewards Accountant: {config.rewards_accountant_key}")
41
+ print(f"Contributor Manager: {config.contributor_manager_key}")
42
+ print(f"Next Completed Epoch: {config.next_completed_dz_epoch}")
43
+ print()
44
+
45
+ print("=== Distribution Parameters ===")
46
+ print(f"Calculation Grace Period: {config.distribution_parameters.calculation_grace_period_minutes} minutes")
47
+ print(f"Initialization Grace: {config.distribution_parameters.initialization_grace_period_minutes} minutes")
48
+ print(f"Min Epoch Duration: {config.distribution_parameters.minimum_epoch_duration_to_finalize_rewards}")
49
+ print()
50
+
51
+ vfee = config.distribution_parameters.solana_validator_fee_parameters
52
+ print("=== Validator Fee Parameters ===")
53
+ print(f"Base Block Rewards: {vfee.base_block_rewards_pct / 100:.2f}%")
54
+ print(f"Priority Block Rewards: {vfee.priority_block_rewards_pct / 100:.2f}%")
55
+ print(f"Inflation Rewards: {vfee.inflation_rewards_pct / 100:.2f}%")
56
+ print(f"Jito Tips: {vfee.jito_tips_pct / 100:.2f}%")
57
+ print()
58
+
59
+ # Fetch distribution for a specific epoch
60
+ target_epoch = args.epoch
61
+ if target_epoch == 0 and config.next_completed_dz_epoch > 0:
62
+ target_epoch = config.next_completed_dz_epoch - 1
63
+
64
+ if target_epoch > 0:
65
+ try:
66
+ dist = client.fetch_distribution(target_epoch)
67
+ print(f"=== Distribution (epoch {dist.dz_epoch}) ===")
68
+ print(f"Community Burn Rate: {dist.community_burn_rate} ({dist.community_burn_rate / 1_000_000_000 * 100:.2f}%)")
69
+ print(f"Total Solana Validators: {dist.total_solana_validators}")
70
+ print(f"Validator Payments Count: {dist.solana_validator_payments_count}")
71
+ print(f"Total Validator Debt: {dist.total_solana_validator_debt} lamports")
72
+ print(f"Collected Validator Payments: {dist.collected_solana_validator_payments} lamports")
73
+ print(f"Total Contributors: {dist.total_contributors}")
74
+ print(f"Distributed Rewards Count: {dist.distributed_rewards_count}")
75
+ print(f"Collected Prepaid 2Z: {dist.collected_prepaid_2z_payments}")
76
+ print(f"2Z Converted from SOL: {dist.collected_2z_converted_from_sol}")
77
+ print(f"Distributed 2Z Amount: {dist.distributed_2z_amount}")
78
+ except Exception as e:
79
+ print(f"=== Distribution (epoch {target_epoch}) ===")
80
+ print(f" Not found or error: {e}")
81
+ print()
82
+
83
+ # Fetch journal
84
+ try:
85
+ journal = client.fetch_journal()
86
+ print("=== Journal ===")
87
+ print(f"Total SOL Balance: {journal.total_sol_balance} lamports")
88
+ print(f"Total 2Z Balance: {journal.total_2z_balance}")
89
+ print(f"Swapped SOL Amount: {journal.swapped_sol_amount} lamports")
90
+ print(f"Next Epoch to Sweep: {journal.next_dz_epoch_to_sweep_tokens}")
91
+ except Exception as e:
92
+ print("=== Journal ===")
93
+ print(f" Not found or error: {e}")
94
+ print()
95
+
96
+ # Fetch all validator deposits
97
+ try:
98
+ deposits = client.fetch_all_validator_deposits()
99
+ print(f"=== Validator Deposits ({len(deposits)}) ===")
100
+ for i, dep in enumerate(deposits[:10]):
101
+ print(f" {str(dep.node_id)[:16]}...: written off debt {dep.written_off_sol_debt}")
102
+ if len(deposits) > 10:
103
+ print(f" ... and {len(deposits) - 10} more")
104
+ except Exception as e:
105
+ print("=== Validator Deposits ===")
106
+ print(f" Error: {e}")
107
+ print()
108
+
109
+ # Fetch all contributor rewards
110
+ try:
111
+ rewards = client.fetch_all_contributor_rewards()
112
+ print(f"=== Contributor Rewards ({len(rewards)}) ===")
113
+ for i, r in enumerate(rewards[:10]):
114
+ print(f" {str(r.service_key)[:16]}...: rewards manager {str(r.rewards_manager_key)[:16]}...")
115
+ if len(rewards) > 10:
116
+ print(f" ... and {len(rewards) - 10} more")
117
+ except Exception as e:
118
+ print("=== Contributor Rewards ===")
119
+ print(f" Error: {e}")
120
+ print()
121
+
122
+ print("Done.")
123
+
124
+
125
+ if __name__ == "__main__":
126
+ main()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "doublezero-revenue-distribution"
3
- version = "0.0.2"
3
+ version = "0.0.3"
4
4
  description = "DoubleZero Revenue Distribution SDK"
5
5
  requires-python = ">=3.10"
6
6
  dependencies = [
@@ -10,7 +10,7 @@ from __future__ import annotations
10
10
  import struct
11
11
  from dataclasses import dataclass
12
12
 
13
- from borsh_incremental import IncrementalReader
13
+ from borsh_incremental import DefensiveReader
14
14
 
15
15
  from revdist.reserved import Reserved
16
16
  from solders.pubkey import Pubkey # type: ignore[import-untyped]
@@ -415,7 +415,7 @@ class ComputedSolanaValidatorDebts:
415
415
 
416
416
  @classmethod
417
417
  def from_bytes(cls, data: bytes) -> ComputedSolanaValidatorDebts:
418
- r = IncrementalReader(data)
418
+ r = DefensiveReader(data)
419
419
  blockhash = r.read_bytes(32)
420
420
  first_epoch = r.read_u64()
421
421
  last_epoch = r.read_u64()
@@ -458,7 +458,7 @@ class ShapleyOutputStorage:
458
458
 
459
459
  @classmethod
460
460
  def from_bytes(cls, data: bytes) -> ShapleyOutputStorage:
461
- r = IncrementalReader(data)
461
+ r = DefensiveReader(data)
462
462
  epoch = r.read_u64()
463
463
  count = r.read_u32()
464
464
  rewards = []