diff --git a/src/interfaces/IAssetPool.sol b/src/interfaces/IAssetPool.sol index 7e57df1..e976de3 100644 --- a/src/interfaces/IAssetPool.sol +++ b/src/interfaces/IAssetPool.sol @@ -151,6 +151,8 @@ interface IAssetPool { error RebalanceMismatch(); /// @notice Thrown when a user attempts to interact with an LP's rebalance error InvalidCycleRequest(); + /// @notice Thrown when an LP tries to settle a rebalance before the rebalance ends + error RebalancingInProgress(); // -------------------------------------------------------------------------------- // USER ACTIONS @@ -208,6 +210,11 @@ interface IAssetPool { */ function rebalancePool(address lp, uint256 rebalancePrice, uint256 amount, bool isDeposit) external; + /** + * @notice Settle the pool if the rebalance window has expired and pool is not fully rebalanced. + */ + function settlePool() external; + /** * @notice When there is nothing to rebalance, start the new cycle */ diff --git a/src/protocol/AssetPool.sol b/src/protocol/AssetPool.sol index 9f933a5..d2b9b04 100644 --- a/src/protocol/AssetPool.sol +++ b/src/protocol/AssetPool.sol @@ -403,6 +403,17 @@ contract AssetPool is IAssetPool, Ownable, Pausable { } } + /** + * @notice Settle the pool if the rebalance window has expired and pool is not fully rebalanced. + * ToDo: Slash the LPs who didn't rebalance within the rebalance window, rebalance the pool and start the next cycle + */ + function settlePool() external { + if (cycleState != CycleState.REBALANCING) revert InvalidCycleState(); + if (block.timestamp < nextRebalanceEndDate) revert RebalancingInProgress(); + + _startNewCycle(); + } + /** * @notice If there is nothing to rebalance, start the next cycle. */