Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"StableStrategy.sol": {
"content": "/*\r
\r
The Perpetual Stable Machine - powered by $STBLSTR\r
\r
https://x.com/stablestrategy \r
https://t.me/stablestrategy \r
https://stablestrategy.fun \r
\r
*/\r
\r
pragma solidity >=0.6.2;\r
\r
interface IUniswapV2Router01 {\r
function factory() external pure returns (address);\r
function WETH() external pure returns (address);\r
\r
function addLiquidity(\r
address tokenA,\r
address tokenB,\r
uint amountADesired,\r
uint amountBDesired,\r
uint amountAMin,\r
uint amountBMin,\r
address to,\r
uint deadline\r
) external returns (uint amountA, uint amountB, uint liquidity);\r
function addLiquidityETH(\r
address token,\r
uint amountTokenDesired,\r
uint amountTokenMin,\r
uint amountETHMin,\r
address to,\r
uint deadline\r
) external payable returns (uint amountToken, uint amountETH, uint liquidity);\r
function removeLiquidity(\r
address tokenA,\r
address tokenB,\r
uint liquidity,\r
uint amountAMin,\r
uint amountBMin,\r
address to,\r
uint deadline\r
) external returns (uint amountA, uint amountB);\r
function removeLiquidityETH(\r
address token,\r
uint liquidity,\r
uint amountTokenMin,\r
uint amountETHMin,\r
address to,\r
uint deadline\r
) external returns (uint amountToken, uint amountETH);\r
function removeLiquidityWithPermit(\r
address tokenA,\r
address tokenB,\r
uint liquidity,\r
uint amountAMin,\r
uint amountBMin,\r
address to,\r
uint deadline,\r
bool approveMax, uint8 v, bytes32 r, bytes32 s\r
) external returns (uint amountA, uint amountB);\r
function removeLiquidityETHWithPermit(\r
address token,\r
uint liquidity,\r
uint amountTokenMin,\r
uint amountETHMin,\r
address to,\r
uint deadline,\r
bool approveMax, uint8 v, bytes32 r, bytes32 s\r
) external returns (uint amountToken, uint amountETH);\r
function swapExactTokensForTokens(\r
uint amountIn,\r
uint amountOutMin,\r
address[] calldata path,\r
address to,\r
uint deadline\r
) external returns (uint[] memory amounts);\r
function swapTokensForExactTokens(\r
uint amountOut,\r
uint amountInMax,\r
address[] calldata path,\r
address to,\r
uint deadline\r
) external returns (uint[] memory amounts);\r
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)\r
external\r
payable\r
returns (uint[] memory amounts);\r
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)\r
external\r
returns (uint[] memory amounts);\r
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)\r
external\r
returns (uint[] memory amounts);\r
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)\r
external\r
payable\r
returns (uint[] memory amounts);\r
\r
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);\r
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);\r
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);\r
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);\r
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);\r
}\r
\r
// File: @uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol\r
\r
\r
\r
pragma solidity >=0.6.2;\r
\r
\r
interface IUniswapV2Router02 is IUniswapV2Router01 {\r
function removeLiquidityETHSupportingFeeOnTransferTokens(\r
address token,\r
uint liquidity,\r
uint amountTokenMin,\r
uint amountETHMin,\r
address to,\r
uint deadline\r
) external returns (uint amountETH);\r
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\r
address token,\r
uint liquidity,\r
uint amountTokenMin,\r
uint amountETHMin,\r
address to,\r
uint deadline,\r
bool approveMax, uint8 v, bytes32 r, bytes32 s\r
) external returns (uint amountETH);\r
\r
function swapExactTokensForTokensSupportingFeeOnTransferTokens(\r
uint amountIn,\r
uint amountOutMin,\r
address[] calldata path,\r
address to,\r
uint deadline\r
) external;\r
function swapExactETHForTokensSupportingFeeOnTransferTokens(\r
uint amountOutMin,\r
address[] calldata path,\r
address to,\r
uint deadline\r
) external payable;\r
function swapExactTokensForETHSupportingFeeOnTransferTokens(\r
uint amountIn,\r
uint amountOutMin,\r
address[] calldata path,\r
address to,\r
uint deadline\r
) external;\r
}\r
\r
// File: @uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol\r
\r
\r
\r
pragma solidity >=0.5.0;\r
\r
interface IUniswapV2Factory {\r
event PairCreated(address indexed token0, address indexed token1, address pair, uint);\r
\r
function feeTo() external view returns (address);\r
function feeToSetter() external view returns (address);\r
\r
function getPair(address tokenA, address tokenB) external view returns (address pair);\r
function allPairs(uint) external view returns (address pair);\r
function allPairsLength() external view returns (uint);\r
\r
function createPair(address tokenA, address tokenB) external returns (address pair);\r
\r
function setFeeTo(address) external;\r
function setFeeToSetter(address) external;\r
}\r
\r
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol\r
\r
\r
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)\r
\r
pragma solidity ^0.8.0;\r
\r
/**\r
* @dev Contract module that helps prevent reentrant calls to a function.\r
*\r
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r
* available, which can be applied to functions to make sure there are no nested\r
* (reentrant) calls to them.\r
*\r
* Note that because there is a single `nonReentrant` guard, functions marked as\r
* `nonReentrant` may not call one another. This can be worked around by making\r
* those functions `private`, and then adding `external` `nonReentrant` entry\r
* points to them.\r
*\r
* TIP: If you would like to learn more about reentrancy and alternative ways\r
* to protect against it, check out our blog post\r
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r
*/\r
abstract contract ReentrancyGuard {\r
// Booleans are more expensive than uint256 or any type that takes up a full\r
// word because each write operation emits an extra SLOAD to first read the\r
// slot's contents, replace the bits taken up by the boolean, and then write\r
// back. This is the compiler's defense against contract upgrades and\r
// pointer aliasing, and it cannot be disabled.\r
\r
// The values being non-zero value makes deployment a bit more expensive,\r
// but in exchange the refund on every call to nonReentrant will be lower in\r
// amount. Since refunds are capped to a percentage of the total\r
// transaction's gas, it is best to keep them low in cases like this one, to\r
// increase the likelihood of the full refund coming into effect.\r
uint256 private constant _NOT_ENTERED = 1;\r
uint256 private constant _ENTERED = 2;\r
\r
uint256 private _status;\r
\r
constructor() {\r
_status = _NOT_ENTERED;\r
}\r
\r
/**\r
* @dev Prevents a contract from calling itself, directly or indirectly.\r
* Calling a `nonReentrant` function from another `nonReentrant`\r
* function is not supported. It is possible to prevent this from happening\r
* by making the `nonReentrant` function external, and making it call a\r
* `private` function that does the actual work.\r
*/\r
modifier nonReentrant() {\r
_nonReentrantBefore();\r
_;\r
_nonReentrantAfter();\r
}\r
\r
function _nonReentrantBefore() private {\r
// On the first call to nonReentrant, _status will be _NOT_ENTERED\r
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");\r
\r
// Any calls to nonReentrant after this point will fail\r
_status = _ENTERED;\r
}\r
\r
function _nonReentrantAfter() private {\r
// By storing the original value once again, a refund is triggered (see\r
// https://eips.ethereum.org/EIPS/eip-2200)\r
_status = _NOT_ENTERED;\r
}\r
\r
/**\r
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a\r
* `nonReentrant` function in the call stack.\r
*/\r
function _reentrancyGuardEntered() internal view returns (bool) {\r
return _status == _ENTERED;\r
}\r
}\r
\r
pragma solidity ^0.8.19;\r
\r
/**\r
* @dev Wrappers over Solidity's arithmetic operations.\r
*\r
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler\r
* now has built in overflow checking.\r
*/\r
library SafeMath {\r
/**\r
* @dev Returns the addition of two unsigned integers, with an overflow flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\r
unchecked {\r
uint256 c = a + b;\r
if (c < a) return (false, 0);\r
return (true, c);\r
}\r
}\r
\r
/**\r
* @dev Returns the substraction of two unsigned integers, with an overflow flag.\r
*\r
* _Available since v3.4._\r
*/\r
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\r
unchecked {\r
if (b > a) return (false, 0);\r
return (true, a - b);\r
}\r
}\r
\r
/**\r
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\r
unchecked {\r
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the\r
// benefit is lost if 'b' is also tested.\r
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\r
if (a == 0) return (true, 0);\r
uint256 c = a * b;\r
if (c / a != b) return (false, 0);\r
return (true, c);\r
}\r
}\r
\r
/**\r
* @dev Returns the division of two unsigned integers, with a division by zero flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\r
unchecked {\r
if (b == 0) return (false, 0);\r
return (true, a / b);\r
}\r
}\r
\r
/**\r
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\r
*\r
* _Available since v3.4._\r
*/\r
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\r
unchecked {\r
if (b == 0) return (false, 0);\r
return (true, a % b);\r
}\r
}\r
\r
/**\r
* @dev Returns the addition of two unsigned integers, reverting on\r
* overflow.\r
*\r
* Counterpart to Solidity's `+` operator.\r
*\r
* Requirements:\r
*\r
* - Addition cannot overflow.\r
*/\r
function add(uint256 a, uint256 b) internal pure returns (uint256) {\r
return a + b;\r
}\r
\r
/**\r
* @dev Returns the subtraction of two unsigned integers, reverting on\r
* overflow (when the result is negative).\r
*\r
* Counterpart to Solidity's `-` operator.\r
*\r
* Requirements:\r
*\r
* - Subtraction cannot overflow.\r
*/\r
function sub(uint256 a, uint256 b) internal pure returns (uint256) {\r
return a - b;\r
}\r
\r
/**\r
* @dev Returns the multiplication of two unsigned integers, reverting on\r
* overflow.\r
*\r
* Counterpart to Solidity's `*` operator.\r
*\r
* Requirements:\r
*\r
* - Multiplication cannot overflow.\r
*/\r
function mul(uint256 a, uint256 b) internal pure returns (uint256) {\r
return a * b;\r
}\r
\r
/**\r
* @dev Returns the integer division of two unsigned integers, reverting on\r
* division by zero. The result is rounded towards zero.\r
*\r
* Counterpart to Solidity's `/` operator.\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function div(uint256 a, uint256 b) internal pure returns (uint256) {\r
return a / b;\r
}\r
\r
/**\r
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r
* reverting when dividing by zero.\r
*\r
* Counterpart to Solidity's `%` operator. This function uses a `revert`\r
* opcode (which leaves remaining gas untouched) while Solidity uses an\r
* invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function mod(uint256 a, uint256 b) internal pure returns (uint256) {\r
return a % b;\r
}\r
\r
/**\r
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on\r
* overflow (when the result is negative).\r
*\r
* CAUTION: This function is deprecated because it requires allocating memory for the error\r
* message unnecessarily. For custom revert reasons use {trySub}.\r
*\r
* Counterpart to Solidity's `-` operator.\r
*\r
* Requirements:\r
*\r
* - Subtraction cannot overflow.\r
*/\r
function sub(\r
uint256 a,\r
uint256 b,\r
string memory errorMessage\r
) internal pure returns (uint256) {\r
unchecked {\r
require(b <= a, errorMessage);\r
return a - b;\r
}\r
}\r
\r
/**\r
* @dev Returns the integer division of two unsigned integers, reverting with custom message on\r
* division by zero. The result is rounded towards zero.\r
*\r
* Counterpart to Solidity's `/` operator. Note: this function uses a\r
* `revert` opcode (which leaves remaining gas untouched) while Solidity\r
* uses an invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function div(\r
uint256 a,\r
uint256 b,\r
string memory errorMessage\r
) internal pure returns (uint256) {\r
unchecked {\r
require(b > 0, errorMessage);\r
return a / b;\r
}\r
}\r
\r
/**\r
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\r
* reverting with custom message when dividing by zero.\r
*\r
* CAUTION: This function is deprecated because it requires allocating memory for the error\r
* message unnecessarily. For custom revert reasons use {tryMod}.\r
*\r
* Counterpart to Solidity's `%` operator. This function uses a `revert`\r
* opcode (which leaves remaining gas untouched) while Solidity uses an\r
* invalid opcode to revert (consuming all remaining gas).\r
*\r
* Requirements:\r
*\r
* - The divisor cannot be zero.\r
*/\r
function mod(\r
uint256 a,\r
uint256 b,\r
string memory errorMessage\r
) internal pure returns (uint256) {\r
unchecked {\r
require(b > 0, errorMessage);\r
return a % b;\r
}\r
}\r
}\r
\r
pragma solidity ^0.8.0; \r
\r
/**\r
* @dev Interface of the ERC20 standard as defined in the EIP.\r
*/\r
interface IERC20 {\r
/**\r
* @dev Returns the amount of tokens in existence.\r
*/\r
function totalSupply() external view returns (uint256);\r
\r
/**\r
* @dev Returns the amount of tokens owned by `account`.\r
*/\r
function balanceOf(address account) external view returns (uint256);\r
\r
/**\r
* @dev Moves `amount` tokens from the caller's account to `recipient`.\r
*\r
* Returns a boolean value indicating whether the operation succeeded.\r
*\r
* Emits a {Transfer} event.\r
*/\r
function transfer(address recipient, uint256 amount) external returns (bool);\r
\r
/**\r
* @dev Returns the remaining number of tokens that `spender` will be\r
* allowed to spend on behalf of `owner` through {transferFrom}. This is\r
* zero by default.\r
*\r
* This value changes when {approve} or {transferFrom} are called.\r
*/\r
function allowance(address owner, address spender) external view returns (uint256);\r
\r
/**\r
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\r
*\r
* Returns a boolean value indicating whether the operation succeeded.\r
*\r
* IMPORTANT: Beware that changing an allowance with this method brings the risk\r
* that someone may use both the old and the new allowance by unfortunate\r
* transaction ordering. One possible solution to mitigate this race\r
* condition is to first reduce the spender's allowance to 0 and set the\r
* desired value afterwards:\r
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r
*\r
* Emits an {Approval} event.\r
*/\r
function approve(address spender, uint256 amount) external returns (bool);\r
\r
/**\r
* @dev Moves `amount` tokens from `sender` to `recipient` using the\r
* allowance mechanism. `amount` is then deducted from the caller's\r
* allowance.\r
*\r
* Returns a boolean value indicating whether the operation succeeded.\r
*\r
* Emits a {Transfer} event.\r
*/\r
function transferFrom(\r
address sender,\r
address recipient,\r
uint256 amount\r
) external returns (bool);\r
\r
/**\r
* @dev Emitted when `value` tokens are moved from one account (`from`) to\r
* another (`to`).\r
*\r
* Note that `value` may be zero.\r
*/\r
event Transfer(address indexed from, address indexed to, uint256 value);\r
\r
/**\r
* @dev Emitted when the allowance of a `spender` for an `owner` is set by\r
* a call to {approve}. `value` is the new allowance.\r
*/\r
event Approval(address indexed owner, address indexed spender, uint256 value);\r
}\r
\r
\r
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)\r
\r
pragma solidity ^0.8.0;\r
\r
\r
/**\r
* @dev Interface for the optional metadata functions from the ERC20 standard.\r
*/\r
interface IERC20Metadata is IERC20 {\r
/**\r
* @dev Returns the name of the token.\r
*/\r
function name() external view returns (string memory);\r
\r
/**\r
* @dev Returns the symbol of the token.\r
*/\r
function symbol() external view returns (string memory);\r
\r
/**\r
* @dev Returns the decimals places of the token.\r
*/\r
function decimals() external view returns (uint8);\r
}\r
\r
\r
\r
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)\r
\r
pragma solidity ^0.8.19;\r
\r
/**\r
* @dev Provides information about the current execution context, including the\r
* sender of the transaction and its data. While these are generally available\r
* via msg.sender and msg.data, they should not be accessed in such a direct\r
* manner, since when dealing with meta-transactions the account sending and\r
* paying for execution may not be the actual sender (as far as an application\r
* is concerned).\r
*\r
* This contract is only required for intermediate, library-like contracts.\r
*/\r
abstract contract Context {\r
function _msgSender() internal view virtual returns (address) {\r
return msg.sender;\r
}\r
\r
function _msgData() internal view virtual returns (bytes calldata) {\r
return msg.data;\r
}\r
}\r
\r
\r
pragma solidity ^0.8.0;\r
\r
\r
\r
\r
/**\r
* @dev Implementation of the {IERC20} interface.\r
*\r
* This implementation is agnostic to the way tokens are created. This means\r
* that a supply mechanism has to be added in a derived contract using {_mint}.\r
* For a generic mechanism see {ERC20PresetMinterPauser}.\r
*\r
* TIP: For a detailed writeup see our guide\r
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\r
* to implement supply mechanisms].\r
*\r
* We have followed general OpenZeppelin Contracts guidelines: functions revert\r
* instead returning `false` on failure. This behavior is nonetheless\r
* conventional and does not conflict with the expectations of ERC20\r
* applications.\r
*\r
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.\r
* This allows applications to reconstruct the allowance for all accounts just\r
* by listening to said events. Other implementations of the EIP may not emit\r
* these events, as it isn't required by the specification.\r
*\r
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\r
* functions have been added to mitigate the well-known issues around setting\r
* allowances. See {IERC20-approve}.\r
*/\r
contract ERC20 is Context, IERC20, IERC20Metadata {\r
mapping(address => uint256) private _balances;\r
\r
mapping(address => mapping(address => uint256)) private _allowances;\r
\r
uint256 private _totalSupply;\r
\r
string private _name;\r
string private _symbol;\r
\r
/**\r
* @dev Sets the values for {name} and {symbol}.\r
*\r
* The default value of {decimals} is 18. To select a different value for\r
* {decimals} you should overload it.\r
*\r
* All two of these values are immutable: they can only be set once during\r
* construction.\r
*/\r
constructor(string memory name_, string memory symbol_) {\r
_name = name_;\r
_symbol = symbol_;\r
}\r
\r
/**\r
* @dev Returns the name of the token.\r
*/\r
function name() public view virtual override returns (string memory) {\r
return _name;\r
}\r
\r
/**\r
* @dev Returns the symbol of the token, usually a shorter version of the\r
* name.\r
*/\r
function symbol() public view virtual override returns (string memory) {\r
return _symbol;\r
}\r
\r
/**\r
* @dev Returns the number of decimals used to get its user representation.\r
* For example, if `decimals` equals `2`, a balance of `505` tokens should\r
* be displayed to a user as `5.05` (`505 / 10 ** 2`).\r
*\r
* Tokens usually opt for a value of 18, imitating the relationship between\r
* Ether and Wei. This is the value {ERC20} uses, unless this function is\r
* overridden;\r
*\r
* NOTE: This information is only used for _display_ purposes: it in\r
* no way affects any of the arithmetic of the contract, including\r
* {IERC20-balanceOf} and {IERC20-transfer}.\r
*/\r
function decimals() public view virtual override returns (uint8) {\r
return 18;\r
}\r
\r
/**\r
* @dev See {IERC20-totalSupply}.\r
*/\r
function totalSupply() public view virtual override returns (uint256) {\r
return _totalSupply;\r
}\r
\r
/**\r
* @dev See {IERC20-balanceOf}.\r
*/\r
function balanceOf(address account) public view virtual override returns (uint256) {\r
return _balances[account];\r
}\r
\r
/**\r
* @dev See {IERC20-transfer}.\r
*\r
* Requirements:\r
*\r
* - `recipient` cannot be the zero address.\r
* - the caller must have a balance of at least `amount`.\r
*/\r
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {\r
_transfer(_msgSender(), recipient, amount);\r
return true;\r
}\r
\r
/**\r
* @dev See {IERC20-allowance}.\r
*/\r
function allowance(address owner, address spender) public view virtual override returns (uint256) {\r
return _allowances[owner][spender];\r
}\r
\r
/**\r
* @dev See {IERC20-approve}.\r
*\r
* Requirements:\r
*\r
* - `spender` cannot be the zero address.\r
*/\r
function approve(address spender, uint256 amount) public virtual override returns (bool) {\r
_approve(_msgSender(), spender, amount);\r
return true;\r
}\r
\r
/**\r
* @dev See {IERC20-transferFrom}.\r
*\r
* Emits an {Approval} event indicating the updated allowance. This is not\r
* required by the EIP. See the note at the beginning of {ERC20}.\r
*\r
* Requirements:\r
*\r
* - `sender` and `recipient` cannot be the zero address.\r
* - `sender` must have a balance of at least `amount`.\r
* - the caller must have allowance for ``sender``'s tokens of at least\r
* `amount`.\r
*/\r
function transferFrom(\r
address sender,\r
address recipient,\r
uint256 amount\r
) public virtual override returns (bool) {\r
_transfer(sender, recipient, amount);\r
\r
uint256 currentAllowance = _allowances[sender][_msgSender()];\r
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");\r
unchecked {\r
_approve(sender, _msgSender(), currentAllowance - amount);\r
}\r
\r
return true;\r
}\r
\r
/**\r
* @dev Atomically increases the allowance granted to `spender` by the caller.\r
*\r
* This is an alternative to {approve} that can be used as a mitigation for\r
* problems described in {IERC20-approve}.\r
*\r
* Emits an {Approval} event indicating the updated allowance.\r
*\r
* Requirements:\r
*\r
* - `spender` cannot be the zero address.\r
*/\r
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\r
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);\r
return true;\r
}\r
\r
/**\r
* @dev Atomically decreases the allowance granted to `spender` by the caller.\r
*\r
* This is an alternative to {approve} that can be used as a mitigation for\r
* problems described in {IERC20-approve}.\r
*\r
* Emits an {Approval} event indicating the updated allowance.\r
*\r
* Requirements:\r
*\r
* - `spender` cannot be the zero address.\r
* - `spender` must have allowance for the caller of at least\r
* `subtractedValue`.\r
*/\r
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\r
uint256 currentAllowance = _allowances[_msgSender()][spender];\r
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");\r
unchecked {\r
_approve(_msgSender(), spender, currentAllowance - subtractedValue);\r
}\r
\r
return true;\r
}\r
\r
/**\r
* @dev Moves `amount` of tokens from `sender` to `recipient`.\r
*\r
* This internal function is equivalent to {transfer}, and can be used to\r
* e.g. implement automatic token fees, slashing mechanisms, etc.\r
*\r
* Emits a {Transfer} event.\r
*\r
* Requirements:\r
*\r
* - `sender` cannot be the zero address.\r
* - `recipient` cannot be the zero address.\r
* - `sender` must have a balance of at least `amount`.\r
*/\r
function _transfer(\r
address sender,\r
address recipient,\r
uint256 amount\r
) internal virtual {\r
require(sender != address(0), "ERC20: transfer from the zero address");\r
require(recipient != address(0), "ERC20: transfer to the zero address");\r
\r
_beforeTokenTransfer(sender, recipient, amount);\r
\r
uint256 senderBalance = _balances[sender];\r
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");\r
unchecked {\r
_balances[sender] = senderBalance - amount;\r
}\r
_balances[recipient] += amount;\r
\r
emit Transfer(sender, recipient, amount);\r
\r
_afterTokenTransfer(sender, recipient, amount);\r
}\r
\r
/** @dev Creates `amount` tokens and assigns them to `account`, increasing\r
* the total supply.\r
*\r
* Emits a {Transfer} event with `from` set to the zero address.\r
*\r
* Requirements:\r
*\r
* - `account` cannot be the zero address.\r
*/\r
function _mint(address account, uint256 amount) internal virtual {\r
require(account != address(0), "ERC20: mint to the zero address");\r
\r
_beforeTokenTransfer(address(0), account, amount);\r
\r
_totalSupply += amount;\r
_balances[account] += amount;\r
emit Transfer(address(0), account, amount);\r
\r
_afterTokenTransfer(address(0), account, amount);\r
}\r
\r
/**\r
* @dev Destroys `amount` tokens from `account`, reducing the\r
* total supply.\r
*\r
* Emits a {Transfer} event with `to` set to the zero address.\r
*\r
* Requirements:\r
*\r
* - `account` cannot be the zero address.\r
* - `account` must have at least `amount` tokens.\r
*/\r
function _burn(address account, uint256 amount) internal virtual {\r
require(account != address(0), "ERC20: burn from the zero address");\r
\r
_beforeTokenTransfer(account, address(0), amount);\r
\r
uint256 accountBalance = _balances[account];\r
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");\r
unchecked {\r
_balances[account] = accountBalance - amount;\r
}\r
_totalSupply -= amount;\r
\r
emit Transfer(account, address(0), amount);\r
\r
_afterTokenTransfer(account, address(0), amount);\r
}\r
\r
/**\r
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\r
*\r
* This internal function is equivalent to `approve`, and can be used to\r
* e.g. set automatic allowances for certain subsystems, etc.\r
*\r
* Emits an {Approval} event.\r
*\r
* Requirements:\r
*\r
* - `owner` cannot be the zero address.\r
* - `spender` cannot be the zero address.\r
*/\r
function _approve(\r
address owner,\r
address spender,\r
uint256 amount\r
) internal virtual {\r
require(owner != address(0), "ERC20: approve from the zero address");\r
require(spender != address(0), "ERC20: approve to the zero address");\r
\r
_allowances[owner][spender] = amount;\r
emit Approval(owner, spender, amount);\r
}\r
\r
/**\r
* @dev Hook that is called before any transfer of tokens. This includes\r
* minting and burning.\r
*\r
* Calling conditions:\r
*\r
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r
* will be transferred to `to`.\r
* - when `from` is zero, `amount` tokens will be minted for `to`.\r
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.\r
* - `from` and `to` are never both zero.\r
*\r
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r
*/\r
function _beforeTokenTransfer(\r
address from,\r
address to,\r
uint256 amount\r
) internal virtual {}\r
\r
/**\r
* @dev Hook that is called after any transfer of tokens. This includes\r
* minting and burning.\r
*\r
* Calling conditions:\r
*\r
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\r
* has been transferred to `to`.\r
* - when `from` is zero, `amount` tokens have been minted for `to`.\r
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.\r
* - `from` and `to` are never both zero.\r
*\r
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\r
*/\r
function _afterTokenTransfer(\r
address from,\r
address to,\r
uint256 amount\r
) internal virtual {}\r
}\r
\r
\r
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\r
\r
pragma solidity ^0.8.19;\r
\r
\r
/**\r
* @dev Contract module which provides a basic access control mechanism, where\r
* there is an account (an owner) that can be granted exclusive access to\r
* specific functions.\r
*\r
* By default, the owner account will be the one that deploys the contract. This\r
* can later be changed with {transferOwnership}.\r
*\r
* This module is used through inheritance. It will make available the modifier\r
* `onlyOwner`, which can be applied to your functions to restrict their use to\r
* the owner.\r
*/\r
abstract contract Ownable is Context {\r
address private _owner;\r
\r
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\r
\r
/**\r
* @dev Initializes the contract setting the deployer as the initial owner.\r
*/\r
constructor() {\r
_transferOwnership(_msgSender());\r
}\r
\r
/**\r
* @dev Returns the address of the current owner.\r
*/\r
function owner() public view virtual returns (address) {\r
return _owner;\r
}\r
\r
/**\r
* @dev Throws if called by any account other than the owner.\r
*/\r
modifier onlyOwner() {\r
require(owner() == _msgSender(), "Ownable: caller is not the owner");\r
_;\r
}\r
\r
/**\r
* @dev Leaves the contract without owner. It will not be possible to call\r
* `onlyOwner` functions anymore. Can only be called by the current owner.\r
*\r
* NOTE: Renouncing ownership will leave the contract without an owner,\r
* thereby removing any functionality that is only available to the owner.\r
*/\r
function renounceOwnership() public virtual onlyOwner {\r
_transferOwnership(address(0));\r
}\r
\r
/**\r
* @dev Transfers ownership of the contract to a new account (`newOwner`).\r
* Can only be called by the current owner.\r
*/\r
function transferOwnership(address newOwner) public virtual onlyOwner {\r
require(newOwner != address(0), "Ownable: new owner is the zero address");\r
_transferOwnership(newOwner);\r
}\r
\r
/**\r
* @dev Transfers ownership of the contract to a new account (`newOwner`).\r
* Internal function without access restriction.\r
*/\r
function _transferOwnership(address newOwner) internal virtual {\r
address oldOwner = _owner;\r
_owner = newOwner;\r
emit OwnershipTransferred(oldOwner, newOwner);\r
}\r
}\r
\r
\r
pragma solidity ^0.8.30;\r
contract StableStrategy is ERC20, Ownable,ReentrancyGuard {\r
using SafeMath for uint256;\r
\r
IUniswapV2Router02 public immutable uniswapRouter;\r
address public uniswapV2Pair;\r
\r
address constant public USDT_TOKEN = payable(0xdAC17F958D2ee523a2206206994597C13D831ec7);\r
address constant public WETH_TOKEN = payable(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);\r
address constant public DEAD_ADDRESS = payable(0x000000000000000000000000000000000000dEaD);\r
\r
uint256 private constant PROFIT_BPS = 1050;\r
\r
struct Order {\r
uint256 ethSpent;\r
uint256 usdtBought;\r
uint256 timestamp;\r
bool sold; \r
}\r
\r
uint256 public nextOrderId = 1;\r
mapping(uint256 => Order) public orders;\r
\r
uint256 public minStableBuy = 1 ether;\r
uint256 public txCallerReward = 0.01 ether; \r
\r
uint256 public lastBuyBlock;\r
uint256 public lastSellBlock;\r
\r
bool private swapping;\r
\r
address public treasuryWallet;\r
address public teamWallet;\r
\r
uint256 public maxTransactionAmount;\r
uint256 public swapTokensAtAmount;\r
uint256 public maxWallet;\r
\r
bool public limitsInEffect = true;\r
bool public tradingActive = false;\r
bool public swapEnabled = false;\r
\r
uint256 public buyTotalFees;\r
uint256 public buyTreasuryFee;\r
\r
uint256 public sellTotalFees;\r
uint256 public sellTreasuryFee;\r
\r
uint256 public tokensForTreasury;\r
\r
\r
mapping(address => bool) private _isExcludedFromFees;\r
mapping(address => bool) public _isExcludedMaxTransactionAmount;\r
\r
mapping(address => bool) public automatedMarketMakerPairs;\r
\r
event UpdateUniswapRouter(\r
address indexed newAddress,\r
address indexed oldAddress\r
);\r
\r
event ExcludeFromFees(address indexed account, bool isExcluded);\r
\r
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);\r
\r
event treasuryWalletUpdated(\r
address indexed newWallet,\r
address indexed oldWallet\r
);\r
\r
constructor() ERC20("StableStrategy", "STBLSTR") {\r
IUniswapV2Router02 _uniswapRouter = IUniswapV2Router02(\r
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D \r
);\r
\r
excludeFromMaxTransaction(address(_uniswapRouter), true);\r
uniswapRouter = _uniswapRouter;\r
\r
uint256 _buyTreasuryFee = 50; // 50% off at launch, 10% normally\r
uint256 _sellTreasuryFee = 50; // 50% off at launch, 10% normally\r
\r
uint256 totalSupply = 1_000_000_000 * 1e18;\r
\r
maxTransactionAmount = totalSupply / 100;\r
maxWallet = totalSupply / 100;\r
swapTokensAtAmount = (totalSupply * 5) / 10000; \r
\r
buyTreasuryFee = _buyTreasuryFee;\r
buyTotalFees = buyTreasuryFee;\r
\r
sellTreasuryFee = _sellTreasuryFee;\r
sellTotalFees = sellTreasuryFee;\r
\r
treasuryWallet = address(this);\r
teamWallet = msg.sender;\r
\r
excludeFromFees(owner(), true);\r
excludeFromFees(address(this), true);\r
\r
excludeFromMaxTransaction(owner(), true);\r
excludeFromMaxTransaction(address(this), true);\r
\r
_mint(msg.sender, totalSupply);\r
\r
lastBuyBlock = block.number - 5;\r
lastSellBlock = block.number - 5;\r
}\r
\r
receive() external payable {}\r
\r
function createPair() external onlyOwner {\r
uniswapV2Pair = IUniswapV2Factory(uniswapRouter.factory())\r
.createPair(address(this), uniswapRouter.WETH());\r
excludeFromMaxTransaction(address(uniswapV2Pair), true);\r
_setAutomatedMarketMakerPair(address(uniswapV2Pair), true);\r
}\r
\r
function enableTrading() external onlyOwner {\r
tradingActive = true;\r
swapEnabled = true;\r
}\r
\r
// remove limits after token is stable\r
function removeLimits() external onlyOwner returns (bool) {\r
limitsInEffect = false;\r
return true;\r
}\r
\r
// change the minimum amount of tokens to sell from fees\r
function updateSwapTokensAtAmount(uint256 newAmount)\r
external\r
onlyOwner\r
returns (bool)\r
{\r
swapTokensAtAmount = newAmount;\r
return true;\r
}\r
\r
function excludeFromMaxTransaction(address updAds, bool isEx)\r
public\r
onlyOwner\r
{\r
_isExcludedMaxTransactionAmount[updAds] = isEx;\r
}\r
\r
function updateSwapEnabled(bool enabled) external onlyOwner {\r
swapEnabled = enabled;\r
}\r
\r
function updateBuyFees(\r
uint256 _treasuryFee\r
) external onlyOwner {\r
buyTreasuryFee = _treasuryFee;\r
buyTotalFees = buyTreasuryFee;\r
}\r
\r
function updateSellFees(\r
uint256 _treasuryFee\r
) external onlyOwner {\r
sellTreasuryFee = _treasuryFee;\r
sellTotalFees = sellTreasuryFee;\r
}\r
\r
function excludeFromFees(address account, bool excluded) public onlyOwner {\r
_isExcludedFromFees[account] = excluded;\r
emit ExcludeFromFees(account, excluded);\r
}\r
\r
function setAutomatedMarketMakerPair(address pair, bool value)\r
public\r
onlyOwner\r
{\r
require(\r
pair != uniswapV2Pair,\r
"The pair cannot be removed from automatedMarketMakerPairs"\r
);\r
\r
_setAutomatedMarketMakerPair(pair, value);\r
}\r
\r
function _setAutomatedMarketMakerPair(address pair, bool value) private {\r
automatedMarketMakerPairs[pair] = value;\r
\r
emit SetAutomatedMarketMakerPair(pair, value);\r
}\r
\r
function isExcludedFromFees(address account) public view returns (bool) {\r
return _isExcludedFromFees[account];\r
}\r
\r
\r
function _transfer(\r
address from,\r
address to,\r
uint256 amount\r
) internal override {\r
require(from != address(0), "ERC20: transfer from the zero address");\r
require(to != address(0), "ERC20: transfer to the zero address");\r
\r
if (amount == 0) {\r
super._transfer(from, to, 0);\r
return;\r
}\r
\r
if (limitsInEffect) {\r
if (\r
from != owner() &&\r
to != owner() &&\r
to != address(0) &&\r
!swapping\r
) {\r
if (!tradingActive) {\r
require(\r
_isExcludedFromFees[from] || _isExcludedFromFees[to],\r
"Trading is not active."\r
);\r
}\r
\r
//when buy\r
if (\r
automatedMarketMakerPairs[from] &&\r
!_isExcludedMaxTransactionAmount[to]\r
) {\r
require(\r
amount <= maxTransactionAmount,\r
"Buy transfer amount exceeds the maxTransactionAmount."\r
);\r
require(\r
amount + balanceOf(to) <= maxWallet,\r
"Max wallet exceeded"\r
);\r
}\r
//when sell\r
else if (\r
automatedMarketMakerPairs[to] &&\r
!_isExcludedMaxTransactionAmount[from]\r
) {\r
require(\r
amount <= maxTransactionAmount,\r
"Sell transfer amount exceeds the maxTransactionAmount."\r
);\r
} else if (!_isExcludedMaxTransactionAmount[to]) {\r
require(\r
amount + balanceOf(to) <= maxWallet,\r
"Max wallet exceeded"\r
);\r
}\r
}\r
}\r
\r
uint256 contractTokenBalance = balanceOf(address(this));\r
\r
bool canSwap = contractTokenBalance >= swapTokensAtAmount;\r
\r
if (\r
canSwap &&\r
swapEnabled &&\r
!swapping &&\r
!automatedMarketMakerPairs[from] &&\r
!_isExcludedFromFees[from] &&\r
!_isExcludedFromFees[to]\r
) {\r
swapping = true;\r
\r
swapBack();\r
\r
swapping = false;\r
}\r
\r
bool takeFee = !swapping;\r
\r
// if any account belongs to _isExcludedFromFee account then remove the fee\r
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {\r
takeFee = false;\r
}\r
\r
uint256 fees = 0;\r
// only take fees on buys/sells, do not take on wallet transfers\r
if (takeFee) {\r
// on sell\r
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {\r
fees = amount.mul(sellTotalFees).div(100);\r
tokensForTreasury += (fees * sellTreasuryFee) / sellTotalFees;\r
}\r
// on buy\r
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {\r
fees = amount.mul(buyTotalFees).div(100);\r
tokensForTreasury += (fees * buyTreasuryFee) / buyTotalFees;\r
}\r
\r
if (fees > 0) {\r
super._transfer(from, address(this), fees);\r
}\r
\r
amount -= fees;\r
}\r
\r
super._transfer(from, to, amount);\r
}\r
\r
function swapTokensForEth(uint256 tokenAmount) private {\r
// generate the uniswap pair path of token -> weth\r
address[] memory path = new address[](2);\r
path[0] = address(this);\r
path[1] = uniswapRouter.WETH();\r
\r
_approve(address(this), address(uniswapRouter), tokenAmount);\r
\r
// make the swap\r
uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(\r
tokenAmount,\r
0, // accept any amount of ETH\r
path,\r
address(this),\r
block.timestamp\r
);\r
}\r
\r
function swapBack() private {\r
uint256 contractBalance = balanceOf(address(this));\r
uint256 totalTokensToSwap = tokensForTreasury;\r
bool success;\r
\r
if (contractBalance == 0 || totalTokensToSwap == 0) {\r
return;\r
}\r
\r
if (contractBalance > swapTokensAtAmount * 20) {\r
contractBalance = swapTokensAtAmount * 20;\r
}\r
\r
\r
uint256 amountToSwapForETH = contractBalance;\r
uint256 initialETHBalance = address(this).balance;\r
swapTokensForEth(amountToSwapForETH);\r
uint256 ethBalance = address(this).balance.sub(initialETHBalance);\r
tokensForTreasury = 0;\r
\r
uint256 teamShare = ethBalance.mul(20).div(100);\r
\r
if (teamWallet != address(0)) {\r
(success, ) = teamWallet.call{value: teamShare}("");\r
}\r
}\r
\r
/* usdt funcs */\r
\r
function executeStableStrategy() external nonReentrant{\r
require(block.number >= lastBuyBlock + 5, "executeStableStrategy cooldown: wait more blocks");\r
\r
uint256 treasuryBalance = address(this).balance;\r
require(treasuryBalance >= minStableBuy + txCallerReward, "Not enough ETH in treasury");\r
\r
uint256 beforeUsdtBalance = IERC20(USDT_TOKEN).balanceOf(address(this));\r
address[] memory path = new address[](2);\r
path[0] = uniswapRouter.WETH();\r
path[1] = USDT_TOKEN;\r
\r
uint256[] memory amounts = uniswapRouter.getAmountsOut(treasuryBalance - txCallerReward, path);\r
uint256 minOut = amounts[1] * 95 / 100; \r
uniswapRouter.swapExactETHForTokensSupportingFeeOnTransferTokens{value: treasuryBalance - txCallerReward}(\r
minOut, \r
path,\r
address(this),\r
block.timestamp\r
);\r
uint256 afterUsdtBalance = IERC20(USDT_TOKEN).balanceOf(address(this));\r
uint256 usdtBought = afterUsdtBalance - beforeUsdtBalance;\r
\r
uint256 orderId = nextOrderId++;\r
orders[orderId] = Order({\r
ethSpent: treasuryBalance - txCallerReward,\r
usdtBought: usdtBought,\r
timestamp: block.timestamp,\r
sold: false\r
});\r
\r
lastBuyBlock = block.number;\r
payable(msg.sender).transfer(txCallerReward);\r
\r
}\r
\r
function triggerSellStable(uint256 orderId) external nonReentrant{\r
require(block.number >= lastSellBlock + 5, "triggerSellStable cooldown: wait more blocks");\r
\r
Order storage order = orders[orderId];\r
require(!order.sold, "Already sold");\r
require(simulateSell(order.usdtBought) * 1000 >= order.ethSpent * PROFIT_BPS, "Profit threshold not met");\r
\r
require(IERC20(USDT_TOKEN).balanceOf(address(this)) >= order.usdtBought, "Not enough USDT in contract");\r
\r
IERC20(USDT_TOKEN).approve(address(uniswapRouter), 0);\r
IERC20(USDT_TOKEN).approve(address(uniswapRouter), order.usdtBought);\r
\r
address[] memory path = new address[](3); \r
path[0] = USDT_TOKEN;\r
path[1] = uniswapRouter.WETH();\r
path[2] = address(this);\r
\r
uint256[] memory amounts = uniswapRouter.getAmountsOut(order.usdtBought, path);\r
uint256 minOut = amounts[2] * 95 / 100;\r
\r
uniswapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens(\r
order.usdtBought,\r
minOut,\r
path,\r
address(DEAD_ADDRESS),\r
block.timestamp\r
);\r
\r
order.sold = true;\r
\r
lastSellBlock = block.number;\r
payable(msg.sender).transfer(txCallerReward);\r
\r
}\r
\r
function simulateSell(uint256 amountIn) public view returns (uint256 ethExpected) {\r
address[] memory path = new address[](2);\r
path[0] = USDT_TOKEN;\r
path[1] = uniswapRouter.WETH();\r
\r
uint[] memory amounts = uniswapRouter.getAmountsOut(amountIn, path);\r
ethExpected = amounts[1]; // path[1] = ETH (WETH)\r
}\r
\r
function stats() public view returns(uint256[] memory){\r
uint256[] memory data = new uint256[](3);\r
data[0] = IERC20(address(this)).balanceOf(DEAD_ADDRESS); // data0\r
data[1] = address(this).balance; // data1\r
data[2] = IERC20(USDT_TOKEN).balanceOf(address(this)); // data2\r
return data;\r
}\r
}"
}
},
"settings": {
"optimizer": {
"enabled": false,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"remappings": []
}
}}
Submitted on: 2025-10-04 21:37:34
Comments
Log in to comment.
No comments yet.