feat: add OpenLiquidityStrategy for direct rebalancing#711
Merged
feat: add OpenLiquidityStrategy for direct rebalancing#711
Conversation
Add a new liquidity strategy where the caller of rebalance() acts as the liquidity source, providing tokens via ERC20 transfers instead of minting/burning through a reserve. Uses EIP-1153 transient storage to track the rebalancer address within a transaction. Includes full test suite (40 tests): admin, rebalance, and hook tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The rebalancer address comes from transient storage set by msg.sender in rebalance(), so the transferFrom source is not actually arbitrary. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rategy Add a virtual _beforeRebalance(pool) hook called at the start of rebalance() and make _getHookCalled internal instead of private. This allows OpenLiquidityStrategy to inherit rebalance() as-is and just override _beforeRebalance to store the caller, removing ~45 lines of duplicated logic and the _isHookCalled mirror function. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
philbow61
previously approved these changes
Mar 6, 2026
test/unit/liquidityStrategies/OpenLiquidityStrategy/OpenLiquidityStrategy_BaseTest.sol
Outdated
Show resolved
Hide resolved
test/unit/liquidityStrategies/OpenLiquidityStrategy/OpenLiquidityStrategy_Hook.t.sol
Outdated
Show resolved
Hide resolved
test/unit/liquidityStrategies/OpenLiquidityStrategy/OpenLiquidityStrategy_Hook.t.sol
Outdated
Show resolved
Hide resolved
test/unit/liquidityStrategies/OpenLiquidityStrategy/OpenLiquidityStrategy_Rebalance.t.sol
Outdated
Show resolved
Hide resolved
- Fix misleading comment "basis points to bps" -> "1e18-denominated to bps" - Fix incorrect liquiditySourceIncentiveContraction value (50 -> 0.005e18) in first rebalance test (was a copy-paste bug from ReserveLiquidityStrategy) - Remove duplicate hook tests that were identical to existing ones: - test_hook_expansionCallback_whenToken0IsDebt (dup of whenValidExpansion) - test_hook_contractionCallback_whenToken0IsDebt (dup of whenValidContraction) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
philbow61
previously approved these changes
Mar 6, 2026
nvtaveras
reviewed
Mar 10, 2026
philbow61
approved these changes
Mar 10, 2026
nvtaveras
approved these changes
Mar 10, 2026
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
OpenLiquidityStrategy, a new liquidity strategy where the caller ofrebalance()acts as the liquidity source via ERC20 transfers (no reserve minting/burning)tstore/tload) to track the rebalancer address within a transaction_clampExpansionand_clampContractionoverrides that check the rebalancer's token balance and adjust amounts accordinglyprotocolFeeRecipient, remaining tokens go to the rebalancerFiles
contracts/interfaces/IOpenLiquidityStrategy.sol— interface withOLS_OUT_OF_DEBT/OLS_OUT_OF_COLLATERALerrorscontracts/liquidityStrategies/OpenLiquidityStrategy.sol— full implementationtest/utils/harnesses/OpenLiquidityStrategyHarness.sol— test harnesstest/unit/liquidityStrategies/OpenLiquidityStrategy/— 40 tests (admin, rebalance, hook)Test plan
_handleCallback🤖 Generated with Claude Code