Contract Overview
My Name Tag:
Not Available, login to update
[ Download CSV Export ]
Contract Name:
SandRewardPool
Compiler Version
v0.8.2+commit.661d1103
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../utils/Context.sol"; import "../utils/introspection/ERC165.sol"; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControl { function hasRole(bytes32 role, address account) external view returns (bool); function getRoleAdmin(bytes32 role) external view returns (bytes32); function grantRole(bytes32 role, address account) external; function revokeRole(bytes32 role, address account) external; function renounceRole(bytes32 role, address account) external; } /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControl is Context, IAccessControl, ERC165 { struct RoleData { mapping (address => bool) members; bytes32 adminRole; } mapping (bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override { require(hasRole(getRoleAdmin(role), _msgSender()), "AccessControl: sender must be an admin to grant"); _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override { require(hasRole(getRoleAdmin(role), _msgSender()), "AccessControl: sender must be an admin to revoke"); _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { emit RoleAdminChanged(role, getRoleAdmin(role), adminRole); _roles[role].adminRole = adminRole; } function _grantRole(bytes32 role, address account) private { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } function _revokeRole(bytes32 role, address account) private { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor () { _status = _NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and make it call a * `private` function that does the actual work. */ modifier nonReentrant() { // On the first call to nonReentrant, _notEntered will be true require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; _; // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @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 `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool); /** * @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); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20.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; function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); } 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' // solhint-disable-next-line max-line-length 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)); } function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 newAllowance = token.allowance(address(this), spender) + value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } 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"); uint256 newAllowance = oldAllowance - value; _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); } } /** * @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"); if (returndata.length > 0) { // Return data is optional // solhint-disable-next-line max-line-length require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 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://diligence.consensys.net/posts/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.5.11/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"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (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 functionCall(target, data, "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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(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) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(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) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // 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 // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT 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) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // solhint-disable-next-line compiler-version pragma solidity ^0.8.0; /// @dev minimal ERC2771 handler to keep bytecode-size down. /// based on: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/metatx/ERC2771Context.sol contract ERC2771Handler { address internal _trustedForwarder; function __ERC2771Handler_initialize(address forwarder) internal { _trustedForwarder = forwarder; } function isTrustedForwarder(address forwarder) public view returns (bool) { return forwarder == _trustedForwarder; } function getTrustedForwarder() external view returns (address trustedForwarder) { return _trustedForwarder; } function _msgSender() internal view virtual returns (address sender) { if (isTrustedForwarder(msg.sender)) { // The assembly code is more direct than the Solidity version using `abi.decode`. // solhint-disable-next-line no-inline-assembly assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) } } else { return msg.sender; } } function _msgData() internal view virtual returns (bytes calldata) { if (isTrustedForwarder(msg.sender)) { return msg.data[:msg.data.length - 20]; } else { return msg.data; } } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.2; import {Context} from "@openzeppelin/contracts-0.8/utils/Context.sol"; import {SafeERC20} from "@openzeppelin/contracts-0.8/token/ERC20/utils/SafeERC20.sol"; import {IERC20} from "@openzeppelin/contracts-0.8/token/ERC20/IERC20.sol"; import {ReentrancyGuard} from "@openzeppelin/contracts-0.8/security/ReentrancyGuard.sol"; import {Address} from "@openzeppelin/contracts-0.8/utils/Address.sol"; import {AccessControl} from "@openzeppelin/contracts-0.8/access/AccessControl.sol"; import {ERC2771Handler} from "../common/BaseWithStorage/ERC2771Handler.sol"; import {StakeTokenWrapper} from "./StakeTokenWrapper.sol"; import {IContributionCalculator} from "./interfaces/IContributionCalculator.sol"; import {IRewardCalculator} from "./interfaces/IRewardCalculator.sol"; /// @title A pool that distributes rewards between users that stake sand (or any erc20 token) /// @notice The contributions are updated passively, an external call to computeContribution from a backend is needed. /// @notice After initialization the reward calculator must be set by the admin. /// @dev The contract has two plugins that affect the behaviour: contributionCalculator and rewardCalculator /// @dev contributionCalculator instead of using the stake directly the result of computeContribution is used /// @dev this way some users can get an extra share of the rewards /// @dev rewardCalculator is used to manage the rate at which the rewards are distributed. /// @dev This way we can build different types of pools by mixing in the plugins we want with this contract. /// @dev default behaviour (address(0)) for contributionCalculator is to use the stacked amount as contribution. /// @dev default behaviour (address(0)) for rewardCalculator is that no rewards are giving contract SandRewardPool is StakeTokenWrapper, AccessControl, ReentrancyGuard, ERC2771Handler { using SafeERC20 for IERC20; using Address for address; event Staked(address indexed account, uint256 stakeAmount); event Withdrawn(address indexed account, uint256 stakeAmount); event Exit(address indexed account); event RewardPaid(address indexed account, uint256 rewardAmount); event ContributionUpdated(address indexed account, uint256 newContribution, uint256 oldContribution); // This value multiplied by the user contribution is the share of accumulated rewards (from the start of time // until the last call to restartRewards) for the user taking into account the value of totalContributions. uint256 public rewardPerTokenStored; // This value multiplied by the user contribution is the share of reward from the the last time // the user changed his contribution and called restartRewards mapping(address => uint256) public userRewardPerTokenPaid; // This value is the accumulated rewards won by the user when he called the contract. mapping(address => uint256) public rewards; IERC20 public rewardToken; IContributionCalculator public contributionCalculator; IRewardCalculator public rewardCalculator; uint256 internal _totalContributions; mapping(address => uint256) internal _contributions; struct AntiCompound { uint256 lockPeriodInSecs; mapping(address => uint256) lastClaim; } // This is used to implement a time buffer for reward retrieval, so the used cannot re-stake the rewards too fast. AntiCompound public antiCompound; constructor( IERC20 stakeToken_, IERC20 rewardToken_, address trustedForwarder ) StakeTokenWrapper(stakeToken_) { rewardToken = rewardToken_; _setupRole(DEFAULT_ADMIN_ROLE, _msgSender()); __ERC2771Handler_initialize(trustedForwarder); } modifier antiCompoundCheck(address account) { // We use lockPeriodInSecs == 0 to disable this check if (antiCompound.lockPeriodInSecs != 0) { require( block.timestamp > antiCompound.lastClaim[account] + antiCompound.lockPeriodInSecs, "SandRewardPool: must wait" ); } antiCompound.lastClaim[account] = block.timestamp; _; } modifier isContractAndAdmin(address contractAddress) { require(contractAddress.isContract(), "SandRewardPool: not a contract"); require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "SandRewardPool: not admin"); _; } /// @notice set the lockPeriodInSecs for the anti-compound buffer /// @param lockPeriodInSecs amount of time the user must wait between reward withdrawal function setAntiCompoundLockPeriod(uint256 lockPeriodInSecs) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "SandRewardPool: not admin"); antiCompound.lockPeriodInSecs = lockPeriodInSecs; } /// @notice set the contribution calculator /// @param contractAddress address of a plugin that calculates the contribution of the user based on his stake function setContributionCalculator(address contractAddress) external isContractAndAdmin(contractAddress) { contributionCalculator = IContributionCalculator(contractAddress); } /// @notice set the reward token /// @param contractAddress address token used to pay rewards function setRewardToken(address contractAddress) external isContractAndAdmin(contractAddress) { rewardToken = IERC20(contractAddress); } /// @notice set the stake token /// @param contractAddress address token used to stake funds function setStakeToken(address contractAddress) external isContractAndAdmin(contractAddress) { _stakeToken = IERC20(contractAddress); } /// @notice set the trusted forwarder /// @param trustedForwarder address of the contract that is enabled to send meta-tx on behalf of the user function setTrustedForwarder(address trustedForwarder) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "SandRewardPool: not admin"); _trustedForwarder = trustedForwarder; } /// @notice set the reward calculator /// @param contractAddress address of a plugin that calculates absolute rewards at any point in time /// @param restartRewards if true the rewards from the previous calculator are accumulated before changing it function setRewardCalculator(address contractAddress, bool restartRewards) external isContractAndAdmin(contractAddress) { // We process the rewards of the current reward calculator before the switch. if (restartRewards) { _restartRewards(); } rewardCalculator = IRewardCalculator(contractAddress); } /// @notice the admin recover is able to recover reward funds /// @param receiver address of the beneficiary of the recovered funds /// @dev this function must be called in an emergency situation only. /// @dev Calling it is risky specially when rewardToken == stakeToken function recoverFunds(address receiver) external { require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "SandRewardPool: not admin"); require(receiver != address(0), "SandRewardPool: invalid receiver"); rewardToken.safeTransfer(receiver, rewardToken.balanceOf(address(this))); } /// @notice return the total supply of staked tokens /// @return the total supply of staked tokens function totalSupply() external view returns (uint256) { return _totalSupply; } /// @notice return the balance of staked tokens for a user /// @param account the address of the account /// @return balance of staked tokens function balanceOf(address account) external view returns (uint256) { return _balances[account]; } /// @notice return the address of the stake token contract /// @return address of the stake token contract function stakeToken() external view returns (IERC20) { return _stakeToken; } /// @notice return the amount of rewards deposited in the contract that can be distributed by different campaigns /// @return the total amount of deposited rewards /// @dev this function can be called by a reward calculator to throw if a campaign doesn't have /// @dev enough rewards to start function getRewardsAvailable() external view returns (uint256) { if (address(rewardToken) != address(_stakeToken)) { return rewardToken.balanceOf(address(this)); } return _stakeToken.balanceOf(address(this)) - _totalSupply; } /// @notice return the sum of the values returned by the contribution calculator /// @return total contributions of the users /// @dev this is the same than the totalSupply only if the contribution calculator /// @dev uses the staked amount as the contribution of the user which is the default behaviour function totalContributions() external view returns (uint256) { return _totalContributions; } /// @notice return the contribution of some user /// @param account the address of the account /// @return contribution of the users /// @dev this is the same than the balanceOf only if the contribution calculator /// @dev uses the staked amount as the contribution of the user which is the default behaviour function contributionOf(address account) external view returns (uint256) { return _contributions[account]; } /// @notice accumulated rewards taking into account the totalContribution (see: rewardPerTokenStored) /// @return the accumulated total rewards /// @dev This value multiplied by the user contribution is the share of accumulated rewards for the user. Taking /// @dev into account the value of totalContributions. function rewardPerToken() external view returns (uint256) { return rewardPerTokenStored + _rewardPerToken(); } /// @notice available earnings for some user /// @param account the address of the account /// @return the available earnings for the user function earned(address account) external view returns (uint256) { return rewards[account] + _earned(account, _rewardPerToken()); } /// @notice accumulates the current rewards into rewardPerTokenStored and restart the reward calculator /// @dev calling this function make no difference. It is useful for testing and when the reward calculator /// @dev is changed. function restartRewards() external { _restartRewards(); } /// @notice update the contribution for a user /// @param account the address of the account /// @dev if the user change his holdings (or any other parameter that affect the contribution calculation), /// @dev he can the reward distribution to his favor. This function must be called by an external agent ASAP to /// @dev update the contribution for the user. We understand the risk but the rewards are distributes slowly so /// @dev the user cannot affect the reward distribution heavily. function computeContribution(address account) external { require(account != address(0), "SandRewardPool: invalid address"); // We decide to give the user the accumulated rewards even if he cheated a little bit. _processRewards(account); _updateContribution(account); } /// @notice update the contribution for a sef of users /// @param accounts the addresses of the accounts to update /// @dev see: computeContribution function computeContributionInBatch(address[] calldata accounts) external { _restartRewards(); for (uint256 i = 0; i < accounts.length; i++) { address account = accounts[i]; if (account == address(0)) { continue; } _processAccountRewards(account); _updateContribution(account); } } /// @notice stake some amount into the contract /// @param amount the amount of tokens to stake /// @dev the user must approve in the stack token before calling this function function stake(uint256 amount) external nonReentrant { require(amount > 0, "SandRewardPool: Cannot stake 0"); // The first time a user stakes he cannot remove his rewards immediately. if (antiCompound.lastClaim[_msgSender()] == 0) { antiCompound.lastClaim[_msgSender()] = block.timestamp; } uint256 earlierRewards = 0; if (_totalContributions == 0 && rewardCalculator != IRewardCalculator(address(0))) { earlierRewards = rewardCalculator.getRewards(); } _processRewards(_msgSender()); super._stake(amount); _updateContribution(_msgSender()); require(_contributions[_msgSender()] > 0, "SandRewardPool: not enough contributions"); if (earlierRewards != 0) { rewards[_msgSender()] = rewards[_msgSender()] + earlierRewards; } emit Staked(_msgSender(), amount); } /// @notice withdraw the stake from the contract /// @param amount the amount of tokens to withdraw /// @dev the user can withdraw his stake independently from the rewards function withdraw(uint256 amount) external nonReentrant { _processRewards(_msgSender()); _withdrawStake(_msgSender(), amount); _updateContribution(_msgSender()); } /// @notice withdraw the stake and the rewards from the contract function exit() external nonReentrant { _processRewards(_msgSender()); _withdrawStake(_msgSender(), _balances[_msgSender()]); _withdrawRewards(_msgSender()); _updateContribution(_msgSender()); emit Exit(_msgSender()); } /// @notice withdraw the rewards from the contract /// @dev the user can withdraw his stake independently from the rewards function getReward() external nonReentrant { _processRewards(_msgSender()); _withdrawRewards(_msgSender()); _updateContribution(_msgSender()); } function _withdrawStake(address account, uint256 amount) internal { require(amount > 0, "SandRewardPool: Cannot withdraw 0"); super._withdraw(amount); emit Withdrawn(account, amount); } function _withdrawRewards(address account) internal antiCompoundCheck(account) { uint256 reward = rewards[account]; if (reward > 0) { rewards[account] = 0; rewardToken.safeTransfer(account, reward); emit RewardPaid(account, reward); } } function _updateContribution(address account) internal { uint256 oldContribution = _contributions[account]; _totalContributions = _totalContributions - oldContribution; uint256 contribution = _computeContribution(account); _totalContributions = _totalContributions + contribution; _contributions[account] = contribution; emit ContributionUpdated(account, contribution, oldContribution); } function _computeContribution(address account) internal returns (uint256) { if (contributionCalculator == IContributionCalculator(address(0))) { return _balances[account]; } else { return contributionCalculator.computeContribution(account, _balances[account]); } } // Something changed (stake, withdraw, etc), we distribute current accumulated rewards and start from zero. // Called each time there is a change in contract state (stake, withdraw, etc). function _processRewards(address account) internal { _restartRewards(); _processAccountRewards(account); } // Update the earnings for this specific user with what he earned until now function _processAccountRewards(address account) internal { // usually _earned takes _rewardPerToken() but in this method is zero because _restartRewards must be // called before _processAccountRewards rewards[account] = rewards[account] + _earned(account, 0); // restart rewards for this specific user, now earned(account) = 0 userRewardPerTokenPaid[account] = rewardPerTokenStored; } function _restartRewards() internal { if (rewardCalculator != IRewardCalculator(address(0))) { // Distribute the accumulated rewards rewardPerTokenStored = rewardPerTokenStored + _rewardPerToken(); // restart rewards so now the rewardCalculator return zero rewards rewardCalculator.restartRewards(); } } function _earned(address account, uint256 rewardPerToken) internal view returns (uint256) { // - userRewardPerTokenPaid[account] * _contributions[account] / _totalContributions is the portion of // rewards the last time the user changed his contribution and called _restartRewards // (_totalContributions corresponds to previous value of that moment). // - rewardPerTokenStored * _contributions[account] is the share of the user from the // accumulated rewards (from the start of time until the last call to _restartRewards) with the // current value of _totalContributions // - _rewardPerToken() * _contributions[account] / _totalContributions is the share of the user of the // rewards from the last time anybody called _restartRewards until this moment // // The important thing to note is that at any moment in time _contributions[account] / _totalContributions is // the share of the user even if _totalContributions changes because of other users activity. return ((rewardPerToken + rewardPerTokenStored - userRewardPerTokenPaid[account]) * _contributions[account]) / 1e24; } // This function gives the proportion of the total contribution that corresponds to each user from // last restartRewards call. // _rewardsPerToken() * _contributions[account] is the amount of extra rewards gained from last restartRewards. function _rewardPerToken() internal view returns (uint256) { if (rewardCalculator == IRewardCalculator(address(0)) || _totalContributions == 0) { return 0; } return (rewardCalculator.getRewards() * 1e24) / _totalContributions; } function _msgSender() internal view override(Context, ERC2771Handler) returns (address sender) { return ERC2771Handler._msgSender(); } function _msgData() internal view override(Context, ERC2771Handler) returns (bytes calldata) { return ERC2771Handler._msgData(); } }
//SPDX-License-Identifier: MIT pragma solidity 0.8.2; import "@openzeppelin/contracts-0.8/utils/Context.sol"; import "@openzeppelin/contracts-0.8/token/ERC20/utils/SafeERC20.sol"; abstract contract StakeTokenWrapper is Context { using SafeERC20 for IERC20; IERC20 internal _stakeToken; uint256 internal _totalSupply; mapping(address => uint256) internal _balances; constructor(IERC20 stakeToken) { _stakeToken = stakeToken; } function _stake(uint256 amount) internal virtual { _totalSupply = _totalSupply + amount; _balances[_msgSender()] = _balances[_msgSender()] + amount; _stakeToken.safeTransferFrom(_msgSender(), address(this), amount); } function _withdraw(uint256 amount) internal virtual { _totalSupply = _totalSupply - amount; _balances[_msgSender()] = _balances[_msgSender()] - amount; _stakeToken.safeTransfer(_msgSender(), amount); } uint256[50] private __gap; }
//SPDX-License-Identifier: MIT pragma solidity 0.8.2; /// @title Plugins for the SandRewardPool that calculate the contributions must implement this interface interface IContributionCalculator { /// @notice based on the user stake and address calculate the contribution /// @param account address of the user that is staking tokens /// @param amountStaked the amount of tokens stacked function computeContribution(address account, uint256 amountStaked) external returns (uint256); }
//SPDX-License-Identifier: MIT pragma solidity 0.8.2; /// @title Plugins for the SandRewardPool that calculate the rewards must implement this interface interface IRewardCalculator { /// @dev At any point in time this function must return the accumulated rewards from the last call to restartRewards function getRewards() external view returns (uint256); /// @dev The main contract has distributed the rewards (getRewards()) until this point, this must start /// @dev from scratch => getRewards() == 0 function restartRewards() external; }
{ "evmVersion": "istanbul", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 2000 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"contract IERC20","name":"stakeToken_","type":"address"},{"internalType":"contract IERC20","name":"rewardToken_","type":"address"},{"internalType":"address","name":"trustedForwarder","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"newContribution","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldContribution","type":"uint256"}],"name":"ContributionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"Exit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"rewardAmount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"stakeAmount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"stakeAmount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"antiCompound","outputs":[{"internalType":"uint256","name":"lockPeriodInSecs","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"computeContribution","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"}],"name":"computeContributionInBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"contributionCalculator","outputs":[{"internalType":"contract IContributionCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"contributionOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardsAvailable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTrustedForwarder","outputs":[{"internalType":"address","name":"trustedForwarder","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"forwarder","type":"address"}],"name":"isTrustedForwarder","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"recoverFunds","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"restartRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardCalculator","outputs":[{"internalType":"contract IRewardCalculator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"lockPeriodInSecs","type":"uint256"}],"name":"setAntiCompoundLockPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"setContributionCalculator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"},{"internalType":"bool","name":"restartRewards","type":"bool"}],"name":"setRewardCalculator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"setRewardToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"contractAddress","type":"address"}],"name":"setStakeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"trustedForwarder","type":"address"}],"name":"setTrustedForwarder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalContributions","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60806040523480156200001157600080fd5b5060405162002657380380620026578339810160408190526200003491620001a0565b600080546001600160a01b038086166001600160a01b03199283161783556001603655603b8054918616919092161790556200007a90620000746200009e565b620000bb565b603780546001600160a01b0319166001600160a01b0383161790555050506200020c565b6000620000b5620000cb60201b620015891760201c565b90505b90565b620000c78282620000fa565b5050565b6037546000906001600160a01b0316331415620000f2575060131936013560601c620000b8565b5033620000b8565b60008281526035602090815260408083206001600160a01b038516845290915290205460ff16620000c75760008281526035602090815260408083206001600160a01b03851684529091529020805460ff191660011790556200015c6200009e565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600080600060608486031215620001b5578283fd5b8351620001c281620001f3565b6020850151909350620001d581620001f3565b6040850151909250620001e881620001f3565b809150509250925092565b6001600160a01b03811681146200020957600080fd5b50565b61243b806200021c6000396000f3fe608060405234801561001057600080fd5b50600436106102915760003560e01c806391d1485411610160578063d547741f116100d8578063dfeb94391161008c578063e9fad8ee11610071578063e9fad8ee1461058f578063f7c618c114610597578063ff9b110b146105aa57610291565b8063dfeb943914610569578063e72f6e301461057c57610291565b8063d7805ece116100bd578063d7805ece14610524578063da7422281461054d578063df136d651461056057610291565b8063d547741f146104fe578063d64791f81461051157610291565b8063accb04bd1161012f578063bfbe13d511610114578063bfbe13d5146104db578063cd3daf9d146104e5578063ce1b815f146104ed57610291565b8063accb04bd146104c0578063b0165840146104d357610291565b806391d148541461045957806396769e8914610492578063a217fddf146104a5578063a694fc3a146104ad57610291565b806337c089231161020e5780635ae64bd8116101c257806370a08231116101a757806370a08231146103fd5780638aee8127146104265780638b8763471461043957610291565b80635ae64bd8146103e25780635c22f2bc146103ea57610291565b806351ed6a30116101f357806351ed6a3014610388578063534d8499146103ad578063572b6c05146103c057610291565b806337c08923146103785780633d18b9121461038057610291565b806318160ddd116102655780632e1a7d4d1161024a5780632e1a7d4d1461033f5780632f2ff15d1461035257806336568abe1461036557610291565b806318160ddd14610314578063248a9ca31461031c57610291565b80628cc2621461029657806301ffc9a7146102bc5780630397d458146102df5780630700037d146102f4575b600080fd5b6102a96102a4366004612167565b6105bd565b6040519081526020015b60405180910390f35b6102cf6102ca366004612285565b6105fb565b60405190151581526020016102b3565b6102f26102ed366004612167565b610692565b005b6102a9610302366004612167565b603a6020526000908152604090205481565b6102a9610778565b6102a961032a366004612242565b60009081526035602052604090206001015490565b6102f261034d366004612242565b61077f565b6102f261036036600461225a565b610810565b6102f261037336600461225a565b6108af565b603e546102a9565b6102f2610947565b6000546001600160a01b03165b6040516001600160a01b0390911681526020016102b3565b603c54610395906001600160a01b031681565b6102cf6103ce366004612167565b6037546001600160a01b0390811691161490565b6102a96109cc565b6102f26103f8366004612167565b610af4565b6102a961040b366004612167565b6001600160a01b031660009081526002602052604090205490565b6102f2610434366004612167565b610bd5565b6102a9610447366004612167565b60396020526000908152604090205481565b6102cf61046736600461225a565b60009182526035602090815260408084206001600160a01b0393909316845291905290205460ff1690565b603d54610395906001600160a01b031681565b6102a9600081565b6102f26104bb366004612242565b610cb6565b6102f26104ce366004612181565b610fd2565b6102f26110c2565b6040546102a99081565b6102a96110cc565b6037546001600160a01b0316610395565b6102f261050c36600461225a565b6110e3565b6102f261051f3660046121b7565b611170565b6102a9610532366004612167565b6001600160a01b03166000908152603f602052604090205490565b6102f261055b366004612167565b6111fb565b6102a960385481565b6102f2610577366004612167565b611283565b6102f261058a366004612167565b6112ee565b6102f2611431565b603b54610395906001600160a01b031681565b6102f26105b8366004612242565b61152b565b60006105d0826105cb6115d3565b6116a2565b6001600160a01b0383166000908152603a60205260409020546105f3919061232c565b90505b919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b0000000000000000000000000000000000000000000000000000000014806105f357507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316146105f3565b806001600160a01b0381163b6106ef5760405162461bcd60e51b815260206004820152601e60248201527f53616e64526577617264506f6f6c3a206e6f74206120636f6e7472616374000060448201526064015b60405180910390fd5b6106fc6000610467611706565b6107485760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b506000805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6001545b90565b600260365414156107d25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106e6565b60026036556107e76107e2611706565b611710565b6107f86107f2611706565b82611721565b610808610803611706565b6117e7565b506001603655565b60008281526035602052604090206001015461082f905b610467611706565b6108a15760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201527f2061646d696e20746f206772616e74000000000000000000000000000000000060648201526084016106e6565b6108ab828261188a565b5050565b6108b7611706565b6001600160a01b0316816001600160a01b03161461093d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c66000000000000000000000000000000000060648201526084016106e6565b6108ab828261192d565b6002603654141561099a5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106e6565b60026036556109aa6107e2611706565b6109ba6109b5611706565b6119ce565b6109c5610803611706565b6001603655565b60008054603b546001600160a01b03908116911614610a6757603b546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015610a2857600080fd5b505afa158015610a3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a6091906122c5565b905061077c565b6001546000546040516370a0823160e01b81523060048201526001600160a01b03909116906370a082319060240160206040518083038186803b158015610aad57600080fd5b505afa158015610ac1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae591906122c5565b610aef9190612383565b905090565b806001600160a01b0381163b610b4c5760405162461bcd60e51b815260206004820152601e60248201527f53616e64526577617264506f6f6c3a206e6f74206120636f6e7472616374000060448201526064016106e6565b610b596000610467611706565b610ba55760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b50603c805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b806001600160a01b0381163b610c2d5760405162461bcd60e51b815260206004820152601e60248201527f53616e64526577617264506f6f6c3a206e6f74206120636f6e7472616374000060448201526064016106e6565b610c3a6000610467611706565b610c865760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b50603b805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b60026036541415610d095760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106e6565b600260365580610d5b5760405162461bcd60e51b815260206004820152601e60248201527f53616e64526577617264506f6f6c3a2043616e6e6f74207374616b652030000060448201526064016106e6565b60416000610d67611706565b6001600160a01b03168152602081019190915260400160002054610dad574260416000610d92611706565b6001600160a01b031681526020810191909152604001600020555b6000603e546000148015610dcb5750603d546001600160a01b031615155b15610e5957603d60009054906101000a90046001600160a01b03166001600160a01b0316630572b0cc6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e1e57600080fd5b505afa158015610e32573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e5691906122c5565b90505b610e646107e2611706565b610e6d82611ae1565b610e78610803611706565b6000603f6000610e86611706565b6001600160a01b03166001600160a01b031681526020019081526020016000205411610f1a5760405162461bcd60e51b815260206004820152602860248201527f53616e64526577617264506f6f6c3a206e6f7420656e6f75676820636f6e747260448201527f69627574696f6e7300000000000000000000000000000000000000000000000060648201526084016106e6565b8015610f7f5780603a6000610f2d611706565b6001600160a01b03166001600160a01b0316815260200190815260200160002054610f58919061232c565b603a6000610f64611706565b6001600160a01b031681526020810191909152604001600020555b610f87611706565b6001600160a01b03167f9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d83604051610fc191815260200190565b60405180910390a250506001603655565b816001600160a01b0381163b61102a5760405162461bcd60e51b815260206004820152601e60248201527f53616e64526577617264506f6f6c3a206e6f74206120636f6e7472616374000060448201526064016106e6565b6110376000610467611706565b6110835760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b811561109157611091611b6f565b5050603d805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6110ca611b6f565b565b60006110d66115d3565b603854610aef919061232c565b6000828152603560205260409020600101546110fe90610827565b61093d5760405162461bcd60e51b815260206004820152603060248201527f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60448201527f2061646d696e20746f207265766f6b650000000000000000000000000000000060648201526084016106e6565b611178611b6f565b60005b818110156111f65760008383838181106111a557634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111ba9190612167565b90506001600160a01b0381166111d057506111e4565b6111d981611c11565b6111e2816117e7565b505b806111ee816123c6565b91505061117b565b505050565b6112086000610467611706565b6112545760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b6037805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6001600160a01b0381166112d95760405162461bcd60e51b815260206004820152601f60248201527f53616e64526577617264506f6f6c3a20696e76616c696420616464726573730060448201526064016106e6565b6112e281611710565b6112eb816117e7565b50565b6112fb6000610467611706565b6113475760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b6001600160a01b03811661139d5760405162461bcd60e51b815260206004820181905260248201527f53616e64526577617264506f6f6c3a20696e76616c696420726563656976657260448201526064016106e6565b603b546040516370a0823160e01b81523060048201526112eb9183916001600160a01b03909116906370a082319060240160206040518083038186803b1580156113e657600080fd5b505afa1580156113fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061141e91906122c5565b603b546001600160a01b03169190611c6d565b600260365414156114845760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016106e6565b60026036556114946107e2611706565b6114d161149f611706565b600260006114ab611706565b6001600160a01b03166001600160a01b0316815260200190815260200160002054611721565b6114dc6109b5611706565b6114e7610803611706565b6114ef611706565b6001600160a01b03167f7c79e6e24ed041d1072d54523b53956f01b91b835f0490856370594d9d14470e60405160405180910390a26001603655565b6115386000610467611706565b6115845760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206e6f742061646d696e0000000000000060448201526064016106e6565b604055565b6037546000906001600160a01b03163314156115cc57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec36013560601c61077c565b503361077c565b603d546000906001600160a01b031615806115ee5750603e54155b156115fb5750600061077c565b603e54603d60009054906101000a90046001600160a01b03166001600160a01b0316630572b0cc6040518163ffffffff1660e01b815260040160206040518083038186803b15801561164c57600080fd5b505afa158015611660573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061168491906122c5565b6116989069d3c21bcecceda1000000612364565b610aef9190612344565b6001600160a01b0382166000908152603f6020908152604080832054603990925282205460385469d3c21bcecceda10000009291906116e1908661232c565b6116eb9190612383565b6116f59190612364565b6116ff9190612344565b9392505050565b6000610aef611589565b611718611b6f565b6112eb81611c11565b600081116117975760405162461bcd60e51b815260206004820152602160248201527f53616e64526577617264506f6f6c3a2043616e6e6f742077697468647261772060448201527f300000000000000000000000000000000000000000000000000000000000000060648201526084016106e6565b6117a081611d16565b816001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5826040516117db91815260200190565b60405180910390a25050565b6001600160a01b0381166000908152603f6020526040902054603e5461180e908290612383565b603e55600061181c83611da3565b905080603e5461182c919061232c565b603e556001600160a01b0383166000818152603f602090815260409182902084905581518481529081018590527f36c7c98dfe7e045d8de3e3a8ef7280d623eeb82e7ac5f92d4854297dd078130591015b60405180910390a2505050565b60008281526035602090815260408083206001600160a01b038516845290915290205460ff166108ab5760008281526035602090815260408083206001600160a01b03851684529091529020805460ff191660011790556118e9611706565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526035602090815260408083206001600160a01b038516845290915290205460ff16156108ab5760008281526035602090815260408083206001600160a01b03851684529091529020805460ff1916905561198a611706565b6001600160a01b0316816001600160a01b0316837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b604054819015611a4d57604080546001600160a01b0383166000908152604160205291909120546119ff919061232c565b4211611a4d5760405162461bcd60e51b815260206004820152601960248201527f53616e64526577617264506f6f6c3a206d75737420776169740000000000000060448201526064016106e6565b6001600160a01b0380821660009081526041602090815260408083204290559285168252603a9052205480156111f6576001600160a01b038084166000908152603a6020526040812055603b54611aa691168483611c6d565b826001600160a01b03167fe2403640ba68fed3a2f88b7557551d1993f84b99bb10ff833f0cf8db0c5e04868260405161187d91815260200190565b80600154611aef919061232c565b6001558060026000611aff611706565b6001600160a01b03166001600160a01b0316815260200190815260200160002054611b2a919061232c565b60026000611b36611706565b6001600160a01b031681526020810191909152604001600020556112eb611b5b611706565b6000546001600160a01b0316903084611e8b565b603d546001600160a01b0316156110ca57611b886115d3565b603854611b95919061232c565b603855603d54604080517fb016584000000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169163b01658409160048082019260009290919082900301818387803b158015611bf757600080fd5b505af1158015611c0b573d6000803e3d6000fd5b50505050565b611c1c8160006116a2565b6001600160a01b0382166000908152603a6020526040902054611c3f919061232c565b6001600160a01b039091166000908152603a6020908152604080832093909355603854603990915291902055565b6040516001600160a01b0383166024820152604481018290526111f69084907fa9059cbb00000000000000000000000000000000000000000000000000000000906064015b60408051601f198184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152611edc565b80600154611d249190612383565b6001558060026000611d34611706565b6001600160a01b03166001600160a01b0316815260200190815260200160002054611d5f9190612383565b60026000611d6b611706565b6001600160a01b031681526020810191909152604001600020556112eb611d90611706565b6000546001600160a01b03169083611c6d565b603c546000906001600160a01b0316611dd557506001600160a01b0381166000908152600260205260409020546105f6565b603c546001600160a01b03838116600081815260026020526040908190205490517f968b84e50000000000000000000000000000000000000000000000000000000081526004810192909252602482015291169063968b84e590604401602060405180830381600087803b158015611e4c57600080fd5b505af1158015611e60573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e8491906122c5565b90506105f6565b6040516001600160a01b0380851660248301528316604482015260648101829052611c0b9085907f23b872dd0000000000000000000000000000000000000000000000000000000090608401611cb2565b6000611f31826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316611fc19092919063ffffffff16565b8051909150156111f65780806020019051810190611f4f9190612226565b6111f65760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016106e6565b6060611fd08484600085611fd8565b949350505050565b6060824710156120505760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016106e6565b843b61209e5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016106e6565b600080866001600160a01b031685876040516120ba91906122dd565b60006040518083038185875af1925050503d80600081146120f7576040519150601f19603f3d011682016040523d82523d6000602084013e6120fc565b606091505b509150915061210c828286612117565b979650505050505050565b606083156121265750816116ff565b8251156121365782518084602001fd5b8160405162461bcd60e51b81526004016106e691906122f9565b80356001600160a01b03811681146105f657600080fd5b600060208284031215612178578081fd5b6116ff82612150565b60008060408385031215612193578081fd5b61219c83612150565b915060208301356121ac816123f7565b809150509250929050565b600080602083850312156121c9578182fd5b823567ffffffffffffffff808211156121e0578384fd5b818501915085601f8301126121f3578384fd5b813581811115612201578485fd5b8660208083028501011115612214578485fd5b60209290920196919550909350505050565b600060208284031215612237578081fd5b81516116ff816123f7565b600060208284031215612253578081fd5b5035919050565b6000806040838503121561226c578182fd5b8235915061227c60208401612150565b90509250929050565b600060208284031215612296578081fd5b81357fffffffff00000000000000000000000000000000000000000000000000000000811681146116ff578182fd5b6000602082840312156122d6578081fd5b5051919050565b600082516122ef81846020870161239a565b9190910192915050565b600060208252825180602084015261231881604085016020870161239a565b601f01601f19169190910160400192915050565b6000821982111561233f5761233f6123e1565b500190565b60008261235f57634e487b7160e01b81526012600452602481fd5b500490565b600081600019048311821515161561237e5761237e6123e1565b500290565b600082821015612395576123956123e1565b500390565b60005b838110156123b557818101518382015260200161239d565b83811115611c0b5750506000910152565b60006000198214156123da576123da6123e1565b5060010190565b634e487b7160e01b600052601160045260246000fd5b80151581146112eb57600080fdfea2646970667358221220a299d285ce0a8677e7bf299e51dcef0ab19e69ec79fe53fa521f1896a356c7db64736f6c63430008020033000000000000000000000000bbba073c31bf03b8acf7c28ef0738decf3695683000000000000000000000000bbba073c31bf03b8acf7c28ef0738decf369568300000000000000000000000086c80a8aa58e0a4fa09a69624c31ab2a6cad56b8
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000bbba073c31bf03b8acf7c28ef0738decf3695683000000000000000000000000bbba073c31bf03b8acf7c28ef0738decf369568300000000000000000000000086c80a8aa58e0a4fa09a69624c31ab2a6cad56b8
-----Decoded View---------------
Arg [0] : stakeToken_ (address): 0xbbba073c31bf03b8acf7c28ef0738decf3695683
Arg [1] : rewardToken_ (address): 0xbbba073c31bf03b8acf7c28ef0738decf3695683
Arg [2] : trustedForwarder (address): 0x86c80a8aa58e0a4fa09a69624c31ab2a6cad56b8
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 000000000000000000000000bbba073c31bf03b8acf7c28ef0738decf3695683
Arg [1] : 000000000000000000000000bbba073c31bf03b8acf7c28ef0738decf3695683
Arg [2] : 00000000000000000000000086c80a8aa58e0a4fa09a69624c31ab2a6cad56b8
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.