Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion allways/__init__.py
Original file line number Diff line number Diff line change
@@ -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]))
4 changes: 2 additions & 2 deletions allways/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
24 changes: 13 additions & 11 deletions tests/test_scoring_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np

from allways.constants import (
DIRECTION_POOLS,
MAX_SCORING_BACKFILL_BLOCKS,
RECYCLE_UID,
SCORING_WINDOW_BLOCKS,
Expand All @@ -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'
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.