Skip to content

Commit

Permalink
refactor(contracts): ability to relock exppried tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtekgrinder committed Dec 11, 2023
1 parent 53d17d1 commit c8eca37
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions contracts/src/Pounders/abstracts/APounder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
ISwapper(swapper).swap(tokens, callDatas);
}

/**
* @dev Updates the Delegatee & delegates the voting power
* @param _delegatee Address of the delegatee
*/
function _setDelegate(address _delegatee) internal virtual;

/**
* @notice Updates the Delegatee & delegates the voting power
* @param _delegatee Address of the delegatee
Expand All @@ -120,31 +114,33 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
}

/*//////////////////////////////////////////////////////////////
LOCK
LOCK LOGIC
//////////////////////////////////////////////////////////////*/

function _lock(uint256 amount) internal virtual;

function _unlock() internal virtual;

function _unlock(uint256 amount) internal {
_unlock();
_unlock(false);

uint256 balance = asset.balanceOf(address(this));
if (amount < balance) {
_lock(balance - amount);
}
}

function _lockedBalances() internal view virtual returns (ILocker.LockedBalance[] memory);

/**
* @dev Locks the tokens in the vlToken contract
* @dev lock the tokens in the vlToken contract
*/
function lock() external whenNotPaused {
_lock(asset.balanceOf(address(this)));
}

/**
* @dev relock the tokens in the vlToken contract
*/
function relock() external whenNotPaused {
_unlock(true);
}

function deposit(uint256 amount, address receiver) external whenNotPaused nonReentrant {
if (amount == 0) revert Errors.ZeroAmount();
if (receiver == address(0)) revert Errors.ZeroAddress();
Expand Down Expand Up @@ -260,6 +256,22 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
SafeTransferLib.safeTransfer(address(asset), receiver, totalAssets);
}

/*//////////////////////////////////////////////////////////////
INTERNAL HOOKS LOGIC
//////////////////////////////////////////////////////////////*/

/**
* @dev Updates the Delegatee & delegates the voting power
* @param _delegatee Address of the delegatee
*/
function _setDelegate(address _delegatee) internal virtual;

function _lock(uint256 amount) internal virtual;

function _unlock(bool relock) internal virtual;

function _lockedBalances() internal view virtual returns (ILocker.LockedBalance[] memory);

/*//////////////////////////////////////////////////////////////
EMERGENCY/MIGRATION LOGIC
//////////////////////////////////////////////////////////////*/
Expand All @@ -280,7 +292,7 @@ abstract contract APounder is Owned2Step, ERC20, AIncentiveClaimer, AProtocolCla
* @notice Manually unlock CVX in the case of a mass unlock
*/
function unlock() external whenPaused onlyOwner {
_unlock();
_unlock(false);
}

/**
Expand Down

0 comments on commit c8eca37

Please sign in to comment.