文件 1 的 1:EcoFrog.sol
pragma solidity ^0.8.20;
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
}
pragma solidity ^0.8.20;
interface IERC20Metadata is IERC20 {
function name() external view returns (string memory);
function symbol() external view returns (string memory);
function decimals() external view returns (uint8);
}
pragma solidity ^0.8.20;
abstract contract Initializable {
struct InitializableStorage {
uint64 _initialized;
bool _initializing;
}
bytes32 private constant INITIALIZABLE_STORAGE =
0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
error InvalidInitialization();
error NotInitializing();
event Initialized(uint64 version);
modifier initializer() {
InitializableStorage storage $ = _getInitializableStorage();
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
modifier reinitializer(uint64 version) {
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
modifier onlyInitializing() {
_checkInitializing();
_;
}
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
function _disableInitializers() internal virtual {
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
function _getInitializableStorage()
private
pure
returns (InitializableStorage storage $)
{
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}
pragma solidity ^0.8.0;
interface IERC20Upgradeable {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address to, uint256 amount) external returns (bool);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
pragma solidity ^0.8.20;
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {}
function __Context_init_unchained() internal onlyInitializing {}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
pragma solidity ^0.8.20;
interface IERC20Errors {
error ERC20InsufficientBalance(
address sender,
uint256 balance,
uint256 needed
);
error ERC20InvalidSender(address sender);
error ERC20InvalidReceiver(address receiver);
error ERC20InsufficientAllowance(
address spender,
uint256 allowance,
uint256 needed
);
error ERC20InvalidApprover(address approver);
error ERC20InvalidSpender(address spender);
}
interface IERC721Errors {
error ERC721InvalidOwner(address owner);
error ERC721NonexistentToken(uint256 tokenId);
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
error ERC721InvalidSender(address sender);
error ERC721InvalidReceiver(address receiver);
error ERC721InsufficientApproval(address operator, uint256 tokenId);
error ERC721InvalidApprover(address approver);
error ERC721InvalidOperator(address operator);
}
interface IERC1155Errors {
error ERC1155InsufficientBalance(
address sender,
uint256 balance,
uint256 needed,
uint256 tokenId
);
error ERC1155InvalidSender(address sender);
error ERC1155InvalidReceiver(address receiver);
error ERC1155MissingApprovalForAll(address operator, address owner);
error ERC1155InvalidApprover(address approver);
error ERC1155InvalidOperator(address operator);
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
pragma solidity ^0.8.20;
abstract contract ERC20Upgradeable is
Initializable,
ContextUpgradeable,
IERC20,
IERC20Metadata,
IERC20Errors
{
struct ERC20Storage {
mapping(address => uint256) _balances;
mapping(address => mapping(address => uint256)) _allowances;
uint256 _totalSupply;
string _name;
string _symbol;
}
bytes32 private constant ERC20StorageLocation =
0x52c63247e1f47db19d5ce0460030c497f067ca4cebf71ba98eeadabe20bace00;
function _getERC20Storage() private pure returns (ERC20Storage storage $) {
assembly {
$.slot := ERC20StorageLocation
}
}
function __ERC20_init(string memory name_, string memory symbol_)
internal
onlyInitializing
{
__ERC20_init_unchained(name_, symbol_);
}
function __ERC20_init_unchained(string memory name_, string memory symbol_)
internal
onlyInitializing
{
ERC20Storage storage $ = _getERC20Storage();
$._name = name_;
$._symbol = symbol_;
}
function name() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._name;
}
function symbol() public view virtual returns (string memory) {
ERC20Storage storage $ = _getERC20Storage();
return $._symbol;
}
function decimals() public view virtual returns (uint8) {
return 18;
}
function totalSupply() public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._totalSupply;
}
function balanceOf(address account) public view virtual returns (uint256) {
ERC20Storage storage $ = _getERC20Storage();
return $._balances[account];
}
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
function allowance(address owner, address spender)
public
view
virtual
returns (uint256)
{
ERC20Storage storage $ = _getERC20Storage();
return $._allowances[owner][spender];
}
function approve(address spender, uint256 value)
public
virtual
returns (bool)
{
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
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;
}
function _transfer(
address from,
address to,
uint256 value
) internal virtual {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
function _update(
address from,
address to,
uint256 value
) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
if (from == address(0)) {
$._totalSupply += value;
} else {
uint256 fromBalance = $._balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
$._balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
$._totalSupply -= value;
}
} else {
unchecked {
$._balances[to] += value;
}
}
emit Transfer(from, to, value);
}
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
function _approve(
address owner,
address spender,
uint256 value
) internal {
_approve(owner, spender, value, true);
}
function _approve(
address owner,
address spender,
uint256 value,
bool emitEvent
) internal virtual {
ERC20Storage storage $ = _getERC20Storage();
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);
}
}
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);
}
}
}
}
pragma solidity ^0.8.20;
abstract contract ERC20BurnableUpgradeable is
Initializable,
ContextUpgradeable,
ERC20Upgradeable
{
function __ERC20Burnable_init() internal onlyInitializing {}
function __ERC20Burnable_init_unchained() internal onlyInitializing {}
function burn(uint256 value) public virtual {
_burn(_msgSender(), value);
}
function burnFrom(address account, uint256 value) public virtual {
_spendAllowance(account, _msgSender(), value);
_burn(account, value);
}
}
pragma solidity ^0.8.20;
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
struct OwnableStorage {
address _owner;
}
bytes32 private constant OwnableStorageLocation =
0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;
function _getOwnableStorage()
private
pure
returns (OwnableStorage storage $)
{
assembly {
$.slot := OwnableStorageLocation
}
}
error OwnableUnauthorizedAccount(address account);
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
function __Ownable_init(address initialOwner) internal onlyInitializing {
__Ownable_init_unchained(initialOwner);
}
function __Ownable_init_unchained(address initialOwner)
internal
onlyInitializing
{
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
OwnableStorage storage $ = _getOwnableStorage();
return $._owner;
}
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
OwnableStorage storage $ = _getOwnableStorage();
address oldOwner = $._owner;
$._owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
pragma solidity ^0.8.20;
interface IERC1822Proxiable {
function proxiableUUID() external view returns (bytes32);
}
pragma solidity ^0.8.20;
interface IBeacon {
function implementation() external view returns (address);
}
pragma solidity ^0.8.20;
interface IERC1967 {
event Upgraded(address indexed implementation);
event AdminChanged(address previousAdmin, address newAdmin);
event BeaconUpgraded(address indexed beacon);
}
pragma solidity ^0.8.20;
library Errors {
error InsufficientBalance(uint256 balance, uint256 needed);
error FailedCall();
error FailedDeployment();
error MissingPrecompile(address);
}
pragma solidity ^0.8.20;
library Address {
error AddressEmptyCode(address target);
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert Errors.InsufficientBalance(address(this).balance, amount);
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert Errors.FailedCall();
}
}
function functionCall(address target, bytes memory data)
internal
returns (bytes memory)
{
return functionCallWithValue(target, data, 0);
}
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
if (address(this).balance < value) {
revert Errors.InsufficientBalance(address(this).balance, value);
}
(bool success, bytes memory returndata) = target.call{value: value}(
data
);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionStaticCall(address target, bytes memory data)
internal
view
returns (bytes memory)
{
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function functionDelegateCall(address target, bytes memory data)
internal
returns (bytes memory)
{
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
function verifyCallResult(bool success, bytes memory returndata)
internal
pure
returns (bytes memory)
{
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
function _revert(bytes memory returndata) private pure {
if (returndata.length > 0) {
assembly ("memory-safe") {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert Errors.FailedCall();
}
}
}
pragma solidity ^0.8.20;
library StorageSlot {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct Int256Slot {
int256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
function getAddressSlot(bytes32 slot)
internal
pure
returns (AddressSlot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getBooleanSlot(bytes32 slot)
internal
pure
returns (BooleanSlot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getBytes32Slot(bytes32 slot)
internal
pure
returns (Bytes32Slot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getUint256Slot(bytes32 slot)
internal
pure
returns (Uint256Slot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getInt256Slot(bytes32 slot)
internal
pure
returns (Int256Slot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getStringSlot(bytes32 slot)
internal
pure
returns (StringSlot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getStringSlot(string storage store)
internal
pure
returns (StringSlot storage r)
{
assembly ("memory-safe") {
r.slot := store.slot
}
}
function getBytesSlot(bytes32 slot)
internal
pure
returns (BytesSlot storage r)
{
assembly ("memory-safe") {
r.slot := slot
}
}
function getBytesSlot(bytes storage store)
internal
pure
returns (BytesSlot storage r)
{
assembly ("memory-safe") {
r.slot := store.slot
}
}
}
pragma solidity ^0.8.21;
library ERC1967Utils {
bytes32 internal constant IMPLEMENTATION_SLOT =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
error ERC1967InvalidImplementation(address implementation);
error ERC1967InvalidAdmin(address admin);
error ERC1967InvalidBeacon(address beacon);
error ERC1967NonPayable();
function getImplementation() internal view returns (address) {
return StorageSlot.getAddressSlot(IMPLEMENTATION_SLOT).value;
}
function _setImplementation(address newImplementation) private {
if (newImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(newImplementation);
}
StorageSlot
.getAddressSlot(IMPLEMENTATION_SLOT)
.value = newImplementation;
}
function upgradeToAndCall(address newImplementation, bytes memory data)
internal
{
_setImplementation(newImplementation);
emit IERC1967.Upgraded(newImplementation);
if (data.length > 0) {
Address.functionDelegateCall(newImplementation, data);
} else {
_checkNonPayable();
}
}
bytes32 internal constant ADMIN_SLOT =
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
function getAdmin() internal view returns (address) {
return StorageSlot.getAddressSlot(ADMIN_SLOT).value;
}
function _setAdmin(address newAdmin) private {
if (newAdmin == address(0)) {
revert ERC1967InvalidAdmin(address(0));
}
StorageSlot.getAddressSlot(ADMIN_SLOT).value = newAdmin;
}
function changeAdmin(address newAdmin) internal {
emit IERC1967.AdminChanged(getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
bytes32 internal constant BEACON_SLOT =
0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
function getBeacon() internal view returns (address) {
return StorageSlot.getAddressSlot(BEACON_SLOT).value;
}
function _setBeacon(address newBeacon) private {
if (newBeacon.code.length == 0) {
revert ERC1967InvalidBeacon(newBeacon);
}
StorageSlot.getAddressSlot(BEACON_SLOT).value = newBeacon;
address beaconImplementation = IBeacon(newBeacon).implementation();
if (beaconImplementation.code.length == 0) {
revert ERC1967InvalidImplementation(beaconImplementation);
}
}
function upgradeBeaconToAndCall(address newBeacon, bytes memory data)
internal
{
_setBeacon(newBeacon);
emit IERC1967.BeaconUpgraded(newBeacon);
if (data.length > 0) {
Address.functionDelegateCall(
IBeacon(newBeacon).implementation(),
data
);
} else {
_checkNonPayable();
}
}
function _checkNonPayable() private {
if (msg.value > 0) {
revert ERC1967NonPayable();
}
}
}
pragma solidity ^0.8.20;
abstract contract UUPSUpgradeable is Initializable, IERC1822Proxiable {
address private immutable __self = address(this);
string public constant UPGRADE_INTERFACE_VERSION = "5.0.0";
error UUPSUnauthorizedCallContext();
error UUPSUnsupportedProxiableUUID(bytes32 slot);
modifier onlyProxy() {
_checkProxy();
_;
}
modifier notDelegated() {
_checkNotDelegated();
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {}
function proxiableUUID()
external
view
virtual
notDelegated
returns (bytes32)
{
return ERC1967Utils.IMPLEMENTATION_SLOT;
}
function upgradeToAndCall(address newImplementation, bytes memory data)
public
payable
virtual
onlyProxy
{
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data);
}
function _checkProxy() internal view virtual {
if (
address(this) == __self ||
ERC1967Utils.getImplementation() != __self
) {
revert UUPSUnauthorizedCallContext();
}
}
function _checkNotDelegated() internal view virtual {
if (address(this) != __self) {
revert UUPSUnauthorizedCallContext();
}
}
function _authorizeUpgrade(address newImplementation) internal virtual;
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data)
private
{
try IERC1822Proxiable(newImplementation).proxiableUUID() returns (
bytes32 slot
) {
if (slot != ERC1967Utils.IMPLEMENTATION_SLOT) {
revert UUPSUnsupportedProxiableUUID(slot);
}
ERC1967Utils.upgradeToAndCall(newImplementation, data);
} catch {
revert ERC1967Utils.ERC1967InvalidImplementation(newImplementation);
}
}
}
pragma solidity ^0.8.0;
abstract contract ReentrancyGuard {
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
}
function _nonReentrantAfter() private {
_status = _NOT_ENTERED;
}
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
pragma solidity >=0.5.0;
interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB)
external
view
returns (address pair);
function allPairs(uint256) external view returns (address pair);
function allPairsLength() external view returns (uint256);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
pragma solidity >=0.6.2;
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETH(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountToken, uint256 amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountA, uint256 amountB);
function removeLiquidityETHWithPermit(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountToken, uint256 amountETH);
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapTokensForExactTokens(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapTokensForExactETH(
uint256 amountOut,
uint256 amountInMax,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function quote(
uint256 amountA,
uint256 reserveA,
uint256 reserveB
) external pure returns (uint256 amountB);
function getAmountOut(
uint256 amountIn,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountOut);
function getAmountIn(
uint256 amountOut,
uint256 reserveIn,
uint256 reserveOut
) external pure returns (uint256 amountIn);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
}
pragma solidity >=0.6.2;
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
) external returns (uint256 amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint256 liquidity,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline,
bool approveMax,
uint8 v,
bytes32 r,
bytes32 s
) external returns (uint256 amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
pragma solidity >=0.5.0;
interface IUniswapV2Pair {
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(
address indexed sender,
uint256 amount0,
uint256 amount1,
address indexed to
);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);
function mint(address to) external returns (uint256 liquidity);
function burn(address to)
external
returns (uint256 amount0, uint256 amount1);
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
pragma solidity ^0.8.0;
contract EcoFrog is
Initializable,
ERC20Upgradeable,
ERC20BurnableUpgradeable,
OwnableUpgradeable,
UUPSUpgradeable,
ReentrancyGuard
{
constructor() Initializable() {
uniswapRouter = IUniswapV2Router02(
0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24
);
uniswapV2Pair = IUniswapV2Factory(uniswapRouter.factory()).createPair(
address(this),
uniswapRouter.WETH()
);
}
string public constant tokenMetadata =
"https://violet-tremendous-gopher-860.mypinata.cloud/ipfs/bafkreic67cpsfucipfxrk6mxe7eqci22st5g5wa7ag7uzgx5kkymuqkv4u";
string public constant logoURI = "https://i.imgur.com/SxDPk9B.png";
string public constant website = "https://www.froggo.org";
string public constant description =
"$FROGGO is a revolutionary eco-friendly memecoin that transforms the concept of cryptocurrency by directly linking digital assets with real-world environmental impact. Our mission goes beyond the blockchain for every 10,000 transactions, we restore one acre of vital wetland habitat, making a tangible difference in amphibian conservation and ecosystem restoration. Through our innovative NFT collection, P2E game mechanics, and merchandise program, we're creating a sustainable ecosystem that directly supports environmental conservation while building a strong, engaged community of eco-conscious investors.";
uint256 public constant TOTAL_SUPPLY = 10_000_000_000 * 10**18;
uint256 public constant CHARITY_FEE = 1;
uint256 public constant STAKING_FEE = 1;
uint256 public constant LIQUIDITY_FEE = 1;
address public charityWallet;
address public devWallet;
IUniswapV2Router02 public uniswapRouter;
address public immutable uniswapV2Pair;
mapping(address => bool) public marketPair;
uint256 public tokensForLiquidity;
uint256 public swapThreshold;
bool public migrationUnlocked = true;
bool public swapEnabled;
bool private inSwap;
struct Stake {
uint256 amount;
uint256 startTime;
}
mapping(address => Stake[]) public stakes;
uint256 public totalStaked;
mapping(address => bool) public airdropClaimed;
event LiquidityAdded(uint256 tokenAmount, uint256 ethAmount);
event TokensStaked(address indexed user, uint256 amount);
event TokensUnstaked(address indexed user, uint256 amount);
event TransferFeeDistributed(
address indexed sender,
uint256 charityFee,
uint256 stakingFee
);
event AirdropDistributed(address indexed recipient, uint256 amount);
event SwapAndLiquify(uint256 tokensSwapped, uint256 ethReceived);
event Step(string description, uint256 value);
event MigrationLocked();
modifier lockSwap() {
inSwap = true;
_;
inSwap = false;
}
modifier onlyWhenMigrationUnlocked() {
require(migrationUnlocked, "Migration is currently locked");
_;
}
function initialize() external initializer {
__ERC20_init("EcoFrog", "ECO");
__ERC20Burnable_init();
__Ownable_init(msg.sender);
__UUPSUpgradeable_init();
charityWallet = 0xD89E97545D91500c9a70DbE7279cf5A22C32112c;
devWallet = 0xafb9459f50a86dBEf445e2B0BE45CdC8D7E48D02;
_mint(address(this), TOTAL_SUPPLY);
uint256 ecosystemTokens = (TOTAL_SUPPLY * 10) / 100;
_transfer(address(this), charityWallet, ecosystemTokens);
_transfer(address(this), devWallet, ecosystemTokens);
swapThreshold = (TOTAL_SUPPLY * 1) / 100000;
swapEnabled = true;
}
function _authorizeUpgrade(address newImplementation)
internal
override
onlyOwner
{}
function setMarketPair(address pair, bool value) external onlyOwner {
marketPair[pair] = value;
}
function stakeTokens(uint256 amount) external nonReentrant {
require(amount > 0, "Amount must be greater than zero");
require(balanceOf(msg.sender) >= amount, "Insufficient balance");
_transfer(msg.sender, address(this), amount);
stakes[msg.sender].push(Stake(amount, block.timestamp));
totalStaked += amount;
emit TokensStaked(msg.sender, amount);
}
function unstakeTokens(uint256 index) external nonReentrant {
require(index < stakes[msg.sender].length, "Invalid stake index");
Stake memory userStake = stakes[msg.sender][index];
require(
block.timestamp >= userStake.startTime + 1 weeks,
"You must wait at least 1 week before unstaking."
);
uint256 reward = calculateStakingReward(userStake);
uint256 totalAmount = userStake.amount + reward;
_transfer(address(this), msg.sender, totalAmount);
totalStaked -= userStake.amount;
removeStake(msg.sender, index);
emit TokensUnstaked(msg.sender, totalAmount);
}
function calculateStakingReward(Stake memory stake)
public
view
returns (uint256)
{
uint256 stakingDuration = block.timestamp - stake.startTime;
uint256 annualRewardRate = 10;
return
(stake.amount * annualRewardRate * stakingDuration) /
(365 days * 100);
}
function removeStake(address user, uint256 index) internal {
require(index < stakes[user].length, "Invalid index");
stakes[user][index] = stakes[user][stakes[user].length - 1];
stakes[user].pop();
}
function lockMigration() external onlyOwner {
migrationUnlocked = false;
emit MigrationLocked();
}
function migrateFROGGO(uint256 amount)
external
nonReentrant
onlyWhenMigrationUnlocked
{
require(msg.sender != address(0), "Invalid address");
require(amount > 0, "Invalid token amount");
IERC20 oldToken = IERC20(0x01eC5f71BdAdab52ac12eb4d7914C44C251CaE33);
address migrationWallet = 0x398d52114Ea5BADedc71A5B6629b8f6b17f9f726;
bool success = oldToken.transferFrom(msg.sender, migrationWallet, amount);
require(success, "Transfer failed");
_transfer(address(this), msg.sender, amount * 10);
emit Step("FROGGO Deposited", amount);
}
function _safeApprove(address spender, uint256 amount) internal {
if (IERC20(address(this)).allowance(address(this), spender) > 0) {
IERC20(address(this)).approve(spender, 0);
}
IERC20(address(this)).approve(spender, amount);
}
function addECOFROGLiquidity(
address routerAddress,
uint256 ethAmount,
uint256 newTokenAmount
) external {
require(ethAmount > 0, "Invalid ETH amount");
require(newTokenAmount > 0, "Invalid token amount");
IUniswapV2Router02 router = IUniswapV2Router02(routerAddress);
_safeApprove(routerAddress, newTokenAmount);
router.addLiquidityETH{value: ethAmount}(
address(this),
newTokenAmount,
0,
0,
address(this),
block.timestamp
);
emit Step("Liquidity Added", ethAmount);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount)
external
payable
onlyOwner
{
_safeApprove(address(uniswapRouter), tokenAmount);
uniswapRouter.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
tokenAmount * 99 / 100,
ethAmount * 99 / 100,
address(0),
block.timestamp
);
emit LiquidityAdded(tokenAmount, ethAmount);
}
function swapTokensForETH(uint256 tokenAmount) internal returns (uint256) {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapRouter.WETH();
_safeApprove(address(uniswapRouter), tokenAmount);
uint256 initialBalance = address(this).balance;
try uniswapRouter.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
1,
path,
address(this),
block.timestamp
) {
uint256 ethReceived = address(this).balance - initialBalance;
require(ethReceived > 0, "Swap failed: no ETH received");
return ethReceived;
} catch {
revert("Uniswap swap failed");
}
}
function swapBack() private lockSwap {
uint256 contractBalance = balanceOf(address(this));
if (contractBalance == 0 || contractBalance < swapThreshold) return;
uint256 liquidityTokens = (contractBalance * 30) / 100;
uint256 tokensToSwap = contractBalance - liquidityTokens;
uint256 ethReceived = swapTokensForETH(tokensToSwap);
uint256 ethForLiquidity = ethReceived / 2;
if (liquidityTokens > 0 && ethForLiquidity > 0) {
this.addLiquidity(liquidityTokens, ethForLiquidity);
}
emit SwapAndLiquify(tokensToSwap, ethReceived);
}
function claimAirdrop(uint256 amount, address recipient) external onlyOwner {
require(recipient != address(0), "Invalid recipient address");
require(amount > 0, "Amount must be greater than zero");
require(!airdropClaimed[recipient], "Airdrop already claimed");
require(
balanceOf(address(this)) >= amount,
"Not enough tokens for airdrop"
);
airdropClaimed[recipient] = true;
_transfer(address(this), recipient, amount);
emit AirdropDistributed(recipient, amount);
}
function multiAirdrop(address[] calldata recipients, uint256[] calldata amounts) external onlyOwner {
require(recipients.length == amounts.length, "Recipients and amounts length mismatch");
for (uint256 i = 0; i < recipients.length; i++) {
address recipient = recipients[i];
uint256 amount = amounts[i];
require(recipient != address(0), "Invalid recipient address");
require(amount > 0, "Amount must be greater than zero");
require(!airdropClaimed[recipient], "Airdrop already claimed");
require(
balanceOf(address(this)) >= amount,
"Not enough tokens for airdrop"
);
airdropClaimed[recipient] = true;
_transfer(address(this), recipient, amount);
emit AirdropDistributed(recipient, amount);
}
}
function _transfer(
address sender,
address recipient,
uint256 amount
) internal override {
require(amount > 0, "Transfer amount must be greater than zero");
bool isMarketPairTransfer = marketPair[sender] || marketPair[recipient];
uint256 charityFee = (amount * CHARITY_FEE) / 100;
uint256 stakingFee = isMarketPairTransfer
? (amount * STAKING_FEE) / 100
: 0;
uint256 liquidityFee = isMarketPairTransfer
? (amount * LIQUIDITY_FEE) / 100
: 0;
uint256 transferAmount = amount -
charityFee -
stakingFee -
liquidityFee;
if (isMarketPairTransfer) {
tokensForLiquidity += liquidityFee;
super._transfer(sender, address(this), stakingFee + liquidityFee);
}
super._transfer(sender, charityWallet, charityFee);
super._transfer(sender, recipient, transferAmount);
if (!inSwap && swapEnabled && marketPair[recipient]) {
swapBack();
}
emit TransferFeeDistributed(sender, charityFee, stakingFee);
}
receive() external payable {
require(msg.sender == address(uniswapRouter), "Only router can send ETH");
require(msg.value > 0, "No ETH sent");
}
}