Address Contract Partially Verified
Address
0xC4c244F1dbCA07083feE35220D2169957c275e68
Balance
0 ETH
Nonce
1
Code Size
5742 bytes
Creator
0x8bF0C74D...F027 at tx 0x5384f07d...aed90f
Indexed Transactions
0
Contract Bytecode
5742 bytes
0x60806040526004361061014a575f3560e01c806395d89b41116100b3578063cb4ca6311161006d578063cb4ca631146103c3578063dd62ed3e146103f1578063e5a4a89b14610435578063e76779ba14610463578063f2fde38b14610482578063f7371c24146104a1575f80fd5b806395d89b41146103135780639a679cf6146103275780639e7d8d1d14610346578063a9059cbb14610366578063c04a541414610385578063c6a30647146103a4575f80fd5b8063313ce56711610104578063313ce5671461025857806370a0823114610279578063715018a6146102ad578063760bf186146102c1578063790ca413146102e15780638da5cb5b146102f6575f80fd5b806306fdde0314610155578063095ea7b31461017f5780630ab76f72146101ae578063141b4972146101fa57806318160ddd1461021b57806323b872dd14610239575f80fd5b3661015157005b5f80fd5b348015610160575f80fd5b506101696104d5565b6040516101769190611327565b60405180910390f35b34801561018a575f80fd5b5061019e610199366004611370565b610565565b6040519015158152602001610176565b3480156101b9575f80fd5b506101e26101c836600461139a565b600b6020525f90815260409020546001600160a01b031681565b6040516001600160a01b039091168152602001610176565b348015610205575f80fd5b506102196102143660046113bc565b61057e565b005b348015610226575f80fd5b506002545b604051908152602001610176565b348015610244575f80fd5b5061019e6102533660046113f7565b6105e4565b348015610263575f80fd5b5060125b60405160ff9091168152602001610176565b348015610284575f80fd5b5061022b61029336600461139a565b6001600160a01b03165f9081526020819052604090205490565b3480156102b8575f80fd5b50610219610607565b3480156102cc575f80fd5b5060055461026790600160a01b900460ff1681565b3480156102ec575f80fd5b5061022b60065481565b348015610301575f80fd5b506005546001600160a01b03166101e2565b34801561031e575f80fd5b5061016961061a565b348015610332575f80fd5b5061021961034136600461139a565b610629565b348015610351575f80fd5b5060055461026790600160a81b900460ff1681565b348015610371575f80fd5b5061019e610380366004611370565b6106e7565b348015610390575f80fd5b50600c546101e2906001600160a01b031681565b3480156103af575f80fd5b506102196103be3660046113bc565b6106f4565b3480156103ce575f80fd5b5061019e6103dd36600461139a565b60086020525f908152604090205460ff1681565b3480156103fc575f80fd5b5061022b61040b366004611435565b6001600160a01b039182165f90815260016020908152604080832093909416825291909152205490565b348015610440575f80fd5b5061019e61044f36600461139a565b60096020525f908152604090205460ff1681565b34801561046e575f80fd5b5061021961047d36600461139a565b61074f565b34801561048d575f80fd5b5061021961049c36600461139a565b610a5e565b3480156104ac575f80fd5b506101e26104bb36600461139a565b600a6020525f90815260409020546001600160a01b031681565b6060600380546104e490611461565b80601f016020809104026020016040519081016040528092919081815260200182805461051090611461565b801561055b5780601f106105325761010080835404028352916020019161055b565b820191905f5260205f20905b81548152906001019060200180831161053e57829003601f168201915b5050505050905090565b5f33610572818585610a9b565b60019150505b92915050565b610586610aad565b6001600160a01b0382165f81815260096020908152604091829020805460ff191685151590811790915591519182527faccac7931dadca88fa8d45f979e2a896d25d034582069b4d6dea021d9179fc28910160405180910390a25050565b5f336105f1858285610ada565b6105fc858585610b55565b506001949350505050565b61060f610aad565b6106185f610bb2565b565b6060600480546104e490611461565b610631610aad565b6001600160a01b0381166106965760405162461bcd60e51b815260206004820152602160248201527f45524332303a206e65772077616c6c6574206973207a65726f206164647265736044820152607360f81b60648201526084015b60405180910390fd5b600c80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907fd81320f087e35dbb474e65a2f1cbbb39d4847d40955b32e095656849410252ce905f90a35050565b5f33610572818585610b55565b6106fc610aad565b6001600160a01b0382165f81815260086020526040808220805460ff191685151590811790915590519092917f057dc60ecf6df48e0f4af40ef0f88074d41e0ce54a1fef20925cd23c6de0386091a35050565b610757610aad565b5f8190505f816001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610798573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107bc9190611499565b6001600160a01b031663c9c6539630846001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610807573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061082b9190611499565b6040516001600160e01b031960e085901b1681526001600160a01b039283166004820152911660248201526044016020604051808303815f875af1925050508015610893575060408051601f3d908101601f1916820190925261089091810190611499565b60015b1561089a57505b816001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108d6573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906108fa9190611499565b6001600160a01b031663e6a4390530846001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa158015610945573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109699190611499565b6040516001600160e01b031960e085901b1681526001600160a01b03928316600482015291166024820152604401602060405180830381865afa1580156109b2573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906109d69190611499565b6001600160a01b038082165f818152600960209081526040808320805460ff19166001179055600a82528083208054958a166001600160a01b03199687168117909155808452600b90925280832080549095168417909455925193945090927fd54807570472d7b5bc32453ebc95b1efff2caa5857145789dee1fc1658a09d3a9190a3505050565b610a66610aad565b6001600160a01b038116610a8f57604051631e4fbdf760e01b81525f600482015260240161068d565b610a9881610bb2565b50565b610aa88383836001610c03565b505050565b6005546001600160a01b031633146106185760405163118cdaa760e01b815233600482015260240161068d565b6001600160a01b038381165f908152600160209081526040808320938616835292905220545f198114610b4f5781811015610b4157604051637dc7a0d960e11b81526001600160a01b0384166004820152602481018290526044810183905260640161068d565b610b4f84848484035f610c03565b50505050565b6001600160a01b038316610b7e57604051634b637e8f60e11b81525f600482015260240161068d565b6001600160a01b038216610ba75760405163ec442f0560e01b81525f600482015260240161068d565b610aa8838383610cd5565b600580546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0905f90a35050565b6001600160a01b038416610c2c5760405163e602df0560e01b81525f600482015260240161068d565b6001600160a01b038316610c5557604051634a1406b160e11b81525f600482015260240161068d565b6001600160a01b038085165f9081526001602090815260408083209387168352929052208290558015610b4f57826001600160a01b0316846001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92584604051610cc791815260200190565b60405180910390a350505050565b6001600160a01b0382165f9081526009602052604090205460ff168015610cfc5750600654155b15610d0657426006555b60065415610e12575f60065442610d1d91906114c8565b600754909150610d349063ffffffff16601c6114db565b63ffffffff16811115610d5b576005805461ffff60a01b191661010160a11b179055610e10565b600754610d6f9063ffffffff16600e6114db565b63ffffffff168110610d95576005805461ffff60a01b191661018160a11b179055610e10565b60078054610dab9163ffffffff909116906114db565b63ffffffff168110610dd1576005805461ffff60a01b191661020160a11b179055610e10565b60075463ffffffff168110610dfa576005805461ffff60a01b191661050360a01b179055610e10565b6005805461ffff60a01b1916610a0360a01b1790555b505b6001600160a01b0383165f9081526009602052604090205460ff1680610e4f57506001600160a01b0382165f9081526009602052604090205460ff165b8015610e9557506001600160a01b0383165f9081526008602052604090205460ff1680610e9357506001600160a01b0382165f9081526008602052604090205460ff165b155b8015610eac5750600754640100000000900460ff16155b15611050576001600160a01b0382165f9081526009602052604081205460ff168015610ef057506001600160a01b038381165f908152600a60205260409020541615155b1561101057305f9081526020819052604081205490505f80856001600160a01b0316630902f1ac6040518163ffffffff1660e01b8152600401606060405180830381865afa158015610f44573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f68919061151e565b506001600160701b0391821693501690505f82610f85838661156a565b610f8f9190611581565b905066b1a2bc2ec500008110610fe157610fa9848861105b565b600c546040516001600160a01b03909116904780156108fc02915f818181858888f19350505050158015610fdf573d5f803e3d5ffd5b505b600554606490610ffb90600160a81b900460ff168861156a565b6110059190611581565b945050505050611037565b60055460649061102a90600160a01b900460ff168461156a565b6110349190611581565b90505b61104181836114c8565b915061104e843083611201565b505b610aa8838383611201565b6007805464010000000064ff00000000199091161790556001600160a01b038181165f908152600a60205260408082205481516002808252606082019093529316929081602001602082028036833701905050905030815f815181106110c3576110c36115a0565b60200260200101906001600160a01b031690816001600160a01b031681525050816001600160a01b031663ad5c46486040518163ffffffff1660e01b8152600401602060405180830381865afa15801561111f573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906111439190611499565b81600181518110611156576111566115a0565b60200260200101906001600160a01b031690816001600160a01b031681525050611181308386610a9b565b6001600160a01b03821663791ac947855f84306111a04261012c6115b4565b6040518663ffffffff1660e01b81526004016111c09594939291906115c7565b5f604051808303815f87803b1580156111d7575f80fd5b505af11580156111e9573d5f803e3d5ffd5b50506007805464ff0000000019169055505050505050565b6001600160a01b03831661122b578060025f82825461122091906115b4565b9091555061129b9050565b6001600160a01b0383165f908152602081905260409020548181101561127d5760405163391434e360e21b81526001600160a01b0385166004820152602481018290526044810183905260640161068d565b6001600160a01b0384165f9081526020819052604090209082900390555b6001600160a01b0382166112b7576002805482900390556112d5565b6001600160a01b0382165f9081526020819052604090208054820190555b816001600160a01b0316836001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161131a91815260200190565b60405180910390a3505050565b602081525f82518060208401528060208501604085015e5f604082850101526040601f19601f83011684010191505092915050565b6001600160a01b0381168114610a98575f80fd5b5f8060408385031215611381575f80fd5b823561138c8161135c565b946020939093013593505050565b5f602082840312156113aa575f80fd5b81356113b58161135c565b9392505050565b5f80604083850312156113cd575f80fd5b82356113d88161135c565b9150602083013580151581146113ec575f80fd5b809150509250929050565b5f805f60608486031215611409575f80fd5b83356114148161135c565b925060208401356114248161135c565b929592945050506040919091013590565b5f8060408385031215611446575f80fd5b82356114518161135c565b915060208301356113ec8161135c565b600181811c9082168061147557607f821691505b60208210810361149357634e487b7160e01b5f52602260045260245ffd5b50919050565b5f602082840312156114a9575f80fd5b81516113b58161135c565b634e487b7160e01b5f52601160045260245ffd5b81810381811115610578576105786114b4565b63ffffffff8181168382160280821691908281146114fb576114fb6114b4565b505092915050565b80516001600160701b0381168114611519575f80fd5b919050565b5f805f60608486031215611530575f80fd5b61153984611503565b925061154760208501611503565b9150604084015163ffffffff8116811461155f575f80fd5b809150509250925092565b8082028115828204841417610578576105786114b4565b5f8261159b57634e487b7160e01b5f52601260045260245ffd5b500490565b634e487b7160e01b5f52603260045260245ffd5b80820180821115610578576105786114b4565b5f60a08201878352602087602085015260a0604085015281875180845260c0860191506020890193505f5b818110156116175784516001600160a01b0316835293830193918301916001016115f2565b50506001600160a01b0396909616606085015250505060800152939250505056fea2646970667358221220dabadd675cb746dfe69a6ec275098281e04536510afe778f08647120bcd0a5f764736f6c63430008190033
Verified Source Code Partial Match
Compiler: v0.8.25+commit.b61c2a91
EVM: cancun
Optimization: Yes (200 runs)
Steak.sol 805 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;
/**
* @dev Interface for the DEX version 2 factory contract
*/
interface IDexV2Factory {
function createPair(
address tokenA,
address tokenB
) external returns (address pair);
function getPair(address tokenA, address tokenB) external view returns (address pair);
}
/**
* @dev Interface for the DEX version 2 router contract
*/
interface IDexV2Router {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
/**
* @dev Interface for the DEX version 2 pair contract
*/
interface IDexV2Pair {
function getReserves()
external
view
returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
}
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(
address owner,
address spender
) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
}
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(
address sender,
uint256 balance,
uint256 needed
);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(
address spender,
uint256 allowance,
uint256 needed
);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256))
private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(
address owner,
address spender
) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(
address spender,
uint256 value
) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(
address from,
address to,
uint256 value
) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(
address owner,
address spender,
uint256 value,
bool emitEvent
) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(
address owner,
address spender,
uint256 value
) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(
spender,
currentAllowance,
value
);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
/**
* @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.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @dev ERC20 token with taxation and liquidity swap functionalities.
*/
contract Steak is ERC20, Ownable {
uint8 public buyTaxPercentage = 3;
uint8 public sellTaxPercentage = 10;
uint256 public launchTime = 0;
uint32 private _day = 1 days;
bool private _inSwapAndLiquify;
mapping(address => bool) public isExcludedFromTax;
mapping(address => bool) public dexPairStatus;
mapping(address => address) public pairToRouter;
mapping(address => address) public routerToPair;
address public developmentWallet;
event TaxExclusionUpdated(address indexed account, bool indexed isExcluded);
event DevelopmentWalletChanged(address indexed oldWallet, address indexed newWallet);
event NewRouterAdded(address indexed routerAddress, address indexed pairAddress);
event DexPairStatusChanged(address indexed pair, bool status);
modifier lockTheSwap() {
_inSwapAndLiquify = true;
_;
_inSwapAndLiquify = false;
}
/**
* @dev Constructor to initialize the Steak token contract.
*/
constructor() ERC20("Steak", "STEAK") Ownable(msg.sender) {
_mint(msg.sender, 100_000 * 10 ** decimals());
developmentWallet = msg.sender;
isExcludedFromTax[msg.sender] = true;
}
/**
* @dev Adds a new DEX router to the contract.
* @param routerAddress The address of the new DEX router.
* Requirements:
* - Caller must be the owner of the contract.
*/
function addNewDexRouter(address routerAddress) public onlyOwner {
IDexV2Router newRouter = IDexV2Router(routerAddress);
address newPair;
try IDexV2Factory(newRouter.factory()).createPair(address(this), newRouter.WETH()){ }
catch { }
newPair = IDexV2Factory(newRouter.factory()).getPair(address(this), newRouter.WETH());
dexPairStatus[newPair] = true;
pairToRouter[newPair] = routerAddress;
routerToPair[routerAddress] = newPair;
emit NewRouterAdded(routerAddress, newPair);
}
/**
* @dev Sets the status of a DEX pair.
* @param pair The address of the DEX pair.
* @param status The status to set for the DEX pair.
* Requirements:
* - Caller must be the owner of the contract.
*/
function setDexPairStatus(address pair, bool status) external onlyOwner {
dexPairStatus[pair] = status;
emit DexPairStatusChanged(pair, status);
}
/**
* @dev Converts the accumulated tokens to ETH.
*/
function _swapTokensForEth(uint256 tokenAmount, address pair) private lockTheSwap {
IDexV2Router dexRouter = IDexV2Router(pairToRouter[pair]);
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = dexRouter.WETH();
_approve(address(this), address(dexRouter), tokenAmount);
dexRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
(block.timestamp + 300)
);
}
/**
* @dev Internal function to update balances and apply taxes on token transfers.
* @param from Address from which tokens are transferred.
* @param to Address to which tokens are transferred.
* @param value Amount of tokens transferred.
*/
function _update(address from, address to, uint256 value) internal override {
if (dexPairStatus[to] && launchTime == 0) { launchTime = block.timestamp; }
if (launchTime != 0) {
uint256 timePassedSinceLaunch = block.timestamp - launchTime;
if (timePassedSinceLaunch > (28 * _day)) {
buyTaxPercentage = sellTaxPercentage = 2;
}
else if (timePassedSinceLaunch >= (14 * _day)) {
buyTaxPercentage = 2;
sellTaxPercentage = 3;
}
else if (timePassedSinceLaunch >= (7 * _day)) {
buyTaxPercentage = 2;
sellTaxPercentage = 4;
}
else if (timePassedSinceLaunch >= _day) {
buyTaxPercentage = 3;
sellTaxPercentage = 5;
}
else {
buyTaxPercentage = 3;
sellTaxPercentage = 10;
}
}
if ((dexPairStatus[from] || dexPairStatus[to]) && !(isExcludedFromTax[from] || isExcludedFromTax[to]) && !_inSwapAndLiquify) {
uint256 taxValue;
if (dexPairStatus[to] && pairToRouter[to] != address(0)) { // sell
uint256 contractBalance = balanceOf(address(this));
uint256 tokenBalanceInPool;
uint256 ethBalanceInPool;
(tokenBalanceInPool, ethBalanceInPool, ) = IDexV2Pair(to).getReserves();
uint256 tokenWorth = (contractBalance * ethBalanceInPool) / tokenBalanceInPool;
if (tokenWorth >= 50000000000000000) {
_swapTokensForEth(contractBalance, to);
payable(developmentWallet).transfer(address(this).balance);
}
taxValue = (value * sellTaxPercentage) / 100;
}
else {
taxValue = (value * buyTaxPercentage) / 100;
}
value -= taxValue;
super._update(from, address(this), taxValue);
}
super._update(from, to, value);
}
/**
* @dev Sets the address of the new development wallet.
* @param newWallet The address of the new development wallet.
* Requirements:
* `newWallet` cannot be the zero address.
* Emits a {DevelopmentWalletChanged} event.
*/
function changeDevelopmentWallet(address newWallet) external onlyOwner {
require(newWallet != address(0), "ERC20: new wallet is zero address");
address oldWallet = developmentWallet;
developmentWallet = newWallet;
emit DevelopmentWalletChanged(oldWallet, newWallet);
}
/**
* @dev Excludes or includes an account from taxation.
* @param account The address of the account to be excluded or included.
* @param status The status to set for tax exclusion (true for exclusion, false for inclusion).
* Requirements:
* - The caller must be the contract owner.
*/
function excludeFromTax(address account, bool status) external onlyOwner {
isExcludedFromTax[account] = status;
emit TaxExclusionUpdated(account, status);
}
receive() external payable {}
}
Read Contract
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
buyTaxPercentage 0x760bf186 → uint8
decimals 0x313ce567 → uint8
developmentWallet 0xc04a5414 → address
dexPairStatus 0xe5a4a89b → bool
isExcludedFromTax 0xcb4ca631 → bool
launchTime 0x790ca413 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
pairToRouter 0xf7371c24 → address
routerToPair 0x0ab76f72 → address
sellTaxPercentage 0x9e7d8d1d → uint8
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
addNewDexRouter 0xe76779ba
address routerAddress
approve 0x095ea7b3
address spender
uint256 value
returns: bool
changeDevelopmentWallet 0x9a679cf6
address newWallet
excludeFromTax 0xc6a30647
address account
bool status
renounceOwnership 0x715018a6
No parameters
setDexPairStatus 0x141b4972
address pair
bool status
transfer 0xa9059cbb
address to
uint256 value
returns: bool
transferFrom 0x23b872dd
address from
address to
uint256 value
returns: bool
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address