all files / contracts/ Faucet.sol

100% Statements 5/5
100% Branches 4/4
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                          14× 13× 12×      
// SPDX-License-Identifier: Unlicense
pragma solidity 0.8.6;
 
import "./interfaces/ISOLACE.sol";
import "./interfaces/IFaucet.sol";
 
/**
 * @title Faucet
 * @author solace.fi
 * @notice Drips [**SOLACE**](./SOLACE).
 *
 * Useful for testing but should NOT be used in production.
 */
contract Faucet is IFaucet {
 
    ISOLACE public solace;
    mapping(address => uint256) public lastPull;
 
    /**
     * @notice Constructs the faucet.
     * @param solace_ Address of the [**SOLACE**](./SOLACE) contract.
     */
    constructor(address solace_) {
        require(solace_ != address(0x0), "zero address solace");
        solace = ISOLACE(solace_);
    }
 
    /**
     * @notice Drips [**SOLACE**](./SOLACE) to msg.sender.
     */
    function drip() external override {
        require(lastPull[msg.sender] + 86400 <= block.timestamp, "the well is dry");
        solace.mint(msg.sender, 1000 ether);
        lastPull[msg.sender] = block.timestamp;
    }
}