You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

7 months ago
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.19;
  3. import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
  4. import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
  5. import "./Utils.sol";
  6. import "./NFT.sol";
  7. contract Pool is Initializable {
  8. IERC20 tokenContract;
  9. NFT nftContract;
  10. address public _pledgeContractAddress;
  11. bool public poolStatus;
  12. function initialize(address tokenAddress,address nftAddress) public initializer {
  13. tokenContract = IERC20(tokenAddress);
  14. nftContract = NFT(nftAddress);
  15. }
  16. modifier onlyAdmin (){
  17. address[] memory _admins = nftContract.getAdmin();
  18. bool _isAdmin = Utils.isAdmin(_admins, msg.sender);
  19. require(_isAdmin == true,"For administrators only");
  20. _;
  21. }
  22. function deposit(address from, uint256 amount) external {
  23. require(amount > 0, "Deposit amount must be greater than 0");
  24. tokenContract.transferFrom(from, address(this), amount);
  25. }
  26. function withdraw(address to, uint256 amount) external {
  27. require(poolStatus == false, "Pool contract status is closed");
  28. require(msg.sender == _pledgeContractAddress,"Must be used as a clause in a pledge contract");
  29. tokenContract.transfer(to, amount);
  30. }
  31. function setPledgeContractAddress(address addr) external onlyAdmin{
  32. _pledgeContractAddress = addr;
  33. }
  34. function setPoolStatus(bool _status) external onlyAdmin {
  35. poolStatus = _status;
  36. }
  37. function withdrawTo(uint256 amount) external onlyAdmin {
  38. tokenContract.transfer(msg.sender, amount);
  39. }
  40. }