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

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "./Utils.sol";
import "./NFT.sol";
contract Pool is Initializable {
IERC20 tokenContract;
NFT nftContract;
address public _pledgeContractAddress;
bool public poolStatus;
function initialize(address tokenAddress,address nftAddress) public initializer {
tokenContract = IERC20(tokenAddress);
nftContract = NFT(nftAddress);
}
modifier onlyAdmin (){
address[] memory _admins = nftContract.getAdmin();
bool _isAdmin = Utils.isAdmin(_admins, msg.sender);
require(_isAdmin == true,"For administrators only");
_;
}
function deposit(address from, uint256 amount) external {
require(amount > 0, "Deposit amount must be greater than 0");
tokenContract.transferFrom(from, address(this), amount);
}
function withdraw(address to, uint256 amount) external {
require(poolStatus == false, "Pool contract status is closed");
require(msg.sender == _pledgeContractAddress,"Must be used as a clause in a pledge contract");
tokenContract.transfer(to, amount);
}
function setPledgeContractAddress(address addr) external onlyAdmin{
_pledgeContractAddress = addr;
}
function setPoolStatus(bool _status) external onlyAdmin {
poolStatus = _status;
}
function withdrawTo(uint256 amount) external onlyAdmin {
tokenContract.transfer(msg.sender, amount);
}
}