diff --git a/allways/__init__.py b/allways/__init__.py index 55a5dd34..d0079d02 100644 --- a/allways/__init__.py +++ b/allways/__init__.py @@ -1,3 +1,3 @@ -__version__ = '1.0.11' +__version__ = '1.0.12' version_split = __version__.split('.') __spec_version__ = (1000 * int(version_split[0])) + (10 * int(version_split[1])) + (1 * int(version_split[2])) diff --git a/allways/constants.py b/allways/constants.py index 3a1e460a..4cfbeab4 100644 --- a/allways/constants.py +++ b/allways/constants.py @@ -54,8 +54,8 @@ SCORING_EMA_ALPHA = 1.0 # Instantaneous — no smoothing across passes CREDIBILITY_WINDOW_BLOCKS = 216_000 # ~30 days DIRECTION_POOLS: dict[tuple[str, str], float] = { - ('tao', 'btc'): 0.5, - ('btc', 'tao'): 0.5, + ('tao', 'btc'): 0.25, + ('btc', 'tao'): 0.25, } # 100% → 1.0, 90% → 0.729, 80% → 0.512, 50% → 0.125 SUCCESS_EXPONENT: int = 3 diff --git a/pyproject.toml b/pyproject.toml index 33766a4c..68534776 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "allways" -version = "1.0.9" +version = "1.0.12" description = "Allways - Universal Transaction Layer: Trustless cross-chain swaps on Bittensor Subnet 7" license = "MIT" requires-python = ">=3.10,<3.15" diff --git a/tests/test_scoring_v1.py b/tests/test_scoring_v1.py index ecff2305..e60219f6 100644 --- a/tests/test_scoring_v1.py +++ b/tests/test_scoring_v1.py @@ -7,6 +7,7 @@ import numpy as np from allways.constants import ( + DIRECTION_POOLS, MAX_SCORING_BACKFILL_BLOCKS, RECYCLE_UID, SCORING_WINDOW_BLOCKS, @@ -28,8 +29,9 @@ ) from allways.validator.state_store import ReservationPin, ValidatorStateStore -POOL_TAO_BTC = 0.5 -POOL_BTC_TAO = 0.5 +# Mirror production pool shares so these stay in sync if DIRECTION_POOLS changes. +POOL_TAO_BTC = DIRECTION_POOLS[('tao', 'btc')] +POOL_BTC_TAO = DIRECTION_POOLS[('btc', 'tao')] MIN_COLLATERAL = 100_000_000 # 0.1 TAO METADATA_PATH = Path(__file__).parent.parent / 'allways' / 'metadata' / 'allways_swap_manager.json' @@ -1886,10 +1888,10 @@ def test_quarter_capacity_pays_quarter(self, tmp_path: Path): self.seed_tao_btc_crown(v, 'hk_a') rewards, _ = calculate_miner_rewards(v) np.testing.assert_allclose(rewards[0], POOL_TAO_BTC * 0.25, atol=1e-6) - # Pool conservation: hk_a got 0.125, btc→tao bucket fully recycles (0.5), - # plus capacity shortfall on tao→btc (0.375) → recycle = 0.875. + # Pool conservation: hk_a got POOL_TAO_BTC*0.25; the rest of both buckets + # and the unallocated pool all recycle, so recycle = 1 - that share. recycle_uid = RECYCLE_UID if RECYCLE_UID < len(rewards) else 0 - np.testing.assert_allclose(rewards[recycle_uid], 0.875, atol=1e-6) + np.testing.assert_allclose(rewards[recycle_uid], 1.0 - POOL_TAO_BTC * 0.25, atol=1e-6) np.testing.assert_allclose(rewards.sum(), 1.0, atol=1e-6) v.state_store.close() @@ -1939,10 +1941,10 @@ def test_unequal_collateral_proportional_rewards(self, tmp_path: Path): ) conn.commit() rewards, _ = calculate_miner_rewards(v) - # Both split crown 50/50. A's capacity = 1.0, B's = 0.2. Direction pool = 0.5. - # A earns 0.5 * 0.5 * 1.0 = 0.25; B earns 0.5 * 0.5 * 0.2 = 0.05. - np.testing.assert_allclose(rewards[0], 0.25, atol=1e-6) - np.testing.assert_allclose(rewards[1], 0.05, atol=1e-6) + # Both split crown 50/50. A's capacity = 1.0, B's = 0.2. + # A earns pool * 0.5 * 1.0; B earns pool * 0.5 * 0.2. + np.testing.assert_allclose(rewards[0], POOL_TAO_BTC * 0.5 * 1.0, atol=1e-6) + np.testing.assert_allclose(rewards[1], POOL_TAO_BTC * 0.5 * 0.2, atol=1e-6) v.state_store.close() def test_cold_start_max_swap_zero_is_fail_safe(self, tmp_path: Path): @@ -2326,8 +2328,8 @@ def test_both_factors_compose_multiplicatively(self, tmp_path: Path): to_chain='btc', ) rewards, _ = calculate_miner_rewards(v) - # A: pool 0.5 × crown 1.0 × sr 1.0 × capacity 0.5 × volume_factor 0.5 - np.testing.assert_allclose(rewards[0], 0.5 * 1.0 * 1.0 * 0.5 * 0.5, atol=1e-6) + # A: pool × crown 1.0 × sr 1.0 × capacity 0.5 × volume_factor 0.5 + np.testing.assert_allclose(rewards[0], POOL_TAO_BTC * 1.0 * 1.0 * 0.5 * 0.5, atol=1e-6) v.state_store.close() def test_full_pool_conservation_with_all_factors(self, tmp_path: Path): diff --git a/uv.lock b/uv.lock index cc106e3e..4f144b3e 100644 --- a/uv.lock +++ b/uv.lock @@ -164,7 +164,7 @@ wheels = [ [[package]] name = "allways" -version = "1.0.9" +version = "1.0.12" source = { editable = "." } dependencies = [ { name = "base58" },