Conversation
There was a problem hiding this comment.
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
146000000000000toint(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 |
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
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.
Repurpose adjustment_step to become upper boundary in tweak_price, instead of current lower limit