feat(fees): inbound discount protection and global rebalance guard - #45
Merged
Conversation
- Cap inbound fee discounts to prevent unprofitable routing against exit channels - Implement dynamic ar_out_target locking in fee_adjuster.py when inbound discounts are active - Add standalone rebalance_guard.py auditor to protect all 112 channels across native LNDg and fee_adjuster - Add full unit test coverage using TDD (23 passing tests) - Update documentation and feeConfig.json.example
- Make max_inbound_discount_ppm optional (null for unlimited discount) - Keep lock_ar_out_target_on_discount active independently - Add README documentation for rebalance_guard.py - Add unit test for disabled locking
- Persist original channel ar_out_target values in data/rebalance_targets_baseline.json - Restore each channel to its specific baseline target upon liquidity recovery - Fall back to default_restored_ar_out_target only when baseline is unknown - Add unit tests for custom baseline restorations (26 passing tests)
- Prevent restoring intentionally unmanaged 100% channels (like bfx-lnd0) - Only trigger RESTORE when a channel is recorded in baseline_map with a baseline < 100% - Add test coverage for unmanaged 100% channels
…els into fee_adjuster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
1. Inbound Fee Discount Protection & Rebalance Guard
Other/fee_adjuster.pyand dedicated daemon/standalone runnerOther/rebalance_guard.py.ar_out_targetis automatically set to100%(disabling outbound rebalancing on that channel).fee_adjuster_baseline_ar_out_target) before locking.2. Dynamic Hysteresis & Unlock Condition
3. Global Rebalance Guard
4. Comprehensive Test Suites & CI
tests/test_rebalance_guard.py(6 tests).tests/test_fee_adjuster.py(14 tests).