Skip to content

Commit

Permalink
made updates to the treasury contract
Browse files Browse the repository at this point in the history
  • Loading branch information
David405 committed Apr 7, 2024
2 parents ab4a24e + c53b667 commit 59613bd
Show file tree
Hide file tree
Showing 9 changed files with 668 additions and 2 deletions.
47 changes: 47 additions & 0 deletions contracts/Faucet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";

import "./interfaces/ZTokenInterface.sol";

contract Faucet is OwnableUpgradeable {
mapping(string => address) public assets;
address public avax;

event AvaxFinished(address _avax, address faucet, uint256 balance);

function init() external initializer {
__Ownable_init();
}


function setAsset(string memory asset, address _address) external onlyOwner {
require(_address != address(0), "address cannot be a zero address");
assets[asset] = _address;
}

function setAvax(address _address) external onlyOwner {
require(_address != address(0), "address cannot be a zero address");
avax = _address;
}

function getAsset(string memory asset, address receiver) external {
if(IERC20Upgradeable(avax).balanceOf(address(this)) > 0.02 ether){
if(IERC20Upgradeable(avax).balanceOf(msg.sender) < 0.02 ether){
IERC20Upgradeable(avax).approve(address(this), 0.02 ether);
bool _success = IERC20Upgradeable(avax).transferFrom(address(this), msg.sender, 0.02 ether);
if(!_success) revert();

}
} else {
emit AvaxFinished(avax, address(this), IERC20Upgradeable(avax).balanceOf(msg.sender));
}
bool success = ZTokenInterface(assets[asset]).mint(receiver, 1000000 ether);
if(!success) revert();
}


}
Loading

0 comments on commit 59613bd

Please sign in to comment.