// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.0 (utils/Address.sol)pragmasolidity ^0.8.0;/**
* @dev Collection of functions related to the address type
*/libraryAddress{
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/functionisContract(address account) internalviewreturns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in// construction, since the code is only stored at the end of the// constructor execution.uint256 size;
assembly {
size :=extcodesize(account)
}
return size >0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/functionsendValue(addresspayable recipient, uint256 amount) internal{
require(address(this).balance>= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/functionfunctionCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value
) internalreturns (bytesmemory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemory errorMessage
) internalreturns (bytesmemory) {
require(address(this).balance>= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytesmemory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target, bytesmemory data) internalviewreturns (bytesmemory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/functionfunctionStaticCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytesmemory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target, bytesmemory data) internalreturns (bytesmemory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/functionfunctionDelegateCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytesmemory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/functionverifyCallResult(bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalpurereturns (bytesmemory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if presentif (returndata.length>0) {
// The easiest way to bubble the revert reason is using memory via assemblyassembly {
let returndata_size :=mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Contract Source Code
File 2 of 10: Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)pragmasolidity ^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.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
}
Contract Source Code
File 3 of 10: IERC20.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)pragmasolidity ^0.8.0;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransfer(address recipient, uint256 amount) externalreturns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/functionallowance(address owner, address spender) externalviewreturns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/functionapprove(address spender, uint256 amount) externalreturns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/functiontransferFrom(address sender,
address recipient,
uint256 amount
) externalreturns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
}
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)pragmasolidity ^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.
*/abstractcontractOwnableisContext{
addressprivate _owner;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
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.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
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) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Contract Source Code
File 9 of 10: SafeMath.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol)pragmasolidity ^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.
*/librarySafeMath{
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/functiontryAdd(uint256 a, uint256 b) internalpurereturns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/functiontrySub(uint256 a, uint256 b) internalpurereturns (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._
*/functiontryMul(uint256 a, uint256 b) internalpurereturns (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/522if (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._
*/functiontryDiv(uint256 a, uint256 b) internalpurereturns (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._
*/functiontryMod(uint256 a, uint256 b) internalpurereturns (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.
*/functionadd(uint256 a, uint256 b) internalpurereturns (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.
*/functionsub(uint256 a, uint256 b) internalpurereturns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/functionmul(uint256 a, uint256 b) internalpurereturns (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.
*/functiondiv(uint256 a, uint256 b) internalpurereturns (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.
*/functionmod(uint256 a, uint256 b) internalpurereturns (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.
*/functionsub(uint256 a,
uint256 b,
stringmemory errorMessage
) internalpurereturns (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.
*/functiondiv(uint256 a,
uint256 b,
stringmemory errorMessage
) internalpurereturns (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.
*/functionmod(uint256 a,
uint256 b,
stringmemory errorMessage
) internalpurereturns (uint256) {
unchecked {
require(b >0, errorMessage);
return a % b;
}
}
}
Contract Source Code
File 10 of 10: acyc.sol
/**
All Coins Yield Capital: $ACYC
- The Meme Coin Index
- You aim for one moon shot, we grab them all.
Tokenomics:
- Buy side taxes:
- 10% of each buy goes to reflections.
- Sell side taxes:
- 5% of each sell to our proprietary trading algorithm; and
- 5% to the liquidity pool.
- You do the marketing
Distribution of profits from farming:
- 50% reflected back to token holders.
- 35% reflected back to farming pool.
- 15% to team and advisors.
Website:
https://acy.capital
Telegram:
https://t.me/ACYCapital
Twitter:
https://twitter.com/ACYCapital
Medium:
https://acycapital.medium.com
*/// SPDX-License-Identifier: MITpragmasolidity ^0.8.0;import"@openzeppelin/contracts/access/Ownable.sol";
import"@openzeppelin/contracts/token/ERC20/IERC20.sol";
import"@openzeppelin/contracts/utils/Address.sol";
import"@openzeppelin/contracts/utils/Context.sol";
import"@openzeppelin/contracts/utils/math/SafeMath.sol";
import"@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import"@uniswap/v2-core/contracts/interfaces/IUniswapV2Pair.sol";
import"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router01.sol";
import"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
// Contract implementationcontractAllCoinsYieldCapitalisContext, IERC20, Ownable{
usingSafeMathforuint256;
usingAddressforaddress;
// standard variablesstringprivate _name ="AllCoinsYieldCapital";
stringprivate _symbol ="ACYC";
uint8private _decimals =18;
// baseline token constructionuint256privateconstant MAX =~uint256(0);
uint256private _totalTokenSupply =1*10**12*10**_decimals;
uint256private _totalReflections = (MAX - (MAX % _totalTokenSupply));
uint256private _totalTaxesReflectedToHodlers;
uint256private _totalTaxesSentToTreasury;
mapping(address=>uint256) private _reflectionsOwned;
mapping(address=>mapping(address=>uint256)) private _allowances;
// taxes and feesaddresspayablepublic _treasuryAddress;
uint256private _currentTaxForReflections =10; // modified depending on context of txuint256private _currentTaxForTreasury =10; // modified depending on context of txuint256public _fixedTaxForReflections =10; // unchanged save by owner transactionuint256public _fixedTaxForTreasury =10; // unchanged save by owner transaction// tax exempt addressesmapping(address=>bool) private _isExcludedFromTaxes;
// uniswap matters -- n.b. we are married to this particular uniswap v2 pair// contract will not survive as is and will require migration if a new pool// is stood up on sushiswap, uniswapv3, etc.addressprivate uniDefault =0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
IUniswapV2Router02 publicimmutable uniswapV2Router;
boolprivate _inSwap =false;
addresspublicimmutable uniswapV2Pair;
// minimum tokens to initiate a swapuint256private _minimumTokensToSwap =10*10**3*10**_decimals;
modifierlockTheSwap() {
_inSwap =true;
_;
_inSwap =false;
}
constructor(addresspayable treasuryAddress, address router) {
require(
(treasuryAddress !=address(0)),
"Give me the treasury address"
);
_treasuryAddress = treasuryAddress;
_reflectionsOwned[_msgSender()] = _totalReflections;
// connect to uniswap routerif (router ==address(0)) {
router = uniDefault;
}
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(router);
// setup uniswap pairaddress _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Pair = _uniswapV2Pair;
uniswapV2Router = _uniswapV2Router;
// Exclude owner, treasury, and this contract from fee
_isExcludedFromTaxes[owner()] =true;
_isExcludedFromTaxes[address(this)] =true;
_isExcludedFromTaxes[_treasuryAddress] =true;
emit Transfer(address(0), _msgSender(), _totalTokenSupply);
}
// recieve ETH from uniswapV2Router when swapingreceive() externalpayable{
return;
}
// We expose this function to modify the address where the treasuryTax goesfunctionsetTreasuryAddress(addresspayable treasuryAddress) external{
require(_msgSender() == _treasuryAddress, "You cannot call this");
require(
(treasuryAddress !=address(0)),
"Give me the treasury address"
);
address _previousTreasuryAddress = _treasuryAddress;
_treasuryAddress = treasuryAddress;
_isExcludedFromTaxes[treasuryAddress] =true;
_isExcludedFromTaxes[_previousTreasuryAddress] =false;
}
// We allow the owner to set addresses that are unaffected by taxesfunctionexcludeFromTaxes(address account, bool excluded)
externalonlyOwner{
_isExcludedFromTaxes[account] = excluded;
}
// We expose these functions to be able to modify the fees and tx amountsfunctionsetReflectionsTax(uint256 tax) externalonlyOwner{
require(tax >=0&& tax <=10, "ERC20: tax out of band");
_currentTaxForReflections = tax;
_fixedTaxForReflections = tax;
}
functionsetTreasuryTax(uint256 tax) externalonlyOwner{
require(tax >=0&& tax <=10, "ERC20: tax out of band");
_currentTaxForTreasury = tax;
_fixedTaxForTreasury = tax;
}
// We expose these functions to be able to manual swap and sendfunctionmanualSend() externalonlyOwner{
uint256 _contractETHBalance =address(this).balance;
_sendETHToTreasury(_contractETHBalance);
}
functionmanualSwap() externalonlyOwner{
uint256 _contractBalance = balanceOf(address(this));
_swapTokensForEth(_contractBalance);
}
// public functions to do thingsfunctiontransfer(address recipient, uint256 amount)
publicoverridereturns (bool)
{
_transfer(_msgSender(), recipient, amount);
returntrue;
}
functionapprove(address spender, uint256 amount)
publicoverridereturns (bool)
{
_approve(_msgSender(), spender, amount);
returntrue;
}
// used by smart contracts rather than usersfunctiontransferFrom(address sender,
address recipient,
uint256 amount
) publicoverridereturns (bool) {
_transfer(sender, recipient, amount);
_approve(
sender,
_msgSender(),
_allowances[sender][_msgSender()].sub(
amount,
"ERC20: transfer amount exceeds allowance"
)
);
returntrue;
}
functionincreaseAllowance(address spender, uint256 addedValue)
publicvirtualreturns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].add(addedValue)
);
returntrue;
}
functiondecreaseAllowance(address spender, uint256 subtractedValue)
publicvirtualreturns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender].sub(
subtractedValue,
"ERC20: decreased allowance below zero"
)
);
returntrue;
}
functionname() publicviewreturns (stringmemory) {
return _name;
}
functionsymbol() publicviewreturns (stringmemory) {
return _symbol;
}
functiondecimals() publicviewreturns (uint8) {
return _decimals;
}
functiontotalSupply() publicviewoverridereturns (uint256) {
uint256 currentRate = _getRate();
return _totalReflections.div(currentRate);
}
functionisExcludedFromTaxes(address account) publicviewreturns (bool) {
return _isExcludedFromTaxes[account];
}
functiontotalTaxesSentToReflections() publicviewreturns (uint256) {
return tokensFromReflection(_totalTaxesReflectedToHodlers);
}
functiontotalTaxesSentToTreasury() publicviewreturns (uint256) {
return tokensFromReflection(_totalTaxesSentToTreasury);
}
functiongetETHBalance() publicviewreturns (uint256 balance) {
returnaddress(this).balance;
}
functionallowance(address owner, address spender)
publicviewoverridereturns (uint256)
{
return _allowances[owner][spender];
}
functionbalanceOf(address account) publicviewoverridereturns (uint256) {
return tokensFromReflection(_reflectionsOwned[account]);
}
functionreflectionFromToken(uint256 amountOfTokens,
bool deductTaxForReflections
) publicviewreturns (uint256) {
require(
amountOfTokens <= _totalTokenSupply,
"Amount must be less than supply"
);
if (!deductTaxForReflections) {
(uint256 reflectionsToDebit, , , ) = _getValues(amountOfTokens);
return reflectionsToDebit;
} else {
(, uint256 reflectionsToCredit, , ) = _getValues(amountOfTokens);
return reflectionsToCredit;
}
}
functiontokensFromReflection(uint256 amountOfReflections)
publicviewreturns (uint256)
{
require(
amountOfReflections <= _totalReflections,
"ERC20: Amount too large"
);
uint256 currentRate = _getRate();
return amountOfReflections.div(currentRate);
}
function_approve(address owner,
address spender,
uint256 amount
) private{
require(owner !=address(0), "ERC20: approve from 0 address");
require(spender !=address(0), "ERC20: approve to 0 address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
// transfer function that sets up the context so that the// _tokenTransfer function can do the accounting work// to perform the transfer functionfunction_transfer(address sender,
address recipient,
uint256 amountOfTokens
) private{
require(sender !=address(0), "ERC20: transfer from 0 address");
require(recipient !=address(0), "ERC20: transfer to 0 address");
require(amountOfTokens >0, "ERC20: Transfer more than zero");
// if either side of transfer account belongs to _isExcludedFromTaxes// account then remove the feebool takeFee =true;
if (_isExcludedFromTaxes[sender] || _isExcludedFromTaxes[recipient]) {
takeFee =false;
}
// check if we're buy side or sell side in a swap; if buy side apply// buy side taxes; if sell side then apply those taxes; duhbool buySide =false;
if (sender ==address(uniswapV2Pair)) {
buySide =true;
}
// based on context set the correct fee structureif (!takeFee) {
_setNoFees();
} elseif (buySide) {
_setBuySideFees();
} else {
_setSellSideFees();
}
// conduct the transfer
_tokenTransfer(sender, recipient, amountOfTokens);
// reset the fees for the next go around
_restoreAllFees();
}
// primary transfer function that does all the workfunction_tokenTransfer(address sender,
address recipient,
uint256 amountOfTokens
) private{
// when treasury transfers to the contract we automatically// remove these reflections from pool such that all token hodlers// benefit prorata and the treasury's reflections are removed.//// this allows for gas effective distribution of farming profits// to be returned cleanly to all token hodlers.//// we do not emit a Transfer event here because it is not strictly// speaking a transfer due to the lack of a recipientif (sender == _treasuryAddress && recipient ==address(this)) {
_manualReflect(amountOfTokens);
return;
}
// the below allows for a consolidated handling of the necessary// math to support the possible transfer+tax combinations
(
uint256 reflectionsToDebit, // senderuint256 reflectionsToCredit, // recipientuint256 reflectionsToRemove, // to all the hodlersuint256 reflectionsForTreasury // to treasury
) = _getValues(amountOfTokens);
// take taxes -- this is not a tax free zone ser
_takeTreasuryTax(reflectionsForTreasury);
_takeReflectionTax(reflectionsToRemove);
// we potentially do any "inline" swapping after the taxes are taken// so that we know if there's balance to take.uint256 contractTokenBalance = balanceOf(address(this));
bool overMinTokenBalance = contractTokenBalance >= _minimumTokensToSwap;
if (!_inSwap && overMinTokenBalance && reflectionsForTreasury !=0) {
_swapTokensForEth(contractTokenBalance);
}
uint256 contractETHBalance =address(this).balance;
if (contractETHBalance >0) {
_sendETHToTreasury(address(this).balance);
}
// debit the correct reflections from the sender's account and credit// the correct number of reflections to the recipient's (accounting for// taxes)
_reflectionsOwned[sender] = _reflectionsOwned[sender].sub(
reflectionsToDebit
);
_reflectionsOwned[recipient] = _reflectionsOwned[recipient].add(
reflectionsToCredit
);
// let the world knowemit Transfer(sender, recipient, reflectionsToCredit.div(_getRate()));
}
// allows for treasury to cleanly distribute earnings back to// tokenhodlers pro ratafunction_manualReflect(uint256 amountOfTokens) private{
uint256 currentRate = _getRate();
uint256 amountOfReflections = amountOfTokens.mul(currentRate);
// we remove the reflections from the treasury address and then// burn them by removing them from the reflections pool thus// reducing the denominator and "distributing" the reflections// to all hodlers pro rata
_reflectionsOwned[_treasuryAddress] = _reflectionsOwned[
_treasuryAddress
].sub(amountOfReflections);
_totalReflections = _totalReflections.sub(amountOfReflections);
}
// reflections are added to the balance of this contract and are// subsequently swapped out with the uniswap pair within the same// transaction; the resulting eth is transfered to the treasury.//// the below function is simple accounting which will not survive// to the end of the transaction as long as the totaly amount of// reflections taken by the tax are more than the _minimumTokensToSwap//// in the case where they are not more than _minimumTokensToSwap// the tokens will not be swapped due to gas concerns and will simply// accrue within the contract until the contract's acyc balance is// more than _minimumTokensToSwap at which time the automatic swap// will occur sending eth to the treasury.function_takeTreasuryTax(uint256 reflectionsForTreasury) private{
_reflectionsOwned[address(this)] = _reflectionsOwned[address(this)].add(
reflectionsForTreasury
);
_totalTaxesSentToTreasury = _totalTaxesSentToTreasury.add(
reflectionsForTreasury
);
}
// reflections are "reflected" back to hodlers via a mechanism which// seeks to simply remove the amount of the tax from the total reflection// pool. since the token balance is a simple product of the amount of// reflections a hodler has in their account to the ratio of all the// reflections to the total token supply, removing reflections is a// gas efficient way of applying a benefit to all hodlers pro rata as// it lowers the denominator in the ratio thus increasing the result// of the product. in other words, by removing reflections the// numbers folks care about go up.function_takeReflectionTax(uint256 reflectionsToRemove) private{
_totalReflections = _totalReflections.sub(reflectionsToRemove);
_totalTaxesReflectedToHodlers = _totalTaxesReflectedToHodlers.add(
reflectionsToRemove
);
}
// baking this in so deeply will mean if the uni v2 pool ever dries up// then the contract will effectively stop functioning and it will need// to be migratedfunction_swapTokensForEth(uint256 tokenAmount) privatelockTheSwap{
// generate the uniswap pair path of token -> wethaddress[] memory path =newaddress[](2);
path[0] =address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(_treasuryAddress),
block.timestamp
);
}
function_sendETHToTreasury(uint256 amount) private{
_treasuryAddress.transfer(amount);
}
// on buy side we collect tax and apply that to reflections; there is// no tax taken for the treasury on the buy sidefunction_setBuySideFees() private{
_currentTaxForReflections = _fixedTaxForReflections;
_currentTaxForTreasury =0;
}
// on sell side we collect tax and apply that to the treasury account;// there is no sell side tax taken for reflectionsfunction_setSellSideFees() private{
_currentTaxForReflections =0;
_currentTaxForTreasury = _fixedTaxForTreasury;
}
// if a tax exempt address is transfering we turn off all the taxesfunction_setNoFees() private{
_currentTaxForReflections =0;
_currentTaxForTreasury =0;
}
// once a transfer occurs we reset the taxes. this is strictly speaking// not necessary due to the construction of the transfer function which// will opinionated-ly always set the tax structure before performing// the math (in the functions below). however, for reasons of super-// stition it remainsfunction_restoreAllFees() private{
_currentTaxForReflections = _fixedTaxForReflections;
_currentTaxForTreasury = _fixedTaxForTreasury;
}
// this function is the primary math function which calculates the// proper accounting to support a transfer based on the context of// that transfer (buy side; sell side; tax free).function_getValues(uint256 amountOfTokens)
privateviewreturns (uint256,
uint256,
uint256,
uint256)
{
// given tokens split those out into what goes where (reflections,// treasury, and recipient)
(
uint256 tokensToTransfer,
uint256 tokensForReflections,
uint256 tokensForTreasury
) = _getTokenValues(amountOfTokens);
// given the proper split of tokens, turn those into reflections// based on the current ratio of _tokenTokenSupply:_totalReflectionsuint256 currentRate = _getRate();
uint256 reflectionsTotal = amountOfTokens.mul(currentRate);
uint256 reflectionsToTransfer = tokensToTransfer.mul(currentRate);
uint256 reflectionsToRemove = tokensForReflections.mul(currentRate);
uint256 reflectionsForTreasury = tokensForTreasury.mul(currentRate);
return (
reflectionsTotal,
reflectionsToTransfer,
reflectionsToRemove,
reflectionsForTreasury
);
}
// the golden and necssary function that allows us to calculate the// ratio of total token supply to total reflections on which the// entire token accounting infrastructure residesfunction_getRate() privateviewreturns (uint256) {
return _totalReflections.div(_totalTokenSupply);
}
// the below function calculates where tokens needs to go based on the// inputted amount of tokens. n.b., this function does not work in// reflections, those typically happen later in the processing when the// token distribution calculated by this function is turned to reflections// based on the golden ratio of total token supply to total reflections.function_getTokenValues(uint256 amountOfTokens)
privateviewreturns (uint256,
uint256,
uint256)
{
uint256 tokensForReflections = amountOfTokens
.mul(_currentTaxForReflections)
.div(100);
uint256 tokensForTreasury = amountOfTokens
.mul(_currentTaxForTreasury)
.div(100);
uint256 tokensToTransfer = amountOfTokens.sub(tokensForReflections).sub(
tokensForTreasury
);
return (tokensToTransfer, tokensForReflections, tokensForTreasury);
}
}