Skip to content

Commit

Permalink
added deposit cap
Browse files Browse the repository at this point in the history
  • Loading branch information
ControlCplusControlV committed Jul 23, 2024
1 parent c7d86f9 commit 91f86a7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/FoldCaptiveStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ contract FoldCaptiveStaking is Owned(msg.sender) {
error ZeroLiquidity();
error WithdrawFailed();
error WithdrawProRata();
error DepositCapReached();

/// @param _positionManager The Canonical UniswapV3 PositionManager
/// @param _pool The FOLD Pool to Reward
Expand Down Expand Up @@ -134,6 +135,9 @@ contract FoldCaptiveStaking is Owned(msg.sender) {
/// @dev For keeping track of positions fees
uint256 public token1FeesPerLiquidity;

/// @dev The cap on deposits in the pool in liquidity, set to 0 if no cap
uint256 public depositCap;

/*//////////////////////////////////////////////////////////////
CHEF
//////////////////////////////////////////////////////////////*/
Expand Down Expand Up @@ -199,6 +203,10 @@ contract FoldCaptiveStaking is Owned(msg.sender) {
balances[msg.sender].amount += liquidity;
liquidityUnderManagement += uint256(liquidity);

if (liquidityUnderManagement > depositCap && depositCap != 0) {
revert DepositCapReached();
}

emit Deposit(msg.sender, amount0, amount1);
}

Expand Down Expand Up @@ -327,6 +335,14 @@ contract FoldCaptiveStaking is Owned(msg.sender) {
token1FeesPerLiquidity += amount1Collected;
}

/*//////////////////////////////////////////////////////////////
OWNER CONTROLS
//////////////////////////////////////////////////////////////*/
/// @param _newCap The new deposit cap, measured in liquidity
function setDepositCap(uint256 _newCap) public onlyOwner {
depositCap = _newCap;
}

/// @notice Allows the owner to claim insurance in case of relay outage
/// @param liquidity The amount of liquidity to claim
function claimInsurance(uint128 liquidity) external onlyOwner {
Expand Down

0 comments on commit 91f86a7

Please sign in to comment.