More Info
Private Name Tags
ContractCreator
Advanced mode: Intended for advanced users or developers and will display all Internal Transactions including zero value transfers. Name tag integration is not available in advanced view.
Latest 25 internal transactions (View All)
Advanced mode:
Parent Transaction Hash | Block | From | To | ||||
---|---|---|---|---|---|---|---|
20590499 | 15 mins ago | 0 ETH | |||||
20590407 | 34 mins ago | 0 ETH | |||||
20590407 | 34 mins ago | 0 ETH | |||||
20590402 | 35 mins ago | 0 ETH | |||||
20590402 | 35 mins ago | 0 ETH | |||||
20590385 | 38 mins ago | 0 ETH | |||||
20590385 | 38 mins ago | 0 ETH | |||||
20590288 | 57 mins ago | 0 ETH | |||||
20590288 | 57 mins ago | 0 ETH | |||||
20590284 | 58 mins ago | 0 ETH | |||||
20590284 | 58 mins ago | 0 ETH | |||||
20590181 | 1 hr ago | 0 ETH | |||||
20590181 | 1 hr ago | 0 ETH | |||||
20590161 | 1 hr ago | 0 ETH | |||||
20590161 | 1 hr ago | 0 ETH | |||||
20590077 | 1 hr ago | 0 ETH | |||||
20590067 | 1 hr ago | 0 ETH | |||||
20590067 | 1 hr ago | 0 ETH | |||||
20590063 | 1 hr ago | 0 ETH | |||||
20590063 | 1 hr ago | 0 ETH | |||||
20589831 | 2 hrs ago | 0 ETH | |||||
20589831 | 2 hrs ago | 0 ETH | |||||
20589807 | 2 hrs ago | 0 ETH | |||||
20589631 | 3 hrs ago | 0 ETH | |||||
20589631 | 3 hrs ago | 0 ETH |
Loading...
Loading
Contract Name:
StargateMultiRewarder
Compiler Version
v0.8.22+commit.4fc1097e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IStargateStaking } from "./interfaces/IStargateStaking.sol"; import { IMultiRewarder, IERC20 } from "./interfaces/IMultiRewarder.sol"; import { RewardLib, RewardPool } from "./lib/RewardLib.sol"; import { RewardRegistryLib, RewardRegistry } from "./lib/RewardRegistryLib.sol"; /// @notice See `IMultiRewarder` and `IRewarder` for documentation. contract StargateMultiRewarder is Ownable, IMultiRewarder { using RewardLib for RewardPool; using EnumerableSet for EnumerableSet.UintSet; using EnumerableSet for EnumerableSet.AddressSet; using RewardRegistryLib for RewardRegistry; using SafeCast for uint256; using SafeERC20 for IERC20; address private constant ETH = address(0); RewardRegistry private registry; IStargateStaking public immutable staking; modifier onlyStaking() { if (msg.sender != address(staking)) revert MultiRewarderUnauthorizedCaller(msg.sender); _; } constructor(IStargateStaking _staking) { staking = _staking; } //** STAKING FUNCTIONS **/ function onUpdate( IERC20 stakingToken, address user, uint256 oldStake, uint256 oldSupply, uint256 /*newStake*/ ) external onlyStaking { uint256[] memory ids = registry.byStake[stakingToken].values(); address[] memory tokens = new address[](ids.length); uint256[] memory amounts = new uint256[](ids.length); for (uint256 i = 0; i < ids.length; i++) { RewardPool storage pool = registry.pools[ids[i]]; address rewardToken = pool.rewardToken; tokens[i] = rewardToken; amounts[i] = pool.indexAndUpdate(registry.rewardDetails[rewardToken], user, oldStake, oldSupply); } emit RewardsClaimed(user, tokens, amounts); for (uint256 i = 0; i < ids.length; i++) { if (amounts[i] > 0) { _transferToken(user, tokens[i], amounts[i]); } } } function connect(IERC20 stakingToken) external onlyStaking { if (registry.connected[stakingToken]) revert RewarderAlreadyConnected(stakingToken); registry.connected[stakingToken] = true; emit RewarderConnected(stakingToken); } function _indexRewardTokenPools(address rewardToken) internal { uint256 numPools = registry.byReward[rewardToken].length(); for (uint256 i = 0; i < numPools; i++) { RewardPool storage pool = registry.pools[registry.byReward[rewardToken].at(i)]; pool.index(registry.rewardDetails[rewardToken], staking.totalSupply(pool.stakingToken)); } } /** * ADMIN FUNCTIONS * */ function extendReward(address rewardToken, uint256 amount) external payable onlyOwner { RewardDetails storage reward = registry.rewardDetails[rewardToken]; if (!reward.exists) revert MultiRewarderUnregisteredToken(rewardToken); if (reward.end < block.timestamp) revert MultiRewarderPoolFinished(rewardToken); reward.end += (amount / reward.rewardPerSec).toUint48(); emit RewardExtended(rewardToken, amount, reward.end); _transferInToken(rewardToken, amount); } function setReward(address rewardToken, uint256 amount, uint48 start, uint48 duration) external payable onlyOwner { if (start < block.timestamp) revert MultiRewarderStartInPast(start); if (duration == 0) revert MultiRewarderZeroDuration(); RewardDetails storage reward = registry.getOrCreateRewardDetails(rewardToken); _indexRewardTokenPools(rewardToken); uint256 rewardsToAdd = amount; if (block.timestamp < reward.end) { uint256 previousStart = reward.start > block.timestamp ? reward.start : block.timestamp; rewardsToAdd += reward.rewardPerSec * (reward.end - previousStart); } uint256 rewardPerSec = rewardsToAdd / duration; if (rewardPerSec == 0) revert MultiRewarderZeroRewardRate(); reward.start = start; reward.end = start + duration; reward.rewardPerSec = rewardPerSec; emit RewardSet(rewardToken, amount, rewardsToAdd, start, duration); _transferInToken(rewardToken, amount); } function setAllocPoints( address rewardToken, IERC20[] calldata stakingTokens, uint48[] calldata allocPoints ) external onlyOwner { _indexRewardTokenPools(rewardToken); registry.setAllocPoints(rewardToken, stakingTokens, allocPoints); emit AllocPointsSet(rewardToken, stakingTokens, allocPoints); } function stopReward(address rewardToken, address receiver, bool pullTokens) external onlyOwner { registry.removeReward(rewardToken); /** * @dev we provide pullTokens as we especially need to be able to retire rewards even if the token transfers * revert for some reason. */ if (pullTokens) { uint256 amount = rewardToken == ETH ? address(this).balance : IERC20(rewardToken).balanceOf(address(this)); _transferToken(receiver, rewardToken, amount); } emit RewardStopped(rewardToken, receiver, pullTokens); } function renounceOwnership() public view override onlyOwner { revert MultiRewarderRenounceOwnershipDisabled(); } /** * UTILITIES * */ function _transferToken(address to, address token, uint256 amount) internal { if (token == ETH) { (bool success, ) = to.call{ value: amount }(""); if (!success) revert MultiRewarderNativeTransferFailed(token, amount); } else { IERC20(token).safeTransfer(to, amount); } } function _transferInToken(address token, uint256 amount) internal { if (token == ETH) { if (msg.value != amount) revert MultiRewarderIncorrectNative(amount, msg.value); } else { IERC20(token).safeTransferFrom(msg.sender, address(this), amount); } } /** * VIEW FUNCTIONS * */ function getRewards(IERC20 stakingToken, address user) external view returns (address[] memory, uint256[] memory) { uint256[] memory ids = registry.byStake[stakingToken].values(); address[] memory tokens = new address[](ids.length); uint256[] memory amounts = new uint256[](ids.length); for (uint256 i = 0; i < ids.length; i++) { RewardPool storage pool = registry.pools[ids[i]]; RewardDetails storage reward = registry.rewardDetails[pool.rewardToken]; tokens[i] = pool.rewardToken; amounts[i] = pool.getRewards( reward, user, staking.balanceOf(pool.stakingToken, user), staking.totalSupply(pool.stakingToken) ); } return (tokens, amounts); } function allocPointsByReward(address rewardToken) external view returns (IERC20[] memory, uint48[] memory) { return registry.allocPointsByReward(rewardToken); } function allocPointsByStake(IERC20 stakingToken) external view returns (address[] memory, uint48[] memory) { return registry.allocPointsByStake(stakingToken); } function rewardDetails(address rewardToken) external view returns (RewardDetails memory) { return registry.rewardDetails[rewardToken]; } function rewardTokens() external view override returns (address[] memory) { return registry.rewardTokens.values(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ 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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` 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 amount) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.0; import "../IERC20.sol"; import "../extensions/IERC20Permit.sol"; import "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 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 { using Address for address; /** * @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.encodeWithSelector(token.transfer.selector, 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.encodeWithSelector(token.transferFrom.selector, from, to, value)); } /** * @dev Deprecated. This function has issues similar to the ones found in * {IERC20-approve}, and its usage is discouraged. * * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ function safeApprove(IERC20 token, address spender, uint256 value) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' require( (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 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. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value)); } /** * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { unchecked { uint256 oldAllowance = token.allowance(address(this), spender); require(oldAllowance >= value, "SafeERC20: decreased allowance below zero"); _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value)); } } /** * @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. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0)); _callOptionalReturn(token, approvalCall); } } /** * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`. * Revert on invalid signature. */ function safePermit( IERC20Permit token, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) internal { uint256 nonceBefore = token.nonces(owner); token.permit(owner, spender, value, deadline, v, r, s); uint256 nonceAfter = token.nonces(owner); require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed"); } /** * @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). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } /** * @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 silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * * Furthermore, `isContract` will also return true if the target contract within * the same transaction is already scheduled for destruction by `SELFDESTRUCT`, * which only has an effect at the end of a transaction. * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @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.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @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, it is bubbled up by this * function (like regular Solidity function calls). * * 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. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @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`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.0; /** * @dev Wrappers over Solidity's uintXX/intXX 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. * * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing * all math on `uint256` and `int256` and then downcasting. */ library SafeCast { /** * @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 * * _Available since v4.7._ */ function toUint248(uint256 value) internal pure returns (uint248) { require(value <= type(uint248).max, "SafeCast: value doesn't fit in 248 bits"); 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 * * _Available since v4.7._ */ function toUint240(uint256 value) internal pure returns (uint240) { require(value <= type(uint240).max, "SafeCast: value doesn't fit in 240 bits"); 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 * * _Available since v4.7._ */ function toUint232(uint256 value) internal pure returns (uint232) { require(value <= type(uint232).max, "SafeCast: value doesn't fit in 232 bits"); 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 * * _Available since v4.2._ */ function toUint224(uint256 value) internal pure returns (uint224) { require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits"); 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 * * _Available since v4.7._ */ function toUint216(uint256 value) internal pure returns (uint216) { require(value <= type(uint216).max, "SafeCast: value doesn't fit in 216 bits"); 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 * * _Available since v4.7._ */ function toUint208(uint256 value) internal pure returns (uint208) { require(value <= type(uint208).max, "SafeCast: value doesn't fit in 208 bits"); 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 * * _Available since v4.7._ */ function toUint200(uint256 value) internal pure returns (uint200) { require(value <= type(uint200).max, "SafeCast: value doesn't fit in 200 bits"); 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 * * _Available since v4.7._ */ function toUint192(uint256 value) internal pure returns (uint192) { require(value <= type(uint192).max, "SafeCast: value doesn't fit in 192 bits"); 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 * * _Available since v4.7._ */ function toUint184(uint256 value) internal pure returns (uint184) { require(value <= type(uint184).max, "SafeCast: value doesn't fit in 184 bits"); 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 * * _Available since v4.7._ */ function toUint176(uint256 value) internal pure returns (uint176) { require(value <= type(uint176).max, "SafeCast: value doesn't fit in 176 bits"); 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 * * _Available since v4.7._ */ function toUint168(uint256 value) internal pure returns (uint168) { require(value <= type(uint168).max, "SafeCast: value doesn't fit in 168 bits"); 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 * * _Available since v4.7._ */ function toUint160(uint256 value) internal pure returns (uint160) { require(value <= type(uint160).max, "SafeCast: value doesn't fit in 160 bits"); 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 * * _Available since v4.7._ */ function toUint152(uint256 value) internal pure returns (uint152) { require(value <= type(uint152).max, "SafeCast: value doesn't fit in 152 bits"); 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 * * _Available since v4.7._ */ function toUint144(uint256 value) internal pure returns (uint144) { require(value <= type(uint144).max, "SafeCast: value doesn't fit in 144 bits"); 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 * * _Available since v4.7._ */ function toUint136(uint256 value) internal pure returns (uint136) { require(value <= type(uint136).max, "SafeCast: value doesn't fit in 136 bits"); 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 * * _Available since v2.5._ */ function toUint128(uint256 value) internal pure returns (uint128) { require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits"); 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 * * _Available since v4.7._ */ function toUint120(uint256 value) internal pure returns (uint120) { require(value <= type(uint120).max, "SafeCast: value doesn't fit in 120 bits"); 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 * * _Available since v4.7._ */ function toUint112(uint256 value) internal pure returns (uint112) { require(value <= type(uint112).max, "SafeCast: value doesn't fit in 112 bits"); 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 * * _Available since v4.7._ */ function toUint104(uint256 value) internal pure returns (uint104) { require(value <= type(uint104).max, "SafeCast: value doesn't fit in 104 bits"); 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 * * _Available since v4.2._ */ function toUint96(uint256 value) internal pure returns (uint96) { require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits"); 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 * * _Available since v4.7._ */ function toUint88(uint256 value) internal pure returns (uint88) { require(value <= type(uint88).max, "SafeCast: value doesn't fit in 88 bits"); 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 * * _Available since v4.7._ */ function toUint80(uint256 value) internal pure returns (uint80) { require(value <= type(uint80).max, "SafeCast: value doesn't fit in 80 bits"); 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 * * _Available since v4.7._ */ function toUint72(uint256 value) internal pure returns (uint72) { require(value <= type(uint72).max, "SafeCast: value doesn't fit in 72 bits"); 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 * * _Available since v2.5._ */ function toUint64(uint256 value) internal pure returns (uint64) { require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits"); 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 * * _Available since v4.7._ */ function toUint56(uint256 value) internal pure returns (uint56) { require(value <= type(uint56).max, "SafeCast: value doesn't fit in 56 bits"); 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 * * _Available since v4.7._ */ function toUint48(uint256 value) internal pure returns (uint48) { require(value <= type(uint48).max, "SafeCast: value doesn't fit in 48 bits"); 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 * * _Available since v4.7._ */ function toUint40(uint256 value) internal pure returns (uint40) { require(value <= type(uint40).max, "SafeCast: value doesn't fit in 40 bits"); 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 * * _Available since v2.5._ */ function toUint32(uint256 value) internal pure returns (uint32) { require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits"); 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 * * _Available since v4.7._ */ function toUint24(uint256 value) internal pure returns (uint24) { require(value <= type(uint24).max, "SafeCast: value doesn't fit in 24 bits"); 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 * * _Available since v2.5._ */ function toUint16(uint256 value) internal pure returns (uint16) { require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits"); 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 * * _Available since v2.5._ */ function toUint8(uint256 value) internal pure returns (uint8) { require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits"); return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. * * _Available since v3.0._ */ function toUint256(int256 value) internal pure returns (uint256) { require(value >= 0, "SafeCast: value must be positive"); 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 * * _Available since v4.7._ */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); require(downcasted == value, "SafeCast: value doesn't fit in 248 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); require(downcasted == value, "SafeCast: value doesn't fit in 240 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); require(downcasted == value, "SafeCast: value doesn't fit in 232 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); require(downcasted == value, "SafeCast: value doesn't fit in 224 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); require(downcasted == value, "SafeCast: value doesn't fit in 216 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); require(downcasted == value, "SafeCast: value doesn't fit in 208 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); require(downcasted == value, "SafeCast: value doesn't fit in 200 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); require(downcasted == value, "SafeCast: value doesn't fit in 192 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); require(downcasted == value, "SafeCast: value doesn't fit in 184 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); require(downcasted == value, "SafeCast: value doesn't fit in 176 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); require(downcasted == value, "SafeCast: value doesn't fit in 168 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); require(downcasted == value, "SafeCast: value doesn't fit in 160 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); require(downcasted == value, "SafeCast: value doesn't fit in 152 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); require(downcasted == value, "SafeCast: value doesn't fit in 144 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); require(downcasted == value, "SafeCast: value doesn't fit in 136 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); require(downcasted == value, "SafeCast: value doesn't fit in 128 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); require(downcasted == value, "SafeCast: value doesn't fit in 120 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); require(downcasted == value, "SafeCast: value doesn't fit in 112 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); require(downcasted == value, "SafeCast: value doesn't fit in 104 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); require(downcasted == value, "SafeCast: value doesn't fit in 96 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); require(downcasted == value, "SafeCast: value doesn't fit in 88 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); require(downcasted == value, "SafeCast: value doesn't fit in 80 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); require(downcasted == value, "SafeCast: value doesn't fit in 72 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); require(downcasted == value, "SafeCast: value doesn't fit in 64 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); require(downcasted == value, "SafeCast: value doesn't fit in 56 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); require(downcasted == value, "SafeCast: value doesn't fit in 48 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); require(downcasted == value, "SafeCast: value doesn't fit in 40 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); require(downcasted == value, "SafeCast: value doesn't fit in 32 bits"); } /** * @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 * * _Available since v4.7._ */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); require(downcasted == value, "SafeCast: value doesn't fit in 24 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); require(downcasted == value, "SafeCast: value doesn't fit in 16 bits"); } /** * @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 * * _Available since v3.1._ */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); require(downcasted == value, "SafeCast: value doesn't fit in 8 bits"); } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. * * _Available since v3.0._ */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256"); return int256(value); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastValue; // Update the index for the moved value set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; /// @solidity memory-safe-assembly assembly { result := store } return result; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { IRewarder, IERC20 } from "./IRewarder.sol"; // @dev This is an internal struct, placed here as its shared between multiple libraries. struct RewardPool { uint256 accRewardPerShare; address rewardToken; uint48 lastRewardTime; uint48 allocPoints; IERC20 stakingToken; bool removed; mapping(address => uint256) rewardDebt; } /// @notice A rewarder that can distribute multiple reward tokens (ERC20 and native) to `StargateStaking` pools. /// @dev The native token is encoded as 0x0. interface IMultiRewarder is IRewarder { struct RewardDetails { uint256 rewardPerSec; uint160 totalAllocPoints; uint48 start; uint48 end; bool exists; } /// @notice MultiRewarder renounce ownership is disabled. error MultiRewarderRenounceOwnershipDisabled(); /// @notice The token is not connected to the staking contract, connect it first. error MultiRewarderDisconnectedStakingToken(address token); /// @notice This token is not registered via `setReward` yet, register it first. error MultiRewarderUnregisteredToken(address token); /** * @notice Due to various functions looping over the staking tokens connected to a reward token, * a maximum number of such links is instated. */ error MultiRewarderMaxPoolsForRewardToken(); /** * @notice Due to various functions looping over the reward tokens connected to a staking token, * a maximum number of such links is instated. */ error MultiRewarderMaxActiveRewardTokens(); /// @notice The function can only be called while the pool hasn't ended yet. error MultiRewarderPoolFinished(address rewardToken); /// @notice The pool emission duration cannot be set to zero, as this would cause the rewards to be voided. error MultiRewarderZeroDuration(); /// @notice The pool start time cannot be set in the past, as this would cause the rewards to be voided. error MultiRewarderStartInPast(uint256 start); /** * @notice The recipient failed to handle the receipt of the native tokens, do they have a receipt hook? * If not, use `emergencyWithdraw`. */ error MultiRewarderNativeTransferFailed(address to, uint256 amount); /** * @notice A wrong `msg.value` was provided while setting a native reward, make sure it matches the function * `amount`. */ error MultiRewarderIncorrectNative(uint256 expected, uint256 actual); /** * @notice Due to a zero input or rounding, the reward rate while setting this pool would be zero, * which is not allowed. */ error MultiRewarderZeroRewardRate(); /// @notice Emitted when additional rewards were added to a pool, extending the reward duration. event RewardExtended(address indexed rewardToken, uint256 amountAdded, uint48 newEnd); /** * @notice Emitted when a reward token has been registered. Can be emitted again for the same token after it has * been explicitly stopped. */ event RewardRegistered(address indexed rewardToken); /// @notice Emitted when the reward pool has been adjusted or intialized, with the new params. event RewardSet( address indexed rewardToken, uint256 amountAdded, uint256 amountPeriod, uint48 start, uint48 duration ); /// @notice Emitted whenever rewards are claimed via the staking pool. event RewardsClaimed(address indexed user, address[] rewardTokens, uint256[] amounts); /** * @notice Emitted whenever a new staking pool combination was registered via the allocation point adjustment * function. */ event PoolRegistered(address indexed rewardToken, IERC20 indexed stakeToken); /// @notice Emitted when the owner adjusts the allocation points for pools. event AllocPointsSet(address indexed rewardToken, IERC20[] indexed stakeToken, uint48[] allocPoint); /// @notice Emitted when a reward token is stopped. event RewardStopped(address indexed rewardToken, address indexed receiver, bool pullTokens); /** * @notice Sets the reward for `rewards` of `rewardToken` over `duration` seconds, starting at `start`. The actual * reward over this period will be increased by any rewards on the pool that haven't been distributed yet. */ function setReward(address rewardToken, uint256 rewards, uint48 start, uint48 duration) external payable; /** * @notice Extends the reward duration for `rewardToken` by `amount` tokens, extending the duration by the * equivalent time according to the `rewardPerSec` rate of the pool. */ function extendReward(address rewardToken, uint256 amount) external payable; /** * @notice Configures allocation points for a reward token over multiple staking tokens, setting the `allocPoints` * for each `stakingTokens` and updating the `totalAllocPoint` for the `rewardToken`. The allocation * points of any non-provided staking tokens will be left as-is, and won't be reset to zero. */ function setAllocPoints( address rewardToken, IERC20[] calldata stakingTokens, uint48[] calldata allocPoints ) external; /** * @notice Unregisters a reward token fully, immediately preventing users from ever harvesting their pending * accumulated rewards. Optionally `pullTokens` can be set to false which causes the token balance to * not be sent to the owner, this should only be set to false in case the token is bugged and reverts. */ function stopReward(address rewardToken, address receiver, bool pullTokens) external; /** * @notice Returns the reward pools linked to the `stakingToken` alongside the pending rewards for `user` * for these pools. */ function getRewards(IERC20 stakingToken, address user) external view returns (address[] memory, uint256[] memory); /// @notice Returns the allocation points for the `rewardToken` over all staking tokens linked to it. function allocPointsByReward( address rewardToken ) external view returns (IERC20[] memory stakingTokens, uint48[] memory allocPoints); /// @notice Returns the allocation points for the `stakingToken` over all reward tokens linked to it. function allocPointsByStake( IERC20 stakingToken ) external view returns (address[] memory rewardTokens, uint48[] memory allocPoints); /// @notice Returns all enabled reward tokens. Stopped reward tokens are not included, while ended rewards are. function rewardTokens() external view returns (address[] memory); /// @notice Returns the emission details of a `rewardToken`, configured via `setReward`. function rewardDetails(address rewardToken) external view returns (RewardDetails memory); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /** * @notice A rewarder is connected to the staking contract and distributes rewards whenever the staking contract * updates the rewarder. */ interface IRewarder { /** * @notice This function is only callable by the staking contract. */ error MultiRewarderUnauthorizedCaller(address caller); /** * @notice The rewarder cannot be reconnected to the same staking token as it would cause wrongful reward * attribution through reconfiguration. */ error RewarderAlreadyConnected(IERC20 stakingToken); /** * @notice Emitted when the rewarder is connected to a staking token. */ event RewarderConnected(IERC20 indexed stakingToken); /** * @notice Informs the rewarder of an update in the staking contract, such as a deposit, withdraw or claim. * @dev Emergency withdrawals draw the balance of a user to 0, and DO NOT call `onUpdate`. * The rewarder logic must keep this in mind! */ function onUpdate(IERC20 token, address user, uint256 oldStake, uint256 oldSupply, uint256 newStake) external; /** * @notice Called by the staking contract whenever this rewarder is connected to a staking token in the staking * contract. Should only be callable once per staking token to avoid wrongful reward attribution through * reconfiguration. */ function connect(IERC20 stakingToken) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IStakingReceiver { function onWithdrawReceived( IERC20 token, address from, uint256 value, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import { IStakingReceiver } from "./IStakingReceiver.sol"; import { IRewarder } from "./IRewarder.sol"; // @notice The interface to the staking contract for Stargate V2 LPs. interface IStargateStaking { /// @notice StargateStaking renounce ownership is disabled. error StargateStakingRenounceOwnershipDisabled(); /** * @notice Thrown on `depositTo` if the caller does not have bytecode, used as an anti-phishing measure to prevent * users from calling `depositTo` as it's for zappers. */ error InvalidCaller(); /** * @notice Thrown on `withdrawToAndCall` if the `to` contract does not return the magic bytes. */ error InvalidReceiver(address receiver); error NonExistentPool(IERC20 token); event Deposit(IERC20 indexed token, address indexed from, address indexed to, uint256 amount); event Withdraw(IERC20 indexed token, address indexed from, address indexed to, uint256 amount, bool withUpdate); event PoolSet(IERC20 indexed token, IRewarder rewarder, bool exists); /** * ADMIN * */ /** * @notice Configures the rewarder for a pool. This will initialize the pool if it does not exist yet, * whitelisting it for deposits. */ function setPool(IERC20 token, IRewarder rewarder) external; /** * USER * */ /** * @notice Deposits `amount` of `token` into the pool. Informs the rewarder of the deposit, triggering a harvest. */ function deposit(IERC20 token, uint256 amount) external; /** * @notice Deposits `amount` of `token` into the pool for `to`. Informs the rewarder of the deposit, triggering a * harvest. This function can only be called by a contract, as to prevent phishing by a malicious contract. * @dev This function is useful for zappers, as it allows to do multiple steps ending with a deposit, * without the need to do multiple transactions. */ function depositTo(IERC20 token, address to, uint256 amount) external; /// @notice Withdraws `amount` of `token` from the pool. Informs the rewarder of the withdrawal, triggers a harvest. function withdraw(IERC20 token, uint256 amount) external; /** * @notice Withdraws `amount` of `token` from the pool for `to`, and subsequently calls the receipt function on the * `to` contract. Informs the rewarder of the withdrawal, triggering a harvest. * @dev This function is useful for zappers, as it allows to do multiple steps ending with a deposit, * without the need to do multiple transactions. */ function withdrawToAndCall(IERC20 token, IStakingReceiver to, uint256 amount, bytes calldata data) external; /// @notice Withdraws `amount` of `token` from the pool in an always-working fashion. The rewarder is not informed. function emergencyWithdraw(IERC20 token) external; /// @notice Claims the rewards from the rewarder, and sends them to the caller. function claim(IERC20[] calldata lpTokens) external; /** * VIEW * */ /// @notice Returns the deposited balance of `user` in the pool of `token`. function balanceOf(IERC20 token, address user) external view returns (uint256); /// @notice Returns the total supply of the pool of `token`. function totalSupply(IERC20 token) external view returns (uint256); /// @notice Returns whether `token` is a pool. function isPool(IERC20 token) external view returns (bool); /// @notice Returns the number of pools. function tokensLength() external view returns (uint256); /// @notice Returns the list of pools, by their staking tokens. function tokens() external view returns (IERC20[] memory); /// @notice Returns a slice of the list of pools, by their staking tokens. function tokens(uint256 start, uint256 end) external view returns (IERC20[] memory); // @notice Returns the rewarder of the pool of `token`, responsible for distribution reward tokens. function rewarder(IERC20 token) external view returns (IRewarder); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { IMultiRewarder, RewardPool } from "../interfaces/IMultiRewarder.sol"; /// @dev Library which handles staking rewards. library RewardLib { uint256 private constant PRECISION = 10 ** 24; function indexAndUpdate( RewardPool storage pool, IMultiRewarder.RewardDetails storage rewardDetails, address user, uint256 oldStake, uint256 totalSupply ) internal returns (uint256) { uint256 accRewardPerShare = index(pool, rewardDetails, totalSupply); return update(pool, user, oldStake, accRewardPerShare); } function update( RewardPool storage pool, address user, uint256 oldStake, uint256 accRewardPerShare ) internal returns (uint256) { uint256 rewardsForUser = ((accRewardPerShare - pool.rewardDebt[user]) * oldStake) / PRECISION; pool.rewardDebt[user] = accRewardPerShare; return rewardsForUser; } function index( RewardPool storage pool, IMultiRewarder.RewardDetails storage rewardDetails, uint256 totalSupply ) internal returns (uint256 accRewardPerShare) { accRewardPerShare = _index(pool, rewardDetails, totalSupply); pool.accRewardPerShare = accRewardPerShare; pool.lastRewardTime = uint48(block.timestamp); } function _index( RewardPool storage pool, IMultiRewarder.RewardDetails storage rewardDetails, uint256 totalSupply ) internal view returns (uint256) { // max(start, lastRewardTime) uint256 start = rewardDetails.start > pool.lastRewardTime ? rewardDetails.start : pool.lastRewardTime; // min(end, now) uint256 end = rewardDetails.end < block.timestamp ? rewardDetails.end : block.timestamp; if (start >= end || totalSupply == 0 || rewardDetails.totalAllocPoints == 0) { return pool.accRewardPerShare; } return (rewardDetails.rewardPerSec * (end - start) * pool.allocPoints * PRECISION) / rewardDetails.totalAllocPoints / totalSupply + pool.accRewardPerShare; } function getRewards( RewardPool storage pool, IMultiRewarder.RewardDetails storage rewardDetails, address user, uint256 oldStake, uint256 oldSupply ) internal view returns (uint256) { uint256 accRewardPerShare = _index(pool, rewardDetails, oldSupply); return ((accRewardPerShare - pool.rewardDebt[user]) * oldStake) / PRECISION; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.22; import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import { IMultiRewarder, RewardPool, IERC20 } from "../interfaces/IMultiRewarder.sol"; /// @dev Internal representation for a staking pool. struct RewardRegistry { uint256 rewardIdCount; mapping(uint256 => RewardPool) pools; mapping(address rewardToken => EnumerableSet.UintSet) byReward; mapping(IERC20 stakingToken => EnumerableSet.UintSet) byStake; mapping(address rewardToken => mapping(IERC20 stakingToken => uint256)) byRewardAndStake; mapping(address rewardToken => IMultiRewarder.RewardDetails) rewardDetails; EnumerableSet.AddressSet rewardTokens; mapping(IERC20 stakingToken => bool) connected; } /// @dev Library for staking pool logic. library RewardRegistryLib { using EnumerableSet for EnumerableSet.UintSet; using EnumerableSet for EnumerableSet.AddressSet; uint256 private constant MAX_ACTIVE_POOLS_PER_REWARD = 100; uint256 private constant MAX_ACTIVE_REWARD_TOKENS = 100; //** REGISTRY ADJUSTMENTS **/ function getOrCreateRewardDetails( RewardRegistry storage self, address rewardToken ) internal returns (IMultiRewarder.RewardDetails storage reward) { reward = self.rewardDetails[rewardToken]; if (!reward.exists) { if (self.rewardTokens.length() >= MAX_ACTIVE_REWARD_TOKENS) { revert IMultiRewarder.MultiRewarderMaxActiveRewardTokens(); } reward.exists = true; self.rewardTokens.add(rewardToken); emit IMultiRewarder.RewardRegistered(rewardToken); } } function getOrCreatePoolId( RewardRegistry storage self, address reward, IERC20 stake ) internal returns (uint256 poolId) { poolId = self.byRewardAndStake[reward][stake]; if (poolId == 0) { if (self.byReward[reward].length() >= MAX_ACTIVE_POOLS_PER_REWARD) { revert IMultiRewarder.MultiRewarderMaxPoolsForRewardToken(); } if (!self.connected[stake]) { revert IMultiRewarder.MultiRewarderDisconnectedStakingToken(address(stake)); } poolId = ++self.rewardIdCount; // Start at 1 self.byRewardAndStake[reward][stake] = poolId; self.byReward[reward].add(poolId); self.byStake[stake].add(poolId); self.pools[poolId].rewardToken = reward; self.pools[poolId].stakingToken = stake; self.pools[poolId].lastRewardTime = uint48(block.timestamp); emit IMultiRewarder.PoolRegistered(reward, stake); } } function removeReward(RewardRegistry storage self, address rewardToken) internal { if (!self.rewardDetails[rewardToken].exists) revert IMultiRewarder.MultiRewarderUnregisteredToken(rewardToken); uint256[] memory ids = self.byReward[rewardToken].values(); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; IERC20 stakingToken = self.pools[id].stakingToken; self.byStake[stakingToken].remove(id); self.byReward[rewardToken].remove(id); self.byRewardAndStake[rewardToken][stakingToken] = 0; self.pools[id].removed = true; } self.rewardTokens.remove(rewardToken); delete self.rewardDetails[rewardToken]; } function setAllocPoints( RewardRegistry storage self, address rewardToken, IERC20[] calldata stakingTokens, uint48[] calldata allocPoints ) internal { IMultiRewarder.RewardDetails storage reward = getOrCreateRewardDetails(self, rewardToken); uint160 totalSubtract; uint160 totalAdd; uint256 length = stakingTokens.length; for (uint256 i = 0; i < length; i++) { uint256 id = getOrCreatePoolId(self, rewardToken, stakingTokens[i]); totalSubtract += self.pools[id].allocPoints; totalAdd += allocPoints[i]; self.pools[id].allocPoints = allocPoints[i]; } reward.totalAllocPoints = reward.totalAllocPoints + totalAdd - totalSubtract; } //** VIEW FUNCTIONS **/ function allocPointsByReward( RewardRegistry storage self, address rewardToken ) internal view returns (IERC20[] memory stakingTokens, uint48[] memory allocPoints) { uint256[] memory ids = self.byReward[rewardToken].values(); stakingTokens = new IERC20[](ids.length); allocPoints = new uint48[](ids.length); for (uint256 i = 0; i < ids.length; i++) { stakingTokens[i] = self.pools[ids[i]].stakingToken; allocPoints[i] = self.pools[ids[i]].allocPoints; } } function allocPointsByStake( RewardRegistry storage self, IERC20 stakingToken ) internal view returns (address[] memory rewardTokens, uint48[] memory allocPoints) { uint256[] memory ids = self.byStake[stakingToken].values(); rewardTokens = new address[](ids.length); allocPoints = new uint48[](ids.length); for (uint256 i = 0; i < ids.length; i++) { rewardTokens[i] = self.pools[ids[i]].rewardToken; allocPoints[i] = self.pools[ids[i]].allocPoints; } } }
{ "evmVersion": "paris", "optimizer": { "enabled": true, "runs": 5000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IStargateStaking","name":"_staking","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"MultiRewarderDisconnectedStakingToken","type":"error"},{"inputs":[{"internalType":"uint256","name":"expected","type":"uint256"},{"internalType":"uint256","name":"actual","type":"uint256"}],"name":"MultiRewarderIncorrectNative","type":"error"},{"inputs":[],"name":"MultiRewarderMaxActiveRewardTokens","type":"error"},{"inputs":[],"name":"MultiRewarderMaxPoolsForRewardToken","type":"error"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"MultiRewarderNativeTransferFailed","type":"error"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"}],"name":"MultiRewarderPoolFinished","type":"error"},{"inputs":[],"name":"MultiRewarderRenounceOwnershipDisabled","type":"error"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"}],"name":"MultiRewarderStartInPast","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"MultiRewarderUnauthorizedCaller","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"MultiRewarderUnregisteredToken","type":"error"},{"inputs":[],"name":"MultiRewarderZeroDuration","type":"error"},{"inputs":[],"name":"MultiRewarderZeroRewardRate","type":"error"},{"inputs":[{"internalType":"contract IERC20","name":"stakingToken","type":"address"}],"name":"RewarderAlreadyConnected","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":true,"internalType":"contract IERC20[]","name":"stakeToken","type":"address[]"},{"indexed":false,"internalType":"uint48[]","name":"allocPoint","type":"uint48[]"}],"name":"AllocPointsSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":true,"internalType":"contract IERC20","name":"stakeToken","type":"address"}],"name":"PoolRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountAdded","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"newEnd","type":"uint48"}],"name":"RewardExtended","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"}],"name":"RewardRegistered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountAdded","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountPeriod","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"start","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"duration","type":"uint48"}],"name":"RewardSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"rewardToken","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"bool","name":"pullTokens","type":"bool"}],"name":"RewardStopped","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IERC20","name":"stakingToken","type":"address"}],"name":"RewarderConnected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address[]","name":"rewardTokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"RewardsClaimed","type":"event"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"}],"name":"allocPointsByReward","outputs":[{"internalType":"contract IERC20[]","name":"","type":"address[]"},{"internalType":"uint48[]","name":"","type":"uint48[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"stakingToken","type":"address"}],"name":"allocPointsByStake","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint48[]","name":"","type":"uint48[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"stakingToken","type":"address"}],"name":"connect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"extendReward","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"stakingToken","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getRewards","outputs":[{"internalType":"address[]","name":"","type":"address[]"},{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"stakingToken","type":"address"},{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"oldStake","type":"uint256"},{"internalType":"uint256","name":"oldSupply","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"onUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"}],"name":"rewardDetails","outputs":[{"components":[{"internalType":"uint256","name":"rewardPerSec","type":"uint256"},{"internalType":"uint160","name":"totalAllocPoints","type":"uint160"},{"internalType":"uint48","name":"start","type":"uint48"},{"internalType":"uint48","name":"end","type":"uint48"},{"internalType":"bool","name":"exists","type":"bool"}],"internalType":"struct IMultiRewarder.RewardDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"contract IERC20[]","name":"stakingTokens","type":"address[]"},{"internalType":"uint48[]","name":"allocPoints","type":"uint48[]"}],"name":"setAllocPoints","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint48","name":"start","type":"uint48"},{"internalType":"uint48","name":"duration","type":"uint48"}],"name":"setReward","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"staking","outputs":[{"internalType":"contract IStargateStaking","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bool","name":"pullTokens","type":"bool"}],"name":"stopReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60a06040523480156200001157600080fd5b5060405162002edc38038062002edc8339810160408190526200003491620000a1565b6200003f3362000051565b6001600160a01b0316608052620000d3565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208284031215620000b457600080fd5b81516001600160a01b0381168114620000cc57600080fd5b9392505050565b608051612dca62000112600039600081816101140152818161076e01528181610816015281816109f101528181610f1d0152611a790152612dca6000f3fe6080604052600436106100e85760003560e01c8063aed457c81161008a578063cf17240311610059578063cf17240314610285578063ee8f931b14610399578063f2fde38b146103b9578063f42395f2146103d957600080fd5b8063aed457c814610210578063aeefd1fc14610230578063c1ef636414610250578063c2b18aa01461026357600080fd5b8063715018a6116100c6578063715018a614610181578063779bcb9b1461019657806380520969146101c45780638da5cb5b146101f257600080fd5b8063406b15cd146100ed5780634cf088d9146101025780635a564e8614610153575b600080fd5b6101006100fb36600461268f565b6103f9565b005b34801561010e57600080fd5b506101367f000000000000000000000000000000000000000000000000000000000000000081565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561015f57600080fd5b5061017361016e3660046126bb565b610593565b60405161014a929190612756565b34801561018d57600080fd5b506101006105aa565b3480156101a257600080fd5b506101b66101b1366004612784565b6105e4565b60405161014a9291906127bd565b3480156101d057600080fd5b506101e46101df3660046126bb565b6108c3565b60405161014a929190612814565b3480156101fe57600080fd5b506000546001600160a01b0316610136565b34801561021c57600080fd5b5061010061022b366004612879565b6108d1565b34801561023c57600080fd5b5061010061024b3660046128c4565b6109e6565b61010061025e366004612930565b610c8c565b34801561026f57600080fd5b50610278610f01565b60405161014a919061297f565b34801561029157600080fd5b5061033e6102a03660046126bb565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152506001600160a01b03908116600090815260066020908152604091829020825160a0810184528154815260018201549485169281019290925265ffffffffffff600160a01b8504811693830193909352600160d01b909304909116606082015260029091015460ff161515608082015290565b60405161014a9190600060a082019050825182526001600160a01b036020840151166020830152604083015165ffffffffffff8082166040850152806060860151166060850152505060808301511515608083015292915050565b3480156103a557600080fd5b506101006103b43660046126bb565b610f12565b3480156103c557600080fd5b506101006103d43660046126bb565b611020565b3480156103e557600080fd5b506101006103f43660046129d7565b6110b0565b610401611132565b6001600160a01b0382166000908152600660205260409020600281015460ff16610467576040517fc3367e760000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024015b60405180910390fd5b600181015442600160d01b90910465ffffffffffff1610156104c0576040517f0fc659c20000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161045e565b80546104d5906104d09084612a89565b61118e565b600182018054601a906104f8908490600160d01b900465ffffffffffff16612ac4565b92506101000a81548165ffffffffffff021916908365ffffffffffff160217905550826001600160a01b03167f71d0060f3c1f2f0de478aca435ab612f7550b9415f91c6beac671faaca34bb688383600101601a9054906101000a900465ffffffffffff1660405161057c92919091825265ffffffffffff16602082015260400190565b60405180910390a261058e8383611210565b505050565b6060806105a1600184611279565b91509150915091565b6105b2611132565b6040517f20e02be700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166000908152600460205260408120606091829161060a90611430565b90506000815167ffffffffffffffff81111561062857610628612ae3565b604051908082528060200260200182016040528015610651578160200160208202803683370190505b5090506000825167ffffffffffffffff81111561067057610670612ae3565b604051908082528060200260200182016040528015610699578160200160208202803683370190505b50905060005b83518110156108b45760006001800160008684815181106106c2576106c2612b12565b6020908102919091018101518252818101929092526040908101600090812060018101546001600160a01b031680835260069094529190208651919350919086908590811061071357610713612b12565b6001600160a01b03928316602091820292909201015260028301546040517ff7888aec00000000000000000000000000000000000000000000000000000000815290821660048201528a8216602482015261088d9183918c917f0000000000000000000000000000000000000000000000000000000000000000169063f7888aec90604401602060405180830381865afa1580156107b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d99190612b41565b60028601546040517fe4dc2aa40000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f00000000000000000000000000000000000000000000000000000000000000009091169063e4dc2aa490602401602060405180830381865afa15801561085f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108839190612b41565b8693929190611444565b84848151811061089f5761089f612b12565b6020908102919091010152505060010161069f565b509093509150505b9250929050565b6060806105a16001846114a7565b6108d9611132565b6108e4600184611655565b80156109925760006001600160a01b03841615610981576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038516906370a0823190602401602060405180830381865afa158015610958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097c9190612b41565b610983565b475b9050610990838583611816565b505b816001600160a01b0316836001600160a01b03167ff842ed66d8fd158c4e8a71051d6493bff2e7f1994ea49e9713600c9aaa9cc4a7836040516109d9911515815260200190565b60405180910390a3505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610a4a576040517f9f49538400000000000000000000000000000000000000000000000000000000815233600482015260240161045e565b6001600160a01b0385166000908152600460205260408120610a6b90611430565b90506000815167ffffffffffffffff811115610a8957610a89612ae3565b604051908082528060200260200182016040528015610ab2578160200160208202803683370190505b5090506000825167ffffffffffffffff811115610ad157610ad1612ae3565b604051908082528060200260200182016040528015610afa578160200160208202803683370190505b50905060005b8351811015610bca576000600180016000868481518110610b2357610b23612b12565b60200260200101518152602001908152602001600020905060008160010160009054906101000a90046001600160a01b0316905080858481518110610b6a57610b6a612b12565b6001600160a01b039283166020918202929092018101919091529082166000908152600690915260409020610ba39083908c8c8c6118dd565b848481518110610bb557610bb5612b12565b60209081029190910101525050600101610b00565b50866001600160a01b03167fc53cb8bc1a7200a84d0b66a538905a245c4915aace7f1ce5dc4a0ba107ebc15c8383604051610c069291906127bd565b60405180910390a260005b8351811015610c81576000828281518110610c2e57610c2e612b12565b60200260200101511115610c7957610c7988848381518110610c5257610c52612b12565b6020026020010151848481518110610c6c57610c6c612b12565b6020026020010151611816565b600101610c11565b505050505050505050565b610c94611132565b428265ffffffffffff161015610ce0576040517f53c1289f00000000000000000000000000000000000000000000000000000000815265ffffffffffff8316600482015260240161045e565b8065ffffffffffff16600003610d22576040517f95cf0dc400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610d2f6001866118f9565b9050610d3a856119bc565b60018101548490600160d01b900465ffffffffffff16421015610dcc57600182015460009042600160a01b90910465ffffffffffff1611610d7b5742610d90565b6001830154600160a01b900465ffffffffffff165b6001840154909150610db2908290600160d01b900465ffffffffffff16612b5a565b8354610dbe9190612b6d565b610dc89083612b84565b9150505b6000610de065ffffffffffff851683612a89565b905080600003610e1c576040517f6e9377ee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001830180547fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b65ffffffffffff881602179055610e608486612ac4565b60018401805465ffffffffffff928316600160d01b0279ffffffffffffffffffffffffffffffffffffffffffffffffffff9091161790558184556040805188815260208101859052878316818301529186166060830152516001600160a01b038916917fa57b91f8b94eace9e74d336f5f3202d0eb4cb489f646fc322c7ed0f00fcd99fd919081900360800190a2610ef88787611210565b50505050505050565b6060610f0d6007611430565b905090565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610f76576040517f9f49538400000000000000000000000000000000000000000000000000000000815233600482015260240161045e565b6001600160a01b03811660009081526009602052604090205460ff1615610fd4576040517f8575f3a60000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260240161045e565b6001600160a01b038116600081815260096020526040808220805460ff19166001179055517fa351e5ceb90bd585957b38958d172682cb48fcff0320a4395c976ccdb40e44539190a250565b611028611132565b6001600160a01b0381166110a45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161045e565b6110ad81611af8565b50565b6110b8611132565b6110c1856119bc565b6110d060018686868686611b60565b83836040516110e0929190612b97565b6040518091039020856001600160a01b03167fa8f10febbe8be4d24be81ee9f81f1a380ac400eb0cfc898b153b15dbaa70ae748484604051611123929190612bd9565b60405180910390a35050505050565b6000546001600160a01b0316331461118c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045e565b565b600065ffffffffffff82111561120c5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203460448201527f3820626974730000000000000000000000000000000000000000000000000000606482015260840161045e565b5090565b6001600160a01b03821661126457803414611260576040517f8b00479e0000000000000000000000000000000000000000000000000000000081526004810182905234602482015260440161045e565b5050565b6112606001600160a01b038316333084611d01565b6001600160a01b0381166000908152600383016020526040812060609182916112a190611430565b9050805167ffffffffffffffff8111156112bd576112bd612ae3565b6040519080825280602002602001820160405280156112e6578160200160208202803683370190505b509250805167ffffffffffffffff81111561130357611303612ae3565b60405190808252806020026020018201604052801561132c578160200160208202803683370190505b50915060005b81518110156114275785600101600083838151811061135357611353612b12565b6020026020010151815260200190815260200160002060010160009054906101000a90046001600160a01b031684828151811061139257611392612b12565b60200260200101906001600160a01b031690816001600160a01b0316815250508560010160008383815181106113ca576113ca612b12565b60200260200101518152602001908152602001600020600101601a9054906101000a900465ffffffffffff1683828151811061140857611408612b12565b65ffffffffffff90921660209283029190910190910152600101611332565b50509250929050565b6060600061143d83611dd0565b9392505050565b600080611452878785611e2c565b6001600160a01b038616600090815260038901602052604090205490915069d3c21bcecceda10000009085906114889084612b5a565b6114929190612b6d565b61149c9190612a89565b979650505050505050565b6001600160a01b0381166000908152600283016020526040812060609182916114cf90611430565b9050805167ffffffffffffffff8111156114eb576114eb612ae3565b604051908082528060200260200182016040528015611514578160200160208202803683370190505b509250805167ffffffffffffffff81111561153157611531612ae3565b60405190808252806020026020018201604052801561155a578160200160208202803683370190505b50915060005b81518110156114275785600101600083838151811061158157611581612b12565b6020026020010151815260200190815260200160002060020160009054906101000a90046001600160a01b03168482815181106115c0576115c0612b12565b60200260200101906001600160a01b031690816001600160a01b0316815250508560010160008383815181106115f8576115f8612b12565b60200260200101518152602001908152602001600020600101601a9054906101000a900465ffffffffffff1683828151811061163657611636612b12565b65ffffffffffff90921660209283029190910190910152600101611560565b6001600160a01b038116600090815260058301602052604090206002015460ff166116b7576040517fc3367e760000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260240161045e565b6001600160a01b038116600090815260028301602052604081206116da90611430565b905060005b81518110156117d45760008282815181106116fc576116fc612b12565b60209081029190910181015160008181526001880183526040808220600201546001600160a01b031680835260038a01909452902090925061173e9083611f7d565b506001600160a01b038516600090815260028701602052604090206117639083611f7d565b506001600160a01b0380861660009081526004880160209081526040808320949093168252928352818120819055928352600180880190925290912060020180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b179055016116df565b506117e26006840183611f89565b50506001600160a01b031660009081526005909101602052604081208181556001810191909155600201805460ff19169055565b6001600160a01b0382166118c9576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114611871576040519150601f19603f3d011682016040523d82523d6000602084013e611876565b606091505b50509050806118c3576040517f5c4c2a250000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024810183905260440161045e565b50505050565b61058e6001600160a01b0383168483611f9e565b6000806118eb878785611fe7565b905061149c8786868461203a565b6001600160a01b03811660009081526005830160205260409020600281015460ff166119b657606461192d846006016120ac565b10611964576040517f290e96a500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028101805460ff1916600117905561198060068401836120b6565b506040516001600160a01b038316907f2967504cad2094d65ef2dcb85e4074f4f7455a846798fcc90657d6f33c4125ea90600090a25b92915050565b6001600160a01b03811660009081526003602052604081206119dd906120ac565b905060005b8181101561058e576001600160a01b03831660009081526003602052604081206002908290611a1190856120cb565b8152602080820192909252604090810160009081206001600160a01b038881168352600690945290829020600282015492517fe4dc2aa40000000000000000000000000000000000000000000000000000000081529284166004840152909350611aee9290917f00000000000000000000000000000000000000000000000000000000000000009091169063e4dc2aa490602401602060405180830381865afa158015611ac2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae69190612b41565b839190611fe7565b50506001016119e2565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611b6c87876118f9565b905060008085815b81811015611c94576000611baf8c8c8c8c86818110611b9557611b95612b12565b9050602002016020810190611baa91906126bb565b6120d7565b600081815260018e810160205260409091200154909150611bdf90600160d01b900465ffffffffffff1686612c24565b9450878783818110611bf357611bf3612b12565b9050602002016020810190611c089190612c44565b611c1a9065ffffffffffff1685612c24565b9350878783818110611c2e57611c2e612b12565b9050602002016020810190611c439190612c44565b60009182526001808e0160205260409092208201805465ffffffffffff92909216600160d01b0279ffffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117905501611b74565b5060018401548390611cb09084906001600160a01b0316612c24565b611cba9190612c5f565b60019490940180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0390951694909417909355505050505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526118c39085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612300565b606081600001805480602002602001604051908101604052809291908181526020018280548015611e2057602002820191906000526020600020905b815481526020019060010190808311611e0c575b50505050509050919050565b60018084015490830154600091829165ffffffffffff600160a01b928390048116929091041611611e70576001850154600160a01b900465ffffffffffff16611e85565b6001840154600160a01b900465ffffffffffff165b600185015465ffffffffffff918216925060009142600160d01b9092041610611eae5742611ec3565b6001850154600160d01b900465ffffffffffff165b90508082101580611ed2575083155b80611ee8575060018501546001600160a01b0316155b15611ef85750508354905061143d565b85546001868101549088015486916001600160a01b03169069d3c21bcecceda100000090600160d01b900465ffffffffffff16611f358787612b5a565b8a54611f419190612b6d565b611f4b9190612b6d565b611f559190612b6d565b611f5f9190612a89565b611f699190612a89565b611f739190612b84565b9695505050505050565b600061143d83836123e8565b600061143d836001600160a01b0384166123e8565b6040516001600160a01b03831660248201526044810182905261058e9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611d4e565b6000611ff4848484611e2c565b808555600190940180547fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b4265ffffffffffff1602179055509192915050565b6001600160a01b0383166000908152600385016020526040812054819069d3c21bcecceda100000090859061206f9086612b5a565b6120799190612b6d565b6120839190612a89565b6001600160a01b038616600090815260038801602052604090208490559150505b949350505050565b60006119b6825490565b600061143d836001600160a01b0384166124e2565b600061143d8383612531565b6001600160a01b03808316600090815260048501602090815260408083209385168352929052908120549081900361143d576001600160a01b0383166000908152600285016020526040902060649061212f906120ac565b10612166576040517f2fee563000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216600090815260088501602052604090205460ff166121c5576040517fff9864e50000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260240161045e565b83600001600081546121d690612c7f565b91829055506001600160a01b03808516600081815260048801602090815260408083209488168352938152838220859055918152600288019091522090915061221f908261255b565b506001600160a01b03821660009081526003850160205260409020612244908261255b565b506000818152600185810160205260408083209182018054600290930180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038881169182179092559088167fffffffffffff00000000000000000000000000000000000000000000000000009094168417600160a01b4265ffffffffffff160217909155905190927f26f4b31b7240e7422a9fe2ba5ce7684500302a536166d0ed481d7ad653ff25ab91a39392505050565b6000612355826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166125679092919063ffffffff16565b90508051600014806123765750808060200190518101906123769190612cb7565b61058e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161045e565b600081815260018301602052604081205480156124d157600061240c600183612b5a565b855490915060009061242090600190612b5a565b905081811461248557600086600001828154811061244057612440612b12565b906000526020600020015490508087600001848154811061246357612463612b12565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061249657612496612cd4565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506119b6565b60009150506119b6565b5092915050565b6000818152600183016020526040812054612529575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556119b6565b5060006119b6565b600082600001828154811061254857612548612b12565b9060005260206000200154905092915050565b600061143d83836124e2565b60606120a4848460008585600080866001600160a01b0316858760405161258e9190612d27565b60006040518083038185875af1925050503d80600081146125cb576040519150601f19603f3d011682016040523d82523d6000602084013e6125d0565b606091505b509150915061149c878383876060831561264b578251600003612644576001600160a01b0385163b6126445760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161045e565b50816120a4565b6120a483838151156126605781518083602001fd5b8060405162461bcd60e51b815260040161045e9190612d43565b6001600160a01b03811681146110ad57600080fd5b600080604083850312156126a257600080fd5b82356126ad8161267a565b946020939093013593505050565b6000602082840312156126cd57600080fd5b813561143d8161267a565b60008151808452602080850194506020840160005b838110156127125781516001600160a01b0316875295820195908201906001016126ed565b509495945050505050565b60008151808452602080850194506020840160005b8381101561271257815165ffffffffffff1687529582019590820190600101612732565b60408152600061276960408301856126d8565b828103602084015261277b818561271d565b95945050505050565b6000806040838503121561279757600080fd5b82356127a28161267a565b915060208301356127b28161267a565b809150509250929050565b6040815260006127d060408301856126d8565b82810360208481019190915284518083528582019282019060005b81811015612807578451835293830193918301916001016127eb565b5090979650505050505050565b604080825283519082018190526000906020906060840190828701845b828110156128565781516001600160a01b031684529284019290840190600101612831565b5050508381036020850152611f73818661271d565b80151581146110ad57600080fd5b60008060006060848603121561288e57600080fd5b83356128998161267a565b925060208401356128a98161267a565b915060408401356128b98161286b565b809150509250925092565b600080600080600060a086880312156128dc57600080fd5b85356128e78161267a565b945060208601356128f78161267a565b94979496505050506040830135926060810135926080909101359150565b803565ffffffffffff8116811461292b57600080fd5b919050565b6000806000806080858703121561294657600080fd5b84356129518161267a565b93506020850135925061296660408601612915565b915061297460608601612915565b905092959194509250565b60208152600061143d60208301846126d8565b60008083601f8401126129a457600080fd5b50813567ffffffffffffffff8111156129bc57600080fd5b6020830191508360208260051b85010111156108bc57600080fd5b6000806000806000606086880312156129ef57600080fd5b85356129fa8161267a565b9450602086013567ffffffffffffffff80821115612a1757600080fd5b612a2389838a01612992565b90965094506040880135915080821115612a3c57600080fd5b50612a4988828901612992565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082612abf577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b65ffffffffffff8181168382160190808211156124db576124db612a5a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215612b5357600080fd5b5051919050565b818103818111156119b6576119b6612a5a565b80820281158282048414176119b6576119b6612a5a565b808201808211156119b6576119b6612a5a565b60008184825b85811015612bce578135612bb08161267a565b6001600160a01b031683526020928301929190910190600101612b9d565b509095945050505050565b60208082528181018390526000908460408401835b86811015612c195765ffffffffffff612c0684612915565b1682529183019190830190600101612bee565b509695505050505050565b6001600160a01b038181168382160190808211156124db576124db612a5a565b600060208284031215612c5657600080fd5b61143d82612915565b6001600160a01b038281168282160390808211156124db576124db612a5a565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612cb057612cb0612a5a565b5060010190565b600060208284031215612cc957600080fd5b815161143d8161286b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60005b83811015612d1e578181015183820152602001612d06565b50506000910152565b60008251612d39818460208701612d03565b9190910192915050565b6020815260008251806020840152612d62816040850160208701612d03565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122067296dd182c1bc08332182b8a32d7058a27d9c387da1735d2f5e912941bdb99f64736f6c63430008160033000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd
Deployed Bytecode
0x6080604052600436106100e85760003560e01c8063aed457c81161008a578063cf17240311610059578063cf17240314610285578063ee8f931b14610399578063f2fde38b146103b9578063f42395f2146103d957600080fd5b8063aed457c814610210578063aeefd1fc14610230578063c1ef636414610250578063c2b18aa01461026357600080fd5b8063715018a6116100c6578063715018a614610181578063779bcb9b1461019657806380520969146101c45780638da5cb5b146101f257600080fd5b8063406b15cd146100ed5780634cf088d9146101025780635a564e8614610153575b600080fd5b6101006100fb36600461268f565b6103f9565b005b34801561010e57600080fd5b506101367f000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd81565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561015f57600080fd5b5061017361016e3660046126bb565b610593565b60405161014a929190612756565b34801561018d57600080fd5b506101006105aa565b3480156101a257600080fd5b506101b66101b1366004612784565b6105e4565b60405161014a9291906127bd565b3480156101d057600080fd5b506101e46101df3660046126bb565b6108c3565b60405161014a929190612814565b3480156101fe57600080fd5b506000546001600160a01b0316610136565b34801561021c57600080fd5b5061010061022b366004612879565b6108d1565b34801561023c57600080fd5b5061010061024b3660046128c4565b6109e6565b61010061025e366004612930565b610c8c565b34801561026f57600080fd5b50610278610f01565b60405161014a919061297f565b34801561029157600080fd5b5061033e6102a03660046126bb565b6040805160a081018252600080825260208201819052918101829052606081018290526080810191909152506001600160a01b03908116600090815260066020908152604091829020825160a0810184528154815260018201549485169281019290925265ffffffffffff600160a01b8504811693830193909352600160d01b909304909116606082015260029091015460ff161515608082015290565b60405161014a9190600060a082019050825182526001600160a01b036020840151166020830152604083015165ffffffffffff8082166040850152806060860151166060850152505060808301511515608083015292915050565b3480156103a557600080fd5b506101006103b43660046126bb565b610f12565b3480156103c557600080fd5b506101006103d43660046126bb565b611020565b3480156103e557600080fd5b506101006103f43660046129d7565b6110b0565b610401611132565b6001600160a01b0382166000908152600660205260409020600281015460ff16610467576040517fc3367e760000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024015b60405180910390fd5b600181015442600160d01b90910465ffffffffffff1610156104c0576040517f0fc659c20000000000000000000000000000000000000000000000000000000081526001600160a01b038416600482015260240161045e565b80546104d5906104d09084612a89565b61118e565b600182018054601a906104f8908490600160d01b900465ffffffffffff16612ac4565b92506101000a81548165ffffffffffff021916908365ffffffffffff160217905550826001600160a01b03167f71d0060f3c1f2f0de478aca435ab612f7550b9415f91c6beac671faaca34bb688383600101601a9054906101000a900465ffffffffffff1660405161057c92919091825265ffffffffffff16602082015260400190565b60405180910390a261058e8383611210565b505050565b6060806105a1600184611279565b91509150915091565b6105b2611132565b6040517f20e02be700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0382166000908152600460205260408120606091829161060a90611430565b90506000815167ffffffffffffffff81111561062857610628612ae3565b604051908082528060200260200182016040528015610651578160200160208202803683370190505b5090506000825167ffffffffffffffff81111561067057610670612ae3565b604051908082528060200260200182016040528015610699578160200160208202803683370190505b50905060005b83518110156108b45760006001800160008684815181106106c2576106c2612b12565b6020908102919091018101518252818101929092526040908101600090812060018101546001600160a01b031680835260069094529190208651919350919086908590811061071357610713612b12565b6001600160a01b03928316602091820292909201015260028301546040517ff7888aec00000000000000000000000000000000000000000000000000000000815290821660048201528a8216602482015261088d9183918c917f000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd169063f7888aec90604401602060405180830381865afa1580156107b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107d99190612b41565b60028601546040517fe4dc2aa40000000000000000000000000000000000000000000000000000000081526001600160a01b0391821660048201527f000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd9091169063e4dc2aa490602401602060405180830381865afa15801561085f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108839190612b41565b8693929190611444565b84848151811061089f5761089f612b12565b6020908102919091010152505060010161069f565b509093509150505b9250929050565b6060806105a16001846114a7565b6108d9611132565b6108e4600184611655565b80156109925760006001600160a01b03841615610981576040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201526001600160a01b038516906370a0823190602401602060405180830381865afa158015610958573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061097c9190612b41565b610983565b475b9050610990838583611816565b505b816001600160a01b0316836001600160a01b03167ff842ed66d8fd158c4e8a71051d6493bff2e7f1994ea49e9713600c9aaa9cc4a7836040516109d9911515815260200190565b60405180910390a3505050565b336001600160a01b037f000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd1614610a4a576040517f9f49538400000000000000000000000000000000000000000000000000000000815233600482015260240161045e565b6001600160a01b0385166000908152600460205260408120610a6b90611430565b90506000815167ffffffffffffffff811115610a8957610a89612ae3565b604051908082528060200260200182016040528015610ab2578160200160208202803683370190505b5090506000825167ffffffffffffffff811115610ad157610ad1612ae3565b604051908082528060200260200182016040528015610afa578160200160208202803683370190505b50905060005b8351811015610bca576000600180016000868481518110610b2357610b23612b12565b60200260200101518152602001908152602001600020905060008160010160009054906101000a90046001600160a01b0316905080858481518110610b6a57610b6a612b12565b6001600160a01b039283166020918202929092018101919091529082166000908152600690915260409020610ba39083908c8c8c6118dd565b848481518110610bb557610bb5612b12565b60209081029190910101525050600101610b00565b50866001600160a01b03167fc53cb8bc1a7200a84d0b66a538905a245c4915aace7f1ce5dc4a0ba107ebc15c8383604051610c069291906127bd565b60405180910390a260005b8351811015610c81576000828281518110610c2e57610c2e612b12565b60200260200101511115610c7957610c7988848381518110610c5257610c52612b12565b6020026020010151848481518110610c6c57610c6c612b12565b6020026020010151611816565b600101610c11565b505050505050505050565b610c94611132565b428265ffffffffffff161015610ce0576040517f53c1289f00000000000000000000000000000000000000000000000000000000815265ffffffffffff8316600482015260240161045e565b8065ffffffffffff16600003610d22576040517f95cf0dc400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000610d2f6001866118f9565b9050610d3a856119bc565b60018101548490600160d01b900465ffffffffffff16421015610dcc57600182015460009042600160a01b90910465ffffffffffff1611610d7b5742610d90565b6001830154600160a01b900465ffffffffffff165b6001840154909150610db2908290600160d01b900465ffffffffffff16612b5a565b8354610dbe9190612b6d565b610dc89083612b84565b9150505b6000610de065ffffffffffff851683612a89565b905080600003610e1c576040517f6e9377ee00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001830180547fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b65ffffffffffff881602179055610e608486612ac4565b60018401805465ffffffffffff928316600160d01b0279ffffffffffffffffffffffffffffffffffffffffffffffffffff9091161790558184556040805188815260208101859052878316818301529186166060830152516001600160a01b038916917fa57b91f8b94eace9e74d336f5f3202d0eb4cb489f646fc322c7ed0f00fcd99fd919081900360800190a2610ef88787611210565b50505050505050565b6060610f0d6007611430565b905090565b336001600160a01b037f000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd1614610f76576040517f9f49538400000000000000000000000000000000000000000000000000000000815233600482015260240161045e565b6001600160a01b03811660009081526009602052604090205460ff1615610fd4576040517f8575f3a60000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260240161045e565b6001600160a01b038116600081815260096020526040808220805460ff19166001179055517fa351e5ceb90bd585957b38958d172682cb48fcff0320a4395c976ccdb40e44539190a250565b611028611132565b6001600160a01b0381166110a45760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161045e565b6110ad81611af8565b50565b6110b8611132565b6110c1856119bc565b6110d060018686868686611b60565b83836040516110e0929190612b97565b6040518091039020856001600160a01b03167fa8f10febbe8be4d24be81ee9f81f1a380ac400eb0cfc898b153b15dbaa70ae748484604051611123929190612bd9565b60405180910390a35050505050565b6000546001600160a01b0316331461118c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161045e565b565b600065ffffffffffff82111561120c5760405162461bcd60e51b815260206004820152602660248201527f53616665436173743a2076616c756520646f65736e27742066697420696e203460448201527f3820626974730000000000000000000000000000000000000000000000000000606482015260840161045e565b5090565b6001600160a01b03821661126457803414611260576040517f8b00479e0000000000000000000000000000000000000000000000000000000081526004810182905234602482015260440161045e565b5050565b6112606001600160a01b038316333084611d01565b6001600160a01b0381166000908152600383016020526040812060609182916112a190611430565b9050805167ffffffffffffffff8111156112bd576112bd612ae3565b6040519080825280602002602001820160405280156112e6578160200160208202803683370190505b509250805167ffffffffffffffff81111561130357611303612ae3565b60405190808252806020026020018201604052801561132c578160200160208202803683370190505b50915060005b81518110156114275785600101600083838151811061135357611353612b12565b6020026020010151815260200190815260200160002060010160009054906101000a90046001600160a01b031684828151811061139257611392612b12565b60200260200101906001600160a01b031690816001600160a01b0316815250508560010160008383815181106113ca576113ca612b12565b60200260200101518152602001908152602001600020600101601a9054906101000a900465ffffffffffff1683828151811061140857611408612b12565b65ffffffffffff90921660209283029190910190910152600101611332565b50509250929050565b6060600061143d83611dd0565b9392505050565b600080611452878785611e2c565b6001600160a01b038616600090815260038901602052604090205490915069d3c21bcecceda10000009085906114889084612b5a565b6114929190612b6d565b61149c9190612a89565b979650505050505050565b6001600160a01b0381166000908152600283016020526040812060609182916114cf90611430565b9050805167ffffffffffffffff8111156114eb576114eb612ae3565b604051908082528060200260200182016040528015611514578160200160208202803683370190505b509250805167ffffffffffffffff81111561153157611531612ae3565b60405190808252806020026020018201604052801561155a578160200160208202803683370190505b50915060005b81518110156114275785600101600083838151811061158157611581612b12565b6020026020010151815260200190815260200160002060020160009054906101000a90046001600160a01b03168482815181106115c0576115c0612b12565b60200260200101906001600160a01b031690816001600160a01b0316815250508560010160008383815181106115f8576115f8612b12565b60200260200101518152602001908152602001600020600101601a9054906101000a900465ffffffffffff1683828151811061163657611636612b12565b65ffffffffffff90921660209283029190910190910152600101611560565b6001600160a01b038116600090815260058301602052604090206002015460ff166116b7576040517fc3367e760000000000000000000000000000000000000000000000000000000081526001600160a01b038216600482015260240161045e565b6001600160a01b038116600090815260028301602052604081206116da90611430565b905060005b81518110156117d45760008282815181106116fc576116fc612b12565b60209081029190910181015160008181526001880183526040808220600201546001600160a01b031680835260038a01909452902090925061173e9083611f7d565b506001600160a01b038516600090815260028701602052604090206117639083611f7d565b506001600160a01b0380861660009081526004880160209081526040808320949093168252928352818120819055928352600180880190925290912060020180547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16600160a01b179055016116df565b506117e26006840183611f89565b50506001600160a01b031660009081526005909101602052604081208181556001810191909155600201805460ff19169055565b6001600160a01b0382166118c9576000836001600160a01b03168260405160006040518083038185875af1925050503d8060008114611871576040519150601f19603f3d011682016040523d82523d6000602084013e611876565b606091505b50509050806118c3576040517f5c4c2a250000000000000000000000000000000000000000000000000000000081526001600160a01b03841660048201526024810183905260440161045e565b50505050565b61058e6001600160a01b0383168483611f9e565b6000806118eb878785611fe7565b905061149c8786868461203a565b6001600160a01b03811660009081526005830160205260409020600281015460ff166119b657606461192d846006016120ac565b10611964576040517f290e96a500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028101805460ff1916600117905561198060068401836120b6565b506040516001600160a01b038316907f2967504cad2094d65ef2dcb85e4074f4f7455a846798fcc90657d6f33c4125ea90600090a25b92915050565b6001600160a01b03811660009081526003602052604081206119dd906120ac565b905060005b8181101561058e576001600160a01b03831660009081526003602052604081206002908290611a1190856120cb565b8152602080820192909252604090810160009081206001600160a01b038881168352600690945290829020600282015492517fe4dc2aa40000000000000000000000000000000000000000000000000000000081529284166004840152909350611aee9290917f000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd9091169063e4dc2aa490602401602060405180830381865afa158015611ac2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ae69190612b41565b839190611fe7565b50506001016119e2565b600080546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000611b6c87876118f9565b905060008085815b81811015611c94576000611baf8c8c8c8c86818110611b9557611b95612b12565b9050602002016020810190611baa91906126bb565b6120d7565b600081815260018e810160205260409091200154909150611bdf90600160d01b900465ffffffffffff1686612c24565b9450878783818110611bf357611bf3612b12565b9050602002016020810190611c089190612c44565b611c1a9065ffffffffffff1685612c24565b9350878783818110611c2e57611c2e612b12565b9050602002016020810190611c439190612c44565b60009182526001808e0160205260409092208201805465ffffffffffff92909216600160d01b0279ffffffffffffffffffffffffffffffffffffffffffffffffffff90921691909117905501611b74565b5060018401548390611cb09084906001600160a01b0316612c24565b611cba9190612c5f565b60019490940180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0390951694909417909355505050505050505050565b6040516001600160a01b03808516602483015283166044820152606481018290526118c39085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152612300565b606081600001805480602002602001604051908101604052809291908181526020018280548015611e2057602002820191906000526020600020905b815481526020019060010190808311611e0c575b50505050509050919050565b60018084015490830154600091829165ffffffffffff600160a01b928390048116929091041611611e70576001850154600160a01b900465ffffffffffff16611e85565b6001840154600160a01b900465ffffffffffff165b600185015465ffffffffffff918216925060009142600160d01b9092041610611eae5742611ec3565b6001850154600160d01b900465ffffffffffff165b90508082101580611ed2575083155b80611ee8575060018501546001600160a01b0316155b15611ef85750508354905061143d565b85546001868101549088015486916001600160a01b03169069d3c21bcecceda100000090600160d01b900465ffffffffffff16611f358787612b5a565b8a54611f419190612b6d565b611f4b9190612b6d565b611f559190612b6d565b611f5f9190612a89565b611f699190612a89565b611f739190612b84565b9695505050505050565b600061143d83836123e8565b600061143d836001600160a01b0384166123e8565b6040516001600160a01b03831660248201526044810182905261058e9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611d4e565b6000611ff4848484611e2c565b808555600190940180547fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff16600160a01b4265ffffffffffff1602179055509192915050565b6001600160a01b0383166000908152600385016020526040812054819069d3c21bcecceda100000090859061206f9086612b5a565b6120799190612b6d565b6120839190612a89565b6001600160a01b038616600090815260038801602052604090208490559150505b949350505050565b60006119b6825490565b600061143d836001600160a01b0384166124e2565b600061143d8383612531565b6001600160a01b03808316600090815260048501602090815260408083209385168352929052908120549081900361143d576001600160a01b0383166000908152600285016020526040902060649061212f906120ac565b10612166576040517f2fee563000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b038216600090815260088501602052604090205460ff166121c5576040517fff9864e50000000000000000000000000000000000000000000000000000000081526001600160a01b038316600482015260240161045e565b83600001600081546121d690612c7f565b91829055506001600160a01b03808516600081815260048801602090815260408083209488168352938152838220859055918152600288019091522090915061221f908261255b565b506001600160a01b03821660009081526003850160205260409020612244908261255b565b506000818152600185810160205260408083209182018054600290930180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038881169182179092559088167fffffffffffff00000000000000000000000000000000000000000000000000009094168417600160a01b4265ffffffffffff160217909155905190927f26f4b31b7240e7422a9fe2ba5ce7684500302a536166d0ed481d7ad653ff25ab91a39392505050565b6000612355826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166125679092919063ffffffff16565b90508051600014806123765750808060200190518101906123769190612cb7565b61058e5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f74207375636365656400000000000000000000000000000000000000000000606482015260840161045e565b600081815260018301602052604081205480156124d157600061240c600183612b5a565b855490915060009061242090600190612b5a565b905081811461248557600086600001828154811061244057612440612b12565b906000526020600020015490508087600001848154811061246357612463612b12565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061249657612496612cd4565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506119b6565b60009150506119b6565b5092915050565b6000818152600183016020526040812054612529575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556119b6565b5060006119b6565b600082600001828154811061254857612548612b12565b9060005260206000200154905092915050565b600061143d83836124e2565b60606120a4848460008585600080866001600160a01b0316858760405161258e9190612d27565b60006040518083038185875af1925050503d80600081146125cb576040519150601f19603f3d011682016040523d82523d6000602084013e6125d0565b606091505b509150915061149c878383876060831561264b578251600003612644576001600160a01b0385163b6126445760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015260640161045e565b50816120a4565b6120a483838151156126605781518083602001fd5b8060405162461bcd60e51b815260040161045e9190612d43565b6001600160a01b03811681146110ad57600080fd5b600080604083850312156126a257600080fd5b82356126ad8161267a565b946020939093013593505050565b6000602082840312156126cd57600080fd5b813561143d8161267a565b60008151808452602080850194506020840160005b838110156127125781516001600160a01b0316875295820195908201906001016126ed565b509495945050505050565b60008151808452602080850194506020840160005b8381101561271257815165ffffffffffff1687529582019590820190600101612732565b60408152600061276960408301856126d8565b828103602084015261277b818561271d565b95945050505050565b6000806040838503121561279757600080fd5b82356127a28161267a565b915060208301356127b28161267a565b809150509250929050565b6040815260006127d060408301856126d8565b82810360208481019190915284518083528582019282019060005b81811015612807578451835293830193918301916001016127eb565b5090979650505050505050565b604080825283519082018190526000906020906060840190828701845b828110156128565781516001600160a01b031684529284019290840190600101612831565b5050508381036020850152611f73818661271d565b80151581146110ad57600080fd5b60008060006060848603121561288e57600080fd5b83356128998161267a565b925060208401356128a98161267a565b915060408401356128b98161286b565b809150509250925092565b600080600080600060a086880312156128dc57600080fd5b85356128e78161267a565b945060208601356128f78161267a565b94979496505050506040830135926060810135926080909101359150565b803565ffffffffffff8116811461292b57600080fd5b919050565b6000806000806080858703121561294657600080fd5b84356129518161267a565b93506020850135925061296660408601612915565b915061297460608601612915565b905092959194509250565b60208152600061143d60208301846126d8565b60008083601f8401126129a457600080fd5b50813567ffffffffffffffff8111156129bc57600080fd5b6020830191508360208260051b85010111156108bc57600080fd5b6000806000806000606086880312156129ef57600080fd5b85356129fa8161267a565b9450602086013567ffffffffffffffff80821115612a1757600080fd5b612a2389838a01612992565b90965094506040880135915080821115612a3c57600080fd5b50612a4988828901612992565b969995985093965092949392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600082612abf577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b65ffffffffffff8181168382160190808211156124db576124db612a5a565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600060208284031215612b5357600080fd5b5051919050565b818103818111156119b6576119b6612a5a565b80820281158282048414176119b6576119b6612a5a565b808201808211156119b6576119b6612a5a565b60008184825b85811015612bce578135612bb08161267a565b6001600160a01b031683526020928301929190910190600101612b9d565b509095945050505050565b60208082528181018390526000908460408401835b86811015612c195765ffffffffffff612c0684612915565b1682529183019190830190600101612bee565b509695505050505050565b6001600160a01b038181168382160190808211156124db576124db612a5a565b600060208284031215612c5657600080fd5b61143d82612915565b6001600160a01b038281168282160390808211156124db576124db612a5a565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612cb057612cb0612a5a565b5060010190565b600060208284031215612cc957600080fd5b815161143d8161286b565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603160045260246000fd5b60005b83811015612d1e578181015183820152602001612d06565b50506000910152565b60008251612d39818460208701612d03565b9190910192915050565b6020815260008251806020840152612d62816040850160208701612d03565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122067296dd182c1bc08332182b8a32d7058a27d9c387da1735d2f5e912941bdb99f64736f6c63430008160033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd
-----Decoded View---------------
Arg [0] : _staking (address): 0xFF551fEDdbeDC0AeE764139cCD9Cb644Bb04A6BD
-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000ff551feddbedc0aee764139ccd9cb644bb04a6bd
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 26 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 100.00% | $0.330271 | 944,242.0308 | $311,855.76 |
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.