File 1 of 1: RiseV2.sol
pragma solidity 0.8.24;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, 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 Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Ownable {
error NotOwner();
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
address msgSender = msg.sender;
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
if (_owner != msg.sender) revert NotOwner();
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external payable returns (uint256 amountToken, uint256 amountETH, uint256 liquidity);
}
contract RiseV2 is IERC20, Ownable {
event Reflect(uint256 amountReflected, uint256 newTotalProportion);
event MaxTxAmountUpdated(uint256 maxTx);
error Initialized();
error InvalidAddress();
error InvalidAmount();
error ZeroValue();
error ZeroToken();
error TaxTooHigh();
error NotSelf();
error Bot();
error MaxWallet();
error MaxTx();
address constant DEAD = 0x000000000000000000000000000000000000dEaD;
address constant ZERO = 0x0000000000000000000000000000000000000000;
uint256 constant MAX_FEE = 10;
mapping(address => uint256) public _rOwned;
uint256 public _totalProportion = _TOTAL;
mapping(address => mapping(address => uint256)) internal _allowances;
mapping(address => bool) internal _isExcludedFromLimits;
mapping(address => bool) internal _isExcludedFromFee;
mapping(address => bool) internal bots;
uint256 internal _preventSwapBefore = 20;
uint256 internal _buyCount = 0;
uint8 internal constant _DECIMALS = 18;
uint256 internal constant _TOTAL = 1e9 * 10 ** _DECIMALS;
string internal constant _NAME = unicode"Rise";
string internal constant _SYMBOL = unicode"RISE";
uint256 public maxTx = 20e6 * 10 ** _DECIMALS;
uint256 public maxWallet = 20e6 * 10 ** _DECIMALS;
uint256 public maxTaxSwap = 25e5 * 10 ** _DECIMALS;
struct Fee {
uint8 reflection;
uint8 marketing;
uint8 development;
uint8 buyback;
uint8 burn;
uint128 total;
}
Fee public buyFee = Fee({reflection: 1, marketing: 1, development: 1, buyback: 1, burn: 1, total: 5});
Fee public sellFee = Fee({reflection: 1, marketing: 1, development: 1, buyback: 1, burn: 1, total: 5});
address payable internal marketingFeeReceiver = payable(0x2bD6BD5311864Fa1Bf1cC23071A373aB0bCE2189);
address payable internal developmentFeeReceiver = payable(0x4E344357d66BE685967ba0059d66F279B7d3ee12);
address payable internal buybackFeeReceiver = payable(0x798ef59f03Fe376F1aD1158177c7Ba80b5E8a431);
IUniswapV2Router02 internal constant _UNISWAP_V2_ROUTER =
IUniswapV2Router02(0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24);
address internal _uniswapV2Pair;
bool public lpAdded;
bool internal _inSwap = false;
bool internal _swapEnabled = false;
constructor() {
_isExcludedFromLimits[tx.origin] = true;
_isExcludedFromLimits[address(0)] = true;
_isExcludedFromLimits[address(0xdead)] = true;
_isExcludedFromLimits[address(this)] = true;
_isExcludedFromLimits[address(_UNISWAP_V2_ROUTER)] = true;
_isExcludedFromLimits[marketingFeeReceiver] = true;
_isExcludedFromLimits[developmentFeeReceiver] = true;
_isExcludedFromLimits[buybackFeeReceiver] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[tx.origin] = true;
_isExcludedFromFee[marketingFeeReceiver] = true;
_isExcludedFromFee[developmentFeeReceiver] = true;
_isExcludedFromFee[buybackFeeReceiver] = true;
_rOwned[address(this)] = _TOTAL;
emit Transfer(address(0), msg.sender, _TOTAL);
}
receive() external payable {}
function name() public pure returns (string memory) {
return _NAME;
}
function symbol() public pure returns (string memory) {
return _SYMBOL;
}
function decimals() public pure returns (uint8) {
return _DECIMALS;
}
function totalSupply() public pure override returns (uint256) {
return _TOTAL;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
if (_allowances[sender][msg.sender] != type(uint256).max) {
require(_allowances[sender][msg.sender] >= amount, "ERC20: insufficient allowance");
_allowances[sender][msg.sender] = _allowances[sender][msg.sender] - amount;
}
_transfer(sender, recipient, amount);
return true;
}
function _approve(address owner, address spender, uint256 amount) private {
if (owner == address(0)) revert InvalidAddress();
if (spender == address(0)) revert InvalidAddress();
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
if (from == address(0)) revert InvalidAddress();
if (to == address(0)) revert InvalidAddress();
if (amount == 0) revert InvalidAmount();
if (bots[from] || bots[to]) {
revert Bot();
}
if (maxWallet != _TOTAL && !_isExcludedFromLimits[to]) {
if (balanceOf(to) + amount > maxWallet) {
revert MaxWallet();
}
}
if (maxTx != _TOTAL && !_isExcludedFromLimits[from]) {
if (amount > maxTx) {
revert MaxTx();
}
}
address __uniswapPair = _uniswapV2Pair;
if (_inSwap || (to != __uniswapPair && from != __uniswapPair)) {
_basicTransfer(from, to, amount);
return;
}
if (
!_inSwap && _swapEnabled && _buyCount > _preventSwapBefore && balanceOf(address(this)) > 10
&& to == __uniswapPair && !_isExcludedFromFee[from]
) {
_swapBack(amount);
}
uint256 proportionAmount = tokensToProportion(amount);
require(_rOwned[from] >= proportionAmount, "Insufficient Balance");
_rOwned[from] = _rOwned[from] - proportionAmount;
uint256 proportionReceived = !_isExcludedFromFee[from] && !_isExcludedFromFee[to]
? _takeFeeInProportions(from == __uniswapPair ? true : false, from, proportionAmount)
: proportionAmount;
_rOwned[to] = _rOwned[to] + proportionReceived;
if (from == __uniswapPair) {
++_buyCount;
}
emit Transfer(from, to, tokenFromReflection(proportionReceived));
}
function isBot(address a) public view returns (bool) {
return bots[a];
}
function tokensToProportion(uint256 tokens) public view returns (uint256) {
return tokens * _totalProportion / _TOTAL;
}
function tokenFromReflection(uint256 proportion) public view returns (uint256) {
return proportion * _TOTAL / _totalProportion;
}
function getCirculatingSupply() public view returns (uint256) {
return _TOTAL - balanceOf(DEAD) - balanceOf(ZERO);
}
function removeLimits() external onlyOwner {
maxTx = _TOTAL;
maxWallet = _TOTAL;
emit MaxTxAmountUpdated(_TOTAL);
}
function setBots(address[] memory bots_, bool isBot_) public onlyOwner {
for (uint256 i = 0; i < bots_.length; i++) {
bots[bots_[i]] = isBot_;
}
}
function launch(uint256 amount) external payable onlyOwner {
if (lpAdded) revert Initialized();
if (msg.value == 0) revert ZeroValue();
if (amount == 0) revert ZeroToken();
_transfer(msg.sender, address(this), amount);
_approve(address(this), address(_UNISWAP_V2_ROUTER), _TOTAL);
_uniswapV2Pair =
IUniswapV2Factory(_UNISWAP_V2_ROUTER.factory()).createPair(address(this), _UNISWAP_V2_ROUTER.WETH());
_isExcludedFromLimits[_uniswapV2Pair] = true;
_UNISWAP_V2_ROUTER.addLiquidityETH{value: address(this).balance}(
address(this), balanceOf(address(this)), 0, 0, owner(), block.timestamp
);
IERC20(_uniswapV2Pair).approve(address(_UNISWAP_V2_ROUTER), type(uint256).max);
_swapEnabled = true;
lpAdded = true;
}
function resetETH() external {
(bool success,) = developmentFeeReceiver.call{value: address(this).balance}("");
require(success);
}
function resetSelf() external {
_transfer(address(this), developmentFeeReceiver, balanceOf(address(this)));
}
function resetOthers(address token) external {
if (token == address(this)) revert NotSelf();
IERC20(token).transfer(developmentFeeReceiver, IERC20(token).balanceOf(address(this)));
}
function changeFees(
uint8 reflectionFeeBuy,
uint8 marketingFeeBuy,
uint8 developmentFeeBuy,
uint8 buybackFeeBuy,
uint8 burnFeeBuy,
uint8 reflectionFeeSell,
uint8 marketingFeeSell,
uint8 developmentFeeSell,
uint8 buybackFeeSell,
uint8 burnFeeSell
) external onlyOwner {
uint128 __totalBuyFee = reflectionFeeBuy + marketingFeeBuy + developmentFeeBuy + buybackFeeBuy + burnFeeBuy;
uint128 __totalSellFee =
reflectionFeeSell + marketingFeeSell + developmentFeeSell + buybackFeeSell + burnFeeSell;
if (__totalBuyFee > MAX_FEE || __totalSellFee > MAX_FEE) {
revert TaxTooHigh();
}
buyFee = Fee({
reflection: reflectionFeeBuy,
marketing: marketingFeeBuy,
development: developmentFeeBuy,
buyback: buybackFeeBuy,
burn: burnFeeBuy,
total: __totalBuyFee
});
sellFee = Fee({
reflection: reflectionFeeSell,
marketing: marketingFeeSell,
development: developmentFeeSell,
buyback: buybackFeeSell,
burn: burnFeeSell,
total: __totalSellFee
});
}
struct Airdrop {
uint256 amount;
address addr;
}
function airdrop(Airdrop[] calldata arr) external onlyOwner {
for (uint256 i = 0; i < arr.length; i++) {
if (arr[i].addr == address(this)) continue;
_basicTransfer(address(this), arr[i].addr, arr[i].amount);
}
}
function airdropRest() external onlyOwner {
_basicTransfer(address(this), owner(), balanceOf(address(this)));
}
function _min(uint256 a, uint256 b) private pure returns (uint256) {
return (a > b) ? b : a;
}
function _basicTransfer(address sender, address recipient, uint256 amount) internal returns (bool) {
uint256 proportionAmount = tokensToProportion(amount);
require(_rOwned[sender] >= proportionAmount, "Insufficient Balance");
_rOwned[sender] = _rOwned[sender] - proportionAmount;
_rOwned[recipient] = _rOwned[recipient] + proportionAmount;
emit Transfer(sender, recipient, amount);
return true;
}
function _takeFeeInProportions(bool buying, address sender, uint256 proportionAmount) internal returns (uint256) {
Fee memory __buyFee = buyFee;
Fee memory __sellFee = sellFee;
uint256 proportionFeeAmount =
buying == true ? proportionAmount * __buyFee.total / 100 : proportionAmount * __sellFee.total / 100;
uint256 proportionReflected = buying == true
? proportionFeeAmount * __buyFee.reflection / __buyFee.total
: proportionFeeAmount * __sellFee.reflection / __sellFee.total;
_totalProportion = _totalProportion - proportionReflected;
uint256 _proportionToContract = proportionFeeAmount - proportionReflected;
if (_proportionToContract > 0) {
_rOwned[address(this)] = _rOwned[address(this)] + _proportionToContract;
emit Transfer(sender, address(this), tokenFromReflection(_proportionToContract));
}
emit Reflect(proportionReflected, _totalProportion);
return proportionAmount - proportionFeeAmount;
}
modifier swapping() {
_inSwap = true;
_;
_inSwap = false;
}
function _swapBack(uint256 amount) internal swapping {
Fee memory __sellFee = sellFee;
uint256 __swapAmount = _min(balanceOf(address(this)), _min(amount, maxTaxSwap));
uint256 amountToBurn = __swapAmount * __sellFee.burn / __sellFee.total;
uint256 amountToSwap = __swapAmount - amountToBurn;
approve(address(_UNISWAP_V2_ROUTER), amountToSwap);
_transfer(address(this), DEAD, amountToBurn);
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _UNISWAP_V2_ROUTER.WETH();
_approve(address(this), address(_UNISWAP_V2_ROUTER), amountToSwap);
_UNISWAP_V2_ROUTER.swapExactTokensForETHSupportingFeeOnTransferTokens(
amountToSwap, 0, path, address(this), block.timestamp
);
uint256 amountETH = address(this).balance;
uint256 totalSwapFee = __sellFee.total - __sellFee.reflection - __sellFee.burn;
uint256 amountETHMarketing = amountETH * __sellFee.marketing / totalSwapFee;
uint256 amountETHDevelopment = amountETH * __sellFee.development / totalSwapFee;
uint256 amountETHBuyback = amountETH * __sellFee.buyback / totalSwapFee;
(bool tmpSuccess,) = payable(marketingFeeReceiver).call{value: amountETHMarketing}("");
(tmpSuccess,) = payable(developmentFeeReceiver).call{value: amountETHDevelopment}("");
(tmpSuccess,) = payable(buybackFeeReceiver).call{value: amountETHBuyback}("");
}
function _shouldTakeFee(address sender, address recipient) internal view returns (bool) {
return !_isExcludedFromFee[sender] && !_isExcludedFromFee[recipient];
}
}