Skip to content

Commit

Permalink
feat: add settlePool function
Browse files Browse the repository at this point in the history
  • Loading branch information
bhargavaparoksham committed Jan 20, 2025
1 parent 1033581 commit 103a037
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/interfaces/IAssetPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down
11 changes: 11 additions & 0 deletions src/protocol/AssetPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 103a037

Please sign in to comment.