SUSF (left) vs. UNIF (right)

-20 Removals
+13 Additions
/**/**
*Submitted for verification at Etherscan.io on 2021-01-01 *Submitted for verification at Etherscan.io on 2020-12-22
*/*/
pragma solidity ^0.6.12;// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
library SafeCast {library SafeCast {
function toUint128(uint256 value) internal pure returns (uint128) { function toUint128(uint256 value) internal pure returns (uint128) {
require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits"); require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
return uint128(value); return uint128(value);
} }
function toUint64(uint256 value) internal pure returns (uint64) { function toUint64(uint256 value) internal pure returns (uint64) {
require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits"); require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
return uint64(value); return uint64(value);
} }
function toUint32(uint256 value) internal pure returns (uint32) { function toUint32(uint256 value) internal pure returns (uint32) {
require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits"); require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
return uint32(value); return uint32(value);
} }
function toUint16(uint256 value) internal pure returns (uint16) { function toUint16(uint256 value) internal pure returns (uint16) {
require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits"); require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
return uint16(value); return uint16(value);
} }
function toUint8(uint256 value) internal pure returns (uint8) { function toUint8(uint256 value) internal pure returns (uint8) {
require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits"); require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
return uint8(value); return uint8(value);
} }
function toUint256(int256 value) internal pure returns (uint256) { function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive"); require(value >= 0, "SafeCast: value must be positive");
return uint256(value); return uint256(value);
} }
function toInt256(uint256 value) internal pure returns (int256) { function toInt256(uint256 value) internal pure returns (int256) {
require(value < 2**255, "SafeCast: value doesn't fit in an int256"); require(value < 2**255, "SafeCast: value doesn't fit in an int256");
return int256(value); return int256(value);
} }
}}
contract Initializable {contract Initializable {
bool private initialized; bool private initialized;
bool private initializing; bool private initializing;
modifier initializer() { modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized"); require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing; bool isTopLevelCall = !initializing;
if (isTopLevelCall) { if (isTopLevelCall) {
initializing = true; initializing = true;
initialized = true; initialized = true;
} }
_; _;
if (isTopLevelCall) { if (isTopLevelCall) {
initializing = false; initializing = false;
} }
} }
function isConstructor() private view returns (bool) { function isConstructor() private view returns (bool) {
address self = address(this); address self = address(this);
uint256 cs; uint256 cs;
assembly { cs := extcodesize(self) } assembly { cs := extcodesize(self) }
return cs == 0; return cs == 0;
} }
uint256[50] private ______gap; uint256[50] private ______gap;
}}
contract ContextUpgradeSafe is Initializable {contract ContextUpgradeSafe is Initializable {
function __Context_init() internal initializer { function __Context_init() internal initializer {
__Context_init_unchained(); __Context_init_unchained();
} }
function __Context_init_unchained() internal initializer { function __Context_init_unchained() internal initializer {
} }
function _msgSender() internal view virtual returns (address payable) { function _msgSender() internal view virtual returns (address payable) {
return msg.sender; return msg.sender;
} }
function _msgData() internal view virtual returns (bytes memory) { function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data; return msg.data;
} }
uint256[50] private __gap; uint256[50] private __gap;
}}
contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe {contract OwnableUpgradeSafe is Initializable, ContextUpgradeSafe {
address private _owner; address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function __Ownable_init() internal initializer { function __Ownable_init() internal initializer {
__Context_init_unchained(); __Context_init_unchained();
__Ownable_init_unchained(); __Ownable_init_unchained();
} }
function __Ownable_init_unchained() internal initializer { function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender(); address msgSender = _msgSender();
_owner = msgSender; _owner = msgSender;
emit OwnershipTransferred(address(0), msgSender); emit OwnershipTransferred(address(0), msgSender);
} }
function owner() public view returns (address) { function owner() public view returns (address) {
return _owner; return _owner;
} }
modifier onlyOwner() { modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner"); require(_owner == _msgSender(), "Ownable: caller is not the owner");
_; _;
} }
function renounceOwnership() public virtual onlyOwner { function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0)); emit OwnershipTransferred(_owner, address(0));
_owner = address(0); _owner = address(0);
} }
function transferOwnership(address newOwner) public virtual onlyOwner { function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address"); require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner); emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner; _owner = newOwner;
} }
uint256[49] private __gap; uint256[49] private __gap;
}}
interface IERC20 {interface IERC20 {
function totalSupply() external view returns (uint256); function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256); function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool); function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool); function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value);
}}
library SafeMath {library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) { function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b; uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow"); require(c >= a, "SafeMath: addition overflow");
return c; return c;
} }
function sub(uint256 a, uint256 b) internal pure returns (uint256) { function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow"); return sub(a, b, "SafeMath: subtraction overflow");
} }
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage); require(b <= a, errorMessage);
uint256 c = a - b; uint256 c = a - b;
return c; return c;
} }
function mul(uint256 a, uint256 b) internal pure returns (uint256) { function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) { if (a == 0) {
return 0; return 0;
} }
uint256 c = a * b; uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow"); require(c / a == b, "SafeMath: multiplication overflow");
return c; return c;
} }
function div(uint256 a, uint256 b) internal pure returns (uint256) { function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero"); return div(a, b, "SafeMath: division by zero");
} }
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage); require(b > 0, errorMessage);
uint256 c = a / b; uint256 c = a / b;
return c; return c;
} }
function mod(uint256 a, uint256 b) internal pure returns (uint256) { function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero"); return mod(a, b, "SafeMath: modulo by zero");
} }
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage); require(b != 0, errorMessage);
return a % b; return a % b;
} }
}}
library Address {library Address {
function isContract(address account) internal view returns (bool) { function isContract(address account) internal view returns (bool) {
bytes32 codehash; bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash := extcodehash(account) } assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0); return (codehash != accountHash && codehash != 0x0);
} }
function sendValue(address payable recipient, uint256 amount) internal { function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance"); require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }(""); (bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted"); require(success, "Address: unable to send value, recipient may have reverted");
} }
}}
contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 {contract ERC20UpgradeSafe is Initializable, ContextUpgradeSafe, IERC20 {
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
mapping (address => uint256) private _balances; mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances; mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply; uint256 private _totalSupply;
string private _name; string private _name;
string private _symbol; string private _symbol;
uint8 private _decimals; uint8 private _decimals;
function __ERC20_init(string memory name, string memory symbol) internal initializer { function __ERC20_init(string memory name, string memory symbol) internal initializer {
__Context_init_unchained(); __Context_init_unchained();
__ERC20_init_unchained(name, symbol); __ERC20_init_unchained(name, symbol);
} }
function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer { function __ERC20_init_unchained(string memory name, string memory symbol) internal initializer {
_name = name; _name = name;
_symbol = symbol; _symbol = symbol;
_decimals = 18; _decimals = 18;
} }
function name() public view returns (string memory) { function name() public view returns (string memory) {
return _name; return _name;
} }
function symbol() public view returns (string memory) { function symbol() public view returns (string memory) {
return _symbol; return _symbol;
} }
function decimals() public view returns (uint8) { function decimals() public view returns (uint8) {
return _decimals; return _decimals;
} }
function totalSupply() public view virtual override returns (uint256) { function totalSupply() public view virtual override returns (uint256) {
return _totalSupply; return _totalSupply;
} }
function balanceOf(address account) public view virtual override returns (uint256) { function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account]; return _balances[account];
} }
function transfer(address recipient, uint256 amount) public virtual override returns (bool) { function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount); _transfer(_msgSender(), recipient, amount);
return true; return true;
} }
function allowance(address owner, address spender) public view virtual override returns (uint256) { function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender]; return _allowances[owner][spender];
} }
function approve(address spender, uint256 amount) public virtual override returns (bool) { function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount); _approve(_msgSender(), spender, amount);
return true; return true;
} }
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) { function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount); _transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true; return true;
} }
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true; return true;
} }
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true; return true;
} }
function _transfer(address sender, address recipient, uint256 amount) internal virtual { function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address"); require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address"); require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount); _beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance"); _balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount); _balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount); emit Transfer(sender, recipient, amount);
} }
function _approve(address owner, address spender, uint256 amount) internal virtual { function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address"); require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address"); require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount; _allowances[owner][spender] = amount;
emit Approval(owner, spender, amount); emit Approval(owner, spender, amount);
} }
function _setupDecimals(uint8 decimals_) internal { function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_; _decimals = decimals_;
} }
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
uint256[44] private __gap; uint256[44] private __gap;
}}
interface IUniswapV2Factory {interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint); event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address); function feeTo() external view returns (address);
function feeToSetter() external view returns (address); function feeToSetter() external view returns (address);
function migrator() external view returns (address); function migrator() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair); function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair); function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint); function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair); function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external; function setFeeTo(address) external;
function setFeeToSetter(address) external; function setFeeToSetter(address) external;
function setMigrator(address) external; function setMigrator(address) external;
}}
interface IUniswapV2Router01 {interface IUniswapV2Router01 {
function factory() external pure returns (address); function factory() external pure returns (address);
function WETH() external pure returns (address); function WETH() external pure returns (address);
function addLiquidity( function addLiquidity(
address tokenA, address tokenA,
address tokenB, address tokenB,
uint amountADesired, uint amountADesired,
uint amountBDesired, uint amountBDesired,
uint amountAMin, uint amountAMin,
uint amountBMin, uint amountBMin,
address to, address to,
uint deadline uint deadline
) external returns (uint amountA, uint amountB, uint liquidity); ) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH( function addLiquidityETH(
address token, address token,
uint amountTokenDesired, uint amountTokenDesired,
uint amountTokenMin, uint amountTokenMin,
uint amountETHMin, uint amountETHMin,
address to, address to,
uint deadline uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity); ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity( function removeLiquidity(
address tokenA, address tokenA,
address tokenB, address tokenB,
uint liquidity, uint liquidity,
uint amountAMin, uint amountAMin,
uint amountBMin, uint amountBMin,
address to, address to,
uint deadline uint deadline
) external returns (uint amountA, uint amountB); ) external returns (uint amountA, uint amountB);
function removeLiquidityETH( function removeLiquidityETH(
address token, address token,
uint liquidity, uint liquidity,
uint amountTokenMin, uint amountTokenMin,
uint amountETHMin, uint amountETHMin,
address to, address to,
uint deadline uint deadline
) external returns (uint amountToken, uint amountETH); ) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit( function removeLiquidityWithPermit(
address tokenA, address tokenA,
address tokenB, address tokenB,
uint liquidity, uint liquidity,
uint amountAMin, uint amountAMin,
uint amountBMin, uint amountBMin,
address to, address to,
uint deadline, uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB); ) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit( function removeLiquidityETHWithPermit(
address token, address token,
uint liquidity, uint liquidity,
uint amountTokenMin, uint amountTokenMin,
uint amountETHMin, uint amountETHMin,
address to, address to,
uint deadline, uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH); ) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens( function swapExactTokensForTokens(
uint amountIn, uint amountIn,
uint amountOutMin, uint amountOutMin,
address[] calldata path, address[] calldata path,
address to, address to,
uint deadline uint deadline
) external returns (uint[] memory amounts); ) external returns (uint[] memory amounts);
function swapTokensForExactTokens( function swapTokensForExactTokens(
uint amountOut, uint amountOut,
uint amountInMax, uint amountInMax,
address[] calldata path, address[] calldata path,
address to, address to,
uint deadline uint deadline
) external returns (uint[] memory amounts); ) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external external
payable payable
returns (uint[] memory amounts); returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external external
returns (uint[] memory amounts); returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external external
returns (uint[] memory amounts); returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external external
payable payable
returns (uint[] memory amounts); returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB); function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut); function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn); function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts); function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}}
interface IUniswapV2Router02 is IUniswapV2Router01 {interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens( function removeLiquidityETHSupportingFeeOnTransferTokens(
address token, address token,
uint liquidity, uint liquidity,
uint amountTokenMin, uint amountTokenMin,
uint amountETHMin, uint amountETHMin,
address to, address to,
uint deadline uint deadline
) external returns (uint amountETH); ) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens( function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token, address token,
uint liquidity, uint liquidity,
uint amountTokenMin, uint amountTokenMin,
uint amountETHMin, uint amountETHMin,
address to, address to,
uint deadline, uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH); ) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens( function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn, uint amountIn,
uint amountOutMin, uint amountOutMin,
address[] calldata path, address[] calldata path,
address to, address to,
uint deadline uint deadline
) external; ) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens( function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin, uint amountOutMin,
address[] calldata path, address[] calldata path,
address to, address to,
uint deadline uint deadline
) external payable; ) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens( function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn, uint amountIn,
uint amountOutMin, uint amountOutMin,
address[] calldata path, address[] calldata path,
address to, address to,
uint deadline uint deadline
) external; ) external;
}}
interface IUniswapV2Pair {interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value); event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value); event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory); function name() external pure returns (string memory);
function symbol() external pure returns (string memory); function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8); function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint); function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint); function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint); function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool); function approve(address spender, uint value) external returns (bool);
function transfer(address to, 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); function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32); function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint); function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external; function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1); event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to); event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap( event Swap(
address indexed sender, address indexed sender,
uint amount0In, uint amount0In,
uint amount1In, uint amount1In,
uint amount0Out, uint amount0Out,
uint amount1Out, uint amount1Out,
address indexed to address indexed to
); );
event Sync(uint112 reserve0, uint112 reserve1); event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint); function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address); function factory() external view returns (address);
function token0() external view returns (address); function token0() external view returns (address);
function token1() external view returns (address); function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint); function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint); function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint); function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity); function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1); function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external; function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external; function skim(address to) external;
function sync() external; function sync() external;
function initialize(address, address) external; function initialize(address, address) external;
}}
interface IWETH {interface IWETH {
function deposit() external payable; function deposit() external payable;
function transfer(address to, uint value) external returns (bool); function transfer(address to, uint value) external returns (bool);
function withdraw(uint) external; function withdraw(uint) external;
}}
contract SUSF is ERC20UpgradeSafe, OwnableUpgradeSafe {contract UNIF is ERC20UpgradeSafe, OwnableUpgradeSafe {
using SafeCast for int256; using SafeCast for int256;
using SafeMath for uint256; using SafeMath for uint256;
using Address for address; using Address for address;
struct Transaction { struct Transaction {
bool enabled; bool enabled;
address destination; address destination;
bytes data; bytes data;
} }
event TransactionFailed(address indexed destination, uint index, bytes data); event TransactionFailed(address indexed destination, uint index, bytes data);
// Stable ordering is not guaranteed. // Stable ordering is not guaranteed.
Transaction[] public transactions; Transaction[] public transactions;
uint256 private _epoch; uint256 private _epoch;
event LogRebase(uint256 indexed epoch, uint256 totalSupply); event LogRebase(uint256 indexed epoch, uint256 totalSupply);
mapping (address => uint256) private _rOwned; mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned; mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances; mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcluded; mapping (address => bool) private _isExcluded;
address[] private _excluded; address[] private _excluded;
uint256 private _totalSupply; uint256 private _totalSupply;
uint256 private constant MAX = ~uint256(0); uint256 private constant MAX = ~uint256(0);
uint256 private _rTotal; uint256 private _rTotal;
uint256 private _tFeeTotal; uint256 private _tFeeTotal;
uint256 private constant DECIMALS = 9; uint256 private constant DECIMALS = 9;
uint256 private constant RATE_PRECISION = 10 ** DECIMALS; uint256 private constant RATE_PRECISION = 10 ** DECIMALS;
uint256 public _tFeePercent; uint256 public _tFeePercent;
address public _rebaser; address public _rebaser;
uint256 public _limitTransferAmount; uint256 public _limitTransferAmount;
uint256 public _limitMaxBalance; uint256 public _limitMaxBalance;
uint256 public _limitSellFeePercent; uint256 public _limitSellFeePercent;
uint256 public _limitTimestamp; uint256 public _limitTimestamp;
uint256 public _presaleTimestamp; uint256 public _presaleTimestamp;
uint256 public _presaleEth; uint256 public _presaleEth;
bool public endSale; bool public endSale;
uint256 public _presaleRate; uint256 public _presaleRate;
mapping(address => uint256) public saleAmt;
mapping(uint256 => bool) public locked;
IUniswapV2Router02 public uniswapRouterV2; IUniswapV2Router02 public uniswapRouterV2;
IUniswapV2Factory public uniswapFactory; IUniswapV2Factory public uniswapFactory;
function initialize() function initialize()
public public
initializer initializer
{ {
__ERC20_init("Sushiforth", "SUSF"); __ERC20_init("Uniforth", "UNIF");
_setupDecimals(uint8(DECIMALS)); _setupDecimals(uint8(DECIMALS));
__Ownable_init(); __Ownable_init();
_totalSupply = 12000000 * 10**9 ; _totalSupply = 8000000 * 10**9 ;
_rTotal = (MAX - (MAX % _totalSupply)); _rTotal = (MAX - (MAX % _totalSupply));
_rebaser = _msgSender(); _rebaser = _msgSender();
_tFeePercent = 237; //2.6682% _tFeePercent = 266; //2.6682%
_rOwned[address(this)] = _rTotal; _rOwned[address(this)] = _rTotal;
emit Transfer(address(0), address(this), _totalSupply); emit Transfer(address(0), address(this), _totalSupply);
_presaleTimestamp = 1609696800; _presaleTimestamp = now + 3 days;
endSale = false; endSale = false;
_presaleEth = 600 ether; _presaleEth = 600 ether;
_presaleRate = 6666; _presaleRate = 6000;
excludeAccount(_msgSender()); excludeAccount(_msgSender());
excludeAccount(address(this)); excludeAccount(address(this));
uniswapRouterV2 = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); uniswapRouterV2 = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f); uniswapFactory = IUniswapV2Factory(0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f);
} }
receive() external payable { receive() external payable {
require(!endSale, "PreSale Ended"); require(!endSale, "PreSale Ended");
require(now > 1609524000, "presale yet to start");
require(_presaleEth >= msg.value, "Sold out"); require(_presaleEth >= msg.value, "Sold out");
saleAmt[msg.sender] += msg.value;
require(saleAmt[msg.sender] <= 7500000000000000000, "max presale limit reached");
address payable wallet = address(uint160(owner())); address payable wallet = address(uint160(owner()));
wallet.transfer(msg.value.div(3)); wallet.transfer(msg.value.div(3));
_presaleEth = _presaleEth.sub(msg.value); _presaleEth = _presaleEth.sub(msg.value);
uint256 amountBought = msg.value.div(10**9).mul(_presaleRate); uint256 amountBought = msg.value.div(10**9).mul(_presaleRate);
_transfer(address(this), msg.sender, amountBought ); _transfer(address(this), msg.sender, amountBought );
} }
function listToken() external onlyOwner() { function listToken() external onlyOwner() {
require(!endSale, 'already listed'); require(!endSale, 'already listed');
require(_presaleEth == 0 || _presaleTimestamp < now, "Sale has not ended yet"); require(_presaleEth == 0 || _presaleTimestamp < now, "Sale has not ended yet");
endSale = true; endSale = true;
_transfer(address(this), _msgSender(), 8000000 * 10**9); _transfer(address(this), _msgSender(), 2000000 * 10**9);
address tokenUniswapPair = uniswapFactory.createPair( address tokenUniswapPair = uniswapFactory.createPair(
address(uniswapRouterV2.WETH()), address(uniswapRouterV2.WETH()),
address(address(this)) address(address(this))
); );
IUniswapV2Pair pair = IUniswapV2Pair(tokenUniswapPair); IUniswapV2Pair pair = IUniswapV2Pair(tokenUniswapPair);
address WETH = uniswapRouterV2.WETH(); address WETH = uniswapRouterV2.WETH();
uint256 ethToSend = address(this).balance; uint256 ethToSend = address(this).balance;
IWETH(WETH).deposit{value : ethToSend}(); IWETH(WETH).deposit{value : ethToSend}();
require(address(this).balance == 0 , "Transfer Failed"); require(address(this).balance == 0 , "Transfer Failed");
uint256 tokenToAdd = 2666666 * 10**9; uint256 tokenToAdd = 2400000 * 10**9;
if(_presaleEth != 0) { if(_presaleEth != 0) {
tokenToAdd = ethToSend.div(10**9).mul(_presaleRate); tokenToAdd = ethToSend.div(10**9).mul(_presaleRate);
uint256 unsoldTokens = balanceOf(address(this)) - tokenToAdd; uint256 unsoldTokens = balanceOf(address(this)) - tokenToAdd;
_transfer(address(this), address(0), unsoldTokens); _transfer(address(this), address(0), unsoldTokens);
} }
IWETH(WETH).transfer(address(pair),ethToSend); IWETH(WETH).transfer(address(pair),ethToSend);
_transfer(address(this), address(pair), tokenToAdd); _transfer(address(this), address(pair), tokenToAdd);
pair.mint(address(this)); pair.mint(address(this));
IERC20(address(pair)).transfer(msg.sender, IERC20(address(pair)).balanceOf(address(this))); IERC20(address(pair)).transfer(msg.sender, IERC20(address(pair)).balanceOf(address(this)));
} }
function setRebaser(address rebaser) external onlyOwner() { function setRebaser(address rebaser) external onlyOwner() {
_rebaser = rebaser; _rebaser = rebaser;
}
function setLock(uint256 _index) external onlyOwner() {
locked[_index] = true;
} }
function setTransferFeePercent(uint256 tFeePercent) external onlyOwner() { function setTransferFeePercent(uint256 tFeePercent) external onlyOwner() {
_tFeePercent = tFeePercent; _tFeePercent = tFeePercent;
} }
function setLimit(uint256 transferAmount, uint256 maxBalance, uint256 sellFeePercent) external onlyOwner() { function setLimit(uint256 transferAmount, uint256 maxBalance, uint256 sellFeePercent) external onlyOwner() {
require(_limitTimestamp == 0, "Limit changes not allowed"); require(_limitTimestamp == 0, "Limit changes not allowed");
_limitTransferAmount = transferAmount; _limitTransferAmount = transferAmount;
_limitMaxBalance = maxBalance; _limitMaxBalance = maxBalance;
_limitSellFeePercent = sellFeePercent; _limitSellFeePercent = sellFeePercent;
_limitTimestamp = now; _limitTimestamp = now;
} }
function totalSupply() public view override returns (uint256) { function totalSupply() public view override returns (uint256) {
return _totalSupply; return _totalSupply;
} }
function rebase(int256 supplyDelta) function rebase(int256 supplyDelta)
external external
returns (uint256) returns (uint256)
{ {
require(_msgSender() == owner() || _msgSender() == _rebaser, "Sender not authorized"); require(_msgSender() == owner() || _msgSender() == _rebaser, "Sender not authorized");
_epoch = _epoch.add(1); _epoch = _epoch.add(1);
if (supplyDelta == 0) { if (supplyDelta == 0) {
emit LogRebase(_epoch, _totalSupply); emit LogRebase(_epoch, _totalSupply);
return _totalSupply; return _totalSupply;
} }
uint256 uSupplyDelta = (supplyDelta < 0 ? -supplyDelta : supplyDelta).toUint256(); uint256 uSupplyDelta = (supplyDelta < 0 ? -supplyDelta : supplyDelta).toUint256();
uint256 rate = uSupplyDelta.mul(RATE_PRECISION).div(_totalSupply); uint256 rate = uSupplyDelta.mul(RATE_PRECISION).div(_totalSupply);
uint256 multiplier; uint256 multiplier;
if (supplyDelta < 0) { if (supplyDelta < 0) {
multiplier = RATE_PRECISION.sub(rate); multiplier = RATE_PRECISION.sub(rate);
} else { } else {
multiplier = RATE_PRECISION.add(rate); multiplier = RATE_PRECISION.add(rate);
} }
if (supplyDelta < 0) { if (supplyDelta < 0) {
_totalSupply = _totalSupply.sub(uSupplyDelta); _totalSupply = _totalSupply.sub(uSupplyDelta);
} else { } else {
_totalSupply = _totalSupply.add(uSupplyDelta); _totalSupply = _totalSupply.add(uSupplyDelta);
} }
if (_totalSupply > MAX) { if (_totalSupply > MAX) {
_totalSupply = MAX; _totalSupply = MAX;
} }
for (uint256 i = 0; i < _excluded.length; i++) { for (uint256 i = 0; i < _excluded.length; i++) {
if(_tOwned[_excluded[i]] > 0) { if(_tOwned[_excluded[i]] > 0) {
_tOwned[_excluded[i]] = _tOwned[_excluded[i]].mul(multiplier).div(RATE_PRECISION); _tOwned[_excluded[i]] = _tOwned[_excluded[i]].mul(multiplier).div(RATE_PRECISION);
} }
} }
emit LogRebase(_epoch, _totalSupply); emit LogRebase(_epoch, _totalSupply);
for (uint i = 0; i < transactions.length; i++) { for (uint i = 0; i < transactions.length; i++) {
Transaction storage t = transactions[i]; Transaction storage t = transactions[i];
if (t.enabled) { if (t.enabled) {
bool result = externalCall(t.destination, t.data); bool result = externalCall(t.destination, t.data);
if (!result) { if (!result) {
emit TransactionFailed(t.destination, i, t.data); emit TransactionFailed(t.destination, i, t.data);
revert("Transaction Failed"); revert("Transaction Failed");
} }
} }
} }
return _totalSupply; return _totalSupply;
} }
/** /**
* @notice Adds a transaction that gets called for a downstream receiver of rebases * @notice Adds a transaction that gets called for a downstream receiver of rebases
* @param destination Address of contract destination * @param destination Address of contract destination
* @param data Transaction data payload * @param data Transaction data payload
*/ */
function addTransaction(address destination, bytes memory data) function addTransaction(address destination, bytes memory data)
external external
onlyOwner onlyOwner
{ {
transactions.push(Transaction({ transactions.push(Transaction({
enabled: true, enabled: true,
destination: destination, destination: destination,
data: data data: data
})); }));
} }
/** /**
* @param index Index of transaction to remove. * @param index Index of transaction to remove.
* Transaction ordering may have changed since adding. * Transaction ordering may have changed since adding.
*/ */
function removeTransaction(uint index) function removeTransaction(uint index)
external external
onlyOwner onlyOwner
{ {
require(index < transactions.length, "index out of bounds"); require(index < transactions.length, "index out of bounds");
require(!locked[index], "index is locked");
if (index < transactions.length - 1) { if (index < transactions.length - 1) {
transactions[index] = transactions[transactions.length - 1]; transactions[index] = transactions[transactions.length - 1];
} }
transactions.pop(); transactions.pop();
} }
/** /**
* @param index Index of transaction. Transaction ordering may have changed since adding. * @param index Index of transaction. Transaction ordering may have changed since adding.
* @param enabled True for enabled, false for disabled. * @param enabled True for enabled, false for disabled.
*/ */
function setTransactionEnabled(uint index, bool enabled) function setTransactionEnabled(uint index, bool enabled)
external external
onlyOwner onlyOwner
{ {
require(index < transactions.length, "index must be in range of stored tx list"); require(index < transactions.length, "index must be in range of stored tx list");
transactions[index].enabled = enabled; transactions[index].enabled = enabled;
} }
/** /**
* @return Number of transactions, both enabled and disabled, in transactions list. * @return Number of transactions, both enabled and disabled, in transactions list.
*/ */
function transactionsSize() function transactionsSize()
external external
view view
returns (uint256) returns (uint256)
{ {
return transactions.length; return transactions.length;
} }
/** /**
* @dev wrapper to call the encoded transactions on downstream consumers. * @dev wrapper to call the encoded transactions on downstream consumers.
* @param destination Address of destination contract. * @param destination Address of destination contract.
* @param data The encoded data payload. * @param data The encoded data payload.
* @return True on success * @return True on success
*/ */
function externalCall(address destination, bytes memory data) function externalCall(address destination, bytes memory data)
internal internal
returns (bool) returns (bool)
{ {
bool result; bool result;
assembly { // solhint-disable-line no-inline-assembly assembly { // solhint-disable-line no-inline-assembly
// "Allocate" memory for output // "Allocate" memory for output
// (0x40 is where "free memory" pointer is stored by convention) // (0x40 is where "free memory" pointer is stored by convention)
let outputAddress := mload(0x40) let outputAddress := mload(0x40)
// First 32 bytes are the padded length of data, so exclude that // First 32 bytes are the padded length of data, so exclude that
let dataAddress := add(data, 32) let dataAddress := add(data, 32)
result := call( result := call(
// 34710 is the value that solidity is currently emitting // 34710 is the value that solidity is currently emitting
// It includes callGas (700) + callVeryLow (3, to pay for SUB) // It includes callGas (700) + callVeryLow (3, to pay for SUB)
// + callValueTransferGas (9000) + callNewAccountGas // + callValueTransferGas (9000) + callNewAccountGas
// (25000, in case the destination address does not exist and needs creating) // (25000, in case the destination address does not exist and needs creating)
sub(gas(), 34710), sub(gas(), 34710),
destination, destination,
0, // transfer value in wei 0, // transfer value in wei
dataAddress, dataAddress,
mload(data), // Size of the input, in bytes. Stored in position 0 of the array. mload(data), // Size of the input, in bytes. Stored in position 0 of the array.
outputAddress, outputAddress,
0 // Output is ignored, therefore the output size is zero 0 // Output is ignored, therefore the output size is zero
) )
} }
return result; return result;
} }
function balanceOf(address account) public view override returns (uint256) { function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account]; if (_isExcluded[account]) return _tOwned[account];
return tokenFromRefraction(_rOwned[account]); return tokenFromRefraction(_rOwned[account]);
} }
function transfer(address recipient, uint256 amount) public override returns (bool) { function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount); _transfer(_msgSender(), recipient, amount);
return true; return true;
} }
function allowance(address owner, address spender) public view override returns (uint256) { function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender]; return _allowances[owner][spender];
} }
function approve(address spender, uint256 amount) public override returns (bool) { function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount); _approve(_msgSender(), spender, amount);
return true; return true;
} }
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount); _transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true; return true;
} }
function increaseAllowance(address spender, uint256 addedValue) public virtual override returns (bool) { function increaseAllowance(address spender, uint256 addedValue) public virtual override returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true; return true;
} }
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override returns (bool) { function decreaseAllowance(address spender, uint256 subtractedValue) public virtual override returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true; return true;
} }
function isExcluded(address account) public view returns (bool) { function isExcluded(address account) public view returns (bool) {
return _isExcluded[account]; return _isExcluded[account];
} }
function totalFees() public view returns (uint256) { function totalFees() public view returns (uint256) {
return _tFeeTotal; return _tFeeTotal;
} }
function refract(uint256 tAmount) public { function refract(uint256 tAmount) public {
address sender = _msgSender(); address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function"); require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,) = _getValues(tAmount, _tFeePercent); (uint256 rAmount,,,,) = _getValues(tAmount, _tFeePercent);
_rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount); _rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount); _tFeeTotal = _tFeeTotal.add(tAmount);
} }
function refractionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { function refractionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _totalSupply, "Amount must be less than supply"); require(tAmount <= _totalSupply, "Amount must be less than supply");
if (!deductTransferFee) { if (!deductTransferFee) {
(uint256 rAmount,,,,) = _getValues(tAmount, _tFeePercent); (uint256 rAmount,,,,) = _getValues(tAmount, _tFeePercent);
return rAmount; return rAmount;
} else { } else {
(,uint256 rTransferAmount,,,) = _getValues(tAmount, _tFeePercent); (,uint256 rTransferAmount,,,) = _getValues(tAmount, _tFeePercent);
return rTransferAmount; return rTransferAmount;
} }
} }
function tokenFromRefraction(uint256 rAmount) public view returns(uint256) { function tokenFromRefraction(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total refractions"); require(rAmount <= _rTotal, "Amount must be less than total refractions");
uint256 currentRate = _getRate(); uint256 currentRate = _getRate();
return rAmount.div(currentRate); return rAmount.div(currentRate);
} }
function excludeAccount(address account) public onlyOwner() { function excludeAccount(address account) public onlyOwner() {
require(!_isExcluded[account], "Account is already excluded"); require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) { if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromRefraction(_rOwned[account]); _tOwned[account] = tokenFromRefraction(_rOwned[account]);
} }
_isExcluded[account] = true; _isExcluded[account] = true;
_excluded.push(account); _excluded.push(account);
} }
function includeAccount(address account) public onlyOwner() { function includeAccount(address account) public onlyOwner() {
require(_isExcluded[account], "Account is already excluded"); require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) { for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) { if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1]; _excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0; _tOwned[account] = 0;
_isExcluded[account] = false; _isExcluded[account] = false;
_excluded.pop(); _excluded.pop();
break; break;
} }
} }
} }
function _approve(address owner, address spender, uint256 amount) internal override { function _approve(address owner, address spender, uint256 amount) internal override {
require(owner != address(0), "ERC20: approve from the zero address"); require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address"); require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount; _allowances[owner][spender] = amount;
emit Approval(owner, spender, amount); emit Approval(owner, spender, amount);
} }
function _transfer(address sender, address recipient, uint256 amount) internal override { function _transfer(address sender, address recipient, uint256 amount) internal override {
require(sender != address(0), "ERC20: transfer from the zero address"); require(sender != address(0), "ERC20: transfer from the zero address");
require(amount > 0, "Transfer amount must be greater than zero"); require(amount > 0, "Transfer amount must be greater than zero");
require(endSale || sender == owner() || sender == address(this), "transfer paused for sale"); require(endSale || sender == owner() || sender == address(this), "transfer paused for sale");
if(sender == address(this) || sender == owner()) { if(sender == address(this) || sender == owner()) {
_transferBothExcluded(sender, recipient, amount, 0); _transferBothExcluded(sender, recipient, amount, 0);
} else if(_isExcluded[sender] && !_isExcluded[recipient]) { } else if(_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount, _tFeePercent); _transferFromExcluded(sender, recipient, amount, _tFeePercent);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) { } else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount, _tFeePercent); _transferToExcluded(sender, recipient, amount, _tFeePercent);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) { } else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount, _tFeePercent); _transferStandard(sender, recipient, amount, _tFeePercent);
} else if (_isExcluded[sender] && _isExcluded[recipient]) { } else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount, 0); _transferBothExcluded(sender, recipient, amount, 0);
} else { } else {
_transferStandard(sender, recipient, amount, _tFeePercent); _transferStandard(sender, recipient, amount, _tFeePercent);
} }
} }
function _transferStandard(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private { function _transferStandard(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent);
_rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_refractFee(rFee, tFee); _refractFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount); emit Transfer(sender, recipient, tTransferAmount);
} }
function _transferToExcluded(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private { function _transferToExcluded(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent);
_rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_refractFee(rFee, tFee); _refractFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount); emit Transfer(sender, recipient, tTransferAmount);
} }
function _transferFromExcluded(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private { function _transferFromExcluded(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent);
_tOwned[sender] = _tOwned[sender].sub(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_refractFee(rFee, tFee); _refractFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount); emit Transfer(sender, recipient, tTransferAmount);
} }
function _transferBothExcluded(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private { function _transferBothExcluded(address sender, address recipient, uint256 tAmount, uint256 tFeePercent) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, tFeePercent);
_tOwned[sender] = _tOwned[sender].sub(tAmount); _tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount); _rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount); _tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount); _rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_refractFee(rFee, tFee); _refractFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount); emit Transfer(sender, recipient, tTransferAmount);
} }
function _refractFee(uint256 rFee, uint256 tFee) private { function _refractFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee); _rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee); _tFeeTotal = _tFeeTotal.add(tFee);
} }
function _getValues(uint256 tAmount, uint256 tFeePercent) private view returns (uint256, uint256, uint256, uint256, uint256) { function _getValues(uint256 tAmount, uint256 tFeePercent) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount, tFeePercent); (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount, tFeePercent);
uint256 currentRate = _getRate(); uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
} }
function _getTValues(uint256 tAmount, uint256 tFeePercent) private pure returns (uint256, uint256) { function _getTValues(uint256 tAmount, uint256 tFeePercent) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.mul(tFeePercent).div(10000); uint256 tFee = tAmount.mul(tFeePercent).div(10000);
uint256 tTransferAmount = tAmount.sub(tFee); uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee); return (tTransferAmount, tFee);
} }
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) { function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate); uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate); uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee); uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee); return (rAmount, rTransferAmount, rFee);
} }
function _getRate() private view returns(uint256) { function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); (uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply); return rSupply.div(tSupply);
} }
function _getCurrentSupply() private view returns(uint256, uint256) { function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal; uint256 rSupply = _rTotal;
uint256 tSupply = _totalSupply; uint256 tSupply = _totalSupply;
for (uint256 i = 0; i < _excluded.length; i++) { for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _totalSupply); if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _totalSupply);
rSupply = rSupply.sub(_rOwned[_excluded[i]]); rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]);
} }
if (rSupply < _rTotal.div(_totalSupply)) return (_rTotal, _totalSupply); if (rSupply < _rTotal.div(_totalSupply)) return (_rTotal, _totalSupply);
return (rSupply, tSupply); return (rSupply, tSupply);
} }
}}
Editor
Clear
Export as PDF
Original Text
Changed Text