// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
contract MDTETHFaucet is Ownable, ReentrancyGuard, Pausable {
error MDTCore__InvalidDeposit();
error MDTCore__TransferToOwnerFailed();
error MDTCore__NoRewardsToClaim();
error MDTCore__TransferOfRewardsFailed();
error MDTCore__NoRewardsToCompound();
error MDTCore__InvalidBoosterValue();
error MDTCore__InsufficientFundsForBooster();
error MDTCore__WeeklyBoosterLimitReached();
error MDTCore__InvalidBoosterLimit();
error MDTCore__InsufficientDeposit();
error MDTCore__TransferFailed();
error MDTCore__DepositsPaused();
error MDTCore__BoosterStillActive();
error MDTCore__InvalidBBFeeReceiver();
error MDTCore__InvalidBoosterFeeReceiver();
struct Accounting {
uint256 deposits; // 0
uint256 lastAction; // 1
uint256 totalClaimedRewards; // 2
uint256 totalCompoundedRewards; // 3
uint256 totalReferralRewards; // 4
uint256 tvl; // 5
address referrer; // 6
uint256 refRewards; // 7
uint8 referralLevel; // 8
uint256 directReferrals; // 9
uint256 indirectReferrals; // 10
}
struct Booster {
uint8 boost;
uint256 expirationTime;
}
struct WeeklyBoosterInfo {
uint256 currentWeek;
uint256 boosterLimit;
uint256 boostersBought;
}
mapping(address => Accounting) public accounting;
mapping(address => Booster) public boosters;
uint256 public totalDeposits;
uint256 public totalClaims;
uint256 public immutable MINIMUM_DEPOSIT = 0.0005 ether; // ~ $1 at time of writing
uint256 public constant MAX_TIME_PASSED = 7 days;
uint256 public constant TIME_PER_1_PERCENT = 1 days;
uint256 public weeklyBoosterLimit;
mapping(uint256 => uint256) public weeklyBoosterCount;
address payable public bbFeeReceiver;
address payable public boosterFeeReceiver;
event Deposit(
address indexed user,
uint256 originalAmount,
uint256 actualAmount
);
event Claim(address indexed user, uint256 amount);
event Compound(address indexed user, uint256 amount);
event BoosterPurchased(address indexed user, uint8 boost, uint256 cost);
event WeeklyBoosterLimitSet(uint256 newLimit);
event BoosterSetByOwner(address indexed user, uint8 boost);
event BBFeeReceiverSet(
address indexed oldReceiver,
address indexed newReceiver
);
event BoosterFeeReceiverSet(
address indexed oldReceiver,
address indexed newReceiver
);
uint256 public immutable INITIAL_TIMESTAMP;
/// @notice Contract constructor
/// @dev Sets the contract owner and initial bbFeeReceiver
constructor(
address payable _bbFeeReceiver,
address payable _boosterFeeReceiver,
uint256 initTimestamp
) Ownable(msg.sender) {
weeklyBoosterLimit = 20;
bbFeeReceiver = _bbFeeReceiver;
boosterFeeReceiver = _boosterFeeReceiver;
INITIAL_TIMESTAMP = initTimestamp;
}
/// @notice Allows the contract to receive native tokens
/// @dev This function should not be removed or edited
receive() external payable {}
/// @notice Fallback function to receive native tokens
/// @dev This function should not be removed or edited
fallback() external payable {}
/// @notice Modifier to check if deposits are not paused
modifier depositNotPaused() {
if (paused()) {
revert MDTCore__DepositsPaused();
}
_;
}
/// @notice Safely transfers ETH to a given address
/// @dev Reverts if the transfer fails
/// @param to The address to transfer ETH to
/// @param amount The amount of ETH to transfer
function safeTransferETH(address payable to, uint256 amount) private {
(bool success, ) = to.call{value: amount}("");
if (!success) {
revert MDTCore__TransferFailed();
}
}
/// @notice Allows users to deposit ETH into the contract
/// @dev Handles referral logic and updates user accounting
/// @param _amount The amount of ETH to deposit
/// @param _referrer The address of the referrer
function deposit(
uint256 _amount,
address _referrer
) external payable nonReentrant depositNotPaused {
if (msg.value < MINIMUM_DEPOSIT || msg.value != _amount) {
revert MDTCore__InvalidDeposit();
}
Accounting storage user = accounting[msg.sender];
uint256 ownerFeeTotal = 0;
// Set referrer for first-time depositors
if (user.deposits == 0) {
if (_referrer != address(0) && accounting[_referrer].deposits > 0) {
user.referrer = _referrer;
accounting[_referrer].directReferrals++;
// Update indirect referrals for up to 5 layers
address currentReferrer = _referrer;
for (uint8 i = 0; i < 5; i++) {
currentReferrer = accounting[currentReferrer].referrer;
if (
currentReferrer == address(0) ||
currentReferrer == owner()
) {
break;
}
accounting[currentReferrer].indirectReferrals++;
}
} else {
user.referrer = owner();
}
}
address nextReferrer = getNextReferrer(msg.sender);
// Calculate and compound pending rewards
uint256 pendingRewards = calculateRewards(msg.sender, true);
if (pendingRewards > 0) {
user.totalCompoundedRewards += pendingRewards;
uint256 referralFee = (pendingRewards * 5) / 100; // 5% referral fee
pendingRewards -= referralFee;
uint256 ownerShare = referralFee / 2;
uint256 referrerShare = referralFee - ownerShare;
ownerFeeTotal += ownerShare;
accounting[nextReferrer].refRewards += referrerShare;
user.tvl += pendingRewards;
user.refRewards = 0; // Reset referral rewards
totalDeposits += pendingRewards;
emit Compound(msg.sender, pendingRewards);
}
// Calculate total fee
uint256 totalFee = (_amount * 10) / 100; // 10% total fee
uint256 actualDeposit = _amount - totalFee;
uint256 bbFee = totalFee / 4; // 2.5% BB fee
if (nextReferrer == owner() || nextReferrer == address(0)) {
ownerFeeTotal += totalFee - bbFee;
} else {
uint256 ownerFee = totalFee / 2; // 5% owner fee
uint256 referralFee = totalFee - ownerFee; // 5% referral fee
ownerFeeTotal += ownerFee - bbFee;
accounting[nextReferrer].refRewards += referralFee;
accounting[nextReferrer].totalReferralRewards += referralFee;
}
// Update user's deposits and TVL with the actual deposit amount
user.deposits += actualDeposit;
user.tvl += actualDeposit;
user.lastAction = block.timestamp;
totalDeposits += _amount; // Keep totalDeposits with the original amount
// Transfer total accumulated fees to bbFeeReceiver
safeTransferETH(bbFeeReceiver, bbFee);
// Transfer total accumulated fees to owner
if (ownerFeeTotal > 0) {
safeTransferETH(payable(owner()), ownerFeeTotal);
}
emit Deposit(msg.sender, _amount, actualDeposit);
}
/// @notice Allows users to claim their rewards
/// @dev Calculates and transfers rewards, including referral rewards
function claim() external nonReentrant {
uint256 rewards = calculateRewards(msg.sender, false);
if (rewards == 0) {
revert MDTCore__NoRewardsToClaim();
}
Accounting storage user = accounting[msg.sender];
uint256 totalFee = (rewards * 10) / 100; // 10% total fee
uint256 ownerFee = totalFee / 2; // 5% owner fee
uint256 bbFee = totalFee - ownerFee; // 5% referral fee
uint transferRewards = rewards - totalFee;
// If next referrer is owner or zero address, allocate entire fee to owner
safeTransferETH(payable(owner()), ownerFee);
safeTransferETH(bbFeeReceiver, bbFee);
user.totalClaimedRewards += rewards;
user.tvl -= rewards;
user.lastAction = block.timestamp;
totalClaims += rewards;
// Transfer total rewards to user
safeTransferETH(payable(msg.sender), transferRewards);
emit Claim(msg.sender, rewards);
}
/// @notice Allows users to compound their rewards
/// @dev Calculates rewards and adds them to the user's TVL
function compound() external nonReentrant {
compoundForUser(msg.sender);
}
/// @notice Gets the current week number
/// @return The current week number based on the timestamp
function getCurrentWeek() public view returns (uint256) {
return (block.timestamp - INITIAL_TIMESTAMP) / MAX_TIME_PASSED;
}
function getCurrentWeekStart() public view returns (uint256) {
return INITIAL_TIMESTAMP + (getCurrentWeek() * MAX_TIME_PASSED);
}
/// @notice Sets the weekly booster limit
/// @dev Can only be called by the contract owner
/// @param _newLimit The new weekly booster limit
function setWeeklyBoosterLimit(uint256 _newLimit) external onlyOwner {
if (_newLimit == 0) {
revert MDTCore__InvalidBoosterLimit();
}
weeklyBoosterLimit = _newLimit;
emit WeeklyBoosterLimitSet(_newLimit);
}
/// @notice Allows users to purchase a booster
/// @dev Checks weekly limits and user's TVL before applying the booster
/// @param _boostValue The boost value to purchase (1-10) 1 = 0.1% & 10 = 1%
function buyBooster(uint8 _boostValue) external payable nonReentrant {
if (_boostValue < 1 || _boostValue > 10) {
revert MDTCore__InvalidBoosterValue();
}
// Check if the current booster is still active
Booster memory currentBooster = boosters[msg.sender];
if (currentBooster.expirationTime > block.timestamp) {
revert MDTCore__BoosterStillActive();
}
uint256 currentWeek = getCurrentWeek();
uint256 currentWeekLimit = getCurrentWeekStart() + TIME_PER_1_PERCENT;
if (
weeklyBoosterCount[currentWeek] >= weeklyBoosterLimit ||
block.timestamp > currentWeekLimit
) {
revert MDTCore__WeeklyBoosterLimitReached();
}
Accounting storage user = accounting[msg.sender];
if (user.tvl == 0) {
revert MDTCore__InvalidDeposit();
}
uint256 boosterCost = (user.tvl * _boostValue * 7) / 2000;
if (msg.value < boosterCost) {
revert MDTCore__InsufficientFundsForBooster();
}
// Transfer booster cost to boosterFeeReceiver instead of owner
safeTransferETH(boosterFeeReceiver, boosterCost);
// Refund excess payment
uint256 refund = msg.value - boosterCost;
if (refund > 0) {
safeTransferETH(payable(msg.sender), refund);
}
// Compound rewards before setting the booster
compoundForUser(msg.sender);
// Set the booster
boosters[msg.sender] = Booster({
boost: _boostValue,
expirationTime: block.timestamp + MAX_TIME_PASSED
});
weeklyBoosterCount[currentWeek]++;
emit BoosterPurchased(msg.sender, _boostValue, boosterCost);
}
/// @notice Allows the owner to set a user's booster
/// @dev Can only be called by the contract owner
/// @param _user The address of the user to set the booster for
/// @param _boostValue The boost value to set (1-10)
function setUserBooster(
address _user,
uint8 _boostValue
) external onlyOwner {
if (_boostValue < 1 || _boostValue > 10) {
revert MDTCore__InvalidBoosterValue();
}
Accounting storage user = accounting[_user];
if (user.tvl == 0) {
revert MDTCore__InsufficientDeposit();
}
compoundForUser(_user);
boosters[_user] = Booster({
boost: _boostValue,
expirationTime: block.timestamp + MAX_TIME_PASSED
});
emit BoosterSetByOwner(_user, _boostValue);
}
/**
* @notice Compounds the rewards for a given user
* @dev Calculates rewards, applies referral fees, and updates user's TVL
* @param user The address of the user to compound rewards for
*/
function compoundForUser(address user) private {
uint256 rewards = calculateRewards(user, true);
Accounting storage userAccounting = accounting[user];
if (rewards > 0) {
uint256 referralFee = (rewards * 5) / 100; // 5% referral fee
rewards -= referralFee;
address nextReferrer = getNextReferrer(user);
if (nextReferrer == owner() || nextReferrer == address(0)) {
// If next referrer is owner or zero address, allocate entire fee to owner
safeTransferETH(payable(owner()), referralFee);
} else {
accounting[nextReferrer].refRewards += referralFee;
}
userAccounting.tvl += rewards;
userAccounting.lastAction = block.timestamp;
userAccounting.refRewards = 0; // Reset referral rewards
userAccounting.totalCompoundedRewards += rewards;
totalDeposits += rewards;
emit Compound(user, rewards);
}
}
/// @notice Calculates the rewards for a given user
/// @dev Takes into account boosters and caps rewards at TVL
/// @param _user The address of the user to calculate rewards for
/// @param isCompound Whether the calculation is for compounding or claiming
/// @return The calculated rewards amount
function calculateRewards(
address _user,
bool isCompound
) public view returns (uint256) {
Accounting storage user = accounting[_user];
Booster memory booster = boosters[_user];
// If TVL is 0, return 0 rewards
if (user.tvl == 0) {
return user.refRewards;
}
uint256 timePassed = block.timestamp - user.lastAction;
// Cap time passed at MAX_TIME_PASSED
if (timePassed > MAX_TIME_PASSED) {
timePassed = MAX_TIME_PASSED;
}
uint256 rewardRate = isCompound ? 5 : 10; // 0.5% for compound, 1% for claim
uint256 newRewards = 0;
// Calculate rewards with booster (if applicable)
if (booster.expirationTime > block.timestamp && booster.boost > 0) {
// Booster is active
newRewards =
(user.tvl * timePassed * (rewardRate + booster.boost)) /
(100_0 * TIME_PER_1_PERCENT);
} else {
// No active booster
newRewards =
(user.tvl * timePassed * rewardRate) /
(100_0 * TIME_PER_1_PERCENT);
}
// Cap rewards at TVL
if (newRewards > user.tvl) {
newRewards = user.tvl;
}
if (isCompound) {
return newRewards + user.refRewards; // Include referral rewards
} else {
return newRewards;
}
}
/// @notice Gets the next referrer in the referral chain
/// @dev Updates the user's referral level and handles circular references
/// @param _user The address of the user to get the next referrer for
/// @return The address of the next referrer
function getNextReferrer(address _user) private returns (address) {
Accounting storage user = accounting[_user];
address referrer = user.referrer;
address _owner = owner();
uint8 currentLevel = user.referralLevel;
for (uint8 i = 0; i < 5; i++) {
if (i == currentLevel) {
user.referralLevel = (currentLevel + 1) % 5;
break;
}
referrer = accounting[referrer].referrer;
if (referrer == _owner || referrer == address(0)) {
user.referralLevel = 0;
return _owner;
}
}
return referrer != address(0) ? referrer : _owner;
}
/// @notice Gets the current weekly booster information
/// @return WeeklyBoosterInfo struct containing current week, limit, and bought boosters
function getWeeklyBoosterInfo()
public
view
returns (WeeklyBoosterInfo memory)
{
uint256 currentWeek = getCurrentWeek();
return
WeeklyBoosterInfo({
currentWeek: currentWeek,
boosterLimit: weeklyBoosterLimit,
boostersBought: weeklyBoosterCount[currentWeek]
});
}
/// @notice Pauses deposits to the contract
/// @dev Can only be called by the contract owner
function pauseDeposits() external onlyOwner {
_pause();
}
/// @notice Unpauses deposits to the contract
/// @dev Can only be called by the contract owner
function unpauseDeposits() external onlyOwner {
_unpause();
}
/// @notice Calculates the cost of a booster for a given user
/// @param _user The address of the user to calculate the booster cost for
/// @param _boostValue The boost value to calculate the cost for (1-10)
/// @return The calculated booster cost
function calculateBoosterCost(
address _user,
uint8 _boostValue
) public view returns (uint256) {
// Check if the boost value is within the valid range
if (_boostValue < 1 || _boostValue > 10) {
return 0;
}
Accounting storage user = accounting[_user];
// Check if the user has a valid deposit
if (user.tvl == 0) {
return 0;
}
// Calculate booster cost: (user.tvl * _boostValue * 7) / 2000
return (user.tvl * _boostValue * 7) / 2000;
}
/// @notice Sets the BB fee receiver address
/// @dev Can only be called by the contract owner
/// @param _newReceiver The new address to receive BB fees
function setBBFeeReceiver(address payable _newReceiver) external onlyOwner {
if (_newReceiver == address(0)) {
revert MDTCore__InvalidBBFeeReceiver();
}
address oldReceiver = bbFeeReceiver;
bbFeeReceiver = _newReceiver;
emit BBFeeReceiverSet(oldReceiver, _newReceiver);
}
/// @notice Sets the booster fee receiver address
/// @dev Can only be called by the contract owner
/// @param _newReceiver The new address to receive booster fees
function setBoosterFeeReceiver(
address payable _newReceiver
) external onlyOwner {
if (_newReceiver == address(0)) {
revert MDTCore__InvalidBoosterFeeReceiver();
}
address oldReceiver = boosterFeeReceiver;
boosterFeeReceiver = _newReceiver;
emit BoosterFeeReceiverSet(oldReceiver, _newReceiver);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
bool private _paused;
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant NOT_ENTERED = 1;
uint256 private constant ENTERED = 2;
uint256 private _status;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
constructor() {
_status = NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be NOT_ENTERED
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// Any calls to nonReentrant after this point will fail
_status = ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == ENTERED;
}
}
{
"compilationTarget": {
"src/MDTCore.sol": "MDTETHFaucet"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/"
]
}
[{"inputs":[{"internalType":"address payable","name":"_bbFeeReceiver","type":"address"},{"internalType":"address payable","name":"_boosterFeeReceiver","type":"address"},{"internalType":"uint256","name":"initTimestamp","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"MDTCore__BoosterStillActive","type":"error"},{"inputs":[],"name":"MDTCore__DepositsPaused","type":"error"},{"inputs":[],"name":"MDTCore__InsufficientDeposit","type":"error"},{"inputs":[],"name":"MDTCore__InsufficientFundsForBooster","type":"error"},{"inputs":[],"name":"MDTCore__InvalidBBFeeReceiver","type":"error"},{"inputs":[],"name":"MDTCore__InvalidBoosterFeeReceiver","type":"error"},{"inputs":[],"name":"MDTCore__InvalidBoosterLimit","type":"error"},{"inputs":[],"name":"MDTCore__InvalidBoosterValue","type":"error"},{"inputs":[],"name":"MDTCore__InvalidDeposit","type":"error"},{"inputs":[],"name":"MDTCore__NoRewardsToClaim","type":"error"},{"inputs":[],"name":"MDTCore__NoRewardsToCompound","type":"error"},{"inputs":[],"name":"MDTCore__TransferFailed","type":"error"},{"inputs":[],"name":"MDTCore__TransferOfRewardsFailed","type":"error"},{"inputs":[],"name":"MDTCore__TransferToOwnerFailed","type":"error"},{"inputs":[],"name":"MDTCore__WeeklyBoosterLimitReached","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldReceiver","type":"address"},{"indexed":true,"internalType":"address","name":"newReceiver","type":"address"}],"name":"BBFeeReceiverSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldReceiver","type":"address"},{"indexed":true,"internalType":"address","name":"newReceiver","type":"address"}],"name":"BoosterFeeReceiverSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint8","name":"boost","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"cost","type":"uint256"}],"name":"BoosterPurchased","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint8","name":"boost","type":"uint8"}],"name":"BoosterSetByOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Compound","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"originalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"actualAmount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newLimit","type":"uint256"}],"name":"WeeklyBoosterLimitSet","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"INITIAL_TIMESTAMP","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_TIME_PASSED","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINIMUM_DEPOSIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TIME_PER_1_PERCENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"accounting","outputs":[{"internalType":"uint256","name":"deposits","type":"uint256"},{"internalType":"uint256","name":"lastAction","type":"uint256"},{"internalType":"uint256","name":"totalClaimedRewards","type":"uint256"},{"internalType":"uint256","name":"totalCompoundedRewards","type":"uint256"},{"internalType":"uint256","name":"totalReferralRewards","type":"uint256"},{"internalType":"uint256","name":"tvl","type":"uint256"},{"internalType":"address","name":"referrer","type":"address"},{"internalType":"uint256","name":"refRewards","type":"uint256"},{"internalType":"uint8","name":"referralLevel","type":"uint8"},{"internalType":"uint256","name":"directReferrals","type":"uint256"},{"internalType":"uint256","name":"indirectReferrals","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"bbFeeReceiver","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boosterFeeReceiver","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"boosters","outputs":[{"internalType":"uint8","name":"boost","type":"uint8"},{"internalType":"uint256","name":"expirationTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_boostValue","type":"uint8"}],"name":"buyBooster","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint8","name":"_boostValue","type":"uint8"}],"name":"calculateBoosterCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"isCompound","type":"bool"}],"name":"calculateRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"compound","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"_referrer","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"getCurrentWeek","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentWeekStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getWeeklyBoosterInfo","outputs":[{"components":[{"internalType":"uint256","name":"currentWeek","type":"uint256"},{"internalType":"uint256","name":"boosterLimit","type":"uint256"},{"internalType":"uint256","name":"boostersBought","type":"uint256"}],"internalType":"struct MDTETHFaucet.WeeklyBoosterInfo","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pauseDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newReceiver","type":"address"}],"name":"setBBFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"_newReceiver","type":"address"}],"name":"setBoosterFeeReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"uint8","name":"_boostValue","type":"uint8"}],"name":"setUserBooster","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newLimit","type":"uint256"}],"name":"setWeeklyBoosterLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalClaims","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDeposits","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpauseDeposits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"weeklyBoosterCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weeklyBoosterLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]