Source Code
Latest 25 from a total of 14,187 transactions
| Transaction Hash |
|
Block
|
From
|
To
|
|||||
|---|---|---|---|---|---|---|---|---|---|
| Claim | 41235271 | 38 hrs ago | IN | 0 ETH | 0.00000036 | ||||
| Claim | 40627603 | 15 days ago | IN | 0 ETH | 0.00000023 | ||||
| Claim | 40546123 | 17 days ago | IN | 0 ETH | 0.00000066 | ||||
| Claim | 40302610 | 23 days ago | IN | 0 ETH | 0.00000047 | ||||
| Claim And Stake | 40294848 | 23 days ago | IN | 0 ETH | 0.00000201 | ||||
| Claim | 40267445 | 23 days ago | IN | 0 ETH | 0.0000004 | ||||
| Claim | 40157940 | 26 days ago | IN | 0 ETH | 0.00000047 | ||||
| Claim | 40059098 | 28 days ago | IN | 0 ETH | 0.00000021 | ||||
| Claim | 40022792 | 29 days ago | IN | 0 ETH | 0.00000005 | ||||
| Claim | 39855699 | 33 days ago | IN | 0 ETH | 0.00000015 | ||||
| Claim | 39855629 | 33 days ago | IN | 0 ETH | 0.00000013 | ||||
| Claim | 39855554 | 33 days ago | IN | 0 ETH | 0.00000025 | ||||
| Claim | 39855549 | 33 days ago | IN | 0 ETH | 0.00000011 | ||||
| Claim | 39855524 | 33 days ago | IN | 0 ETH | 0.0000001 | ||||
| Claim | 39855429 | 33 days ago | IN | 0 ETH | 0.00000007 | ||||
| Claim | 39855340 | 33 days ago | IN | 0 ETH | 0.00000007 | ||||
| Claim | 39855338 | 33 days ago | IN | 0 ETH | 0.00000015 | ||||
| Claim | 39855269 | 33 days ago | IN | 0 ETH | 0.00000008 | ||||
| Claim | 39855222 | 33 days ago | IN | 0 ETH | 0.00000008 | ||||
| Claim | 39855154 | 33 days ago | IN | 0 ETH | 0.00000008 | ||||
| Claim | 39855106 | 33 days ago | IN | 0 ETH | 0.00000008 | ||||
| Claim | 39855078 | 33 days ago | IN | 0 ETH | 0.00000007 | ||||
| Claim | 39855015 | 33 days ago | IN | 0 ETH | 0.00000009 | ||||
| Claim | 39854984 | 33 days ago | IN | 0 ETH | 0.00000008 | ||||
| Claim | 39854888 | 33 days ago | IN | 0 ETH | 0.00000009 |
Cross-Chain Transactions
Loading...
Loading
Contract Name:
AirdropDistributor
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
No with 200 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
/*
Copyright 2025 Giza Association
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
pragma solidity 0.8.26;
import {Ownable} from "./utils/Ownable.sol";
import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {MerkleProof} from "openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol";
import {IStaker} from "src/interfaces/IStaker.sol";
///@title Airdrop Distributor contract
///@notice This is a contract to distribute airdrop rewards to users, this implements a merkle tree to verify the proof and efficiently distribute the rewards
contract AirdropDistributor is Ownable {
using SafeERC20 for IERC20;
event Claimed(address indexed user, uint256 amount);
event ClaimedAndStaked(address indexed user, uint256 amount);
error AlreadyClaimed();
error InvalidProof();
error NotDistributing();
/*//////////////////////////////////////////////////////////////
STORAGE
//////////////////////////////////////////////////////////////*/
IERC20 public immutable giza;
IStaker public immutable staker;
///@notice Merkle root
bytes32 public merkleRoot;
///@notice Mapping of asset to claimed bitmap
mapping(address user => bool) public isClaimed;
///@notice Is distributing
bool public isDistributing;
constructor(address _owner, address _giza, address _staker) Ownable(_owner) {
giza = IERC20(_giza);
staker = IStaker(_staker);
}
/*//////////////////////////////////////////////////////////////
ADMIN FUNCTIONS
//////////////////////////////////////////////////////////////*/
///@notice Set the merkle root
///@param _merkleRoot bytes32 of the merkle root
function setMerkleRoot(bytes32 _merkleRoot) external onlyOwner {
merkleRoot = _merkleRoot;
}
///@notice Recover asset from the contract in case of emergency
function recoverAsset(address asset, address to, uint256 amount) external onlyOwner {
IERC20(asset).safeTransfer(to, amount);
}
///@notice Send reward to the contract and activate the distribution
///@param amount amount of the reward
function sendReward(uint256 amount) external onlyOwner {
giza.safeTransferFrom(msg.sender, address(this), amount);
isDistributing = true;
}
/*//////////////////////////////////////////////////////////////
EXTERNAL FUNCTIONS
//////////////////////////////////////////////////////////////*/
///@notice Claim the reward for a given asset
///@param amount amount of the reward
///@param merkleProof bytes32[] of the merkle proof
function claim(uint256 amount, bytes32[] calldata merkleProof) external {
_claim(amount, merkleProof);
// Transfer token to the user
giza.safeTransfer(msg.sender, amount);
emit Claimed(msg.sender, amount);
}
///@notice Claim the reward for a given asset and stake it
///@param amount amount of the reward
///@param merkleProof bytes32[] of the merkle proof
function claimAndStake(uint256 amount, bytes32[] calldata merkleProof) external {
_claim(amount, merkleProof);
// Approve the staking contract to stake the tokens
giza.approve(address(staker), amount);
// Stake the tokens
staker.stakeOnBehalf(msg.sender, amount);
emit ClaimedAndStaked(msg.sender, amount);
}
function _claim(uint256 amount, bytes32[] calldata merkleProof) internal {
address user = msg.sender;
if (!isDistributing || merkleRoot == bytes32(0)) revert NotDistributing();
if (isClaimed[user]) revert AlreadyClaimed();
// Verify the merkle proof.
bytes32 node = keccak256(bytes.concat(keccak256(abi.encode(user, amount))));
if (!MerkleProof.verify(merkleProof, merkleRoot, node)) revert InvalidProof();
isClaimed[user] = true;
}
}// SPDX-License-Identifier: MIT
/*
Copyright 2025 Giza Association
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
pragma solidity 0.8.26;
///@title Ownable contract
/// @notice Simple 2step owner authorization combining solmate and OZ implementation
abstract contract Ownable {
/*//////////////////////////////////////////////////////////////
STORAGE
//////////////////////////////////////////////////////////////*/
///@notice Address of the owner
address public owner;
///@notice Address of the pending owner
address public pendingOwner;
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OwnershipTransferred(address indexed user, address indexed newOner);
event OwnershipTransferStarted(address indexed user, address indexed newOwner);
event OwnershipTransferCanceled(address indexed pendingOwner);
/*//////////////////////////////////////////////////////////////
ERROR
//////////////////////////////////////////////////////////////*/
error Unauthorized();
/*//////////////////////////////////////////////////////////////
CONSTRUCTOR
//////////////////////////////////////////////////////////////*/
constructor(address _owner) {
owner = _owner;
emit OwnershipTransferred(address(0), _owner);
}
/*//////////////////////////////////////////////////////////////
OWNERSHIP LOGIC
//////////////////////////////////////////////////////////////*/
///@notice Transfer ownership to a new address
///@param newOwner address of the new owner
///@dev newOwner have to acceptOwnership
function transferOwnership(address newOwner) external onlyOwner {
pendingOwner = newOwner;
emit OwnershipTransferStarted(msg.sender, newOwner);
}
///@notice NewOwner accept the ownership, it transfer the ownership to newOwner
function acceptOwnership() external {
if (msg.sender != pendingOwner) revert Unauthorized();
address oldOwner = owner;
owner = pendingOwner;
delete pendingOwner;
emit OwnershipTransferred(oldOwner, owner);
}
///@notice Cancel the ownership transfer
function cancelTransferOwnership() external onlyOwner {
emit OwnershipTransferCanceled(pendingOwner);
delete pendingOwner;
}
modifier onlyOwner() {
if (msg.sender != owner) revert Unauthorized();
_;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (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
pragma solidity 0.8.26;
import {DepositCheckpoint, Deposit} from "src/Staker.sol";
interface IStaker {
function notifyRewardAmount(uint256 amount) external;
function getUserCheckpointHistory(address user) external view returns (DepositCheckpoint[] memory);
function stakeOnBehalf(address user, uint256 amount) external;
function getDepositorList() external view returns (address[] memory);
function getUserDeposit(address user) external view returns (Deposit memory);
function bumpEarningPower(address _user) external;
}// 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.1.0) (utils/Address.sol)
pragma solidity ^0.8.20;
import {Errors} from "./Errors.sol";
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {Errors.FailedCall} error.
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {Errors.FailedCall}) in case
* of an unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {Errors.FailedCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {Errors.FailedCall}.
*/
function _revert(bytes memory returndata) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}// 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
/*
Copyright 2025 Giza Association
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
pragma solidity 0.8.26;
/// Utils /////
import {IERC20} from "openzeppelin-contracts/contracts/token/ERC20/IERC20.sol";
import {Ownable} from "src/utils/Ownable.sol";
import {SafeERC20} from "openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {IEarningPowerCalculator} from "src/interfaces/IEarningPowerCalculator.sol";
struct Deposit {
uint128 balance;
uint128 earningPower;
uint256 rewardPerTokenCheckpoint;
uint256 scaledUnclaimedRewardCheckpoint;
}
struct DepositCheckpoint {
uint128 amount;
uint128 timestamp;
}
/// @title Staker
/// @notice A staking contract that distributes rewards based on earning power.
/// Users stake GIZA tokens to earn rewards over time, with earning power determined by stake amount.
/// Rewards are streamed continuously over a fixed duration, with each staker
/// earning proportionally to their share of total earning power.
///
/// Key features:
/// - Time-based reward distribution inspired by Synthetix StakingRewards
/// - Customizable earning power calculation via an external calculator module
/// - Early withdrawal fees that decrease linearly over 30 days
/// - Reward bumping mechanism to incentivize earning power updates
contract Staker is Ownable {
using SafeERC20 for IERC20;
using SafeCast for uint256;
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event AuthorizedStakerOnBehalfSet(address indexed authorizedStakerOnBehalf, bool isEnabled);
event RewardNotifierSet(address indexed rewardNotifier, bool isEnabled);
event BumpTipSet(uint256 oldBumpTip, uint256 newBumpTip);
event EarlyWithdrawFee(uint256 fee);
event Stake(address indexed user, uint256 amount);
event RewardClaimed(address indexed user, uint256 amount);
event RewardNotified(address indexed notifier, uint256 amount);
event RewardDurationSet(uint256 oldRewardDuration, uint256 newRewardDuration);
event StakeWithdrawn(address indexed user, uint256 amount, uint256 fee);
event EarningPowerBumped(address indexed staker, uint256 newEarningPower, uint256 oldEarningPower);
event EarningPowerCalculatorSet(address indexed earningPowerCalculator);
event EarlyWithdrawFeePeriodSet(uint256 oldEarlyWithdrawFeePeriod, uint256 newEarlyWithdrawFeePeriod);
/*//////////////////////////////////////////////////////////////
ERRORS
//////////////////////////////////////////////////////////////*/
error MaxBumpTipExceeded();
error ZeroInput();
error InvalidRewardRate();
error InsufficientRewardBalance();
error NoActiveDeposit();
error BumpNotQualified();
error InsufficientUnclaimedRewards();
error InvalidEarlyWithdrawFee();
error InvalidEarlyWithdrawFeePeriod();
/*//////////////////////////////////////////////////////////////
STORAGE
//////////////////////////////////////////////////////////////*/
/// @notice The GIZA token
IERC20 public immutable GIZA;
/// @notice The earning power calculator
IEarningPowerCalculator public earningPowerCalculator;
/// @notice Maximum early withdraw fee.
uint256 public constant MAX_EARLY_WITHDRAW_FEE = 1000; // 10%
/// @notice Early withdraw fee.
uint256 public earlyWithdrawFee;
/// @notice Early withdraw fee period.
uint256 public earlyWithdrawFeePeriod;
/// @notice Scale factor used in reward calculation math to reduce rounding errors caused by
/// truncation during division.
uint256 public constant FEE_BPS = 10000; // If fee is 500e18, then 500e18 / 100e18 = 0.05 = 5%
/// @notice Scale factor used in reward calculation math to reduce rounding errors caused by
/// truncation during division.
uint256 public constant SCALE_FACTOR = 1e36;
/// @notice Length of time over which rewards sent to this contract are distributed to stakers.
uint256 public reward_duration = 30 days;
/// @notice Maximum tip a bumper can request.
uint256 public bumpTip;
/// @notice Total fee to be collected from early withdrawals.
uint256 public feeToCollect;
/// @notice Global amount currently staked across all deposits.
uint256 public totalStaked;
/// @notice Global amount of earning power for all deposits.
uint256 public totalEarningPower;
/// @notice Time at which rewards distribution will complete if there are no new rewards.
uint256 public rewardEndTime;
/// @notice Last time at which the global rewards accumulator was updated.
uint256 public lastCheckpointTime;
/// @notice Global rate at which rewards are currently being distributed to stakers,
/// denominated in scaled reward tokens per second, using the SCALE_FACTOR.
uint256 public scaledRewardRate;
/// @notice Checkpoint value of the global reward per token accumulator.
uint256 public rewardPerTokenAccumulatedCheckpoint;
/// @notice List of depositors.
/// @dev This is used to iterate over all depositors, for off chain automations.
address[] depositorsList;
/// @notice Tracks the total staked by a depositor across all unique deposits.
mapping(address depositor => Deposit) public deposits;
/// @notice Tracks the total staked by a depositor across all unique deposits.
mapping(address depositor => DepositCheckpoint[]) public userDepositsCheckpoint;
/// @notice Maps addresses to whether they are authorized to call `notifyRewardAmount`.
mapping(address rewardNotifier => bool) public isRewardNotifier;
/// @notice Maps addresses to whether they are authorized to call `stakeOnBehalf`.
mapping(address authorizedStakerOnBehalf => bool) public isAuthorizedStakerOnBehalf;
constructor(address _owner, address _giza, address _earningPowerCalculator) Ownable(_owner) {
GIZA = IERC20(_giza);
_setEarningPowerCalculator(address(_earningPowerCalculator));
emit EarningPowerCalculatorSet(_earningPowerCalculator);
_setBumpTip(1e18);
earlyWithdrawFee = 500;
emit EarlyWithdrawFee(500);
earlyWithdrawFeePeriod = 30 days;
emit EarlyWithdrawFeePeriodSet(0, 30 days);
}
/*//////////////////////////////////////////////////////////////
OWNER
//////////////////////////////////////////////////////////////*/
/// @notice Set the authorized staker on behalf address.
/// @param _authorizedStakerOnBehalf The address of the authorized staker on behalf.
/// @param _isEnabled `true` to enable the `_authorizedStakerOnBehalf`, or `false` to disable.
function setAuthorizedStakerOnBehalf(address _authorizedStakerOnBehalf, bool _isEnabled) external onlyOwner {
isAuthorizedStakerOnBehalf[_authorizedStakerOnBehalf] = _isEnabled;
emit AuthorizedStakerOnBehalfSet(_authorizedStakerOnBehalf, _isEnabled);
}
/// @notice Set the early withdraw fee period.
/// @param _newEarlyWithdrawFeePeriod The new early withdraw fee period.
function setEarlyWithdrawFeePeriod(uint256 _newEarlyWithdrawFeePeriod) external onlyOwner {
if (_newEarlyWithdrawFeePeriod > 60 days) revert InvalidEarlyWithdrawFeePeriod();
emit EarlyWithdrawFeePeriodSet(earlyWithdrawFeePeriod, _newEarlyWithdrawFeePeriod);
earlyWithdrawFeePeriod = _newEarlyWithdrawFeePeriod;
}
/// @notice Set the earning power calculator address.
/// @param _newEarningPowerCalculator The address of the new earning power calculator.
function setEarningPowerCalculator(address _newEarningPowerCalculator) external onlyOwner {
_setEarningPowerCalculator(_newEarningPowerCalculator);
emit EarningPowerCalculatorSet(_newEarningPowerCalculator);
}
/// @notice Set the max bump tip.
/// @param _newBumpTip Value of the new max bump tip.
/// @dev Caller must be the current admin.
function setBumpTip(uint256 _newBumpTip) external onlyOwner {
_setBumpTip(_newBumpTip);
}
/// @notice Enables or disables a reward notifier address.
/// @param _rewardNotifier Address of the reward notifier.
/// @param _isEnabled `true` to enable the `_rewardNotifier`, or `false` to disable.
/// @dev Caller must be the current admin.
function setRewardNotifier(address _rewardNotifier, bool _isEnabled) external onlyOwner {
isRewardNotifier[_rewardNotifier] = _isEnabled;
emit RewardNotifierSet(_rewardNotifier, _isEnabled);
}
/// @notice Set the reward duration.
/// @param _newRewardDuration Value of the new reward duration.
/// @dev Caller must be the current admin.
function setRewardDuration(uint256 _newRewardDuration) external onlyOwner {
if (_newRewardDuration == 0) revert ZeroInput();
reward_duration = _newRewardDuration;
emit RewardDurationSet(reward_duration, _newRewardDuration);
}
/// @notice Set the early withdraw fee.
/// @param _newEarlyWithdrawFee Value of the new early withdraw fee.
/// @dev Caller must be the current admin.
function setEarlyWithdrawFee(uint256 _newEarlyWithdrawFee) external onlyOwner {
if (_newEarlyWithdrawFee > MAX_EARLY_WITHDRAW_FEE) revert InvalidEarlyWithdrawFee();
earlyWithdrawFee = _newEarlyWithdrawFee;
emit EarlyWithdrawFee(earlyWithdrawFee);
}
/// @notice Collect the fee to be collected from early withdrawals.
function collectFee() external onlyOwner {
uint256 _feeToCollect = feeToCollect;
feeToCollect = 0;
GIZA.safeTransfer(owner, _feeToCollect);
}
/*//////////////////////////////////////////////////////////////
ENTRYPOINTS
//////////////////////////////////////////////////////////////*/
/// @notice Called by an authorized rewards notifier to alert the staking contract that a new
/// reward has been transferred to it. It is assumed that the reward has already been
/// transferred to this staking contract before the rewards notifier calls this method.
/// @param _amount Quantity of reward tokens the staking contract is being notified of.
/// @dev It is critical that only well behaved contracts are approved by the admin to call this
/// method, for two reasons.
///
/// 1. A misbehaving contract could grief stakers by frequently notifying this contract of tiny
/// rewards, thereby continuously stretching out the time duration over which real rewards are
/// distributed. It is required that reward notifiers supply reasonable rewards at reasonable
/// intervals.
// 2. A misbehaving contract could falsely notify this contract of rewards that were not actually
/// distributed, creating a shortfall for those claiming their rewards after others. It is
/// required that a notifier contract always transfers the `_amount` to this contract before
/// calling this method.
function notifyRewardAmount(uint256 _amount) external virtual {
if (!isRewardNotifier[msg.sender]) revert Unauthorized();
// We checkpoint the accumulator without updating the timestamp at which it was updated,
// because that second operation will be done after updating the reward rate.
rewardPerTokenAccumulatedCheckpoint = rewardPerTokenAccumulated();
if (block.timestamp >= rewardEndTime) {
scaledRewardRate = (_amount * SCALE_FACTOR) / reward_duration;
} else {
uint256 _remainingReward = scaledRewardRate * (rewardEndTime - block.timestamp);
scaledRewardRate = (_remainingReward + _amount * SCALE_FACTOR) / reward_duration;
}
rewardEndTime = block.timestamp + reward_duration;
lastCheckpointTime = block.timestamp;
if ((scaledRewardRate / SCALE_FACTOR) == 0) revert InvalidRewardRate();
GIZA.safeTransferFrom(msg.sender, address(this), _amount);
emit RewardNotified(msg.sender, _amount);
}
/// @notice Stake a given amount of GIZA tokens.
/// @param amount The amount of GIZA tokens to stake.
function stake(uint256 amount) external {
_stake(msg.sender, amount);
}
/// @notice Stake a given amount of GIZA tokens on behalf of a user.
/// @param user The address of the user to stake for.
/// @param amount The amount of GIZA tokens to stake.
function stakeOnBehalf(address user, uint256 amount) external {
if (!isAuthorizedStakerOnBehalf[msg.sender]) revert Unauthorized();
_stake(user, amount);
}
/// @notice Claim reward tokens earned by a given deposit.
function claimReward() external {
_claimReward(msg.sender);
}
/// @notice Withdraw a given amount of GIZA tokens.
/// @dev This function allow only for a full withdraw
function withdraw() external {
if (deposits[msg.sender].balance == 0) revert NoActiveDeposit();
// Calculate reward without updating earning power
uint256 reward = _calculateReward(msg.sender);
uint256 fee = calculateWithdrawalFee(msg.sender);
uint256 amount = deposits[msg.sender].balance;
// Update state variables before transfer
totalStaked -= amount;
totalEarningPower = _calculateTotalEarningPower(deposits[msg.sender].earningPower, 0, totalEarningPower);
// Clean up user data
delete deposits[msg.sender];
delete userDepositsCheckpoint[msg.sender];
// Update fee to collect
feeToCollect += fee;
// Combine transfers - send both reward and deposit amount (minus fee) in one transfer
emit RewardClaimed(msg.sender, reward);
emit StakeWithdrawn(msg.sender, amount - fee, fee);
// Single transfer of both reward and withdrawn amount
GIZA.safeTransfer(msg.sender, reward + amount - fee);
}
/// @notice A function that a bumper can call to update a deposit's earning power when a
/// qualifying change in the earning power is returned by the earning power calculator. A
/// deposit's earning power may change as determined by the algorithm of the current earning power
/// calculator. In order to incentivize bumpers to trigger these updates a portion of deposit's
/// unclaimed rewards are sent to the bumper.
function bumpEarningPower(address _user) external {
Deposit storage deposit = deposits[_user];
_checkpointGlobalReward();
_checkpointReward(deposit);
uint256 _unclaimedRewards = deposit.scaledUnclaimedRewardCheckpoint / SCALE_FACTOR;
(uint256 _newEarningPower, bool _isQualifiedForBump) =
earningPowerCalculator.getNewEarningPower(deposit.balance, _user, deposit.earningPower);
if (!_isQualifiedForBump) {
revert BumpNotQualified();
}
if (_unclaimedRewards < bumpTip) {
revert InsufficientUnclaimedRewards();
}
emit EarningPowerBumped(_user, _newEarningPower, deposit.earningPower);
// Update global earning power & deposit earning power based on this bump
totalEarningPower = _calculateTotalEarningPower(deposit.earningPower, _newEarningPower, totalEarningPower);
deposit.earningPower = _newEarningPower.toUint96();
// Send tip to the receiver
deposit.scaledUnclaimedRewardCheckpoint = deposit.scaledUnclaimedRewardCheckpoint - (bumpTip * SCALE_FACTOR);
GIZA.safeTransfer(msg.sender, bumpTip);
}
/*//////////////////////////////////////////////////////////////
VIEW
//////////////////////////////////////////////////////////////*/
/// @notice Get the list of depositors.
/// @return List of depositors.
/// @dev This is used for off chain automations => for bumping logic
function getDepositorsList() external view returns (address[] memory) {
return depositorsList;
}
/// @notice Returns the voting power of a user
/// @param user the user to get the voting power of
/// @return the voting power of the user
/// @dev This is used for voting and governance purposes and intented to be called offchain by Snapshot, this take into account the earning power of the user
function votingPower(address user) external view returns (uint256) {
return deposits[user].earningPower;
}
/// @notice Timestamp representing the last time at which rewards have been distributed, which is
/// either the current timestamp (because rewards are still actively being streamed) or the time
/// at which the reward duration ended (because all rewards to date have already been streamed).
/// @return Timestamp representing the last time at which rewards have been distributed.
function lastTimeRewardDistributed() public view returns (uint256) {
if (rewardEndTime <= block.timestamp) return rewardEndTime;
else return block.timestamp;
}
/// @notice Live value of the global reward per token accumulator. It is the sum of the last
/// checkpoint value with the live calculation of the value that has accumulated in the interim.
/// This number should monotonically increase over time as more rewards are distributed.
/// @return Live value of the global reward per token accumulator.
function rewardPerTokenAccumulated() public view returns (uint256) {
if (totalEarningPower == 0) return rewardPerTokenAccumulatedCheckpoint;
return rewardPerTokenAccumulatedCheckpoint
+ (scaledRewardRate * (lastTimeRewardDistributed() - lastCheckpointTime)) / totalEarningPower;
}
/// @notice Live value of the unclaimed rewards earned by a given deposit. It is the
/// sum of the last checkpoint value of the unclaimed rewards with the live calculation of the
/// rewards that have accumulated for this account in the interim. This value can only increase,
/// until it is reset to zero once the unearned rewards are claimed.
///
/// Note that the contract tracks the unclaimed rewards internally with the scale factor
/// included, in order to avoid the accrual of precision losses as users takes actions that
/// cause rewards to be checkpointed. This external helper method is useful for integrations, and
/// returns the value after it has been scaled down to the reward token's raw decimal amount.
/// @param user Address of the user in question.
/// @return Live value of the unclaimed rewards earned by a given deposit.
function unclaimedReward(address user) external view virtual returns (uint256) {
return _scaledUnclaimedReward(deposits[user]) / SCALE_FACTOR;
}
/// @notice Get the user checkpoint history
/// @param user The address of the user to get the checkpoint history for
/// @return The checkpoint history for the user
function getUserCheckpointHistory(address user) external view returns (DepositCheckpoint[] memory) {
return userDepositsCheckpoint[user];
}
/// @notice Get a specific checkpoint from the user's checkpoint history
/// @param user The address of the user to get the checkpoint from
/// @param index The index of the checkpoint to get
/// @return The checkpoint at the given index
function getUserCheckPointHistory(address user, uint256 index) external view returns (DepositCheckpoint memory) {
return userDepositsCheckpoint[user][index];
}
/// @notice Get a specific deposit from the user's deposit history
/// @param user The address of the user to get the deposit from
/// @return The deposit at the given index
function getUserDeposit(address user) external view returns (Deposit memory) {
return deposits[user];
}
/// @notice Public function to calculate the total withdrawal fee for a user
/// @param user Address of the user to calculate fee for
/// @return totalFee Total fee amount that would be charged on withdrawal
function calculateWithdrawalFee(address user) public view returns (uint256) {
DepositCheckpoint[] memory checkpoints = userDepositsCheckpoint[user];
// If no checkpoints or no active deposit, return 0
if (checkpoints.length == 0 || deposits[user].balance == 0) {
return 0;
}
uint256 totalFee = 0;
for (uint256 i = 0; i < checkpoints.length; i++) {
totalFee += _calculateFeeForDeposit(checkpoints[i].amount, checkpoints[i].timestamp);
}
return totalFee;
}
/// @notice Get the list of depositors
/// @return The list of depositors
function getDepositorList() external view returns (address[] memory) {
return depositorsList;
}
/*//////////////////////////////////////////////////////////////
INTERNAL
//////////////////////////////////////////////////////////////*/
/// @notice Stake a given amount of GIZA tokens.
/// @param _user The address of the user to stake for.
/// @param _amount The amount of GIZA tokens to stake.
function _stake(address _user, uint256 _amount) internal {
if (_amount == 0 || _user == address(0)) revert ZeroInput();
_checkpointGlobalReward();
// Check if the user already has a deposit
Deposit storage userDeposit = deposits[_user];
// We add the checkpoint to the user's deposit history, EarningPower will use it to calculate the earning power
userDepositsCheckpoint[_user].push(
DepositCheckpoint({amount: _amount.toUint128(), timestamp: block.timestamp.toUint128()})
);
if (userDeposit.balance == 0) {
// New deposit
uint256 _earningPower = earningPowerCalculator.getEarningPower(_amount, _user);
totalStaked += _amount;
totalEarningPower += _earningPower;
deposits[_user] = Deposit({
balance: _amount.toUint128(),
earningPower: _earningPower.toUint128(),
rewardPerTokenCheckpoint: rewardPerTokenAccumulatedCheckpoint,
scaledUnclaimedRewardCheckpoint: 0
});
depositorsList.push(_user);
} else {
// Existing deposit - update with additional stake
_checkpointReward(userDeposit);
uint256 _newBalance = userDeposit.balance + _amount;
uint256 _newEarningPower = earningPowerCalculator.getEarningPower(_newBalance, _user);
totalStaked += _amount;
totalEarningPower = totalEarningPower - userDeposit.earningPower + _newEarningPower;
userDeposit.balance = _newBalance.toUint128();
userDeposit.earningPower = _newEarningPower.toUint128();
}
GIZA.safeTransferFrom(msg.sender, address(this), _amount);
emit Stake(_user, _amount);
}
function _claimReward(address _claimer) internal {
uint256 _reward = _calculateReward(_claimer);
Deposit storage deposit = deposits[_claimer];
// Only update earning power when claiming rewards (not during withdrawal)
uint256 _newEarningPower = earningPowerCalculator.getEarningPower(deposit.balance, _claimer);
totalEarningPower = _calculateTotalEarningPower(deposit.earningPower, _newEarningPower, totalEarningPower);
deposit.earningPower = _newEarningPower.toUint96();
emit RewardClaimed(_claimer, _reward);
GIZA.safeTransfer(_claimer, _reward);
}
/// @notice Internal helper method which calculates reward tokens earned by a given deposit without updating earning power.
/// @param _claimer The address of the claimer
/// @return _reward The amount of reward tokens earned
function _calculateReward(address _claimer) internal returns (uint256 _reward) {
Deposit storage deposit = deposits[_claimer];
_checkpointGlobalReward();
_checkpointReward(deposit);
_reward = deposit.scaledUnclaimedRewardCheckpoint / SCALE_FACTOR;
// Reset the scaled unclaimed reward checkpoint, retaining sub-wei dust
deposit.scaledUnclaimedRewardCheckpoint = deposit.scaledUnclaimedRewardCheckpoint - (_reward * SCALE_FACTOR);
return _reward;
}
/// @notice Checkpoints the global reward per token accumulator.
function _checkpointGlobalReward() internal {
rewardPerTokenAccumulatedCheckpoint = rewardPerTokenAccumulated();
lastCheckpointTime = lastTimeRewardDistributed();
}
/// @notice Internal helper method which calculates and returns an updated value for total
/// earning power based on the old and new earning power of a deposit which is being changed.
/// @param _depositOldEarningPower The earning power of the deposit before a change is applied.
/// @param _depositNewEarningPower The earning power of the deposit after a change is applied.
/// @return _newTotalEarningPower The new total earning power.
function _calculateTotalEarningPower(
uint256 _depositOldEarningPower,
uint256 _depositNewEarningPower,
uint256 _totalEarningPower
) internal pure returns (uint256 _newTotalEarningPower) {
return _totalEarningPower + _depositNewEarningPower - _depositOldEarningPower;
}
/// @notice Live value of the unclaimed rewards earned by a given deposit with the
/// scale factor included. Used internally for calculating reward checkpoints while minimizing
/// precision loss.
/// @return Live value of the unclaimed rewards earned by a given deposit with the
/// scale factor included.
/// @dev See documentation for the public, non-scaled `unclaimedReward` method for more details.
function _scaledUnclaimedReward(Deposit storage deposit) internal view virtual returns (uint256) {
return deposit.scaledUnclaimedRewardCheckpoint
+ (deposit.earningPower * (rewardPerTokenAccumulated() - deposit.rewardPerTokenCheckpoint));
}
/// @notice Checkpoints the unclaimed rewards and reward per token accumulator of a given deposit.
/// @param deposit The deposit for which the reward parameters will be checkpointed.
/// @dev This method calculates and updates the unclaimed rewards for a deposit.
function _checkpointReward(Deposit storage deposit) internal {
uint256 scaledUnclaimedReward = deposit.scaledUnclaimedRewardCheckpoint
+ (deposit.earningPower * (rewardPerTokenAccumulated() - deposit.rewardPerTokenCheckpoint));
deposit.scaledUnclaimedRewardCheckpoint = scaledUnclaimedReward;
deposit.rewardPerTokenCheckpoint = rewardPerTokenAccumulatedCheckpoint;
}
/// @notice Internal helper method which sets the bump tip.
/// @param _newBumpTip Value of the new bump tip.
function _setBumpTip(uint256 _newBumpTip) internal {
emit BumpTipSet(bumpTip, _newBumpTip);
bumpTip = _newBumpTip;
}
/// @notice Internal helper method which sets the earning power calculator address.
function _setEarningPowerCalculator(address _newEarningPowerCalculator) internal {
if (_newEarningPowerCalculator == address(0)) revert ZeroInput();
earningPowerCalculator = IEarningPowerCalculator(_newEarningPowerCalculator);
}
/// @notice Calculate fee for a single deposit based on time elapsed
/// @param depositAmount The amount of the deposit
/// @param depositTimestamp When the deposit was made
/// @return Fee amount to be charged
function _calculateFeeForDeposit(uint256 depositAmount, uint256 depositTimestamp) internal view returns (uint256) {
uint256 timeElapsed = block.timestamp - depositTimestamp;
if (timeElapsed >= earlyWithdrawFeePeriod) {
return 0;
}
// Linear decay
uint256 remainingFeePercentage =
earlyWithdrawFee - ((timeElapsed * earlyWithdrawFee) / (earlyWithdrawFeePeriod));
// Calculate fee: amount * percentage / 10000 (for basis points)
return (depositAmount * remainingFeePercentage) / FEE_BPS;
}
}// 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.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of common custom errors used in multiple contracts
*
* IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
* It is recommended to avoid relying on the error API for critical functionality.
*
* _Available since v5.1._
*/
library Errors {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error InsufficientBalance(uint256 balance, uint256 needed);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedCall();
/**
* @dev The deployment failed.
*/
error FailedDeployment();
/**
* @dev A necessary precompile is missing.
*/
error MissingPrecompile(address);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.
pragma solidity ^0.8.20;
/**
* @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeCast {
/**
* @dev Value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);
/**
* @dev An int value doesn't fit in an uint of `bits` size.
*/
error SafeCastOverflowedIntToUint(int256 value);
/**
* @dev Value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);
/**
* @dev An uint value doesn't fit in an int of `bits` size.
*/
error SafeCastOverflowedUintToInt(uint256 value);
/**
* @dev Returns the downcasted uint248 from uint256, reverting on
* overflow (when the input is greater than largest uint248).
*
* Counterpart to Solidity's `uint248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toUint248(uint256 value) internal pure returns (uint248) {
if (value > type(uint248).max) {
revert SafeCastOverflowedUintDowncast(248, value);
}
return uint248(value);
}
/**
* @dev Returns the downcasted uint240 from uint256, reverting on
* overflow (when the input is greater than largest uint240).
*
* Counterpart to Solidity's `uint240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toUint240(uint256 value) internal pure returns (uint240) {
if (value > type(uint240).max) {
revert SafeCastOverflowedUintDowncast(240, value);
}
return uint240(value);
}
/**
* @dev Returns the downcasted uint232 from uint256, reverting on
* overflow (when the input is greater than largest uint232).
*
* Counterpart to Solidity's `uint232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toUint232(uint256 value) internal pure returns (uint232) {
if (value > type(uint232).max) {
revert SafeCastOverflowedUintDowncast(232, value);
}
return uint232(value);
}
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
if (value > type(uint224).max) {
revert SafeCastOverflowedUintDowncast(224, value);
}
return uint224(value);
}
/**
* @dev Returns the downcasted uint216 from uint256, reverting on
* overflow (when the input is greater than largest uint216).
*
* Counterpart to Solidity's `uint216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toUint216(uint256 value) internal pure returns (uint216) {
if (value > type(uint216).max) {
revert SafeCastOverflowedUintDowncast(216, value);
}
return uint216(value);
}
/**
* @dev Returns the downcasted uint208 from uint256, reverting on
* overflow (when the input is greater than largest uint208).
*
* Counterpart to Solidity's `uint208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toUint208(uint256 value) internal pure returns (uint208) {
if (value > type(uint208).max) {
revert SafeCastOverflowedUintDowncast(208, value);
}
return uint208(value);
}
/**
* @dev Returns the downcasted uint200 from uint256, reverting on
* overflow (when the input is greater than largest uint200).
*
* Counterpart to Solidity's `uint200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toUint200(uint256 value) internal pure returns (uint200) {
if (value > type(uint200).max) {
revert SafeCastOverflowedUintDowncast(200, value);
}
return uint200(value);
}
/**
* @dev Returns the downcasted uint192 from uint256, reverting on
* overflow (when the input is greater than largest uint192).
*
* Counterpart to Solidity's `uint192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toUint192(uint256 value) internal pure returns (uint192) {
if (value > type(uint192).max) {
revert SafeCastOverflowedUintDowncast(192, value);
}
return uint192(value);
}
/**
* @dev Returns the downcasted uint184 from uint256, reverting on
* overflow (when the input is greater than largest uint184).
*
* Counterpart to Solidity's `uint184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toUint184(uint256 value) internal pure returns (uint184) {
if (value > type(uint184).max) {
revert SafeCastOverflowedUintDowncast(184, value);
}
return uint184(value);
}
/**
* @dev Returns the downcasted uint176 from uint256, reverting on
* overflow (when the input is greater than largest uint176).
*
* Counterpart to Solidity's `uint176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toUint176(uint256 value) internal pure returns (uint176) {
if (value > type(uint176).max) {
revert SafeCastOverflowedUintDowncast(176, value);
}
return uint176(value);
}
/**
* @dev Returns the downcasted uint168 from uint256, reverting on
* overflow (when the input is greater than largest uint168).
*
* Counterpart to Solidity's `uint168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toUint168(uint256 value) internal pure returns (uint168) {
if (value > type(uint168).max) {
revert SafeCastOverflowedUintDowncast(168, value);
}
return uint168(value);
}
/**
* @dev Returns the downcasted uint160 from uint256, reverting on
* overflow (when the input is greater than largest uint160).
*
* Counterpart to Solidity's `uint160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toUint160(uint256 value) internal pure returns (uint160) {
if (value > type(uint160).max) {
revert SafeCastOverflowedUintDowncast(160, value);
}
return uint160(value);
}
/**
* @dev Returns the downcasted uint152 from uint256, reverting on
* overflow (when the input is greater than largest uint152).
*
* Counterpart to Solidity's `uint152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toUint152(uint256 value) internal pure returns (uint152) {
if (value > type(uint152).max) {
revert SafeCastOverflowedUintDowncast(152, value);
}
return uint152(value);
}
/**
* @dev Returns the downcasted uint144 from uint256, reverting on
* overflow (when the input is greater than largest uint144).
*
* Counterpart to Solidity's `uint144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toUint144(uint256 value) internal pure returns (uint144) {
if (value > type(uint144).max) {
revert SafeCastOverflowedUintDowncast(144, value);
}
return uint144(value);
}
/**
* @dev Returns the downcasted uint136 from uint256, reverting on
* overflow (when the input is greater than largest uint136).
*
* Counterpart to Solidity's `uint136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toUint136(uint256 value) internal pure returns (uint136) {
if (value > type(uint136).max) {
revert SafeCastOverflowedUintDowncast(136, value);
}
return uint136(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
if (value > type(uint128).max) {
revert SafeCastOverflowedUintDowncast(128, value);
}
return uint128(value);
}
/**
* @dev Returns the downcasted uint120 from uint256, reverting on
* overflow (when the input is greater than largest uint120).
*
* Counterpart to Solidity's `uint120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toUint120(uint256 value) internal pure returns (uint120) {
if (value > type(uint120).max) {
revert SafeCastOverflowedUintDowncast(120, value);
}
return uint120(value);
}
/**
* @dev Returns the downcasted uint112 from uint256, reverting on
* overflow (when the input is greater than largest uint112).
*
* Counterpart to Solidity's `uint112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toUint112(uint256 value) internal pure returns (uint112) {
if (value > type(uint112).max) {
revert SafeCastOverflowedUintDowncast(112, value);
}
return uint112(value);
}
/**
* @dev Returns the downcasted uint104 from uint256, reverting on
* overflow (when the input is greater than largest uint104).
*
* Counterpart to Solidity's `uint104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toUint104(uint256 value) internal pure returns (uint104) {
if (value > type(uint104).max) {
revert SafeCastOverflowedUintDowncast(104, value);
}
return uint104(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
if (value > type(uint96).max) {
revert SafeCastOverflowedUintDowncast(96, value);
}
return uint96(value);
}
/**
* @dev Returns the downcasted uint88 from uint256, reverting on
* overflow (when the input is greater than largest uint88).
*
* Counterpart to Solidity's `uint88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toUint88(uint256 value) internal pure returns (uint88) {
if (value > type(uint88).max) {
revert SafeCastOverflowedUintDowncast(88, value);
}
return uint88(value);
}
/**
* @dev Returns the downcasted uint80 from uint256, reverting on
* overflow (when the input is greater than largest uint80).
*
* Counterpart to Solidity's `uint80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toUint80(uint256 value) internal pure returns (uint80) {
if (value > type(uint80).max) {
revert SafeCastOverflowedUintDowncast(80, value);
}
return uint80(value);
}
/**
* @dev Returns the downcasted uint72 from uint256, reverting on
* overflow (when the input is greater than largest uint72).
*
* Counterpart to Solidity's `uint72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toUint72(uint256 value) internal pure returns (uint72) {
if (value > type(uint72).max) {
revert SafeCastOverflowedUintDowncast(72, value);
}
return uint72(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
if (value > type(uint64).max) {
revert SafeCastOverflowedUintDowncast(64, value);
}
return uint64(value);
}
/**
* @dev Returns the downcasted uint56 from uint256, reverting on
* overflow (when the input is greater than largest uint56).
*
* Counterpart to Solidity's `uint56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toUint56(uint256 value) internal pure returns (uint56) {
if (value > type(uint56).max) {
revert SafeCastOverflowedUintDowncast(56, value);
}
return uint56(value);
}
/**
* @dev Returns the downcasted uint48 from uint256, reverting on
* overflow (when the input is greater than largest uint48).
*
* Counterpart to Solidity's `uint48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toUint48(uint256 value) internal pure returns (uint48) {
if (value > type(uint48).max) {
revert SafeCastOverflowedUintDowncast(48, value);
}
return uint48(value);
}
/**
* @dev Returns the downcasted uint40 from uint256, reverting on
* overflow (when the input is greater than largest uint40).
*
* Counterpart to Solidity's `uint40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toUint40(uint256 value) internal pure returns (uint40) {
if (value > type(uint40).max) {
revert SafeCastOverflowedUintDowncast(40, value);
}
return uint40(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
if (value > type(uint32).max) {
revert SafeCastOverflowedUintDowncast(32, value);
}
return uint32(value);
}
/**
* @dev Returns the downcasted uint24 from uint256, reverting on
* overflow (when the input is greater than largest uint24).
*
* Counterpart to Solidity's `uint24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toUint24(uint256 value) internal pure returns (uint24) {
if (value > type(uint24).max) {
revert SafeCastOverflowedUintDowncast(24, value);
}
return uint24(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
if (value > type(uint16).max) {
revert SafeCastOverflowedUintDowncast(16, value);
}
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toUint8(uint256 value) internal pure returns (uint8) {
if (value > type(uint8).max) {
revert SafeCastOverflowedUintDowncast(8, value);
}
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
if (value < 0) {
revert SafeCastOverflowedIntToUint(value);
}
return uint256(value);
}
/**
* @dev Returns the downcasted int248 from int256, reverting on
* overflow (when the input is less than smallest int248 or
* greater than largest int248).
*
* Counterpart to Solidity's `int248` operator.
*
* Requirements:
*
* - input must fit into 248 bits
*/
function toInt248(int256 value) internal pure returns (int248 downcasted) {
downcasted = int248(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(248, value);
}
}
/**
* @dev Returns the downcasted int240 from int256, reverting on
* overflow (when the input is less than smallest int240 or
* greater than largest int240).
*
* Counterpart to Solidity's `int240` operator.
*
* Requirements:
*
* - input must fit into 240 bits
*/
function toInt240(int256 value) internal pure returns (int240 downcasted) {
downcasted = int240(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(240, value);
}
}
/**
* @dev Returns the downcasted int232 from int256, reverting on
* overflow (when the input is less than smallest int232 or
* greater than largest int232).
*
* Counterpart to Solidity's `int232` operator.
*
* Requirements:
*
* - input must fit into 232 bits
*/
function toInt232(int256 value) internal pure returns (int232 downcasted) {
downcasted = int232(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(232, value);
}
}
/**
* @dev Returns the downcasted int224 from int256, reverting on
* overflow (when the input is less than smallest int224 or
* greater than largest int224).
*
* Counterpart to Solidity's `int224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toInt224(int256 value) internal pure returns (int224 downcasted) {
downcasted = int224(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(224, value);
}
}
/**
* @dev Returns the downcasted int216 from int256, reverting on
* overflow (when the input is less than smallest int216 or
* greater than largest int216).
*
* Counterpart to Solidity's `int216` operator.
*
* Requirements:
*
* - input must fit into 216 bits
*/
function toInt216(int256 value) internal pure returns (int216 downcasted) {
downcasted = int216(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(216, value);
}
}
/**
* @dev Returns the downcasted int208 from int256, reverting on
* overflow (when the input is less than smallest int208 or
* greater than largest int208).
*
* Counterpart to Solidity's `int208` operator.
*
* Requirements:
*
* - input must fit into 208 bits
*/
function toInt208(int256 value) internal pure returns (int208 downcasted) {
downcasted = int208(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(208, value);
}
}
/**
* @dev Returns the downcasted int200 from int256, reverting on
* overflow (when the input is less than smallest int200 or
* greater than largest int200).
*
* Counterpart to Solidity's `int200` operator.
*
* Requirements:
*
* - input must fit into 200 bits
*/
function toInt200(int256 value) internal pure returns (int200 downcasted) {
downcasted = int200(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(200, value);
}
}
/**
* @dev Returns the downcasted int192 from int256, reverting on
* overflow (when the input is less than smallest int192 or
* greater than largest int192).
*
* Counterpart to Solidity's `int192` operator.
*
* Requirements:
*
* - input must fit into 192 bits
*/
function toInt192(int256 value) internal pure returns (int192 downcasted) {
downcasted = int192(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(192, value);
}
}
/**
* @dev Returns the downcasted int184 from int256, reverting on
* overflow (when the input is less than smallest int184 or
* greater than largest int184).
*
* Counterpart to Solidity's `int184` operator.
*
* Requirements:
*
* - input must fit into 184 bits
*/
function toInt184(int256 value) internal pure returns (int184 downcasted) {
downcasted = int184(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(184, value);
}
}
/**
* @dev Returns the downcasted int176 from int256, reverting on
* overflow (when the input is less than smallest int176 or
* greater than largest int176).
*
* Counterpart to Solidity's `int176` operator.
*
* Requirements:
*
* - input must fit into 176 bits
*/
function toInt176(int256 value) internal pure returns (int176 downcasted) {
downcasted = int176(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(176, value);
}
}
/**
* @dev Returns the downcasted int168 from int256, reverting on
* overflow (when the input is less than smallest int168 or
* greater than largest int168).
*
* Counterpart to Solidity's `int168` operator.
*
* Requirements:
*
* - input must fit into 168 bits
*/
function toInt168(int256 value) internal pure returns (int168 downcasted) {
downcasted = int168(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(168, value);
}
}
/**
* @dev Returns the downcasted int160 from int256, reverting on
* overflow (when the input is less than smallest int160 or
* greater than largest int160).
*
* Counterpart to Solidity's `int160` operator.
*
* Requirements:
*
* - input must fit into 160 bits
*/
function toInt160(int256 value) internal pure returns (int160 downcasted) {
downcasted = int160(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(160, value);
}
}
/**
* @dev Returns the downcasted int152 from int256, reverting on
* overflow (when the input is less than smallest int152 or
* greater than largest int152).
*
* Counterpart to Solidity's `int152` operator.
*
* Requirements:
*
* - input must fit into 152 bits
*/
function toInt152(int256 value) internal pure returns (int152 downcasted) {
downcasted = int152(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(152, value);
}
}
/**
* @dev Returns the downcasted int144 from int256, reverting on
* overflow (when the input is less than smallest int144 or
* greater than largest int144).
*
* Counterpart to Solidity's `int144` operator.
*
* Requirements:
*
* - input must fit into 144 bits
*/
function toInt144(int256 value) internal pure returns (int144 downcasted) {
downcasted = int144(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(144, value);
}
}
/**
* @dev Returns the downcasted int136 from int256, reverting on
* overflow (when the input is less than smallest int136 or
* greater than largest int136).
*
* Counterpart to Solidity's `int136` operator.
*
* Requirements:
*
* - input must fit into 136 bits
*/
function toInt136(int256 value) internal pure returns (int136 downcasted) {
downcasted = int136(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(136, value);
}
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toInt128(int256 value) internal pure returns (int128 downcasted) {
downcasted = int128(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(128, value);
}
}
/**
* @dev Returns the downcasted int120 from int256, reverting on
* overflow (when the input is less than smallest int120 or
* greater than largest int120).
*
* Counterpart to Solidity's `int120` operator.
*
* Requirements:
*
* - input must fit into 120 bits
*/
function toInt120(int256 value) internal pure returns (int120 downcasted) {
downcasted = int120(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(120, value);
}
}
/**
* @dev Returns the downcasted int112 from int256, reverting on
* overflow (when the input is less than smallest int112 or
* greater than largest int112).
*
* Counterpart to Solidity's `int112` operator.
*
* Requirements:
*
* - input must fit into 112 bits
*/
function toInt112(int256 value) internal pure returns (int112 downcasted) {
downcasted = int112(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(112, value);
}
}
/**
* @dev Returns the downcasted int104 from int256, reverting on
* overflow (when the input is less than smallest int104 or
* greater than largest int104).
*
* Counterpart to Solidity's `int104` operator.
*
* Requirements:
*
* - input must fit into 104 bits
*/
function toInt104(int256 value) internal pure returns (int104 downcasted) {
downcasted = int104(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(104, value);
}
}
/**
* @dev Returns the downcasted int96 from int256, reverting on
* overflow (when the input is less than smallest int96 or
* greater than largest int96).
*
* Counterpart to Solidity's `int96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toInt96(int256 value) internal pure returns (int96 downcasted) {
downcasted = int96(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(96, value);
}
}
/**
* @dev Returns the downcasted int88 from int256, reverting on
* overflow (when the input is less than smallest int88 or
* greater than largest int88).
*
* Counterpart to Solidity's `int88` operator.
*
* Requirements:
*
* - input must fit into 88 bits
*/
function toInt88(int256 value) internal pure returns (int88 downcasted) {
downcasted = int88(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(88, value);
}
}
/**
* @dev Returns the downcasted int80 from int256, reverting on
* overflow (when the input is less than smallest int80 or
* greater than largest int80).
*
* Counterpart to Solidity's `int80` operator.
*
* Requirements:
*
* - input must fit into 80 bits
*/
function toInt80(int256 value) internal pure returns (int80 downcasted) {
downcasted = int80(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(80, value);
}
}
/**
* @dev Returns the downcasted int72 from int256, reverting on
* overflow (when the input is less than smallest int72 or
* greater than largest int72).
*
* Counterpart to Solidity's `int72` operator.
*
* Requirements:
*
* - input must fit into 72 bits
*/
function toInt72(int256 value) internal pure returns (int72 downcasted) {
downcasted = int72(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(72, value);
}
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toInt64(int256 value) internal pure returns (int64 downcasted) {
downcasted = int64(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(64, value);
}
}
/**
* @dev Returns the downcasted int56 from int256, reverting on
* overflow (when the input is less than smallest int56 or
* greater than largest int56).
*
* Counterpart to Solidity's `int56` operator.
*
* Requirements:
*
* - input must fit into 56 bits
*/
function toInt56(int256 value) internal pure returns (int56 downcasted) {
downcasted = int56(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(56, value);
}
}
/**
* @dev Returns the downcasted int48 from int256, reverting on
* overflow (when the input is less than smallest int48 or
* greater than largest int48).
*
* Counterpart to Solidity's `int48` operator.
*
* Requirements:
*
* - input must fit into 48 bits
*/
function toInt48(int256 value) internal pure returns (int48 downcasted) {
downcasted = int48(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(48, value);
}
}
/**
* @dev Returns the downcasted int40 from int256, reverting on
* overflow (when the input is less than smallest int40 or
* greater than largest int40).
*
* Counterpart to Solidity's `int40` operator.
*
* Requirements:
*
* - input must fit into 40 bits
*/
function toInt40(int256 value) internal pure returns (int40 downcasted) {
downcasted = int40(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(40, value);
}
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toInt32(int256 value) internal pure returns (int32 downcasted) {
downcasted = int32(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(32, value);
}
}
/**
* @dev Returns the downcasted int24 from int256, reverting on
* overflow (when the input is less than smallest int24 or
* greater than largest int24).
*
* Counterpart to Solidity's `int24` operator.
*
* Requirements:
*
* - input must fit into 24 bits
*/
function toInt24(int256 value) internal pure returns (int24 downcasted) {
downcasted = int24(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(24, value);
}
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits
*/
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(8, value);
}
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
if (value > uint256(type(int256).max)) {
revert SafeCastOverflowedUintToInt(value);
}
return int256(value);
}
/**
* @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
*/
function toUint(bool b) internal pure returns (uint256 u) {
assembly ("memory-safe") {
u := iszero(iszero(b))
}
}
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
/// @notice Interface to which Earning Power Calculators must conform in order to provide earning
/// power updates to an instance of Staker. Well behaving earning power calculators should:
///
/// 1. Be deterministic, i.e. produce the same output for the same input at a given time.
/// 2. Return values that are in the same order of magnitude as reasonable stake token amounts.
/// Avoid returning values that are dramatically detached from the staked amount.
/// 3. Avoid too much "churn" on earning power values, in particular, avoid returning "true" for
/// the `getNewEarningPower` method's `_isQualifiedForBump` too frequently, as such an earning
/// calculator would result in repeated bumps on a user's deposit, requiring excessive
/// monitoring on their behalf to avoid eating into their rewards.
interface IEarningPowerCalculator {
/// @notice Returns the current earning power for a given staker, delegatee and staking amount.
/// @param _amountStaked The amount of tokens staked.
/// @param _staker The address of the staker.
/// @return _earningPower The calculated earning power.
function getEarningPower(uint256 _amountStaked, address _staker) external view returns (uint256 _earningPower);
/// @notice Returns the current earning power for a given staker, delegatee, staking amount, and
/// old earning power, along with a flag denoting whether the change in earning power warrants
/// "bumping." Bumping means paying a third party a bit of the rewards to update the deposit's
/// earning power on the depositor's behalf.
/// @param _amountStaked The amount of tokens staked.
/// @param _staker The address of the staker.
/// @param _oldEarningPower The earning power currently assigned to the deposit for which new
/// earning power is being calculated.
/// @return _newEarningPower The calculated earning power.
/// @return _isQualifiedForBump A flag indicating whether or not this new earning power qualifies
/// the deposit for having its earning power bumped.
/// @dev Earning Power calculators should only "qualify" a bump when the difference warrants a
/// forced update by a third party. This could be, for example, to reduce a deposit's earning
/// power because their delegatee has become inactive. Even in these cases, a calculator should
/// avoid qualifying for a bump too frequently. A calculator implementer may, for example, want
/// to implement a grace period or a threshold difference before qualifying a deposit for a bump.
function getNewEarningPower(uint256 _amountStaked, address _staker, uint256 _oldEarningPower)
external
view
returns (uint256 _newEarningPower, bool _isQualifiedForBump);
}// 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);
}{
"remappings": [
"@layerzerolabs/oft-evm/contracts/=layerzero-oft/node_modules/@layerzerolabs/oft-evm/contracts/",
"@layerzerolabs/oapp-evm/contracts/oapp/=layerzero-oft/node_modules/@layerzerolabs/oapp-evm/contracts/oapp/",
"@layerzerolabs/lz-evm-protocol-v2/contracts/=layerzero-oft/node_modules/@layerzerolabs/lz-evm-protocol-v2/contracts/",
"@layerzerolabs/oapp-evm/contracts/precrime/=layerzero-oft/node_modules/@layerzerolabs/oapp-evm/contracts/precrime/",
"@layerzerolabs/lz-evm-messagelib-v2/contracts/libs/=layerzero-oft/node_modules/@layerzerolabs/lz-evm-messagelib-v2/contracts/libs/",
"solidity-bytes-utils/contracts/=lib/solidity-bytes-utils/contracts/",
"@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/=layerzero-oft/node_modules/@layerzerolabs/lz-evm-messagelib-v2/contracts/uln/libs/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"createx-forge/=lib/createx-forge/",
"ds-test/=lib/createx-forge/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/"
],
"optimizer": {
"enabled": false,
"runs": 200
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "cancun",
"viaIR": true,
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_giza","type":"address"},{"internalType":"address","name":"_staker","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyClaimed","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[],"name":"NotDistributing","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ClaimedAndStaked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelTransferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"claimAndStake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"giza","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isDistributing","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"recoverAsset","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"sendReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"staker","outputs":[{"internalType":"contract IStaker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60c0604052346100655761001a610014610146565b916101b8565b61002261006a565b6116666102c682396080518181816106dd0152818161090e01528181610a620152610f5d015260a05181818161042e01528181610a930152610af5015261166690f35b610070565b60405190565b5f80fd5b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b9061009c90610074565b810190811060018060401b038211176100b457604052565b61007e565b906100cc6100c561006a565b9283610092565b565b5f80fd5b60018060a01b031690565b6100e6906100d2565b90565b6100f2816100dd565b036100f957565b5f80fd5b9050519061010a826100e9565b565b90916060828403126101415761013e610127845f85016100fd565b9361013581602086016100fd565b936040016100fd565b90565b6100ce565b61016461192c80380380610159816100b9565b92833981019061010c565b909192565b90565b61018061017b610185926100d2565b610169565b6100d2565b90565b6101919061016c565b90565b61019d90610188565b90565b6101a99061016c565b90565b6101b5906101a0565b90565b6101d692916101c96101ce92610266565b610194565b6080526101ac565b60a052565b5f1b90565b906101f160018060a01b03916101db565b9181191691161790565b6102049061016c565b90565b610210906101fb565b90565b90565b9061022b61022661023292610207565b610213565b82546101e0565b9055565b90565b61024d61024861025292610236565b610169565b6100d2565b90565b61025e90610239565b90565b5f0190565b610270815f610216565b6102795f610255565b906102ad6102a77f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e093610207565b91610207565b916102b661006a565b806102c081610261565b0390a356fe60806040526004361015610013575b61082a565b61001d5f3561010c565b806329d3cb35146101075780632eb4a7ab146101025780632f52ebb7146100fd57806336d76a95146100f857806345153af8146100f35780635ebaf1db146100ee57806379ba5097146100e95780637cb64759146100e45780638cc08025146100df5780638da5cb5b146100da57806392fede00146100d55780639b915ae0146100d0578063c78b6dea146100cb578063e30c3978146100c65763f2fde38b0361000e576107f7565b6107c2565b610780565b61072d565b6106a8565b610673565b6105de565b610552565b6104de565b6104a9565b6103f7565b610361565b61032d565b610267565b6101c3565b60e01c90565b60405190565b5f80fd5b5f80fd5b5f80fd5b60018060a01b031690565b61013890610124565b90565b6101448161012f565b0361014b57565b5f80fd5b9050359061015c8261013b565b565b90565b61016a8161015e565b0361017157565b5f80fd5b9050359061018282610161565b565b90916060828403126101b9576101b661019f845f850161014f565b936101ad816020860161014f565b93604001610175565b90565b61011c565b5f0190565b346101f2576101dc6101d6366004610184565b916108cb565b6101e4610112565b806101ee816101be565b0390f35b610118565b5f91031261020157565b61011c565b1c90565b90565b61021d9060086102229302610206565b61020a565b90565b90610230915461020d565b90565b61023f60025f90610225565b90565b90565b61024e90610242565b9052565b9190610265905f60208501940190610245565b565b34610297576102773660046101f7565b610293610282610233565b61028a610112565b91829182610252565b0390f35b610118565b5f80fd5b5f80fd5b5f80fd5b909182601f830112156102e25781359167ffffffffffffffff83116102dd5760200192602083028401116102d857565b6102a4565b6102a0565b61029c565b91909160408184031261032857610300835f8301610175565b92602082013567ffffffffffffffff81116103235761031f92016102a8565b9091565b610120565b61011c565b3461035c576103466103403660046102e7565b916108fa565b61034e610112565b80610358816101be565b0390f35b610118565b346103905761037a6103743660046102e7565b91610a4e565b610382610112565b8061038c816101be565b0390f35b610118565b60ff1690565b6103ab9060086103b09302610206565b610395565b90565b906103be915461039b565b90565b6103cd60045f906103b3565b90565b151590565b6103de906103d0565b9052565b91906103f5905f602085019401906103d5565b565b34610427576104073660046101f7565b6104236104126103c1565b61041a610112565b918291826103e2565b0390f35b610118565b7f000000000000000000000000000000000000000000000000000000000000000090565b90565b61046761046261046c92610124565b610450565b610124565b90565b61047890610453565b90565b6104849061046f565b90565b6104909061047b565b9052565b91906104a7905f60208501940190610487565b565b346104d9576104b93660046101f7565b6104d56104c461042c565b6104cc610112565b91829182610494565b0390f35b610118565b3461050c576104ee3660046101f7565b6104f6610cb7565b6104fe610112565b80610508816101be565b0390f35b610118565b61051a81610242565b0361052157565b5f80fd5b9050359061053282610511565b565b9060208282031261054d5761054a915f01610525565b90565b61011c565b346105805761056a610565366004610534565b610e0f565b610572610112565b8061057c816101be565b0390f35b610118565b9060208282031261059e5761059b915f0161014f565b90565b61011c565b6105ac9061046f565b90565b906105b9906105a3565b5f5260205260405f2090565b6105db906105d66003915f926105af565b6103b3565b90565b3461060e5761060a6105f96105f4366004610585565b6105c5565b610601610112565b918291826103e2565b0390f35b610118565b60018060a01b031690565b61062e9060086106339302610206565b610613565b90565b90610641915461061e565b90565b61064e5f80610636565b90565b61065a9061012f565b9052565b9190610671905f60208501940190610651565b565b346106a3576106833660046101f7565b61069f61068e610644565b610696610112565b9182918261065e565b0390f35b610118565b346106d6576106b83660046101f7565b6106c0610eb6565b6106c8610112565b806106d2816101be565b0390f35b610118565b7f000000000000000000000000000000000000000000000000000000000000000090565b6107089061046f565b90565b610714906106ff565b9052565b919061072b905f6020850194019061070b565b565b3461075d5761073d3660046101f7565b6107596107486106db565b610750610112565b91829182610718565b0390f35b610118565b9060208282031261077b57610778915f01610175565b90565b61011c565b346107ae57610798610793366004610762565b610f9c565b6107a0610112565b806107aa816101be565b0390f35b610118565b6107bf60015f90610636565b90565b346107f2576107d23660046101f7565b6107ee6107dd6107b3565b6107e5610112565b9182918261065e565b0390f35b610118565b346108255761080f61080a366004610585565b611045565b610817610112565b80610821816101be565b0390f35b610118565b5f80fd5b5f1c90565b61083f6108449161082e565b610613565b90565b6108519054610833565b90565b91903361087161086b6108665f610847565b61012f565b9161012f565b036108815761087f926108b4565b565b5f6282b42960e81b815280610898600482016101be565b0390fd5b6108a590610453565b90565b6108b19061089c565b90565b916108c16108c9936108a8565b919091611081565b565b906108d69291610854565b565b6108e19061015e565b9052565b91906108f8905f602085019401906108d8565b565b91906109099183919091611223565b6109357f0000000000000000000000000000000000000000000000000000000000000000338391611081565b336109756109637fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a926105a3565b9261096c610112565b918291826108e5565b0390a2565b5f80fd5b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906109a69061097e565b810190811067ffffffffffffffff8211176109c057604052565b610988565b60e01b90565b6109d4816103d0565b036109db57565b5f80fd5b905051906109ec826109cb565b565b90602082820312610a0757610a04915f016109df565b90565b61011c565b916020610a2d929493610a2660408201965f830190610651565b01906108d8565b565b610a37610112565b3d5f823e3d90fd5b5f910312610a4957565b61011c565b9190610a5d9183919091611223565b610a867f00000000000000000000000000000000000000000000000000000000000000006106ff565b602063095ea7b391610ab77f000000000000000000000000000000000000000000000000000000000000000061047b565b90610ad55f8695610ae0610ac9610112565b978896879586946109c5565b845260048401610a0c565b03925af18015610c0757610bdb575b50610b197f000000000000000000000000000000000000000000000000000000000000000061047b565b63460b5ee2338392803b15610bd657610b455f8094610b50610b39610112565b978896879586946109c5565b845260048401610a0c565b03925af18015610bd157610ba5575b5033610ba0610b8e7fe355416ef72a4ee51b15d2ca97670169b610e79b34df8e94673c08f045faf77d926105a3565b92610b97610112565b918291826108e5565b0390a2565b610bc4905f3d8111610bca575b610bbc818361099c565b810190610a3f565b5f610b5f565b503d610bb2565b610a2f565b61097a565b610bfb9060203d8111610c00575b610bf3818361099c565b8101906109ee565b610aef565b503d610be9565b610a2f565b5f1b90565b90610c2260018060a01b0391610c0c565b9181191691161790565b90565b90610c44610c3f610c4b926105a3565b610c2c565b8254610c11565b9055565b1b90565b91906008610c73910291610c6d60018060a01b0384610c4f565b92610c4f565b9181191691161790565b9190610c93610c8e610c9b936105a3565b610c2c565b908354610c53565b9055565b5f90565b610cb591610caf610c9f565b91610c7d565b565b33610cd3610ccd610cc86001610847565b61012f565b9161012f565b03610d5357610ce15f610847565b610cf4610cee6001610847565b5f610c2f565b610cff5f6001610ca3565b610d085f610847565b610d3b610d357f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0936105a3565b916105a3565b91610d44610112565b80610d4e816101be565b0390a3565b5f6282b42960e81b815280610d6a600482016101be565b0390fd5b33610d89610d83610d7e5f610847565b61012f565b9161012f565b03610d9957610d9790610e02565b565b5f6282b42960e81b815280610db0600482016101be565b0390fd5b90610dc05f1991610c0c565b9181191691161790565b610dd390610242565b90565b610ddf9061082e565b90565b90610df7610df2610dfe92610dca565b610dd6565b8254610db4565b9055565b610e0d906002610de2565b565b610e1890610d6e565b565b33610e35610e2f610e2a5f610847565b61012f565b9161012f565b03610e4457610e42610e5f565b565b5f6282b42960e81b815280610e5b600482016101be565b0390fd5b610e696001610847565b610e937f6ecd4842251bedd053b09547c0fabaab9ec98506ebf24469e8dd5560412ed37f916105a3565b90610e9c610112565b80610ea6816101be565b0390a2610eb45f6001610ca3565b565b610ebe610e1a565b565b33610edb610ed5610ed05f610847565b61012f565b9161012f565b03610eeb57610ee990610f57565b565b5f6282b42960e81b815280610f02600482016101be565b0390fd5b610f0f9061046f565b90565b90610f1e60ff91610c0c565b9181191691161790565b610f31906103d0565b90565b90565b90610f4c610f47610f5392610f28565b610f34565b8254610f12565b9055565b610f8e907f00000000000000000000000000000000000000000000000000000000000000009033610f8730610f06565b91926113a9565b610f9a60016004610f37565b565b610fa590610ec0565b565b33610fc2610fbc610fb75f610847565b61012f565b9161012f565b03610fd257610fd090610fed565b565b5f6282b42960e81b815280610fe9600482016101be565b0390fd5b610ff8816001610c2f565b339061102d6110277f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700936105a3565b916105a3565b91611036610112565b80611040816101be565b0390a3565b61104e90610fa7565b565b63ffffffff1690565b63ffffffff60e01b1690565b61107961107461107e92611050565b6109c5565b611059565b90565b906110c86110cd936110b9600494936110a063a9059cbb919391611065565b926110a9610112565b9687946020860190815201610a0c565b6020820181038252038361099c565b611438565b565b6110db6110e09161082e565b610395565b90565b6110ed90546110cf565b90565b6110fc6111019161082e565b61020a565b90565b61110e90546110f0565b90565b90565b61112861112361112d92611111565b610c0c565b610242565b90565b60200190565b5190565b90565b61114961114e91610242565b61113a565b9052565b61115e8160209361113d565b0190565b9061118a61116e610112565b809361117e602083019182611152565b9081038252038361099c565b565b9061119f611198610112565b928361099c565b565b67ffffffffffffffff81116111b95760208091020190565b610988565b909291926111d36111ce826111a1565b61118c565b938185526020808601920283019281841161121057915b8383106111f75750505050565b602080916112058486610525565b8152019201916111ea565b6102a4565b6112209136916111be565b90565b339261123861123260046110e3565b156103d0565b801561134c575b61133057611257611252600386906105af565b6110e3565b611314576112dc926112d16112ab6112d69461129388611284611278610112565b93849260208401610a0c565b6020820181038252038261099c565b6112a561129f82611136565b91611130565b20611162565b6112bd6112b782611136565b91611130565b2091926112ca6002611104565b9293611215565b6114f0565b156103d0565b6112f8576112f6906112f160019160036105af565b610f37565b565b5f6309bde33960e01b815280611310600482016101be565b0390fd5b5f630c8d9eab60e31b81528061132c600482016101be565b0390fd5b5f637ba49b2f60e11b815280611348600482016101be565b0390fd5b506113576002611104565b61137161136b6113665f611114565b610242565b91610242565b1461123f565b6040906113a06113a7949695939661139660608401985f850190610651565b6020830190610651565b01906108d8565b565b6004926113e36113f795936113f293946113ca6323b872dd92949192611065565b936113d3610112565b9788956020870190815201611377565b6020820181038252038361099c565b611438565b565b5f90565b61141161140c61141692611111565b610450565b61015e565b90565b90565b61143061142b61143592611419565b610450565b61015e565b90565b905f6020916114456113f9565b5061144e6113f9565b50828151910182855af1156114e1573d5f519061147361146d5f6113fd565b9161015e565b145f146114c75750611484816106ff565b3b6114976114915f6113fd565b9161015e565b145b6114a05750565b6114ac6114c3916106ff565b5f918291635274afe760e01b83526004830161065e565b0390fd5b6114da6114d4600161141c565b9161015e565b1415611499565b6040513d5f823e3d90fd5b5f90565b61150a6115169293611510926115046114ec565b50611572565b92610242565b91610242565b1490565b5f90565b600161152a910161015e565b90565b5190565b634e487b7160e01b5f52603260045260245ffd5b9061154f8261152d565b811015611560576020809102010190565b611531565b61156f9051610242565b90565b919061157c61151a565b506115865f6113fd565b905b816115a361159d6115988761152d565b61015e565b9161015e565b10156115d5576115c96115cf916115c36115be878690611545565b611565565b906115dc565b9161151e565b90611588565b9192505090565b6115e461151a565b50806115f86115f284610242565b91610242565b105f1461160d57906116099161161b565b5b90565b6116169161161b565b61160a565b61162361151a565b505f5260205260405f209056fea2646970667358221220b009e36e2492790b868693ef149b0613937bfbc010d39f79b1a3abeb698aec8964736f6c634300081a00330000000000000000000000003587bf7990efd7b1bec26f828e67c63332b50bef000000000000000000000000590830dfdf9a3f68afcdde2694773debdf267774000000000000000000000000e576638a9f2ad99ee9dd6f4acbb83217566d8e18
Deployed Bytecode
0x60806040526004361015610013575b61082a565b61001d5f3561010c565b806329d3cb35146101075780632eb4a7ab146101025780632f52ebb7146100fd57806336d76a95146100f857806345153af8146100f35780635ebaf1db146100ee57806379ba5097146100e95780637cb64759146100e45780638cc08025146100df5780638da5cb5b146100da57806392fede00146100d55780639b915ae0146100d0578063c78b6dea146100cb578063e30c3978146100c65763f2fde38b0361000e576107f7565b6107c2565b610780565b61072d565b6106a8565b610673565b6105de565b610552565b6104de565b6104a9565b6103f7565b610361565b61032d565b610267565b6101c3565b60e01c90565b60405190565b5f80fd5b5f80fd5b5f80fd5b60018060a01b031690565b61013890610124565b90565b6101448161012f565b0361014b57565b5f80fd5b9050359061015c8261013b565b565b90565b61016a8161015e565b0361017157565b5f80fd5b9050359061018282610161565b565b90916060828403126101b9576101b661019f845f850161014f565b936101ad816020860161014f565b93604001610175565b90565b61011c565b5f0190565b346101f2576101dc6101d6366004610184565b916108cb565b6101e4610112565b806101ee816101be565b0390f35b610118565b5f91031261020157565b61011c565b1c90565b90565b61021d9060086102229302610206565b61020a565b90565b90610230915461020d565b90565b61023f60025f90610225565b90565b90565b61024e90610242565b9052565b9190610265905f60208501940190610245565b565b34610297576102773660046101f7565b610293610282610233565b61028a610112565b91829182610252565b0390f35b610118565b5f80fd5b5f80fd5b5f80fd5b909182601f830112156102e25781359167ffffffffffffffff83116102dd5760200192602083028401116102d857565b6102a4565b6102a0565b61029c565b91909160408184031261032857610300835f8301610175565b92602082013567ffffffffffffffff81116103235761031f92016102a8565b9091565b610120565b61011c565b3461035c576103466103403660046102e7565b916108fa565b61034e610112565b80610358816101be565b0390f35b610118565b346103905761037a6103743660046102e7565b91610a4e565b610382610112565b8061038c816101be565b0390f35b610118565b60ff1690565b6103ab9060086103b09302610206565b610395565b90565b906103be915461039b565b90565b6103cd60045f906103b3565b90565b151590565b6103de906103d0565b9052565b91906103f5905f602085019401906103d5565b565b34610427576104073660046101f7565b6104236104126103c1565b61041a610112565b918291826103e2565b0390f35b610118565b7f000000000000000000000000e576638a9f2ad99ee9dd6f4acbb83217566d8e1890565b90565b61046761046261046c92610124565b610450565b610124565b90565b61047890610453565b90565b6104849061046f565b90565b6104909061047b565b9052565b91906104a7905f60208501940190610487565b565b346104d9576104b93660046101f7565b6104d56104c461042c565b6104cc610112565b91829182610494565b0390f35b610118565b3461050c576104ee3660046101f7565b6104f6610cb7565b6104fe610112565b80610508816101be565b0390f35b610118565b61051a81610242565b0361052157565b5f80fd5b9050359061053282610511565b565b9060208282031261054d5761054a915f01610525565b90565b61011c565b346105805761056a610565366004610534565b610e0f565b610572610112565b8061057c816101be565b0390f35b610118565b9060208282031261059e5761059b915f0161014f565b90565b61011c565b6105ac9061046f565b90565b906105b9906105a3565b5f5260205260405f2090565b6105db906105d66003915f926105af565b6103b3565b90565b3461060e5761060a6105f96105f4366004610585565b6105c5565b610601610112565b918291826103e2565b0390f35b610118565b60018060a01b031690565b61062e9060086106339302610206565b610613565b90565b90610641915461061e565b90565b61064e5f80610636565b90565b61065a9061012f565b9052565b9190610671905f60208501940190610651565b565b346106a3576106833660046101f7565b61069f61068e610644565b610696610112565b9182918261065e565b0390f35b610118565b346106d6576106b83660046101f7565b6106c0610eb6565b6106c8610112565b806106d2816101be565b0390f35b610118565b7f000000000000000000000000590830dfdf9a3f68afcdde2694773debdf26777490565b6107089061046f565b90565b610714906106ff565b9052565b919061072b905f6020850194019061070b565b565b3461075d5761073d3660046101f7565b6107596107486106db565b610750610112565b91829182610718565b0390f35b610118565b9060208282031261077b57610778915f01610175565b90565b61011c565b346107ae57610798610793366004610762565b610f9c565b6107a0610112565b806107aa816101be565b0390f35b610118565b6107bf60015f90610636565b90565b346107f2576107d23660046101f7565b6107ee6107dd6107b3565b6107e5610112565b9182918261065e565b0390f35b610118565b346108255761080f61080a366004610585565b611045565b610817610112565b80610821816101be565b0390f35b610118565b5f80fd5b5f1c90565b61083f6108449161082e565b610613565b90565b6108519054610833565b90565b91903361087161086b6108665f610847565b61012f565b9161012f565b036108815761087f926108b4565b565b5f6282b42960e81b815280610898600482016101be565b0390fd5b6108a590610453565b90565b6108b19061089c565b90565b916108c16108c9936108a8565b919091611081565b565b906108d69291610854565b565b6108e19061015e565b9052565b91906108f8905f602085019401906108d8565b565b91906109099183919091611223565b6109357f000000000000000000000000590830dfdf9a3f68afcdde2694773debdf267774338391611081565b336109756109637fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a926105a3565b9261096c610112565b918291826108e5565b0390a2565b5f80fd5b601f801991011690565b634e487b7160e01b5f52604160045260245ffd5b906109a69061097e565b810190811067ffffffffffffffff8211176109c057604052565b610988565b60e01b90565b6109d4816103d0565b036109db57565b5f80fd5b905051906109ec826109cb565b565b90602082820312610a0757610a04915f016109df565b90565b61011c565b916020610a2d929493610a2660408201965f830190610651565b01906108d8565b565b610a37610112565b3d5f823e3d90fd5b5f910312610a4957565b61011c565b9190610a5d9183919091611223565b610a867f000000000000000000000000590830dfdf9a3f68afcdde2694773debdf2677746106ff565b602063095ea7b391610ab77f000000000000000000000000e576638a9f2ad99ee9dd6f4acbb83217566d8e1861047b565b90610ad55f8695610ae0610ac9610112565b978896879586946109c5565b845260048401610a0c565b03925af18015610c0757610bdb575b50610b197f000000000000000000000000e576638a9f2ad99ee9dd6f4acbb83217566d8e1861047b565b63460b5ee2338392803b15610bd657610b455f8094610b50610b39610112565b978896879586946109c5565b845260048401610a0c565b03925af18015610bd157610ba5575b5033610ba0610b8e7fe355416ef72a4ee51b15d2ca97670169b610e79b34df8e94673c08f045faf77d926105a3565b92610b97610112565b918291826108e5565b0390a2565b610bc4905f3d8111610bca575b610bbc818361099c565b810190610a3f565b5f610b5f565b503d610bb2565b610a2f565b61097a565b610bfb9060203d8111610c00575b610bf3818361099c565b8101906109ee565b610aef565b503d610be9565b610a2f565b5f1b90565b90610c2260018060a01b0391610c0c565b9181191691161790565b90565b90610c44610c3f610c4b926105a3565b610c2c565b8254610c11565b9055565b1b90565b91906008610c73910291610c6d60018060a01b0384610c4f565b92610c4f565b9181191691161790565b9190610c93610c8e610c9b936105a3565b610c2c565b908354610c53565b9055565b5f90565b610cb591610caf610c9f565b91610c7d565b565b33610cd3610ccd610cc86001610847565b61012f565b9161012f565b03610d5357610ce15f610847565b610cf4610cee6001610847565b5f610c2f565b610cff5f6001610ca3565b610d085f610847565b610d3b610d357f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0936105a3565b916105a3565b91610d44610112565b80610d4e816101be565b0390a3565b5f6282b42960e81b815280610d6a600482016101be565b0390fd5b33610d89610d83610d7e5f610847565b61012f565b9161012f565b03610d9957610d9790610e02565b565b5f6282b42960e81b815280610db0600482016101be565b0390fd5b90610dc05f1991610c0c565b9181191691161790565b610dd390610242565b90565b610ddf9061082e565b90565b90610df7610df2610dfe92610dca565b610dd6565b8254610db4565b9055565b610e0d906002610de2565b565b610e1890610d6e565b565b33610e35610e2f610e2a5f610847565b61012f565b9161012f565b03610e4457610e42610e5f565b565b5f6282b42960e81b815280610e5b600482016101be565b0390fd5b610e696001610847565b610e937f6ecd4842251bedd053b09547c0fabaab9ec98506ebf24469e8dd5560412ed37f916105a3565b90610e9c610112565b80610ea6816101be565b0390a2610eb45f6001610ca3565b565b610ebe610e1a565b565b33610edb610ed5610ed05f610847565b61012f565b9161012f565b03610eeb57610ee990610f57565b565b5f6282b42960e81b815280610f02600482016101be565b0390fd5b610f0f9061046f565b90565b90610f1e60ff91610c0c565b9181191691161790565b610f31906103d0565b90565b90565b90610f4c610f47610f5392610f28565b610f34565b8254610f12565b9055565b610f8e907f000000000000000000000000590830dfdf9a3f68afcdde2694773debdf2677749033610f8730610f06565b91926113a9565b610f9a60016004610f37565b565b610fa590610ec0565b565b33610fc2610fbc610fb75f610847565b61012f565b9161012f565b03610fd257610fd090610fed565b565b5f6282b42960e81b815280610fe9600482016101be565b0390fd5b610ff8816001610c2f565b339061102d6110277f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e22700936105a3565b916105a3565b91611036610112565b80611040816101be565b0390a3565b61104e90610fa7565b565b63ffffffff1690565b63ffffffff60e01b1690565b61107961107461107e92611050565b6109c5565b611059565b90565b906110c86110cd936110b9600494936110a063a9059cbb919391611065565b926110a9610112565b9687946020860190815201610a0c565b6020820181038252038361099c565b611438565b565b6110db6110e09161082e565b610395565b90565b6110ed90546110cf565b90565b6110fc6111019161082e565b61020a565b90565b61110e90546110f0565b90565b90565b61112861112361112d92611111565b610c0c565b610242565b90565b60200190565b5190565b90565b61114961114e91610242565b61113a565b9052565b61115e8160209361113d565b0190565b9061118a61116e610112565b809361117e602083019182611152565b9081038252038361099c565b565b9061119f611198610112565b928361099c565b565b67ffffffffffffffff81116111b95760208091020190565b610988565b909291926111d36111ce826111a1565b61118c565b938185526020808601920283019281841161121057915b8383106111f75750505050565b602080916112058486610525565b8152019201916111ea565b6102a4565b6112209136916111be565b90565b339261123861123260046110e3565b156103d0565b801561134c575b61133057611257611252600386906105af565b6110e3565b611314576112dc926112d16112ab6112d69461129388611284611278610112565b93849260208401610a0c565b6020820181038252038261099c565b6112a561129f82611136565b91611130565b20611162565b6112bd6112b782611136565b91611130565b2091926112ca6002611104565b9293611215565b6114f0565b156103d0565b6112f8576112f6906112f160019160036105af565b610f37565b565b5f6309bde33960e01b815280611310600482016101be565b0390fd5b5f630c8d9eab60e31b81528061132c600482016101be565b0390fd5b5f637ba49b2f60e11b815280611348600482016101be565b0390fd5b506113576002611104565b61137161136b6113665f611114565b610242565b91610242565b1461123f565b6040906113a06113a7949695939661139660608401985f850190610651565b6020830190610651565b01906108d8565b565b6004926113e36113f795936113f293946113ca6323b872dd92949192611065565b936113d3610112565b9788956020870190815201611377565b6020820181038252038361099c565b611438565b565b5f90565b61141161140c61141692611111565b610450565b61015e565b90565b90565b61143061142b61143592611419565b610450565b61015e565b90565b905f6020916114456113f9565b5061144e6113f9565b50828151910182855af1156114e1573d5f519061147361146d5f6113fd565b9161015e565b145f146114c75750611484816106ff565b3b6114976114915f6113fd565b9161015e565b145b6114a05750565b6114ac6114c3916106ff565b5f918291635274afe760e01b83526004830161065e565b0390fd5b6114da6114d4600161141c565b9161015e565b1415611499565b6040513d5f823e3d90fd5b5f90565b61150a6115169293611510926115046114ec565b50611572565b92610242565b91610242565b1490565b5f90565b600161152a910161015e565b90565b5190565b634e487b7160e01b5f52603260045260245ffd5b9061154f8261152d565b811015611560576020809102010190565b611531565b61156f9051610242565b90565b919061157c61151a565b506115865f6113fd565b905b816115a361159d6115988761152d565b61015e565b9161015e565b10156115d5576115c96115cf916115c36115be878690611545565b611565565b906115dc565b9161151e565b90611588565b9192505090565b6115e461151a565b50806115f86115f284610242565b91610242565b105f1461160d57906116099161161b565b5b90565b6116169161161b565b61160a565b61162361151a565b505f5260205260405f209056fea2646970667358221220b009e36e2492790b868693ef149b0613937bfbc010d39f79b1a3abeb698aec8964736f6c634300081a0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000003587bf7990efd7b1bec26f828e67c63332b50bef000000000000000000000000590830dfdf9a3f68afcdde2694773debdf267774000000000000000000000000e576638a9f2ad99ee9dd6f4acbb83217566d8e18
-----Decoded View---------------
Arg [0] : _owner (address): 0x3587bf7990eFD7B1bEC26f828E67C63332b50BEF
Arg [1] : _giza (address): 0x590830dFDf9A3F68aFCDdE2694773dEBDF267774
Arg [2] : _staker (address): 0xE576638a9f2AD99EE9dD6F4AcBb83217566D8e18
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 0000000000000000000000003587bf7990efd7b1bec26f828e67c63332b50bef
Arg [1] : 000000000000000000000000590830dfdf9a3f68afcdde2694773debdf267774
Arg [2] : 000000000000000000000000e576638a9f2ad99ee9dd6f4acbb83217566d8e18
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ 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.