Skip to content

Instantly share code, notes, and snippets.

@pythonpete32
Created February 7, 2023 12:01
Show Gist options
  • Save pythonpete32/5ce523478b43e42d4b2eab8b05818993 to your computer and use it in GitHub Desktop.
Save pythonpete32/5ce523478b43e42d4b2eab8b05818993 to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity 0.8.17;
import {IWETH9} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IDAO} from "aragon-plugin-base/contracts/lib/interfaces/IDAO.sol";
import {PluginUUPSUpgradeable} from "aragon-plugin-base/contracts/lib/plugin/PluginUUPSUpgradeable.sol";
/// @title AdminTransferPlugin
/// @notice Enables Admins to transfer ANT Tokens from the DAO to a recipient without a vote.
contract WrapperPluggin is PluginUUPSUpgradeable {
/* ====================================================================== */
/* PERMISSION IDS
/* ====================================================================== */
/// @notice Permission ID for the transfer function
bytes32 public constant WRAP_PERMISSION_ID = keccak256("WRAP_PERMISSION_ID");
/* ====================================================================== */
/* STATE
/* ====================================================================== */
/// @notice address of the WETH9 contract
address public weth;
/// @notice Nonce for the DAO
uint256 public nonce;
/// @notice Admins
mapping(address => bool) public admins;
/* ====================================================================== */
/* FUNCTIONS
/* ====================================================================== */
/// @notice Constructor
constructor() {
_disableInitializers();
}
function initialize(IDAO _dao, address _weth, address admin) external initializer {
__PluginUUPSUpgradeable_init(_dao);
nonce = 0;
weth = _weth;
admins[admin] = true;
}
function protectedByDAO(address admin, bool isAdmin) external auth(ADD_ADDRESS_PERMISSION_ID) {
admins[admin] = isAdmin;
}
function protectedByPlugin(uint256 _amount) external {
// validate params
require(admins[msg.sender] = true, "NOT PERMITTED");
// Create an action to transfer ANT from the DAO to the recipient.
IDAO.Action[] memory action = new IDAO.Action[](1);
action[0].to = address(weth);
action[0].value = 0;
action[0].data = abi.encodeWithSelector(IWETH9(weth).wrap.withdraw.selector, _amount);
dao.execute(bytes32(nonce++), action, 0);
}
/// @notice This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain (see [OpenZepplins guide about storage gaps](https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps)).
uint256[48] private __gap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment