From f0aee47ac5c9cf9467de5a910cb59c5399100a44 Mon Sep 17 00:00:00 2001 From: 3xHarry Date: Mon, 10 Apr 2023 20:59:37 +0200 Subject: [PATCH] fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/122 --- src/v2/Carousel/Carousel.sol | 25 ++++++++++++++++++++++--- src/v2/VaultV2.sol | 1 + 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/v2/Carousel/Carousel.sol b/src/v2/Carousel/Carousel.sol index d968c05f..ecf000be 100644 --- a/src/v2/Carousel/Carousel.sol +++ b/src/v2/Carousel/Carousel.sol @@ -571,16 +571,35 @@ contract Carousel is VaultV2 { ADMIN FUNCTIONS //////////////////////////////////////////////////////////////*/ + /** + @notice This function is called by the controller if the epoch has started, but the counterparty vault has no value. In this case the users can withdraw their deposit. Additionally, emissions are transferred to the treasury. + @param _id uint256 identifier of the epoch + */ + function setEpochNull(uint256 _id) + public + override + onlyController + epochIdExists(_id) + epochHasEnded(_id) + { + epochNull[_id] = true; + if(emissions[_id] > 0) { + emissionsToken.safeTransfer(treasury(), emissions[_id]); + emissions[_id] = 0; + } + } + + /** @notice sets emissions * @param _epochId epoch id - * @param _emissionsRate emissions rate + * @param _emissionAmount emissions rate */ - function setEmissions(uint256 _epochId, uint256 _emissionsRate) + function setEmissions(uint256 _epochId, uint256 _emissionAmount) external onlyFactory epochIdExists(_epochId) { - emissions[_epochId] = _emissionsRate; + emissions[_epochId] = _emissionAmount; } /** @notice changes relayer fee diff --git a/src/v2/VaultV2.sol b/src/v2/VaultV2.sol index b9979db4..098365b9 100644 --- a/src/v2/VaultV2.sol +++ b/src/v2/VaultV2.sol @@ -325,6 +325,7 @@ contract VaultV2 is IVaultV2, SemiFungibleVault, ReentrancyGuard { */ function setEpochNull(uint256 _id) public + virtual onlyController epochIdExists(_id) epochHasEnded(_id)