Skip to content

Comments

Tweak price max step#126

Merged
heswithme merged 4 commits intoinvariant-changefrom
tweak-price-max-step
Dec 30, 2025
Merged

Tweak price max step#126
heswithme merged 4 commits intoinvariant-changefrom
tweak-price-max-step

Conversation

@heswithme
Copy link
Member

Repurpose adjustment_step to become upper boundary in tweak_price, instead of current lower limit

Copilot AI review requested due to automatic review settings December 30, 2025 11:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR repurposes the adjustment_step parameter from a lower boundary to an upper boundary in the tweak_price function. The key change is replacing max with min when calculating the effective adjustment step, which fundamentally alters how aggressively the pool rebalances its price scale toward the oracle price.

Key Changes

  • Changed adjustment_step from lower limit (max) to upper limit (min) in price rebalancing logic
  • Updated adjustment_step default value from 146000000000000 to int(10 / 100 * 10**18) (10%) in test configurations
  • Updated titanoboa dependency from git source (0.2.7) to PyPI registry (0.2.8)

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
contracts/main/Twocrypto.vy Changed max to min in adjustment_step calculation to make it an upper boundary instead of lower limit
tests/unitary/stableswap_math/test_get_y.py Updated adjustment_step to 10% (from 146000000000000) to align with new upper boundary semantics
tests/unitary/pool/test_oracles.py Changed max to min in test to match the new algorithm behavior
tests/conftest.py Updated adjustment_step default parameter to 10% for consistency across tests
tests/unitary/pool/test_donation.py Reduced donation amounts (R_DONATE from 0.01 to 0.001, donation_amount from 40,000 to 4,000) to accommodate new rebalancing dynamics
tests/unitary/pool/test_claim_admin_fees.py Relaxed test tolerances from 1e-8 to 1e-2 to account for different numerical behavior with new algorithm
pyproject.toml Updated titanoboa from git source (0.2.7) to PyPI registry version (0.2.8) and commented out git source configuration
uv.lock Updated lock file to reflect titanoboa 0.2.8 from PyPI with package hashes and metadata

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# vp-defined rate and absolute values must match
assert estimated_profit_admin_vp_rated == pytest.approx(
estimated_profit_admin_absolute, rel=1e-8
estimated_profit_admin_absolute, rel=1e-2
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The tolerance has been relaxed from 1e-8 (0.00000001%) to 1e-2 (1%), which is a significant change - four orders of magnitude less precise. This dramatic relaxation in test precision suggests that the changes to adjustment_step calculation may be introducing larger numerical errors or different rebalancing behavior. Consider investigating whether this tolerance relaxation is masking a more fundamental issue with the new min-based calculation, or if it's an expected consequence of the algorithm change that should be documented.

Copilot uses AI. Check for mistakes.
value_received = sum(receiver_values_post) - sum(receiver_values_init)

assert value_received == pytest.approx(estimated_profit_admin, rel=1e-8)
assert value_received == pytest.approx(estimated_profit_admin, rel=1e-2)
Copy link

Copilot AI Dec 30, 2025

Choose a reason for hiding this comment

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

The tolerance has been relaxed from 1e-8 (0.00000001%) to 1e-2 (1%), which is a significant change - four orders of magnitude less precise. This dramatic relaxation in test precision suggests that the changes to adjustment_step calculation may be introducing larger numerical errors or different rebalancing behavior. Consider investigating whether this tolerance relaxation is masking a more fundamental issue with the new min-based calculation, or if it's an expected consequence of the algorithm change that should be documented.

Copilot uses AI. Check for mistakes.
@heswithme heswithme merged commit 14cfbb1 into invariant-change Dec 30, 2025
2 of 4 checks passed
@heswithme heswithme deleted the tweak-price-max-step branch December 30, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant