Skip to content

Commit

Permalink
Merge pull request #116 from Lossless-Cash/LSS-3920-retrieve-reporter…
Browse files Browse the repository at this point in the history
…=-tokens

fix: add function to retrieve rejected report tokens
  • Loading branch information
Ignacio-Freire authored Apr 17, 2024
2 parents 91c3448 + 5d8ff3e commit 3dfd293
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
24 changes: 23 additions & 1 deletion contracts/LosslessReporting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,26 @@ contract LosslessReporting is ILssReporting, Initializable, ContextUpgradeable,
emit CompensationRetrieve(_adr, _amount);
}

}
/// @notice This function allows the admin to retrieve tokens that are stuck in the contract
/// @param _token Address of the token to be retrieved
/// @param _to Address to which the tokens will be sent
/// @param _reportId ID of the associated report to check its status
function retrieveRejectedReportTokens(ILERC20 _token, address _to, uint256 _reportId) public onlyLosslessAdmin {
require(_to != address(0), "LSS: Cannot send to zero address");

// Retrieve the report from storage
Report storage report = reportInfo[_reportId];

// Check if the report is either expired or resolved negatively
bool isExpired = (block.timestamp > report.reportTimestamps + reportLifetime);
bool isResolvedNegatively = (losslessGovernance.isReportSolved(_reportId) && !losslessGovernance.reportResolution(_reportId));

require(isExpired || isResolvedNegatively, "LSS: Report not expired or resolved negatively");

uint256 contractBalance = _token.balanceOf(address(this));
require(reportingAmount <= contractBalance, "LSS: Not enough tokens in contract");

require(_token.transfer(_to, reportingAmount), "LSS: Token transfer failed");
}

}

0 comments on commit 3dfd293

Please sign in to comment.