Bokuto Testnet

Contract

0xba804DF5c476E8EaeF87BF8085F295300ccE2a49
Source Code Source Code

Overview

ETH Balance

0 ETH

More Info

Contract Creator

N/A (System Contract)

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Amount

There are no matching entries

Please try again later

Parent Transaction Hash Block From To Amount
View All Internal Transactions

Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x05F45674...ca849932C in Monad Testnet
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
AgoraFaucet

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 100000000 runs

Other Settings:
cancun EvmVersion

Contract Source Code (Solidity Standard Json-Input format)

// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.21;

// ====================================================================
//             _        ______     ___   _______          _
//            / \     .' ___  |  .'   `.|_   __ \        / \
//           / _ \   / .'   \_| /  .-.  \ | |__) |      / _ \
//          / ___ \  | |   ____ | |   | | |  __ /      / ___ \
//        _/ /   \ \_\ `.___]  |\  `-'  /_| |  \ \_  _/ /   \ \_
//       |____| |____|`._____.'  `.___.'|____| |___||____| |____|
// ====================================================================
// =========================== AgoraFaucet ============================
// ====================================================================

import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { IERC20Metadata } from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

struct InitializeParams {
    address tokenToDistribute;
    uint256 faucetDripAmount;
    uint256 maxAmountToOwn;
    uint256 maxDripFrequency;
}

/// @title AgoraFaucet
/// @notice The AgoraFaucet is a contract that distributes a fixed amount of tokens to an address
/// @author Agora
contract AgoraFaucet is Initializable {
    using SafeERC20 for IERC20;

    //==============================================================================
    // Storage structs
    //==============================================================================

    struct FaucetStorage {
        address tokenToDistribute;
        uint256 faucetDripAmount; // 18 decimals precision
        uint256 maxAmountToOwn; // 18 decimals precision
        uint256 maxDripFrequency; // in seconds
        uint256 lastDripTimestamp; // timestamp - acts as global rate-limiting.
    }

    //==============================================================================
    // Erc 7201: UnstructuredNamespace Storage Functions
    //==============================================================================

    /// @notice The ```AGORA_FAUCET_STORAGE_SLOT``` is the storage slot for the FaucetStorage struct
    /// @dev keccak256(abi.encode(uint256(keccak256("AgoraFaucet")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 public constant AGORA_FAUCET_STORAGE_SLOT =
        0xd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14000;

    /// @notice The ```_getPointerToStorage``` function returns a pointer to the FaucetStorage struct
    /// @return $ A pointer to the FaucetStorage struct
    function _getPointerToStorage() internal pure returns (FaucetStorage storage $) {
        /// @solidity memory-safe-assembly
        assembly {
            $.slot := AGORA_FAUCET_STORAGE_SLOT
        }
    }

    //==============================================================================
    // Constructor & Initalization Functions
    //==============================================================================
    constructor() {
        _disableInitializers();
    }

    function initialize(InitializeParams memory _params) public initializer {
        uint8 _decimals = IERC20Metadata(_params.tokenToDistribute).decimals();

        _getPointerToStorage().tokenToDistribute = _params.tokenToDistribute;
        _getPointerToStorage().faucetDripAmount = _params.faucetDripAmount * (10 ** _decimals);
        _getPointerToStorage().maxAmountToOwn = _params.maxAmountToOwn * (10 ** _decimals);
        _getPointerToStorage().maxDripFrequency = _params.maxDripFrequency;
        _getPointerToStorage().lastDripTimestamp = 0;
    }

    //==============================================================================
    // View Functions
    //==============================================================================

    /// @notice Returns the address of the ERC20 token that the Faucet will distribute.
    /// @return The address of the ERC20 token.
    function token() external view returns (address) {
        return _getPointerToStorage().tokenToDistribute;
    }

    /// @notice Returns the amount of tokens that the Faucet will dispense per request.
    /// @return The amount of tokens to dispense, specified without decimals.
    function faucetDripAmount() external view returns (uint256) {
        return _getPointerToStorage().faucetDripAmount;
    }

    /// @notice Returns the maximum token balance an address can hold to remain eligible
    /// to receive tokens from the Faucet.
    /// @return The maximum token balance an address can hold, specified without decimals.
    function maxAmountToOwn() external view returns (uint256) {
        return _getPointerToStorage().maxAmountToOwn;
    }

    /// @notice Returns the minimum time that must elapse between requests for tokens.
    /// @return The minimum time between token requests, specified as seconds.
    function maxDripFrequency() external view returns (uint256) {
        return _getPointerToStorage().maxDripFrequency;
    }

    /// @notice Returns the last time that tokens were requested from the Faucet.
    /// @return The timestamp of the last token request, corresponding to `block.timestamp`.
    function lastDripTimestamp() external view returns (uint256) {
        return _getPointerToStorage().lastDripTimestamp;
    }

    // ============================================================================================
    // Internal Functions
    // ============================================================================================

    /// @notice Sets the last time that tokens were requested from the Faucet.
    /// @param _lastDripTimestamp The updated timestamp to set, corresponding to `block.timestamp`
    function _updateLastDripTime(uint256 _lastDripTimestamp) internal {
        _getPointerToStorage().lastDripTimestamp = _lastDripTimestamp;
    }

    // ============================================================================================
    // External Functions
    // ============================================================================================

    /// @notice Distributes the `faucetDripAmount` of tokens to the provided address
    /// if the conditions of the Faucet rate-limiting are met
    /// @param _receiver The address that will receive the tokens.
    function requestFunds(address _receiver) external {
        FaucetStorage memory _config = _getPointerToStorage();

        if (block.timestamp - _config.lastDripTimestamp < _config.maxDripFrequency) {
            revert MaxFrequencyExceeded();
        }
        if (IERC20(_config.tokenToDistribute).balanceOf(address(this)) <= _config.faucetDripAmount)
            revert InsufficientFunds();
        if (IERC20(_config.tokenToDistribute).balanceOf(_receiver) >= _config.maxAmountToOwn) {
            revert MaxAllowedExceeded();
        }

        _updateLastDripTime(block.timestamp);

        IERC20(_config.tokenToDistribute).safeTransfer({ to: _receiver, value: _config.faucetDripAmount });
        emit FundsRequested(_receiver, _config.faucetDripAmount);
    }

    // ============================================================================================
    // Events
    // ============================================================================================

    /// @notice Emitted when the configuration is updated.
    /// @param faucetDripAmount The configured amount to dispense, specified without decimals.
    /// @param maxAmountToOwn The configured maximum tokens balance an address cna hold, specified without decimals.
    /// @param maxDripFrequency The configured maximum time between token requests, specified as seconds.
    event configureFaucet(uint256 faucetDripAmount, uint256 maxAmountToOwn, uint256 maxDripFrequency);

    /// @notice Emitted when the last time tokens were requested from the Faucet is updated.
    /// @param _lastDripTimestamp The updated timestamp to set, corresponding to `block.timestamp`.
    event SetLastDripTime(uint256 _lastDripTimestamp);

    /// @notice Emitted when tokens are requested from the Faucet.
    /// @param receiver The address that will receive the tokens.
    /// @param amount The amount of tokens that will be transferred.
    event FundsRequested(address indexed receiver, uint256 amount);

    // ============================================================================================
    // Errors
    // ============================================================================================

    /// @notice Emitted when the reserve of tokens in the Faucet is insufficient
    error InsufficientFunds();

    /// @notice Emitted when an invalid path is passed to a function
    error MaxAllowedExceeded();

    /// @notice Emitted when the maximum frequency of token requests is exceeded
    error MaxFrequencyExceeded();

    /// @notice The ```Version``` struct is used to represent the version of the AgoraFaucet
    /// @param major The major version number
    /// @param minor The minor version number
    /// @param patch The patch version number
    struct Version {
        uint256 major;
        uint256 minor;
        uint256 patch;
    }

    /// @notice The ```version``` function returns the version of the AgoraFaucet
    /// @return _version The version of the AgoraFaucet
    function version() public pure returns (Version memory _version) {
        _version = Version({ major: 1, minor: 0, patch: 0 });
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```solidity
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 *
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reininitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._initialized = 1;
        if (isTopLevelCall) {
            $._initializing = true;
        }
        _;
        if (isTopLevelCall) {
            $._initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._initialized = version;
        $._initializing = true;
        _;
        $._initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        assembly {
            $.slot := INITIALIZABLE_STORAGE
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC-20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    /**
     * @dev An operation with an ERC-20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

File 8 of 9 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../token/ERC20/IERC20.sol";

File 9 of 9 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../utils/introspection/IERC165.sol";

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

Settings
{
  "remappings": [
    "stable-swap/=lib/stable-swap-dev/src/",
    "forge-std/=lib/forge-std/src/",
    "agora-std/=lib/agora-standard-solidity/src/",
    "createx/=node_modules/createx/src/",
    "@interfaces/=src/interfaces/",
    "@utils/=src/sol-utils/",
    "@swap-actions/=src/actions/stable-swap/",
    "@testnet-actions/=src/actions/testnet/",
    "@check-actions/=src/actions/check/",
    "agora-dollar/=node_modules/agora-dollar-dev/src/",
    "solady/=node_modules/solady/",
    "agora-contracts/=node_modules/agora-contracts/src/contracts/",
    "lib/stable-swap-dev/src/contracts/:agora-contracts/=lib/stable-swap-dev/node_modules/agora-contracts/src/contracts/",
    "@chainlink/=lib/agora-standard-solidity/node_modules/@chainlink/",
    "@eth-optimism/=lib/agora-standard-solidity/node_modules/@eth-optimism/",
    "@layerzerolabs/=lib/layerzero-dev/node_modules/@layerzerolabs/",
    "@openzeppelin/=node_modules/@openzeppelin/",
    "agora-contracts-old/=node_modules/agora-contracts-old/",
    "agora-dollar-dev/=node_modules/agora-dollar-dev/",
    "agora-dollar-evm-dev/=lib/agora-dollar-evm-dev/src/",
    "agora-standard-solidity/=lib/agora-standard-solidity/src/",
    "agora-whitelist/=lib/arbitrage-bot/node_modules/agora-whitelist/src/contracts/",
    "arbitrage-bot/=lib/arbitrage-bot/src/",
    "contracts/=node_modules/agora-dollar-dev/src/contracts/",
    "ds-test/=node_modules/ds-test/",
    "hardhat-deploy/=lib/layerzero-dev/node_modules/hardhat-deploy/",
    "hardhat/=lib/layerzero-dev/node_modules/hardhat/",
    "interfaces/=lib/arbitrage-bot/src/interfaces/",
    "layerzero-dev/=lib/layerzero-dev/contracts/",
    "openzeppelin/=node_modules/createx/lib/openzeppelin-contracts/contracts/",
    "script/=node_modules/agora-dollar-dev/src/script/",
    "solidity-bytes-utils/=lib/agora-standard-solidity/node_modules/solidity-bytes-utils/",
    "stable-swap-dev/=lib/stable-swap-dev/src/",
    "test/=node_modules/agora-dollar-dev/src/test/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 100000000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "none",
    "appendCBOR": false
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true
}

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"InsufficientFunds","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"MaxAllowedExceeded","type":"error"},{"inputs":[],"name":"MaxFrequencyExceeded","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FundsRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_lastDripTimestamp","type":"uint256"}],"name":"SetLastDripTime","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"faucetDripAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxAmountToOwn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"maxDripFrequency","type":"uint256"}],"name":"configureFaucet","type":"event"},{"inputs":[],"name":"AGORA_FAUCET_STORAGE_SLOT","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"faucetDripAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"tokenToDistribute","type":"address"},{"internalType":"uint256","name":"faucetDripAmount","type":"uint256"},{"internalType":"uint256","name":"maxAmountToOwn","type":"uint256"},{"internalType":"uint256","name":"maxDripFrequency","type":"uint256"}],"internalType":"struct InitializeParams","name":"_params","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastDripTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAmountToOwn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxDripFrequency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_receiver","type":"address"}],"name":"requestFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"components":[{"internalType":"uint256","name":"major","type":"uint256"},{"internalType":"uint256","name":"minor","type":"uint256"},{"internalType":"uint256","name":"patch","type":"uint256"}],"internalType":"struct AgoraFaucet.Version","name":"_version","type":"tuple"}],"stateMutability":"pure","type":"function"}]

Deployed Bytecode

0x6080806040526004361015610012575f80fd5b5f3560e01c90816314bc2fd714610b39575080634864570414610adf578063544c7cf9146106c257806354fd4d50146106455780638be6392f146105ed578063905467f614610593578063cdc438b41461014d578063d9772a25146100f35763fc0c546a1461007f575f80fd5b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef57602073ffffffffffffffffffffffffffffffffffffffff7fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc140005416604051908152f35b5f80fd5b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef5760207fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400454604051908152f35b346100ef5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef576040516080810181811067ffffffffffffffff821117610566576040526101a1610b90565b8152602081016024358152604082016044358152606083019160643583527ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00549060ff8260401c16159467ffffffffffffffff83168015908161055e575b6001149081610554575b15908161054b575b5061052357828660017fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000060049616177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00556104ce575b50602073ffffffffffffffffffffffffffffffffffffffff825116604051948580927f313ce5670000000000000000000000000000000000000000000000000000000082525afa9283156104c3575f93610481575b50926103576103519273ffffffffffffffffffffffffffffffffffffffff6103809651167fffffffffffffffffffffffff00000000000000000000000000000000000000007fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc140005416177fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14000555161035185610c10565b90610c21565b7fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14001555191610c10565b7fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400255517fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14003555f7fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14004556103ee57005b7fffffffffffffffffffffffffffffffffffffffffffffff00ffffffffffffffff7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a0054167ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00557fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602060405160018152a1005b9092506020813d6020116104bb575b8161049d60209383610bcf565b810103126100ef57519260ff841684036100ef5792916103576102bc565b3d9150610490565b6040513d5f823e3d90fd5b7fffffffffffffffffffffffffffffffffffffffffffffff0000000000000000001668010000000000000001177ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a005586610267565b7ff92ee8a9000000000000000000000000000000000000000000000000000000005f5260045ffd5b90501587610211565b303b159150610209565b8791506101ff565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef5760207fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400154604051908152f35b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef5760206040517fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc140008152f35b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef575f6040805161068181610bb3565b8281528260208201520152606060405161069a81610bb3565b60018152604060208201915f8352015f81526040519160018352516020830152516040820152f35b346100ef5760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef576106f9610b90565b60405160a0810181811067ffffffffffffffff8211176105665760405273ffffffffffffffffffffffffffffffffffffffff7fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14000541681527fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc140015490602081019182527fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400254604082019081527fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400354606083019081527fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400454806080850152420390428211610ab2575111610a8a576024602073ffffffffffffffffffffffffffffffffffffffff845116604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa9081156104c3575f91610a58575b5083511015610a305773ffffffffffffffffffffffffffffffffffffffff90602082845116956024604051809581937f70a0823100000000000000000000000000000000000000000000000000000000835216988960048301525afa9182156104c3575f926109fc575b505111156109d45773ffffffffffffffffffffffffffffffffffffffff90427fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400455511660205f8351604051838101917fa9059cbb000000000000000000000000000000000000000000000000000000008352876024830152604482015260448152610956606482610bcf565b519082855af1156104c3575f513d6109cb5750803b155b6109a0575060207f4087832b44fdb3158fdf0e558259a49524c43a1e2fb21ee61859eb8ea5855e2e9151604051908152a2005b7f5274afe7000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b6001141561096d565b7f0949dab9000000000000000000000000000000000000000000000000000000005f5260045ffd5b9091506020813d602011610a28575b81610a1860209383610bcf565b810103126100ef575190856108ca565b3d9150610a0b565b7f356680b7000000000000000000000000000000000000000000000000000000005f5260045ffd5b90506020813d602011610a82575b81610a7360209383610bcf565b810103126100ef575185610860565b3d9150610a66565b7f20e5bc67000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef5760207fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc1400354604051908152f35b346100ef575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126100ef576020907fd71d30ae1739f9e5e681d58ab25df7b1e56518c2d536eba11a605e88ebc14002548152f35b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100ef57565b6060810190811067ffffffffffffffff82111761056657604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761056657604052565b60ff16604d8111610ab257600a0a90565b81810292918115918404141715610ab25756

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
0xba804DF5c476E8EaeF87BF8085F295300ccE2a49
Loading...
Loading
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.