Overview
ETH Balance
0 ETH
Eth Value
$0.00More Info
Private Name Tags
ContractCreator
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Method | Block |
From
|
To
|
|||
---|---|---|---|---|---|---|---|
- | 11514212 | 1540 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Name:
RewardManager
Compiler Version
v0.7.4+commit.3f05b770
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// Copyright 2020 Cartesi Pte. Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software distributed // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR // CONDITIONS OF ANY KIND, either express or implied. See the License for the // specific language governing permissions and limitations under the License. /// @title RewardManager /// @author Felipe Argento pragma solidity ^0.7.0; import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract RewardManager { using SafeMath for uint256; uint256 minReward; uint256 maxReward; uint256 distNumerator; uint256 distDenominator; address operator; IERC20 ctsi; /// @notice Creates contract /// @param _operator address of the operator /// @param _ctsiAddress address of token instance being used /// @param _maxReward maximum reward that this contract pays /// @param _minReward minimum reward that this contract pays /// @param _distNumerator multiplier factor to define reward amount /// @param _distDenominator dividing factor to define reward amount constructor( address _operator, address _ctsiAddress, uint256 _maxReward, uint256 _minReward, uint256 _distNumerator, uint256 _distDenominator ) { operator = _operator; ctsi = IERC20(_ctsiAddress); minReward = _minReward; maxReward = _maxReward; distNumerator = _distNumerator; distDenominator = _distDenominator; } /// @notice Rewards address /// @param _address address be rewarded /// @param _amount reward /// @dev only the pos contract can call this function reward(address _address, uint256 _amount) public { require(msg.sender == operator, "Only the operator contract can call this function"); ctsi.transfer(_address, _amount); } /// @notice Get RewardManager's balance function getBalance() public view returns (uint256) { return ctsi.balanceOf(address(this)); } /// @notice Get current reward amount function getCurrentReward() public view returns (uint256) { uint256 cReward = (getBalance().mul(distNumerator)).div(distDenominator); cReward = cReward > minReward? cReward : minReward; cReward = cReward > maxReward? maxReward : cReward; return cReward > getBalance()? getBalance() : cReward; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.7.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); }
{ "optimizer": { "enabled": true, "runs": 200 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "abi" ] } }, "metadata": { "useLiteralContent": true }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_ctsiAddress","type":"address"},{"internalType":"uint256","name":"_maxReward","type":"uint256"},{"internalType":"uint256","name":"_minReward","type":"uint256"},{"internalType":"uint256","name":"_distNumerator","type":"uint256"},{"internalType":"uint256","name":"_distDenominator","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"getBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"reward","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b506040516104bc3803806104bc833981810160405260c081101561003357600080fd5b508051602082015160408301516060840151608085015160a090950151600480546001600160a01b039687166001600160a01b031991821617909155600580549690951695169490941790925560009190915560015560029190915560035561041b806100a16000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c806312065fe01461004657806321670f22146100605780638aec85421461008e575b600080fd5b61004e610096565b60408051918252519081900360200190f35b61008c6004803603604081101561007657600080fd5b506001600160a01b038135169060200135610112565b005b61004e6101e1565b600554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156100e157600080fd5b505afa1580156100f5573d6000803e3d6000fd5b505050506040513d602081101561010b57600080fd5b5051905090565b6004546001600160a01b0316331461015b5760405162461bcd60e51b81526004018080602001828103825260318152602001806103946031913960400191505060405180910390fd5b6005546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156101b157600080fd5b505af11580156101c5573d6000803e3d6000fd5b505050506040513d60208110156101db57600080fd5b50505050565b6000806102046003546101fe6002546101f8610096565b90610252565b906102b4565b9050600054811161021757600054610219565b805b9050600154811161022a578061022e565b6001545b9050610238610096565b8111610244578061024c565b61024c610096565b91505090565b600082610261575060006102ae565b8282028284828161026e57fe5b04146102ab5760405162461bcd60e51b81526004018080602001828103825260218152602001806103c56021913960400191505060405180910390fd5b90505b92915050565b60006102ab83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506000818361037d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561034257818101518382015260200161032a565b50505050905090810190601f16801561036f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161038957fe5b049594505050505056fe4f6e6c7920746865206f70657261746f7220636f6e74726163742063616e2063616c6c20746869732066756e6374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220773ca5f35ea4a5be7610919e02be78171a9f2a626d2a3cef292278cb9bd677d764736f6c63430007040033000000000000000000000000d25f2624fc00966fdab3141a5d4205bf5df9aed3000000000000000000000000491604c0fdf08347dd1fa4ee062a822a5dd06b5d00000000000000000000000000000000000000000000009d3595ab2438d000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000002710
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100415760003560e01c806312065fe01461004657806321670f22146100605780638aec85421461008e575b600080fd5b61004e610096565b60408051918252519081900360200190f35b61008c6004803603604081101561007657600080fd5b506001600160a01b038135169060200135610112565b005b61004e6101e1565b600554604080516370a0823160e01b815230600482015290516000926001600160a01b0316916370a08231916024808301926020929190829003018186803b1580156100e157600080fd5b505afa1580156100f5573d6000803e3d6000fd5b505050506040513d602081101561010b57600080fd5b5051905090565b6004546001600160a01b0316331461015b5760405162461bcd60e51b81526004018080602001828103825260318152602001806103946031913960400191505060405180910390fd5b6005546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156101b157600080fd5b505af11580156101c5573d6000803e3d6000fd5b505050506040513d60208110156101db57600080fd5b50505050565b6000806102046003546101fe6002546101f8610096565b90610252565b906102b4565b9050600054811161021757600054610219565b805b9050600154811161022a578061022e565b6001545b9050610238610096565b8111610244578061024c565b61024c610096565b91505090565b600082610261575060006102ae565b8282028284828161026e57fe5b04146102ab5760405162461bcd60e51b81526004018080602001828103825260218152602001806103c56021913960400191505060405180910390fd5b90505b92915050565b60006102ab83836040518060400160405280601a81526020017f536166654d6174683a206469766973696f6e206279207a65726f0000000000008152506000818361037d5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561034257818101518382015260200161032a565b50505050905090810190601f16801561036f5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b50600083858161038957fe5b049594505050505056fe4f6e6c7920746865206f70657261746f7220636f6e74726163742063616e2063616c6c20746869732066756e6374696f6e536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a2646970667358221220773ca5f35ea4a5be7610919e02be78171a9f2a626d2a3cef292278cb9bd677d764736f6c63430007040033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000d25f2624fc00966fdab3141a5d4205bf5df9aed3000000000000000000000000491604c0fdf08347dd1fa4ee062a822a5dd06b5d00000000000000000000000000000000000000000000009d3595ab2438d000000000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000027100000000000000000000000000000000000000000000000000000000000002710
-----Decoded View---------------
Arg [0] : _operator (address): 0xd25f2624FC00966FdaB3141A5D4205Bf5df9aED3
Arg [1] : _ctsiAddress (address): 0x491604c0FDF08347Dd1fa4Ee062a822A5DD06B5D
Arg [2] : _maxReward (uint256): 2900000000000000000000
Arg [3] : _minReward (uint256): 1000000000000000000
Arg [4] : _distNumerator (uint256): 10000
Arg [5] : _distDenominator (uint256): 10000
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 000000000000000000000000d25f2624fc00966fdab3141a5d4205bf5df9aed3
Arg [1] : 000000000000000000000000491604c0fdf08347dd1fa4ee062a822a5dd06b5d
Arg [2] : 00000000000000000000000000000000000000000000009d3595ab2438d00000
Arg [3] : 0000000000000000000000000000000000000000000000000de0b6b3a7640000
Arg [4] : 0000000000000000000000000000000000000000000000000000000000002710
Arg [5] : 0000000000000000000000000000000000000000000000000000000000002710
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 35 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.