// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title Errors Library
library Errors {
////////////////////////////////////////////////////////////////////////////
// Common //
////////////////////////////////////////////////////////////////////////////
/// @notice The caller is not the owner of the contract.
error OwnerInvalid();
////////////////////////////////////////////////////////////////////////////
// ERC20 //
////////////////////////////////////////////////////////////////////////////
/// @notice The token allowance of the sender is insufficient.
error ERC20_SenderAllowanceInsufficient();
/// @notice The balance of the token owner is insufficient.
error ERC20_TokenBalanceInsufficient();
////////////////////////////////////////////////////////////////////////////
// WONDY //
////////////////////////////////////////////////////////////////////////////
/// @notice The token recipient may not own more than 1% of the total supply.
error Wondys_OnePercentTransferLimitExceeded();
////////////////////////////////////////////////////////////////////////////
// Staking //
////////////////////////////////////////////////////////////////////////////
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @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);
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
/// @title Unownable Contract Interface
interface IUnownable {
/// @notice Transfers contract ownership from `prevOwner` to `newOwner`.
/// @param prevOwner The current owner of the contract.
/// @param newOwner The new owner of the contract.
event OwnershipTransferred(address prevOwner, address newOwner);
/// @notice Gets the current owner of the contract.
function owner() external returns (address);
/// @notice Permanently revokes ownership of the underlying contract.
function revokeOwnership() external;
}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import { Errors } from "src/lib/Errors.sol";
import { IUnownable } from "./interfaces/IUnownable.sol";
/// @title Unownable Contract
/// @notice Contract built for irreversible revocation of ownership.
contract Unownable is IUnownable {
/// @notice The current contract owner address.
address public owner;
/// @notice Modifier to ensure message sender is the contract owner.
modifier onlyOwner {
if (msg.sender != owner) {
revert Errors.OwnerInvalid();
}
_;
}
/// @notice Creates the contract, signifying owner transfer to sender.
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
/// @notice Permanently revokes ownership of the underlying contract.
function revokeOwnership() external onlyOwner {
address oldOwner = owner;
owner = address(0);
emit OwnershipTransferred(oldOwner, address(0));
}
}
// SPDX-License-Identifier: MIT
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@@@@@@@@@@@@@%#**++++++++++**#%@@@@@@@@@@@@@@@@@@@@@
// @@@@@@@@@@@@%*=----------------------------------------+%@@@@@@@@@@@@@
// @@@@@@@@+=-----------------------------------------------------=*@@@@@@@@@@
// @@@@@@+---------------------------------------------------------------#@@@@@@@@@
// @@@@+---------------------------------------------------------------------#@@@@@@@@
// @@@@+--------=+**###%%%%%%%%%###**+=------------------------------------------*@@@@@@@
// @@@@+#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=---------------------------------------#@@@@@@
// %%@%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=-------------------------------------=@@@@@@@
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#=------------------------------------@@@@@@@
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*-----------------------------------@@@@@@
// %%%%%%%%%%%%#+*%%%%%%%%%%%%%%%%##%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=--------------------------------=@@@@@@
// %%%%%%%%%%#+---*%%%%%%%%%%%%*+=------+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+-------------------------------=@@@@@@
// %%%%%%*+-----=#%%%%%%%%#+---------------=#%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+-----------=*+----------------%@@@@@
// @%%*=--------+%%%%%*+-----------------------=*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%=---------@*#*#%*-------------@@@@@@
// @@+------------------------------=----=====-------+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%#--------@*#####*%#=---------*@@@@@
// @@=-------------------------------+%#+-------@@@#=----=%%%%%%%%%%%%%%%%%%%%%%%%%%%%%-------@*########*%#-------=@@@@@@
// @@*##**##+-------------------------=#------------*+-------*%%%%%%%%%%%%%%%%%%%%%%%%%%%=-----@*###########%=------@@@@@@
// @@=------#---------------------------+%%####%%#=-------------*%%%%%%%%%%%%%%%%%%%%%%%%%-----@*##########*@-------*@@@@@
// @@+==+*%#=-------==+---------------------------------------------=%%%%%%%%%%%%%%%%%%%%%%%*=--@##########*%--------=@@@@@
// @%----+==---------------======---------------------------------------=#%%%%%%%%%%%%%%%%%%%%%@*##*%######%----------@@@@@
// @#-=--=--========+*%%*-------+%=----------=----=--------------------------*%%%%%%%%%%%%%%%%%####*%##*%*-----------@@@@@
// @@=-----*---------------------+----------------------------------------------#-+#%%%%%%%%%%######%%#------------=@@@@
// @@%=--=@-------------------#=-----------------------------------------------*=------+%%%#######%%%%%%%=-------+@@@@
// %%%%*--=@=--------------#**=------------------------------------------------#+-------*#@#*##%%%%%%%%%%%%%%+--%@@@@
// %%%%%%%%%%#+=%@@@@@@@#=----=+---------=*#%%#*=--------------------------------++-----+%######%%%%%%%%%%%%%%%%@@@@@%
// @%%%%%%%%%%%%%%%%@#%@@@@@@@@@@%#+-----------------%#-----------------------------#----%######*#+%%%%%%%%%%%%%%%%%%%%%%
// %%%%%%%%%%%%%%@@@@*----------------------------------#=---------------------------@--########%=-#%%%%%%%%%%%%%%%%%%%
// @%@ %%%%%%%%%%%%%%%%@@@@*-----------------------------------%=--------------------------%=--#%*###@---*%%%%%%%%%%%%%%%%%%%%
// @####%@ @%%%%%%%%%%%%%% @@@@@@-----------------------------------=#--------------------------+*----%%#=----%%%%%%%%%%%%%%%%%%%%%%
// @########@@ %%%%%%%%%%%%%%% @@@@@+-----------------------------------#---------------------------%------------#%%%%%%%%%%%%%%%%%%%%%%
// @###########@ %%%%%%%%%%%%% @@@@@@-----------------------------------*=--------------------------*+-----------#%%%%%%%%%%%%%%%%%%%%
// @*#############@@@%%%%%%%%%%%% @@@@@@@---------------------------------*@+----#@=----=@+------+*#---=%#@---------#%%%%%%%%%%%%%
// @*###########*%##*#@@@@%%%% @@@@@@@*-----------------------------=#-@--=%--#=--=#--#=----@--=#--=@-*=---------*@@%%%%%%%%%%
// @*#########*#@%#@#*####@#%@@@@@ @@@@@@@*--------------------------#---%=%----++-#=---=%--#-----+##---=*--------+@@@@@@%%%%%%
// @@@@@@@@@@%%%%%%%%@###%@#####**##%@ @@@@@@@@*---------------------%=----*------=@=------*+*------*#+----%-----*@@@@@@ %%%%%
// %%%%%%%%%%%%%%%%*############@ @@@@@@@@@%*--------------+=----#+----=%####%+----+*------*##+----#=#@@@@@@@@ %%%
// %%%%%%%%%%%%%%%%% @@%########*@@ @@@@@@@@@@@@@#*=----+*----=#=----*#*#*#%-----##*-----*###--*@@@@@@@@@@ %%%%%%
// %%%%%%%%%%%%%%%%%%% @@@######@ @@@@@@@@@@@@@@@@@%%###+==----=+=------=***--=+*#%@@@@@@@@@@@@ %%%%%%%
// %%%%%%%%%%%%%%%%%%%%%% @@###@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ %%%% %%%%%%%
//%%%%%%%%%%%%%%%%%%%%%%% @@ %%%% @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ %%%%%% %%%%%%%
//%% %%%%%%%%%%%%% %%%%%% %%%%% %%% %%% %%%%%%% %%%%%% %%%%%%%%
// %%%%%%%%%%%%%% %%%%% %%%%%% %%%%%%% %% % %%%%%%%%%%%%%%%%%% %%%%%%% %%%%% %%%%%%%%%%%%
// %%%%%%%%%%%%%% %%%%% %%%%% %%%%%%%%%%%%%% %%%%%% %%%%% %%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%
// %%%%%% @%%%%% %%%%%% %%%%%% %%%%%%%%%%%%%%%%% %%%%%% %%%%%% %%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%% %%%%
// %%%@ %%%%% %%%%%% %%%%%%% %%%%%%%%%%%%%%%%% %%%%%%%% %%%%%% %%%%% %%%%%% %%%%%%%% %%%%%%%%%%%%%%
// %%%% %%%%% %%%%%%%%% %%%%%%%%%%% %%%%%% %%%%%%%% %%%%% %%%%% %%%%%% %%%%%%% %%%%%%%%%%%%%%%%
// %%@ %%%%% %%%%%%%%%%%%%%%%%%%%% %%%%% %%%%%%%%%%%%%% %%%%%% %%%%%% %%%%%% %%%%%%%%%%%
// % %%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% %%%%%% %%%%%% %%%%%% %%%%% %%%%%%
// %%%%%%%%%% %%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%%%% %%%%%%
// ser, dis is a %%%%%%%%% %%%%%%%%% %%%%%% %%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%% %%%%%% %%%%%%%% %%%%%%%%
// %%%%%%%% %%%%%%%% %%%%%% %%%%%%% %%%%% %%%%%%% %%%%%%%%%% %%%%% %%%%%%%%% %%%%%%%%%
// %%%%% %%%%%%%% %%%%%%%%%%%%% %%%%%% %%%% %%%%%%%% %%%%% %%%%%%%%%%%%%%%%%%%%%%
// %%%%% %%%%%%%%%% %%%% %%%%%% %%%%% %%%%%%%%%%%%%%%%
// %%%%%%% %% %%%%%%%%%
//
// apply tu be a wondys ehmployee at https://wondys.xyz
//
pragma solidity ^0.8.24;
import { IERC20Metadata } from "openzeppelin-contracts/token/ERC20/extensions/IERC20Metadata.sol";
import { Errors } from "src/lib/Errors.sol";
import { Unownable } from "src/Unownable.sol";
/// @title Wondys Contract
contract Wondys is IERC20Metadata, Unownable {
/// @notice Gets the token balance for an owner address.
mapping(address owner => uint256) public balanceOf;
/// @notice Gets the token allowance of a spender on behalf of an owner.
mapping(address owner => mapping(address spender => uint256)) public allowance;
/// @notice Gets the total supply of the token.
uint256 public totalSupply;
/// @notice Gets the name of the token.
string public constant name = "Wondys";
/// @notice Gets the symbol of the token.
string public constant symbol = "WONDY";
/// @notice Gets the number of token decimals, fixed to 18.
uint8 public constant decimals = 18;
/// @notice Returns whether the 1% transfer limit is being enforced.
bool public onePercentLimitEnforced = true;
/// @notice Returns the address of the $WONDY LP (or zero if not assigned).
address public lp;
constructor() {
_mint(msg.sender, 888_624_814 * 1e18);
}
/// @notice Sets whether or not the one percent transfer limit is enforced.
/// @param enforced Whether or not to enforce the 1% transfer limit.
function setOnePercentLimitEnforced(bool enforced) external onlyOwner {
onePercentLimitEnforced = enforced;
}
/// @notice Enable trading by setting the LP address pair.
/// @param liquidityPool Address of the $WONDY LP contract.
function setLP(address liquidityPool) external onlyOwner {
require(lp == address(0), "Wondys: LP already set");
lp = liquidityPool;
}
/// @notice Burns `amount` tokens owned by the message sender.
function burn(uint256 amount) public {
_burn(msg.sender, amount);
}
/// @notice Approves a spender to spend tokens on behalf of the sender.
/// @param spender The address of the spender being granted an allowance.
/// @param amount The token amount being granted for the spender allowance.
/// @return Whether or not the approval was successful.
function approve(address spender, uint256 amount) public returns (bool) {
allowance[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
/// @notice Transfers `amount` tokens from sender to recipient address `to`.
/// @param to The address of the recipient receiving the tokens.
/// @param amount The number of tokens being transferrd to the recipient.
/// @return Whether the transfer was successful or not.
function transfer(address to, uint256 amount) public returns (bool) {
_transfer(msg.sender, to, amount);
return true;
}
/// @notice Transfers `amount` tokens from address `from` to address `to`.
/// @param from The address of the owner whose tokens are being transferred.
/// @param to The recipient address of the token transfer.
/// @param amount The number of tokens being transferred.
/// @return Whether the transfer was successful or not.
function transferFrom(address from, address to, uint256 amount) public returns (bool) {
uint256 senderAllowance = allowance[from][msg.sender];
if ((senderAllowance) != type(uint256).max) {
if (senderAllowance < amount) {
revert Errors.ERC20_SenderAllowanceInsufficient();
}
unchecked {
allowance[from][msg.sender] = senderAllowance - amount;
}
}
_transfer(from, to, amount);
return true;
}
/// @dev Validates whether a transfer is valid or not.
/// @param to The recipient address of the token transfer.
function _validateTransfer(address, address to, uint256) internal view {
if (onePercentLimitEnforced && to != lp && balanceOf[to] * 100 > totalSupply) {
revert Errors.Wondys_OnePercentTransferLimitExceeded();
}
}
/// @dev Transfers tokens from address `from` to address `to`.
/// @param from The address of the owner whose tokens are being transferred.
/// @param to The recipient address of the token transfer.
/// @param amount The number of tokens being transferred.
function _transfer(address from, address to, uint256 amount) internal {
uint256 balance = balanceOf[from];
if (balance < amount) {
revert Errors.ERC20_TokenBalanceInsufficient();
}
unchecked {
balanceOf[from] -= amount;
balanceOf[to] += amount;
}
_validateTransfer(from, to, amount);
emit Transfer(from, to, amount);
}
/// @dev Mints `amount` tokens to recipient address `to`.
/// @param to The address receiving the minted tokens.
/// @param amount The number of tokens to mint to address `to`.
function _mint(address to, uint256 amount) internal {
totalSupply += amount; // Only place overflow of supply must be checked.
unchecked {
balanceOf[to] += amount;
}
emit Transfer(address(0), to, amount);
}
/// @dev Burns `amount` tokens owned by address `from`.
/// @param from The address whose tokens are being burned.
/// @param amount The number of tokens to burn.
function _burn(address from, uint256 amount) internal {
uint256 balance = balanceOf[from];
if (balance < amount) {
revert Errors.ERC20_TokenBalanceInsufficient();
}
unchecked {
balanceOf[from] -= amount;
totalSupply -= amount;
}
emit Transfer(from, address(0), amount);
}
}
{
"compilationTarget": {
"src/Wondys.sol": "Wondys"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 20000
},
"remappings": [
":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
":ds-test/=lib/forge-std/lib/ds-test/src/",
":erc4626-tests/=lib/joe-v2/lib/openzeppelin-contracts/lib/erc4626-tests/",
":forge-std/=lib/forge-std/src/",
":joe-v2/test/=lib/joe-v2/test/",
":openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
":openzeppelin/=lib/joe-v2/lib/openzeppelin-contracts/contracts/"
]
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ERC20_SenderAllowanceInsufficient","type":"error"},{"inputs":[],"name":"ERC20_TokenBalanceInsufficient","type":"error"},{"inputs":[],"name":"OwnerInvalid","type":"error"},{"inputs":[],"name":"Wondys_OnePercentTransferLimitExceeded","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"prevOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lp","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onePercentLimitEnforced","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"revokeOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"liquidityPool","type":"address"}],"name":"setLP","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enforced","type":"bool"}],"name":"setOnePercentLimitEnforced","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]