Skip to content

Conversation

@gztensor
Copy link
Contributor

Description

No root sell when EMA prices sum up to lower than 1.0.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run cargo fmt and cargo clippy to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@gztensor gztensor added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Oct 16, 2025
@gztensor gztensor marked this pull request as draft October 16, 2025 17:06
@gztensor gztensor marked this pull request as ready for review October 16, 2025 17:12
camfairchild
camfairchild previously approved these changes Oct 16, 2025
// Prices are low => we limit tao issued (buy alpha with it)
let tao_issued = TaoCurrency::from(((0.1 + 0.2) * emission as f64) as u64);
assert_abs_diff_eq!(
TotalIssuance::<Test>::get(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issuance should increase by the full emission, no? We should still be emitting the same amount of TAO. It's just where it goes that is different.

@gztensor gztensor marked this pull request as draft October 16, 2025 20:04
@gztensor gztensor marked this pull request as ready for review October 17, 2025 20:48
camfairchild
camfairchild previously approved these changes Oct 17, 2025
);
if price_i < tao_in_ratio {
if subsidy_mode {
tao_in_i = price_i.saturating_mul(U96F32::saturating_from_num(block_emission));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tao_in_i should only be changed for subnets where ALPHA price < TAO emissions (EMA / sum of EMAs), otherwise it would inject more TAO, and would result in more than 1 TAO/block being emitted. The only reason to change the tao_in_i according to the ALPHA price * Block Emission is so that one can calculate how much TAO should be used to swap for ALPHA (to bring the ALPHA price back up).

Here a scenario:

SoS is 0.8 and there is a subnet A that is overpriced, so ALPHA price is 0.5 while TAO emissions are 0.25, the chain would inject 0.5 TAO into the subnet because it looks at ALPHA price * Block Emission, instead of the 0.25 TAO that he should get based on TAO emissions. The difference_tao_in would clamp to 0 because it would be otherwise negative (tao_in > default_tao_in). Then subnet B has 0.75 TAO emissions but an ALPHA price of 0.3, so the chain would use 0.3 TAO to inject, and 0.45 TAO to swap for ALPHA to push ALPHA price towards TAO emissions (still using 0.75 TAO in total).

Thus subnet A gets 0.5 TAO and subnet B gets 0.75 TAO, so the chain emits 1.25 TAO/block

If one were to use ALPHA prices only as commented at line 38 I think this wouldn't happen, because then there is no discrepancy between ALPHA price and EMA price, as only ALPHA price is used.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason to downscale TAO is if ALPHA needs to be downscaled, so that the injections can maintain the price, while the difference_tao_in is used to swap for ALPHA (increasing the ALPHA price towards TAO emissions), which it doesn't when ALPHA price > TAO emissions

// Sell root emission through the pool (do not pay fees)
let subsidized: bool = *is_subsidized.get(netuid_i).unwrap_or(&false);
if !subsidized {
if !subsidy_mode {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That could technically stay so that the root proportion on "overpriced" subnets (ALPHA price > TAO emissions) is not countering the SoS to increase at/above 1

}
// Insert values into maps
tao_in.insert(*netuid_i, tao_in_i);
tao_issued.insert(*netuid_i, default_tao_in_i);
Copy link

@mcjkula mcjkula Oct 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented above that wouldn't be true, when ALPHA price > TAO emissions, with the global subsidy, because the tao_in_i (ALPHA price * Block Emission) would be larger than default_tao_in_i (which is based on EMA price).

@gztensor gztensor marked this pull request as draft October 20, 2025 19:01
@gztensor
Copy link
Contributor Author

Closing in favor of #2096 fix

@gztensor gztensor closed this Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants