Transactions
Token Transfers
Tokens
Internal Transactions
Coin Balance History
Logs
Code
Read Contract
Write Contract
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- TokenDividendTracker
- Optimization enabled
- true
- Compiler version
- v0.8.18+commit.87f61d96
- Optimization runs
- 50
- EVM Version
- default
- Verified at
- 2023-10-19T06:50:49.237943Z
Constructor Arguments
0x0000000000000000000000002b591e99afe9f32eaa6214f7b7629768c40eeb390000000000000000000000000000000000000000000000000000050d5fcd3e00
Arg [0] (address) : 0x2b591e99afe9f32eaa6214f7b7629768c40eeb39
Arg [1] (uint256) : 5555000000000
contracts/DPT/TokenDividendTracker.sol
import "./DividendPayingToken.sol";
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.15;
contract TokenDividendTracker is Ownable, DividendPayingToken {
using SafeMath for uint256;
using SafeMathInt for int256;
struct MAP {
address[] keys;
mapping(address => uint) values;
mapping(address => uint) indexOf;
mapping(address => bool) inserted;
}
MAP private tokenHoldersMap;
uint256 public lastProcessedIndex;
mapping(address => bool) public excludedFromDividends;
mapping(address => uint256) public lastClaimTimes;
uint256 public claimWait;
uint256 public minimumTokenBalanceForDividends;
event ExcludeFromDividends(address indexed account);
event ClaimWaitUpdated(uint256 indexed newValue, uint256 indexed oldValue);
event Claim(
address indexed account,
uint256 amount,
bool indexed automatic
);
constructor(
address _rewardTokenAddress,
uint256 _minimumTokenBalanceForDividends
)
DividendPayingToken(
_rewardTokenAddress
)
{
claimWait = 3600;
minimumTokenBalanceForDividends = _minimumTokenBalanceForDividends;
}
function _transfer(
address,
address,
uint256
) internal pure override {
require(false, "DT: FORBIDDEN");
}
function withdrawDividend() public pure override {
require(
false,
"DT: CLAIM."
);
}
function setMinimumTokenBalanceForDividends(uint256 val)
external
onlyOwner
{
minimumTokenBalanceForDividends = val;
}
function excludeFromDividends(address account) external onlyOwner {
require(!excludedFromDividends[account]);
excludedFromDividends[account] = true;
_setBalance(account, 0);
MAPRemove(account);
emit ExcludeFromDividends(account);
}
function updateClaimWait(uint256 newClaimWait) external onlyOwner {
require(
newClaimWait >= 3600 && newClaimWait <= 86400,
"DT: 1 < claimWait < 24"
);
require(
newClaimWait != claimWait,
"DT: Same"
);
emit ClaimWaitUpdated(newClaimWait, claimWait);
claimWait = newClaimWait;
}
function getLastProcessedIndex() external view returns (uint256) {
return lastProcessedIndex;
}
function getNumberOfTokenHolders() external view returns (uint256) {
return tokenHoldersMap.keys.length;
}
function isExcludedFromDividends(address account)
public
view
returns (bool)
{
return excludedFromDividends[account];
}
function getAccount(address _account)
public
view
returns (
address account,
int256 index,
int256 iterationsUntilProcessed,
uint256 withdrawableDividends,
uint256 totalDividends,
uint256 lastClaimTime,
uint256 nextClaimTime,
uint256 secondsUntilAutoClaimAvailable
)
{
account = _account;
index = MAPGetIndexOfKey(account);
iterationsUntilProcessed = -1;
if (index >= 0) {
if (uint256(index) > lastProcessedIndex) {
iterationsUntilProcessed = index.sub(
int256(lastProcessedIndex)
);
} else {
uint256 processesUntilEndOfArray = tokenHoldersMap.keys.length >
lastProcessedIndex
? tokenHoldersMap.keys.length.sub(lastProcessedIndex)
: 0;
iterationsUntilProcessed = index.add(
int256(processesUntilEndOfArray)
);
}
}
withdrawableDividends = withdrawableDividendOf(account);
totalDividends = accumulativeDividendOf(account);
lastClaimTime = lastClaimTimes[account];
nextClaimTime = lastClaimTime > 0 ? lastClaimTime.add(claimWait) : 0;
secondsUntilAutoClaimAvailable = nextClaimTime > block.timestamp
? nextClaimTime.sub(block.timestamp)
: 0;
}
function getAccountAtIndex(uint256 index)
public
view
returns (
address,
int256,
int256,
uint256,
uint256,
uint256,
uint256,
uint256
)
{
if (index >= MAPSize()) {
return (
0x0000000000000000000000000000000000000000,
-1,
-1,
0,
0,
0,
0,
0
);
}
address account = MAPGetKeyAtIndex(index);
return getAccount(account);
}
function canAutoClaim(uint256 lastClaimTime) private view returns (bool) {
if (lastClaimTime > block.timestamp) {
return false;
}
return block.timestamp.sub(lastClaimTime) >= claimWait;
}
function setBalance(address payable account, uint256 newBalance)
external
onlyOwner
{
if (excludedFromDividends[account]) {
return;
}
if (newBalance >= minimumTokenBalanceForDividends) {
_setBalance(account, newBalance);
MAPSet(account, newBalance);
} else {
_setBalance(account, 0);
MAPRemove(account);
}
processAccount(account, true);
}
function process(uint256 gas)
public
returns (
uint256,
uint256,
uint256
)
{
uint256 numberOfTokenHolders = tokenHoldersMap.keys.length;
if (numberOfTokenHolders == 0) {
return (0, 0, lastProcessedIndex);
}
uint256 _lastProcessedIndex = lastProcessedIndex;
uint256 gasUsed = 0;
uint256 gasLeft = gasleft();
uint256 iterations = 0;
uint256 claims = 0;
while (gasUsed < gas && iterations < numberOfTokenHolders) {
_lastProcessedIndex++;
if (_lastProcessedIndex >= tokenHoldersMap.keys.length) {
_lastProcessedIndex = 0;
}
address account = tokenHoldersMap.keys[_lastProcessedIndex];
if (canAutoClaim(lastClaimTimes[account])) {
if (processAccount(payable(account), true)) {
claims++;
}
}
iterations++;
uint256 newGasLeft = gasleft();
if (gasLeft > newGasLeft) {
gasUsed = gasUsed.add(gasLeft.sub(newGasLeft));
}
gasLeft = newGasLeft;
}
lastProcessedIndex = _lastProcessedIndex;
return (iterations, claims, lastProcessedIndex);
}
function processAccount(address payable account, bool automatic)
public
onlyOwner
returns (bool)
{
uint256 amount = _withdrawDividendOfUser(account);
if (amount > 0) {
lastClaimTimes[account] = block.timestamp;
emit Claim(account, amount, automatic);
return true;
}
return false;
}
function MAPGet(address key) public view returns (uint) {
return tokenHoldersMap.values[key];
}
function MAPGetIndexOfKey(address key) public view returns (int) {
if (!tokenHoldersMap.inserted[key]) {
return -1;
}
return int(tokenHoldersMap.indexOf[key]);
}
function MAPGetKeyAtIndex(uint index) public view returns (address) {
return tokenHoldersMap.keys[index];
}
function MAPSize() public view returns (uint) {
return tokenHoldersMap.keys.length;
}
function MAPSet(address key, uint val) internal {
if (tokenHoldersMap.inserted[key]) {
tokenHoldersMap.values[key] = val;
} else {
tokenHoldersMap.inserted[key] = true;
tokenHoldersMap.values[key] = val;
tokenHoldersMap.indexOf[key] = tokenHoldersMap.keys.length;
tokenHoldersMap.keys.push(key);
}
}
function MAPRemove(address key) internal {
if (!tokenHoldersMap.inserted[key]) {
return;
}
delete tokenHoldersMap.inserted[key];
delete tokenHoldersMap.values[key];
uint index = tokenHoldersMap.indexOf[key];
uint lastIndex = tokenHoldersMap.keys.length - 1;
address lastKey = tokenHoldersMap.keys[lastIndex];
tokenHoldersMap.indexOf[lastKey] = index;
delete tokenHoldersMap.indexOf[key];
tokenHoldersMap.keys[index] = lastKey;
tokenHoldersMap.keys.pop();
}
function distributeDividends() external payable override {}
}
contracts/DPT/math/SafeMathUint.sol
pragma solidity ^0.8.15;
// SPDX-License-Identifier: UNLICENSED
/**
* @title SafeMathUint
* @dev Math operations with safety checks that revert on error
*/
library SafeMathUint {
function toInt256Safe(uint256 a) internal pure returns (int256) {
int256 b = int256(a);
require(b >= 0);
return b;
}
}
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.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 anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing 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);
}
}
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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;
}
}
@openzeppelin/contracts/utils/math/SafeMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// 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 (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @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) {
return a + b;
}
/**
* @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 a - b;
}
/**
* @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) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting 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 a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting 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) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* 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) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
@uniswap/v2-core/contracts/interfaces/IERC20.sol
pragma solidity >=0.5.0;
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
}
contracts/DPT/DividendPayingToken.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.15;
import "@uniswap/v2-core/contracts/interfaces/IERC20.sol";
import "./DividendPayingTokenInterface.sol";
import "./DividendPayingTokenOptionalInterface.sol";
import "./math/SafeMathUint.sol";
import "./math/SafeMathInt.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
/// @title Dividend-Paying Token
/// @author Roger Wu (https://github.com/roger-wu)
/// @dev A mintable ERC20 token that allows anyone to pay and distribute tokens
/// to token holders as dividends and allows token holders to withdraw their dividends.
/// Reference: the source code of PoWH3D: https://etherscan.io/address/0xB3775fB83F7D12A36E0475aBdD1FCA35c091efBe#code
abstract contract DividendPayingToken is
Ownable,
DividendPayingTokenInterface,
DividendPayingTokenOptionalInterface
{
using SafeMath for uint256;
using SafeMathUint for uint256;
using SafeMathInt for int256;
address public REWARD_TOKEN;
address public stakingImpl;
// With `magnitude`, we can properly distribute dividends even if the amount of received ether is small.
// For more discussion about choosing the value of `magnitude`,
// see https://github.com/ethereum/EIPs/issues/1726#issuecomment-472352728
uint256 internal constant magnitude = 2 ** 128;
uint256 internal magnifiedDividendPerShare;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_totalSupply += amount;
_balances[account] += amount;
magnifiedDividendCorrections[account] = magnifiedDividendCorrections[
account
].sub((magnifiedDividendPerShare.mul(amount)).toInt256Safe());
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
magnifiedDividendCorrections[account] = magnifiedDividendCorrections[
account
].add((magnifiedDividendPerShare.mul(amount)).toInt256Safe());
}
modifier onlySSHex() {
require(_msgSender() == owner() || _msgSender() == stakingImpl, "Only senders.");
_;
}
// About dividendCorrection:
// If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with:
// `dividendOf(_user) = dividendPerShare * balanceOf(_user)`.
// When `balanceOf(_user)` is changed (via minting/burning/transferring tokens),
// `dividendOf(_user)` should not be changed,
// but the computed value of `dividendPerShare * balanceOf(_user)` is changed.
// To keep the `dividendOf(_user)` unchanged, we add a correction term:
// `dividendOf(_user) = dividendPerShare * balanceOf(_user) + dividendCorrectionOf(_user)`,
// where `dividendCorrectionOf(_user)` is updated whenever `balanceOf(_user)` is changed:
// `dividendCorrectionOf(_user) = dividendPerShare * (old balanceOf(_user)) - (new balanceOf(_user))`.
// So now `dividendOf(_user)` returns the same value before and after `balanceOf(_user)` is changed.
mapping(address => int256) internal magnifiedDividendCorrections;
mapping(address => uint256) internal withdrawnDividends;
uint256 public totalDividendsDistributed;
constructor(
address _rewardTokenAddress
) {
REWARD_TOKEN = _rewardTokenAddress;
}
function setStakingImpl(address impl) public onlyOwner {
stakingImpl = impl;
}
function afterReceivedHex(uint256 amount) public onlySSHex {
if (_totalSupply > 0 && amount > 0) {
magnifiedDividendPerShare = magnifiedDividendPerShare.add(
(amount).mul(magnitude) / _totalSupply
);
emit DividendsDistributed(msg.sender, amount);
totalDividendsDistributed = totalDividendsDistributed.add(amount);
}
}
/// @notice Withdraws the ether distributed to the sender.
/// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.
function withdrawDividend() public virtual override {
_withdrawDividendOfUser(payable(msg.sender));
}
/// @notice Withdraws the ether distributed to the sender.
/// @dev It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0.
function _withdrawDividendOfUser(
address payable user
) internal returns (uint256) {
uint256 _withdrawableDividend = withdrawableDividendOf(user);
if (_withdrawableDividend > 0) {
withdrawnDividends[user] = withdrawnDividends[user].add(
_withdrawableDividend
);
emit DividendWithdrawn(user, _withdrawableDividend);
bool success = IERC20(REWARD_TOKEN).transfer(
user,
_withdrawableDividend
);
if (!success) {
withdrawnDividends[user] = withdrawnDividends[user].sub(
_withdrawableDividend
);
return 0;
}
return _withdrawableDividend;
}
return 0;
}
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function dividendOf(address _owner) public view override returns (uint256) {
return withdrawableDividendOf(_owner);
}
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(
address _owner
) public view override returns (uint256) {
return accumulativeDividendOf(_owner).sub(withdrawnDividends[_owner]);
}
/// @notice View the amount of dividend in wei that an address has withdrawn.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has withdrawn.
function withdrawnDividendOf(
address _owner
) public view override returns (uint256) {
return withdrawnDividends[_owner];
}
/// @notice View the amount of dividend in wei that an address has earned in total.
/// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)
/// = (magnifiedDividendPerShare * balanceOf(_owner) + magnifiedDividendCorrections[_owner]) / magnitude
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has earned in total.
function accumulativeDividendOf(
address _owner
) public view override returns (uint256) {
return
magnifiedDividendPerShare
.mul(_balances[_owner])
.toInt256Safe()
.add(magnifiedDividendCorrections[_owner])
.toUint256Safe() / magnitude;
}
/// @dev Internal function that transfer tokens from one address to another.
/// Update magnifiedDividendCorrections to keep dividends unchanged.
/// @param from The address to transfer from.
/// @param to The address to transfer to.
/// @param value The amount to be transferred.
function _transfer(
address from,
address to,
uint256 value
) internal virtual {
require(false);
int256 _magCorrection = magnifiedDividendPerShare
.mul(value)
.toInt256Safe();
magnifiedDividendCorrections[from] = magnifiedDividendCorrections[from]
.add(_magCorrection);
magnifiedDividendCorrections[to] = magnifiedDividendCorrections[to].sub(
_magCorrection
);
}
function _setBalance(address account, uint256 newBalance) internal {
uint256 currentBalance = _balances[account];
if (newBalance > currentBalance) {
uint256 mintAmount = newBalance.sub(currentBalance);
_mint(account, mintAmount);
} else if (newBalance < currentBalance) {
uint256 burnAmount = currentBalance.sub(newBalance);
_burn(account, burnAmount);
}
}
}
contracts/DPT/DividendPayingTokenInterface.sol
pragma solidity ^0.8.15;
// SPDX-License-Identifier: UNLICENSED
/// @title Dividend-Paying Token Interface
/// @author Roger Wu (https://github.com/roger-wu)
/// @dev An interface for a dividend-paying token contract.
interface DividendPayingTokenInterface {
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function dividendOf(address _owner) external view returns(uint256);
/// @notice Distributes ether to token holders as dividends.
/// @dev SHOULD distribute the paid ether to token holders as dividends.
/// SHOULD NOT directly transfer ether to token holders in this function.
/// MUST emit a `DividendsDistributed` event when the amount of distributed ether is greater than 0.
function distributeDividends() external payable;
/// @notice Withdraws the ether distributed to the sender.
/// @dev SHOULD transfer `dividendOf(msg.sender)` wei to `msg.sender`, and `dividendOf(msg.sender)` SHOULD be 0 after the transfer.
/// MUST emit a `DividendWithdrawn` event if the amount of ether transferred is greater than 0.
function withdrawDividend() external;
/// @dev This event MUST emit when ether is distributed to token holders.
/// @param from The address which sends ether to this contract.
/// @param weiAmount The amount of distributed ether in wei.
event DividendsDistributed(
address indexed from,
uint256 weiAmount
);
/// @dev This event MUST emit when an address withdraws their dividend.
/// @param to The address which withdraws ether from this contract.
/// @param weiAmount The amount of withdrawn ether in wei.
event DividendWithdrawn(
address indexed to,
uint256 weiAmount
);
}
contracts/DPT/DividendPayingTokenOptionalInterface.sol
pragma solidity ^0.8.15;
// SPDX-License-Identifier: UNLICENSED
/// @title Dividend-Paying Token Optional Interface
/// @author Roger Wu (https://github.com/roger-wu)
/// @dev OPTIONAL functions for a dividend-paying token contract.
interface DividendPayingTokenOptionalInterface {
/// @notice View the amount of dividend in wei that an address can withdraw.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` can withdraw.
function withdrawableDividendOf(address _owner) external view returns(uint256);
/// @notice View the amount of dividend in wei that an address has withdrawn.
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has withdrawn.
function withdrawnDividendOf(address _owner) external view returns(uint256);
/// @notice View the amount of dividend in wei that an address has earned in total.
/// @dev accumulativeDividendOf(_owner) = withdrawableDividendOf(_owner) + withdrawnDividendOf(_owner)
/// @param _owner The address of a token holder.
/// @return The amount of dividend in wei that `_owner` has earned in total.
function accumulativeDividendOf(address _owner) external view returns(uint256);
}
contracts/DPT/math/SafeMathInt.sol
pragma solidity ^0.8.15;
// SPDX-License-Identifier: UNLICENSED
/**
* @title SafeMathInt
* @dev Math operations with safety checks that revert on error
* @dev SafeMath adapted for int256
* Based on code of https://github.com/RequestNetwork/requestNetwork/blob/master/packages/requestNetworkSmartContracts/contracts/base/math/SafeMathInt.sol
*/
library SafeMathInt {
function mul(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when multiplying INT256_MIN with -1
// https://github.com/RequestNetwork/requestNetwork/issues/43
require(!(a == - 2**255 && b == -1) && !(b == - 2**255 && a == -1));
int256 c = a * b;
require((b == 0) || (c / b == a));
return c;
}
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing INT256_MIN by -1
// https://github.com/RequestNetwork/requestNetwork/issues/43
require(!(a == - 2**255 && b == -1) && (b > 0));
return a / b;
}
function sub(int256 a, int256 b) internal pure returns (int256) {
require((b >= 0 && a - b <= a) || (b < 0 && a - b > a));
return a - b;
}
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
}
Compiler Settings
{"viaIR":false,"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"optimizer":{"runs":50,"enabled":true},"libraries":{}}
Contract ABI
[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_rewardTokenAddress","internalType":"address"},{"type":"uint256","name":"_minimumTokenBalanceForDividends","internalType":"uint256"}]},{"type":"event","name":"Claim","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false},{"type":"bool","name":"automatic","internalType":"bool","indexed":true}],"anonymous":false},{"type":"event","name":"ClaimWaitUpdated","inputs":[{"type":"uint256","name":"newValue","internalType":"uint256","indexed":true},{"type":"uint256","name":"oldValue","internalType":"uint256","indexed":true}],"anonymous":false},{"type":"event","name":"DividendWithdrawn","inputs":[{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"uint256","name":"weiAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DividendsDistributed","inputs":[{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"uint256","name":"weiAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"ExcludeFromDividends","inputs":[{"type":"address","name":"account","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAPGet","inputs":[{"type":"address","name":"key","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"","internalType":"int256"}],"name":"MAPGetIndexOfKey","inputs":[{"type":"address","name":"key","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"MAPGetKeyAtIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"MAPSize","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"REWARD_TOKEN","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"accumulativeDividendOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"afterReceivedHex","inputs":[{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"claimWait","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"distributeDividends","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"dividendOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"excludeFromDividends","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"excludedFromDividends","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"account","internalType":"address"},{"type":"int256","name":"index","internalType":"int256"},{"type":"int256","name":"iterationsUntilProcessed","internalType":"int256"},{"type":"uint256","name":"withdrawableDividends","internalType":"uint256"},{"type":"uint256","name":"totalDividends","internalType":"uint256"},{"type":"uint256","name":"lastClaimTime","internalType":"uint256"},{"type":"uint256","name":"nextClaimTime","internalType":"uint256"},{"type":"uint256","name":"secondsUntilAutoClaimAvailable","internalType":"uint256"}],"name":"getAccount","inputs":[{"type":"address","name":"_account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"},{"type":"int256","name":"","internalType":"int256"},{"type":"int256","name":"","internalType":"int256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getAccountAtIndex","inputs":[{"type":"uint256","name":"index","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getLastProcessedIndex","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getNumberOfTokenHolders","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isExcludedFromDividends","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastClaimTimes","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"lastProcessedIndex","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"minimumTokenBalanceForDividends","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"process","inputs":[{"type":"uint256","name":"gas","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"processAccount","inputs":[{"type":"address","name":"account","internalType":"address payable"},{"type":"bool","name":"automatic","internalType":"bool"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBalance","inputs":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint256","name":"newBalance","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMinimumTokenBalanceForDividends","inputs":[{"type":"uint256","name":"val","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setStakingImpl","inputs":[{"type":"address","name":"impl","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"stakingImpl","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalDividendsDistributed","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"updateClaimWait","inputs":[{"type":"uint256","name":"newClaimWait","internalType":"uint256"}]},{"type":"function","stateMutability":"pure","outputs":[],"name":"withdrawDividend","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"withdrawableDividendOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"withdrawnDividendOf","inputs":[{"type":"address","name":"_owner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b5060405161191738038061191783398101604081905261002f916100b8565b8161003933610068565b600180546001600160a01b0319166001600160a01b0392909216919091179055610e10601155601255506100f2565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600080604083850312156100cb57600080fd5b82516001600160a01b03811681146100e257600080fd5b6020939093015192949293505050565b611816806101016000396000f3fe6080604052600436106101b95760003560e01c80638da5cb5b116100ed578063bc4c4b3711610090578063bc4c4b371461051b578063be10b6141461053b578063c705c56914610551578063e30443bc1461058a578063e7841ec0146105aa578063e98030c7146105bf578063f2fde38b146105df578063fbcbc0f1146105ff578063ffb2c4791461061f57600080fd5b80638da5cb5b1461043057806391b89fba1461044557806399248ea714610465578063a3395cb414610485578063a8b9d240146104a5578063aafd847a146104c5578063b1181e5514610200578063b4113cc8146104fb57600080fd5b806331e79db01161016057806331e79db0146102bf5780634e7b827f146102df5780635183d6fd1461031f578063556cafb0146103845780635ebf4db9146103ba5780636a474002146103da5780636f2789ec146103ef578063715018a61461040557806385a6b3ae1461041a57600080fd5b806303c83302146101be57806305910bee146101c057806306ba651c146101e057806309bbedde1461020057806310a8c46b14610224578063226cfa3d1461025c57806327ce0147146102895780633009a609146102a9575b600080fd5b005b3480156101cc57600080fd5b506101be6101db366004611603565b61065c565b3480156101ec57600080fd5b506101be6101fb366004611631565b610762565b34801561020c57600080fd5b50600a545b6040519081526020015b60405180910390f35b34801561023057600080fd5b5061024461023f366004611603565b61078c565b6040516001600160a01b03909116815260200161021b565b34801561026857600080fd5b50610211610277366004611631565b60106020526000908152604090205481565b34801561029557600080fd5b506102116102a4366004611631565b6107bf565b3480156102b557600080fd5b50610211600e5481565b3480156102cb57600080fd5b506101be6102da366004611631565b610822565b3480156102eb57600080fd5b5061030f6102fa366004611631565b600f6020526000908152604090205460ff1681565b604051901515815260200161021b565b34801561032b57600080fd5b5061033f61033a366004611603565b6108be565b604080516001600160a01b0390991689526020890197909752958701949094526060860192909252608085015260a084015260c083015260e08201526101000161021b565b34801561039057600080fd5b5061021161039f366004611631565b6001600160a01b03166000908152600b602052604090205490565b3480156103c657600080fd5b506101be6103d5366004611603565b61092b565b3480156103e657600080fd5b506101be610938565b3480156103fb57600080fd5b5061021160115481565b34801561041157600080fd5b506101be61096d565b34801561042657600080fd5b5061021160095481565b34801561043c57600080fd5b5061024461097f565b34801561045157600080fd5b50610211610460366004611631565b61098e565b34801561047157600080fd5b50600154610244906001600160a01b031681565b34801561049157600080fd5b506102116104a0366004611631565b610999565b3480156104b157600080fd5b506102116104c0366004611631565b6109de565b3480156104d157600080fd5b506102116104e0366004611631565b6001600160a01b031660009081526008602052604090205490565b34801561050757600080fd5b50600254610244906001600160a01b031681565b34801561052757600080fd5b5061030f61053636600461165c565b610a0a565b34801561054757600080fd5b5061021160125481565b34801561055d57600080fd5b5061030f61056c366004611631565b6001600160a01b03166000908152600f602052604090205460ff1690565b34801561059657600080fd5b506101be6105a5366004611695565b610a95565b3480156105b657600080fd5b50600e54610211565b3480156105cb57600080fd5b506101be6105da366004611603565b610b04565b3480156105eb57600080fd5b506101be6105fa366004611631565b610bd5565b34801561060b57600080fd5b5061033f61061a366004611631565b610c4b565b34801561062b57600080fd5b5061063f61063a366004611603565b610d32565b6040805193845260208401929092529082015260600161021b565b565b61066461097f565b6001600160a01b0316336001600160a01b0316148061069657506002546001600160a01b0316336001600160a01b0316145b6106d75760405162461bcd60e51b815260206004820152600d60248201526c27b7363c9039b2b73232b9399760991b60448201526064015b60405180910390fd5b60006006541180156106e95750600081115b1561075f576006546107169061070383600160801b610e4f565b61070d91906116d7565b60035490610e62565b60035560405181815233907fa493a9229478c3fcd73f66d2cdeb7f94fd0f341da924d1054236d784541165119060200160405180910390a260095461075b9082610e62565b6009555b50565b61076a610e6e565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000600a60000182815481106107a4576107a46116f9565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b0381166000908152600760209081526040808320546004909252822054600354600160801b926108129261080d92610807916108029190610e4f565b610ecd565b90610edd565b610f1b565b61081c91906116d7565b92915050565b61082a610e6e565b6001600160a01b0381166000908152600f602052604090205460ff161561085057600080fd5b6001600160a01b0381166000908152600f60205260408120805460ff1916600117905561087e908290610f2e565b61088781610f93565b6040516001600160a01b038216907fa878b31040b2e6d0a9a3d3361209db3908ba62014b0dca52adbaee451d128b2590600090a250565b6000806000806000806000806108d3600a5490565b89106108f8575060009650600019955085945086935083925082915081905080610920565b60006109038a61078c565b905061090e81610c4b565b98509850985098509850985098509850505b919395975091939597565b610933610e6e565b601255565b60405162461bcd60e51b815260206004820152600a602482015269222a1d1021a620a4a69760b11b60448201526064016106ce565b610975610e6e565b61065a60006110c6565b6000546001600160a01b031690565b600061081c826109de565b6001600160a01b0381166000908152600d602052604081205460ff166109c25750600019919050565b506001600160a01b03166000908152600c602052604090205490565b6001600160a01b03811660009081526008602052604081205461081c90610a04846107bf565b90611116565b6000610a14610e6e565b6000610a1f84611122565b90508015610a8b576001600160a01b038416600081815260106020526040908190204290555184151591907fa2c38e2d2fb7e3e1912d937fd1ca11ed6d51864dee4cfa7a7bf02becd7acf09290610a799085815260200190565b60405180910390a3600191505061081c565b5060009392505050565b610a9d610e6e565b6001600160a01b0382166000908152600f602052604090205460ff16610b00576012548110610adf57610ad08282610f2e565b610ada8282611287565b610af3565b610aea826000610f2e565b610af382610f93565b610afe826001610a0a565b505b5050565b610b0c610e6e565b610e108110158015610b215750620151808111155b610b665760405162461bcd60e51b815260206004820152601660248201527511150e880c480f0818db185a5b55d85a5d080f080c8d60521b60448201526064016106ce565b6011548103610ba25760405162461bcd60e51b815260206004820152600860248201526744543a2053616d6560c01b60448201526064016106ce565b60115460405182907f474ea64804364a1e29a4487ddb63c3342a2dd826ccd8acf48825e680a0e6f20f90600090a3601155565b610bdd610e6e565b6001600160a01b038116610c425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106ce565b61075f816110c6565b806000808080808080610c5d88610999565b9650600019955060008712610cbf57600e54871115610c8b57600e54610c84908890611345565b9550610cbf565b600e54600a5460009110610ca0576000610caf565b600e54600a54610caf91611116565b9050610cbb8882610edd565b9650505b610cc8886109de565b9450610cd3886107bf565b6001600160a01b038916600090815260106020526040902054909450925082610cfd576000610d0b565b601154610d0b908490610e62565b9150428211610d1b576000610d25565b610d258242611116565b9050919395975091939597565b600a5460009081908190808203610d54575050600e5460009250829150610e48565b600e546000805a90506000805b8984108015610d6f57508582105b15610e375784610d7e8161170f565b600a5490965086109050610d9157600094505b6000600a6000018681548110610da957610da96116f9565b60009182526020808320909101546001600160a01b03168083526010909152604090912054909150610dda90611391565b15610dfd57610dea816001610a0a565b15610dfd5781610df98161170f565b9250505b82610e078161170f565b93505060005a905080851115610e2e57610e2b610e248683611116565b8790610e62565b95505b9350610d619050565b600e85905590975095509193505050505b9193909250565b6000610e5b8284611728565b9392505050565b6000610e5b828461173f565b33610e7761097f565b6001600160a01b03161461065a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ce565b6000818181121561081c57600080fd5b600080610eea8385611752565b905060008312158015610efd5750838112155b80610f125750600083128015610f1257508381125b610e5b57600080fd5b600080821215610f2a57600080fd5b5090565b6001600160a01b03821660009081526004602052604090205480821115610f6d576000610f5b8383611116565b9050610f6784826113b8565b50610afe565b80821015610afe576000610f818284611116565b9050610f8d84826114a6565b50505050565b6001600160a01b0381166000908152600d602052604090205460ff16610fb65750565b6001600160a01b0381166000908152600d60209081526040808320805460ff19169055600b8252808320839055600c909152812054600a54909190610ffd9060019061177a565b90506000600a6000018281548110611017576110176116f9565b60009182526020808320909101546001600160a01b03908116808452600c90925260408084208790559087168352822091909155600a8054919250829185908110611064576110646116f9565b600091825260209091200180546001600160a01b0319166001600160a01b0392909216919091179055600a80548061109e5761109e61178d565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610e5b828461177a565b60008061112e836109de565b9050801561127e576001600160a01b0383166000908152600860205260409020546111599082610e62565b6001600160a01b038416600081815260086020526040908190209290925590517fee503bee2bb6a87e57bc57db795f98137327401a0e7b7ce42e37926cc1a9ca4d906111a89084815260200190565b60405180910390a260015460405163a9059cbb60e01b81526001600160a01b03858116600483015260248201849052600092169063a9059cbb906044016020604051808303816000875af1158015611204573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122891906117a3565b905080611277576001600160a01b0384166000908152600860205260409020546112529083611116565b6001600160a01b03909416600090815260086020526040812094909455509192915050565b5092915050565b50600092915050565b6001600160a01b0382166000908152600d602052604090205460ff16156112c5576001600160a01b03919091166000908152600b6020526040902055565b6001600160a01b0382166000818152600d60209081526040808320805460ff19166001908117909155600b8352818420869055600a8054600c909452918420839055820181559091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b03191690911790555050565b600080821215801561136057508261135d83826117c0565b13155b8061137e575060008212801561137e57508261137c83826117c0565b135b61138757600080fd5b610e5b82846117c0565b6000428211156113a357506000919050565b6011546113b04284611116565b101592915050565b6001600160a01b03821661140e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016106ce565b8060066000828254611420919061173f565b90915550506001600160a01b0382166000908152600460205260408120805483929061144d90849061173f565b909155505060035461148690611467906108029084610e4f565b6001600160a01b03841660009081526007602052604090205490611345565b6001600160a01b0390921660009081526007602052604090209190915550565b6001600160a01b0382166115065760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016106ce565b6001600160a01b0382166000908152600460205260409020548181101561157a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016106ce565b6001600160a01b03831660009081526004602052604081208383039055600680548492906115a990849061177a565b90915550506003546115e2906115c3906108029085610e4f565b6001600160a01b03851660009081526007602052604090205490610edd565b6001600160a01b039093166000908152600760205260409020929092555050565b60006020828403121561161557600080fd5b5035919050565b6001600160a01b038116811461075f57600080fd5b60006020828403121561164357600080fd5b8135610e5b8161161c565b801515811461075f57600080fd5b6000806040838503121561166f57600080fd5b823561167a8161161c565b9150602083013561168a8161164e565b809150509250929050565b600080604083850312156116a857600080fd5b82356116b38161161c565b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b6000826116f457634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b600060018201611721576117216116c1565b5060010190565b808202811582820484141761081c5761081c6116c1565b8082018082111561081c5761081c6116c1565b8082018281126000831280158216821582161715611772576117726116c1565b505092915050565b8181038181111561081c5761081c6116c1565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156117b557600080fd5b8151610e5b8161164e565b8181036000831280158383131683831282161715611277576112776116c156fea2646970667358221220d8e01e364f403110c88a9b2a9b3c095d8ce89c5b04afa59b8a57a6fe259f838864736f6c634300081200330000000000000000000000002b591e99afe9f32eaa6214f7b7629768c40eeb390000000000000000000000000000000000000000000000000000050d5fcd3e00
Deployed ByteCode
0x6080604052600436106101b95760003560e01c80638da5cb5b116100ed578063bc4c4b3711610090578063bc4c4b371461051b578063be10b6141461053b578063c705c56914610551578063e30443bc1461058a578063e7841ec0146105aa578063e98030c7146105bf578063f2fde38b146105df578063fbcbc0f1146105ff578063ffb2c4791461061f57600080fd5b80638da5cb5b1461043057806391b89fba1461044557806399248ea714610465578063a3395cb414610485578063a8b9d240146104a5578063aafd847a146104c5578063b1181e5514610200578063b4113cc8146104fb57600080fd5b806331e79db01161016057806331e79db0146102bf5780634e7b827f146102df5780635183d6fd1461031f578063556cafb0146103845780635ebf4db9146103ba5780636a474002146103da5780636f2789ec146103ef578063715018a61461040557806385a6b3ae1461041a57600080fd5b806303c83302146101be57806305910bee146101c057806306ba651c146101e057806309bbedde1461020057806310a8c46b14610224578063226cfa3d1461025c57806327ce0147146102895780633009a609146102a9575b600080fd5b005b3480156101cc57600080fd5b506101be6101db366004611603565b61065c565b3480156101ec57600080fd5b506101be6101fb366004611631565b610762565b34801561020c57600080fd5b50600a545b6040519081526020015b60405180910390f35b34801561023057600080fd5b5061024461023f366004611603565b61078c565b6040516001600160a01b03909116815260200161021b565b34801561026857600080fd5b50610211610277366004611631565b60106020526000908152604090205481565b34801561029557600080fd5b506102116102a4366004611631565b6107bf565b3480156102b557600080fd5b50610211600e5481565b3480156102cb57600080fd5b506101be6102da366004611631565b610822565b3480156102eb57600080fd5b5061030f6102fa366004611631565b600f6020526000908152604090205460ff1681565b604051901515815260200161021b565b34801561032b57600080fd5b5061033f61033a366004611603565b6108be565b604080516001600160a01b0390991689526020890197909752958701949094526060860192909252608085015260a084015260c083015260e08201526101000161021b565b34801561039057600080fd5b5061021161039f366004611631565b6001600160a01b03166000908152600b602052604090205490565b3480156103c657600080fd5b506101be6103d5366004611603565b61092b565b3480156103e657600080fd5b506101be610938565b3480156103fb57600080fd5b5061021160115481565b34801561041157600080fd5b506101be61096d565b34801561042657600080fd5b5061021160095481565b34801561043c57600080fd5b5061024461097f565b34801561045157600080fd5b50610211610460366004611631565b61098e565b34801561047157600080fd5b50600154610244906001600160a01b031681565b34801561049157600080fd5b506102116104a0366004611631565b610999565b3480156104b157600080fd5b506102116104c0366004611631565b6109de565b3480156104d157600080fd5b506102116104e0366004611631565b6001600160a01b031660009081526008602052604090205490565b34801561050757600080fd5b50600254610244906001600160a01b031681565b34801561052757600080fd5b5061030f61053636600461165c565b610a0a565b34801561054757600080fd5b5061021160125481565b34801561055d57600080fd5b5061030f61056c366004611631565b6001600160a01b03166000908152600f602052604090205460ff1690565b34801561059657600080fd5b506101be6105a5366004611695565b610a95565b3480156105b657600080fd5b50600e54610211565b3480156105cb57600080fd5b506101be6105da366004611603565b610b04565b3480156105eb57600080fd5b506101be6105fa366004611631565b610bd5565b34801561060b57600080fd5b5061033f61061a366004611631565b610c4b565b34801561062b57600080fd5b5061063f61063a366004611603565b610d32565b6040805193845260208401929092529082015260600161021b565b565b61066461097f565b6001600160a01b0316336001600160a01b0316148061069657506002546001600160a01b0316336001600160a01b0316145b6106d75760405162461bcd60e51b815260206004820152600d60248201526c27b7363c9039b2b73232b9399760991b60448201526064015b60405180910390fd5b60006006541180156106e95750600081115b1561075f576006546107169061070383600160801b610e4f565b61070d91906116d7565b60035490610e62565b60035560405181815233907fa493a9229478c3fcd73f66d2cdeb7f94fd0f341da924d1054236d784541165119060200160405180910390a260095461075b9082610e62565b6009555b50565b61076a610e6e565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b6000600a60000182815481106107a4576107a46116f9565b6000918252602090912001546001600160a01b031692915050565b6001600160a01b0381166000908152600760209081526040808320546004909252822054600354600160801b926108129261080d92610807916108029190610e4f565b610ecd565b90610edd565b610f1b565b61081c91906116d7565b92915050565b61082a610e6e565b6001600160a01b0381166000908152600f602052604090205460ff161561085057600080fd5b6001600160a01b0381166000908152600f60205260408120805460ff1916600117905561087e908290610f2e565b61088781610f93565b6040516001600160a01b038216907fa878b31040b2e6d0a9a3d3361209db3908ba62014b0dca52adbaee451d128b2590600090a250565b6000806000806000806000806108d3600a5490565b89106108f8575060009650600019955085945086935083925082915081905080610920565b60006109038a61078c565b905061090e81610c4b565b98509850985098509850985098509850505b919395975091939597565b610933610e6e565b601255565b60405162461bcd60e51b815260206004820152600a602482015269222a1d1021a620a4a69760b11b60448201526064016106ce565b610975610e6e565b61065a60006110c6565b6000546001600160a01b031690565b600061081c826109de565b6001600160a01b0381166000908152600d602052604081205460ff166109c25750600019919050565b506001600160a01b03166000908152600c602052604090205490565b6001600160a01b03811660009081526008602052604081205461081c90610a04846107bf565b90611116565b6000610a14610e6e565b6000610a1f84611122565b90508015610a8b576001600160a01b038416600081815260106020526040908190204290555184151591907fa2c38e2d2fb7e3e1912d937fd1ca11ed6d51864dee4cfa7a7bf02becd7acf09290610a799085815260200190565b60405180910390a3600191505061081c565b5060009392505050565b610a9d610e6e565b6001600160a01b0382166000908152600f602052604090205460ff16610b00576012548110610adf57610ad08282610f2e565b610ada8282611287565b610af3565b610aea826000610f2e565b610af382610f93565b610afe826001610a0a565b505b5050565b610b0c610e6e565b610e108110158015610b215750620151808111155b610b665760405162461bcd60e51b815260206004820152601660248201527511150e880c480f0818db185a5b55d85a5d080f080c8d60521b60448201526064016106ce565b6011548103610ba25760405162461bcd60e51b815260206004820152600860248201526744543a2053616d6560c01b60448201526064016106ce565b60115460405182907f474ea64804364a1e29a4487ddb63c3342a2dd826ccd8acf48825e680a0e6f20f90600090a3601155565b610bdd610e6e565b6001600160a01b038116610c425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016106ce565b61075f816110c6565b806000808080808080610c5d88610999565b9650600019955060008712610cbf57600e54871115610c8b57600e54610c84908890611345565b9550610cbf565b600e54600a5460009110610ca0576000610caf565b600e54600a54610caf91611116565b9050610cbb8882610edd565b9650505b610cc8886109de565b9450610cd3886107bf565b6001600160a01b038916600090815260106020526040902054909450925082610cfd576000610d0b565b601154610d0b908490610e62565b9150428211610d1b576000610d25565b610d258242611116565b9050919395975091939597565b600a5460009081908190808203610d54575050600e5460009250829150610e48565b600e546000805a90506000805b8984108015610d6f57508582105b15610e375784610d7e8161170f565b600a5490965086109050610d9157600094505b6000600a6000018681548110610da957610da96116f9565b60009182526020808320909101546001600160a01b03168083526010909152604090912054909150610dda90611391565b15610dfd57610dea816001610a0a565b15610dfd5781610df98161170f565b9250505b82610e078161170f565b93505060005a905080851115610e2e57610e2b610e248683611116565b8790610e62565b95505b9350610d619050565b600e85905590975095509193505050505b9193909250565b6000610e5b8284611728565b9392505050565b6000610e5b828461173f565b33610e7761097f565b6001600160a01b03161461065a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016106ce565b6000818181121561081c57600080fd5b600080610eea8385611752565b905060008312158015610efd5750838112155b80610f125750600083128015610f1257508381125b610e5b57600080fd5b600080821215610f2a57600080fd5b5090565b6001600160a01b03821660009081526004602052604090205480821115610f6d576000610f5b8383611116565b9050610f6784826113b8565b50610afe565b80821015610afe576000610f818284611116565b9050610f8d84826114a6565b50505050565b6001600160a01b0381166000908152600d602052604090205460ff16610fb65750565b6001600160a01b0381166000908152600d60209081526040808320805460ff19169055600b8252808320839055600c909152812054600a54909190610ffd9060019061177a565b90506000600a6000018281548110611017576110176116f9565b60009182526020808320909101546001600160a01b03908116808452600c90925260408084208790559087168352822091909155600a8054919250829185908110611064576110646116f9565b600091825260209091200180546001600160a01b0319166001600160a01b0392909216919091179055600a80548061109e5761109e61178d565b600082815260209020810160001990810180546001600160a01b031916905501905550505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610e5b828461177a565b60008061112e836109de565b9050801561127e576001600160a01b0383166000908152600860205260409020546111599082610e62565b6001600160a01b038416600081815260086020526040908190209290925590517fee503bee2bb6a87e57bc57db795f98137327401a0e7b7ce42e37926cc1a9ca4d906111a89084815260200190565b60405180910390a260015460405163a9059cbb60e01b81526001600160a01b03858116600483015260248201849052600092169063a9059cbb906044016020604051808303816000875af1158015611204573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061122891906117a3565b905080611277576001600160a01b0384166000908152600860205260409020546112529083611116565b6001600160a01b03909416600090815260086020526040812094909455509192915050565b5092915050565b50600092915050565b6001600160a01b0382166000908152600d602052604090205460ff16156112c5576001600160a01b03919091166000908152600b6020526040902055565b6001600160a01b0382166000818152600d60209081526040808320805460ff19166001908117909155600b8352818420869055600a8054600c909452918420839055820181559091527fc65a7bb8d6351c1cf70c95a316cc6a92839c986682d98bc35f958f4883f9d2a80180546001600160a01b03191690911790555050565b600080821215801561136057508261135d83826117c0565b13155b8061137e575060008212801561137e57508261137c83826117c0565b135b61138757600080fd5b610e5b82846117c0565b6000428211156113a357506000919050565b6011546113b04284611116565b101592915050565b6001600160a01b03821661140e5760405162461bcd60e51b815260206004820152601f60248201527f45524332303a206d696e7420746f20746865207a65726f20616464726573730060448201526064016106ce565b8060066000828254611420919061173f565b90915550506001600160a01b0382166000908152600460205260408120805483929061144d90849061173f565b909155505060035461148690611467906108029084610e4f565b6001600160a01b03841660009081526007602052604090205490611345565b6001600160a01b0390921660009081526007602052604090209190915550565b6001600160a01b0382166115065760405162461bcd60e51b815260206004820152602160248201527f45524332303a206275726e2066726f6d20746865207a65726f206164647265736044820152607360f81b60648201526084016106ce565b6001600160a01b0382166000908152600460205260409020548181101561157a5760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b60648201526084016106ce565b6001600160a01b03831660009081526004602052604081208383039055600680548492906115a990849061177a565b90915550506003546115e2906115c3906108029085610e4f565b6001600160a01b03851660009081526007602052604090205490610edd565b6001600160a01b039093166000908152600760205260409020929092555050565b60006020828403121561161557600080fd5b5035919050565b6001600160a01b038116811461075f57600080fd5b60006020828403121561164357600080fd5b8135610e5b8161161c565b801515811461075f57600080fd5b6000806040838503121561166f57600080fd5b823561167a8161161c565b9150602083013561168a8161164e565b809150509250929050565b600080604083850312156116a857600080fd5b82356116b38161161c565b946020939093013593505050565b634e487b7160e01b600052601160045260246000fd5b6000826116f457634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052603260045260246000fd5b600060018201611721576117216116c1565b5060010190565b808202811582820484141761081c5761081c6116c1565b8082018082111561081c5761081c6116c1565b8082018281126000831280158216821582161715611772576117726116c1565b505092915050565b8181038181111561081c5761081c6116c1565b634e487b7160e01b600052603160045260246000fd5b6000602082840312156117b557600080fd5b8151610e5b8161164e565b8181036000831280158383131683831282161715611277576112776116c156fea2646970667358221220d8e01e364f403110c88a9b2a9b3c095d8ce89c5b04afa59b8a57a6fe259f838864736f6c63430008120033