Skip to content

Commit

Permalink
Add function to withdraw all tokens from Coordinator for a token address
Browse files Browse the repository at this point in the history
  • Loading branch information
cygnusv committed Sep 12, 2024
1 parent 48e71c8 commit c379e45
Show file tree
Hide file tree
Showing 2 changed files with 475 additions and 441 deletions.
10 changes: 10 additions & 0 deletions contracts/contracts/coordination/Coordinator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin-upgradeable/contracts/access/extensions/AccessControlDefaultAdminRulesUpgradeable.sol";
import "@openzeppelin-upgradeable/contracts/proxy/utils/Initializable.sol";
import "./IFeeModel.sol";
Expand All @@ -15,6 +17,8 @@ import "./IEncryptionAuthorizer.sol";
* @notice Coordination layer for Threshold Access Control (TACo 🌮)
*/
contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable {
using SafeERC20 for IERC20;

// DKG Protocol
event StartRitual(uint32 indexed ritualId, address indexed authority, address[] participants);
event StartAggregationRound(uint32 indexed ritualId);
Expand Down Expand Up @@ -642,4 +646,10 @@ contract Coordinator is Initializable, AccessControlDefaultAdminRulesUpgradeable
);
emit RitualExtended(ritualId, ritual.endTimestamp);
}

function withdrawAllTokens(IERC20 token) external onlyRole(TREASURY_ROLE) {
uint256 tokenBalance = token.balanceOf(msg.sender);
require(tokenBalance > 0, "Insufficient balance");
token.safeTransferFrom(address(this), msg.sender, tokenBalance);
}
}
Loading

0 comments on commit c379e45

Please sign in to comment.