Source Code
Latest 11 from a total of 11 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Claim Rewards | 25224949 | 90 days ago | IN | 0 ETH | 0.00000338 | ||||
| Claim Rewards | 25224696 | 90 days ago | IN | 0 ETH | 0.00000452 | ||||
| Update Merkle Ro... | 25224584 | 90 days ago | IN | 0 ETH | 0.0000017 | ||||
| Claim Rewards | 25220933 | 90 days ago | IN | 0 ETH | 0.00000452 | ||||
| Claim Rewards | 25220271 | 90 days ago | IN | 0 ETH | 0.00000514 | ||||
| Update Merkle Ro... | 25123474 | 92 days ago | IN | 0 ETH | 0.0000033 | ||||
| Grant Role | 25117504 | 93 days ago | IN | 0 ETH | 0.00000508 | ||||
| Grant Role | 25114437 | 93 days ago | IN | 0 ETH | 0.00000508 | ||||
| Grant Role | 25110849 | 93 days ago | IN | 0 ETH | 0.00000508 | ||||
| Grant Role | 25079758 | 94 days ago | IN | 0 ETH | 0.00000508 | ||||
| Grant Role | 25079756 | 94 days ago | IN | 0 ETH | 0.00000512 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
ReferralRewards
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 2000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: AGPL-3.0-or-later
// ▗▖ ▗▞▀▚▖█ ▄ ▗▞▀▚▖▄ ▄ ▗▞▀▚▖
// ▐▌ ▐▛▀▀▘█ ▄ ▐▛▀▀▘█ █ ▐▛▀▀▘
// ▐▛▀▚▖▝▚▄▄▖█ █ ▝▚▄▄▖ ▀▄▀ ▝▚▄▄▖
// ▐▙▄▞▘ █ █
// ▄ ▄▄▄▄
// ▄ █ █
// █ █ █
// █
// ▄▄▄ ▄▄▄ ▄▄▄▄ ▗▄▄▄▖▗▄▄▄▖▗▖ ▗▖▄ ▄▄▄▄
// ▀▄▄ █ █ █ █ █ ▐▌ █ ▐▌ ▐▌▄ █ █
// ▄▄▄▀ ▀▄▄▀ █ █ ▐▛▀▀▘ █ ▐▛▀▜▌█ █ █
// ▐▙▄▄▖ █ ▐▌ ▐▌█ ▗▄▖
// ▐▌ ▐▌
// ▝▀▜▌
// ▐▙▄▞▘
// Website: https://something.fun
pragma solidity ^0.8.0;
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {MerkleProof} from "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol";
import {IReferralSystem} from "contracts/interfaces/IReferralSystem.sol";
/// @title ReferralRewards
/// @notice Contract for managing referral reward distribution using merkle trees
/// @dev Distributes trading fee rewards to referrers (split between layer 1 and layer 2)
/// @dev Reward amounts are calculated off-chain based on actual fees collected
contract ReferralRewards is Ownable, AccessControl, ReentrancyGuard, Pausable {
using SafeERC20 for IERC20;
// Custom errors for gas optimization
error UnauthorizedAccess();
error InvalidAmount();
error AlreadyClaimed();
error InvalidMerkleProof();
error BatchTooLarge();
error ProofTooLong();
error InvalidAddress();
error OverflowDetected();
/// @notice Referral reward claim data
/// @param user Address of the user claiming rewards
/// @param token Address of the token being claimed
/// @param amount Amount of rewards to claim for this token
/// @param merkleProof Merkle proof for verification
struct ClaimRewardsInput {
address user;
address token;
uint256 amount;
bytes32[] merkleProof;
}
// Constants for security and gas optimization
uint256 public MAX_BATCH_SIZE;
uint256 public constant MAX_MERKLE_PROOF_LENGTH = 32;
uint256 public constant MIN_CLAIM_AMOUNT = 1e12; // 0.000001 tokens
uint256 public constant MAX_CLAIM_AMOUNT = type(uint128).max;
// Access control roles
bytes32 public constant MERKLE_SERVER_ROLE = keccak256("MERKLE_SERVER_ROLE");
bytes32 public constant REWARD_DISTRIBUTOR_ROLE = keccak256("REWARD_DISTRIBUTOR_ROLE");
// Storage mappings
mapping(address => mapping(address => uint256)) public userTokenClaimedRewards; // user => token => claimed amount
mapping(address => uint256) public userLastClaimTimestamp;
// State variables
IReferralSystem public referralSystem;
IERC20 public rewardToken;
address public treasury;
bytes32 public merkleRoot;
uint256 public lastMerkleUpdate;
// Enhanced events
event MerkleRootUpdated(bytes32 indexed newMerkleRoot, uint256 timestamp);
event RewardsClaimed(
address indexed user,
address indexed token,
uint256 amount,
uint256 timestamp
);
event BatchRewardsClaimed(
address indexed user,
uint256 totalAmount,
uint256 claimCount,
uint256 timestamp
);
event TreasuryUpdated(address indexed newTreasury);
constructor(
address _referralSystem,
address _rewardToken,
address _treasury,
uint256 _maxBatchSize
) Ownable(msg.sender) {
if (_referralSystem == address(0) || _rewardToken == address(0) || _treasury == address(0)) {
revert InvalidAddress();
}
referralSystem = IReferralSystem(_referralSystem);
rewardToken = IERC20(_rewardToken);
treasury = _treasury;
MAX_BATCH_SIZE = _maxBatchSize;
// Set up roles
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MERKLE_SERVER_ROLE, msg.sender);
_grantRole(REWARD_DISTRIBUTOR_ROLE, msg.sender);
}
/// @notice Updates the Merkle root for reward distribution
/// @param _merkleRoot The new Merkle root containing all claimable rewards
function updateMerkleRoot(bytes32 _merkleRoot) external onlyRole(MERKLE_SERVER_ROLE) whenNotPaused {
if (_merkleRoot == bytes32(0)) revert InvalidAddress();
merkleRoot = _merkleRoot;
lastMerkleUpdate = block.timestamp;
emit MerkleRootUpdated(_merkleRoot, block.timestamp);
}
/// @notice Claims rewards with comprehensive security checks
/// @dev Only callable by an authorized distributor (e.g., Launchpad) with REWARD_DISTRIBUTOR_ROLE
/// @param input Claim input containing user, amount, and proof
function claimRewards(ClaimRewardsInput calldata input) external nonReentrant whenNotPaused {
_validateClaimInput(input);
_processClaim(input);
}
/// @notice Batch claims rewards with DoS protection
/// @dev Only callable by an authorized distributor (e.g., Launchpad) with REWARD_DISTRIBUTOR_ROLE
/// @param inputs Array of claim inputs
function batchClaimRewards(ClaimRewardsInput[] calldata inputs) external nonReentrant whenNotPaused {
if (inputs.length == 0 || inputs.length > MAX_BATCH_SIZE) revert BatchTooLarge();
uint256 totalAmount = 0;
for (uint256 i = 0; i < inputs.length; ) {
ClaimRewardsInput calldata input = inputs[i];
_validateClaimInput(input);
// Accumulate total for overflow check
uint256 newTotal = totalAmount + input.amount;
if (newTotal < totalAmount) revert OverflowDetected();
totalAmount = newTotal;
_processClaim(input);
unchecked { ++i; }
}
emit BatchRewardsClaimed(msg.sender, totalAmount, inputs.length, block.timestamp);
}
/// @notice Internal function to validate claim input
function _validateClaimInput(ClaimRewardsInput calldata input) internal view {
if (input.user == address(0)) revert InvalidAddress();
if (input.token == address(0)) revert InvalidAddress();
if (input.amount == 0) revert InvalidAmount();
if (input.amount < MIN_CLAIM_AMOUNT || input.amount > MAX_CLAIM_AMOUNT) revert InvalidAmount();
if (input.merkleProof.length == 0 || input.merkleProof.length > MAX_MERKLE_PROOF_LENGTH) {
revert ProofTooLong();
}
if (merkleRoot == bytes32(0)) revert InvalidMerkleProof();
}
/// @notice Internal function to process a claim
function _processClaim(ClaimRewardsInput calldata input) internal {
// Create leaf hash: keccak256(user, token, totalClaimable)
// Note: totalClaimable is the cumulative amount the user can claim for this specific token
bytes32 leaf = keccak256(abi.encodePacked(
input.user,
input.token,
input.amount // This is the total claimable amount for this user for this token
));
// Verify merkle proof
if (!MerkleProof.verify(input.merkleProof, merkleRoot, leaf)) {
revert InvalidMerkleProof();
}
// Calculate how much is actually claimable (total - already claimed for this token)
uint256 alreadyClaimed = userTokenClaimedRewards[input.user][input.token];
if (input.amount <= alreadyClaimed) revert AlreadyClaimed();
uint256 claimableAmount = input.amount - alreadyClaimed;
// Update user statistics with overflow protection
uint256 newUserTokenTotal = userTokenClaimedRewards[input.user][input.token] + claimableAmount;
if (newUserTokenTotal < userTokenClaimedRewards[input.user][input.token]) revert OverflowDetected();
userTokenClaimedRewards[input.user][input.token] = newUserTokenTotal;
userLastClaimTimestamp[input.user] = block.timestamp;
// Record claimed rewards in the referral system
referralSystem.recordClaimedRewards(input.user, input.token, claimableAmount);
// Transfer rewards (in the specified token)
IERC20(input.token).safeTransfer(input.user, claimableAmount);
emit RewardsClaimed(input.user, input.token, claimableAmount, block.timestamp);
}
/// @notice Get total claimed rewards for a user for a specific token
/// @param user Address of the user
/// @param token Address of the token
/// @return claimed Total amount of rewards claimed by the user for this token
function getClaimedRewards(address user, address token) external view returns (uint256) {
return userTokenClaimedRewards[user][token];
}
/// @notice Get last claim timestamp for a user
/// @param user Address of the user
/// @return timestamp When the user last claimed rewards
function getLastClaimTimestamp(address user) external view returns (uint256) {
return userLastClaimTimestamp[user];
}
/// @notice Get the current Merkle root
/// @return root The current Merkle root
function getMerkleRoot() external view returns (bytes32) {
return merkleRoot;
}
/// @notice Get when the Merkle root was last updated
/// @return timestamp Last update time
function getLastMerkleUpdate() external view returns (uint256) {
return lastMerkleUpdate;
}
// Admin functions with proper access control
/// @notice Set treasury address
/// @param _treasury New treasury address
function setTreasury(address _treasury) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (_treasury == address(0)) revert InvalidAddress();
treasury = _treasury;
emit TreasuryUpdated(_treasury);
}
/// @notice Emergency pause all operations
function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_pause();
}
/// @notice Resume all operations
function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
_unpause();
}
/// @notice Emergency withdraw tokens
/// @param token Token to withdraw
/// @param amount Amount to withdraw
function emergencyWithdraw(IERC20 token, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE) {
token.safeTransfer(msg.sender, amount);
}
/// @notice Grant merkle server role
/// @param server Address to grant role to
function grantMerkleServerRole(address server) external onlyRole(DEFAULT_ADMIN_ROLE) {
if (server == address(0)) revert InvalidAddress();
_grantRole(MERKLE_SERVER_ROLE, server);
}
/// @notice Revoke merkle server role
/// @param server Address to revoke role from
function revokeMerkleServerRole(address server) external onlyRole(DEFAULT_ADMIN_ROLE) {
_revokeRole(MERKLE_SERVER_ROLE, server);
}
/// @notice Get treasury address
/// @return treasury The treasury address
function getTreasury() external view returns (address) {
return treasury;
}
// Required by AccessControl
function supportsInterface(bytes4 interfaceId) public view override(AccessControl) returns (bool) {
return super.supportsInterface(interfaceId);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}// 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.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);
}// 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.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";// 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.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.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
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/Hashes.sol)
pragma solidity ^0.8.20;
/**
* @dev Library of standard hash functions.
*
* _Available since v5.1._
*/
library Hashes {
/**
* @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
*
* NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
*/
function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
return a < b ? _efficientKeccak256(a, b) : _efficientKeccak256(b, a);
}
/**
* @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
*/
function _efficientKeccak256(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly ("memory-safe") {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/cryptography/MerkleProof.sol)
// This file was procedurally generated from scripts/generate/templates/MerkleProof.js.
pragma solidity ^0.8.20;
import {Hashes} from "./Hashes.sol";
/**
* @dev These functions deal with verification of Merkle Tree proofs.
*
* The tree and the proofs can be generated using our
* https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
* You will find a quickstart guide in the readme.
*
* WARNING: You should avoid using leaf values that are 64 bytes long prior to
* hashing, or use a hash function other than keccak256 for hashing leaves.
* This is because the concatenation of a sorted pair of internal nodes in
* the Merkle tree could be reinterpreted as a leaf value.
* OpenZeppelin's JavaScript library generates Merkle trees that are safe
* against this attack out of the box.
*
* IMPORTANT: Consider memory side-effects when using custom hashing functions
* that access memory in an unsafe way.
*
* NOTE: This library supports proof verification for merkle trees built using
* custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
* leaf inclusion in trees built using non-commutative hashing functions requires
* additional logic that is not supported by this library.
*/
library MerkleProof {
/**
*@dev The multiproof provided is not valid.
*/
error MerkleProofInvalidMultiproof();
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with the default hashing function.
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProof(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in memory with a custom hashing function.
*/
function processProof(
bytes32[] memory proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
return processProofCalldata(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with the default hashing function.
*/
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processProofCalldata(proof, leaf, hasher) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leaves & pre-images are assumed to be sorted.
*
* This version handles proofs in calldata with a custom hashing function.
*/
function processProofCalldata(
bytes32[] calldata proof,
bytes32 leaf,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
computedHash = hasher(computedHash, proof[i]);
}
return computedHash;
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProof(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProof}.
*/
function multiProofVerify(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProof(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in memory with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProof(
bytes32[] memory proof,
bool[] memory proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves
) internal pure returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with the default hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves
) internal pure returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = Hashes.commutativeKeccak256(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
/**
* @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
* `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
*
* NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
* The `leaves` must be validated independently. See {processMultiProofCalldata}.
*/
function multiProofVerifyCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32 root,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bool) {
return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
}
/**
* @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
* proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
* leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
* respectively.
*
* This version handles multiproofs in calldata with a custom hashing function.
*
* CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
* is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
* tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
*
* NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
* and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
* validating the leaves elsewhere.
*/
function processMultiProofCalldata(
bytes32[] calldata proof,
bool[] calldata proofFlags,
bytes32[] memory leaves,
function(bytes32, bytes32) view returns (bytes32) hasher
) internal view returns (bytes32 merkleRoot) {
// This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
// consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
// `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
// the Merkle tree.
uint256 leavesLen = leaves.length;
uint256 proofFlagsLen = proofFlags.length;
// Check proof validity.
if (leavesLen + proof.length != proofFlagsLen + 1) {
revert MerkleProofInvalidMultiproof();
}
// The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
// `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
bytes32[] memory hashes = new bytes32[](proofFlagsLen);
uint256 leafPos = 0;
uint256 hashPos = 0;
uint256 proofPos = 0;
// At each step, we compute the next hash using two values:
// - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
// get the next hash.
// - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
// `proof` array.
for (uint256 i = 0; i < proofFlagsLen; i++) {
bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
bytes32 b = proofFlags[i]
? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
: proof[proofPos++];
hashes[i] = hasher(a, b);
}
if (proofFlagsLen > 0) {
if (proofPos != proof.length) {
revert MerkleProofInvalidMultiproof();
}
unchecked {
return hashes[proofFlagsLen - 1];
}
} else if (leavesLen > 0) {
return leaves[0];
} else {
return proof[0];
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}// 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);
}// 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.1.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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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;
}
}// SPDX-License-Identifier: AGPL-3.0-or-later
// ▗▖ ▗▞▀▚▖█ ▄ ▗▞▀▚▖▄ ▄ ▗▞▀▚▖
// ▐▌ ▐▛▀▀▘█ ▄ ▐▛▀▀▘█ █ ▐▛▀▀▘
// ▐▛▀▚▖▝▚▄▄▖█ █ ▝▚▄▄▖ ▀▄▀ ▝▚▄▄▖
// ▐▙▄▞▘ █ █
// ▄ ▄▄▄▄
// ▄ █ █
// █ █ █
// █
// ▄▄▄ ▄▄▄ ▄▄▄▄ ▗▄▄▄▖▗▄▄▄▖▗▖ ▗▖▄ ▄▄▄▄
// ▀▄▄ █ █ █ █ █ ▐▌ █ ▐▌ ▐▌▄ █ █
// ▄▄▄▀ ▀▄▄▀ █ █ ▐▛▀▀▘ █ ▐▛▀▜▌█ █ █
// ▐▙▄▄▖ █ ▐▌ ▐▌█ ▗▄▖
// ▐▌ ▐▌
// ▝▀▜▌
// ▐▙▄▞▘
// Website: https://something.fun
pragma solidity ^0.8.0;
/// @title IReferralSystem Interface
/// @notice Interface for the ReferralSystem contract that handles referral tracking
/// @dev Rewards are calculated off-chain based on trading fees and distributed via Merkle proofs
interface IReferralSystem {
/// @notice Referral data structure
/// @param referralCode Unique 8-byte referral code
/// @param referrer Address who referred this user
/// @param totalReferrals Total number of direct referrals
/// @param isActive Whether the referral code is active
/// @param createdAt Timestamp when referral code was created
struct ReferralData {
bytes8 referralCode;
address referrer;
uint256 totalReferrals;
bool isActive;
uint256 createdAt;
}
/// @notice Emitted when a referral code is registered
/// @param user Address of the user registering the code
/// @param referralCode The referral code registered
event ReferralCodeRegistered(address indexed user, bytes8 referralCode);
/// @notice Emitted when a referral relationship is established
/// @param referrer Address of the referrer
/// @param referee Address of the referee
/// @param referralCode The referral code used
event ReferralRelationshipEstablished(
address indexed referrer,
address indexed referee,
bytes8 referralCode
);
/// @notice Emitted when referral registration is enabled/disabled
/// @param enabled Whether registration is enabled
event ReferralRegistrationToggled(bool enabled);
/// @notice Emitted when rewards are claimed
/// @param user Address claiming rewards
/// @param amount Amount of rewards claimed
event RewardsClaimed(address indexed user, address indexed token, uint256 amount);
// Errors
error InvalidReferralCode();
error ReferralCodeAlreadyTaken();
error UserAlreadyHasReferralCode();
error ReferralRegistrationDisabled();
error InvalidUserAddress();
error InvalidVolume();
error CannotReferYourself();
error CircularReferralNotAllowed();
error PercentageTooHigh();
error UnauthorizedAccess();
error InvalidTokenAddress();
/// @notice Registers a referral code for the caller
/// @param referralCode The 8-byte referral code to register
function registerReferralCode(bytes8 referralCode) external;
/// @notice Registers a referral code for another user (admin only)
/// @param user Address of the user to register the code for
/// @param referralCode The 8-byte referral code to register
function registerReferralCodeFor(address user, bytes8 referralCode) external;
/// @notice Generates a referral code from an address
/// @param user Address to generate code from
/// @return referralCode Generated 8-byte referral code
function generateReferralCodeFromAddress(address user) external view returns (bytes8);
/// @notice Generates a referral code from a custom string
/// @param customString Custom string to generate code from
/// @return referralCode Generated 8-byte referral code
function generateReferralCodeFromString(string memory customString) external view returns (bytes8);
/// @notice Establishes a referral relationship if not already set
/// @param user Address of the user being referred
/// @param referralCode Referral code used
function useReferralCode(address user, bytes8 referralCode) external;
/// @notice Gets the referrer for a user
/// @param user Address of the user
/// @return referrer Address of the referrer
function getReferrer(address user) external view returns (address);
/// @notice Gets all referees for a referrer
/// @param referrer Address of the referrer
/// @return referees Array of referee addresses
function getReferees(address referrer) external view returns (address[] memory);
/// @notice Gets total number of referrals for a referrer
/// @param referrer Address of the referrer
/// @return count Number of referrals
function getReferralCount(address referrer) external view returns (uint256);
/// @notice Checks if a referral code is available
/// @param referralCode The referral code to check
/// @return available Whether the code is available
function isReferralCodeAvailable(bytes8 referralCode) external view returns (bool);
/// @notice Gets the user for a referral code
/// @param referralCode The referral code
/// @return user Address of the user who owns the code
function getReferralCodeOwner(bytes8 referralCode) external view returns (address);
/// @notice Gets total claimed rewards for a user
/// @param user Address of the user
/// @return claimed Total rewards claimed
function getClaimedRewards(address user, address token) external view returns (uint256);
/// @notice Records claimed rewards for a user (only callable by rewards contract)
/// @param user Address of the user
/// @param amount Amount of rewards claimed
function recordClaimedRewards(address user, address token, uint256 amount) external;
/// @notice Toggles referral registration (admin only)
/// @param enabled Whether to enable registration
function toggleReferralRegistration(bool enabled) external;
/// @notice Checks if referral registration is enabled
/// @return enabled Whether registration is enabled
function isReferralRegistrationEnabled() external view returns (bool);
}{
"viaIR": true,
"optimizer": {
"enabled": true,
"runs": 2000
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_referralSystem","type":"address"},{"internalType":"address","name":"_rewardToken","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"uint256","name":"_maxBatchSize","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[],"name":"AlreadyClaimed","type":"error"},{"inputs":[],"name":"BatchTooLarge","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidAmount","type":"error"},{"inputs":[],"name":"InvalidMerkleProof","type":"error"},{"inputs":[],"name":"OverflowDetected","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":"ProofTooLong","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"UnauthorizedAccess","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"claimCount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"BatchRewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"newMerkleRoot","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"MerkleRootUpdated","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":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"timestamp","type":"uint256"}],"name":"RewardsClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newTreasury","type":"address"}],"name":"TreasuryUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_BATCH_SIZE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_CLAIM_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_MERKLE_PROOF_LENGTH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MERKLE_SERVER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_CLAIM_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_DISTRIBUTOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"internalType":"struct ReferralRewards.ClaimRewardsInput[]","name":"inputs","type":"tuple[]"}],"name":"batchClaimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"internalType":"struct ReferralRewards.ClaimRewardsInput","name":"input","type":"tuple"}],"name":"claimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getLastClaimTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getLastMerkleUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTreasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"server","type":"address"}],"name":"grantMerkleServerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastMerkleUpdate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"referralSystem","outputs":[{"internalType":"contract IReferralSystem","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"callerConfirmation","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"server","type":"address"}],"name":"revokeMerkleServerRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"updateMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userLastClaimTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"userTokenClaimedRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]Contract Creation Code
60803461019157601f611b9538819003918201601f19168301916001600160401b038311848410176101965780849260809460405283398101031261019157610047816101ac565b90610054602082016101ac565b6060610062604084016101ac565b92015192331561017b5760008054336001600160a01b0319821681178355916001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09080a360016002556003805460ff191690556001600160a01b03168015801561016a575b8015610159575b61014857600780546001600160a01b03199081169290921790556008805482166001600160a01b039384161790556009805490911692909116919091179055600455610124336101c0565b5061012e3361023c565b50610138336102d4565b506040516117a490816103918239f35b63e6c4247b60e01b60005260046000fd5b506001600160a01b038316156100d9565b506001600160a01b038216156100d2565b631e4fbdf760e01b600052600060045260246000fd5b600080fd5b634e487b7160e01b600052604160045260246000fd5b51906001600160a01b038216820361019157565b6001600160a01b0381166000908152600080516020611b55833981519152602052604090205460ff16610236576001600160a01b03166000818152600080516020611b5583398151915260205260408120805460ff19166001179055339190600080516020611b358339815191528180a4600190565b50600090565b6001600160a01b0381166000908152600080516020611b75833981519152602052604090205460ff16610236576001600160a01b03166000818152600080516020611b7583398151915260205260408120805460ff191660011790553391907f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d90600080516020611b358339815191529080a4600190565b6001600160a01b03811660009081527f9fa2c3f7d407d24f1efe37d5d52c83824a0093283c561d327263952e65b322e6602052604090205460ff16610236576001600160a01b031660008181527f9fa2c3f7d407d24f1efe37d5d52c83824a0093283c561d327263952e65b322e660205260408120805460ff191660011790553391907fb814ff4a26ea3ec5cd1fa579daad86324826254265f3acfec78303a19845b44990600080516020611b358339815191529080a460019056fe608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714610bb4575080631d4d8ed514610b8b5780631e2f85c3146104bd578063248a9ca314610b565780632eb4a7ab146107865780632f2ff15d14610b1657806332e4bb0a14610adb57806336568abe14610a7c578063387a02521461049f5780633b19e84a146106c85780633f4ba83a146109fa578063471cde031461086b5780634783f0ef146107a457806349590657146107865780634969f5a81461074b5780635c975abb1461072857806360e12396146106ef57806361d027b3146106c8578063715018a6146106625780638456cb59146106085780638da5cb5b146105e157806391d148541461059357806395ccea6714610558578063a04e876c14610531578063a217fddf14610515578063c121ff3f146104bd578063cb8088ed1461049f578063cfdbf25414610481578063d547741f1461043a578063d731c4f61461041a578063e1f92d26146103b5578063e362b4f7146103ef578063e90dbd8c146103b5578063f0f4426014610315578063f2dafbea146102b7578063f2fde38b14610208578063f7c618c1146101e15763feac51b5146101c157600080fd5b346101dc5760006003193601126101dc576020604051818152f35b600080fd5b346101dc5760006003193601126101dc5760206001600160a01b0360085416604051908152f35b346101dc5760206003193601126101dc576001600160a01b03610229610c52565b610231611664565b168015610288576001600160a01b036000548273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b7f1e4fbdf700000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b346101dc5760206003193601126101dc5760043567ffffffffffffffff81116101dc5760806003198260040192360301126101dc5761030e906102f8611004565b61030061103d565b610309816110db565b61125c565b6001600255005b346101dc5760206003193601126101dc576001600160a01b03610336610c52565b61033e610ca1565b16801561038b578073ffffffffffffffffffffffffffffffffffffffff1960095416176009557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d1600080a2005b7fe6c4247b0000000000000000000000000000000000000000000000000000000060005260046000fd5b346101dc5760206003193601126101dc576001600160a01b036103d6610c52565b1660005260066020526020604060002054604051908152f35b346101dc5760006003193601126101dc5760206040516fffffffffffffffffffffffffffffffff8152f35b346101dc5760006003193601126101dc57602060405164e8d4a510008152f35b346101dc5760406003193601126101dc5761047f600435610459610c68565b9061047a61047582600052600160205260016040600020015490565b610cf4565b610e0d565b005b346101dc5760006003193601126101dc576020600454604051908152f35b346101dc5760006003193601126101dc576020600b54604051908152f35b346101dc5760406003193601126101dc576104d6610c52565b6001600160a01b036104e6610c68565b911660005260056020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b346101dc5760006003193601126101dc57602060405160008152f35b346101dc5760006003193601126101dc5760206001600160a01b0360075416604051908152f35b346101dc5760406003193601126101dc576004356001600160a01b03811681036101dc5761047f90610588610ca1565b6024359033906116a6565b346101dc5760406003193601126101dc576105ac610c68565b60043560005260016020526001600160a01b0360406000209116600052602052602060ff604060002054166040519015158152f35b346101dc5760006003193601126101dc5760206001600160a01b0360005416604051908152f35b346101dc5760006003193601126101dc57610621610ca1565b61062961103d565b600160ff1960035416176003557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346101dc5760006003193601126101dc5761067b611664565b60006001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101dc5760006003193601126101dc5760206001600160a01b0360095416604051908152f35b346101dc5760206003193601126101dc57610708610c52565b610710610ca1565b6001600160a01b0381161561038b5761047f90610ea3565b346101dc5760006003193601126101dc57602060ff600354166040519015158152f35b346101dc5760006003193601126101dc5760206040517f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d8152f35b346101dc5760006003193601126101dc576020600a54604051908152f35b346101dc5760206003193601126101dc573360009081527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c60205260409020546004359060ff1615610832576107f861103d565b801561038b5780600a5542600b557fecb6e184c8c1ff50ab199b30650a76b7eb56fe2f261becc6284e0a3a1707be486020604051428152a2005b63e2517d3f60e01b600052336004527f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d60245260446000fd5b346101dc5760206003193601126101dc5760043567ffffffffffffffff81116101dc57366023820112156101dc57806004013567ffffffffffffffff81116101dc573660248260051b840101116101dc576108c4611004565b6108cc61103d565b801580156109ef575b6109c5576000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5d84360301905b838110156109855760009260248260051b87010135838112156109815786019361093e60646024870196610936886110db565b013583610c7e565b9182106109595750906109536001929461125c565b01610903565b807ff1075a7a0000000000000000000000000000000000000000000000000000000060049252fd5b8480fd5b828460405191825260208201524260408201527ff1f6dd2e19164e6e054315354946fd50dccfbcff365bc9ebfaf1f7a0dffa492f60603392a26001600255005b7f0b7d62e20000000000000000000000000000000000000000000000000000000060005260046000fd5b5060045481116108d5565b346101dc5760006003193601126101dc57610a13610ca1565b60035460ff811615610a525760ff19166003557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b0000000000000000000000000000000000000000000000000000000060005260046000fd5b346101dc5760406003193601126101dc57610a95610c68565b336001600160a01b03821603610ab15761047f90600435610e0d565b7f6697b2320000000000000000000000000000000000000000000000000000000060005260046000fd5b346101dc5760006003193601126101dc5760206040517fb814ff4a26ea3ec5cd1fa579daad86324826254265f3acfec78303a19845b4498152f35b346101dc5760406003193601126101dc5761047f600435610b35610c68565b90610b5161047582600052600160205260016040600020015490565b610f71565b346101dc5760206003193601126101dc576020610b83600435600052600160205260016040600020015490565b604051908152f35b346101dc5760206003193601126101dc5761047f610ba7610c52565b610baf610ca1565b610d3b565b346101dc5760206003193601126101dc57600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101dc57817f7965db0b0000000000000000000000000000000000000000000000000000000060209314908115610c28575b5015158152f35b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483610c21565b600435906001600160a01b03821682036101dc57565b602435906001600160a01b03821682036101dc57565b91908201809211610c8b57565b634e487b7160e01b600052601160045260246000fd5b3360009081527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49602052604090205460ff1615610cda57565b63e2517d3f60e01b60005233600452600060245260446000fd5b80600052600160205260406000206001600160a01b03331660005260205260ff6040600020541615610d235750565b63e2517d3f60e01b6000523360045260245260446000fd5b6001600160a01b03811660009081527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c602052604090205460ff1615610e07576001600160a01b031660008181527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c60205260408120805460ff191690553391907f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b50600090565b80600052600160205260406000206001600160a01b03831660005260205260ff60406000205416600014610e9c5780600052600160205260406000206001600160a01b038316600052602052604060002060ff1981541690556001600160a01b03339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a4600190565b5050600090565b6001600160a01b03811660009081527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c602052604090205460ff16610e07576001600160a01b031660008181527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c60205260408120805460ff191660011790553391907f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b80600052600160205260406000206001600160a01b03831660005260205260ff6040600020541615600014610e9c5780600052600160205260406000206001600160a01b0383166000526020526040600020600160ff198254161790556001600160a01b03339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d600080a4600190565b60028054146110135760028055565b7f3ee5aeb50000000000000000000000000000000000000000000000000000000060005260046000fd5b60ff6003541661104957565b7fd93c06650000000000000000000000000000000000000000000000000000000060005260046000fd5b356001600160a01b03811681036101dc5790565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1813603018212156101dc570180359067ffffffffffffffff82116101dc57602001918160051b360383136101dc57565b6001600160a01b036110ec82611073565b161561038b576001600160a01b0361110660208301611073565b161561038b57604081013580156111c15764e8d4a5100081109081156111eb575b506111c1576060810161113a8183611087565b9050159182156111a9575b505061117f57600a541561115557565b7fb05e92fa0000000000000000000000000000000000000000000000000000000060005260046000fd5b7fb5ae13c80000000000000000000000000000000000000000000000000000000060005260046000fd5b60209250906111b791611087565b9050113880611145565b7f2c5211c60000000000000000000000000000000000000000000000000000000060005260046000fd5b6fffffffffffffffffffffffffffffffff91501138611127565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761124657604052565b634e487b7160e01b600052604160045260246000fd5b9061126682611073565b602083019161127483611073565b906000926040860135927fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006040519181602084019460601b16845260601b166034820152836048820152604881526112cd606882611205565b519020936112de6060870187611087565b939095600a549667ffffffffffffffff8611611650578560051b604051966113096020830189611205565b8752602087019082019136831161164c57905b82821061163c575050509685975b855189101561136d5760208960051b870101519081811060001461135c5787526020526001604087205b98019761132a565b908752602052600160408720611354565b9195939750935094909403611614576001600160a01b0361138d83611073565b1681526005602052604081206001600160a01b036113aa86611073565b1682526020526040812054808411156115ec5783039283116115d8576001600160a01b036113d783611073565b1681526005602052604081206001600160a01b036113f486611073565b168252602052611408836040832054610c7e565b6001600160a01b0361141984611073565b1682526005602052604082206001600160a01b0361143687611073565b168352602052604082205481106115b0576001600160a01b0361145884611073565b1682526005602052604082206001600160a01b0361147587611073565b16835260205260408220556001600160a01b0361149183611073565b16815260066020524260408220556001600160a01b03600754166114b483611073565b6114bd86611073565b91803b156115ac5760648492836001600160a01b03938460405197889687957f654e7e150000000000000000000000000000000000000000000000000000000087521660048601521660248401528960448401525af180156115a15761157f6115797fd92c424393cb3ccdf7d5e36602e3bfa34f24490579ba47978f4bcfad496995f2956040956001600160a01b03958695611591575b505061157488856115648c611073565b1661156e84611073565b906116a6565b611073565b96611073565b835195865242602087015216941692a3565b8161159b91611205565b38611554565b6040513d84823e3d90fd5b8380fd5b6004827ff1075a7a000000000000000000000000000000000000000000000000000000008152fd5b80634e487b7160e01b602492526011600452fd5b6004827f646cf558000000000000000000000000000000000000000000000000000000008152fd5b807fb05e92fa0000000000000000000000000000000000000000000000000000000060049252fd5b813581526020918201910161131c565b8880fd5b602487634e487b7160e01b81526041600452fd5b6001600160a01b0360005416330361167857565b7f118cdaa7000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b91602091600091604051906001600160a01b03858301937fa9059cbb0000000000000000000000000000000000000000000000000000000085521660248301526044820152604481526116fa606482611205565b519082855af115611762576000513d61175957506001600160a01b0381163b155b6117225750565b6001600160a01b03907f5274afe7000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b6001141561171b565b6040513d6000823e3d90fdfea2646970667358221220d5265e97014ed9498ed43dbb355dcbee26e0e29ddcc352a093b3ab117368ee7464736f6c634300081c00332f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0da6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c000000000000000000000000035e9ad8a0ef4079e1e91f0db16ffa9f5032679a0000000000000000000000007bf60411d3238c508f6bf4603ec651bc2d98034c000000000000000000000000ed3af36d7b9c5bbd7ecfa7fb794eda6e242016f50000000000000000000000000000000000000000000000000000000000000032
Deployed Bytecode
0x608080604052600436101561001357600080fd5b60003560e01c90816301ffc9a714610bb4575080631d4d8ed514610b8b5780631e2f85c3146104bd578063248a9ca314610b565780632eb4a7ab146107865780632f2ff15d14610b1657806332e4bb0a14610adb57806336568abe14610a7c578063387a02521461049f5780633b19e84a146106c85780633f4ba83a146109fa578063471cde031461086b5780634783f0ef146107a457806349590657146107865780634969f5a81461074b5780635c975abb1461072857806360e12396146106ef57806361d027b3146106c8578063715018a6146106625780638456cb59146106085780638da5cb5b146105e157806391d148541461059357806395ccea6714610558578063a04e876c14610531578063a217fddf14610515578063c121ff3f146104bd578063cb8088ed1461049f578063cfdbf25414610481578063d547741f1461043a578063d731c4f61461041a578063e1f92d26146103b5578063e362b4f7146103ef578063e90dbd8c146103b5578063f0f4426014610315578063f2dafbea146102b7578063f2fde38b14610208578063f7c618c1146101e15763feac51b5146101c157600080fd5b346101dc5760006003193601126101dc576020604051818152f35b600080fd5b346101dc5760006003193601126101dc5760206001600160a01b0360085416604051908152f35b346101dc5760206003193601126101dc576001600160a01b03610229610c52565b610231611664565b168015610288576001600160a01b036000548273ffffffffffffffffffffffffffffffffffffffff19821617600055167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0600080a3005b7f1e4fbdf700000000000000000000000000000000000000000000000000000000600052600060045260246000fd5b346101dc5760206003193601126101dc5760043567ffffffffffffffff81116101dc5760806003198260040192360301126101dc5761030e906102f8611004565b61030061103d565b610309816110db565b61125c565b6001600255005b346101dc5760206003193601126101dc576001600160a01b03610336610c52565b61033e610ca1565b16801561038b578073ffffffffffffffffffffffffffffffffffffffff1960095416176009557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d1600080a2005b7fe6c4247b0000000000000000000000000000000000000000000000000000000060005260046000fd5b346101dc5760206003193601126101dc576001600160a01b036103d6610c52565b1660005260066020526020604060002054604051908152f35b346101dc5760006003193601126101dc5760206040516fffffffffffffffffffffffffffffffff8152f35b346101dc5760006003193601126101dc57602060405164e8d4a510008152f35b346101dc5760406003193601126101dc5761047f600435610459610c68565b9061047a61047582600052600160205260016040600020015490565b610cf4565b610e0d565b005b346101dc5760006003193601126101dc576020600454604051908152f35b346101dc5760006003193601126101dc576020600b54604051908152f35b346101dc5760406003193601126101dc576104d6610c52565b6001600160a01b036104e6610c68565b911660005260056020526001600160a01b03604060002091166000526020526020604060002054604051908152f35b346101dc5760006003193601126101dc57602060405160008152f35b346101dc5760006003193601126101dc5760206001600160a01b0360075416604051908152f35b346101dc5760406003193601126101dc576004356001600160a01b03811681036101dc5761047f90610588610ca1565b6024359033906116a6565b346101dc5760406003193601126101dc576105ac610c68565b60043560005260016020526001600160a01b0360406000209116600052602052602060ff604060002054166040519015158152f35b346101dc5760006003193601126101dc5760206001600160a01b0360005416604051908152f35b346101dc5760006003193601126101dc57610621610ca1565b61062961103d565b600160ff1960035416176003557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346101dc5760006003193601126101dc5761067b611664565b60006001600160a01b03815473ffffffffffffffffffffffffffffffffffffffff1981168355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101dc5760006003193601126101dc5760206001600160a01b0360095416604051908152f35b346101dc5760206003193601126101dc57610708610c52565b610710610ca1565b6001600160a01b0381161561038b5761047f90610ea3565b346101dc5760006003193601126101dc57602060ff600354166040519015158152f35b346101dc5760006003193601126101dc5760206040517f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d8152f35b346101dc5760006003193601126101dc576020600a54604051908152f35b346101dc5760206003193601126101dc573360009081527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c60205260409020546004359060ff1615610832576107f861103d565b801561038b5780600a5542600b557fecb6e184c8c1ff50ab199b30650a76b7eb56fe2f261becc6284e0a3a1707be486020604051428152a2005b63e2517d3f60e01b600052336004527f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d60245260446000fd5b346101dc5760206003193601126101dc5760043567ffffffffffffffff81116101dc57366023820112156101dc57806004013567ffffffffffffffff81116101dc573660248260051b840101116101dc576108c4611004565b6108cc61103d565b801580156109ef575b6109c5576000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff5d84360301905b838110156109855760009260248260051b87010135838112156109815786019361093e60646024870196610936886110db565b013583610c7e565b9182106109595750906109536001929461125c565b01610903565b807ff1075a7a0000000000000000000000000000000000000000000000000000000060049252fd5b8480fd5b828460405191825260208201524260408201527ff1f6dd2e19164e6e054315354946fd50dccfbcff365bc9ebfaf1f7a0dffa492f60603392a26001600255005b7f0b7d62e20000000000000000000000000000000000000000000000000000000060005260046000fd5b5060045481116108d5565b346101dc5760006003193601126101dc57610a13610ca1565b60035460ff811615610a525760ff19166003557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b0000000000000000000000000000000000000000000000000000000060005260046000fd5b346101dc5760406003193601126101dc57610a95610c68565b336001600160a01b03821603610ab15761047f90600435610e0d565b7f6697b2320000000000000000000000000000000000000000000000000000000060005260046000fd5b346101dc5760006003193601126101dc5760206040517fb814ff4a26ea3ec5cd1fa579daad86324826254265f3acfec78303a19845b4498152f35b346101dc5760406003193601126101dc5761047f600435610b35610c68565b90610b5161047582600052600160205260016040600020015490565b610f71565b346101dc5760206003193601126101dc576020610b83600435600052600160205260016040600020015490565b604051908152f35b346101dc5760206003193601126101dc5761047f610ba7610c52565b610baf610ca1565b610d3b565b346101dc5760206003193601126101dc57600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101dc57817f7965db0b0000000000000000000000000000000000000000000000000000000060209314908115610c28575b5015158152f35b7f01ffc9a70000000000000000000000000000000000000000000000000000000091501483610c21565b600435906001600160a01b03821682036101dc57565b602435906001600160a01b03821682036101dc57565b91908201809211610c8b57565b634e487b7160e01b600052601160045260246000fd5b3360009081527fa6eef7e35abe7026729641147f7915573c7e97b47efa546f5f6e3230263bcb49602052604090205460ff1615610cda57565b63e2517d3f60e01b60005233600452600060245260446000fd5b80600052600160205260406000206001600160a01b03331660005260205260ff6040600020541615610d235750565b63e2517d3f60e01b6000523360045260245260446000fd5b6001600160a01b03811660009081527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c602052604090205460ff1615610e07576001600160a01b031660008181527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c60205260408120805460ff191690553391907f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9080a4600190565b50600090565b80600052600160205260406000206001600160a01b03831660005260205260ff60406000205416600014610e9c5780600052600160205260406000206001600160a01b038316600052602052604060002060ff1981541690556001600160a01b03339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b600080a4600190565b5050600090565b6001600160a01b03811660009081527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c602052604090205460ff16610e07576001600160a01b031660008181527f517c3180cd5c038a24c2bda58d168e1080be916aa9a1aa6342b60a90851f011c60205260408120805460ff191660011790553391907f4ed7541f05bc3c369c29e915cb391e013776aff19c61f847b02047d21280f86d907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b80600052600160205260406000206001600160a01b03831660005260205260ff6040600020541615600014610e9c5780600052600160205260406000206001600160a01b0383166000526020526040600020600160ff198254161790556001600160a01b03339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d600080a4600190565b60028054146110135760028055565b7f3ee5aeb50000000000000000000000000000000000000000000000000000000060005260046000fd5b60ff6003541661104957565b7fd93c06650000000000000000000000000000000000000000000000000000000060005260046000fd5b356001600160a01b03811681036101dc5790565b9035907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1813603018212156101dc570180359067ffffffffffffffff82116101dc57602001918160051b360383136101dc57565b6001600160a01b036110ec82611073565b161561038b576001600160a01b0361110660208301611073565b161561038b57604081013580156111c15764e8d4a5100081109081156111eb575b506111c1576060810161113a8183611087565b9050159182156111a9575b505061117f57600a541561115557565b7fb05e92fa0000000000000000000000000000000000000000000000000000000060005260046000fd5b7fb5ae13c80000000000000000000000000000000000000000000000000000000060005260046000fd5b60209250906111b791611087565b9050113880611145565b7f2c5211c60000000000000000000000000000000000000000000000000000000060005260046000fd5b6fffffffffffffffffffffffffffffffff91501138611127565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff82111761124657604052565b634e487b7160e01b600052604160045260246000fd5b9061126682611073565b602083019161127483611073565b906000926040860135927fffffffffffffffffffffffffffffffffffffffff0000000000000000000000006040519181602084019460601b16845260601b166034820152836048820152604881526112cd606882611205565b519020936112de6060870187611087565b939095600a549667ffffffffffffffff8611611650578560051b604051966113096020830189611205565b8752602087019082019136831161164c57905b82821061163c575050509685975b855189101561136d5760208960051b870101519081811060001461135c5787526020526001604087205b98019761132a565b908752602052600160408720611354565b9195939750935094909403611614576001600160a01b0361138d83611073565b1681526005602052604081206001600160a01b036113aa86611073565b1682526020526040812054808411156115ec5783039283116115d8576001600160a01b036113d783611073565b1681526005602052604081206001600160a01b036113f486611073565b168252602052611408836040832054610c7e565b6001600160a01b0361141984611073565b1682526005602052604082206001600160a01b0361143687611073565b168352602052604082205481106115b0576001600160a01b0361145884611073565b1682526005602052604082206001600160a01b0361147587611073565b16835260205260408220556001600160a01b0361149183611073565b16815260066020524260408220556001600160a01b03600754166114b483611073565b6114bd86611073565b91803b156115ac5760648492836001600160a01b03938460405197889687957f654e7e150000000000000000000000000000000000000000000000000000000087521660048601521660248401528960448401525af180156115a15761157f6115797fd92c424393cb3ccdf7d5e36602e3bfa34f24490579ba47978f4bcfad496995f2956040956001600160a01b03958695611591575b505061157488856115648c611073565b1661156e84611073565b906116a6565b611073565b96611073565b835195865242602087015216941692a3565b8161159b91611205565b38611554565b6040513d84823e3d90fd5b8380fd5b6004827ff1075a7a000000000000000000000000000000000000000000000000000000008152fd5b80634e487b7160e01b602492526011600452fd5b6004827f646cf558000000000000000000000000000000000000000000000000000000008152fd5b807fb05e92fa0000000000000000000000000000000000000000000000000000000060049252fd5b813581526020918201910161131c565b8880fd5b602487634e487b7160e01b81526041600452fd5b6001600160a01b0360005416330361167857565b7f118cdaa7000000000000000000000000000000000000000000000000000000006000523360045260246000fd5b91602091600091604051906001600160a01b03858301937fa9059cbb0000000000000000000000000000000000000000000000000000000085521660248301526044820152604481526116fa606482611205565b519082855af115611762576000513d61175957506001600160a01b0381163b155b6117225750565b6001600160a01b03907f5274afe7000000000000000000000000000000000000000000000000000000006000521660045260246000fd5b6001141561171b565b6040513d6000823e3d90fdfea2646970667358221220d5265e97014ed9498ed43dbb355dcbee26e0e29ddcc352a093b3ab117368ee7464736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000035e9ad8a0ef4079e1e91f0db16ffa9f5032679a0000000000000000000000007bf60411d3238c508f6bf4603ec651bc2d98034c000000000000000000000000ed3af36d7b9c5bbd7ecfa7fb794eda6e242016f50000000000000000000000000000000000000000000000000000000000000032
-----Decoded View---------------
Arg [0] : _referralSystem (address): 0x035e9ad8A0Ef4079e1E91F0dB16fFa9F5032679a
Arg [1] : _rewardToken (address): 0x7Bf60411D3238c508f6bf4603EC651bC2d98034c
Arg [2] : _treasury (address): 0xeD3Af36D7b9C5Bbd7ECFa7fb794eDa6E242016f5
Arg [3] : _maxBatchSize (uint256): 50
-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000035e9ad8a0ef4079e1e91f0db16ffa9f5032679a
Arg [1] : 0000000000000000000000007bf60411d3238c508f6bf4603ec651bc2d98034c
Arg [2] : 000000000000000000000000ed3af36d7b9c5bbd7ecfa7fb794eda6e242016f5
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000032
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
[ Download: CSV Export ]
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.